Class UrlCopy
java.lang.Object
org.globus.io.urlcopy.UrlCopy
- All Implemented Interfaces:
Runnable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanstatic final intmaximum buffer size to read or write when putting and getting filesprotected intprotected booleanprotected booleanprotected longprotected booleanprotected Authorizationprotected GSSCredentialprotected GlobusURLprotected Listprivate static org.apache.commons.logging.Logprotected longprotected longprotected Authorizationprotected GSSCredentialprotected GlobusURLprotected intprotected boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddUrlCopyListener(UrlCopyListener listener) Adds url copy listener.voidcancel()Cancels the transfer in progress.private voidvoidcopy()Performs the copy function.private FTPClientcreateFTPConnection(GlobusURL ftpURL, boolean srcSide) Creates ftp connection based on the ftp url (secure vs.private voidfireUrlTransferProgressEvent(long totalBytes, long transferedBytes) intReturns buffer size used for transfering data.booleangetDCAU()Returns authorization type for the destination side for the url copy.Returns credentials used for authenticating the destination side for the url copy.longGets the offset in the destination file from which data starts to be writtenReturns destination url.booleanCan be used to query whether the use of the ALLO command with GridFTP uploads is disabled.protected GlobusInputStreamReturns input stream based on the source urlprotected GlobusOutputStreamgetOutputStream(long size) Returns output stream based on the destination url.Returns authorization type for the source side for the url copy.Returns credentials used for authenticating the source side for the url copy.longGets the maximum data size that will be transfered.longGets the offset in the source file from which data starts to be readReturns source url.intReturns TCP buffer size used for transfers data.booleanChecks if append mode is enabled.booleanChecks if the transfer was canceled.protected voidnegotiateDCAU(FTPClient src, FTPClient dst) voidremoveUrlCopyListener(UrlCopyListener listener) Remove url copy listenervoidrun()This method is an implementation of theRunnableinterface and can be used to perform the copy in a separate thread.voidsetAppendMode(boolean appendMode) Enables/disables append mode.voidsetBufferSize(int size) Sets buffer size for transfering data.voidsetCredentials(GSSCredential credentials) Sets credentials to use for both sides.voidsetDCAU(boolean dcau) private static voidsetDCAU(GridFTPClient c, boolean dcau) voidSets destination authorization typevoidsetDestinationCredentials(GSSCredential dstCredentials) Sets destination url credentials.voidsetDestinationOffset(long destinationOffset) Sets the offset in the destination file from which data starts to be written.voidsetDestinationUrl(GlobusURL dest) Sets destination url.voidsetDisableAllo(boolean disableAllo) Allows disabling of the use of ALLO with GridFTP uploadsvoidSets source authorization typevoidsetSourceCredentials(GSSCredential srcCredentials) Sets source url credentials.voidsetSourceFileLength(long sourceLength) Allows a partial transfer by setting the maximum number of bytes that will be transfered.voidsetSourceFileOffset(long sourceOffset) Sets the offset in the source file from which data starts to be read.voidsetSourceUrl(GlobusURL source) Sets source url.voidsetTCPBufferSize(int size) Sets the TCP buffer size for GridFTP transfers.voidsetUseThirdPartyCopy(boolean thirdParty) Enables/disables usage of third party transfers.private voidThis performs thrid party transfer only if source and destination urls are ftp urls.private booleantransfer(long total, GlobusInputStream in, GlobusOutputStream out) This function performs the actual transfer.
-
Field Details
-
logger
private static org.apache.commons.logging.Log logger -
BUFF_SIZE
public static final int BUFF_SIZEmaximum buffer size to read or write when putting and getting files- See Also:
-
bufferSize
protected int bufferSize -
srcCreds
-
srcAuth
-
dstCreds
-
dstAuth
-
dcau
protected boolean dcau -
appendMode
protected boolean appendMode -
srcUrl
-
dstUrl
-
canceled
protected boolean canceled -
thirdParty
protected boolean thirdParty -
listeners
-
sourceOffset
protected long sourceOffset -
destinationOffset
protected long destinationOffset -
sourceLength
protected long sourceLength -
tcpBufferSize
protected int tcpBufferSize -
disableAllo
protected boolean disableAllo
-
-
Constructor Details
-
UrlCopy
public UrlCopy()
-
-
Method Details
-
setDCAU
public void setDCAU(boolean dcau) -
getDCAU
public boolean getDCAU() -
setCredentials
Sets credentials to use for both sides.- Parameters:
credentials- user credentials
-
setSourceCredentials
Sets source url credentials.- Parameters:
srcCredentials- source url credentials.
-
setDestinationCredentials
Sets destination url credentials.- Parameters:
dstCredentials- destination url credentials.
-
setSourceAuthorization
Sets source authorization type- Parameters:
auth- authorization type to perform for source
-
setDestinationAuthorization
Sets destination authorization type- Parameters:
auth- authorization type to perform for destination
-
getSourceCredentials
Returns credentials used for authenticating the source side for the url copy. If no source credentials are set, the default user credentials will used.- Returns:
- source credentials.
-
getDestinationCredentials
Returns credentials used for authenticating the destination side for the url copy. If no destination credentials are set, the default user credentials will used.- Returns:
- destination credentials.
-
getSourceAuthorization
Returns authorization type for the source side for the url copy. If no authorization type is set, the default authorization will be performed for a given protocol.- Returns:
- source authorization type
-
getDestinationAuthorization
Returns authorization type for the destination side for the url copy. If no authorization type is set, the default authorization will be performed for a given protocol.- Returns:
- destination authorization type
-
addUrlCopyListener
Adds url copy listener.- Parameters:
listener- url copy listener
-
removeUrlCopyListener
Remove url copy listener- Parameters:
listener- url copy listener
-
setBufferSize
public void setBufferSize(int size) Sets buffer size for transfering data. It does not set the TCP buffers.- Parameters:
size- size of the data buffer
-
getBufferSize
public int getBufferSize()Returns buffer size used for transfering data.- Returns:
- data buffer size
-
setTCPBufferSize
public void setTCPBufferSize(int size) Sets the TCP buffer size for GridFTP transfers.- Parameters:
size- size of TCP buffer
-
getTCPBufferSize
public int getTCPBufferSize()Returns TCP buffer size used for transfers data.- Returns:
- TCP buffer size
-
setAppendMode
public void setAppendMode(boolean appendMode) Enables/disables append mode.- Parameters:
appendMode- if true, destination file will be appended.
-
isAppendMode
public boolean isAppendMode()Checks if append mode is enabled.- Returns:
- true if appending will be performed, false otherwise.
-
getDestinationOffset
public long getDestinationOffset()Gets the offset in the destination file from which data starts to be written- Returns:
- a value indicating the offset in bytes
-
setDestinationOffset
public void setDestinationOffset(long destinationOffset) Sets the offset in the destination file from which data starts to be written. The default offset is 0 (the beginning of the file)- Parameters:
destinationOffset- the offset in bytes
-
getSourceLength
public long getSourceLength()Gets the maximum data size that will be transfered.- Returns:
- the size in bytes
-
setSourceFileLength
public void setSourceFileLength(long sourceLength) Allows a partial transfer by setting the maximum number of bytes that will be transfered. By default the entire source file is transfered.- Parameters:
sourceLength- the size of the transfer in bytes
-
getSourceOffset
public long getSourceOffset()Gets the offset in the source file from which data starts to be read- Returns:
- a value indicating the offset in bytes
-
setSourceFileOffset
public void setSourceFileOffset(long sourceOffset) Sets the offset in the source file from which data starts to be read. The default offset is 0 (the beginning of the file)- Parameters:
sourceOffset- the offset in bytes
-
checkUrl
- Throws:
UrlCopyException
-
setSourceUrl
Sets source url.- Parameters:
source- source url.- Throws:
UrlCopyException
-
getSourceUrl
-
setDestinationUrl
Sets destination url.- Parameters:
dest- destination url- Throws:
UrlCopyException
-
getDestinationUrl
-
setUseThirdPartyCopy
public void setUseThirdPartyCopy(boolean thirdParty) Enables/disables usage of third party transfers.- Parameters:
thirdParty- if true enable, false disable
-
getDisableAllo
public boolean getDisableAllo()Can be used to query whether the use of the ALLO command with GridFTP uploads is disabled. -
setDisableAllo
public void setDisableAllo(boolean disableAllo) Allows disabling of the use of ALLO with GridFTP uploads -
cancel
public void cancel()Cancels the transfer in progress. If no transfer is in progress it is ignored. -
isCanceled
public boolean isCanceled()Checks if the transfer was canceled.- Returns:
- true if transfer was canceled
-
run
public void run()This method is an implementation of theRunnableinterface and can be used to perform the copy in a separate thread.This method will perform the transfer and signal completion and errors through the
UrlCopyListener.transferCompleted()andUrlCopyListener.transferError(Exception)of any registered listeners (seeaddUrlCopyListener(UrlCopyListener)). -
copy
Performs the copy function. Source and destination urls must be specified otherwise a exception is thrown. Also, if source and destination url are ftp urls and thirdPartyCopy is enabled, third party transfer will be performed. Urls, of course, must be of supported protocol. Currently, gsiftp, ftp, https, http, and file are supported.This method does not cause the
UrlCopyListener.transferCompleted()andUrlCopyListener.transferError(Exception)to be called. If you want completion/failures to be signaled asynchronously, either call therun()method or wrap this object in aThread.- Throws:
UrlCopyException- in case of an error.
-
getInputStream
Returns input stream based on the source url- Throws:
Exception
-
getOutputStream
Returns output stream based on the destination url.- Throws:
Exception
-
transfer
private boolean transfer(long total, GlobusInputStream in, GlobusOutputStream out) throws IOException This function performs the actual transfer.- Throws:
IOException
-
fireUrlTransferProgressEvent
private void fireUrlTransferProgressEvent(long totalBytes, long transferedBytes) -
thirdPartyTransfer
This performs thrid party transfer only if source and destination urls are ftp urls.- Throws:
UrlCopyException
-
negotiateDCAU
- Throws:
IOExceptionFTPException
-
setDCAU
- Throws:
IOExceptionFTPException
-
createFTPConnection
-