org.jboss.ha.framework.server
Class ClusterFileTransfer

java.lang.Object
  extended by org.jboss.ha.framework.server.ClusterFileTransfer
All Implemented Interfaces:
HAPartition.AsynchHAMembershipListener, HAPartition.HAMembershipListener

public class ClusterFileTransfer
extends Object
implements HAPartition.AsynchHAMembershipListener

Handles transfering files on the cluster. Files are sent in small chunks at a time (up to MAX_CHUNK_BUFFER_SIZE bytes per Cluster call).

Version:
$Revision: 1.1.2.5 $
Author:
Scott Marlow.

Nested Class Summary
static class ClusterFileTransfer.ClusterFileTransferException
          Exception wrapper class
 
Constructor Summary
ClusterFileTransfer(HAPartition partition, Map destinationDirectoryMap)
          Constructor needs the cluster partition and the mapping of server folder names to the java.io.File instance representing the physical folder.
 
Method Summary
static boolean localMove(File source, File destination)
           
 void membershipChanged(Vector deadMembers, Vector newMembers, Vector allMembers)
          Called when a new partition topology occurs.
 void pull(File file, String parentName)
          Get specified file from the cluster.
 void push(File file, String parentName, boolean leaveInTempFolder)
          Send specified file to cluster.
 org.jboss.ha.framework.server.ClusterFileTransfer.FileContentChunk remotePullOpenFile(File file, String originNodeName, ClusterNode originNode, String parentName)
          This is remotely called by pull(File , String ) to open the file on the machine that the file is being copied from.
 org.jboss.ha.framework.server.ClusterFileTransfer.FileContentChunk remotePullReadFile(File file, String originNodeName)
          This is remotely called by pull(File, String ) to read the file on the machine that the file is being copied from.
 void remotePushCloseFile(org.jboss.ha.framework.server.ClusterFileTransfer.FileContentChunk fileChunk, Boolean leaveInTempFolder, String parentName)
          Remote method for closing the file just transmitted.
 void remotePushWriteFile(org.jboss.ha.framework.server.ClusterFileTransfer.FileContentChunk fileChunk, String parentName)
          Remote method for writing file a fragment at a time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClusterFileTransfer

public ClusterFileTransfer(HAPartition partition,
                           Map destinationDirectoryMap)
Constructor needs the cluster partition and the mapping of server folder names to the java.io.File instance representing the physical folder.

Parameters:
partition - represents the cluster.
destinationDirectoryMap - is the mapping between server folder name and physical folder representation.
Method Detail

pull

public void pull(File file,
                 String parentName)
          throws ClusterFileTransfer.ClusterFileTransferException
Get specified file from the cluster.

Parameters:
file - identifies the file to get from the cluster.
parentName - is the parent folder name for the file on both source and destination nodes.
Throws:
ClusterFileTransfer.ClusterFileTransferException

remotePullOpenFile

public org.jboss.ha.framework.server.ClusterFileTransfer.FileContentChunk remotePullOpenFile(File file,
                                                                                             String originNodeName,
                                                                                             ClusterNode originNode,
                                                                                             String parentName)
This is remotely called by pull(File , String ) to open the file on the machine that the file is being copied from.

Parameters:
file - is the file to pull.
originNodeName - is the cluster node that is requesting the file.
parentName - is the parent folder name for the file on both source and destination nodes.
Returns:
FileContentChunk containing the first part of the file read after opening it.

remotePullReadFile

public org.jboss.ha.framework.server.ClusterFileTransfer.FileContentChunk remotePullReadFile(File file,
                                                                                             String originNodeName)
This is remotely called by pull(File, String ) to read the file on the machine that the file is being copied from.

Parameters:
file - is the file to pull.
originNodeName - is the cluster node that is requesting the file.
Returns:
FileContentChunk containing the next part of the file read.

push

public void push(File file,
                 String parentName,
                 boolean leaveInTempFolder)
          throws ClusterFileTransfer.ClusterFileTransferException
Send specified file to cluster.

Parameters:
file - is the file to send.
leaveInTempFolder - is true if the file should be left in the server temp folder.
Throws:
ClusterFileTransfer.ClusterFileTransferException

remotePushWriteFile

public void remotePushWriteFile(org.jboss.ha.framework.server.ClusterFileTransfer.FileContentChunk fileChunk,
                                String parentName)
Remote method for writing file a fragment at a time.

Parameters:
fileChunk -

remotePushCloseFile

public void remotePushCloseFile(org.jboss.ha.framework.server.ClusterFileTransfer.FileContentChunk fileChunk,
                                Boolean leaveInTempFolder,
                                String parentName)
Remote method for closing the file just transmitted.

Parameters:
fileChunk -
leaveInTempFolder - is true if we should leave the file in the server temp folder

membershipChanged

public void membershipChanged(Vector deadMembers,
                              Vector newMembers,
                              Vector allMembers)
Called when a new partition topology occurs. see HAPartition.AsynchHAMembershipListener

Specified by:
membershipChanged in interface HAPartition.HAMembershipListener
Parameters:
deadMembers - A list of nodes that have died since the previous view
newMembers - A list of nodes that have joined the partition since the previous view
allMembers - A list of nodes that built the current view

localMove

public static boolean localMove(File source,
                                File destination)
                         throws FileNotFoundException,
                                IOException
Throws:
FileNotFoundException
IOException


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.