use of org.voltdb.utils.PlatformProperties in project voltdb by VoltDB.
the class VoltDB method crashLocalVoltDB.
/**
* Exit the process with an error message, optionally with a stack trace.
*/
public static void crashLocalVoltDB(String errMsg, boolean stackTrace, Throwable thrown) {
if (exitAfterMessage) {
System.err.println(errMsg);
VoltDB.exit(-1);
}
try {
OnDemandBinaryLogger.flush();
} catch (Throwable e) {
}
/*
* InvocationTargetException suppresses information about the cause, so unwrap until
* we get to the root cause
*/
while (thrown instanceof InvocationTargetException) {
thrown = ((InvocationTargetException) thrown).getCause();
}
// for test code
wasCrashCalled = true;
crashMessage = errMsg;
if (ignoreCrash) {
throw new AssertionError("Faux crash of VoltDB successful.");
}
if (CoreUtils.isJunitTest()) {
VoltLogger log = new VoltLogger("HOST");
log.warn("Declining to drop a crash file during a junit test.");
}
// end test code
// send a snmp trap crash notification
sendCrashSNMPTrap(errMsg);
// is called in
try {
// prints a message to stdout
try {
// we don't expect this to ever fail, but if it does, skip to dying immediately
if (!turnOffClientInterface()) {
// this will jump to the finally block and die faster
return;
}
// Flush trace files
try {
VoltTrace.closeAllAndShutdown(new File(instance().getVoltDBRootPath(), "trace_logs").getAbsolutePath(), TimeUnit.SECONDS.toMillis(10));
} catch (IOException e) {
}
// 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<>();
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 ? VoltDB.instance().getVoltDBRootPath() + 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(instance().getVersionString()).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);
if (thrown != null) {
if (stackTrace) {
thrown.printStackTrace();
} else {
System.err.println(thrown.toString());
}
} else {
if (stackTrace) {
for (String currentStackElem : currentStacktrace) {
System.err.println(currentStackElem);
}
}
}
}
} finally {
System.err.println("VoltDB has encountered an unrecoverable error and is exiting.");
System.err.println("The log may contain additional information.");
}
} finally {
ShutdownHooks.useOnlyCrashHooks();
System.exit(-1);
}
}
use of org.voltdb.utils.PlatformProperties in project voltdb by VoltDB.
the class RealVoltDB method logDebuggingInfo.
void logDebuggingInfo(int adminPort, int httpPort, String httpPortExtraLogMessage, boolean jsonEnabled) {
String startAction = m_config.m_startAction.toString();
String startActionLog = "Database start action is " + (startAction.substring(0, 1).toUpperCase() + startAction.substring(1).toLowerCase()) + ".";
if (!m_rejoining) {
hostLog.info(startActionLog);
}
// print out awesome network stuff
hostLog.info(String.format("Listening for native wire protocol clients on port %d.", m_config.m_port));
hostLog.info(String.format("Listening for admin wire protocol clients on port %d.", adminPort));
if (m_startMode == OperationMode.PAUSED) {
hostLog.info(String.format("Started in admin mode. Clients on port %d will be rejected in admin mode.", m_config.m_port));
}
if (getReplicationRole() == ReplicationRole.REPLICA) {
consoleLog.info("Started as " + getReplicationRole().toString().toLowerCase() + " cluster. " + "Clients can only call read-only procedures.");
}
if (httpPortExtraLogMessage != null) {
hostLog.info(httpPortExtraLogMessage);
}
if (httpPort != -1) {
hostLog.info(String.format("Local machine HTTP monitoring is listening on port %d.", httpPort));
} else {
hostLog.info(String.format("Local machine HTTP monitoring is disabled."));
}
if (jsonEnabled) {
hostLog.info(String.format("Json API over HTTP enabled at path /api/1.0/, listening on port %d.", httpPort));
} else {
hostLog.info("Json API disabled.");
}
// java heap size
long javamaxheapmem = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getMax();
javamaxheapmem /= (1024 * 1024);
hostLog.info(String.format("Maximum usable Java heap set to %d mb.", javamaxheapmem));
// Computed minimum heap requirement
long minRqt = computeMinimumHeapRqt(MiscUtils.isPro(), m_catalogContext.tables.size(), (m_iv2Initiators.size() - 1), m_configuredReplicationFactor);
hostLog.info("Minimum required Java heap for catalog and server config is " + minRqt + " MB.");
SortedMap<String, String> dbgMap = m_catalogContext.getDebuggingInfoFromCatalog(true);
for (String line : dbgMap.values()) {
hostLog.info(line);
}
// print out a bunch of useful system info
PlatformProperties pp = PlatformProperties.getPlatformProperties();
String[] lines = pp.toLogLines(getVersionString()).split("\n");
for (String line : lines) {
hostLog.info(line.trim());
}
if (m_catalogContext.cluster.getDrconsumerenabled() || m_catalogContext.cluster.getDrproducerenabled()) {
hostLog.info("DR initializing with Cluster Id " + m_catalogContext.cluster.getDrclusterid() + ". The DR cluster was first started at " + new Date(m_clusterCreateTime).toString() + ".");
}
final ZooKeeper zk = m_messenger.getZK();
ZKUtil.ByteArrayCallback operationModeFuture = new ZKUtil.ByteArrayCallback();
/*
* Publish our cluster metadata, and then retrieve the metadata
* for the rest of the cluster
*/
try {
zk.create(VoltZK.cluster_metadata + "/" + m_messenger.getHostId(), getLocalMetadata().getBytes("UTF-8"), Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL, new ZKUtil.StringCallback(), null);
zk.getData(VoltZK.operationMode, false, operationModeFuture, null);
} catch (Exception e) {
VoltDB.crashLocalVoltDB("Error creating \"/cluster_metadata\" node in ZK", true, e);
}
Map<Integer, String> clusterMetadata = new HashMap<>(0);
/*
* Spin and attempt to retrieve cluster metadata for all nodes in the cluster.
*/
Set<Integer> metadataToRetrieve = new HashSet<>(m_messenger.getLiveHostIds());
metadataToRetrieve.remove(m_messenger.getHostId());
while (!metadataToRetrieve.isEmpty()) {
Map<Integer, ZKUtil.ByteArrayCallback> callbacks = new HashMap<>();
for (Integer hostId : metadataToRetrieve) {
ZKUtil.ByteArrayCallback cb = new ZKUtil.ByteArrayCallback();
zk.getData(VoltZK.cluster_metadata + "/" + hostId, false, cb, null);
callbacks.put(hostId, cb);
}
for (Map.Entry<Integer, ZKUtil.ByteArrayCallback> entry : callbacks.entrySet()) {
try {
ZKUtil.ByteArrayCallback cb = entry.getValue();
Integer hostId = entry.getKey();
clusterMetadata.put(hostId, new String(cb.getData(), "UTF-8"));
metadataToRetrieve.remove(hostId);
} catch (KeeperException.NoNodeException e) {
} catch (Exception e) {
VoltDB.crashLocalVoltDB("Error retrieving cluster metadata", true, e);
}
}
}
// print out cluster membership
hostLog.info("About to list cluster interfaces for all nodes with format [ip1 ip2 ... ipN] client-port,admin-port,http-port");
for (int hostId : m_messenger.getLiveHostIds()) {
if (hostId == m_messenger.getHostId()) {
hostLog.info(String.format(" Host id: %d with interfaces: %s [SELF]", hostId, MiscUtils.formatHostMetadataFromJSON(getLocalMetadata())));
} else {
String hostMeta = clusterMetadata.get(hostId);
hostLog.info(String.format(" Host id: %d with interfaces: %s [PEER]", hostId, MiscUtils.formatHostMetadataFromJSON(hostMeta)));
}
}
try {
if (operationModeFuture.getData() != null) {
String operationModeStr = new String(operationModeFuture.getData(), "UTF-8");
m_startMode = OperationMode.valueOf(operationModeStr);
}
} catch (KeeperException.NoNodeException e) {
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.voltdb.utils.PlatformProperties in project voltdb by VoltDB.
the class ReportMaker method liveReport.
/**
* Find the pre-compild catalog report in the jarfile, and modify it for use in the
* the built-in web portal.
*/
public static String liveReport() {
byte[] reportbytes = VoltDB.instance().getCatalogContext().getFileInJar("catalog-report.html");
String report = new String(reportbytes, Charsets.UTF_8);
// remove commented out code
report = report.replace("<!--##RESOURCES", "");
report = report.replace("##RESOURCES-->", "");
// inject the cluster overview
//String clusterStr = "<h4>System Overview</h4>\n<p>" + getLiveSystemOverview() + "</p><br/>\n";
//report = report.replace("<!--##CLUSTER##-->", clusterStr);
// inject the running system platform properties
PlatformProperties pp = PlatformProperties.getPlatformProperties();
String ppStr = "<h4>Cluster Platform</h4>\n<p>" + pp.toHTML() + "</p><br/>\n";
report = report.replace("<!--##PLATFORM2##-->", ppStr);
// change the live/static var to live
if (VoltDB.instance().getConfig().m_isEnterprise) {
report = report.replace("&b=r&", "&b=e&");
} else {
report = report.replace("&b=r&", "&b=c&");
}
return report;
}
Aggregations