Package org.yamcs.cfdp
Class CfdpService
java.lang.Object
com.google.common.util.concurrent.AbstractService
org.yamcs.AbstractYamcsService
org.yamcs.filetransfer.AbstractFileTransferService
org.yamcs.cfdp.CfdpService
- All Implemented Interfaces:
com.google.common.util.concurrent.Service
,FileActionProvider
,FileListingService
,FileTransferService
,TransferMonitor
,YamcsService
,StreamSubscriber
public class CfdpService
extends AbstractFileTransferService
implements StreamSubscriber, TransferMonitor
Implements CCSDS File Delivery Protocol (CFDP) in Yamcs.
The standard is specified in CCSDS 727.0-B-5
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.google.common.util.concurrent.Service
com.google.common.util.concurrent.Service.Listener, com.google.common.util.concurrent.Service.State
-
Field Summary
Fields inherited from class org.yamcs.AbstractYamcsService
config, log, serviceName, yamcsInstance
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
void
cancel
(FileTransfer transfer) Cancel the file transfer.protected void
doStart()
protected void
doStop()
void
Start fetching a new file list from remote.getCfdpTransfer
(CfdpTransactionId transferId) Return latest file list of the given destination.getFileTransfer
(long id) Get the file transfer with the given identifier.Get configured options for the file transfersGet the list of configured local entities.getLocalEntity
(long entityId) getOngoingCfdpTransfer
(long id) org.yamcs.cfdp.OngoingCfdpTransfer.FaultHandlingAction
Get the list of configured remote entity.getRemoteEntity
(long entityId) org.yamcs.cfdp.OngoingCfdpTransfer.FaultHandlingAction
getSpec()
Returns the valid configuration options for this service.getTransfers
(FileTransferFilter filter) Get the list of ongoing or past transfers.void
init
(String yamcsInstance, String serviceName, YConfiguration config) Initialize this service.void
notifyRemoteFileListMonitors
(ListFilesResponse listFilesResponse) void
void
pause
(FileTransfer transfer) Pause the file transfer.void
void
registerTransferMonitor
(TransferMonitor listener) Register a monitor to be called each time a file transfer is started or changes state.void
resume
(FileTransfer transfer) Resume the file transfer.void
saveFileList
(ListFilesResponse listFilesResponse) startDownload
(String sourceEntity, String sourcePath, String destinationEntity, Bucket bucket, String objectName, TransferOptions options) Start a file download.startUpload
(String source, Bucket bucket, String objectName, String destination, String destinationPath, TransferOptions options) Start a file upload.void
void
streamClosed
(Stream stream) void
void
unregisterTransferMonitor
(TransferMonitor listener) Unregister the monitor.Methods inherited from class org.yamcs.filetransfer.AbstractFileTransferService
addFileAction, getCapabilities, getFileAction, getFileActions
Methods inherited from class org.yamcs.AbstractYamcsService
getConfig, getYamcsInstance
Methods inherited from class com.google.common.util.concurrent.AbstractService
addListener, awaitRunning, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, awaitTerminated, doCancelStart, failureCause, isRunning, notifyFailed, notifyStarted, notifyStopped, startAsync, state, stopAsync, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.google.common.util.concurrent.Service
addListener, awaitRunning, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, awaitTerminated, failureCause, isRunning, startAsync, state, stopAsync
Methods inherited from interface org.yamcs.YamcsService
getYamcsInstance
-
Constructor Details
-
CfdpService
public CfdpService()
-
-
Method Details
-
getSpec
Description copied from interface:YamcsService
Returns the valid configuration options for this service.- Specified by:
getSpec
in interfaceYamcsService
- Returns:
- the argument specification, or
null
if the args should not be validated.
-
init
public void init(String yamcsInstance, String serviceName, YConfiguration config) throws InitException Description copied from interface:YamcsService
Initialize this service. This is called before the service is started. All operations should finish fast.- Specified by:
init
in interfaceFileListingService
- Specified by:
init
in interfaceFileTransferService
- Specified by:
init
in interfaceYamcsService
- Overrides:
init
in classAbstractYamcsService
- Parameters:
yamcsInstance
- The yamcs instance, ornull
if this is a global service.serviceName
- The service name.config
- The configured arguments for this service. IfYamcsService.getSpec()
is implemented then this contains the arguments after being validated (including any defaults).- Throws:
InitException
- When something goes wrong during the execution of this method.
-
getCfdpTransfer
-
getFileTransfer
Description copied from interface:FileTransferService
Get the file transfer with the given identifier.- Specified by:
getFileTransfer
in interfaceFileTransferService
- Returns:
-
getTransfers
Description copied from interface:FileTransferService
Get the list of ongoing or past transfers.- Specified by:
getTransfers
in interfaceFileTransferService
- Returns:
- the list of transfers
-
onTuple
- Specified by:
onTuple
in interfaceStreamSubscriber
-
getRemoteEntity
-
getLocalEntity
-
registerTransferMonitor
Description copied from interface:FileTransferService
Register a monitor to be called each time a file transfer is started or changes state.- Specified by:
registerTransferMonitor
in interfaceFileTransferService
-
unregisterTransferMonitor
Description copied from interface:FileTransferService
Unregister the monitor. If the monitor was not registered, this call has no effect.- Specified by:
unregisterTransferMonitor
in interfaceFileTransferService
-
registerRemoteFileListMonitor
- Specified by:
registerRemoteFileListMonitor
in interfaceFileListingService
-
unregisterRemoteFileListMonitor
- Specified by:
unregisterRemoteFileListMonitor
in interfaceFileListingService
-
notifyRemoteFileListMonitors
- Specified by:
notifyRemoteFileListMonitors
in interfaceFileListingService
-
getRemoteFileListMonitors
- Specified by:
getRemoteFileListMonitors
in interfaceFileListingService
-
doStart
protected void doStart()- Specified by:
doStart
in classcom.google.common.util.concurrent.AbstractService
-
doStop
protected void doStop()- Specified by:
doStop
in classcom.google.common.util.concurrent.AbstractService
-
streamClosed
- Specified by:
streamClosed
in interfaceStreamSubscriber
-
stateChanged
- Specified by:
stateChanged
in interfaceTransferMonitor
-
getLocalEntities
Description copied from interface:FileTransferService
Get the list of configured local entities. These contain the {@code source) used in the {@link #startUpload(String, Bucket, String, String, String, TransferOptions)} call. <p> Can return an empty list if there is only one unnamed entity. @return- Specified by:
getLocalEntities
in interfaceFileTransferService
-
getRemoteEntities
Description copied from interface:FileTransferService
Get the list of configured remote entity. These contain thedestination
used in theFileTransferService.startUpload(String, Bucket, String, String, String, TransferOptions)
call.Can return an empty list if there is only one unnamed remote entity.
- Specified by:
getRemoteEntities
in interfaceFileTransferService
- Returns:
-
getOngoingCfdpTransfer
-
startUpload
public CfdpFileTransfer startUpload(String source, Bucket bucket, String objectName, String destination, String destinationPath, TransferOptions options) throws IOException Description copied from interface:FileTransferService
Start a file upload.- Specified by:
startUpload
in interfaceFileTransferService
- Parameters:
source
- the source (local) entity. Can be null if the service supports only one unnamed source entity.bucket
- the bucket containing the object to be transferred.objectName
- the object name to be transferred.destination
- the destination (remote) entity. Can be null if the service supports only one unnamed destination entity.destinationPath
- the path on the destination where the file will be uploaded. Depending on the implementation this can be the path of a directory in which case the objectName will be used as a destination file name or can be the name of a (non-existent) file which will then be used as the destination file. if the destinationPath is null, then the objectName will be used as the name at the destination.options
- transfer options.- Returns:
- Throws:
IOException
- if there was a problem retrieving the object from the bucket.
-
startDownload
public FileTransfer startDownload(String sourceEntity, String sourcePath, String destinationEntity, Bucket bucket, String objectName, TransferOptions options) throws InvalidRequestException Description copied from interface:FileTransferService
Start a file download.- Specified by:
startDownload
in interfaceFileTransferService
- Parameters:
sourceEntity
- the source (remote) entity. Can be null if the service supports only one unnamed source entity.sourcePath
- the path on the source representing the file to be transferred.destinationEntity
- the destination (local) entity. Can be null if the service supports only one unnamed destination entity.bucket
- the bucket where the file will be stored.objectName
- the object name where the file will be stored.options
- transfer options.- Returns:
- Throws:
InvalidRequestException
- thrown if the request is invalid; possible reasons:- the source or destination entities are not valid
- the transfer options are invalid
- download operation not supported or cannot be triggered by this call (most systems will have a telecommand to trigger a download)
- other service specific error.
-
fetchFileList
public void fetchFileList(String source, String destination, String remotePath, Map<String, Object> options) Description copied from interface:FileListingService
Start fetching a new file list from remote.- Specified by:
fetchFileList
in interfaceFileListingService
- Parameters:
source
- source requesting the file list (e.g. local entity for CFDP)destination
- destination from which the file list is needed (e.g. remote entity for CFDP)remotePath
- path on the destination from which to get the file listoptions
- reliability of the file listing request (e.g. transmission mode for CFDP, may not be needed)
-
getFileList
public ListFilesResponse getFileList(String source, String destination, String remotePath, Map<String, Object> options) Description copied from interface:FileListingService
Return latest file list of the given destination.- Specified by:
getFileList
in interfaceFileListingService
- Parameters:
source
- source requesting the file list (e.g. local entity for CFDP)destination
- destination from which the file list is needed (e.g. remote entity for CFDP)remotePath
- path on the destination from which to get the file listoptions
- reliability of the file listing request (e.g. transmission mode for CFDP, may not be needed)- Returns:
- file list
-
saveFileList
- Specified by:
saveFileList
in interfaceFileListingService
-
pause
Description copied from interface:FileTransferService
Pause the file transfer.If the transfer is already paused, this operation has no effect.
- Specified by:
pause
in interfaceFileTransferService
- Parameters:
transfer
- the transfer to be paused.
-
resume
Description copied from interface:FileTransferService
Resume the file transfer.If the transfer is not paused, this call has no effect.
- Specified by:
resume
in interfaceFileTransferService
- Parameters:
transfer
- the transfer to be resumed.
-
cancel
Description copied from interface:FileTransferService
Cancel the file transfer.- Specified by:
cancel
in interfaceFileTransferService
-
getFileTransferOptions
Description copied from interface:FileTransferService
Get configured options for the file transfers- Specified by:
getFileTransferOptions
in interfaceFileTransferService
- Returns:
-
addCapabilities
- Specified by:
addCapabilities
in classAbstractFileTransferService
-
getSenderFaultHandler
public org.yamcs.cfdp.OngoingCfdpTransfer.FaultHandlingAction getSenderFaultHandler(ConditionCode code) -
getReceiverFaultHandler
public org.yamcs.cfdp.OngoingCfdpTransfer.FaultHandlingAction getReceiverFaultHandler(ConditionCode code)
-