本文整理汇总了Java中com.jamonapi.utils.Misc类的典型用法代码示例。如果您正苦于以下问题:Java Misc类的具体用法?Java Misc怎么用?Java Misc使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Misc类属于com.jamonapi.utils包,在下文中一共展示了Misc类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: trackException
import com.jamonapi.utils.Misc; //导入依赖的package包/类
/**
* Count the thrown exception and put the stack trace in the details portion of the key.
* This will allow the stack trace to be viewed in the JAMon web application.
*/
protected void trackException(MonKey key, Throwable ex) {
String stackTrace = "stackTrace=" + Misc.getExceptionTrace(ex);
key.setDetails(stackTrace);
// Specific exception counter. Example: java.lang.RuntimeException
MonitorFactory.add(new MonKeyImp(ex.getClass().getName(), stackTrace, "Exception"), 1);
// General exception counter which is a total for all exceptions thrown
MonitorFactory.add(new MonKeyImp(MonitorFactory.EXCEPTIONS_LABEL, stackTrace, "Exception"), 1);
}
示例2: getJsonStatus
import com.jamonapi.utils.Misc; //导入依赖的package包/类
@Override
public JsonObject getJsonStatus() {
JsonObject status = new JsonObject();
{
JsonObject java = new JsonObject();
java.addProperty("version", System.getProperty("java.version"));
status.add("java", java);
}
{
JsonObject memory = new JsonObject();
memory.addProperty("max", Runtime.getRuntime().maxMemory());
memory.addProperty("free", Runtime.getRuntime().freeMemory());
memory.addProperty("total", Runtime.getRuntime().totalMemory());
status.add("memory", memory);
}
{
JsonObject application = new JsonObject();
application.addProperty("uptime", Play.started ? System.currentTimeMillis() - Play.startedAt : -1);
application.addProperty("path", Play.applicationPath.getAbsolutePath());
status.add("application", application);
}
{
JsonObject pool = new JsonObject();
pool.addProperty("size", Invoker.executor.getPoolSize());
pool.addProperty("active", Invoker.executor.getActiveCount());
pool.addProperty("scheduled", Invoker.executor.getTaskCount());
pool.addProperty("queue", Invoker.executor.getQueue().size());
status.add("pool", pool);
}
{
JsonArray monitors = new JsonArray();
try {
Object[][] data = Misc.sort(MonitorFactory.getRootMonitor().getBasicData(), 3, "desc");
for (Object[] row : data) {
if (((Double) row[1]) > 0) {
JsonObject o = new JsonObject();
o.addProperty("name", row[0].toString());
o.addProperty("hits", (Double) row[1]);
o.addProperty("avg", (Double) row[2]);
o.addProperty("min", (Double) row[6]);
o.addProperty("max", (Double) row[7]);
monitors.add(o);
}
}
} catch (Exception e) {
e.printStackTrace();
}
status.add("monitors", monitors);
}
return status;
}