Package org.yamcs.cfdp
Class CfdpService
- java.lang.Object
-
- com.google.common.util.concurrent.AbstractService
-
- org.yamcs.AbstractYamcsService
-
- org.yamcs.cfdp.CfdpService
-
- All Implemented Interfaces:
com.google.common.util.concurrent.Service,FileTransferService,TransferMonitor,YamcsService,StreamSubscriber
public class CfdpService extends AbstractYamcsService implements FileTransferService, StreamSubscriber, TransferMonitor
Implements CCSDS File Delivery Protocol (CFDP) in Yamcs.The standard is specified in CCSDS 727.0-B-4
-
-
Field Summary
-
Fields inherited from class org.yamcs.AbstractYamcsService
config, log, serviceName, yamcsInstance
-
-
Constructor Summary
Constructors Constructor Description CfdpService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel(FileTransfer transfer)Cancel the file transfer.protected voiddoStart()protected voiddoStop()org.yamcs.protobuf.FileTransferCapabilitiesgetCapabilities()Get the capabilities supported by this service.OngoingCfdpTransfergetCfdpTransfer(CfdpTransactionId transferId)FileTransfergetFileTransfer(long id)Get the file transfer with the given identifier.List<org.yamcs.protobuf.EntityInfo>getLocalEntities()Get the list of configured local entities.EntityConfgetLocalEntity(long entityId)OngoingCfdpTransfergetOngoingCfdpTransfer(long id)List<org.yamcs.protobuf.EntityInfo>getRemoteEntities()Get the list of configured remote entity.EntityConfgetRemoteEntity(long entityId)SpecgetSpec()Returns the valid configuration options for this service.List<FileTransfer>getTransfers()Get the list of ongoing or past transfers.voidinit(String yamcsInstance, String serviceName, YConfiguration config)Initialize this service.voidonTuple(Stream stream, Tuple tuple)voidpause(FileTransfer transfer)Pause the file transfer.voidregisterTransferMonitor(TransferMonitor listener)Register a monitor to be called each time a file transfer is started or changes state.voidresume(FileTransfer transfer)Resume the file transfer.FileTransferstartDownload(String sourceEntity, String sourcePath, String destinationEntity, Bucket bucket, String objectName, TransferOptions options)Start a file download.CfdpFileTransferstartUpload(String source, Bucket bucket, String objectName, String destination, String destinationPath, TransferOptions options)Start a file upload.voidstateChanged(FileTransfer ft)voidstreamClosed(Stream stream)voidunregisterTransferMonitor(TransferMonitor listener)Unregister the monitor.-
Methods inherited from class org.yamcs.AbstractYamcsService
getConfig, getYamcsInstance
-
Methods inherited from class com.google.common.util.concurrent.AbstractService
addListener, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, 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, awaitTerminated, awaitTerminated, failureCause, isRunning, startAsync, state, stopAsync
-
Methods inherited from interface org.yamcs.YamcsService
getYamcsInstance, init
-
-
-
-
Method Detail
-
getSpec
public Spec getSpec()
Description copied from interface:YamcsServiceReturns the valid configuration options for this service.- Specified by:
getSpecin 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:YamcsServiceInitialize this service. This is called before the service is started. All operations should finish fast.- Specified by:
initin interfaceYamcsService- Overrides:
initin classAbstractYamcsService- Parameters:
yamcsInstance- The yamcs instance, or null 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
public OngoingCfdpTransfer getCfdpTransfer(CfdpTransactionId transferId)
-
getFileTransfer
public FileTransfer getFileTransfer(long id)
Description copied from interface:FileTransferServiceGet the file transfer with the given identifier.- Specified by:
getFileTransferin interfaceFileTransferService- Returns:
-
getTransfers
public List<FileTransfer> getTransfers()
Description copied from interface:FileTransferServiceGet the list of ongoing or past transfers.- Specified by:
getTransfersin interfaceFileTransferService- Returns:
- the list of transfers
-
onTuple
public void onTuple(Stream stream, Tuple tuple)
- Specified by:
onTuplein interfaceStreamSubscriber
-
getRemoteEntity
public EntityConf getRemoteEntity(long entityId)
-
getLocalEntity
public EntityConf getLocalEntity(long entityId)
-
registerTransferMonitor
public void registerTransferMonitor(TransferMonitor listener)
Description copied from interface:FileTransferServiceRegister a monitor to be called each time a file transfer is started or changes state.- Specified by:
registerTransferMonitorin interfaceFileTransferService
-
unregisterTransferMonitor
public void unregisterTransferMonitor(TransferMonitor listener)
Description copied from interface:FileTransferServiceUnregister the monitor. If the monitor was not registered, this call has no effect.- Specified by:
unregisterTransferMonitorin interfaceFileTransferService
-
doStart
protected void doStart()
- Specified by:
doStartin classcom.google.common.util.concurrent.AbstractService
-
doStop
protected void doStop()
- Specified by:
doStopin classcom.google.common.util.concurrent.AbstractService
-
streamClosed
public void streamClosed(Stream stream)
- Specified by:
streamClosedin interfaceStreamSubscriber
-
stateChanged
public void stateChanged(FileTransfer ft)
- Specified by:
stateChangedin interfaceTransferMonitor
-
getLocalEntities
public List<org.yamcs.protobuf.EntityInfo> getLocalEntities()
Description copied from interface:FileTransferServiceGet the list of configured local entities. These contain the {@code source) used in the {@link #startUpload(String, Bucket, String, String, String, TransferOptions)} call.Can return an empty list if there is only one unnamed entity.
- Specified by:
getLocalEntitiesin interfaceFileTransferService- Returns:
-
getRemoteEntities
public List<org.yamcs.protobuf.EntityInfo> getRemoteEntities()
Description copied from interface:FileTransferServiceGet the list of configured remote entity. These contain thedestinationused 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:
getRemoteEntitiesin interfaceFileTransferService- Returns:
-
getOngoingCfdpTransfer
public OngoingCfdpTransfer getOngoingCfdpTransfer(long id)
-
startUpload
public CfdpFileTransfer startUpload(String source, Bucket bucket, String objectName, String destination, String destinationPath, TransferOptions options) throws IOException
Description copied from interface:FileTransferServiceStart a file upload.- Specified by:
startUploadin 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.
-
pause
public void pause(FileTransfer transfer)
Description copied from interface:FileTransferServicePause the file transfer.If the transfer is already paused, this operation has no effect.
- Specified by:
pausein interfaceFileTransferService- Parameters:
transfer- the transfer to be paused.
-
resume
public void resume(FileTransfer transfer)
Description copied from interface:FileTransferServiceResume the file transfer.If the transfer is not paused, this call has no effect.
- Specified by:
resumein interfaceFileTransferService- Parameters:
transfer- the transfer to be resumed.
-
cancel
public void cancel(FileTransfer transfer)
Description copied from interface:FileTransferServiceCancel the file transfer.- Specified by:
cancelin interfaceFileTransferService
-
startDownload
public FileTransfer startDownload(String sourceEntity, String sourcePath, String destinationEntity, Bucket bucket, String objectName, TransferOptions options) throws IOException, InvalidRequestException
Description copied from interface:FileTransferServiceStart a file download.- Specified by:
startDownloadin 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:
IOException- if there was a problem retrieving the object from the bucket.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.
-
getCapabilities
public org.yamcs.protobuf.FileTransferCapabilities getCapabilities()
Description copied from interface:FileTransferServiceGet the capabilities supported by this service.The capabilities are used by the yamcs-web to enable/disable some options.
- Specified by:
getCapabilitiesin interfaceFileTransferService- Returns:
-
-