public class FileAgentImpl extends UnicastRemoteObject implements FileAgent
FileAgent
,
Serialized Formref
Constructor and Description |
---|
FileAgentImpl()
Constructs the file agent.
|
Modifier and Type | Method and Description |
---|---|
boolean |
doesFileExist(String fileName)
Checks whether the given remote file exists.
|
FileTransfer |
get(String srcFile,
String destFile)
Gets a file from the local system to the master.
|
String |
getProperty(String configFile,
String propName)
Gets a property from a given file.
|
boolean |
isDirectory(String fileName)
Checks whether the given remote file exists and is a directory.
|
boolean |
isFile(String fileName)
Checks whether the given remote file exists and is a normal file.
|
static void |
main(String[] argv)
Starts a standalong file agent.
|
FileService |
open(String file,
int mode)
This method creates a new FileServiceImpl object and returns a
reference to its interface, FileService.
|
long |
push(FileTransfer transfer)
Pushes a file, as encapsulated in the FileTransfer, from a the master
to this agent.
|
String |
readWholeFile(String file)
Read the contents of a file.
|
boolean |
removeFile(String fileName)
Removes a file.
|
boolean |
removeFiles(String dirName,
FileFilter filter)
Remove files from a directory matched by the filter.
|
boolean |
truncateFile(String fileName)
Truncates a file to zero-length.
|
boolean |
writeWholeFile(String fileName,
String contents)
Write contents to a file.
|
clone, exportObject, exportObject, exportObject, unexportObject
getClientHost, getLog, setLog
public FileAgentImpl() throws RemoteException
RemoteException
- A communications error occurred.public FileService open(String file, int mode) throws RemoteException, FileServiceException
open
in interface FileAgent
file
- - The pathname for the file.mode
- - specifies whether the file is opened for reading or
for writing. The mode is specified by the FileAgent
interface class variables - READ, WRITE, APPEND.RemoteException
- A communications error occurred.FileServiceException
- Error opening filepublic String readWholeFile(String file) throws IOException
readWholeFile
in interface FileAgent
file
- - The pathname for the fileIOException
- An I/O error occurredpublic String getProperty(String configFile, String propName) throws IOException
getProperty
in interface FileAgent
configFile
- The config file namepropName
- The property key nameIOException
- If there is an error accessing the config filepublic boolean writeWholeFile(String fileName, String contents)
writeWholeFile
in interface FileAgent
fileName
- - The pathname for the file.contents
- - Contents of the file as a String object.public boolean removeFile(String fileName)
removeFile
in interface FileAgent
fileName
- - The pathname for the file.public boolean truncateFile(String fileName)
truncateFile
in interface FileAgent
fileName
- The pathname for the filepublic boolean removeFiles(String dirName, FileFilter filter)
removeFiles
in interface FileAgent
dirName
- The directory path namefilter
- The filterpublic boolean doesFileExist(String fileName)
doesFileExist
in interface FileAgent
fileName
- The file name to test.public boolean isFile(String fileName)
public boolean isDirectory(String fileName)
isDirectory
in interface FileAgent
fileName
- The file name to test.public long push(FileTransfer transfer) throws RemoteException
push
in interface FileAgent
transfer
- The file transfer descriptionRemoteException
- If there is an error in the transferpublic FileTransfer get(String srcFile, String destFile) throws IOException
get
in interface FileAgent
srcFile
- The source file on the host the agent is running ondestFile
- The destination file on the masterRemoteException
- If there is an error reading or transferringIOException
- If there is an error reading or transferringpublic static void main(String[] argv)
argv
- Command line arguments, not used