public class FileTransferAgent<C extends ClientContext,S extends ServerContext> extends AbstractCommonAgent<C,S> implements PrintableAgent, TaskEvent.Source
FileTransferJobs which it contains.
It builds a FileTransferJobList, checks the validity of the content on client and server and
if both succeed, starts a FileTransferClientTask for performing the up/downloads via the transfer Channel.
A file transfer runs asynchronously by default but this can be controlled with setTransferAsync(boolean).
You may also automatically acquire a ResourceLock with setTransferLocked(boolean).
Note that if a locked transfer is being run synchronously the client would not be able
to retrigger the lock. Therefore retriggering is disabled for this case and the lock will never
time out on the server.
| Constructor and Description |
|---|
FileTransferAgent(C clientCtx) |
FileTransferAgent(C clientCtx,
boolean isTransferAsync) |
FileTransferAgent(C clientCtx,
java.lang.String jobName) |
FileTransferAgent(C clientCtx,
java.lang.String jobName,
boolean isTransferAsync) |
| Modifier and Type | Method and Description |
|---|---|
void |
addJob(FileTransferJob job) |
void |
addTaskListener(TaskEvent.Listener l) |
void |
awaitClientCommit()
Blocks the calling thread until the commit was received by the server
|
void |
clearClientParams()
Clears the parameters in the client cache that have been set by this agent.
|
void |
clearJobs() |
protected AgentId |
createAgentId(SessionId sessId) |
void |
doInitiallyOnClient()
Is executed just before the agent is being sent to the server.
|
void |
doOnClientSideCancellation()
Is called by the
TaskManager when an AgentId is being cancelled. |
void |
doOnResponseConfirmed()
Is called on an agent when it was received in a
NetResponse AFTER the response
has been confirmed to the server. |
void |
doOnServerSideCancellation()
Is called by the
AgentExecutorTask when a cancellation has been detected. |
boolean |
equals(java.lang.Object obj)
Evaluates equality by comparing the AgentId object.
|
void |
executeForResponse()
Performs the initial check on the servers target directory.
|
void |
executeOnServer()
This is the agent's main execution method called on the server.
|
TransferAgentId |
getAgentId()
Returns a server side unique identifier.
|
java.lang.Object |
getArgument()
Returns the optional argument of this agent.
|
<T> T |
getClientParam(java.lang.String key)
Fetches an agent specific parameter from the client cache.
|
java.util.Map |
getClientParams()
Allows an async agent to store an Agent-specific parameter in a client cache.
|
FileTransferClientTask |
getClientTask() |
java.lang.Exception |
getError()
Returns the Exception that may have been raised during agent execution on the server.
|
int |
getJobCount() |
JobId |
getJobId() |
FileTransferJobList |
getJobList() |
java.lang.String |
getJobName() |
java.lang.String |
getName()
Returns a meaningful name for debugging purposes.
|
SessionId |
getOwnerSessionId()
Returns session id of the actual originator client
(which cannot be a CoClient, but just a normal client)
|
int |
getPriority()
Returns the thread priority which is used to execute this agent
|
long |
getProcessingDuration()
Returns the time (in millis) it has taken to process the agent on server side.
|
long |
getReceivedTime()
Tells when the agent was received by the client
|
protected java.lang.String |
getResourceName()
Is used as the resource name for locking if locking us used
|
protected ResourceType |
getResourceType() |
int |
getResponseTimeout()
Returns the desired timeout (in seconds) that should apply to this agent, or 0 if no timeout
should be used.
|
long |
getSentTime()
Tells when the agent was sent by the client
|
SessionId |
getSessionId()
Returns the SessionId of the owner of this agent
|
java.lang.String |
getTargetServer()
Returns the target server if one is set.
|
TaskId |
getTaskId()
Returns the unique identifier for this task.
|
long |
getTotalDuration()
Returns the time (in millis) it has taken from sending to finishing postprocessing of the agent.
|
long |
getTransferDuration()
Returns the time (in millis) it has taken from sending to receiving the agent.
|
protected int |
getZippedArgumentLength() |
boolean |
hasClientParam(java.lang.String key)
Checks whether an agent specific parameter exists in the client cache.
|
boolean |
hasError()
Tells whether the agent had an Exception during execution on server side.
|
int |
hashCode() |
boolean |
hasRun()
Tells whether this agent has been executed on the server.
|
boolean |
isPartialResultsEnabled()
Tells whether the agent supports partial results.
|
boolean |
isReceived()
Tells whether this agent yet has been received by the client.
|
boolean |
isReceivedInMessage()
Returns true if the agent has been received within a message.
|
boolean |
isReceivedInResponse()
Returns true if the agent has been received within a response.
|
boolean |
isRejectable()
Tells whether this agent can be rejected when the server is on heavy load.
|
boolean |
isTransferAsync() |
boolean |
isTransferLocked() |
void |
logDebug(java.lang.String message) |
void |
logDump(java.lang.String message) |
void |
logError(java.lang.String message) |
void |
logError(java.lang.String message,
java.lang.Exception error) |
void |
logFatal(java.lang.String message,
java.lang.Exception error) |
void |
logInfo(java.lang.String message) |
void |
logVerbose(java.lang.String message) |
void |
logWarning(java.lang.String message) |
void |
processCommitMessage()
Is called directly by the MessageReceiveThread before message postprocessing is done
|
void |
putClientParam(java.lang.String key,
java.lang.Object value)
Putting a null value results in removing the key
|
void |
removeTaskListener(TaskEvent.Listener l) |
boolean |
sendForBooleanExecution()
Same as
Agent.sendForExecution() but does not return the agent, rather it returns true if
the agent has successfully being processed, false otherwise. |
FileTransferAgent |
sendForExecution()
Sends the agent to the server for execution and returns the readily processed agent.
|
<A extends Agent<C,S>> |
sendForSilentExecution()
Same as
Agent.sendForExecution() just without throwing an Exception. |
void |
setArgument(java.lang.Object arg)
Besides any internal variables the agent may optionally carry an arbitrary argument.
|
void |
setArgument(java.lang.Object arg,
boolean doZip)
Same as setArgument(Object) but compresses the argument to a zipped byte array.
|
void |
setFailed(java.lang.Exception error)
Sets the internal Exception of the Agent.
|
void |
setFinished()
Is called by the server to mark this agent as being processed and stores the processing
duration.
|
void |
setName(java.lang.String agentName)
Sets a meaningful name for debugging purposes.
|
void |
setOwnerSessionId(SessionId origSessId)
Sets the sessionId of the user who creates the agent
|
void |
setPartialResultsEnabled(boolean isEnabled)
Tells whether the agent supports partial results.
|
void |
setPriority(int priority)
Sets the thread priority which is used to execute this agent
|
void |
setReceivedInMessage(boolean isReceivedInMessage)
Is set when this agent has been received within a message
|
void |
setReceivedTime(long receivedTime)
Is called by the client when the agent is received
|
void |
setRejectable(boolean state)
If set to false, then the agent cannot be rejected by the server even if the server is on
heavy load.
|
void |
setResponseTimeout(int seconds)
Sets the response timeout in seconds.
|
void |
setRollbackEnabled(boolean isRollbackEnabled) |
void |
setSentTime(long sentTime)
Is called by the client when the agent is sent
|
void |
setServerContext(S serverCtx)
Sets the server runtime environment
|
void |
setSessionId(SessionId sessId)
Allows for setting the SessionId of this agent
|
void |
setTargetServer(java.lang.String targetServer)
Sets the target server.
|
void |
setTransferAsync(boolean isAsync)
Tells whether the caller should block until the file transfer has finished.
|
void |
setTransferLocked(boolean isLocked)
Enforces fetching an exclusive lock on the server prior to starting the transfer.
|
DumpString |
toDumpString(DumpString s)
This method creates a multi line debug output to display the full content of the agent.
|
ToString |
toString(ToString s)
This method creates a single line debug output to display the most important properties of the agent
|
acquireAsExclusiveLock, getLock, hasLock, isAutoReleaseLock, lockDataSource, lockDataSourcePool, lockExclusive, lockExclusive, lockExclusive, lockExclusive, lockShared, lockShared, lockShared, releaseLock, releaseLock, setAutoReleaseLock, setLockcheckCancelled, checkPermission, doFinallyOnClient, doFinallyOnServer, doInitiallyOnServer, doOnMessageError, doOnMessageReceived, doOnResponseError, doOnResponseReceived, getKillerSessionId, getMessageTimeout, getRenderColor, getRenderIcon, getRenderText, isAsync, isIgnoreMessageError, isNoReturn, isTimedOut, setAsync, setCancelledBy, setIgnoreMessageError, setMessageTimeout, setNoReturn, sleepChecked, wasCancelledcheckOnClient, checkOnServer, getClientContext, getLogChannel, getServerContext, isLogDebug, isLogVerbose, isOnClient, isOnServer, setClientContext, setLogChannelclone, deepCloneconfigureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitgetSessionIdclearClientParams, getArgument, getClientParam, getClientParams, getError, getName, getOwnerSessionId, getPriority, getResponseTimeout, getSessionId, getTargetServer, hasClientParam, hasError, hasRun, isPartialResultsEnabled, isReceived, isReceivedInMessage, isReceivedInResponse, isRejectable, putClientParam, sendForBooleanExecution, sendForSilentExecution, setArgument, setArgument, setFailed, setFinished, setPartialResultsEnabled, setPriority, setReceivedInMessage, setRejectable, setResponseTimeout, setSessionId, setTargetServerisOnClient, isOnServer, setClientContext, setServerContextgetClientContextgetServerContexttoDumpString, toStringdeepClonegetProcessingDuration, getReceivedTime, getSentTime, getTotalDuration, getTransferDuration, setReceivedTime, setSentTimegetLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannelpublic FileTransferAgent(C clientCtx)
public FileTransferAgent(C clientCtx, java.lang.String jobName)
public FileTransferAgent(C clientCtx, boolean isTransferAsync)
public FileTransferAgent(C clientCtx, java.lang.String jobName, boolean isTransferAsync)
public TransferAgentId getAgentId()
AgentgetAgentId in interface Agent<C extends ClientContext,S extends ServerContext>public void doOnClientSideCancellation()
AsyncAgentTaskManager when an AgentId is being cancelled.
Within this method the agent may perform any client-side reaction on cancellation.
Note that this method is called BEFORE the cancel-request is sent to the server.doOnClientSideCancellation in interface AsyncAgent<C extends ClientContext,S extends ServerContext>doOnClientSideCancellation in class AbstractAgent<C extends ClientContext,S extends ServerContext>public void doOnServerSideCancellation()
AsyncAgentAgentExecutorTask when a cancellation has been detected.
Within this method the agent may perform any server-side reaction on cancellation.doOnServerSideCancellation in interface AsyncAgent<C extends ClientContext,S extends ServerContext>doOnServerSideCancellation in class AbstractAgent<C extends ClientContext,S extends ServerContext>public FileTransferAgent sendForExecution() throws java.lang.Exception
AgentsendForExecution in interface Agent<C extends ClientContext,S extends ServerContext>java.lang.Exception - on failureAgent.sendForSilentExecution(),
Agent.sendForBooleanExecution()public final void setName(java.lang.String agentName)
AgentsetName in interface Agent<C extends ClientContext,S extends ServerContext>public final void setOwnerSessionId(SessionId origSessId)
AgentsetOwnerSessionId in interface Agent<C extends ClientContext,S extends ServerContext>public final FileTransferJobList getJobList()
public final void setRollbackEnabled(boolean isRollbackEnabled)
public final void setTransferLocked(boolean isLocked)
getResourceName()public final boolean isTransferLocked()
public final void setTransferAsync(boolean isAsync)
public final boolean isTransferAsync()
public final int getJobCount()
public final void clearJobs()
public final void addJob(FileTransferJob job)
public final JobId getJobId()
public final java.lang.String getJobName()
protected final java.lang.String getResourceName()
setTransferLocked(boolean)protected final ResourceType getResourceType()
public final void executeForResponse()
throws java.lang.Exception
executeForResponse in interface AsyncAgent<C extends ClientContext,S extends ServerContext>executeForResponse in class AbstractAgent<C extends ClientContext,S extends ServerContext>java.lang.Exceptionpublic final void executeOnServer()
throws java.lang.Exception
AgentexecuteOnServer in interface Agent<C extends ClientContext,S extends ServerContext>java.lang.Exceptionpublic final void doInitiallyOnClient()
throws java.lang.Exception
AgentdoInitiallyOnClient in interface Agent<C extends ClientContext,S extends ServerContext>doInitiallyOnClient in class AbstractAgent<C extends ClientContext,S extends ServerContext>java.lang.Exceptionpublic final void doOnResponseConfirmed()
throws java.lang.Exception
AgentNetResponse AFTER the response
has been confirmed to the server.doOnResponseConfirmed in interface Agent<C extends ClientContext,S extends ServerContext>doOnResponseConfirmed in class AbstractAgent<C extends ClientContext,S extends ServerContext>java.lang.Exceptionpublic final void processCommitMessage()
public final void awaitClientCommit()
throws java.lang.Exception
java.lang.Exceptionpublic final FileTransferClientTask getClientTask()
public final void addTaskListener(TaskEvent.Listener l)
addTaskListener in interface TaskEvent.Sourcepublic final void removeTaskListener(TaskEvent.Listener l)
removeTaskListener in interface TaskEvent.Sourcepublic ToString toString(ToString s)
toString in interface DumpabletoString in class AbstractLockableAgent<C extends ClientContext,S extends ServerContext>public DumpString toDumpString(DumpString s)
toDumpString in interface DumpabletoDumpString in class AbstractLockableAgent<C extends ClientContext,S extends ServerContext>public final java.util.Map getClientParams()
AgentgetClientParams in interface Agent<C extends ClientContext,S extends ServerContext>public final void putClientParam(java.lang.String key,
java.lang.Object value)
putClientParam in interface Agent<C extends ClientContext,S extends ServerContext>Agent.getClientParams()public final <T> T getClientParam(java.lang.String key)
AgentgetClientParam in interface Agent<C extends ClientContext,S extends ServerContext>Agent.getClientParams()public final boolean hasClientParam(java.lang.String key)
AgenthasClientParam in interface Agent<C extends ClientContext,S extends ServerContext>public final void clearClientParams()
AgentclearClientParams in interface Agent<C extends ClientContext,S extends ServerContext>public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic final TaskId getTaskId()
TaskIdHolderTaskId.getTaskId in interface TaskIdHolderpublic final SessionId getSessionId()
getSessionId in interface Agent<C extends ClientContext,S extends ServerContext>Agent.setSessionId(SessionId),
Agent.getOwnerSessionId()public final void setSessionId(SessionId sessId)
AgentsetSessionId in interface Agent<C extends ClientContext,S extends ServerContext>Agent.getSessionId()public final void setServerContext(S serverCtx)
CrossPlatformObjectsetServerContext in interface CrossPlatformObject<C extends ClientContext,S extends ServerContext>setServerContext in class AbstractCrossPlatformObject<C extends ClientContext,S extends ServerContext>ServerObject.getServerContext()public final boolean isPartialResultsEnabled()
AgentisPartialResultsEnabled in interface Agent<C extends ClientContext,S extends ServerContext>Agent.setPartialResultsEnabled(boolean)public final void setPartialResultsEnabled(boolean isEnabled)
AgentsetPartialResultsEnabled in interface Agent<C extends ClientContext,S extends ServerContext>Agent.isPartialResultsEnabled()public final void setRejectable(boolean state)
AgentsetRejectable in interface Agent<C extends ClientContext,S extends ServerContext>public final boolean isRejectable()
AgentisRejectable in interface Agent<C extends ClientContext,S extends ServerContext>public final SessionId getOwnerSessionId()
getOwnerSessionId in interface Agent<C extends ClientContext,S extends ServerContext>public final java.lang.String getTargetServer()
AgentgetTargetServer in interface Agent<C extends ClientContext,S extends ServerContext>Agent.setTargetServer(String)public final void setTargetServer(java.lang.String targetServer)
AgentNote that target server routing is not supported for async agents.
setTargetServer in interface Agent<C extends ClientContext,S extends ServerContext>Agent.getTargetServer()public final java.lang.String getName()
AgentgetName in interface Agent<C extends ClientContext,S extends ServerContext>public final void setResponseTimeout(int seconds)
setResponseTimeout in interface Agent<C extends ClientContext,S extends ServerContext>Agent.getResponseTimeout()public final int getResponseTimeout()
AgentgetResponseTimeout in interface Agent<C extends ClientContext,S extends ServerContext>Agent.setResponseTimeout(int)public final boolean hasRun()
AgenthasRun in interface Agent<C extends ClientContext,S extends ServerContext>Agent.hasError()public final boolean hasError()
AgenthasError in interface Agent<C extends ClientContext,S extends ServerContext>Agent.getError()public final java.lang.Exception getError()
AgentAgent.hasError() whether an Exception exists in the agent.getError in interface Agent<C extends ClientContext,S extends ServerContext>Agent.setFailed(Exception),
Agent.hasError()public final void setFinished()
AgentsetFinished in interface Agent<C extends ClientContext,S extends ServerContext>CrossPlatformObject.setServerContext(ServerContext ctx)public final void setFailed(java.lang.Exception error)
AgentsetFailed in interface Agent<C extends ClientContext,S extends ServerContext>Agent.getError(),
Agent.hasError()public final boolean isReceivedInResponse()
AgentisReceivedInResponse in interface Agent<C extends ClientContext,S extends ServerContext>public final boolean isReceivedInMessage()
AgentisReceivedInMessage in interface Agent<C extends ClientContext,S extends ServerContext>Agent.setReceivedInMessage(boolean)public final void setReceivedInMessage(boolean isReceivedInMessage)
AgentsetReceivedInMessage in interface Agent<C extends ClientContext,S extends ServerContext>Agent.isReceivedInMessage()public final int getPriority()
AgentgetPriority in interface Agent<C extends ClientContext,S extends ServerContext>public final void setPriority(int priority)
AgentsetPriority in interface Agent<C extends ClientContext,S extends ServerContext>public final void setSentTime(long sentTime)
TimeMeasurablesetSentTime in interface TimeMeasurablepublic final long getSentTime()
TimeMeasurablegetSentTime in interface TimeMeasurablepublic final void setReceivedTime(long receivedTime)
TimeMeasurablesetReceivedTime in interface TimeMeasurablepublic final long getReceivedTime()
TimeMeasurablegetReceivedTime in interface TimeMeasurablepublic final boolean isReceived()
AgentisReceived in interface Agent<C extends ClientContext,S extends ServerContext>public final long getProcessingDuration()
TimeMeasurablegetProcessingDuration in interface TimeMeasurablepublic final long getTotalDuration()
TimeMeasurablegetTotalDuration in interface TimeMeasurablepublic final long getTransferDuration()
TimeMeasurablegetTransferDuration in interface TimeMeasurablepublic final void setArgument(java.lang.Object arg,
boolean doZip)
AgentsetArgument in interface Agent<C extends ClientContext,S extends ServerContext>public final void setArgument(java.lang.Object arg)
AgentsetArgument in interface Agent<C extends ClientContext,S extends ServerContext>public final java.lang.Object getArgument()
AgentgetArgument in interface Agent<C extends ClientContext,S extends ServerContext>protected final int getZippedArgumentLength()
public final <A extends Agent<C,S>> A sendForSilentExecution()
AgentAgent.sendForExecution() just without throwing an Exception. The returned Agent should be
manually checked if it contains an Exception.sendForSilentExecution in interface Agent<C extends ClientContext,S extends ServerContext>Agent.sendForExecution(),
Agent.sendForBooleanExecution()public final boolean sendForBooleanExecution()
AgentAgent.sendForExecution() but does not return the agent, rather it returns true if
the agent has successfully being processed, false otherwise. In the case of agent processing
failure the error Exception is stored in the original input agent and can be requested from
there.sendForBooleanExecution in interface Agent<C extends ClientContext,S extends ServerContext>Agent.sendForExecution(),
Agent.sendForSilentExecution()public final void logFatal(java.lang.String message,
java.lang.Exception error)
logFatal in interface SimpleLogSupportlogFatal in class AbstractCrossPlatformObject<C extends ClientContext,S extends ServerContext>public final void logError(java.lang.String message,
java.lang.Exception error)
logError in interface SimpleLogSupportlogError in class AbstractCrossPlatformObject<C extends ClientContext,S extends ServerContext>public final void logError(java.lang.String message)
logError in interface SimpleLogSupportlogError in class AbstractCrossPlatformObject<C extends ClientContext,S extends ServerContext>public final void logWarning(java.lang.String message)
logWarning in interface SimpleLogSupportlogWarning in class AbstractCrossPlatformObject<C extends ClientContext,S extends ServerContext>public final void logInfo(java.lang.String message)
logInfo in interface SimpleLogSupportlogInfo in class AbstractCrossPlatformObject<C extends ClientContext,S extends ServerContext>public final void logVerbose(java.lang.String message)
logVerbose in interface SimpleLogSupportlogVerbose in class AbstractCrossPlatformObject<C extends ClientContext,S extends ServerContext>public final void logDebug(java.lang.String message)
logDebug in interface SimpleLogSupportlogDebug in class AbstractCrossPlatformObject<C extends ClientContext,S extends ServerContext>public final void logDump(java.lang.String message)
logDump in interface SimpleLogSupportlogDump in class AbstractCrossPlatformObject<C extends ClientContext,S extends ServerContext>Copyright © 2014 EsprIT-Systems. All Rights Reserved.