public void getCacheStatistics() { if (!isServerActive()) { return; } ModelNode address = RuntimeBaseAddress.get(); address.add("subsystem", "teiid"); ModelNode operation = new ModelNode(); operation.get(OP).set("cache-statistics"); operation.get(ADDRESS).set(address); operation.get("cache-type").set(new ModelNode().set("QUERY_SERVICE_RESULT_SET_CACHE")); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { ModelNode response = result.get(); if (response.get(RESULT).isDefined()) { CacheStatistics cache = cacheAdaptor.fromDMR(response.get(RESULT)); getView().setCacheStatistics(cache); } else { getView().setCacheStatistics(null); } } }); }
public void getSessions(final String vdbName, final int version) { ModelNode address = RuntimeBaseAddress.get(); address.add("subsystem", "teiid"); ModelNode operation = new ModelNode(); operation.get(OP).set("list-sessions"); operation.get(ADDRESS).set(address); operation.get("vdb-name").set(new ModelNode().set(vdbName)); operation.get("vdb-version").set(new ModelNode().set(version)); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { ModelNode response = result.get(); if (response.get(RESULT).isDefined()) { List<Session> sessions = sessionAdaptor.fromDMRList(response.get(RESULT).asList()); getView().setVDBSessions(vdbName, version, sessions); } else { getView().setVDBRequests(null); } } @Override public void onFailure(Throwable caught) { Console.error( "Failed to get current sessions for vdb = " + vdbName + "." + version, caught.getMessage()); } }); }
public void getSourceRequests(final Request selection) { if (!isServerActive()) { getView().setSourceRequests(selection, null); } ModelNode address = RuntimeBaseAddress.get(); address.add("subsystem", "teiid"); ModelNode operation = new ModelNode(); operation.get(OP).set("list-requests-per-session"); operation.get(ADDRESS).set(address); operation.get("session").set(new ModelNode().set(selection.getSessionId())); operation.get("include-source").set(new ModelNode().set(true)); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { ModelNode response = result.get(); if (response.get(RESULT).isDefined()) { List<Request> requests = requestAdaptor.fromDMRList(response.get(RESULT).asList()); getView().setSourceRequests(selection, requests); } else { getView().setSourceRequests(selection, null); } } }); }
public void getRequests( final String vdbName, final int version, final boolean includeSourceQueries) { ModelNode address = RuntimeBaseAddress.get(); address.add("subsystem", "teiid"); ModelNode operation = new ModelNode(); operation.get(OP).set("list-requests-per-vdb"); operation.get(ADDRESS).set(address); operation.get("vdb-name").set(new ModelNode().set(vdbName)); operation.get("vdb-version").set(new ModelNode().set(version)); operation.get("include-source").set(new ModelNode().set(includeSourceQueries)); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { ModelNode response = result.get(); if (response.get(RESULT).isDefined()) { List<Request> requests = requestAdaptor.fromDMRList(response.get(RESULT).asList()); getView().setVDBRequests(requests); } else { getView().setVDBRequests(null); } } @Override public void onFailure(Throwable caught) { Console.error( "Failed to get in process requests for VDB " + vdbName + "." + version, caught.getMessage()); } }); }
public void clearCache(final String vdbName, final int version, final String cacheType) { ModelNode address = RuntimeBaseAddress.get(); address.add("subsystem", "teiid"); ModelNode operation = new ModelNode(); operation.get(OP).set("clear-cache"); operation.get(ADDRESS).set(address); operation.get("cache-type").set(new ModelNode().set(cacheType)); operation.get("vdb-name").set(new ModelNode().set(vdbName)); operation.get("vdb-version").set(new ModelNode().set(version)); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { Console.info( "Cache " + cacheType + " on VDB = " + vdbName + "." + version + " has been cleared"); } @Override public void onFailure(Throwable caught) { Console.error( "Failed to clear Cache " + cacheType + " on VDB = " + vdbName + "." + version, caught.getMessage()); } }); }
public void reloadVDB(final String vdbName, final int version) { ModelNode address = RuntimeBaseAddress.get(); address.add("subsystem", "teiid"); ModelNode operation = new ModelNode(); operation.get(OP).set("restart-vdb"); operation.get(ADDRESS).set(address); operation.get("vdb-name").set(new ModelNode().set(vdbName)); operation.get("vdb-version").set(new ModelNode().set(version)); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { Console.info("VDB " + vdbName + "." + version + " has been submitted for reload"); getView().vdbReloaded(vdbName, version); } @Override public void onFailure(Throwable caught) { Console.error( "Failed to reload the VDB = " + vdbName + "." + version, caught.getMessage()); } }); }
public void getSessions(final String vdbName, final int version) { if (!isServerActive()) { getView().setVDBRequests(null); } ModelNode address = RuntimeBaseAddress.get(); address.add("subsystem", "teiid"); ModelNode operation = new ModelNode(); operation.get(OP).set("list-sessions"); operation.get(ADDRESS).set(address); operation.get("vdb-name").set(new ModelNode().set(vdbName)); operation.get("vdb-version").set(new ModelNode().set(version)); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { ModelNode response = result.get(); if (response.get(RESULT).isDefined()) { List<Session> sessions = sessionAdaptor.fromDMRList(response.get(RESULT).asList()); getView().setVDBSessions(vdbName, version, sessions); } else { getView().setVDBRequests(null); } } }); }
public void cancelRequest(final Request request) { if (!isServerActive()) { getView().cancelSubmitted(request); } ModelNode address = RuntimeBaseAddress.get(); address.add("subsystem", "teiid"); ModelNode operation = new ModelNode(); operation.get(OP).set("cancel-request"); operation.get(ADDRESS).set(address); operation.get("session").set(new ModelNode().set(request.getSessionId())); operation.get("execution-id").set(new ModelNode().set(request.getExecutionId())); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { ModelNode response = result.get(); if (response.get(RESULT).isDefined()) { getView().cancelSubmitted(request); Console.info( "Query Cancel Submitted. Session Id:" + request.getSessionId() + ", Execution Id:" + request.getExecutionId()); } else { getView().cancelSubmitted(null); } } }); }
public void addRoleName( final String vdbName, final int version, final String dataRole, final String mappedRole) { ModelNode address = RuntimeBaseAddress.get(); address.add("subsystem", "teiid"); ModelNode operation = new ModelNode(); operation.get(OP).set("add-data-role"); operation.get(ADDRESS).set(address); operation.get("vdb-name").set(new ModelNode().set(vdbName)); operation.get("vdb-version").set(new ModelNode().set(version)); operation.get("data-role").set(new ModelNode().set(dataRole)); operation.get("mapped-role").set(new ModelNode().set(mappedRole)); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { Console.info(mappedRole + " role added to VDB " + vdbName + "." + version); } @Override public void onFailure(Throwable caught) { Console.error("Failed to add role", caught.getMessage()); } }); }
public void getSchema(String vdbName, int version, String modelName) { if (!isServerActive()) { getView().setModelSchema("No Active Server Found"); } ModelNode address = RuntimeBaseAddress.get(); address.add("subsystem", "teiid"); ModelNode operation = new ModelNode(); operation.get(OP).set("get-schema"); operation.get(ADDRESS).set(address); operation.get("vdb-name").set(new ModelNode().set(vdbName)); operation.get("vdb-version").set(new ModelNode().set(version)); operation.get("model-name").set(new ModelNode().set(modelName)); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { ModelNode response = result.get(); if (response.get(RESULT).isDefined()) { getView().setModelSchema(response.get(RESULT).asString()); } else { getView().setModelSchema(null); } } }); }
public void getRequests(String vdbName, int version, boolean includeSourceQueries) { if (!isServerActive()) { getView().setVDBRequests(null); } ModelNode address = RuntimeBaseAddress.get(); address.add("subsystem", "teiid"); ModelNode operation = new ModelNode(); operation.get(OP).set("list-requests-per-vdb"); operation.get(ADDRESS).set(address); operation.get("vdb-name").set(new ModelNode().set(vdbName)); operation.get("vdb-version").set(new ModelNode().set(version)); operation.get("include-source").set(new ModelNode().set(includeSourceQueries)); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { ModelNode response = result.get(); if (response.get(RESULT).isDefined()) { List<Request> requests = requestAdaptor.fromDMRList(response.get(RESULT).asList()); getView().setVDBRequests(requests); } else { getView().setVDBRequests(null); } } }); }
public void getQueryPlan(Request request) { if (!isServerActive()) { getView().setQueryPlan("No Server Found"); } ModelNode address = RuntimeBaseAddress.get(); address.add("subsystem", "teiid"); ModelNode operation = new ModelNode(); operation.get(OP).set("get-query-plan"); operation.get(ADDRESS).set(address); operation.get("session").set(new ModelNode().set(request.getSessionId())); operation.get("execution-id").set(new ModelNode().set(request.getExecutionId())); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { ModelNode response = result.get(); String plan = null; if (response.get(RESULT).isDefined()) { plan = response.get(RESULT).asString(); } if (plan != null && !plan.trim().isEmpty()) { getView().setQueryPlan(plan); } else { getView() .setQueryPlan( "<node name=\"query\"><property name=\"noplan\">No Plan found, query might have finished executing!</property></node>"); } } }); }
public void addRoleName( final String vdbName, final int version, final String dataRole, final String mappedRole) { if (!isServerActive()) { Console.warning(Console.CONSTANTS.common_err_server_not_active()); return; } ModelNode address = RuntimeBaseAddress.get(); address.add("subsystem", "teiid"); ModelNode operation = new ModelNode(); operation.get(OP).set("add-data-role"); operation.get(ADDRESS).set(address); operation.get("vdb-name").set(new ModelNode().set(vdbName)); operation.get("vdb-version").set(new ModelNode().set(version)); operation.get("data-role").set(new ModelNode().set(dataRole)); operation.get("mapped-role").set(new ModelNode().set(mappedRole)); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { Console.info(mappedRole + " role added to VDB " + vdbName + "." + version); } }); }
public void changeConnectionType(final String vdbName, final int version, final String connType) { if (!isServerActive()) { return; } ModelNode address = RuntimeBaseAddress.get(); address.add("subsystem", "teiid"); ModelNode operation = new ModelNode(); operation.get(OP).set("change-vdb-connection-type"); operation.get(ADDRESS).set(address); operation.get("connection-type").set(new ModelNode().set(connType)); operation.get("vdb-name").set(new ModelNode().set(vdbName)); operation.get("vdb-version").set(new ModelNode().set(version)); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { getView().connectionTypeChanged(vdbName, version); Console.info( "Changing Connection type to " + connType + " on VDB = " + vdbName + "." + version + " has been cleared"); } }); }
public void getEngineStatistics() { ModelNode address = RuntimeBaseAddress.get(); address.add("subsystem", "teiid"); // $NON-NLS-1$ //$NON-NLS-2$ ModelNode operation = new ModelNode(); operation.get(OP).set("engine-statistics"); // $NON-NLS-1$ operation.get(ADDRESS).set(address); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { ModelNode response = result.get(); if (response.get(RESULT).isDefined()) { EngineStatistics stats = runtimeAdaptor.fromDMR(response.get(RESULT)); getView().setEngineStatistics(stats); } else { getView().setEngineStatistics(null); } } @Override public void onFailure(Throwable caught) { Console.error( "Failed to retrieve query engine statistics for Teiid", caught.getMessage()); } }); }
public void terminateSession(final Session session) { if (!isServerActive()) { getView().terminateSessionSubmitted(session); } ModelNode address = RuntimeBaseAddress.get(); address.add("subsystem", "teiid"); ModelNode operation = new ModelNode(); operation.get(OP).set("terminate-session"); operation.get(ADDRESS).set(address); operation.get("session").set(new ModelNode().set(session.getSessionId())); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { ModelNode response = result.get(); if (response.get(RESULT).isDefined()) { getView().terminateSessionSubmitted(session); Console.info("Terminate Session Submitted. Session Id:" + session.getSessionId()); } else { getView().terminateSessionSubmitted(null); } } }); }
public void assignDataSource( final String vdbName, final int version, final String modelName, final String sourceName, final String translatorName, final String dataSourceName) { ModelNode address = RuntimeBaseAddress.get(); address.add("subsystem", "teiid"); ModelNode operation = new ModelNode(); operation.get(OP).set("assign-datasource"); operation.get(ADDRESS).set(address); operation.get("vdb-name").set(new ModelNode().set(vdbName)); operation.get("vdb-version").set(new ModelNode().set(version)); operation.get("model-name").set(new ModelNode().set(modelName)); operation.get("source-name").set(new ModelNode().set(sourceName)); operation.get("translator-name").set(new ModelNode().set(translatorName)); operation.get("ds-name").set(new ModelNode().set(dataSourceName)); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { Console.info( "Changing the JNDI name of the data source on VDB =" + vdbName + "." + version + " on Model=" + modelName + " to " + dataSourceName); } @Override public void onFailure(Throwable caught) { Console.error( "Changing the JNDI name of the data source on VDB =" + vdbName + "." + version + " on Model=" + modelName + " to " + dataSourceName, caught.getMessage()); } }); }
public void onSaveJPADeployment(JPADeployment editedEntity, Map<String, Object> changeset) { ModelNode address = new ModelNode(); address.get(ADDRESS).set(RuntimeBaseAddress.get()); // parent deployment names if (editedEntity.getDeploymentName().indexOf("/") != -1) { String[] parent = editedEntity.getDeploymentName().split("/"); address.get(ADDRESS).add("deployment", parent[0]); address.get(ADDRESS).add("subdeployment", parent[1]); } else { address.get(ADDRESS).add("deployment", editedEntity.getDeploymentName()); } address.get(ADDRESS).add("subsystem", "jpa"); address .get(ADDRESS) .add( "hibernate-persistence-unit", editedEntity.getDeploymentName() + "#" + editedEntity.getPersistenceUnit()); ModelNode operation = adapter.fromChangeset(changeset, address); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { ModelNode response = result.get(); if (response.isFailure()) { Console.error( Console.MESSAGES.modificationFailed("JPA Deployment"), response.getFailureDescription()); } else { Console.info(Console.MESSAGES.modified("JPA Deployment")); refresh(false); } } }); }
public void refresh(final boolean paging) { ModelNode address = RuntimeBaseAddress.get(); address.add("subsystem", "teiid"); ModelNode operation = new ModelNode(); operation.get(OP).set("list-vdbs"); operation.get(ADDRESS).set(address); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { ModelNode response = result.get(); if (response.get(RESULT).isDefined()) { List<VDB> vdbs = vdbAdaptor.fromDMRList(response.get(RESULT).asList()); for (VDB vdb : vdbs) { boolean valid = true; for (Model m : vdb.getModels()) { if (!m.getValidityErrors().isEmpty()) { for (ValidityError ve : m.getValidityErrors()) { if (ve.getSeverity().equals("ERROR")) { valid = false; } } } } vdb.setValid(valid); } getView().setDeployedVDBs(vdbs); } } @Override public void onFailure(Throwable caught) { Console.error( "Failed to get list of current VDBs deployed in the system", caught.getMessage()); } }); }
protected void activateSubsystem() { // Since it takes a few moments for the subsystem to activate we're showing a window indicating // this final DefaultWindow window = new DefaultWindow(Console.CONSTANTS.subsys_osgi()); window.setWidth(320); window.setHeight(140); window.trapWidget(new HTML(Console.MESSAGES.subsys_osgi_activating())); window.setGlassEnabled(true); window.center(); AddressBinding address = bundleMetaData.getAddress(); ModelNode operation = address.asSubresource( RuntimeBaseAddress.get()); // get an operation on the parent address... operation.get(ModelDescriptionConstants.OP).set("activate"); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { Timer t = new Timer() { @Override public void run() { window.hide(); onReset(); } }; t.schedule(4000); } @Override public void onFailure(Throwable caught) { window.hide(); super.onFailure(caught); } }); }
public void refresh(final boolean paging) { if (!isServerActive()) { Console.warning(Console.CONSTANTS.common_err_server_not_active()); getView().setDeployedVDBs(null); return; } ModelNode address = RuntimeBaseAddress.get(); address.add("subsystem", "teiid"); ModelNode operation = new ModelNode(); operation.get(OP).set("list-vdbs"); operation.get(ADDRESS).set(address); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { ModelNode response = result.get(); if (response.get(RESULT).isDefined()) { List<VDB> vdbs = vdbAdaptor.fromDMRList(response.get(RESULT).asList()); for (VDB vdb : vdbs) { boolean valid = true; for (Model m : vdb.getModels()) { if (!m.getValidityErrors().isEmpty()) { for (ValidityError ve : m.getValidityErrors()) { if (ve.getSeverity().equals("ERROR")) { valid = false; } } } } vdb.setValid(valid); } getView().setDeployedVDBs(vdbs); } } }); }
private void loadConnectorMetrics() { if (null == selectedConnector) throw new RuntimeException("connector selection is null!"); getView().clearSamples(); ModelNode operation = new ModelNode(); operation.get(ADDRESS).set(RuntimeBaseAddress.get()); operation.get(ADDRESS).add("subsystem", "web"); operation.get(ADDRESS).add("connector", selectedConnector.getName()); operation.get(OP).set(READ_RESOURCE_OPERATION); operation.get(INCLUDE_RUNTIME).set(true); dispatcher.execute( new DMRAction(operation), new LoggingCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse dmrResponse) { ModelNode response = dmrResponse.get(); if (response.isFailure()) { Log.error(Console.MESSAGES.failed("Web Metrics"), response.getFailureDescription()); } else { ModelNode result = response.get(RESULT).asObject(); Metric metric = new Metric( result.get("requestCount").asLong(), result.get("errorCount").asLong(), result.get("processingTime").asLong(), result.get("maxTime").asLong()); getView().setConnectorMetric(metric); } } }); }
public <T> void executeQuery( final String vdbName, final int version, final String sql, final String clazz) { ModelNode address = RuntimeBaseAddress.get(); address.add("subsystem", "teiid"); ModelNode operation = new ModelNode(); operation.get(OP).set("execute-query"); operation.get(ADDRESS).set(address); operation.get("vdb-name").set(new ModelNode().set(vdbName)); operation.get("vdb-version").set(new ModelNode().set(version)); operation.get("sql-query").set(new ModelNode().set(sql)); operation.get("timeout-in-milli").set(new ModelNode().set(-1)); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { ModelNode response = result.get(); if (response.get(RESULT).isDefined()) { if (getEntityAdapter(clazz) != null) { getView() .setQueryResults( matViewAdaptor.fromDMRList(response.get(RESULT).asList()), clazz); } else { getView().setQueryResults(null, clazz); } } else { getView().setQueryResults(null, clazz); } } @Override public void onFailure(Throwable caught) { Console.error("Failed to execute query, or timeout occured", caught.getMessage()); } }); }
public void reloadVDB(final String vdbName, final int version) { if (!isServerActive()) { return; } ModelNode address = RuntimeBaseAddress.get(); address.add("subsystem", "teiid"); ModelNode operation = new ModelNode(); operation.get(OP).set("restart-vdb"); operation.get(ADDRESS).set(address); operation.get("vdb-name").set(new ModelNode().set(vdbName)); operation.get("vdb-version").set(new ModelNode().set(version)); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { Console.info("VDB " + vdbName + "." + version + " has been submitted for reload"); getView().vdbReloaded(vdbName, version); } }); }
public void getSchema(final String vdbName, final int version, final String modelName) { ModelNode address = RuntimeBaseAddress.get(); address.add("subsystem", "teiid"); ModelNode operation = new ModelNode(); operation.get(OP).set("get-schema"); operation.get(ADDRESS).set(address); operation.get("vdb-name").set(new ModelNode().set(vdbName)); operation.get("vdb-version").set(new ModelNode().set(version)); operation.get("model-name").set(new ModelNode().set(modelName)); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { ModelNode response = result.get(); if (response.get(RESULT).isDefined()) { getView().setModelSchema(response.get(RESULT).asString()); } else { getView().setModelSchema(null); } } @Override public void onFailure(Throwable caught) { Console.error( "Failed to get schema of the model = " + modelName + " in vdb = " + vdbName + " with version = " + version, caught.getMessage()); } }); }
private void bundleAction(OSGiBundle bundle, String operationName) { AddressBinding address = bundleMetaData.getAddress(); ModelNode operation = address.asResource(RuntimeBaseAddress.get(), bundle.getName()); operation.get(ModelDescriptionConstants.OP).set(operationName); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { ModelNode response = result.get(); if (response.isFailure()) { Console.error( Console.MESSAGES.modificationFailed("OSGi Bundle"), response.getFailureDescription()); } else { Console.info(Console.MESSAGES.modified("OSGi Bundle")); } getView().initialLoad(); } }); }
public void loadMetrics(String[] tokens) { ModelNode operation = new ModelNode(); operation.get(ADDRESS).set(RuntimeBaseAddress.get()); // parent deployment names if (tokens[0].indexOf("/") != -1) { String[] parent = tokens[0].split("/"); operation.get(ADDRESS).add("deployment", parent[0]); operation.get(ADDRESS).add("subdeployment", parent[1]); } else { operation.get(ADDRESS).add("deployment", tokens[0]); } operation.get(ADDRESS).add("subsystem", "jpa"); operation.get(ADDRESS).add("hibernate-persistence-unit", tokens[0] + "#" + tokens[1]); operation.get(OP).set(READ_RESOURCE_OPERATION); operation.get(INCLUDE_RUNTIME).set(true); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { ModelNode response = result.get(); if (response.isFailure()) { Console.error( Console.MESSAGES.failed("JPA Metrics"), response.getFailureDescription()); } else { ModelNode payload = response.get(RESULT).asObject(); boolean isEnabled = payload.get("enabled").asBoolean(); if (!isEnabled) { getView().updateMetric(new UnitMetric(false)); } else { Metric txMetric = new Metric( payload.get("completed-transaction-count").asLong(), payload.get("successful-transaction-count").asLong()); // ---- Metric queryExecMetric = new Metric( payload.get("query-execution-count").asLong(), payload.get("query-execution-max-time").asLong()); queryExecMetric.add( payload.get("query-execution-max-time-query-string").asString()); // ---- Metric queryCacheMetric = new Metric( payload.get("query-cache-put-count").asLong(), payload.get("query-cache-hit-count").asLong(), payload.get("query-cache-miss-count").asLong()); // ---- Metric secondLevelCacheMetric = new Metric( payload.get("second-level-cache-put-count").asLong(), payload.get("second-level-cache-hit-count").asLong(), payload.get("second-level-cache-miss-count").asLong()); Metric connectionMetric = new Metric( payload.get("session-open-count").asLong(), payload.get("session-close-count").asLong(), payload.get("connect-count").asLong()); getView() .updateMetric( new UnitMetric( txMetric, queryCacheMetric, queryExecMetric, secondLevelCacheMetric, connectionMetric)); } } } }); }
public void refresh(final boolean paging) { getView().clearValues(); getView().setJpaUnits(Collections.EMPTY_LIST); getView().setSelectedUnit(null); ModelNode operation = new ModelNode(); operation.get(ADDRESS).setEmptyList(); operation.get(OP).set(COMPOSITE); List<ModelNode> steps = new ArrayList<ModelNode>(); ModelNode deploymentsOp = new ModelNode(); deploymentsOp.get(OP).set(READ_RESOURCE_OPERATION); deploymentsOp.get(ADDRESS).set(RuntimeBaseAddress.get()); deploymentsOp.get(ADDRESS).add("deployment", "*"); deploymentsOp.get(ADDRESS).add("subsystem", "jpa"); deploymentsOp.get(INCLUDE_RUNTIME).set(true); deploymentsOp.get(RECURSIVE).set(true); ModelNode subdeploymentOp = new ModelNode(); subdeploymentOp.get(OP).set(READ_RESOURCE_OPERATION); subdeploymentOp.get(ADDRESS).set(RuntimeBaseAddress.get()); subdeploymentOp.get(ADDRESS).add("deployment", "*"); subdeploymentOp.get(ADDRESS).add("subdeployment", "*"); subdeploymentOp.get(ADDRESS).add("subsystem", "jpa"); subdeploymentOp.get(INCLUDE_RUNTIME).set(true); subdeploymentOp.get(RECURSIVE).set(true); steps.add(deploymentsOp); steps.add(subdeploymentOp); operation.get(STEPS).set(steps); dispatcher.execute( new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { ModelNode compositeResponse = result.get(); if (compositeResponse.isFailure()) { Console.error( Console.MESSAGES.failed("JPA Deployments"), compositeResponse.getFailureDescription()); } else { List<JPADeployment> jpaUnits = new ArrayList<JPADeployment>(); ModelNode compositeResult = compositeResponse.get(RESULT); ModelNode mainResponse = compositeResult.get("step-1"); ModelNode subdeploymentResponse = compositeResult.get("step-2"); parseJpaResources(mainResponse, jpaUnits); parseJpaResources(subdeploymentResponse, jpaUnits); getView().setJpaUnits(jpaUnits); } // update selection (paging) if (paging) getView().setSelectedUnit(selectedUnit); } }); }