当前位置: 首页>>代码示例>>Java>>正文


Java Misc类代码示例

本文整理汇总了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);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:15,代码来源:JamonPerformanceMonitorInterceptor.java

示例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;
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:58,代码来源:CorePlugin.java


注:本文中的com.jamonapi.utils.Misc类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。