use of org.onosproject.store.LogicalTimestamp in project onos by opennetworkinglab.
the class DeviceFlowTable method backupBucketToNode.
/**
* Backs up the given flow bucket to the given node.
*
* @param bucket the bucket to backup
* @param nodeId the node to which to back up the bucket
* @return a future to be completed once the bucket has been backed up
*/
private CompletableFuture<Void> backupBucketToNode(FlowBucket bucket, NodeId nodeId) {
// Record the logical timestamp from the bucket to keep track of the highest logical time replicated.
LogicalTimestamp timestamp = bucket.timestamp();
// If the backup can be run (no concurrent backup to the node in progress) then run it.
BackupOperation operation = new BackupOperation(nodeId, bucket.bucketId().bucket());
if (startBackup(operation, timestamp)) {
CompletableFuture<Void> future = new CompletableFuture<>();
backup(bucket, nodeId).whenCompleteAsync((succeeded, error) -> {
if (error != null) {
log.debug("Backup operation {} failed", operation, error);
failBackup(operation);
} else if (succeeded) {
succeedBackup(operation, timestamp);
} else {
log.debug("Backup operation {} failed: term mismatch", operation);
failBackup(operation);
}
future.complete(null);
}, executor);
return future;
}
return CompletableFuture.completedFuture(null);
}
Aggregations