Search in sources :

Example 1 with EndpointMetrics

use of org.jboss.wsf.spi.management.EndpointMetrics in project wildfly by wildfly.

the class WSEndpointMetrics method getEndpointMetricsFragment.

@SuppressWarnings("unchecked")
private ModelNode getEndpointMetricsFragment(final ModelNode operation, final ServiceRegistry registry) throws OperationFailedException {
    final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
    String endpointId;
    try {
        endpointId = URLDecoder.decode(address.getLastElement().getValue(), "UTF-8");
    } catch (final UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }
    final String metricName = operation.require(NAME).asString();
    final String webContext = endpointId.substring(0, endpointId.indexOf(":"));
    final String endpointName = endpointId.substring(endpointId.indexOf(":") + 1);
    ServiceName endpointServiceName = WSServices.ENDPOINT_SERVICE.append("context=" + webContext).append(endpointName);
    ServiceController<Endpoint> service = (ServiceController<Endpoint>) currentServiceContainer().getService(endpointServiceName);
    Endpoint endpoint = service.getValue();
    if (endpoint == null) {
        throw new OperationFailedException(WSLogger.ROOT_LOGGER.noMetricsAvailable());
    }
    final ModelNode result = new ModelNode();
    final EndpointMetrics endpointMetrics = endpoint.getEndpointMetrics();
    if (MIN_PROCESSING_TIME.getName().equals(metricName)) {
        result.set(endpointMetrics.getMinProcessingTime());
    } else if (MAX_PROCESSING_TIME.getName().equals(metricName)) {
        result.set(endpointMetrics.getMaxProcessingTime());
    } else if (AVERAGE_PROCESSING_TIME.getName().equals(metricName)) {
        result.set(endpointMetrics.getAverageProcessingTime());
    } else if (TOTAL_PROCESSING_TIME.getName().equals(metricName)) {
        result.set(endpointMetrics.getTotalProcessingTime());
    } else if (REQUEST_COUNT.getName().equals(metricName)) {
        result.set(endpointMetrics.getRequestCount());
    } else if (RESPONSE_COUNT.getName().equals(metricName)) {
        result.set(endpointMetrics.getResponseCount());
    } else if (FAULT_COUNT.getName().equals(metricName)) {
        result.set(endpointMetrics.getFaultCount());
    }
    return result;
}
Also used : Endpoint(org.jboss.wsf.spi.deployment.Endpoint) ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) OperationFailedException(org.jboss.as.controller.OperationFailedException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ServiceController(org.jboss.msc.service.ServiceController) ModelNode(org.jboss.dmr.ModelNode) EndpointMetrics(org.jboss.wsf.spi.management.EndpointMetrics)

Example 2 with EndpointMetrics

use of org.jboss.wsf.spi.management.EndpointMetrics in project jbossws-cxf by jbossws.

the class RequestHandlerImpl method initRequestMetrics.

private long initRequestMetrics(Endpoint endpoint) {
    long beginTime = 0;
    EndpointMetrics metrics = endpoint.getEndpointMetrics();
    if (metrics != null)
        beginTime = metrics.processRequestMessage();
    return beginTime;
}
Also used : EndpointMetrics(org.jboss.wsf.spi.management.EndpointMetrics)

Aggregations

EndpointMetrics (org.jboss.wsf.spi.management.EndpointMetrics)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 OperationFailedException (org.jboss.as.controller.OperationFailedException)1 PathAddress (org.jboss.as.controller.PathAddress)1 ModelNode (org.jboss.dmr.ModelNode)1 ServiceController (org.jboss.msc.service.ServiceController)1 ServiceName (org.jboss.msc.service.ServiceName)1 Endpoint (org.jboss.wsf.spi.deployment.Endpoint)1