Murtadha Hubail has submitted this change and it was merged. Change subject: [NO ISSUE][CLUS] Unexport Metadata Node Stub on NC Stop ......................................................................
[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]> --- M asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/NCAppRuntimeContext.java M asterixdb/asterix-app/src/test/java/org/apache/asterix/test/logging/CheckpointingTest.java 2 files changed, 46 insertions(+), 38 deletions(-) Approvals: abdullah alamoudi: Looks good to me, approved Jenkins: Verified; No violations found; ; Verified 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()); -- To view, visit https://asterix-gerrit.ics.uci.edu/2027 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: merged Gerrit-Change-Id: If7f1b7a294968e871465900b04c05cf388b776e4 Gerrit-PatchSet: 3 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Murtadha Hubail <[email protected]> Gerrit-Reviewer: Anon. E. Moose #1000171 Gerrit-Reviewer: Jenkins <[email protected]> Gerrit-Reviewer: Michael Blow <[email protected]> Gerrit-Reviewer: Murtadha Hubail <[email protected]> Gerrit-Reviewer: abdullah alamoudi <[email protected]>
