crashMessage = errMsg;
if (ignoreCrash) {
throw new AssertionError("Faux crash of VoltDB successful.");
}
if (VoltDB.isThisATest()) {
VoltLogger log = new VoltLogger("HOST");
log.warn("Declining to drop a crash file during a junit test.");
}
// end test code
// try/finally block does its best to ensure death, no matter what context this
// is called in
try {
// slightly less important than death, this try/finally block protects code that
// prints a message to stdout
try {
// Even if the logger is null, don't stop. We want to log the stack trace and
// any other pertinent information to a .dmp file for crash diagnosis
List<String> currentStacktrace = new ArrayList<String>();
currentStacktrace.add("Stack trace from crashLocalVoltDB() method:");
// Create a special dump file to hold the stack trace
try
{
TimestampType ts = new TimestampType(new java.util.Date());
CatalogContext catalogContext = VoltDB.instance().getCatalogContext();
String root = catalogContext != null ? catalogContext.cluster.getVoltroot() + File.separator : "";
PrintWriter writer = new PrintWriter(root + "voltdb_crash" + ts.toString().replace(' ', '-') + ".txt");
writer.println("Time: " + ts);
writer.println("Message: " + errMsg);
writer.println();
writer.println("Platform Properties:");
PlatformProperties pp = PlatformProperties.getPlatformProperties();
String[] lines = pp.toLogLines().split("\n");
for (String line : lines) {
writer.println(line.trim());
}
if (thrown != null) {
writer.println();
writer.println("****** Exception Thread ****** ");
thrown.printStackTrace(writer);
}
printStackTraces(writer, currentStacktrace);
writer.close();
}
catch (Throwable err)
{
// shouldn't fail, but..
err.printStackTrace();
}
VoltLogger log = null;
try
{
log = new VoltLogger("HOST");
}
catch (RuntimeException rt_ex)
{ /* ignore */ }
if (log != null)
{
log.fatal(errMsg);
if (thrown != null) {
if (stackTrace) {
log.fatal("Fatal exception", thrown);
} else {
log.fatal(thrown.toString());
}
} else {
if (stackTrace) {
for (String currentStackElem : currentStacktrace) {
log.fatal(currentStackElem);
}
}
}
} else {
System.err.println(errMsg);