Class AmazonS3Module

java.lang.Object
ecmwf.common.ectrans.TransferModule
ecmwf.common.ectrans.module.AmazonS3Module
All Implemented Interfaces:
Closeable, AutoCloseable

public final class AmazonS3Module extends TransferModule
The Class AmazonS3Module.
  • Constructor Details

    • AmazonS3Module

      public AmazonS3Module()
  • Method Details

    • getStatus

      public String getStatus()
      Gets the status.
      Overrides:
      getStatus in class TransferModule
      Returns:
      the status
    • getPort

      public int getPort(ECtransSetup setup)
      Gets the port.
      Overrides:
      getPort in class TransferModule
      Parameters:
      setup - the setup
      Returns:
      the port
    • updateSocketStatistics

      public void updateSocketStatistics() throws IOException
      Update socket statistics.
      Overrides:
      updateSocketStatistics in class TransferModule
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • connect

      public void connect(String location, ECtransSetup setup) throws IOException
      Connect.
      Specified by:
      connect in class TransferModule
      Parameters:
      location - the location
      setup - the setup
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • getConnectedRemoteAddress

      public String getConnectedRemoteAddress()
      Gets the real IP address of the remote host this module most recently connected to, if the underlying protocol implementation tracks it. This can differ from the configured Host address for anycast/load-balanced endpoints (e.g. Amazon S3, Google Cloud Storage), where a fresh DNS lookup of the same hostname performed later (e.g. for "Live ECPDS Earth" geolocation) may return a different IP than the one actually used for the transfer. Overridden by modules that track this (currently s3 and http/https); other modules keep the default of null, meaning the configured Host address should be used instead. Returns the real IP address of the S3 endpoint most recently connected to, tracked via the socket factories (see AmazonS3Module.TcpTunedSslSocketFactory/AmazonS3Module.TcpTunedPlainSocketFactory). Preferred over resolving hostName via DNS again later, since Amazon S3 (and other S3-compatible/anycast services such as Google Cloud Storage) may resolve a hostname to a different IP on every lookup.
      Overrides:
      getConnectedRemoteAddress in class TransferModule
      Returns:
      the remote IP address, or null if not tracked or not yet connected
    • del

      public void del(String name) throws IOException
      Del.
      Specified by:
      del in class TransferModule
      Parameters:
      name - the name
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • put

      public boolean put(InputStream in, String name, long posn, long size) throws IOException
      Put.
      Overrides:
      put in class TransferModule
      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.
    • put

      public OutputStream put(String name, long posn, long size) throws IOException
      Put.
      Specified by:
      put in class TransferModule
      Parameters:
      name - the name
      posn - the posn
      size - the size
      Returns:
      the output stream
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • get

      public InputStream get(String name, long posn) throws IOException
      Gets the.
      Specified by:
      get in class TransferModule
      Parameters:
      name - the name
      posn - the posn
      Returns:
      the input stream
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • size

      public long size(String name) throws IOException
      Size.
      Specified by:
      size in class TransferModule
      Parameters:
      name - the name
      Returns:
      the long
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • mkdir

      public void mkdir(String directory) throws IOException
      Mkdir.
      Overrides:
      mkdir in class TransferModule
      Parameters:
      directory - the directory
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • rmdir

      public void rmdir(String directory) throws IOException
      Rmdir.
      Overrides:
      rmdir in class TransferModule
      Parameters:
      directory - the directory
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • listAsStringArray

      public String[] listAsStringArray(String directory, String pattern) throws IOException
      List as string array.
      Overrides:
      listAsStringArray in class TransferModule
      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
      List as byte array.
      Overrides:
      listAsByteArray in class TransferModule
      Parameters:
      directory - the directory
      pattern - the pattern
      Returns:
      the byte[]
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • close

      public void close() throws IOException
      Close.
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • formatS3Exception

      public static String formatS3Exception(software.amazon.awssdk.services.s3.model.S3Exception e)
      Formats a S3Exception into a single-line string with the key AWS diagnostic fields.
      Parameters:
      e - the S3Exception
      Returns:
      formatted string