org.fcrepo.server.journal.readerwriter.multicast
Class MulticastJournalWriter

java.lang.Object
  extended by org.fcrepo.server.journal.xmlhelpers.AbstractXmlWriter
      extended by org.fcrepo.server.journal.JournalWriter
          extended by org.fcrepo.server.journal.readerwriter.multicast.MulticastJournalWriter
All Implemented Interfaces:
JournalConstants, TransportParent

public class MulticastJournalWriter
extends JournalWriter
implements TransportParent

SYNCHRONIZATION NOTE: All public methods are synchronized against JournalWriter.SYNCHRONIZER, as is the closeFile method. This means that an asynchronous call by the timer task will not interrupt a synchronous operation already in progress, or vice versa.

Author:
jblake

Field Summary
static String CLASSNAME_PARAMETER_KEY
          Required parameter for each transport: the full name of the class that implements the transport.
static String CRUCIAL_PARAMETER_KEY
          Required parameter for each transport, and must be set to "true" on at least one transport.
static String TRANSPORT_PARAMETER_PREFIX
          prefix that indicates a transport parameter - must include the separator character, if one is expected.
 
Fields inherited from class org.fcrepo.server.journal.JournalWriter
parameters, role, server, SYNCHRONIZER
 
Fields inherited from interface org.fcrepo.server.journal.JournalConstants
ARGUMENT_NAME_ALT_IDS, ARGUMENT_NAME_CHECKSUM, ARGUMENT_NAME_CHECKSUM_TYPE, ARGUMENT_NAME_CONTEXT, ARGUMENT_NAME_CONTROL_GROUP, ARGUMENT_NAME_DATATYPE, ARGUMENT_NAME_DISSEMINATOR_ID, ARGUMENT_NAME_DISSEMINATOR_LABEL, ARGUMENT_NAME_DISSEMINATOR_STATE, ARGUMENT_NAME_DS_CONTENT, ARGUMENT_NAME_DS_ID, ARGUMENT_NAME_DS_LABEL, ARGUMENT_NAME_DS_LOCATION, ARGUMENT_NAME_DS_STATE, ARGUMENT_NAME_ENCODING, ARGUMENT_NAME_END_DATE, ARGUMENT_NAME_FORCE, ARGUMENT_NAME_FORMAT, ARGUMENT_NAME_FORMAT_URI, ARGUMENT_NAME_IN, ARGUMENT_NAME_IS_LITERAL, ARGUMENT_NAME_LABEL, ARGUMENT_NAME_LAST_MODIFIED_DATE, ARGUMENT_NAME_LOCATION, ARGUMENT_NAME_LOG_MESSAGE, ARGUMENT_NAME_MIME_TYPE, ARGUMENT_NAME_NAMESPACE, ARGUMENT_NAME_NEW_PID, ARGUMENT_NAME_NUM_PIDS, ARGUMENT_NAME_OBJECT, ARGUMENT_NAME_OWNERID, ARGUMENT_NAME_PID, ARGUMENT_NAME_RELATIONSHIP, ARGUMENT_NAME_SERIALIZATION, ARGUMENT_NAME_START_DATE, ARGUMENT_NAME_STATE, ARGUMENT_NAME_VERSION_DATE, ARGUMENT_NAME_VERSIONABLE, ARGUMENT_TYPE_BINDING_MAP, ARGUMENT_TYPE_BOOLEAN, ARGUMENT_TYPE_DATE, ARGUMENT_TYPE_INTEGER, ARGUMENT_TYPE_NULL, ARGUMENT_TYPE_STREAM, ARGUMENT_TYPE_STRING, ARGUMENT_TYPE_STRINGARRAY, CONTEXT_MAPNAME_ACTION, CONTEXT_MAPNAME_ENVIRONMENT, CONTEXT_MAPNAME_RECOVERY, CONTEXT_MAPNAME_RESOURCE, CONTEXT_MAPNAME_SUBJECT, DEFAULT_AGE_LIMIT, DEFAULT_FILENAME_PREFIX, DEFAULT_SIZE_LIMIT, DOCUMENT_ENCODING, DOCUMENT_VERSION, FORMAT_JOURNAL_FILENAME_TIMESTAMP, METHOD_ADD_DATASTREAM, METHOD_ADD_DISSEMINATOR, METHOD_ADD_RELATIONSHIP, METHOD_GET_NEXT_PID, METHOD_INGEST, METHOD_MODIFY_DATASTREAM_BY_REFERENCE, METHOD_MODIFY_DATASTREAM_BY_VALUE, METHOD_MODIFY_DISSEMINATOR, METHOD_MODIFY_OBJECT, METHOD_PURGE_DATASTREAM, METHOD_PURGE_DISSEMINATOR, METHOD_PURGE_OBJECT, METHOD_PURGE_RELATIONSHIP, METHOD_PUT_TEMP_STREAM, METHOD_SET_DATASTREAM_STATE, METHOD_SET_DATASTREAM_VERSIONABLE, METHOD_SET_DISSEMINATOR_STATE, PARAMETER_IGNORE_HASH, PARAMETER_JOURNAL_FILE_AGE_LIMIT, PARAMETER_JOURNAL_FILE_SIZE_LIMIT, PARAMETER_JOURNAL_FILENAME_PREFIX, PARAMETER_JOURNAL_MODE, PARAMETER_JOURNAL_READER_CLASSNAME, PARAMETER_JOURNAL_RECOVERY_LOG_CLASSNAME, PARAMETER_JOURNAL_WRITER_CLASSNAME, PARAMETER_RECOVERY_LOG_FILENAME, PARAMETER_RECOVERY_LOG_LEVEL, PASSWORD_CIPHER_TYPE, QNAME_ATTR_BIND_KEY_NAME, QNAME_ATTR_BIND_LABEL, QNAME_ATTR_CLIENT_IP, QNAME_ATTR_DATASTREAM_ID, QNAME_ATTR_DS_BIND_MAP_ID, QNAME_ATTR_DS_BIND_MAP_LABEL, QNAME_ATTR_DS_BIND_MECHANISM_PID, QNAME_ATTR_LOGIN_ID, QNAME_ATTR_METHOD, QNAME_ATTR_NAME, QNAME_ATTR_PASSWORD_TYPE, QNAME_ATTR_REPOSITORY_HASH, QNAME_ATTR_SEQ_NO, QNAME_ATTR_STATE, QNAME_ATTR_TIMESTAMP, QNAME_ATTR_TYPE, QNAME_ATTR_USERID, QNAME_TAG_ARGUMENT, QNAME_TAG_ARRAYELEMENT, QNAME_TAG_CONTEXT, QNAME_TAG_DS_BINDING, QNAME_TAG_DS_BINDING_MAP, QNAME_TAG_JOURNAL, QNAME_TAG_JOURNAL_ENTRY, QNAME_TAG_MULTI_VALUE_MAP, QNAME_TAG_MULTI_VALUE_MAP_KEY, QNAME_TAG_MULTI_VALUE_MAP_VALUE, QNAME_TAG_NOOP, QNAME_TAG_NOW, QNAME_TAG_PASSWORD, SYSTEM_PROPERTY_PREFIX, TIMESTAMP_FORMAT, VALUE_FALSE, VALUE_JOURNAL_MODE_NORMAL, VALUE_JOURNAL_MODE_RECOVER, VALUE_RECOVERY_LOG_LEVEL_HIGH, VALUE_RECOVERY_LOG_LEVEL_LOW, VALUE_RECOVERY_LOG_LEVEL_MEDIUM, VALUE_TRUE
 
Constructor Summary
MulticastJournalWriter(Map<String,String> parameters, String role, ServerInterface server)
           
 
Method Summary
protected  void checkTransportParametersForValidity()
          "protected" so we can mock it out in unit tests.
protected  Date getCurrentDate()
          protected, so it can be mocked out for unit testing.
 void prepareToWriteJournalEntry()
           Get ready to write a journal entry, insuring that we have an open file.
 void shutdown()
           Shut it down
 void writeDocumentHeader(XMLEventWriter writer, String repositoryHash, Date currentDate)
          make this public so the Transport classes can call it via TransportParent.
 void writeDocumentTrailer(XMLEventWriter writer)
          make this public so the Transport classes can call it via TransportParent.
 void writeJournalEntry(CreatorJournalEntry journalEntry)
           Write a journal entry.
 void writeJournalEntry(CreatorJournalEntry journalEntry, XMLEventWriter writer)
          make this public, so the TransportRequest class can call it.
 
Methods inherited from class org.fcrepo.server.journal.JournalWriter
getInstance, writeDocumentHeader
 
Methods inherited from class org.fcrepo.server.journal.xmlhelpers.AbstractXmlWriter
putAttribute, putAttributeIfNotNull, putCharacters, putEndDocument, putEndTag, putStartDocument, putStartTag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRANSPORT_PARAMETER_PREFIX

public static final String TRANSPORT_PARAMETER_PREFIX
prefix that indicates a transport parameter - must include the separator character, if one is expected.

See Also:
Constant Field Values

CLASSNAME_PARAMETER_KEY

public static final String CLASSNAME_PARAMETER_KEY
Required parameter for each transport: the full name of the class that implements the transport.

See Also:
Constant Field Values

CRUCIAL_PARAMETER_KEY

public static final String CRUCIAL_PARAMETER_KEY
Required parameter for each transport, and must be set to "true" on at least one transport.

See Also:
Constant Field Values
Constructor Detail

MulticastJournalWriter

public MulticastJournalWriter(Map<String,String> parameters,
                              String role,
                              ServerInterface server)
                       throws JournalException
Throws:
JournalException
Method Detail

checkTransportParametersForValidity

protected void checkTransportParametersForValidity()
                                            throws JournalException
"protected" so we can mock it out in unit tests.

Throws:
JournalException

prepareToWriteJournalEntry

public void prepareToWriteJournalEntry()
                                throws JournalException

Get ready to write a journal entry, insuring that we have an open file.

If we are shutdown, ignore this request. Otherwise, check if we need to shut a file down based on size limit. Then check to see whether we need to open another file. If so, we'll need a repository hash and a filename.

Specified by:
prepareToWriteJournalEntry in class JournalWriter
Throws:
JournalException
See Also:
JournalWriter.prepareToWriteJournalEntry()

writeJournalEntry

public void writeJournalEntry(CreatorJournalEntry journalEntry)
                       throws JournalException

Write a journal entry.

If we are shutdown, ignore this request. Otherwise, get an output stream from each Transport in turn, and write the entry. If this puts the file size over the limit, close them.

Specified by:
writeJournalEntry in class JournalWriter
Throws:
JournalException
See Also:
JournalWriter.writeJournalEntry(org.fcrepo.server.journal.entry.CreatorJournalEntry)

shutdown

public void shutdown()
              throws JournalException

Shut it down

If the Transports still have files open, close them. Then stop responding to requests.

Specified by:
shutdown in class JournalWriter
Throws:
JournalException
See Also:
JournalWriter.shutdown()

getCurrentDate

protected Date getCurrentDate()
protected, so it can be mocked out for unit testing.


writeJournalEntry

public void writeJournalEntry(CreatorJournalEntry journalEntry,
                              XMLEventWriter writer)
                       throws JournalException
make this public, so the TransportRequest class can call it.

Overrides:
writeJournalEntry in class JournalWriter
Throws:
JournalException

writeDocumentHeader

public void writeDocumentHeader(XMLEventWriter writer,
                                String repositoryHash,
                                Date currentDate)
                         throws JournalException
make this public so the Transport classes can call it via TransportParent.

Specified by:
writeDocumentHeader in interface TransportParent
Overrides:
writeDocumentHeader in class JournalWriter
Throws:
JournalException

writeDocumentTrailer

public void writeDocumentTrailer(XMLEventWriter writer)
                          throws JournalException
make this public so the Transport classes can call it via TransportParent.

Specified by:
writeDocumentTrailer in interface TransportParent
Overrides:
writeDocumentTrailer in class JournalWriter
Throws:
JournalException


Copyright © 2011 DuraSpace. All Rights Reserved.