Obtains log files for a Replica from other members of the replication
group. A Replica may need to do so if it has been offline for some time, and
has fallen behind in its execution of the replication stream.
During that time, the connected nodes may have reduced their log files by
deleting files after doing log cleaning. When this node rejoins the group,
it is possible that the current Master's log files do not go back far enough
to adequately
sync up this node. In that case, the node can use a
NetworkRestore object to copy the log files from one of the nodes in the
group. The system tries to avoid deleting log files that either would be
needed for replication by current nodes or where replication would be more
efficient than network restore.
A Replica discovers the need for a NetworkRestore operation when a call to
ReplicatedEnvironment() fails with a
InsufficientLogException.
A call to
NetworkRestore.execute() will copy the required log
files from a member of the group who owns the files and seems to be the
least busy. For example:
try {
node = new ReplicatedEnvironment(envDir, envConfig, repConfig);
} catch (InsufficientLogException insufficientLogEx) {
NetworkRestore restore = new NetworkRestore();
NetworkRestoreConfig config = new NetworkRestoreConfig();
config.setRetainLogFiles(false); // delete obsolete log files.
// Use the members returned by insufficientLogEx.getLogProviders() to
// select the desired subset of members and pass the resulting list
// as the argument to config.setLogProviders(), if the default selection
// of providers is not suitable.
restore.execute(insufficientLogEx, config);
// retry
node = new ReplicatedEnvironment(envDir, envConfig, repConfig);
}