sumitagrawl commented on code in PR #8917:
URL: https://github.com/apache/ozone/pull/8917#discussion_r2267001721
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/spi/impl/ReconDBProvider.java:
##########
@@ -115,4 +128,25 @@ public void close() throws Exception {
dbStore = null;
}
}
+
+ public void replaceStagedDb(ReconDBProvider stagedReconDBProvider) throws
Exception {
+ File dbPath = dbStore.getDbLocation();
+ File stagedDbPath = stagedReconDBProvider.getDbStore().getDbLocation();
+ File backupPath = new File(dbPath.getAbsolutePath() + ".backup");
+ stagedReconDBProvider.close();
+ try {
+ FileUtils.deleteDirectory(backupPath);
+ FileUtils.moveDirectory(dbPath, backupPath);
+ close();
+ FileUtils.moveDirectory(stagedDbPath, backupPath);
+ dbStore = initializeDBStore(configuration, dbPath.getName());
+ } catch (Exception e) {
+ if (dbStore == null) {
Review Comment:
when close() is done before reinitializeDBStore(), its updated to null. So
if initializeDBStore() throw exception, it will be null and revert to older
value.
if not null, means either previous DB path present and running fine OR new
db path is initialized successfully.
Moved close() before rename of previous db.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]