List of usage examples for com.google.gson JsonObject getAsJsonPrimitive
public JsonPrimitive getAsJsonPrimitive(String memberName)
From source file:org.cvasilak.jboss.mobile.admin.fragments.JVMMetricsViewFragment.java
License:Open Source License
public void refresh() { progress = ProgressDialog.show(getSherlockActivity(), "", getString(R.string.queryingServer)); application.getOperationsManager().fetchJVMMetrics(new Callback() { @Override/* w ww . jav a2 s. com*/ public void onSuccess(JsonElement reply) { progress.dismiss(); JsonObject jsonObj = reply.getAsJsonObject(); JsonObject step1 = jsonObj.getAsJsonObject("step-1").getAsJsonObject("result"); /* Memory */ long max, committed, init, used; float usedPerc; // Heap Usage JsonObject jsonHeapUsage = step1.getAsJsonObject("heap-memory-usage"); Map<String, String> heapUsage = new HashMap<String, String>(); max = jsonHeapUsage.getAsJsonPrimitive("max").getAsLong() / 1024 / 1024; committed = jsonHeapUsage.getAsJsonPrimitive("committed").getAsLong() / 1024 / 1024; init = jsonHeapUsage.getAsJsonPrimitive("init").getAsLong() / 1024 / 1024; used = jsonHeapUsage.getAsJsonPrimitive("used").getAsLong() / 1024 / 1024; usedPerc = (max != 0 ? ((float) used / max) * 100 : 0); heapUsage.put("max", String.format("%d MB", max)); heapUsage.put("used", String.format("%d MB (%.0f%%)", used, usedPerc)); heapUsage.put("committed", String.format("%d MB", committed)); heapUsage.put("init", String.format("%d MB", init)); for (Metric metric : heapMetrics) { metric.setValue(heapUsage.get(metric.getKey())); } // Non Heap Usage JsonObject jsonNonHeapUsage = step1.getAsJsonObject("non-heap-memory-usage"); Map<String, String> nonHeapUsage = new HashMap<String, String>(); max = jsonNonHeapUsage.getAsJsonPrimitive("max").getAsLong() / 1024 / 1024; committed = jsonNonHeapUsage.getAsJsonPrimitive("committed").getAsLong() / 1024 / 1024; init = jsonNonHeapUsage.getAsJsonPrimitive("init").getAsLong() / 1024 / 1024; used = jsonNonHeapUsage.getAsJsonPrimitive("used").getAsLong() / 1024 / 1024; usedPerc = (max != 0 ? ((float) used / max) * 100 : 0); nonHeapUsage.put("max", String.format("%d MB", max)); nonHeapUsage.put("used", String.format("%d MB (%.0f%%)", used, usedPerc)); nonHeapUsage.put("committed", String.format("%d MB", committed)); nonHeapUsage.put("init", String.format("%d MB", init)); for (Metric metric : nonHeapMetrics) { metric.setValue(nonHeapUsage.get(metric.getKey())); } // Threading JsonObject jsonThreading = jsonObj.getAsJsonObject("step-2").getAsJsonObject("result"); Map<String, String> threading = new HashMap<String, String>(); int threadCount = jsonThreading.getAsJsonPrimitive("thread-count").getAsInt(); int daemonThreadCount = jsonThreading.getAsJsonPrimitive("daemon-thread-count").getAsInt(); float daemonUsedPerc = (threadCount != 0 ? ((float) daemonThreadCount / threadCount) * 100 : 0); threading.put("thread-count", String.format("%d", threadCount)); threading.put("daemon", String.format("%d (%.0f%%)", daemonThreadCount, daemonUsedPerc)); for (Metric metric : threadUsageMetrics) { metric.setValue(threading.get(metric.getKey())); } // OS JsonObject jsonOS = jsonObj.getAsJsonObject("step-3").getAsJsonObject("result"); Map<String, String> os = new HashMap<String, String>(); os.put("name", jsonOS.get("name").getAsString()); os.put("version", jsonOS.get("version").getAsString()); os.put("available-processors", jsonOS.get("available-processors").getAsString()); for (Metric metric : osMetrics) { metric.setValue(os.get(metric.getKey())); } // refresh table ((MergeAdapter) getListAdapter()).notifyDataSetChanged(); } @Override public void onFailure(Exception e) { progress.dismiss(); AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity()); alertDialog.setTitle(R.string.dialog_error_title).setMessage(e.getMessage()) .setPositiveButton(R.string.dialog_button_Bummer, null).setCancelable(false) .setIcon(android.R.drawable.ic_dialog_alert).show(); } }); }
From source file:org.cvasilak.jboss.mobile.admin.fragments.TransactionMetricsViewFragment.java
License:Open Source License
public void refresh() { progress = ProgressDialog.show(getSherlockActivity(), "", getString(R.string.queryingServer)); application.getOperationsManager().fetchTranscationMetrics(new Callback() { @Override/*from w w w . ja v a 2 s.c o m*/ public void onSuccess(JsonElement reply) { progress.dismiss(); JsonObject jsonObj = reply.getAsJsonObject(); Map<String, String> info = new HashMap<String, String>(); int total = jsonObj.getAsJsonPrimitive("number-of-transactions").getAsInt(); int committed = jsonObj.getAsJsonPrimitive("number-of-committed-transactions").getAsInt(); float committedPerc = (total != 0 ? ((float) committed / total) * 100 : 0); int aborted = jsonObj.getAsJsonPrimitive("number-of-aborted-transactions").getAsInt(); float abortedPerc = (total != 0 ? ((float) aborted / total) * 100 : 0); int timedOut = jsonObj.getAsJsonPrimitive("number-of-timed-out-transactions").getAsInt(); float timedOutPerc = (total != 0 ? ((float) timedOut / total) * 100 : 0); int appRollbacks = jsonObj.getAsJsonPrimitive("number-of-application-rollbacks").getAsInt(); int resRollbacks = jsonObj.getAsJsonPrimitive("number-of-resource-rollbacks").getAsInt(); info.put("number-of-transactions", String.format("%d", total)); info.put("number-of-committed-transactions", String.format("%d (%.0f%%)", committed, committedPerc)); info.put("number-of-aborted-transactions", String.format("%d (%.0f%%)", aborted, abortedPerc)); info.put("number-of-timed-out-transactions", String.format("%d (%.0f%%)", timedOut, timedOutPerc)); info.put("number-of-application-rollbacks", String.format("%d", appRollbacks)); info.put("number-of-resource-rollbacks", String.format("%d", resRollbacks)); for (Metric metric : sucFailMetrics) { metric.setValue(info.get(metric.getKey())); } for (Metric metric : failOriginMetrics) { metric.setValue(info.get(metric.getKey())); } // refresh table ((MergeAdapter) getListAdapter()).notifyDataSetChanged(); } @Override public void onFailure(Exception e) { progress.dismiss(); AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity()); alertDialog.setTitle(R.string.dialog_error_title).setMessage(e.getMessage()) .setPositiveButton(R.string.dialog_button_Bummer, null).setCancelable(false) .setIcon(android.R.drawable.ic_dialog_alert).show(); } }); }
From source file:org.cvasilak.jboss.mobile.admin.fragments.WebConnectorMetricsViewFragment.java
License:Open Source License
public void refresh() { progress = ProgressDialog.show(getSherlockActivity(), "", getString(R.string.queryingServer)); application.getOperationsManager().fetchWebConnectorMetrics(connectorName, new Callback() { @Override/* www . java 2s .c om*/ public void onSuccess(JsonElement reply) { progress.dismiss(); JsonObject jsonObj = reply.getAsJsonObject(); Map<String, String> info = new HashMap<String, String>(); long bytesSent = jsonObj.getAsJsonPrimitive("bytesSent").getAsLong(); long bytesReceived = jsonObj.getAsJsonPrimitive("bytesReceived").getAsLong(); info.put("bytesSent", String.format("%d", bytesSent)); info.put("bytesReceived", String.format("%d", bytesReceived)); info.put("protocol", jsonObj.get("protocol").getAsString()); for (Metric metric : generalMetrics) { metric.setValue(info.get(metric.getKey())); } int requestCount = jsonObj.getAsJsonPrimitive("requestCount").getAsInt(); int errorCount = jsonObj.getAsJsonPrimitive("errorCount").getAsInt(); float errorPerc = (requestCount != 0 ? ((float) errorCount / requestCount) * 100 : 0); int processingTime = jsonObj.getAsJsonPrimitive("processingTime").getAsInt(); int maxTime = jsonObj.getAsJsonPrimitive("maxTime").getAsInt(); info.put("requestCount", String.format("%d", requestCount)); info.put("errorCount", String.format("%d (%.0f%%)", errorCount, errorPerc)); info.put("processingTime", String.format("%d", processingTime)); info.put("maxTime", String.format("%d", maxTime)); for (Metric metric : reqPerConnectorMetrics) { metric.setValue(info.get(metric.getKey())); } // refresh table ((MergeAdapter) getListAdapter()).notifyDataSetChanged(); } @Override public void onFailure(Exception e) { progress.dismiss(); AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity()); alertDialog.setTitle(R.string.dialog_error_title).setMessage(e.getMessage()) .setPositiveButton(R.string.dialog_button_Bummer, null).setCancelable(false) .setIcon(android.R.drawable.ic_dialog_alert).show(); } }); }
From source file:org.cvasilak.jboss.mobile.app.fragments.DataSourceMetricsViewFragment.java
License:Apache License
public void refresh() { ProgressDialogFragment.showDialog(getActivity(), R.string.queryingServer); application.getOperationsManager().fetchDataSourceMetrics(this.dsName, this.dsType, new Callback() { @Override/*from w w w . j a v a 2 s.c o m*/ public void onSuccess(JsonElement reply) { ProgressDialogFragment.dismissDialog(getActivity()); JsonObject jsonObj = reply.getAsJsonObject(); Map<String, String> info = new HashMap<String, String>(); JsonObject jsonPool = jsonObj.getAsJsonObject("step-1").getAsJsonObject("result"); int availCount = jsonPool.getAsJsonPrimitive("AvailableCount").getAsInt(); int activeCount = jsonPool.getAsJsonPrimitive("ActiveCount").getAsInt(); int maxUsedCount = jsonPool.getAsJsonPrimitive("MaxUsedCount").getAsInt(); float usedPerc = (availCount != 0 ? ((float) activeCount / availCount) * 100 : 0); info.put("AvailableCount", String.format("%d", availCount)); info.put("ActiveCount", String.format("%d (%.0f%%)", activeCount, usedPerc)); info.put("MaxUsedCount", String.format("%d", maxUsedCount)); for (Metric metric : poolMetrics) { metric.setValue(info.get(metric.getKey())); } JsonObject jsonJDBC = jsonObj.getAsJsonObject("step-2").getAsJsonObject("result"); int curSize = jsonJDBC.getAsJsonPrimitive("PreparedStatementCacheCurrentSize").getAsInt(); int hitCount = jsonJDBC.getAsJsonPrimitive("PreparedStatementCacheHitCount").getAsInt(); float hitPerc = (curSize != 0 ? ((float) hitCount / curSize) * 100 : 0); int misUsed = jsonJDBC.getAsJsonPrimitive("PreparedStatementCacheMissCount").getAsInt(); float misPerc = (curSize != 0 ? ((float) misUsed / curSize) * 100 : 0); info.put("PreparedStatementCacheCurrentSize", String.format("%d", curSize)); info.put("PreparedStatementCacheHitCount", String.format("%d (%.0f%%)", hitCount, hitPerc)); info.put("PreparedStatementCacheMissCount", String.format("%d (%.0f%%)", misUsed, misPerc)); for (Metric metric : prepStatementMetrics) { metric.setValue(info.get(metric.getKey())); } // refresh table ((MergeAdapter) getListAdapter()).notifyDataSetChanged(); } @Override public void onFailure(Exception e) { ProgressDialogFragment.dismissDialog(getActivity()); ErrorDialogFragment.showDialog(getActivity(), e.getMessage()); } }); }
From source file:org.cvasilak.jboss.mobile.app.fragments.JMSQueueMetricsViewFragment.java
License:Apache License
public void refresh() { ProgressDialogFragment.showDialog(getActivity(), R.string.queryingServer); application.getOperationsManager().fetchJMSQueueMetrics(queueName, JMSType.QUEUE, new Callback() { @Override/* ww w . j ava 2 s. c o m*/ public void onSuccess(JsonElement reply) { ProgressDialogFragment.dismissDialog(getActivity()); JsonObject jsonObj = reply.getAsJsonObject(); Map<String, String> info = new HashMap<String, String>(); int msgCount = jsonObj.getAsJsonPrimitive("message-count").getAsInt(); int delivCount = jsonObj.getAsJsonPrimitive("delivering-count").getAsInt(); float delivPerc = (msgCount != 0 ? ((float) delivCount / msgCount) * 100 : 0); int msgAdded = jsonObj.getAsJsonPrimitive("messages-added").getAsInt(); info.put("message-count", String.format("%d", msgCount)); info.put("delivering-count", String.format("%d (%.0f%%)", delivCount, delivPerc)); for (Metric metric : inFlightMetrics) { metric.setValue(info.get(metric.getKey())); } int schCount = jsonObj.getAsJsonPrimitive("scheduled-count").getAsInt(); info.put("messages-added", String.format("%d", msgAdded)); info.put("scheduled-count", String.format("%d", schCount)); for (Metric metric : msgProcessedMetrics) { metric.setValue(info.get(metric.getKey())); } int consCount = jsonObj.getAsJsonPrimitive("consumer-count").getAsInt(); info.put("consumer-count", String.format("%d", consCount)); for (Metric metric : consumerMetrics) { metric.setValue(info.get(metric.getKey())); } // refresh table ((MergeAdapter) getListAdapter()).notifyDataSetChanged(); } @Override public void onFailure(Exception e) { ProgressDialogFragment.dismissDialog(getActivity()); ErrorDialogFragment.showDialog(getActivity(), e.getMessage()); } }); }
From source file:org.cvasilak.jboss.mobile.app.fragments.JMSTopicMetricsViewFragment.java
License:Apache License
public void refresh() { ProgressDialogFragment.showDialog(getActivity(), R.string.queryingServer); application.getOperationsManager().fetchJMSQueueMetrics(topicName, JMSType.TOPIC, new Callback() { @Override/* ww w .j a v a 2s. c o m*/ public void onSuccess(JsonElement reply) { ProgressDialogFragment.dismissDialog(getActivity()); JsonObject jsonObj = reply.getAsJsonObject(); Map<String, String> info = new HashMap<String, String>(); // common metrics int msgCount = jsonObj.getAsJsonPrimitive("message-count").getAsInt(); int delivCount = jsonObj.getAsJsonPrimitive("delivering-count").getAsInt(); float delivPerc = (msgCount != 0 ? ((float) delivCount / msgCount) * 100 : 0); int msgAdded = jsonObj.getAsJsonPrimitive("messages-added").getAsInt(); info.put("message-count", String.format("%d", msgCount)); info.put("delivering-count", String.format("%d (%.0f%%)", delivCount, delivPerc)); info.put("messages-added", String.format("%d", msgAdded)); for (Metric metric : inFlightMetrics) { metric.setValue(info.get(metric.getKey())); } int durCount = jsonObj.getAsJsonPrimitive("durable-message-count").getAsInt(); float durPerc = (msgAdded != 0 ? ((float) durCount / msgAdded) * 100 : 0); int nonDurCount = jsonObj.getAsJsonPrimitive("non-durable-message-count").getAsInt(); float nonDurPerc = (msgAdded != 0 ? ((float) nonDurCount / msgAdded) * 100 : 0); int subCount = jsonObj.getAsJsonPrimitive("subscription-count").getAsInt(); int durSubCount = jsonObj.getAsJsonPrimitive("durable-subscription-count").getAsInt(); int nonDurSubCount = jsonObj.getAsJsonPrimitive("non-durable-subscription-count").getAsInt(); info.put("durable-message-count", String.format("%d (%.0f%%)", durCount, durPerc)); info.put("non-durable-message-count", String.format("%d (%.0f%%)", nonDurCount, nonDurPerc)); info.put("subscription-count", String.format("%d", subCount)); info.put("durable-subscription-count", String.format("%d", durSubCount)); info.put("non-durable-subscription-count", String.format("%d", nonDurSubCount)); for (Metric metric : msgProcessedMetrics) { metric.setValue(info.get(metric.getKey())); } for (Metric metric : subscriptionMetrics) { metric.setValue(info.get(metric.getKey())); } // refresh table ((MergeAdapter) getListAdapter()).notifyDataSetChanged(); } @Override public void onFailure(Exception e) { ProgressDialogFragment.dismissDialog(getActivity()); ErrorDialogFragment.showDialog(getActivity(), e.getMessage()); } }); }
From source file:org.cvasilak.jboss.mobile.app.fragments.JVMMetricsViewFragment.java
License:Apache License
public void refresh() { ProgressDialogFragment.showDialog(getActivity(), R.string.queryingServer); application.getOperationsManager().fetchJVMMetrics(new Callback() { @Override//www .ja va2s . co m public void onSuccess(JsonElement reply) { ProgressDialogFragment.dismissDialog(getActivity()); JsonObject jsonObj = reply.getAsJsonObject(); JsonObject step1 = jsonObj.getAsJsonObject("step-1").getAsJsonObject("result"); /* Memory */ long max, committed, init, used; float usedPerc, committedPerc, initPerc; // Heap Usage JsonObject jsonHeapUsage = step1.getAsJsonObject("heap-memory-usage"); Map<String, String> heapUsage = new HashMap<String, String>(); max = jsonHeapUsage.getAsJsonPrimitive("max").getAsLong() / 1024 / 1024; committed = jsonHeapUsage.getAsJsonPrimitive("committed").getAsLong() / 1024 / 1024; committedPerc = (max != 0 ? ((float) committed / max) * 100 : 0); init = jsonHeapUsage.getAsJsonPrimitive("init").getAsLong() / 1024 / 1024; initPerc = (max != 0 ? ((float) init / max) * 100 : 0); used = jsonHeapUsage.getAsJsonPrimitive("used").getAsLong() / 1024 / 1024; usedPerc = (max != 0 ? ((float) used / max) * 100 : 0); heapUsage.put("max", String.format("%d MB", max)); heapUsage.put("used", String.format("%d MB (%.0f%%)", used, usedPerc)); heapUsage.put("committed", String.format("%d MB (%.0f%%)", committed, committedPerc)); heapUsage.put("init", String.format("%d MB (%.0f%%)", init, initPerc)); for (Metric metric : heapMetrics) { metric.setValue(heapUsage.get(metric.getKey())); } // Non Heap Usage JsonObject jsonNonHeapUsage = step1.getAsJsonObject("non-heap-memory-usage"); Map<String, String> nonHeapUsage = new HashMap<String, String>(); max = jsonNonHeapUsage.getAsJsonPrimitive("max").getAsLong() / 1024 / 1024; committed = jsonNonHeapUsage.getAsJsonPrimitive("committed").getAsLong() / 1024 / 1024; committedPerc = (max != 0 ? ((float) committed / max) * 100 : 0); init = jsonNonHeapUsage.getAsJsonPrimitive("init").getAsLong() / 1024 / 1024; initPerc = (max != 0 ? ((float) init / max) * 100 : 0); used = jsonNonHeapUsage.getAsJsonPrimitive("used").getAsLong() / 1024 / 1024; usedPerc = (max != 0 ? ((float) used / max) * 100 : 0); nonHeapUsage.put("max", String.format("%d MB", max)); nonHeapUsage.put("used", String.format("%d MB (%.0f%%)", used, usedPerc)); nonHeapUsage.put("committed", String.format("%d MB (%.0f%%)", committed, committedPerc)); nonHeapUsage.put("init", String.format("%d MB (%.0f%%)", init, initPerc)); for (Metric metric : nonHeapMetrics) { metric.setValue(nonHeapUsage.get(metric.getKey())); } // Threading JsonObject jsonThreading = jsonObj.getAsJsonObject("step-2").getAsJsonObject("result"); Map<String, String> threading = new HashMap<String, String>(); int threadCount = jsonThreading.getAsJsonPrimitive("thread-count").getAsInt(); int daemonThreadCount = jsonThreading.getAsJsonPrimitive("daemon-thread-count").getAsInt(); float daemonUsedPerc = (threadCount != 0 ? ((float) daemonThreadCount / threadCount) * 100 : 0); threading.put("thread-count", String.format("%d", threadCount)); threading.put("daemon", String.format("%d (%.0f%%)", daemonThreadCount, daemonUsedPerc)); for (Metric metric : threadUsageMetrics) { metric.setValue(threading.get(metric.getKey())); } // OS JsonObject jsonOS = jsonObj.getAsJsonObject("step-3").getAsJsonObject("result"); Map<String, String> os = new HashMap<String, String>(); os.put("name", jsonOS.get("name").getAsString()); os.put("version", jsonOS.get("version").getAsString()); os.put("available-processors", jsonOS.get("available-processors").getAsString()); for (Metric metric : osMetrics) { metric.setValue(os.get(metric.getKey())); } ((MergeAdapter) getListAdapter()).notifyDataSetChanged(); } @Override public void onFailure(Exception e) { ProgressDialogFragment.dismissDialog(getActivity()); ErrorDialogFragment.showDialog(getActivity(), e.getMessage()); } }); }
From source file:org.cvasilak.jboss.mobile.app.fragments.TransactionMetricsViewFragment.java
License:Apache License
public void refresh() { ProgressDialogFragment.showDialog(getActivity(), R.string.queryingServer); application.getOperationsManager().fetchTranscationMetrics(new Callback() { @Override// w ww .j av a 2 s . c om public void onSuccess(JsonElement reply) { ProgressDialogFragment.dismissDialog(getActivity()); JsonObject jsonObj = reply.getAsJsonObject(); Map<String, String> info = new HashMap<String, String>(); int total = jsonObj.getAsJsonPrimitive("number-of-transactions").getAsInt(); int committed = jsonObj.getAsJsonPrimitive("number-of-committed-transactions").getAsInt(); float committedPerc = (total != 0 ? ((float) committed / total) * 100 : 0); int aborted = jsonObj.getAsJsonPrimitive("number-of-aborted-transactions").getAsInt(); float abortedPerc = (total != 0 ? ((float) aborted / total) * 100 : 0); int timedOut = jsonObj.getAsJsonPrimitive("number-of-timed-out-transactions").getAsInt(); float timedOutPerc = (total != 0 ? ((float) timedOut / total) * 100 : 0); int appRollbacks = jsonObj.getAsJsonPrimitive("number-of-application-rollbacks").getAsInt(); int resRollbacks = jsonObj.getAsJsonPrimitive("number-of-resource-rollbacks").getAsInt(); info.put("number-of-transactions", String.format("%d", total)); info.put("number-of-committed-transactions", String.format("%d (%.0f%%)", committed, committedPerc)); info.put("number-of-aborted-transactions", String.format("%d (%.0f%%)", aborted, abortedPerc)); info.put("number-of-timed-out-transactions", String.format("%d (%.0f%%)", timedOut, timedOutPerc)); info.put("number-of-application-rollbacks", String.format("%d", appRollbacks)); info.put("number-of-resource-rollbacks", String.format("%d", resRollbacks)); for (Metric metric : sucFailMetrics) { metric.setValue(info.get(metric.getKey())); } for (Metric metric : failOriginMetrics) { metric.setValue(info.get(metric.getKey())); } // refresh table ((MergeAdapter) getListAdapter()).notifyDataSetChanged(); } @Override public void onFailure(Exception e) { ProgressDialogFragment.dismissDialog(getActivity()); ErrorDialogFragment.showDialog(getActivity(), e.getMessage()); } }); }
From source file:org.cvasilak.jboss.mobile.app.fragments.WebConnectorMetricsViewFragment.java
License:Apache License
public void refresh() { ProgressDialogFragment.showDialog(getActivity(), R.string.queryingServer); application.getOperationsManager().fetchWebConnectorMetrics(connectorName, new Callback() { @Override/*from w w w .j av a2 s . c om*/ public void onSuccess(JsonElement reply) { ProgressDialogFragment.dismissDialog(getActivity()); JsonObject jsonObj = reply.getAsJsonObject(); Map<String, String> info = new HashMap<String, String>(); long bytesSent = jsonObj.getAsJsonPrimitive("bytesSent").getAsLong(); long bytesReceived = jsonObj.getAsJsonPrimitive("bytesReceived").getAsLong(); info.put("bytesSent", String.format("%d", bytesSent)); info.put("bytesReceived", String.format("%d", bytesReceived)); info.put("protocol", jsonObj.get("protocol").getAsString()); for (Metric metric : generalMetrics) { metric.setValue(info.get(metric.getKey())); } int requestCount = jsonObj.getAsJsonPrimitive("requestCount").getAsInt(); int errorCount = jsonObj.getAsJsonPrimitive("errorCount").getAsInt(); float errorPerc = (requestCount != 0 ? ((float) errorCount / requestCount) * 100 : 0); int processingTime = jsonObj.getAsJsonPrimitive("processingTime").getAsInt(); int maxTime = jsonObj.getAsJsonPrimitive("maxTime").getAsInt(); info.put("requestCount", String.format("%d", requestCount)); info.put("errorCount", String.format("%d (%.0f%%)", errorCount, errorPerc)); info.put("processingTime", String.format("%d", processingTime)); info.put("maxTime", String.format("%d", maxTime)); for (Metric metric : reqPerConnectorMetrics) { metric.setValue(info.get(metric.getKey())); } // refresh table ((MergeAdapter) getListAdapter()).notifyDataSetChanged(); } @Override public void onFailure(Exception e) { ProgressDialogFragment.dismissDialog(getActivity()); ErrorDialogFragment.showDialog(getActivity(), e.getMessage()); } }); }
From source file:org.dartlang.vm.service.internal.ErrorRequestSink.java
License:Open Source License
@Override public void add(JsonObject request) { String id = request.getAsJsonPrimitive(ID).getAsString(); try {/*from w ww .j av a 2 s . c o m*/ // TODO(danrubel) is this the correct format for an error response? JsonObject error = new JsonObject(); error.addProperty(CODE, code); error.addProperty(MESSAGE, message); JsonObject response = new JsonObject(); response.addProperty(ID, id); response.add(ERROR, error); responseSink.add(response); } catch (Throwable e) { Logging.getLogger().logError(e.getMessage(), e); } }