Class RemoteFileServer

java.lang.Object
org.lsst.ccs.config.RemoteFileServer

public class RemoteFileServer extends Object
A wrapper class to grant access to a remote FileSystem. There can be multiple instances of this class. For the same cache name they will share the same instance of the FileSystem.
Author:
LSST CCS Team
  • Constructor Details

    • RemoteFileServer

      public RemoteFileServer(String descName, String mountPoint)
      Create an instance of a remote file server with a given cache name.The cache name will be used as the mount point for a local cache.
      Parameters:
      descName - The description name for the agent using this class
      mountPoint - The mount point
    • RemoteFileServer

      public RemoteFileServer(String descName, String mountPoint, Properties p)
  • Method Details

    • getInputStream

      public InputStream getInputStream(Path path, OpenOption... options) throws IOException
      Get an InputStream for reading data for a given Path and OpenOptions.
      Parameters:
      path - The Path of the file to open.
      options - The OpenOption array to open the file with.
      Returns:
      The corresponding InputStream
      Throws:
      IOException
    • exists

      public boolean exists(Path path)
      Check if a file exists in the remote file server
      Parameters:
      path - The path to check.
      Returns:
      true/false if the path exists or not.
    • getBufferedWriter

      public BufferedWriter getBufferedWriter(Path path, OpenOption... options) throws IOException
      Get an BufferedWriter for writing data for a given Path and OpenOptions.
      Parameters:
      path - The Path of the file to open.
      options - The OpenOption array to open the file with.
      Returns:
      The corresponding BufferedWriter
      Throws:
      IOException
    • getOutputStream

      public OutputStream getOutputStream(Path path, OpenOption... options) throws IOException
      Get an OutputStream for writing data for a given Path and OpenOptions.
      Parameters:
      path - The Path of the file to open.
      options - The OpenOption array to open the file with.
      Returns:
      The corresponding OutputStream
      Throws:
      IOException
    • getFileSystem

      public FileSystem getFileSystem()
      Get the underlying FileSystem.
      Returns:
      The FileSystem.
    • close

      public void close()
      Close the connection to the underlying FileSystem. This method can be called at any point by any of the clients using any of the RemoteFileServers sharing the same FileSystem. Not particularly a nice implementation. A better implementation could be to turn this class into an AgentService and manage the lifetime of the FileSystem in the service itself, rather than delegating to external clients.