asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Till Westmann (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: WIP - stop transaction subsystem
Date Mon, 16 May 2016 00:57:15 GMT
Till Westmann has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/847

Change subject: WIP - stop transaction subsystem
......................................................................

WIP - stop transaction subsystem

Change-Id: I9a67a977fa1f2718e02b2bfb28a2b0ed2d5242a7
---
M asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/AsterixAppRuntimeContext.java
M asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
M asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/IAsterixAppRuntimeContext.java
M asterixdb/asterix-common/src/main/java/org/apache/asterix/common/transactions/ITransactionSubsystem.java
M asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/recovery/CheckpointThread.java
M asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/transaction/TransactionSubsystem.java
6 files changed, 31 insertions(+), 13 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/47/847/1

diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/AsterixAppRuntimeContext.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/AsterixAppRuntimeContext.java
index 8342be5..b56a60e 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/AsterixAppRuntimeContext.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/AsterixAppRuntimeContext.java
@@ -127,8 +127,9 @@
     private IRemoteRecoveryManager remoteRecoveryManager;
     private IReplicaResourcesManager replicaResourcesManager;
     private final int metadataRmiPort;
+    private final boolean initialRun;
 
-    public AsterixAppRuntimeContext(INCApplicationContext ncApplicationContext, int metadataRmiPort)
+    public AsterixAppRuntimeContext(INCApplicationContext ncApplicationContext, int metadataRmiPort,
boolean initialRun)
             throws AsterixException {
         this.ncApplicationContext = ncApplicationContext;
         // Determine whether to use old-style asterix-configuration.xml or new-style configuration.
@@ -151,10 +152,11 @@
         replicationProperties = new AsterixReplicationProperties(propertiesAccessor,
                 AsterixClusterProperties.INSTANCE.getCluster());
         this.metadataRmiPort = metadataRmiPort;
+        this.initialRun = initialRun;
     }
 
     @Override
-    public void initialize(boolean initialRun) throws IOException, ACIDException, AsterixException
{
+    public void initialize() throws IOException, ACIDException, AsterixException {
         Logger.getLogger("org.apache").setLevel(externalProperties.getLogLevel());
 
         threadExecutor = new AsterixThreadExecutor(ncApplicationContext.getThreadFactory());
@@ -279,6 +281,7 @@
 
     @Override
     public void deinitialize() throws HyracksDataException {
+        txnSubsystem.stop();
     }
 
     @Override
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
index 643bb16..52af859 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
@@ -96,7 +96,7 @@
             LOGGER.info("Starting Asterix node controller: " + nodeId);
         }
 
-        runtimeContext = new AsterixAppRuntimeContext(ncApplicationContext, metadataRmiPort);
+        runtimeContext = new AsterixAppRuntimeContext(ncApplicationContext, metadataRmiPort,
initialRun);
         AsterixMetadataProperties metadataProperties = ((IAsterixPropertiesProvider) runtimeContext)
                 .getMetadataProperties();
         if (!metadataProperties.getNodeNames().contains(ncApplicationContext.getNodeId()))
{
@@ -105,7 +105,7 @@
             }
             updateOnNodeJoin();
         }
-        runtimeContext.initialize(initialRun);
+        runtimeContext.initialize();
         ncApplicationContext.setApplicationObject(runtimeContext);
         messageBroker = new NCMessageBroker((NodeControllerService) ncAppCtx.getControllerService());
         ncApplicationContext.setMessageBroker(messageBroker);
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/IAsterixAppRuntimeContext.java
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/IAsterixAppRuntimeContext.java
index ee9ed4a..60f679a 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/IAsterixAppRuntimeContext.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/IAsterixAppRuntimeContext.java
@@ -65,7 +65,7 @@
 
     public ILSMOperationTracker getLSMBTreeOperationTracker(int datasetID);
 
-    public void initialize(boolean initialRun) throws IOException, ACIDException, AsterixException;
+    public void initialize() throws IOException, ACIDException, AsterixException;
 
     public void setShuttingdown(boolean b);
 
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/transactions/ITransactionSubsystem.java
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/transactions/ITransactionSubsystem.java
index 4ce84b5..6a3b321 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/transactions/ITransactionSubsystem.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/transactions/ITransactionSubsystem.java
@@ -31,6 +31,8 @@
 
     public IAsterixAppRuntimeContextProvider getAsterixAppRuntimeContextProvider();
 
+    public void stop();
+
     public String getId();
 
 }
diff --git a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/recovery/CheckpointThread.java
b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/recovery/CheckpointThread.java
index c3cf3e0..0f7d305 100644
--- a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/recovery/CheckpointThread.java
+++ b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/recovery/CheckpointThread.java
@@ -53,9 +53,8 @@
             try {
                 sleep(checkpointTermInSecs * 1000);
             } catch (InterruptedException e) {
-                //ignore
+                return;
             }
-
 
             if(lastCheckpointLSN == -1)
             {
diff --git a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/transaction/TransactionSubsystem.java
b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/transaction/TransactionSubsystem.java
index f7ed355..0b40fa0 100644
--- a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/transaction/TransactionSubsystem.java
+++ b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/transaction/TransactionSubsystem.java
@@ -54,9 +54,8 @@
 
     //for profiling purpose
     public static final boolean IS_PROFILE_MODE = false;//true
-    public long profilerEntityCommitLogCount = 0;
-    private EntityCommitProfiler ecp;
-    private Future<Object> fecp;
+    private volatile long profilerEntityCommitLogCount = 0;
+    private Future<EntityCommitProfiler> fecp;
 
     public TransactionSubsystem(String id, IAsterixAppRuntimeContextProvider asterixAppRuntimeContextProvider,
             AsterixTransactionProperties txnProperties) throws ACIDException {
@@ -90,8 +89,23 @@
         }
 
         if (IS_PROFILE_MODE) {
-            ecp = new EntityCommitProfiler(this, this.txnProperties.getCommitProfilerReportInterval());
-            fecp = (Future<Object>) getAsterixAppRuntimeContextProvider().getThreadExecutor().submit(ecp);
+            EntityCommitProfiler ecp = new EntityCommitProfiler(this, this.txnProperties
+                    .getCommitProfilerReportInterval());
+            fecp = (Future<EntityCommitProfiler>) getAsterixAppRuntimeContextProvider().getThreadExecutor().submit(ecp);
+        }
+    }
+
+    public void stop() {
+        if (IS_PROFILE_MODE) {
+            fecp.cancel(true);
+        }
+        if (this.checkpointThread != null) {
+            this.checkpointThread.interrupt();
+            try {
+                this.checkpointThread.join();
+            } catch (InterruptedException e) {
+                // nothing to do, we're quitting anyway
+            }
         }
     }
 
@@ -149,7 +163,7 @@
             this.txnSubsystem = txnSubsystem;
             this.reportIntervalInSeconds = reportIntervalInSeconds;
             this.reportIntervalInMillisec = reportIntervalInSeconds * 1000;
-            lastEntityCommitCount = txnSubsystem.profilerEntityCommitLogCount;
+            this.lastEntityCommitCount = txnSubsystem.profilerEntityCommitLogCount;
         }
 
         @Override

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/847
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9a67a977fa1f2718e02b2bfb28a2b0ed2d5242a7
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Till Westmann <tillw@apache.org>

Mime
View raw message