當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。