public class TransferState extends Object implements TimeEstimator
FileTransfer
implementations.
A single instance will be created per invocation of
FileTransfer.transfer(TransferState)
. Several instance methods are
provided for common reporting actions (See usage in existing
FileTransfer
implementations.Constructor and Description |
---|
TransferState(File file,
int index,
int total,
omero.grid.ImportProcessPrx proc,
ImportLibrary library,
TimeEstimator estimator,
ChecksumProvider cp,
byte[] buf)
State of the current file transfer.
|
Modifier and Type | Method and Description |
---|---|
void |
closeUploader()
Call
StatefulServiceInterfacePrx.close() on the cached uploader
instance if non-null and null the instance. |
byte[] |
getBuffer()
(Not thread safe) Get a moderately large buffer for use in
reading/writing data.
|
String |
getChecksum()
Get the digest string for the local file.
|
ChecksumProvider |
getChecksumProvider()
Get the
ChecksumProvider passed to the constructor. |
File |
getFile()
Return the target file passed to the constructor.
|
long |
getLength()
Return the length of the
target file . |
omero.model.OriginalFile |
getOriginalFile()
Find original file as defined by the ID in the
RawFileStorePrx
regardless of group. |
omero.model.OriginalFile |
getRootFile()
Find original file represented by the managed repository that
import is taking place to.
|
omero.api.RawFileStorePrx |
getUploader() |
omero.api.RawFileStorePrx |
getUploader(String mode)
Return the
RawFileStorePrx instance for this index setting
the mode if not null. |
long |
getUploadTimeLeft()
|
void |
save()
Calls
RawFileStorePrx.save() and stores the resultant
OriginalFile for future inspection along with the local
checksum. |
void |
start()
Starts the time counting.
|
void |
stop()
Stops the time counting and updates the internal time counter.
|
void |
stop(long uploadedBytes)
Stops the time counting and updates the internal updates the internal
time counter and counter of total number of transmitted bytes.
|
void |
uploadBytes(long offset)
Raise the
ImportEvent.FILE_UPLOAD_BYTES
event to all observers. |
void |
uploadComplete(long offset)
Raise the
ImportEvent.FILE_UPLOAD_COMPLETE
event to all observers. |
void |
uploadStarted()
Raise the
ImportEvent.FILE_UPLOAD_STARTED
event to all observers. |
public TransferState(File file, int index, int total, omero.grid.ImportProcessPrx proc, ImportLibrary library, TimeEstimator estimator, ChecksumProvider cp, byte[] buf) throws IOException, omero.ServerError
file
- Source file which is to be transferred.index
- Which of the total files to upload this is.total
- Total number of files to upload.proc
- ImportProcessPrx
which is being imported to.library
- ImportLibrary
to use for notifications.estimator
- a time-to-completion estimator.cp
- a checksum provider, for calculating file content checksums.buf
- optional buffer. Need not be used or updated.IOException
- I/O exceptionomero.ServerError
- server errorpublic void save() throws omero.ServerError
RawFileStorePrx.save()
and stores the resultant
OriginalFile
for future inspection along with the local
checksum. (The remote checksum is available from the
OriginalFile
.omero.ServerError
- server errorpublic byte[] getBuffer()
public String getChecksum()
save()
has been called.public ChecksumProvider getChecksumProvider()
ChecksumProvider
passed to the constructor.
Since the ChecksumProvider
has a number of different usage styles,
TransferState
doesn't attempt to delegate but just returns the
instance.public File getFile()
public long getLength()
target file
.public omero.model.OriginalFile getOriginalFile() throws omero.ServerError
RawFileStorePrx
regardless of group.omero.ServerError
- server errorpublic omero.model.OriginalFile getRootFile() throws omero.ServerError
omero.ServerError
- server errorpublic omero.api.RawFileStorePrx getUploader() throws omero.ServerError
RawFileStorePrx
instance for this indexomero.ServerError
- server errorpublic omero.api.RawFileStorePrx getUploader(String mode) throws omero.ServerError
RawFileStorePrx
instance for this index setting
the mode if not null. Valid values include "r" and "rw". If a non-null
uploader is available, it will be returned instead.
Every instance which is returned from this method should
eventually have StatefulServiceInterfacePrx.close()
called on it.
StatefulServiceInterfacePrx.close()
can be used to facilitate this.mode
- the mode as understood by
PublicRepositoryI.file(String, String, Ice.Current)
RawFileStorePrx
instanceomero.ServerError
- server errorpublic void closeUploader()
StatefulServiceInterfacePrx.close()
on the cached uploader
instance if non-null and null the instance. If
ObjectNotExistException
is thrown, the service is
assumed closed. All other exceptions will be printed at WARN.public void uploadStarted()
ImportEvent.FILE_UPLOAD_STARTED
event to all observers.public void uploadBytes(long offset)
ImportEvent.FILE_UPLOAD_BYTES
event to all observers.offset
- how many bytes are uploadedpublic void uploadComplete(long offset)
ImportEvent.FILE_UPLOAD_COMPLETE
event to all observers.offset
- how many bytes are uploadedpublic void start()
TimeEstimator
start
in interface TimeEstimator
public void stop()
TimeEstimator
stop
in interface TimeEstimator
public void stop(long uploadedBytes)
TimeEstimator
stop
in interface TimeEstimator
uploadedBytes
- Number of bytes uploaded in a single time frame that is being
sampled.public long getUploadTimeLeft()
TimeEstimator
getUploadTimeLeft
in interface TimeEstimator
stop
hasn't been called at least
once before calling this method.
Version: 5.2.4-ice35-b23
Copyright © 2016 The University of Dundee & Open Microscopy Environment. All Rights Reserved.