nl.uva.vlet.vfs
Class VFSTransfer

java.lang.Object
  extended by nl.uva.vlet.vfs.VFSTransfer

public class VFSTransfer
extends java.lang.Object

VFSTransfer class. Keeps record of ongoing transfers. VRS classes should update this transfer information.

The minimum use is:

 
      setStart() 
// dostuff...
setDone()


Constructor Summary
protected VFSTransfer(java.lang.String resourceType, VRL source, VRL destination, boolean isMove)
           
 
Method Summary
 void addLogText(java.lang.String txt)
          Add INFORMATIVE (for end user) text without newline to logtext
 void addSource(VRL vrl)
           
 void addSources(VRL[] vrls)
          Add extra source VRL to the source list, when recursive copying a directory First source in the sources vector is the starting (root) source as specified at construction time.
 VAttribute[] getAttributes()
           
 long getCurrentTransferred()
           
 long getCurrentTransferredLastUpdateTime()
           
 long getCurrentTransferSize()
           
 long getCurrentTransferStartTime()
           
 VRL getDestination()
           
 long getETA()
          Returns ETA in millis.
 VlException getException()
           
 int getId()
           
 java.lang.String getLogText()
           
 boolean getMustStop()
           
 int getNrOfSources()
          Get nr of sources currently transferred/being transferred.
 float getProgress()
           
 VFSNode getResultNode()
           
 VRL getRootDestination()
           
 VRL getSource()
           
 java.lang.String getSpeed()
           
 long getStartTime()
           
 java.lang.String getStatus()
           
 long getStopTime()
           
 long getTime()
           
 int getTotalNrOfSources()
           
 long getTotalTransferred()
           
 long getTotalTransferredLastUpdateTime()
           
 long getTotalTransferSize()
           
static VAttribute[][] getTransferAttributes()
          Returns transfers as attribute matrix
 boolean hasError()
           
 boolean isDone()
           
 boolean isMove()
           
protected  void markStarted()
          store system time when the transfer started
protected  void markStopped()
          stop system time when the transfer stopped.
static VFSTransfer newTransfer(java.lang.String type, VRL source, VRL dest, boolean isMove)
           
 void printReport(java.io.PrintStream output)
           
 void setCurrentTransferred(long size)
          Set nr bytes already transferred in current transfer
 void setCurrentTransferSize(long size)
          Set transfer size of current transfer.
 void setDone()
          Set Transfer status to done.
 void setException(VlException e)
           
 void setMustStop()
          Signal that this transfer must Stop!
 void setResultNode(VFSNode node)
           
 void setStart()
           
 void setTotalSources(int nr)
          Set the total nr of sources to be tranferred.
 void setTotalTransferred(long size)
           
 void setTotalTransferSize(long size)
          Set transfer size of current transfer
 java.lang.String toString()
           
 void waitForCompletion()
          This method will block until the setDone() method is called
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VFSTransfer

protected VFSTransfer(java.lang.String resourceType,
                      VRL source,
                      VRL destination,
                      boolean isMove)
Method Detail

getDestination

public VRL getDestination()
Returns:
Returns the destination.

getException

public VlException getException()
Returns:
Returns the exception.

getTime

public long getTime()

setException

public void setException(VlException e)
Parameters:
exception - The exception to set.

getId

public int getId()
Returns:
Returns the id.

isDone

public boolean isDone()
Returns:
Returns whether the tranfer is done.

setDone

public void setDone()
Set Transfer status to done. Make sure allt the status information has been updated (like setResultNode), since this method will wake up waiting threads !


isMove

public boolean isMove()
Returns:
Returns the isMove.

getStatus

public java.lang.String getStatus()

hasError

public boolean hasError()

getSpeed

public java.lang.String getSpeed()

getProgress

public float getProgress()

getSource

public VRL getSource()
Returns:
Returns the root source.

getRootDestination

public VRL getRootDestination()
Returns:
Returns the root source.

getNrOfSources

public int getNrOfSources()
Get nr of sources currently transferred/being transferred.

For a bulk upload method, this returns only 1 as the whole directory is seen as only 1 source. A recursive directory copy will return actual nr of files+ directories which currently are being transferred. This might be less the the total nr of sources as that nr might increase during the recursive copy.

A directory with one file will return '2' for the number of sources.


getTotalNrOfSources

public int getTotalNrOfSources()

setTotalSources

public void setTotalSources(int nr)
Set the total nr of sources to be tranferred. This is the number of files+directories.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

newTransfer

public static VFSTransfer newTransfer(java.lang.String type,
                                      VRL source,
                                      VRL dest,
                                      boolean isMove)

getTransferAttributes

public static VAttribute[][] getTransferAttributes()
Returns transfers as attribute matrix


getAttributes

public VAttribute[] getAttributes()

markStarted

protected void markStarted()
store system time when the transfer started


markStopped

protected void markStopped()
stop system time when the transfer stopped.


printReport

public void printReport(java.io.PrintStream output)

setCurrentTransferSize

public void setCurrentTransferSize(long size)
Set transfer size of current transfer. Will also update currentTransferSize to current as method implies as a new transfer.


setTotalTransferSize

public void setTotalTransferSize(long size)
Set transfer size of current transfer


setCurrentTransferred

public void setCurrentTransferred(long size)
Set nr bytes already transferred in current transfer


setTotalTransferred

public void setTotalTransferred(long size)

setMustStop

public void setMustStop()
Signal that this transfer must Stop!


addLogText

public void addLogText(java.lang.String txt)
Add INFORMATIVE (for end user) text without newline to logtext


getLogText

public java.lang.String getLogText()

addSources

public void addSources(VRL[] vrls)
Add extra source VRL to the source list, when recursive copying a directory First source in the sources vector is the starting (root) source as specified at construction time.

Parameters:
vrls -

addSource

public void addSource(VRL vrl)

getMustStop

public boolean getMustStop()

waitForCompletion

public void waitForCompletion()
                       throws VlInterruptedException
This method will block until the setDone() method is called

Throws:
VlInterruptedException

setResultNode

public void setResultNode(VFSNode node)

getResultNode

public VFSNode getResultNode()

setStart

public void setStart()

getTotalTransferred

public long getTotalTransferred()

getTotalTransferSize

public long getTotalTransferSize()

getCurrentTransferred

public long getCurrentTransferred()

getCurrentTransferSize

public long getCurrentTransferSize()

getStartTime

public long getStartTime()

getStopTime

public long getStopTime()

getCurrentTransferredLastUpdateTime

public long getCurrentTransferredLastUpdateTime()

getTotalTransferredLastUpdateTime

public long getTotalTransferredLastUpdateTime()

getCurrentTransferStartTime

public long getCurrentTransferStartTime()

getETA

public long getETA()
Returns ETA in millis. Depends on totalTransferred/totalTransferSize to calculate ETA.
 -1 = no statistics
  0 = done 
 >0 = estimated finished time in mill seconds 
 

Returns: