Class ProcessManager
- java.lang.Object
-
- unlimited.fc.client.api.multiclient.processor.ProcessManager
-
public class ProcessManager extends java.lang.ObjectThis class manages processes. You can add/remove and arrange processes in whatever order you want, the process manager runs the jobs through each processor.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classProcessManager.ProcessorComparator
-
Constructor Summary
Constructors Constructor Description ProcessManager(MultiClientManager mgr)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPostprocess(PostProcessor<?> processor)This adds a new post processor.voidaddPreprocess(PreProcessor processor)This adds a new pre processor, it adds it to the front of the process chainvoidaddProcessEventListener(ProcessEventDispatch.ProcessEventListener listener)As a ProcessEventListener into the current listener listbooleancanPostProcess(java.util.Set<ErrorCodes> errorSet)Returns whether or not the files can still be post processedunlimited.core.util.common.CancelHandlergetCanceller()Returns the canceller handler that is used to determine if this manager should continue or cancel it's current operationsprotected <T extends Processor>
TransferJobgetFilteredProcessJob(TransferJob job, FileTransferMechanism client, java.util.TreeSet<T> processors)java.util.TreeSet<PostProcessor<?>>getPostProcesses()Returns the current list of PostProcessorsunlimited.core.util.common.tuples.Pair<java.util.TreeSet<PreProcessor>,ProcessManager.ProcessorComparator>getPreProcessors()Gathers the PreProcessors that this manager currently has access tojava.util.Set<? extends TransferJob>getProcessingJobs()Returns the Jobs that are being processedbooleanisDeleteAfterAdded()Returns whether or not the delete after processor has already been addedbooleanisProcessing()Returns whether or not we are currently processingbooleanisRecoverablePostProcessErrors(java.util.Set<ErrorCodes> postProcessErrorSet)voidnotifyAllWaits()Notifies the listeners that are currently looking into this classTransferJobpostProcess(TransferJob job, FileTransferMechanism client, java.util.Set<ErrorCodes> errorSet)TransferJobpreProcess(TransferJob job)This will run the transfer job through the preprocessors, anything returned will be pushed onto the multi-client manager for transfer.TransferJobpreProcessWaitForCompletion(TransferJob job)This will run the transfer job through the preprocessors, anything returned will be pushed onto the multi-client manager for transfer.protected TransferJobpreProcessWaitForCompletion(TransferJob job, java.util.Set<ErrorCodes> errors)This will run the transfer job through the preprocessors, anything returned will be pushed onto the multi-client manager for transfer.voidremoveProcessEventListener(ProcessEventDispatch.ProcessEventListener listener)Removes the provided ProcessEventListener when calledvoidrunIndividualProcessor(TransferJob job, FileTransferMechanism client, Processor processor)voidshutdown(boolean isShutdown)Calls shutdown on all processors, they will discontinue working after shutdown is called.voidupdateDeleteAfterOrMoveToSent()Adds the delete after processor if the Manager has been set to delete after transfer.voidupdateVerifyIntegritry()Updates the verify integrity preprocessors to whatever mode the MultiClientManager currently has selected
-
-
-
Constructor Detail
-
ProcessManager
public ProcessManager(MultiClientManager mgr)
- Parameters:
mgr- - the multi client manager associated with this ProcessManager
-
-
Method Detail
-
addPostprocess
public void addPostprocess(PostProcessor<?> processor)
This adds a new post processor. It adds it to the front of the process chain.- Parameters:
processor- to be added
-
addPreprocess
public void addPreprocess(PreProcessor processor)
This adds a new pre processor, it adds it to the front of the process chain- Parameters:
processor- to be added
-
preProcess
public final TransferJob preProcess(TransferJob job)
This will run the transfer job through the preprocessors, anything returned will be pushed onto the multi-client manager for transfer. **NOTE** this does not wait for completion of the preprocessors, this must be kept in mind as some preprocessors will sleep for a certain amount of time before continuing e.g. a PreProcessor that will wait for a file to stop growing before it pushes the work into the queue.- Parameters:
job- - job to be processed- Returns:
- a job that contains either work that was either passed through (isPassThrough=true) and not worked on OR work that was rejected by the filters within the processors.
-
preProcessWaitForCompletion
protected TransferJob preProcessWaitForCompletion(TransferJob job, java.util.Set<ErrorCodes> errors)
This will run the transfer job through the preprocessors, anything returned will be pushed onto the multi-client manager for transfer. **NOTE** This is mainly used for testing right now, however it is worth noting that the preprocessor will wait until completion of all preprocessors before returning.- Parameters:
job- - job to be processed- Returns:
- a job that contains either work that was either passed through (isPassThrough=true) and not worked on OR work that was rejected by the filters within the processors.
-
getFilteredProcessJob
protected <T extends Processor> TransferJob getFilteredProcessJob(TransferJob job, FileTransferMechanism client, java.util.TreeSet<T> processors)
-
runIndividualProcessor
public void runIndividualProcessor(TransferJob job, FileTransferMechanism client, Processor processor) throws unlimited.core.util.common.controlFlow.Break
- Throws:
unlimited.core.util.common.controlFlow.Break
-
postProcess
public TransferJob postProcess(TransferJob job, FileTransferMechanism client, java.util.Set<ErrorCodes> errorSet)
- Parameters:
job- - job to be processedclient- - client working on job to be processederrorSet-- Returns:
- a job that contains either work that was either passed through (isPassThrough=true) and not worked on OR work that was rejected by the filters within the processors.
-
addProcessEventListener
public void addProcessEventListener(ProcessEventDispatch.ProcessEventListener listener)
As a ProcessEventListener into the current listener list- Parameters:
listener- A hook to tie into our processing so it can be monitored and data harvested
-
removeProcessEventListener
public void removeProcessEventListener(ProcessEventDispatch.ProcessEventListener listener)
Removes the provided ProcessEventListener when called- Parameters:
listener- Listener to be removed
-
shutdown
public void shutdown(boolean isShutdown)
Calls shutdown on all processors, they will discontinue working after shutdown is called.- Parameters:
isShutdown-
-
isProcessing
public boolean isProcessing()
Returns whether or not we are currently processing- Returns:
- true if the process count is greater than 0.
-
getPostProcesses
public java.util.TreeSet<PostProcessor<?>> getPostProcesses()
Returns the current list of PostProcessors- Returns:
- Set containing the post processors
-
canPostProcess
public boolean canPostProcess(java.util.Set<ErrorCodes> errorSet)
Returns whether or not the files can still be post processed- Parameters:
errorSet- Error codes to check against- Returns:
- True if can still process, false if otherwise
-
preProcessWaitForCompletion
public TransferJob preProcessWaitForCompletion(TransferJob job)
This will run the transfer job through the preprocessors, anything returned will be pushed onto the multi-client manager for transfer. NOTE: This is mainly used for testing right now, however it is worth noting that the preprocessor will wait until completion of all preprocessors before returning.- Parameters:
job- Job to be processed- Returns:
- a job that contains either work that was either passed through (isPassThrough=true) and not worked on OR work that was rejected by the filters within the processors.
-
updateVerifyIntegritry
public void updateVerifyIntegritry()
Updates the verify integrity preprocessors to whatever mode the MultiClientManager currently has selected
-
updateDeleteAfterOrMoveToSent
public void updateDeleteAfterOrMoveToSent()
Adds the delete after processor if the Manager has been set to delete after transfer. Otherwise the processor is removed
-
getProcessingJobs
public java.util.Set<? extends TransferJob> getProcessingJobs()
Returns the Jobs that are being processed
-
notifyAllWaits
public void notifyAllWaits()
Notifies the listeners that are currently looking into this class
-
getCanceller
public unlimited.core.util.common.CancelHandler getCanceller()
Returns the canceller handler that is used to determine if this manager should continue or cancel it's current operations- Returns:
- The cancel handler
-
isDeleteAfterAdded
public boolean isDeleteAfterAdded()
Returns whether or not the delete after processor has already been added- Returns:
- True if already added, false otherwise
-
isRecoverablePostProcessErrors
public boolean isRecoverablePostProcessErrors(java.util.Set<ErrorCodes> postProcessErrorSet)
-
getPreProcessors
public unlimited.core.util.common.tuples.Pair<java.util.TreeSet<PreProcessor>,ProcessManager.ProcessorComparator> getPreProcessors()
Gathers the PreProcessors that this manager currently has access to- Returns:
- Pair object containing the set of preprocessors, and the comparator used to compare their priority
-
-