Package org.lsst.ccs.config
Class RemoteFileServer
java.lang.Object
org.lsst.ccs.config.RemoteFileServer
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 Summary
ConstructorsConstructorDescriptionRemoteFileServer(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.RemoteFileServer(String descName, String mountPoint, Properties p) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the connection to the underlying FileSystem.booleanCheck if a file exists in the remote file servergetBufferedWriter(Path path, OpenOption... options) Get an BufferedWriter for writing data for a given Path and OpenOptions.Get the underlying FileSystem.getInputStream(Path path, OpenOption... options) Get an InputStream for reading data for a given Path and OpenOptions.getOutputStream(Path path, OpenOption... options) Get an OutputStream for writing data for a given Path and OpenOptions.
-
Constructor Details
-
RemoteFileServer
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 classmountPoint- The mount point
-
RemoteFileServer
-
-
Method Details
-
getInputStream
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
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
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
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
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.
-