org.metastatic.rsync.v2
Class Receiver

java.lang.Object
  |
  +--org.metastatic.rsync.v2.Receiver
All Implemented Interfaces:
Constants, EventListener, GeneratorListener, RebuilderListener

public class Receiver
extends Object
implements Constants, GeneratorListener, RebuilderListener

The receiver process. The receiver is the one who generates the checksums for the to-be-synched files, and receives the deltas. These two processes (checksum generation and applying deltas) are usually run in parallel -- one thread generates sums for one file while another thread rebuilds another file.


Field Summary
 
Fields inherited from interface org.metastatic.rsync.v2.Constants
_S_IFDIR, _S_IFLNK, _S_IFMT, _S_IFREG, AT_ERROR, BLOCK_LENGTH, CHUNK_SIZE, FLAG_DELETE, FLIST_RECEIVE_DONE, FLIST_RECEIVE_FILES, FLIST_RECEIVE_GIDS, FLIST_RECEIVE_UIDS, FLIST_SEND_DONE, FLIST_SEND_FILES, FLIST_SEND_GIDS, FLIST_SEND_UIDS, INPUT_MASK, LONG_NAME, MAX_PROTOCOL_VERSION, MAXPATHLEN, MIN_PROTOCOL_VERSION, OUTPUT_MASK, PROTOCOL_VERSION, RECV_RECEIVE_DELTAS, RECV_RECEIVE_INDEX, RECV_SEND_INDEX, RECV_SEND_SUMS, RECV_WAIT, RSYNCD_AUTHREQD, RSYNCD_EXIT, RSYNCD_GREETING, RSYNCD_OK, RSYNCD_PORT, SAME_DIR, SAME_GID, SAME_MODE, SAME_NAME, SAME_RDEV, SAME_TIME, SAME_UID, SENDER_DONE, SENDER_RECEIVE_INDEX, SENDER_RECEIVE_SUMS, SENDER_SEND_DELTAS, SENDER_SEND_FILE, SENDER_WAIT, SETUP_READ_AUTH, SETUP_READ_DONE, SETUP_READ_GREETING, SETUP_READ_MODULE, SETUP_READ_OPTIONS, SETUP_WRITE_CHALLENGE, SETUP_WRITE_DONE, SETUP_WRITE_ERROR, SETUP_WRITE_GREETING, SETUP_WRITE_MODULES, SETUP_WRITE_OK, SETUP_WRITE_WAIT, STATE_DONE, STATE_INPUT_DONE, STATE_OUTPUT_DONE, STATE_RECEIVE_EXCLUDE, STATE_RECEIVE_FLIST, STATE_RECEIVER, STATE_RECEIVER_INPUT, STATE_RECEIVER_OUTPUT, STATE_SEND_FLIST, STATE_SENDER, STATE_SENDER_INPUT, STATE_SENDER_OUTPUT, STATE_SETUP_PROTOCOL, SUM_LENGTH, URL_PREFIX
 
Constructor Summary
Receiver(MultiplexedInputStream in, MultiplexedOutputStream out, Configuration config, int remoteVersion, boolean amServer)
          Create a new receiver object.
 
Method Summary
 void generateFiles(List files)
          Generate the checksums for a list of files and send them to the other side.
 Statistics getStatistics()
          Return the statistics for this session.
 void receiveFiles(List files)
          Recieve the deltas from the other side, and rebuild the target files.
 void setStatistics(Statistics stats)
          Set the pre-initialized statistics object fer this session.
 void update(GeneratorEvent e)
          Update with a single, new checksum pair.
 void update(RebuilderEvent e)
          Upate this listener with an event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Receiver

public Receiver(MultiplexedInputStream in,
                MultiplexedOutputStream out,
                Configuration config,
                int remoteVersion,
                boolean amServer)
Create a new receiver object.

Parameters:
in - The input stream from the Sender.
out - The output stream to the Sender.
config - The configuration to use.
amServer - true if this is the server process.
Method Detail

getStatistics

public Statistics getStatistics()
Return the statistics for this session.

Returns:
The statistics.

setStatistics

public void setStatistics(Statistics stats)
Set the pre-initialized statistics object fer this session.

Parameters:
stats - The statistics object to use.

generateFiles

public void generateFiles(List files)
                   throws IOException
Generate the checksums for a list of files and send them to the other side.

Parameters:
files - The files to generate the checksums for.
Throws:
IOException - If an I/O error occurs.

receiveFiles

public void receiveFiles(List files)
                  throws IOException
Recieve the deltas from the other side, and rebuild the target files.

Parameters:
files - The list of Files to be received.
Throws:
IOException - If an I/O error occurs.

update

public void update(GeneratorEvent e)
            throws ListenerException
Description copied from interface: GeneratorListener
Update with a single, new checksum pair.

Specified by:
update in interface GeneratorListener
Parameters:
e - The event containing the next checksum pair.
ListenerException

update

public void update(RebuilderEvent e)
            throws ListenerException
Description copied from interface: RebuilderListener
Upate this listener with an event.

Specified by:
update in interface RebuilderListener
Parameters:
e - The event.
ListenerException