public class UFTPSessionClient extends AbstractUFTPClient
Constructor and Description |
---|
UFTPSessionClient(InetAddress[] servers,
int port)
create a new UFTP session client
|
Modifier and Type | Method and Description |
---|---|
void |
cd(String dir)
change to the given remote directory
|
void |
cdUp()
change to the parent directory
|
static UFTPSessionClient |
create(String[] args)
create a session client instance from the supplied commandline parameters
|
void |
disconnect()
end the session
|
void |
get(String remoteFile,
long offset,
long length,
OutputStream localTarget)
partial read: get a chunk of a remote file
|
void |
get(String remoteFile,
OutputStream localTarget)
get the remote file and write it to the given local stream
|
File |
getBaseDirectory() |
List<FileInfo> |
getFileInfoList(String baseDir)
get file information for the given basedir (which is relative to the
current dir)
|
List<String> |
getFileList(String baseDir)
get the raw result of 'ls' for the given basedir (which is relative to
the current dir)
|
long |
getFileSize(String pathName) |
static String |
makeCommandline(String host,
int port,
String baseDirectory,
String secret,
int numStreams,
String encryptionKey,
int bufferSize,
boolean compress,
String commandFile)
create a correct commandline for passing the given parameters to a
UFTPSessionClient
|
void |
mkdir(String dir)
create a remote directory
|
void |
put(String remoteFile,
long size,
InputStream localSource)
write data to a remote file
|
void |
put(String remoteFile,
long size,
long offset,
InputStream localSource)
write data to a remote file
|
String |
pwd()
get the current directory
|
void |
rename(String from,
String to)
rename / move a remote file/directory
|
void |
rm(String path)
delete a remote file/directory
|
void |
run() |
void |
setBaseDirectory(File base)
set the local base directory
|
void |
setCommandFile(String commandFile) |
void |
setModificationTime(String path,
Calendar to)
set the modification time of a remote file/directory
|
FileInfo |
stat(String path)
get file information for the given file/dir (which is relative to the
current dir)
|
RsyncStats |
syncLocalFile(String remoteMaster,
File localSlave)
sync a local file with its up-to-date remote version
|
RsyncStats |
syncRemoteFile(File localMaster,
String remoteSlave)
sync a remote file with its up-to-date local version
|
void |
writeAll(String remoteFile,
InputStream localSource)
write all the data from the input stream to a remote file
|
cancel, cleanup, closeData, connect, createSocket, createSocket, getAuthtimeout, getBufferSize, getKey, getNumConnections, getProgressListener, getSecret, getServerFeatures, getServerList, getTimeout, isCompress, isConnected, openDataConnection, prepareGet, preparePut, setAuthtimeout, setBufferSize, setCompress, setKey, setNumConnections, setProgressListener, setSecret, setTimeout
public UFTPSessionClient(InetAddress[] servers, int port)
servers
- - list of alternative IP addresses of the UFTP serverport
- - the server portpublic void setCommandFile(String commandFile)
public void run()
public void disconnect() throws IOException
IOException
public void get(String remoteFile, OutputStream localTarget) throws IOException
remoteFile
- - the remote path (relative to the current dir)localTarget
- - the local target stream to write toIOException
public void get(String remoteFile, long offset, long length, OutputStream localTarget) throws IOException
remoteFile
- - the remote fileoffset
- - the first byte to read, starting at "0"length
- - the number of bytes to readlocalTarget
- - the local stream to write toIOException
public void put(String remoteFile, long size, long offset, InputStream localSource) throws IOException
remoteFile
- - the remote filesize
- - number of bytes to writeoffset
- - the offset to start writing the remote file atlocalSource
- - the local stream to read fromIOException
public void put(String remoteFile, long size, InputStream localSource) throws IOException
remoteFile
- - the remote filesize
- - number of bytes to writelocalSource
- - the local stream to read fromIOException
public void writeAll(String remoteFile, InputStream localSource) throws IOException
remoteFile
- - the remote filelocalSource
- - the local stream to read fromIOException
public List<String> getFileList(String baseDir) throws IOException
baseDir
- - the base dirIOException
public List<FileInfo> getFileInfoList(String baseDir) throws IOException
baseDir
- - the base dirIOException
public FileInfo stat(String path) throws IOException
path
- - the path of the file to statIOException
public long getFileSize(String pathName) throws IOException
IOException
public void cd(String dir) throws IOException
dir
- - the dir to change to, relative to the current oneIOException
public void cdUp() throws IOException
IOException
public void mkdir(String dir) throws IOException
dir
- - the dir to create, either absolute or relative to the
current oneIOException
public void rm(String path) throws IOException
path
- - the file/dir to delete, either absolute or relative to the
current oneIOException
public void rename(String from, String to) throws IOException
from
- - the file/dir to rename, either absolute or relative to the current dirto
- - the target file name, either absolute or relative to the current dirIOException
public void setModificationTime(String path, Calendar to) throws IOException
target
- - the file/dir to modifyto
- - the desired modification timeIOException
public String pwd() throws IOException
IOException
public RsyncStats syncLocalFile(String remoteMaster, File localSlave) throws Exception
remoteMaster
- - the remote file (up of date)localSlave
- - the local file (out of date)Exception
public RsyncStats syncRemoteFile(File localMaster, String remoteSlave) throws Exception
localMaster
- - the local file (up of date)remoteSlave
- - the remote file (out of date)Exception
public void setBaseDirectory(File base)
base
- - the base directorypublic File getBaseDirectory()
public static String makeCommandline(String host, int port, String baseDirectory, String secret, int numStreams, String encryptionKey, int bufferSize, boolean compress, String commandFile)
host
- - server host (can be a comma separated list of addresses)port
- - server portbaseDirectory
- - local base directorysecret
- - the secretnumStreams
- - the number of streamsencryptionKey
- - encryption key (base64), if null
, no
encryption will be usedbufferSize
- - size of the buffercommandFile
- - file to read commands frompublic static UFTPSessionClient create(String[] args) throws UnknownHostException, FileNotFoundException
args
- UnknownHostException
FileNotFoundException
Copyright © 2010–2016 UNICORE. All rights reserved.