-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshotList;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshotList;
private static final Logger LOG = LoggerFactory.getLogger(DatastoreSnapshotRestore.class);
private static AtomicReference<DatastoreSnapshotRestore> instance = new AtomicReference<>();
private static final Logger LOG = LoggerFactory.getLogger(DatastoreSnapshotRestore.class);
private static AtomicReference<DatastoreSnapshotRestore> instance = new AtomicReference<>();
private final String restoreDirectoryPath;
private final Map<String, DatastoreSnapshot> datastoreSnapshots = new ConcurrentHashMap<>();
private final String restoreDirectoryPath;
private final Map<String, DatastoreSnapshot> datastoreSnapshots = new ConcurrentHashMap<>();
this.restoreDirectoryPath = Preconditions.checkNotNull(restoreDirectoryPath);
}
// synchronize this method so that, in case of concurrent access to getAndRemove(),
// no one ends up with partially initialized data
this.restoreDirectoryPath = Preconditions.checkNotNull(restoreDirectoryPath);
}
// synchronize this method so that, in case of concurrent access to getAndRemove(),
// no one ends up with partially initialized data
private synchronized void initialize() {
File restoreDirectoryFile = new File(restoreDirectoryPath);
String[] files = restoreDirectoryFile.list();
private synchronized void initialize() {
File restoreDirectoryFile = new File(restoreDirectoryPath);
String[] files = restoreDirectoryFile.list();
- if(files.length > 1) {
- LOG.error("Found {} files in clustered datastore restore directory {} - expected 1. No restore will be attempted",
- files.length, restoreDirectoryFile);
+ if (files.length > 1) {
+ LOG.error(
+ "Found {} files in clustered datastore restore directory {} - expected 1. No restore will be attempted",
+ files.length, restoreDirectoryFile);
DatastoreSnapshotList snapshots = deserialize(fis);
LOG.debug("Deserialized {} snapshots", snapshots.size());
DatastoreSnapshotList snapshots = deserialize(fis);
LOG.debug("Deserialized {} snapshots", snapshots.size());
- private static DatastoreSnapshotList deserialize(InputStream inputStream) throws IOException, ClassNotFoundException {
- try(ObjectInputStream ois = new ObjectInputStream(inputStream)) {
+ private static DatastoreSnapshotList deserialize(final InputStream inputStream)
+ throws IOException, ClassNotFoundException {
+ try (ObjectInputStream ois = new ObjectInputStream(inputStream)) {