[NO ISSUE][CLUS] Unexport Metadata Node Stub on NC Stop
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
- Unexport metadata node stub on NC stop to avoid
java.rmi.server.ExportException on subsequent NC
startup on save JVM.
Change-Id: If7f1b7a294968e871465900b04c05cf388b776e4
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2027
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: abdullah alamoudi <bamousaa@gmail.com>
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/NCAppRuntimeContext.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/NCAppRuntimeContext.java
index 3591bf0..eedc8ec 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/NCAppRuntimeContext.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/NCAppRuntimeContext.java
@@ -284,8 +284,11 @@
}
@Override
- public void preStop() throws Exception {
+ public synchronized void preStop() throws Exception {
activeManager.shutdown();
+ if (metadataNodeStub != null) {
+ unexportMetadataNodeStub();
+ }
}
@Override
@@ -455,7 +458,7 @@
}
@Override
- public void exportMetadataNodeStub() throws RemoteException {
+ public synchronized void exportMetadataNodeStub() throws RemoteException {
if (metadataNodeStub == null) {
metadataNodeStub = (IMetadataNode) UnicastRemoteObject.exportObject(MetadataNode.INSTANCE,
getMetadataProperties().getMetadataPort());
@@ -464,8 +467,9 @@
}
@Override
- public void unexportMetadataNodeStub() throws RemoteException {
+ public synchronized void unexportMetadataNodeStub() throws RemoteException {
UnicastRemoteObject.unexportObject(MetadataNode.INSTANCE, false);
+ metadataNodeStub = null;
}
public NCExtensionManager getNcExtensionManager() {
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/logging/CheckpointingTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/logging/CheckpointingTest.java
index 370205b..41b3d38 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/logging/CheckpointingTest.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/logging/CheckpointingTest.java
@@ -218,41 +218,45 @@
try {
TestNodeController nc = new TestNodeController(new File(TEST_CONFIG_FILE_PATH).getAbsolutePath(), false);
nc.init();
- final ITransactionSubsystem txnSubsystem = nc.getTransactionSubsystem();
- final AbstractCheckpointManager checkpointManager =
- (AbstractCheckpointManager) txnSubsystem.getCheckpointManager();
- // Make a checkpoint with the current minFirstLSN
- final long minFirstLSN = txnSubsystem.getRecoveryManager().getMinFirstLSN();
- checkpointManager.tryCheckpoint(minFirstLSN);
- // Get the just created checkpoint
- final Checkpoint validCheckpoint = checkpointManager.getLatest();
- // Make sure the valid checkout wouldn't force full recovery
- Assert.assertTrue(validCheckpoint.getMinMCTFirstLsn() >= minFirstLSN);
- // Add a corrupted (empty) checkpoint file with a timestamp > than current checkpoint
- Path corruptedCheckpointPath = checkpointManager.getCheckpointPath(validCheckpoint.getTimeStamp() + 1);
- File corruptedCheckpoint = corruptedCheckpointPath.toFile();
- corruptedCheckpoint.createNewFile();
- // Make sure the corrupted checkpoint file was created
- Assert.assertTrue(corruptedCheckpoint.exists());
- // Try to get the latest checkpoint again
- Checkpoint cpAfterCorruption = checkpointManager.getLatest();
- // Make sure the valid checkpoint was returned
- Assert.assertEquals(validCheckpoint.getTimeStamp(), cpAfterCorruption.getTimeStamp());
- // Make sure the corrupted checkpoint file was deleted
- Assert.assertFalse(corruptedCheckpoint.exists());
- // Corrupt the valid checkpoint by replacing its content
- final Path validCheckpointPath = checkpointManager.getCheckpointPath(validCheckpoint.getTimeStamp());
- File validCheckpointFile = validCheckpointPath.toFile();
- Assert.assertTrue(validCheckpointFile.exists());
- // Delete the valid checkpoint file and create it as an empty file
- validCheckpointFile.delete();
- validCheckpointFile.createNewFile();
- // Make sure the returned checkpoint (the forged checkpoint) will enforce full recovery
- Checkpoint forgedCheckpoint = checkpointManager.getLatest();
- Assert.assertTrue(forgedCheckpoint.getMinMCTFirstLsn() < minFirstLSN);
- // Make sure the forged checkpoint recovery will start from the first available log
- final long readableSmallestLSN = txnSubsystem.getLogManager().getReadableSmallestLSN();
- Assert.assertTrue(forgedCheckpoint.getMinMCTFirstLsn() <= readableSmallestLSN);
+ try {
+ final ITransactionSubsystem txnSubsystem = nc.getTransactionSubsystem();
+ final AbstractCheckpointManager checkpointManager =
+ (AbstractCheckpointManager) txnSubsystem.getCheckpointManager();
+ // Make a checkpoint with the current minFirstLSN
+ final long minFirstLSN = txnSubsystem.getRecoveryManager().getMinFirstLSN();
+ checkpointManager.tryCheckpoint(minFirstLSN);
+ // Get the just created checkpoint
+ final Checkpoint validCheckpoint = checkpointManager.getLatest();
+ // Make sure the valid checkout wouldn't force full recovery
+ Assert.assertTrue(validCheckpoint.getMinMCTFirstLsn() >= minFirstLSN);
+ // Add a corrupted (empty) checkpoint file with a timestamp > than current checkpoint
+ Path corruptedCheckpointPath = checkpointManager.getCheckpointPath(validCheckpoint.getTimeStamp() + 1);
+ File corruptedCheckpoint = corruptedCheckpointPath.toFile();
+ corruptedCheckpoint.createNewFile();
+ // Make sure the corrupted checkpoint file was created
+ Assert.assertTrue(corruptedCheckpoint.exists());
+ // Try to get the latest checkpoint again
+ Checkpoint cpAfterCorruption = checkpointManager.getLatest();
+ // Make sure the valid checkpoint was returned
+ Assert.assertEquals(validCheckpoint.getTimeStamp(), cpAfterCorruption.getTimeStamp());
+ // Make sure the corrupted checkpoint file was deleted
+ Assert.assertFalse(corruptedCheckpoint.exists());
+ // Corrupt the valid checkpoint by replacing its content
+ final Path validCheckpointPath = checkpointManager.getCheckpointPath(validCheckpoint.getTimeStamp());
+ File validCheckpointFile = validCheckpointPath.toFile();
+ Assert.assertTrue(validCheckpointFile.exists());
+ // Delete the valid checkpoint file and create it as an empty file
+ validCheckpointFile.delete();
+ validCheckpointFile.createNewFile();
+ // Make sure the returned checkpoint (the forged checkpoint) will enforce full recovery
+ Checkpoint forgedCheckpoint = checkpointManager.getLatest();
+ Assert.assertTrue(forgedCheckpoint.getMinMCTFirstLsn() < minFirstLSN);
+ // Make sure the forged checkpoint recovery will start from the first available log
+ final long readableSmallestLSN = txnSubsystem.getLogManager().getReadableSmallestLSN();
+ Assert.assertTrue(forgedCheckpoint.getMinMCTFirstLsn() <= readableSmallestLSN);
+ } finally {
+ nc.deInit();
+ }
} catch (Throwable e) {
e.printStackTrace();
Assert.fail(e.getMessage());