Author: jim.ma
Date: 2014-07-07 04:26:10 -0400 (Mon, 07 Jul 2014)
New Revision: 18787
Added:
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/EndpointMetricsCXFAdapterImpl.java
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/EndpointMetricsFactoryImpl.java
stack/cxf/branches/metrics/modules/server/src/main/resources/jbossws-cxf-server.jar/META-INF/services/org.jboss.wsf.spi.management.EndpointMetricsFactory
Modified:
stack/cxf/branches/metrics/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/Constants.java
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EnableDecoupledFaultInterceptor.java
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointAssociationInterceptor.java
stack/cxf/branches/metrics/pom.xml
Log:
[JBWS-3808]:Add new EndpintMetricsImpl and enable the ResponseTimeCounter in cxf to log
message processing time
Modified:
stack/cxf/branches/metrics/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/Constants.java
===================================================================
---
stack/cxf/branches/metrics/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/Constants.java 2014-07-07
07:39:49 UTC (rev 18786)
+++
stack/cxf/branches/metrics/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/Constants.java 2014-07-07
08:26:10 UTC (rev 18787)
@@ -41,7 +41,6 @@
public static final String CXF_QUEUE_DEQUEUE_TIMEOUT_PROP =
"dequeueTimeout";
public static final String CXF_POLICY_ALTERNATIVE_SELECTOR_PROP =
"cxf.policy.alternativeSelector";
public static final String CXF_MANAGEMENT_ENABLED =
"cxf.management.enabled";
- public static final String CXF_MANAGEMENT_INSTALL_RESPONSE_TIME_INTERCEPTORS =
"cxf.management.installResponseTimeInterceptors";
public static final String CXF_WS_DISCOVERY_ENABLED =
"cxf.ws-discovery.enabled";
public static final String JBWS_CXF_DISABLE_HANDLER_AUTH_CHECKS =
"org.jboss.ws.cxf.disableHandlerAuthChecks";
Added:
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/EndpointMetricsCXFAdapterImpl.java
===================================================================
---
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/EndpointMetricsCXFAdapterImpl.java
(rev 0)
+++
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/EndpointMetricsCXFAdapterImpl.java 2014-07-07
08:26:10 UTC (rev 18787)
@@ -0,0 +1,71 @@
+package org.jboss.wsf.stack.cxf;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.apache.cxf.management.counters.CounterRepository;
+import org.apache.cxf.management.counters.ResponseTimeCounter;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.management.EndpointMetrics;
+import org.jboss.wsf.stack.cxf.configuration.BusHolder;
+
+public class EndpointMetricsCXFAdapterImpl implements EndpointMetrics {
+ private CounterRepository counterRepo;
+ private ResponseTimeCounter counter = null;
+ private ObjectName objectName = null;
+
+ public EndpointMetricsCXFAdapterImpl(Endpoint endpoint) {
+ BusHolder busHolder = endpoint.getService().getDeployment()
+ .getAttachment(BusHolder.class);
+ counterRepo = busHolder.getBus().getExtension(CounterRepository.class);
+ try {
+ objectName = new ObjectName(endpoint.getName().toString()
+ + ",metrics=EndpointMetrics");
+ } catch (MalformedObjectNameException e) {
+ // ignore
+ }
+ counter = (ResponseTimeCounter)counterRepo.createCounter(objectName);
+ counter.reset();
+ counterRepo.getCounters().put(objectName, counter);
+ }
+
+ @Override
+ public long getMinProcessingTime() {
+ return counter.getMinResponseTime().longValue();
+ }
+
+ @Override
+ public long getMaxProcessingTime() {
+ return counter.getMaxResponseTime().longValue();
+ }
+
+ @Override
+ public long getAverageProcessingTime() {
+ return counter.getAvgResponseTime().longValue();
+ }
+
+ @Override
+ public long getTotalProcessingTime() {
+ return counter.getTotalHandlingTime().longValue();
+ }
+
+ @Override
+ public long getRequestCount() {
+ return counter.getNumInvocations().longValue();
+ }
+
+ @Override
+ public long getFaultCount() {
+ long totalFault = counter.getNumCheckedApplicationFaults().longValue()
+ + counter.getNumLogicalRuntimeFaults().longValue()
+ + counter.getNumRuntimeFaults().longValue()
+ + counter.getNumUnCheckedApplicationFaults().longValue();
+ return totalFault;
+ }
+
+ @Override
+ public long getResponseCount() {
+ return counter.getNumInvocations().longValue();
+ }
+
+}
Property changes on:
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/EndpointMetricsCXFAdapterImpl.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Added:
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/EndpointMetricsFactoryImpl.java
===================================================================
---
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/EndpointMetricsFactoryImpl.java
(rev 0)
+++
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/EndpointMetricsFactoryImpl.java 2014-07-07
08:26:10 UTC (rev 18787)
@@ -0,0 +1,11 @@
+package org.jboss.wsf.stack.cxf;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.management.EndpointMetrics;
+import org.jboss.wsf.spi.management.EndpointMetricsFactory;
+public class EndpointMetricsFactoryImpl extends EndpointMetricsFactory {
+
+ @Override
+ public EndpointMetrics newEndpointMetrics(Endpoint endpoint) {
+ return new EndpointMetricsCXFAdapterImpl(endpoint);
+ }
+}
Property changes on:
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/EndpointMetricsFactoryImpl.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Modified:
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java
===================================================================
---
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java 2014-07-07
07:39:49 UTC (rev 18786)
+++
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java 2014-07-07
08:26:10 UTC (rev 18787)
@@ -52,7 +52,6 @@
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.invocation.InvocationContext;
import org.jboss.wsf.spi.invocation.RequestHandler;
-import org.jboss.wsf.spi.management.EndpointMetrics;
import org.jboss.wsf.spi.management.ServerConfig;
import org.jboss.wsf.stack.cxf.addressRewrite.SoapAddressRewriteHelper;
import org.jboss.wsf.stack.cxf.configuration.BusHolder;
@@ -93,8 +92,6 @@
out.close();
return;
}
- final boolean statisticsEnabled = getServerConfig().isStatisticsEnabled();
- Long beginTime = statisticsEnabled == true ? initRequestMetrics(ep) : 0;
Bus bus = ep.getService().getDeployment().getAttachment(BusHolder.class).getBus();
AbstractHTTPDestination dest = findDestination(req, bus);
HttpServletResponseWrapper response = new HttpServletResponseWrapper(res);
@@ -113,14 +110,6 @@
{
throw new ServletException(e);
}
- if (response.getStatus() < 500 && statisticsEnabled)
- {
- processResponseMetrics(ep, beginTime);
- }
- if (response.getStatus() >= 500 && statisticsEnabled)
- {
- processFaultMetrics(ep, beginTime);
- }
}
private boolean hasQueryString(HttpServletRequest req)
@@ -210,29 +199,4 @@
}
return
AccessController.doPrivileged(AbstractServerConfig.GET_SERVER_INTEGRATION_SERVER_CONFIG);
}
-
- private long initRequestMetrics(Endpoint endpoint)
- {
- long beginTime = 0;
-
- EndpointMetrics metrics = endpoint.getEndpointMetrics();
- if (metrics != null)
- beginTime = metrics.processRequestMessage();
-
- return beginTime;
- }
-
- private void processResponseMetrics(Endpoint endpoint, long beginTime)
- {
- EndpointMetrics metrics = endpoint.getEndpointMetrics();
- if (metrics != null)
- metrics.processResponseMessage(beginTime);
- }
-
- private void processFaultMetrics(Endpoint endpoint, long beginTime)
- {
- EndpointMetrics metrics = endpoint.getEndpointMetrics();
- if (metrics != null)
- metrics.processFaultMessage(beginTime);
- }
}
Modified:
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
===================================================================
---
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2014-07-07
07:39:49 UTC (rev 18786)
+++
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2014-07-07
08:26:10 UTC (rev 18787)
@@ -21,11 +21,14 @@
*/
package org.jboss.wsf.stack.cxf.configuration;
+import java.security.AccessController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import javax.management.MBeanServer;
+
import org.apache.cxf.Bus;
import org.apache.cxf.buslifecycle.BusLifeCycleListener;
import org.apache.cxf.buslifecycle.BusLifeCycleManager;
@@ -33,9 +36,7 @@
import org.apache.cxf.endpoint.ServerLifeCycleManager;
import org.apache.cxf.management.InstrumentationManager;
import org.apache.cxf.management.counters.CounterRepository;
-import org.apache.cxf.management.interceptor.ResponseTimeMessageInInterceptor;
-import org.apache.cxf.management.interceptor.ResponseTimeMessageInvokerInterceptor;
-import org.apache.cxf.management.interceptor.ResponseTimeMessageOutInterceptor;
+import org.apache.cxf.management.jmx.InstrumentationManagerImpl;
import org.apache.cxf.resource.ResourceManager;
import org.apache.cxf.resource.ResourceResolver;
import org.apache.cxf.service.factory.FactoryBeanListener;
@@ -49,6 +50,7 @@
import org.apache.cxf.ws.policy.selector.MaximalAlternativeSelector;
import org.jboss.ws.api.annotation.PolicySets;
import org.jboss.ws.api.binding.BindingCustomization;
+import org.jboss.ws.common.management.AbstractServerConfig;
import org.jboss.wsf.spi.SPIProvider;
import org.jboss.wsf.spi.WSFException;
import org.jboss.wsf.spi.classloading.ClassLoaderProvider;
@@ -56,6 +58,7 @@
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+import org.jboss.wsf.spi.management.ServerConfig;
import org.jboss.wsf.spi.metadata.webservices.JBossWebservicesMetaData;
import org.jboss.wsf.spi.security.JASPIAuthenticationProvider;
import org.jboss.wsf.stack.cxf.Loggers;
@@ -66,7 +69,6 @@
import org.jboss.wsf.stack.cxf.interceptor.EndpointAssociationInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.HandlerAuthInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.NsCtxSelectorStoreInterceptor;
-import org.jboss.wsf.stack.cxf.management.InstrumentationManagerExtImpl;
import
org.jboss.wsf.stack.cxf.security.authentication.AuthenticationMgrSubjectCreatingInterceptor;
/**
@@ -246,31 +248,17 @@
}
protected static void setCXFManagement(Bus bus, Map<String, String> props) {
- if (props != null && !props.isEmpty()) {
- final String p = props.get(Constants.CXF_MANAGEMENT_ENABLED);
- if ("true".equalsIgnoreCase(p) || "1".equalsIgnoreCase(p))
{
- InstrumentationManagerExtImpl instrumentationManagerImpl = new
InstrumentationManagerExtImpl();
- instrumentationManagerImpl.setBus(bus);
- instrumentationManagerImpl.setEnabled(true);
- instrumentationManagerImpl.initMBeanServer();
- instrumentationManagerImpl.register();
- bus.setExtension(instrumentationManagerImpl, InstrumentationManager.class);
- CounterRepository couterRepository = new CounterRepository();
- couterRepository.setBus(bus);
- final String installRespTimeInterceptors =
props.get(Constants.CXF_MANAGEMENT_INSTALL_RESPONSE_TIME_INTERCEPTORS);
- if (installRespTimeInterceptors == null ||
- "true".equalsIgnoreCase(installRespTimeInterceptors) ||
- "1".equalsIgnoreCase(installRespTimeInterceptors)) {
- ResponseTimeMessageInInterceptor in = new
ResponseTimeMessageInInterceptor();
- ResponseTimeMessageInvokerInterceptor invoker = new
ResponseTimeMessageInvokerInterceptor();
- ResponseTimeMessageOutInterceptor out = new
ResponseTimeMessageOutInterceptor();
- bus.getInInterceptors().add(in);
- bus.getInInterceptors().add(invoker);
- bus.getOutInterceptors().add(out);
- }
- bus.setExtension(couterRepository, CounterRepository.class);
- }
- }
+ CounterRepository couterRepository = new CounterRepository();
+ couterRepository.setBus(bus);
+ bus.setExtension(couterRepository, CounterRepository.class);
+
+ AbstractServerConfig serverConfig = (AbstractServerConfig)getServerConfig();
+ if (serverConfig != null && serverConfig.getMbeanServer() != null) {
+ bus.setExtension(serverConfig.getMbeanServer(), MBeanServer.class);
+ InstrumentationManagerImpl instrumentationImpl = (InstrumentationManagerImpl) bus
+ .getExtension(InstrumentationManager.class);
+ instrumentationImpl.init();
+ }
}
protected static void setWSDiscovery(Bus bus, Map<String, String> props) {
@@ -278,10 +266,19 @@
final String p = props.get(Constants.CXF_WS_DISCOVERY_ENABLED);
if ("true".equalsIgnoreCase(p) || "1".equalsIgnoreCase(p))
{
bus.getExtension(ServerLifeCycleManager.class).registerListener(new
WSDiscoveryServerListener(bus));
+
}
}
}
+ private static ServerConfig getServerConfig() {
+ if (System.getSecurityManager() == null) {
+ return AbstractServerConfig.getServerIntegrationServerConfig();
+ }
+ return AccessController
+ .doPrivileged(AbstractServerConfig.GET_SERVER_INTEGRATION_SERVER_CONFIG);
+ }
+
private static AlternativeSelector getAlternativeSelector(Map<String, String>
props) {
//default to MaximalAlternativeSelector on server side [JBWS-3149]
AlternativeSelector selector = new MaximalAlternativeSelector();
Modified:
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EnableDecoupledFaultInterceptor.java
===================================================================
---
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EnableDecoupledFaultInterceptor.java 2014-07-07
07:39:49 UTC (rev 18786)
+++
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EnableDecoupledFaultInterceptor.java 2014-07-07
08:26:10 UTC (rev 18787)
@@ -30,7 +30,7 @@
* This interceptor adds the context property decoupled_fault_support
* to enable decoupled faultTo. This is an optional feature in cxf and we
* need this to be default to make it same behavior with native stack.
- * @author <a href="mailto:ema@redhat.com>Jim Ma</a>
+ * @author <a href="mailto:ema@redhat.com">Jim Ma</a>
*/
public class EnableDecoupledFaultInterceptor extends
AbstractPhaseInterceptor<Message>
{
Modified:
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointAssociationInterceptor.java
===================================================================
---
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointAssociationInterceptor.java 2014-07-07
07:39:49 UTC (rev 18786)
+++
stack/cxf/branches/metrics/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointAssociationInterceptor.java 2014-07-07
08:26:10 UTC (rev 18787)
@@ -21,13 +21,19 @@
*/
package org.jboss.wsf.stack.cxf.interceptor;
+import java.security.AccessController;
+
import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.management.interceptor.ResponseTimeMessageInInterceptor;
import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
+import org.apache.cxf.ws.policy.PolicyInInterceptor;
+import org.jboss.ws.common.management.AbstractServerConfig;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.invocation.EndpointAssociation;
+import org.jboss.wsf.spi.management.ServerConfig;
/**
* A RECEIVE phase interceptor that sets the @see{org.jboss.wsf.spi.deployment.Endpoint}
@@ -41,10 +47,11 @@
*/
public class EndpointAssociationInterceptor extends
AbstractPhaseInterceptor<Message>
{
-
public EndpointAssociationInterceptor()
{
super(Phase.RECEIVE);
+ addBefore(ResponseTimeMessageInInterceptor.class.getName());
+ addBefore(PolicyInInterceptor.class.getName());
}
@Override
@@ -53,6 +60,22 @@
Endpoint endpoint = EndpointAssociation.getEndpoint();
Exchange exchange = message.getExchange();
exchange.put(Endpoint.class, endpoint);
+ String serviceCounterName = endpoint.getName().toString();
+ exchange.put("org.apache.cxf.management.service.counter.name",
serviceCounterName + ",metrics=EndpointMetrics");
+ if (!getServerConfig().isStatisticsEnabled())
+ {
+ exchange.put("org.apache.cxf.management.counter.enabled", false);
+ }
}
+
+
+ private static ServerConfig getServerConfig() {
+ if (System.getSecurityManager() == null) {
+ return AbstractServerConfig.getServerIntegrationServerConfig();
+ }
+ return AccessController
+ .doPrivileged(AbstractServerConfig.GET_SERVER_INTEGRATION_SERVER_CONFIG);
+ }
+
}
Added:
stack/cxf/branches/metrics/modules/server/src/main/resources/jbossws-cxf-server.jar/META-INF/services/org.jboss.wsf.spi.management.EndpointMetricsFactory
===================================================================
---
stack/cxf/branches/metrics/modules/server/src/main/resources/jbossws-cxf-server.jar/META-INF/services/org.jboss.wsf.spi.management.EndpointMetricsFactory
(rev 0)
+++
stack/cxf/branches/metrics/modules/server/src/main/resources/jbossws-cxf-server.jar/META-INF/services/org.jboss.wsf.spi.management.EndpointMetricsFactory 2014-07-07
08:26:10 UTC (rev 18787)
@@ -0,0 +1 @@
+org.jboss.wsf.stack.cxf.EndpointMetricsFactoryImpl
\ No newline at end of file
Modified: stack/cxf/branches/metrics/pom.xml
===================================================================
--- stack/cxf/branches/metrics/pom.xml 2014-07-07 07:39:49 UTC (rev 18786)
+++ stack/cxf/branches/metrics/pom.xml 2014-07-07 08:26:10 UTC (rev 18787)
@@ -71,7 +71,7 @@
<wildfly810.version>8.1.0.Final</wildfly810.version>
<wildfly900.version>9.0.0.Alpha1-SNAPSHOT</wildfly900.version>
<ejb.api.version>1.0.2.Final</ejb.api.version>
- <cxf.version>3.0.0</cxf.version>
+ <cxf.version>3.0.1-SNAPSHOT</cxf.version>
<cxf.asm.version>3.3.1</cxf.asm.version>
<cxf.xjcplugins.version>2.7.0</cxf.xjcplugins.version>
<jboss.common.core.version>2.2.17.GA</jboss.common.core.version>