add logic for manually triggered state dumps
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/AsterixStateDumpHandler.java b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/AsterixStateDumpHandler.java
new file mode 100644
index 0000000..bcb720f
--- /dev/null
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/AsterixStateDumpHandler.java
@@ -0,0 +1,34 @@
+package edu.uci.ics.asterix.hyracks.bootstrap;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import edu.uci.ics.hyracks.api.application.IStateDumpHandler;
+import edu.uci.ics.hyracks.api.lifecycle.ILifeCycleComponentManager;
+
+public class AsterixStateDumpHandler implements IStateDumpHandler {
+ private final String nodeId;
+ private final Path dumpPath;
+ private final ILifeCycleComponentManager lccm;
+
+ public AsterixStateDumpHandler(String nodeId, String dumpPath, ILifeCycleComponentManager lccm) {
+ this.nodeId = nodeId;
+ this.dumpPath = Paths.get(dumpPath);
+ this.lccm = lccm;
+ }
+
+ @Override
+ public void dumpState(OutputStream os) throws IOException {
+ dumpPath.toFile().mkdirs();
+ File df = dumpPath.resolve(nodeId + "-" + System.currentTimeMillis() + ".dump").toFile();
+ try (FileOutputStream fos = new FileOutputStream(df)) {
+ lccm.dumpState(fos);
+ }
+ os.write(df.getAbsolutePath().getBytes("UTF-8"));
+ }
+
+}
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
index d618974..5f41148 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
@@ -163,17 +163,19 @@
}
Map<String, String> lifecycleMgmtConfiguration = new HashMap<String, String>();
- String key = LifeCycleComponentManager.Config.DUMP_PATH_KEY;
- String value = metadataProperties.getCoredumpPath(nodeId);
- lifecycleMgmtConfiguration.put(key, value);
+ String dumpPathKey = LifeCycleComponentManager.Config.DUMP_PATH_KEY;
+ String dumpPath = metadataProperties.getCoredumpPath(nodeId);
+ lifecycleMgmtConfiguration.put(dumpPathKey, dumpPath);
if (LOGGER.isLoggable(Level.INFO)) {
- LOGGER.info("Coredump directory for NC is: " + value);
+ LOGGER.info("Coredump directory for NC is: " + dumpPath);
}
ILifeCycleComponentManager lccm = ncApplicationContext.getLifeCycleComponentManager();
lccm.configure(lifecycleMgmtConfiguration);
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info("Configured:" + lccm);
}
+ ncApplicationContext.setStateDumpHandler(new AsterixStateDumpHandler(ncApplicationContext.getNodeId(), lccm
+ .getDumpPath(), lccm));
lccm.startAll();
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/DatasetLifecycleManager.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/DatasetLifecycleManager.java
index b2e87d8..ba80c29 100644
--- a/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/DatasetLifecycleManager.java
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/DatasetLifecycleManager.java
@@ -454,7 +454,7 @@
datasetInfos.clear();
}
- private void dumpState(OutputStream outputStream) throws IOException {
+ public void dumpState(OutputStream outputStream) throws IOException {
StringBuilder sb = new StringBuilder();
sb.append(String.format("Memory budget = %d\n", capacity));
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/LockManager.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/LockManager.java
index 34d9f18..d1a6c1b 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/LockManager.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/LockManager.java
@@ -15,7 +15,6 @@
package edu.uci.ics.asterix.transaction.management.service.locking;
-import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Iterator;
@@ -2033,33 +2032,31 @@
@Override
public void stop(boolean dumpState, OutputStream os) {
if (dumpState) {
-
- //#. dump Configurable Variables
- dumpConfVars(os);
-
- //#. dump jobHT
- dumpJobInfo(os);
-
- //#. dump datasetResourceHT
- dumpDatasetLockInfo(os);
-
- //#. dump entityLockInfoManager
- dumpEntityLockInfo(os);
-
- //#. dump entityInfoManager
- dumpEntityInfo(os);
-
- //#. dump lockWaiterManager
-
- dumpLockWaiterInfo(os);
- try {
- os.flush();
- } catch (IOException e) {
- //ignore
- }
+ dumpState(os);
}
}
+ @Override
+ public void dumpState(OutputStream os) {
+ //#. dump Configurable Variables
+ dumpConfVars(os);
+
+ //#. dump jobHT
+ dumpJobInfo(os);
+
+ //#. dump datasetResourceHT
+ dumpDatasetLockInfo(os);
+
+ //#. dump entityLockInfoManager
+ dumpEntityLockInfo(os);
+
+ //#. dump entityInfoManager
+ dumpEntityInfo(os);
+
+ //#. dump lockWaiterManager
+ dumpLockWaiterInfo(os);
+ }
+
private void dumpConfVars(OutputStream os) {
try {
StringBuilder sb = new StringBuilder();
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogManager.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogManager.java
index 2a1e69f..a83bce0 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogManager.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogManager.java
@@ -184,20 +184,19 @@
public void stop(boolean dumpState, OutputStream os) {
terminateLogFlusher();
if (dumpState) {
- // #. dump Configurable Variables
- dumpConfVars(os);
-
- // #. dump LSNInfo
- dumpLSNInfo(os);
-
- try {
- os.flush();
- } catch (IOException e) {
- // ignore
- }
+ dumpState(os);
}
}
+ @Override
+ public void dumpState(OutputStream os) {
+ // #. dump Configurable Variables
+ dumpConfVars(os);
+
+ // #. dump LSNInfo
+ dumpLSNInfo(os);
+ }
+
private void dumpConfVars(OutputStream os) {
try {
StringBuilder sb = new StringBuilder();
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/RecoveryManager.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/RecoveryManager.java
index 166a150..1e34df6 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/RecoveryManager.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/RecoveryManager.java
@@ -448,10 +448,10 @@
if (isSharpCheckpoint) {
try {
- logMgr.renewLogFiles();
- } catch (IOException e) {
- throw new HyracksDataException(e);
- }
+ logMgr.renewLogFiles();
+ } catch (IOException e) {
+ throw new HyracksDataException(e);
+ }
}
if (isSharpCheckpoint && LOGGER.isLoggable(Level.INFO)) {
@@ -686,6 +686,11 @@
//no op
}
+ @Override
+ public void dumpState(OutputStream os) throws IOException {
+ // do nothing
+ }
+
private void undo(ILogRecord logRecord) {
try {
ILSMIndex index = (ILSMIndex) txnSubsystem.getAsterixAppRuntimeContextProvider().getIndexLifecycleManager()
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/transaction/TransactionManager.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/transaction/TransactionManager.java
index 07fc152..94be125 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/transaction/TransactionManager.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/transaction/TransactionManager.java
@@ -14,7 +14,6 @@
*/
package edu.uci.ics.asterix.transaction.management.service.transaction;
-import java.io.IOException;
import java.io.OutputStream;
import java.util.Map;
import java.util.Set;
@@ -153,17 +152,16 @@
@Override
public void stop(boolean dumpState, OutputStream os) {
if (dumpState) {
- //#. dump TxnContext
- dumpTxnContext(os);
-
- try {
- os.flush();
- } catch (IOException e) {
- //ignore
- }
+ dumpState(os);
}
}
+ @Override
+ public void dumpState(OutputStream os) {
+ //#. dump TxnContext
+ dumpTxnContext(os);
+ }
+
private void dumpTxnContext(OutputStream os) {
JobId jobId;
ITransactionContext txnCtx;