Repository: asterixdb Updated Branches: refs/heads/master 8351d2531 -> 62cdcc253
[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 <[email protected]> Tested-by: Jenkins <[email protected]> Contrib: Jenkins <[email protected]> Integration-Tests: Jenkins <[email protected]> Reviewed-by: abdullah alamoudi <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/62cdcc25 Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/62cdcc25 Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/62cdcc25 Branch: refs/heads/master Commit: 62cdcc2532a080f4549e1e6e61d4f9e8dddb9350 Parents: 8351d25 Author: Murtadha Hubail <[email protected]> Authored: Mon Sep 25 22:53:14 2017 +0300 Committer: Murtadha Hubail <[email protected]> Committed: Mon Sep 25 20:18:33 2017 -0700 ---------------------------------------------------------------------- .../asterix/app/nc/NCAppRuntimeContext.java | 10 ++- .../asterix/test/logging/CheckpointingTest.java | 74 +++++++++++--------- 2 files changed, 46 insertions(+), 38 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/asterixdb/blob/62cdcc25/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/NCAppRuntimeContext.java ---------------------------------------------------------------------- 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 @@ public class NCAppRuntimeContext implements INcApplicationContext { } @Override - public void preStop() throws Exception { + public synchronized void preStop() throws Exception { activeManager.shutdown(); + if (metadataNodeStub != null) { + unexportMetadataNodeStub(); + } } @Override @@ -455,7 +458,7 @@ public class NCAppRuntimeContext implements INcApplicationContext { } @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 @@ public class NCAppRuntimeContext implements INcApplicationContext { } @Override - public void unexportMetadataNodeStub() throws RemoteException { + public synchronized void unexportMetadataNodeStub() throws RemoteException { UnicastRemoteObject.unexportObject(MetadataNode.INSTANCE, false); + metadataNodeStub = null; } public NCExtensionManager getNcExtensionManager() { http://git-wip-us.apache.org/repos/asf/asterixdb/blob/62cdcc25/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/logging/CheckpointingTest.java ---------------------------------------------------------------------- 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 @@ public class CheckpointingTest { 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());
