p2pMapReduce.impl.ftp
Class FTPManagerImpl

java.lang.Object
  extended by p2pMapReduce.impl.ftp.FTPManagerImpl
All Implemented Interfaces:
FTPManager

public class FTPManagerImpl
extends java.lang.Object
implements FTPManager

An implementation of the FTPManager interface based on apache libraries. An instance could be obtained by FTPManagerFactory.createFTPManager() Every download path parameters must be a relative path that refers to local ftp base directory as current directory. No absolute paths are allowed


Constructor Summary
FTPManagerImpl(java.io.File userPropFile, int ftpPort)
           
 
Method Summary
 boolean download(java.lang.String host, int port, java.lang.String user, java.lang.String pass, java.lang.String[] path, java.io.File[] dest, boolean[] results)
          Deprecated.  
 boolean download(java.lang.String host, int port, java.lang.String user, java.lang.String pass, java.lang.String path, java.io.File dest)
          Deprecated.  
 boolean downloadDir(NodeInfo remoteNode, java.lang.String dirPath)
          Download the content of the directory dirPath from the specified node in a directory with the same path on the local ftp base directory
 boolean downloadDir(NodeInfo remoteNode, java.lang.String dirPath, java.lang.String destDir)
          Download the content of the directory dirPath from the specified node in the directory destDir
 boolean downloadDir(java.lang.String host, int port, java.lang.String dirPath)
          Download the remote directory in a local directory which path is the same of the remote directory, relatively to the FTP home directory If necessary the directory is created
 boolean downloadDir(java.lang.String host, int port, java.lang.String dir, java.lang.String destDir)
          Download all the content from remote directory dir in the local directory destDir
 boolean downloadFile(NodeInfo remoteNode, java.lang.String filePath)
          Download the specified file from the specified node.
 boolean downloadFile(NodeInfo remoteNode, java.lang.String srcFilePath, java.lang.String dstFilePath)
          Download the file srcFilePath from the specified node.
 boolean downloadFile(java.lang.String host, int port, java.lang.String filePath)
          Download the remote file in a local file which path is the same of the remote file, relatively to the FTP home directory If necessary the directory tree of the file is created
 boolean downloadFile(java.lang.String host, int port, java.lang.String srcFilePath, java.lang.String dstFilePath)
          Download the remote file in a local file which path is dstFilePath relatively to the FTP home directory.
 java.lang.String getBaseDir()
          Returns the path to the directory used as root directory by FTP server
 int getFtpPort()
          The local port on which FTP server listen
 java.lang.String getIpAddress()
          Find for a InetAddress which is not a loopback address and return InetAddress.getHostAddress() result.
 void startLocalServer()
          Starts the local ftp server
 boolean upload(java.lang.String host, int port, java.lang.String user, java.lang.String pass, java.io.File[] srcFiles, java.lang.String[] destPaths, java.lang.String[] destFileNames, boolean[] results)
          Deprecated. to test
 boolean upload(java.lang.String host, int port, java.lang.String user, java.lang.String pass, java.io.File[] srcFiles, java.lang.String destPath, java.lang.String[] destFileNames, boolean[] results)
          Deprecated. to test
 boolean uploadFile(NodeInfo remoteNode, java.lang.String srcFilePath, java.lang.String destPath, java.lang.String destFileName)
           
 boolean uploadFile(java.lang.String host, int port, java.lang.String srcFilePath, java.lang.String destPath, java.lang.String destFileName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FTPManagerImpl

public FTPManagerImpl(java.io.File userPropFile,
                      int ftpPort)
Method Detail

startLocalServer

public void startLocalServer()
                      throws java.io.IOException
Description copied from interface: FTPManager
Starts the local ftp server

Specified by:
startLocalServer in interface FTPManager
Throws:
java.io.IOException

getBaseDir

public java.lang.String getBaseDir()
Returns the path to the directory used as root directory by FTP server

Specified by:
getBaseDir in interface FTPManager
Returns:
The path to FTP server root directory, null if the server has not been stared yet

getIpAddress

public java.lang.String getIpAddress()
Find for a InetAddress which is not a loopback address and return InetAddress.getHostAddress() result. If all InetAddress are loopback addresses utilize InetAddress.getLocalHost()

Specified by:
getIpAddress in interface FTPManager
Returns:
The string representation of the ip address for this FTP server

getFtpPort

public int getFtpPort()
The local port on which FTP server listen

Specified by:
getFtpPort in interface FTPManager
Returns:

downloadFile

public boolean downloadFile(NodeInfo remoteNode,
                            java.lang.String filePath)
Description copied from interface: FTPManager
Download the specified file from the specified node. The file will be downloaded in the same path in the local ftp base directory

Specified by:
downloadFile in interface FTPManager
Returns:

downloadFile

public boolean downloadFile(NodeInfo remoteNode,
                            java.lang.String srcFilePath,
                            java.lang.String dstFilePath)
Description copied from interface: FTPManager
Download the file srcFilePath from the specified node. The file will be downloaded in the specified path dstFilePath which must contain also the file name.

Specified by:
downloadFile in interface FTPManager
Returns:

downloadFile

public boolean downloadFile(java.lang.String host,
                            int port,
                            java.lang.String filePath)
Download the remote file in a local file which path is the same of the remote file, relatively to the FTP home directory If necessary the directory tree of the file is created

Parameters:
host -
port -
filePath -
Returns:

downloadFile

public boolean downloadFile(java.lang.String host,
                            int port,
                            java.lang.String srcFilePath,
                            java.lang.String dstFilePath)
Download the remote file in a local file which path is dstFilePath relatively to the FTP home directory. If necessary the directory tree of the file is created

Parameters:
host -
port -
filePath -
dstFilePath -
Returns:

downloadDir

public boolean downloadDir(NodeInfo remoteNode,
                           java.lang.String dirPath)
Description copied from interface: FTPManager
Download the content of the directory dirPath from the specified node in a directory with the same path on the local ftp base directory

Specified by:
downloadDir in interface FTPManager
Returns:

downloadDir

public boolean downloadDir(NodeInfo remoteNode,
                           java.lang.String dirPath,
                           java.lang.String destDir)
Description copied from interface: FTPManager
Download the content of the directory dirPath from the specified node in the directory destDir

Specified by:
downloadDir in interface FTPManager
Returns:
True if the operation is successfully completed

downloadDir

public boolean downloadDir(java.lang.String host,
                           int port,
                           java.lang.String dirPath)
Download the remote directory in a local directory which path is the same of the remote directory, relatively to the FTP home directory If necessary the directory is created

Parameters:
host -
port -
dirPath -
Returns:

downloadDir

public boolean downloadDir(java.lang.String host,
                           int port,
                           java.lang.String dir,
                           java.lang.String destDir)
Download all the content from remote directory dir in the local directory destDir

Parameters:
host -
port -
dir -
destDir -
Returns:

download

public boolean download(java.lang.String host,
                        int port,
                        java.lang.String user,
                        java.lang.String pass,
                        java.lang.String[] path,
                        java.io.File[] dest,
                        boolean[] results)
Deprecated. 

Parameters:
host -
port -
user -
pass -
path -
dest -
results -
Returns:

download

public boolean download(java.lang.String host,
                        int port,
                        java.lang.String user,
                        java.lang.String pass,
                        java.lang.String path,
                        java.io.File dest)
Deprecated. 

Parameters:
host -
port -
user -
pass -
path -
dest -
Returns:

uploadFile

public boolean uploadFile(NodeInfo remoteNode,
                          java.lang.String srcFilePath,
                          java.lang.String destPath,
                          java.lang.String destFileName)

uploadFile

public boolean uploadFile(java.lang.String host,
                          int port,
                          java.lang.String srcFilePath,
                          java.lang.String destPath,
                          java.lang.String destFileName)
Parameters:
srcFilePath - File da uplodare
dest - Path del file (dove salvarlo)
dim - la dimensione del file
Returns:
True se l'upload รจ stato eseguito con successo

upload

public boolean upload(java.lang.String host,
                      int port,
                      java.lang.String user,
                      java.lang.String pass,
                      java.io.File[] srcFiles,
                      java.lang.String destPath,
                      java.lang.String[] destFileNames,
                      boolean[] results)
Deprecated. to test

Parameters:
host -
port -
user -
pass -
srcFiles -
destPath -
destFileNames -
results -
Returns:

upload

public boolean upload(java.lang.String host,
                      int port,
                      java.lang.String user,
                      java.lang.String pass,
                      java.io.File[] srcFiles,
                      java.lang.String[] destPaths,
                      java.lang.String[] destFileNames,
                      boolean[] results)
Deprecated. to test

Parameters:
host -
port -
user -
pass -
srcFiles -
destPaths -
destFileNames -
results -
Returns: