Class TransferModule
java.lang.Object
ecmwf.common.ectrans.TransferModule
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
AmazonS3Module,AzureModule,ExecModule,FileModule,FtpModule,FtpsModule,GCSModule,HttpModule,JSftpModule,PortalModule,ProxyModule,TestModule
The Class TransferModule.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCheck if the last put was successful comparing the number of bytes sent and the checksum provided to the one calculated.abstract voidconnect(String location, ECtransSetup setup) Connect.booleancontainsAttribute(Object key) Check if the attribute exists by its key.voidCopy the source file to the target file, starting at position posn and writing size bytes.abstract voidDelete by name.voidInstruct the transfer module that the checksum is delegated.booleanget(OutputStream out, String name, long posn) Gets the content of the file given by name written to the provided output stream, starting at posn.abstract InputStreamGets the input stream to read the file given by name starting at posn.<T> TgetAttribute(Class<T> key) Gets the attribute given by its class.getAttribute(Object key) Gets the attribute given by its key.booleanGets the available.Gets the clear password.booleanGets the closed on error.Gets the cookie.booleangetDebug()Gets the debug.Gets the ectrans destination.Gets the ectrans module.Gets the ECUser.Gets the MS user.intgetPort(ECtransSetup setup) Gets the port from the setup.Gets the remote provider.Gets the current status of the transfer module.voidlist(String directory, String pattern, OutputStream out) Default implementation to write the list to the provided output stream.byte[]listAsByteArray(String directory, String pattern) Default implementation to provide the list as a GZIPed byte array.String[]listAsStringArray(String directory, String pattern) List as a string array.voidMake directory by name.voidMove source to target.voidPre-get.Pre-put.booleanput(InputStream in, String name, long posn, long size) Write the content of the file given by its name, starting at position posn and writing to the provided input stream.abstract OutputStreamProvide an output stream to write the content of the file given by its name starting at position posn.voidRemove directory by name.voidsetAttribute(Object key, Object value) Sets the attribute given by its key and value.<T> voidsetAttribute(T value) Sets the attribute given by its key and value.voidsetAvailable(boolean available) Sets the available.voidsetClosedOnError(boolean closedOnError) Sets the closed on error.voidsetDebug(boolean debug) Sets the debug.voidsetInputFilter(String filter) Sets the input filter (for compression on the fly).voidsetInputMd5(String md5) Sets the input md5.voidsetInputSize(long size) Sets the input size.voidsetOutputFilter(String filter) Sets the output filter (for compression on the fly).abstract longGive the size of the file given by its name.voidForce an update of the statistics from the underlying socket.
-
Constructor Details
-
TransferModule
public TransferModule()
-
-
Method Details
-
setDebug
public void setDebug(boolean debug) Sets the debug.- Parameters:
debug- the new debug
-
setClosedOnError
public void setClosedOnError(boolean closedOnError) Sets the closed on error.- Parameters:
closedOnError- the new closed on error
-
setAvailable
public void setAvailable(boolean available) Sets the available.- Parameters:
available- the available
-
getRemoteProvider
-
getMSUser
-
getECUser
-
getECtransModule
-
getECtransDestination
Gets the ectrans destination.- Returns:
- the ectrans destination
-
getCookie
-
getClearPassword
-
getDebug
public boolean getDebug()Gets the debug.- Returns:
- the debug
-
getClosedOnError
public boolean getClosedOnError()Gets the closed on error.- Returns:
- the closed on error
-
getAvailable
public boolean getAvailable()Gets the available.- Returns:
- the available
-
connect
Connect.- Parameters:
location- the locationsetup- the setup- Throws:
Exception- the exception
-
getPort
Gets the port from the setup.- Parameters:
setup- the setup- Returns:
- the port
- Throws:
IOException- Signals that an I/O exception has occurred.
-
del
Delete by name.- Parameters:
name- the name- Throws:
IOException- Signals that an I/O exception has occurred.
-
mkdir
Make directory by name.- Parameters:
dir- the dir- Throws:
IOException- Signals that an I/O exception has occurred.
-
rmdir
Remove directory by name.- Parameters:
dir- the dir- Throws:
IOException- Signals that an I/O exception has occurred.
-
move
Move source to target.- Parameters:
source- the sourcetarget- the target- Throws:
IOException- Signals that an I/O exception has occurred.
-
preGet
Pre-get. When using an external module to transfer files this method is called first.- Parameters:
name- the nameposn- the posn- Throws:
IOException- Signals that an I/O exception has occurred.
-
get
Gets the input stream to read the file given by name starting at posn.- Parameters:
name- the nameposn- the posn- Returns:
- the input stream
- Throws:
IOException- Signals that an I/O exception has occurred.
-
get
Gets the content of the file given by name written to the provided output stream, starting at posn. By default, doing nothing and returning false.- Parameters:
out- the outname- the nameposn- the posn- Returns:
- true, if successful
- Throws:
IOException- Signals that an I/O exception has occurred.
-
prePut
Pre-put. When using an external module to transfer files this method is called first to get the target filename!- Parameters:
name- the nametmpName- the tmp nameposn- the posn- Returns:
- the string
- Throws:
IOException- Signals that an I/O exception has occurred.
-
setInputFilter
Sets the input filter (for compression on the fly).- Parameters:
filter- the new input filter- Throws:
IOException- Signals that an I/O exception has occurred.
-
setInputSize
Sets the input size. By default, is ignored.- Parameters:
size- the new input size- Throws:
IOException- Signals that an I/O exception has occurred.
-
setInputMd5
Sets the input md5. By default, is ignored.- Parameters:
md5- the new input md5- Throws:
IOException- Signals that an I/O exception has occurred.
-
setOutputFilter
Sets the output filter (for compression on the fly).- Parameters:
filter- the new output filter- Throws:
IOException- Signals that an I/O exception has occurred.
-
delegateChecksum
Instruct the transfer module that the checksum is delegated.- Throws:
IOException- Signals that an I/O exception has occurred.
-
put
Provide an output stream to write the content of the file given by its name starting at position posn.- Parameters:
name- the nameposn- the posnsize- the size- Returns:
- the output stream
- Throws:
IOException- Signals that an I/O exception has occurred.
-
put
Write the content of the file given by its name, starting at position posn and writing to the provided input stream. By default, doing nothing and returning false.- Parameters:
in- the inname- the nameposn- the posnsize- the size- Returns:
- true, if successful
- Throws:
IOException- Signals that an I/O exception has occurred.
-
updateSocketStatistics
Force an update of the statistics from the underlying socket.- Throws:
IOException- Signals that an I/O exception has occurred.
-
copy
Copy the source file to the target file, starting at position posn and writing size bytes.- Parameters:
source- the sourcetarget- the targetposn- the posnsize- the size- Throws:
IOException- Signals that an I/O exception has occurred.
-
check
Check if the last put was successful comparing the number of bytes sent and the checksum provided to the one calculated. By default, doing nothing.- Parameters:
sent- the sentchecksum- the checksum- Throws:
IOException- Signals that an I/O exception has occurred.
-
size
Give the size of the file given by its name.- Parameters:
name- the name- Returns:
- the long
- Throws:
IOException- Signals that an I/O exception has occurred.
-
listAsStringArray
List as a string array.- Parameters:
directory- the directorypattern- the pattern- Returns:
- the string[]
- Throws:
IOException- Signals that an I/O exception has occurred.
-
listAsByteArray
Default implementation to provide the list as a GZIPed byte array. The implementation should give a better implementation as this one is relying on the non optimal listAsStringArray method by default.- Parameters:
directory- the directorypattern- the pattern- Returns:
- the bytes
- Throws:
IOException- Signals that an I/O exception has occurred.
-
list
Default implementation to write the list to the provided output stream. The implementation should give a better implementation as this one is relying on the non optimal listAsStringArray method by default.- Parameters:
directory- the directorypattern- the patternout- the out- Throws:
IOException- Signals that an I/O exception has occurred.
-
setAttribute
-
getAttribute
-
setAttribute
public <T> void setAttribute(T value) Sets the attribute given by its key and value.- Type Parameters:
T- the generic type- Parameters:
value- the value
-
getAttribute
Gets the attribute given by its class.- Type Parameters:
T- the generic type- Parameters:
key- the class- Returns:
- the attribute value
-
containsAttribute
Check if the attribute exists by its key.- Parameters:
key- the key- Returns:
- true if exists
-
getStatus
-