com.partnersoft.io.net
Class GuppyActivist

java.lang.Object
  extended by com.partnersoft.io.net.GuppyActivist
All Implemented Interfaces:
GuppyConstants

public class GuppyActivist
extends java.lang.Object
implements GuppyConstants

This class can handle either side of a binary streamed Guppy conversation. It has convenience methods to write Guppy commands to output, and takes care of file updates etc. in response to input. This allows other classes to implement the logistics of establishing the input and output streams and logic.

Author:
Paul Reavis Copyright 2004 Partner Software, Inc.

Field Summary
 
Fields inherited from interface com.partnersoft.io.net.GuppyConstants
BLOCKSIZE, BUFFERSIZE, GZIP, OP_DIFF_FILE, OP_EOF, OP_EOT, OP_EXISTING_BLOCKS, OP_FILE_DIFFS, OP_FILE_LISTING, OP_LIST_FILES, OP_MD5, OP_MESSAGE, OP_NAMES, OP_NEW_BYTES, OP_NULL
 
Constructor Summary
GuppyActivist()
           
 
Method Summary
 boolean allowWrites()
           
 void eot()
           
 long getBytesReceived()
           
 long getBytesSent()
           
 long getBytesUpdated()
           
 java.io.DataInputStream getInput()
           
 java.io.DataOutputStream getOutput()
           
 java.io.File getRootDir()
           
 void logStatistics()
           
 void processRemainingInput()
          Reads the rest of the input stream and takes whatever action requires.
 java.util.ArrayList receiveFileListing(java.lang.String path)
          Returns the filesystem listing.
 void requestFileListing(java.lang.String path)
          Requests a filesystem listing.
 void requestFilesystemUpdate()
          Requests updates needed to match the server's file list.
 void requestFileUpdate(java.lang.String path)
          Requests an update to the file at the given path, using the rsync checksum-diff algorithm.
 void setAllowWrites(boolean shallI)
           
 void setInput(java.io.DataInputStream newInput)
           
 void setOutput(java.io.DataOutputStream newOutput)
           
 void setRootDir(java.io.File newDir)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GuppyActivist

public GuppyActivist()
Method Detail

setInput

public void setInput(java.io.DataInputStream newInput)

getInput

public java.io.DataInputStream getInput()

setOutput

public void setOutput(java.io.DataOutputStream newOutput)

getOutput

public java.io.DataOutputStream getOutput()

getRootDir

public java.io.File getRootDir()

setRootDir

public void setRootDir(java.io.File newDir)

allowWrites

public boolean allowWrites()

setAllowWrites

public void setAllowWrites(boolean shallI)

requestFileListing

public void requestFileListing(java.lang.String path)
                        throws java.io.IOException
Requests a filesystem listing. After you call this, set the input and call getFileListing()

Throws:
java.io.IOException

receiveFileListing

public java.util.ArrayList receiveFileListing(java.lang.String path)
                                       throws java.io.IOException
Returns the filesystem listing. You must have just requested one via requestFileListing(path). Path is used to verify the server's response matches what you expect.

Throws:
java.io.IOException

requestFilesystemUpdate

public void requestFilesystemUpdate()
                             throws java.io.IOException
Requests updates needed to match the server's file list. You must have run both requestFileListing() and receiveFileListing() so that we have the server listing. The output stream must also be set so we can send the commands.

Throws:
java.io.IOException

requestFileUpdate

public void requestFileUpdate(java.lang.String path)
                       throws java.io.IOException
Requests an update to the file at the given path, using the rsync checksum-diff algorithm. The update itself will happen during input processing.

Throws:
java.io.IOException

processRemainingInput

public void processRemainingInput()
                           throws java.io.IOException
Reads the rest of the input stream and takes whatever action requires. Does not close the input stream when done.

Throws:
java.io.IOException

eot

public void eot()
         throws java.io.IOException
Throws:
java.io.IOException

logStatistics

public void logStatistics()

getBytesSent

public long getBytesSent()

getBytesReceived

public long getBytesReceived()

getBytesUpdated

public long getBytesUpdated()