com.sleepycat.je.rep.impl.networkRestore
Class NetworkBackup

java.lang.Object
  extended by com.sleepycat.je.rep.impl.networkRestore.NetworkBackup

public class NetworkBackup
extends Object

This class implements a hot network backup that permits it to obtain a consistent set of log files from any running environment that provides a LogFileFeeder service. This class thus plays the role of a client, and the running environment that of a server.

The log files that are retrieved over the network are placed in a directory that can serve as an environment directory for a JE stand alone or HA environment. If log files are already present in the target directory, it will try reuse them, if they are really consistent with those on the server. Extant log files that are no longer part of the current backup file set are deleted or are renamed, depending on how the backup operation was configured.

Renamed backup files have the following syntax: NNNNNNNN.bup. where the backup number is the number associated with the backup attempt, rather than with an individual file. That is, the backup number is increased by one each time a backup is repeated in the same directory and log files actually needed to be renamed.

The implementation tries to be resilient in the face of network failures and minimizes the amount of work that might need to be done if the client or server were to fail and had to be restarted. Users of this API must be careful to ensure that the execute() completes successfully before accessing the environment. [Sam: should we create a je.lck file to ensure that this is the case?]


Nested Class Summary
protected static class NetworkBackup.DigestException
          Exception indicating that the digest sent by the server did not match the digest computed by the client, that is, the log file was corrupted during transit.
static class NetworkBackup.InsufficientVLSNRangeException
          Exception indicating that the server vlsn range did not cover the VLSN of interest.
static class NetworkBackup.LoadThresholdExceededException
           
 
Field Summary
(package private)  MessageDigest messageDigest
           
(package private)  int serverLoadThreshold
           
 
Constructor Summary
NetworkBackup(InetSocketAddress serverSocket, File envDir, NameIdPair clientNameId, boolean retainLogfiles, FileManager fileManager)
          Convenience overloading.
NetworkBackup(InetSocketAddress serverSocket, int receiveBufferSize, File envDir, NameIdPair clientNameId, boolean retainLogfiles, int serverLoadThreshold, VLSN minVLSN, RepImpl repImpl, FileManager fileManager)
          Creates a configured backup instance which when executed will backup the files to the environment directory.
 
Method Summary
 String[] execute()
          Execute the backup.
protected  void getFile(File file)
          Requests and obtains the specific log file from the server.
 StatGroup getStats()
          Returns statistics associated with the NetworkBackup execution.
 void setTestBarrier(CyclicBarrier testBarrier)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serverLoadThreshold

final int serverLoadThreshold

messageDigest

final MessageDigest messageDigest
Constructor Detail

NetworkBackup

public NetworkBackup(InetSocketAddress serverSocket,
                     int receiveBufferSize,
                     File envDir,
                     NameIdPair clientNameId,
                     boolean retainLogfiles,
                     int serverLoadThreshold,
                     VLSN minVLSN,
                     RepImpl repImpl,
                     FileManager fileManager)
              throws IllegalArgumentException
Creates a configured backup instance which when executed will backup the files to the environment directory.

Parameters:
serverSocket - the socket on which to contact the server
receiveBufferSize - the receive buffer size to be associated with the socket used for the log file transfers.
envDir - the directory in which to place the log files
clientNameId - the id used to identify this client
retainLogfiles - determines whether obsolete log files should be retained by renaming them, instead of deleting them.
serverLoadThreshold - only backup from this server if it has fewer than this number of feeders active.
minVLSN - the VLSN that should be covered by the server. It ensures that the log files are sufficiently current for this client's needs.
Throws:
IllegalArgumentException - if the environment directory is not valid. When used internally, this should be caught appropriately.

NetworkBackup

public NetworkBackup(InetSocketAddress serverSocket,
                     File envDir,
                     NameIdPair clientNameId,
                     boolean retainLogfiles,
                     FileManager fileManager)
              throws DatabaseException
Convenience overloading.

Throws:
DatabaseException
See Also:
NetworkBackup(InetSocketAddress, int, File, NameIdPair, boolean, int, VLSN, RepImpl, FileManager)
Method Detail

getStats

public StatGroup getStats()
Returns statistics associated with the NetworkBackup execution.


execute

public String[] execute()
                 throws IOException,
                        DatabaseException,
                        ServiceDispatcher.ServiceConnectFailedException,
                        NetworkBackup.LoadThresholdExceededException,
                        NetworkBackup.InsufficientVLSNRangeException
Execute the backup.

Throws:
ServiceDispatcher.ServiceConnectFailedException
NetworkBackup.LoadThresholdExceededException
NetworkBackup.InsufficientVLSNRangeException
IOException
DatabaseException

getFile

protected void getFile(File file)
                throws IOException,
                       BinaryProtocol.ProtocolException,
                       NetworkBackup.DigestException
Requests and obtains the specific log file from the server. The file is first created under a name with the .tmp suffix and is renamed to its true name only after its digest has been verified. This method is protected to facilitate error testing.

Throws:
IOException
BinaryProtocol.ProtocolException
NetworkBackup.DigestException

setTestBarrier

public void setTestBarrier(CyclicBarrier testBarrier)


Copyright (c) 2004-2012 Oracle. All rights reserved.