WithSnapshot(final ShardDataTree store, final String shardName, final Logger log, final Snapshot snapshot) {
super(store, shardName, log);
- this.restoreFromSnapshot = requireNonNull(snapshot);
+ restoreFromSnapshot = requireNonNull(snapshot);
}
@Override
open = false;
}
- private File writeRoot(final String kind, final NormalizedNode<?, ?> node) {
+ private File writeRoot(final String kind, final NormalizedNode node) {
final File file = new File(System.getProperty("karaf.data", "."),
"failed-recovery-" + kind + "-" + shardName + ".xml");
NormalizedNodeXMLOutput.toFile(file, node);
public void applyRecoverySnapshot(final Snapshot.State snapshotState) {
if (!(snapshotState instanceof ShardSnapshotState)) {
log.debug("{}: applyRecoverySnapshot ignoring snapshot: {}", shardName, snapshotState);
+ return;
}
log.debug("{}: Applying recovered snapshot", shardName);
-
- ShardDataTreeSnapshot shardSnapshot = ((ShardSnapshotState)snapshotState).getSnapshot();
+ final ShardSnapshotState shardSnapshotState = (ShardSnapshotState)snapshotState;
try {
- store.applyRecoverySnapshot(shardSnapshot);
+ store.applyRecoverySnapshot(shardSnapshotState);
} catch (Exception e) {
+ final ShardDataTreeSnapshot shardSnapshot = shardSnapshotState.getSnapshot();
final File f = writeRoot("snapshot", shardSnapshot.getRootNode().orElse(null));
throw new IllegalStateException(String.format(
"%s: Failed to apply recovery snapshot %s. Node data was written to file %s",