org.cdlib.xtf.util
Class DirSync

Object
  extended by DirSync

public class DirSync
extends Object

Routines to synchronize one directory hierarchy to match another. Now uses rsync for speed and simplicity, and adds a threshold above which we avoid per-subdirectory syncing and just do the whole thing.

Author:
Martin Haye

Field Summary
private  SubDirFilter filter
           
private static int MAX_RSYNC_BATCH
           
static int MAX_SELECTIVE_SYNC
           
 
Constructor Summary
DirSync()
          Initialize a directory syncer with no sub-directory filter (all sub-directories will be scanned.)
DirSync(SubDirFilter filter)
          Initialize with a sub-directory filter.
 
Method Summary
 void runRsync(File src, File dst, List<String> subDirs, String[] extraArgs)
          Run an rsync command with the standard arguments plus the specified subdirectories and optional extra args.
private  void selectiveSync(File srcDir, File dstDir)
          The main workhorse of the scanner.
 void syncDirs(File srcDir, File dstDir)
          Sync the files from source to dest.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_SELECTIVE_SYNC

public static final int MAX_SELECTIVE_SYNC
See Also:
Constant Field Values

MAX_RSYNC_BATCH

private static final int MAX_RSYNC_BATCH
See Also:
Constant Field Values

filter

private SubDirFilter filter
Constructor Detail

DirSync

public DirSync()
Initialize a directory syncer with no sub-directory filter (all sub-directories will be scanned.)


DirSync

public DirSync(SubDirFilter filter)
Initialize with a sub-directory filter.

Method Detail

syncDirs

public void syncDirs(File srcDir,
                     File dstDir)
              throws IOException
Sync the files from source to dest.

Parameters:
srcDir - Directory to match
dstDir - Directory to modify
Throws:
IOException - If anything goes wrong

selectiveSync

private void selectiveSync(File srcDir,
                           File dstDir)
                    throws IOException
The main workhorse of the scanner.

Parameters:
srcDir - Directory to match
dstDir - Directory to modify
Throws:
IOException - If anything goes wrong

runRsync

public void runRsync(File src,
                     File dst,
                     List<String> subDirs,
                     String[] extraArgs)
              throws IOException
Run an rsync command with the standard arguments plus the specified subdirectories and optional extra args.

Parameters:
src - Directory (or file) to match
dst - Directory (or file) to modify
subDirs - Sub-directories to rsync (null for all)
Throws:
IOException - If anything goes wrong