org.jboss.system.server.profileservice.repository.clustered.local.file
Class AddContentStreamAction

java.lang.Object
  extended by org.jboss.system.server.profileservice.repository.clustered.sync.AbstractSynchronizationAction<T>
      extended by org.jboss.system.server.profileservice.repository.clustered.sync.AbstractContentMetadataMutatorAction<FileBasedSynchronizationActionContext>
          extended by org.jboss.system.server.profileservice.repository.clustered.local.file.AbstractLocalContentChangeAction
              extended by org.jboss.system.server.profileservice.repository.clustered.local.file.AbstractFileWriteAction
                  extended by org.jboss.system.server.profileservice.repository.clustered.local.file.AddContentStreamAction
All Implemented Interfaces:
SynchronizationAction<FileBasedSynchronizationActionContext>, SynchronizationReadAction<FileBasedSynchronizationActionContext>, TwoPhaseCommitAction<FileBasedSynchronizationActionContext>

public class AddContentStreamAction
extends AbstractFileWriteAction
implements SynchronizationReadAction<FileBasedSynchronizationActionContext>

SynchronizationReadAction that reads from a InputStream and besides returning ByteChunks, also writes the stream contents to a local file. Used for pushing content from a stream to both the cluster and the local filesystem.

Version:
$Revision: $
Author:
Brian Stansberry

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jboss.system.server.profileservice.repository.clustered.sync.AbstractSynchronizationAction
AbstractSynchronizationAction.State
 
Field Summary
static int MAX_CHUNK_BUFFER_SIZE
          Max file transfer buffer size that we read at a time.
 
Constructor Summary
AddContentStreamAction(InputStream stream, File targetFile, FileBasedSynchronizationActionContext context, ContentModification modification)
          Create a new StreamReadAction.
 
Method Summary
protected  void doCancel()
           
protected  void doCommit()
           
protected  void doComplete()
           
protected  boolean doPrepare()
           
protected  void doRollbackFromCancelled()
           
protected  void doRollbackFromOpen()
           
protected  void doRollbackFromRollbackOnly()
           
protected  org.jboss.logging.Logger getLogger()
           
 ByteChunk getNextBytes()
          Gets the next chunk of bytes from the item associated with this action.
 
Methods inherited from class org.jboss.system.server.profileservice.repository.clustered.local.file.AbstractFileWriteAction
modifyTarget, safeCleanup, writeBytes
 
Methods inherited from class org.jboss.system.server.profileservice.repository.clustered.local.file.AbstractLocalContentChangeAction
createTempFile, doRollbackFromComplete, doRollbackFromPrepared, getTargetFile, safeCleanup
 
Methods inherited from class org.jboss.system.server.profileservice.repository.clustered.sync.AbstractContentMetadataMutatorAction
rollbackContentMetadata, updateContentMetadata
 
Methods inherited from class org.jboss.system.server.profileservice.repository.clustered.sync.AbstractSynchronizationAction
cancel, commit, complete, getContext, getMarkedRemovedItem, getRepositoryContentModification, getState, isCancelled, isComplete, prepare, rollback
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.system.server.profileservice.repository.clustered.sync.SynchronizationAction
cancel, complete, getContext, getRepositoryContentModification, isCancelled, isComplete
 

Field Detail

MAX_CHUNK_BUFFER_SIZE

public static final int MAX_CHUNK_BUFFER_SIZE
Max file transfer buffer size that we read at a time. This influences the number of times that we will invoke disk read/write file operations versus how much memory we will consume for a file transfer.

See Also:
Constant Field Values
Constructor Detail

AddContentStreamAction

public AddContentStreamAction(InputStream stream,
                              File targetFile,
                              FileBasedSynchronizationActionContext context,
                              ContentModification modification)
Create a new StreamReadAction.

Parameters:
stream - the stream to read
context - the overall context of the modification
modification - the modification
Method Detail

getNextBytes

public ByteChunk getNextBytes()
                       throws IOException
Description copied from interface: SynchronizationReadAction
Gets the next chunk of bytes from the item associated with this action. Each call to this method will retrieve more bytes

Specified by:
getNextBytes in interface SynchronizationReadAction<FileBasedSynchronizationActionContext>
Returns:
a ByteChunk.
Throws:
IOException - if there is a problem reading the bytes.

getLogger

protected org.jboss.logging.Logger getLogger()
Specified by:
getLogger in class AbstractLocalContentChangeAction

doCancel

protected void doCancel()
Overrides:
doCancel in class AbstractLocalContentChangeAction

doCommit

protected void doCommit()
Overrides:
doCommit in class AbstractLocalContentChangeAction

doComplete

protected void doComplete()
                   throws Exception
Overrides:
doComplete in class AbstractFileWriteAction
Throws:
Exception

doPrepare

protected boolean doPrepare()
Overrides:
doPrepare in class AbstractLocalContentChangeAction

doRollbackFromCancelled

protected void doRollbackFromCancelled()
Overrides:
doRollbackFromCancelled in class AbstractLocalContentChangeAction

doRollbackFromOpen

protected void doRollbackFromOpen()
Overrides:
doRollbackFromOpen in class AbstractLocalContentChangeAction

doRollbackFromRollbackOnly

protected void doRollbackFromRollbackOnly()
Overrides:
doRollbackFromRollbackOnly in class AbstractLocalContentChangeAction


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.