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

public abstract class TransferModule extends Object implements Closeable
The Class TransferModule.
  • 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

      public RemoteProvider getRemoteProvider()
      Gets the remote provider.
      Returns:
      the remote provider
    • getMSUser

      public MSUser getMSUser()
      Gets the MS user.
      Returns:
      the MS user
    • getECUser

      public ECUser getECUser()
      Gets the ECUser.
      Returns:
      the ECUser
    • getECtransModule

      public ECtransModule getECtransModule()
      Gets the ectrans module.
      Returns:
      the ectrans module
    • getECtransDestination

      public ECtransDestination getECtransDestination()
      Gets the ectrans destination.
      Returns:
      the ectrans destination
    • getCookie

      public String getCookie()
      Gets the cookie.
      Returns:
      the cookie
    • getClearPassword

      public String getClearPassword()
      Gets the clear password.
      Returns:
      the clear password
    • 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

      public abstract void connect(String location, ECtransSetup setup) throws Exception
      Connect.
      Parameters:
      location - the location
      setup - the setup
      Throws:
      Exception - the exception
    • getPort

      public int getPort(ECtransSetup setup) throws IOException
      Gets the port from the setup.
      Parameters:
      setup - the setup
      Returns:
      the port
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • del

      public abstract void del(String name) throws IOException
      Delete by name.
      Parameters:
      name - the name
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • mkdir

      public void mkdir(String dir) throws IOException
      Make directory by name.
      Parameters:
      dir - the dir
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • rmdir

      public void rmdir(String dir) throws IOException
      Remove directory by name.
      Parameters:
      dir - the dir
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • move

      public void move(String source, String target) throws IOException
      Move source to target.
      Parameters:
      source - the source
      target - the target
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • preGet

      public void preGet(String name, long posn) throws IOException
      Pre-get. When using an external module to transfer files this method is called first.
      Parameters:
      name - the name
      posn - the posn
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • get

      public abstract InputStream get(String name, long posn) throws IOException
      Gets the input stream to read the file given by name starting at posn.
      Parameters:
      name - the name
      posn - the posn
      Returns:
      the input stream
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • get

      public boolean get(OutputStream out, String name, long posn) throws IOException
      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 out
      name - the name
      posn - the posn
      Returns:
      true, if successful
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • prePut

      public String prePut(String name, String tmpName, long posn) throws IOException
      Pre-put. When using an external module to transfer files this method is called first to get the target filename!
      Parameters:
      name - the name
      tmpName - the tmp name
      posn - the posn
      Returns:
      the string
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • setInputFilter

      public void setInputFilter(String filter) throws IOException
      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

      public void setInputSize(long size) throws IOException
      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

      public void setInputMd5(String md5) throws IOException
      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

      public void setOutputFilter(String filter) throws IOException
      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

      public void delegateChecksum() throws IOException
      Instruct the transfer module that the checksum is delegated.
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • put

      public abstract OutputStream put(String name, long posn, long size) throws IOException
      Provide an output stream to write the content of the file given by its name starting at position posn.
      Parameters:
      name - the name
      posn - the posn
      size - the size
      Returns:
      the output stream
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • put

      public boolean put(InputStream in, String name, long posn, long size) throws IOException
      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 in
      name - the name
      posn - the posn
      size - the size
      Returns:
      true, if successful
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • updateSocketStatistics

      public void updateSocketStatistics() throws IOException
      Force an update of the statistics from the underlying socket.
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • copy

      public void copy(String source, String target, long posn, long size) throws IOException
      Copy the source file to the target file, starting at position posn and writing size bytes.
      Parameters:
      source - the source
      target - the target
      posn - the posn
      size - the size
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • check

      public void check(long sent, String checksum) throws IOException
      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 sent
      checksum - the checksum
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • size

      public abstract long size(String name) throws IOException
      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

      public String[] listAsStringArray(String directory, String pattern) throws IOException
      List as a string array.
      Parameters:
      directory - the directory
      pattern - the pattern
      Returns:
      the string[]
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • listAsByteArray

      public byte[] listAsByteArray(String directory, String pattern) throws IOException
      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 directory
      pattern - the pattern
      Returns:
      the bytes
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • list

      public void list(String directory, String pattern, OutputStream out) throws IOException
      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 directory
      pattern - the pattern
      out - the out
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • setAttribute

      public void setAttribute(Object key, Object value)
      Sets the attribute given by its key and value.
      Parameters:
      key - the key
      value - the value
    • getAttribute

      public Object getAttribute(Object key)
      Gets the attribute given by its key.
      Parameters:
      key - the key
      Returns:
      the attribute
    • 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

      public <T> T getAttribute(Class<T> key)
      Gets the attribute given by its class.
      Type Parameters:
      T - the generic type
      Parameters:
      key - the class
      Returns:
      the attribute value
    • containsAttribute

      public boolean containsAttribute(Object key)
      Check if the attribute exists by its key.
      Parameters:
      key - the key
      Returns:
      true if exists
    • getStatus

      public String getStatus()
      Gets the current status of the transfer module.
      Returns:
      the status