com.sun.faban.common
Class FileTransfer

java.lang.Object
  extended by com.sun.faban.common.FileTransfer
All Implemented Interfaces:
Externalizable, Serializable

public class FileTransfer
extends Object
implements Externalizable

The FileTransfer class represents a file to be transferred via RMI from one to the other system. We override the serialization mechanism to ensure we don't need to suck the file's content into memory causing memory bloat. This is useful for transferring large files over RMI. As this object gets serialized, deserialized, the file transfer happens internally and the destination file gets created as a result of the deserialization. The file size limit is Long.MAX_VALUE (64bit).

Author:
Akara Sucharitakul
See Also:
Serialized Form

Constructor Summary
FileTransfer()
          The noarg constructore is used for deserializing.
FileTransfer(byte[] buffer, int offset, int length, String dest)
          Creates a file transfer object from a byte buffer.
FileTransfer(String src, String dest)
          Creates a file transfer object.
 
Method Summary
 String getDest()
          Obtains the destination file name.
 long getSize()
          Obtains the size of the file transferred, or 0 if the file transfer has not yet happen.
 String getSource()
          Obtains the sources file name.
 long getTransferSize()
          Obtains the size to be transferred on the sending side, or the size really transferred on the receiving side.
 void readExternal(ObjectInput in)
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileTransfer

public FileTransfer(String src,
                    String dest)
             throws IOException
Creates a file transfer object.

Parameters:
src - The source file name
dest - The destination file name
Throws:
IOException - Error reading the file to be transferred

FileTransfer

public FileTransfer(byte[] buffer,
                    int offset,
                    int length,
                    String dest)
Creates a file transfer object from a byte buffer.

Parameters:
buffer - The buffer
offset - The starting offset to use
length - The length of data to use, in bytes
dest - The destination file

FileTransfer

public FileTransfer()
The noarg constructore is used for deserializing.

Method Detail

getSource

public String getSource()
Obtains the sources file name.

Returns:
The source file name, or an empty string if the transfer happens from a buffer.

getDest

public String getDest()
Obtains the destination file name. *

Returns:
The destination file name

getSize

public long getSize()
Obtains the size of the file transferred, or 0 if the file transfer has not yet happen.

Returns:
The size of the file transferred, or 0

getTransferSize

public long getTransferSize()
Obtains the size to be transferred on the sending side, or the size really transferred on the receiving side.

Returns:
The transfer size

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException