You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by as...@apache.org on 2007/01/23 08:26:37 UTC
svn commit: r498943 - in
/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse:
./ config/ config/xml/ core/ core/axis2/ mediators/base/ mediators/builtin/
statistics/ statistics/impl/
Author: asankha
Date: Mon Jan 22 23:26:34 2007
New Revision: 498943
URL: http://svn.apache.org/viewvc?view=rev&rev=498943
Log:
Adding statistics collecting capability to sequences ,Endpoints and proxy services
Added required changes to the each mediator,mediator sterilizer and factory
Added statistics processing capability
Added method to Synapse Environment API setting and getting Statistics Collector
-checkin on behalf of Indika
Added:
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/Statistics.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsCollector.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsHolder.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsStack.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsUtils.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/impl/
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/impl/EndPointStatisticsStack.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/impl/ProxyServiceStatisticsStack.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/impl/SequenceStatisticsStack.java
Modified:
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Constants.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/Endpoint.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/Constants.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EndpointFactory.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EndpointSerializer.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceFactory.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceSerializer.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SequenceMediatorFactory.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SequenceMediatorSerializer.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/SynapseEnvironment.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/base/SequenceMediator.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/DropMediator.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/SendMediator.java
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Constants.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Constants.java?view=diff&rev=498943&r1=498942&r2=498943
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Constants.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Constants.java Mon Jan 22 23:26:34 2007
@@ -128,17 +128,45 @@
int TRACING_UNSET=2;
/** Tracing logger */
String TRACE_LOGGER ="TRACE_LOGGER";
-
+
// -- Synapse property values for WS-RM sequence handling --
/** WS-RM version 1.0*/
String SEQUENCE_VERSION_1_0 = "1.0";
/** WS-RM version 1.1*/
String SEQUENCE_VERSION_1_1 = "1.1";
-
+
/** Sandesha last message property name */
String SANDESHA_LAST_MESSAGE = "Sandesha2LastMessage";
/** Sandesha last sequence key property name */
String SANDESHA_SEQUENCE_KEY = "Sandesha2SequenceKey";
/** Sandesha WS-RM specification version property name */
String SANDESHA_SPEC_VERSION = "Sandesha2RMSpecVersion";
+
+ /** The statistics state -off */
+ int STATISTICS_OFF =0;
+ /** The statistics state-on */
+ int STATISTICS_ON =1;
+ /** The statistics state-unset */
+ int STATISTICS_UNSET=2;
+
+ /** */
+ String SYNAPSE_ERROR ="syapse_error" ;
+
+ /** key for lookup sequence statistics stack */
+ String SEQUENCE_STATISTICS_STACK ="sequence_statistics_stack";
+
+ /** key for lookup Proxy Service statistics stack */
+ String PROXYSERVICE_STATISTICS_STACK ="proxyservice_statistics_stack";
+
+ /** key for lookup Endpoint statistics stack */
+ String ENDPOINT_STATISTICS_STACK ="endpoint_statistics_stack";
+
+ /** Sequence statistics category*/
+ int SEQUENCE_STATISTICS = 0;
+
+ /** Proxy Service statistics category */
+ int PROXYSERVICE_STATISTICS = 1;
+
+ /** Endpoint statistics category*/
+ int ENDPOINT_STATISTICS = 2;
}
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/Endpoint.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/Endpoint.java?view=diff&rev=498943&r1=498942&r2=498943
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/Endpoint.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/Endpoint.java Mon Jan 22 23:26:34 2007
@@ -19,6 +19,7 @@
package org.apache.synapse.config;
+import org.apache.synapse.Constants;
/**
@@ -56,8 +57,9 @@
private boolean useMTOM = false;
/** use SWA **/
private boolean useSwa = false;
-
-
+
+ /** To decide to whether statistics should have collected or not */
+ private int statisticsEnable = Constants.STATISTICS_UNSET;
/**
* Return the name of the endpoint
@@ -188,7 +190,7 @@
}
public void setUseSeparateListener(boolean b) {
- this.useSeparateListener = b;
+ this.useSeparateListener = b;
}
public boolean isUseSeparateListener() {
return useSeparateListener;
@@ -224,5 +226,23 @@
public void setUseSwa(boolean useSwa) {
this.useSwa = useSwa;
+ }
+
+ /**
+ * To check whether statistics should have collected or not
+ *
+ * @return Returns the int value that indicate statistics is enabled or not.
+ */
+ public int getStatisticsEnable() {
+ return statisticsEnable;
+ }
+
+ /**
+ * To set the statistics enable variable value
+ *
+ * @param statisticsEnable
+ */
+ public void setStatisticsEnable(int statisticsEnable) {
+ this.statisticsEnable = statisticsEnable;
}
}
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/Constants.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/Constants.java?view=diff&rev=498943&r1=498942&r2=498943
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/Constants.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/Constants.java Mon Jan 22 23:26:34 2007
@@ -39,12 +39,18 @@
public static final String RAMPART_POLICY = "rampartPolicy";
public static final String SANDESHA_POLICY = "sandeshaPolicy";
- /** The trace local name */
+ /** The Trace attribute name */
public static final String TRACE_ATTRIB_NAME ="trace";
/** The Trace value 'enable' */
public static final String TRACE_ENABLE ="enable";
/** The Trace value 'disable' */
- public static final String TRACE_DISABLE ="disable";
+ public static final String TRACE_DISABLE ="disable";
+ /** The statistics attribute name */
+ public static final String STATISTICS_ATTRIB_NAME ="statistics";
+ /** The statistics value 'enable' */
+ public static final String STATISTICS_ENABLE ="enable";
+ /** The statistics value 'disable' */
+ public static final String STATISTICS_DISABLE ="disable";
// -- variables for the scoping of a property mediator --
/** The String value for a Synapse messagecontext property */
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EndpointFactory.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EndpointFactory.java?view=diff&rev=498943&r1=498942&r2=498943
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EndpointFactory.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EndpointFactory.java Mon Jan 22 23:26:34 2007
@@ -76,7 +76,19 @@
// right now an address is *required*
handleException("The 'address' attribute is required for an endpoint");
}
- } else {
+ OMAttribute statistics = elem.getAttribute(
+ new QName(Constants.NULL_NAMESPACE, Constants.STATISTICS_ATTRIB_NAME));
+ if (statistics != null) {
+ String statisticsValue = statistics.getAttributeValue();
+ if (statisticsValue != null) {
+ if (Constants.STATISTICS_ENABLE.equals(statisticsValue)) {
+ endpoint.setStatisticsEnable(org.apache.synapse.Constants.STATISTICS_ON);
+ } else if (Constants.STATISTICS_DISABLE.equals(statisticsValue)) {
+ endpoint.setStatisticsEnable(org.apache.synapse.Constants.STATISTICS_OFF);
+ }
+ }
+ }
+ } else {
OMAttribute reference = elem.getAttribute(new QName(
Constants.NULL_NAMESPACE, "ref"));
if (reference != null) {
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EndpointSerializer.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EndpointSerializer.java?view=diff&rev=498943&r1=498942&r2=498943
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EndpointSerializer.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EndpointSerializer.java Mon Jan 22 23:26:34 2007
@@ -84,7 +84,17 @@
} else {
handleException("Invalid Endpoint. Address is required");
}
-
+ int isEnableStatistics = endpt.getStatisticsEnable();
+ String statisticsValue = null;
+ if (isEnableStatistics == org.apache.synapse.Constants.STATISTICS_ON) {
+ statisticsValue = Constants.STATISTICS_ENABLE;
+ } else if (isEnableStatistics == org.apache.synapse.Constants.STATISTICS_OFF) {
+ statisticsValue = Constants.STATISTICS_DISABLE;
+ }
+ if (statisticsValue != null) {
+ endpoint.addAttribute(fac.createOMAttribute(
+ Constants.TRACE_ATTRIB_NAME, nullNS, statisticsValue));
+ }
if (endpt.isAddressingOn()) {
OMElement addressing = fac.createOMElement("enableAddressing", synNS);
if (endpt.isUseSeparateListener()) {
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceFactory.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceFactory.java?view=diff&rev=498943&r1=498942&r2=498943
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceFactory.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceFactory.java Mon Jan 22 23:26:34 2007
@@ -57,6 +57,19 @@
handleException("The 'name' attribute is required for a Proxy service definition");
} else {
proxy.setName(name.getAttributeValue());
+ OMAttribute statistics = elem.getAttribute(
+ new QName(Constants.NULL_NAMESPACE, Constants.STATISTICS_ATTRIB_NAME));
+ if (statistics != null) {
+ String statisticsValue = statistics.getAttributeValue();
+ if (statisticsValue != null) {
+ if (Constants.STATISTICS_ENABLE.equals(statisticsValue)) {
+ proxy.setStatisticsEnable(org.apache.synapse.Constants.STATISTICS_ON);
+ } else if (Constants.STATISTICS_DISABLE.equals(statisticsValue)) {
+ proxy.setStatisticsEnable(org.apache.synapse.Constants.STATISTICS_OFF);
+ }
+ }
+
+ }
}
OMAttribute trans = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "transports"));
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceSerializer.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceSerializer.java?view=diff&rev=498943&r1=498942&r2=498943
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceSerializer.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceSerializer.java Mon Jan 22 23:26:34 2007
@@ -133,10 +133,22 @@
if (service.isWsRMEnabled()) {
proxy.addChild(fac.createOMElement("enableRM", synNS));
}
-
if (service.isWsSecEnabled()) {
proxy.addChild(fac.createOMElement("enableSec", synNS));
}
+
+ int isEnableStatistics = service.getStatisticsEnable();
+ String statisticsValue = null;
+ if (isEnableStatistics == org.apache.synapse.Constants.STATISTICS_ON) {
+ statisticsValue = Constants.STATISTICS_ENABLE;
+ } else if (isEnableStatistics == org.apache.synapse.Constants.STATISTICS_OFF) {
+ statisticsValue = Constants.STATISTICS_DISABLE;
+ }
+ if (statisticsValue != null) {
+ proxy.addAttribute(fac.createOMAttribute(
+ Constants.TRACE_ATTRIB_NAME, nullNS, statisticsValue));
+ }
+
int traceState = service.getTraceState();
String traceValue = null;
if (traceState == org.apache.synapse.Constants.TRACING_ON) {
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SequenceMediatorFactory.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SequenceMediatorFactory.java?view=diff&rev=498943&r1=498942&r2=498943
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SequenceMediatorFactory.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SequenceMediatorFactory.java Mon Jan 22 23:26:34 2007
@@ -85,6 +85,19 @@
}
}
+ OMAttribute statistics = elem.getAttribute(
+ new QName(Constants.NULL_NAMESPACE, Constants.STATISTICS_ATTRIB_NAME));
+ if (statistics != null) {
+ String statisticsValue = statistics.getAttributeValue();
+ if (statisticsValue != null) {
+ if (Constants.STATISTICS_ENABLE.equals(statisticsValue)) {
+ seqMediator.setStatisticsEnable(org.apache.synapse.Constants.STATISTICS_ON);
+ } else if (Constants.STATISTICS_DISABLE.equals(statisticsValue)) {
+ seqMediator.setStatisticsEnable(org.apache.synapse.Constants.STATISTICS_OFF);
+ }
+ }
+ }
+
return seqMediator;
}
}
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SequenceMediatorSerializer.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SequenceMediatorSerializer.java?view=diff&rev=498943&r1=498942&r2=498943
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SequenceMediatorSerializer.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SequenceMediatorSerializer.java Mon Jan 22 23:26:34 2007
@@ -52,6 +52,17 @@
SequenceMediator mediator = (SequenceMediator) m;
OMElement sequence = fac.createOMElement("sequence", synNS);
+ int isEnableStatistics = mediator.getStatisticsEnable();
+ String statisticsValue = null;
+ if (isEnableStatistics == org.apache.synapse.Constants.STATISTICS_ON) {
+ statisticsValue = Constants.STATISTICS_ENABLE;
+ } else if (isEnableStatistics == org.apache.synapse.Constants.STATISTICS_OFF) {
+ statisticsValue = Constants.STATISTICS_DISABLE;
+ }
+ if (statisticsValue != null) {
+ sequence.addAttribute(fac.createOMAttribute(
+ Constants.TRACE_ATTRIB_NAME, nullNS, statisticsValue));
+ }
if (mediator.getRef() != null) {
sequence.addAttribute(fac.createOMAttribute(
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/SynapseEnvironment.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/SynapseEnvironment.java?view=diff&rev=498943&r1=498942&r2=498943
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/SynapseEnvironment.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/SynapseEnvironment.java Mon Jan 22 23:26:34 2007
@@ -20,6 +20,7 @@
package org.apache.synapse.core;
import org.apache.synapse.MessageContext;
+import org.apache.synapse.statistics.StatisticsCollector;
/**
* The SynapseEnvironment allows access into the the host SOAP engine. It allows
@@ -40,10 +41,24 @@
* This will send request messages on (forward), and send the response messages back to the client
*/
public void send(MessageContext smc);
-
+
/**
* Creates a new Synapse <code>MessageContext</code> instance.
* @return a MessageContext
*/
public MessageContext createMessageContext();
+
+ /**
+ * This method returns the StatisticsCollector
+ *
+ * @return Retruns the StatisticsCollector
+ */
+ public StatisticsCollector getStatisticsCollector();
+
+ /**
+ * To set the StatisticsCollector
+ *
+ * @param statisticsCollector
+ */
+ public void setStatisticsCollector(StatisticsCollector statisticsCollector);
}
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java?view=diff&rev=498943&r1=498942&r2=498943
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java Mon Jan 22 23:26:34 2007
@@ -23,11 +23,14 @@
import org.apache.axis2.util.threadpool.ThreadFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.synapse.MessageContext;
import org.apache.synapse.Constants;
import org.apache.synapse.Mediator;
+import org.apache.synapse.MessageContext;
import org.apache.synapse.config.SynapseConfiguration;
import org.apache.synapse.core.SynapseEnvironment;
+import org.apache.synapse.statistics.StatisticsCollector;
+import org.apache.synapse.statistics.StatisticsUtils;
+
/**
* <p> This is the Axis2 implementation of the MessageContext
@@ -40,6 +43,8 @@
private ThreadFactory threadFactory = null;
private SynapseConfiguration synapseConfig;
+ /** The StatisticsCollector object */
+ private StatisticsCollector statisticsCollector;
public Axis2SynapseEnvironment() {}
@@ -57,7 +62,12 @@
synCtx.getConfiguration().getMainMediator().mediate(synCtx);
}
});*/
-
+ if (synCtx.isResponse()) {
+ //Process statistics related to a sequence which has send mediator as a child,end point
+ StatisticsUtils.processEndPointStatistics(synCtx);
+ StatisticsUtils.processProxyServiceStatistics(synCtx);
+ StatisticsUtils.processSequenceStatistics(synCtx);
+ }
// if the outSequence property is present use that for the message mediation
// if not use the main mediator to mediate the outgoing message
if (synCtx.getProperty(Constants.OUT_SEQUENCE) != null) {
@@ -89,6 +99,24 @@
= new org.apache.axis2.context.MessageContext();
MessageContext mc = new Axis2MessageContext(axis2MC, synapseConfig, this);
return mc;
+ }
+
+ /**
+ * This method returns the StatisticsCollector
+ *
+ * @return Retruns the StatisticsCollector
+ */
+ public StatisticsCollector getStatisticsCollector() {
+ return statisticsCollector;
+ }
+
+ /**
+ * To set the StatisticsCollector
+ *
+ * @param collector
+ */
+ public void setStatisticsCollector(StatisticsCollector collector) {
+ this.statisticsCollector = collector;
}
}
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java?view=diff&rev=498943&r1=498942&r2=498943
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java Mon Jan 22 23:26:34 2007
@@ -27,12 +27,12 @@
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.neethi.Policy;
+import org.apache.neethi.PolicyEngine;
import org.apache.synapse.Constants;
import org.apache.synapse.SynapseException;
import org.apache.synapse.config.SynapseConfiguration;
import org.apache.synapse.config.Util;
-import org.apache.neethi.PolicyEngine;
-import org.apache.neethi.Policy;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
@@ -90,6 +90,10 @@
public static final String ALL_TRANSPORTS = "all";
+ /** To decide to whether statistics should have collected or not */
+ private int statisticsEnable = Constants.STATISTICS_UNSET;
+
+
/** The variable that indicate tracing on or off for the current mediator */
protected int traceState = Constants.TRACING_UNSET;
@@ -396,6 +400,24 @@
private static void handleException(String msg, Exception e) {
log.error(msg, e);
throw new SynapseException(msg, e);
+ }
+
+ /**
+ * To check whether statistics should have collected or not
+ *
+ * @return Returns the int value that indicate statistics is enabled or not.
+ */
+ public int getStatisticsEnable() {
+ return statisticsEnable;
+ }
+
+ /**
+ * To set the statistics enable variable value
+ *
+ * @param statisticsEnable
+ */
+ public void setStatisticsEnable(int statisticsEnable) {
+ this.statisticsEnable = statisticsEnable;
}
/**
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java?view=diff&rev=498943&r1=498942&r2=498943
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java Mon Jan 22 23:26:34 2007
@@ -25,8 +25,11 @@
import org.apache.axis2.engine.AxisEngine;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.synapse.MessageContext;
import org.apache.synapse.Mediator;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.statistics.StatisticsUtils;
+import org.apache.synapse.statistics.impl.EndPointStatisticsStack;
+import org.apache.synapse.statistics.impl.ProxyServiceStatisticsStack;
import org.apache.synapse.config.Endpoint;
/**
@@ -102,9 +105,17 @@
// it results in an unbound URI exception for no credible reason - needs more
// investigation seems like a woodstox issue. Use hack for now
//axisOutMsgContext.getEnvelope().build();
-
- log.debug("Reply Body : \n" + axisOutMsgContext.getEnvelope());
+ log.debug("Reply Body : \n" + axisOutMsgContext.getEnvelope());
+ // Setting Required property to collect the proxy service statistics
+ String endPointName = endpoint.getName();
+ boolean statisticsEnable;
+ statisticsEnable = (org.apache.synapse.Constants.STATISTICS_ON == endpoint.getStatisticsEnable());
+ if (endPointName != null && statisticsEnable) {
+ EndPointStatisticsStack endPointStatisticsStack = new EndPointStatisticsStack();
+ endPointStatisticsStack.put(endPointName, System.currentTimeMillis(), !synCtx.isResponse(), statisticsEnable);
+ synCtx.setCorrelationProperty(org.apache.synapse.Constants.ENDPOINT_STATISTICS_STACK, endPointStatisticsStack);
+ }
AxisEngine ae = new AxisEngine(axisOutMsgContext.getConfigurationContext());
try {
axisOutMsgContext.setProperty(
@@ -116,18 +127,34 @@
ae.send(axisOutMsgContext);
} catch (AxisFault e) {
+ synCtx.setProperty(org.apache.synapse.Constants.SYNAPSE_ERROR,Boolean.TRUE);
log.error("Axis fault encountered while forwarding message to endpoint : "
+ targetEndpoint, e);
+ } finally {
+ if (statisticsEnable) {
+ StatisticsUtils.processEndPointStatistics(synCtx);
+ }
}
}
} else {
-
+
// if a named outSequence os specified set it as a property to the MessageContext
if (targetOutSequence != null) {
log.debug("OutSequence " + targetOutSequence
+ " for the proxy set to the MessageContext");
synCtx.setProperty(org.apache.synapse.Constants.OUT_SEQUENCE, targetOutSequence);
+ }
+ // Setting Required property to collect the proxy service statistics
+ boolean statisticsEnable;
+ ProxyService currentProxyService = synCtx.getConfiguration().getProxyService(name);
+ if (currentProxyService != null) {
+ statisticsEnable = (org.apache.synapse.Constants.STATISTICS_ON == currentProxyService.getStatisticsEnable());
+ if (statisticsEnable) {
+ ProxyServiceStatisticsStack proxyServiceStatisticsStack = new ProxyServiceStatisticsStack();
+ proxyServiceStatisticsStack.put(name, System.currentTimeMillis(), !synCtx.isResponse(), statisticsEnable);
+ synCtx.setCorrelationProperty(org.apache.synapse.Constants.PROXYSERVICE_STATISTICS_STACK, proxyServiceStatisticsStack);
+ }
}
// if a named inSequence is specified, use it for message mediation
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/base/SequenceMediator.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/base/SequenceMediator.java?view=diff&rev=498943&r1=498942&r2=498943
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/base/SequenceMediator.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/base/SequenceMediator.java Mon Jan 22 23:26:34 2007
@@ -21,12 +21,15 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.synapse.Constants;
import org.apache.synapse.Mediator;
+import org.apache.synapse.Constants;
import org.apache.synapse.MessageContext;
import org.apache.synapse.SynapseException;
import org.apache.synapse.core.axis2.Axis2MessageContext;
import org.apache.synapse.mediators.AbstractListMediator;
+import org.apache.synapse.statistics.StatisticsUtils;
+import org.apache.synapse.statistics.StatisticsStack;
+import org.apache.synapse.statistics.impl.SequenceStatisticsStack;
/**
* The Sequence mediator either refers to a named Sequence mediator instance
@@ -45,6 +48,9 @@
private String ref = null;
private String errorHandler = null;
+ /** To decide to whether statistics should have collected or not */
+ private int statisticsEnable = Constants.STATISTICS_UNSET;
+
/**
* If this mediator refers to another named Sequence, execute that. Else
* execute the list of mediators (children) contained within this. If a referenced
@@ -60,6 +66,17 @@
log.debug("Sequence mediator <" + (name == null ? "anonymous" : name) + "> :: mediate()");
boolean shouldTrace = shouldTrace(synCtx.getTracingState());
if (ref == null) {
+ // Setting Required property to collect the sequence statistics
+ boolean isStatisticsEnable = (org.apache.synapse.Constants.STATISTICS_ON == statisticsEnable);
+ if (isStatisticsEnable) {
+ StatisticsStack sequenceStack = (StatisticsStack) synCtx.getProperty(Constants.SEQUENCE_STATISTICS_STACK);
+ if (sequenceStack == null) {
+ sequenceStack = new SequenceStatisticsStack();
+ synCtx.setProperty(Constants.SEQUENCE_STATISTICS_STACK, sequenceStack);
+ }
+ String seqName = (name == null ? "anonymous" : name);
+ sequenceStack.put(seqName, System.currentTimeMillis(), !synCtx.isResponse(), isStatisticsEnable);
+ }
try {
if (shouldTrace) {
trace.trace("Start : Sequence <" + (name == null ? "anonymous" : name) + ">");
@@ -71,23 +88,22 @@
if (errorHandler != null) {
if (shouldTrace) {
trace.trace("Sequence " + name + " encountered an exception. " +
- "Locating error handler sequence : " + errorHandler);
+ "Locating error handler sequence : " + errorHandler);
}
// set exception information to message context
Axis2MessageContext.setErrorInformation(synCtx, e);
-
Mediator errHandler = synCtx.getConfiguration().getNamedSequence(errorHandler);
if (errHandler == null) {
if (shouldTrace) {
trace.trace("Sequence " + name + "; error handler sequence named '" +
- errorHandler + "' not found");
+ errorHandler + "' not found");
}
handleException("Error handler sequence mediator instance named " +
errorHandler + " cannot be found");
} else {
if (shouldTrace) {
trace.trace("Sequence " + name + "; Executing error handler sequence : "
- + errorHandler);
+ + errorHandler);
}
return errHandler.mediate(synCtx);
}
@@ -95,11 +111,18 @@
} else {
if (shouldTrace) {
trace.trace("Sequence " + name + " encountered an exception, but does " +
- "not specify an error handler");
+ "not specify an error handler");
}
throw e;
}
+
} finally {
+ //If this sequence is finished it's task normally
+ if (isStatisticsEnable) {
+ StatisticsUtils.processSequenceStatistics(synCtx);
+ }
+ //If this sequence is a IN or OUT sequence of a proxy service
+ StatisticsUtils.processProxyServiceStatistics(synCtx);
if (shouldTrace) {
trace.trace("End : Sequence <" + (name == null ? "anonymous" : name) + ">");
}
@@ -149,5 +172,23 @@
public void setErrorHandler(String errorHandler) {
this.errorHandler = errorHandler;
+ }
+
+ /**
+ * To check whether statistics should have collected or not
+ *
+ * @return Returns the int value that indicate statistics is enabled or not.
+ */
+ public int getStatisticsEnable() {
+ return statisticsEnable;
+ }
+
+ /**
+ * To set the statistics enable variable value
+ *
+ * @param statisticsEnable
+ */
+ public void setStatisticsEnable(int statisticsEnable) {
+ this.statisticsEnable = statisticsEnable;
}
}
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/DropMediator.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/DropMediator.java?view=diff&rev=498943&r1=498942&r2=498943
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/DropMediator.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/DropMediator.java Mon Jan 22 23:26:34 2007
@@ -23,6 +23,7 @@
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.Constants;
import org.apache.synapse.MessageContext;
+import org.apache.synapse.statistics.StatisticsUtils;
import org.apache.synapse.mediators.AbstractMediator;
/**
@@ -41,6 +42,11 @@
*/
public boolean mediate(MessageContext synCtx) {
log.debug("Drop mediator :: mediate()");
+ //If drop mediator is a child of a sequence
+ // and if this sequence is a IN or OUT sequence of a proxy service
+ StatisticsUtils.processProxyServiceStatistics(synCtx);
+ //If this a sequence is not a IN or OUT sequence of a proxy service
+ StatisticsUtils.processSequenceStatistics(synCtx);
boolean shouldTrace = shouldTrace(synCtx.getTracingState());
if (shouldTrace) {
trace.trace("Start : Drop mediator");
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/SendMediator.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/SendMediator.java?view=diff&rev=498943&r1=498942&r2=498943
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/SendMediator.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/SendMediator.java Mon Jan 22 23:26:34 2007
@@ -26,6 +26,8 @@
import org.apache.synapse.MessageContext;
import org.apache.synapse.config.Endpoint;
import org.apache.synapse.mediators.AbstractMediator;
+import org.apache.synapse.statistics.impl.EndPointStatisticsStack;
+
import java.util.ArrayList;
import java.util.List;
@@ -56,99 +58,115 @@
public boolean mediate(MessageContext synCtx) {
log.debug("Send mediator :: mediate()");
- // TODO this may be really strange but true.. unless you call the below, sometimes it
- // results in an unbound URI exception for no credible reason - needs more investigation
- // seems like a woodstox issue. Use hack for now
- // synCtx.getEnvelope().build();
boolean shouldTrace = shouldTrace(synCtx.getTracingState());
- if (shouldTrace) {
- trace.trace("Start : Send mediator");
- trace.trace("Sending Message :: " + synCtx.getEnvelope());
- }
- // if no endpoints are defined, send where implicitly stated
- if (endpoints.isEmpty()) {
- log.debug("Sending message using implicit message properties..");
- log.debug("Sending To: " + (synCtx.getTo() != null ?
- synCtx.getTo().getAddress() : "null"));
- log.debug("SOAPAction: " + (synCtx.getWSAAction() != null ?
- synCtx.getWSAAction() : "null"));
- log.debug("Body : \n" + synCtx.getEnvelope());
- synCtx.getEnvironment().send(synCtx);
-
- } else if (endpoints.size() == 1) {
- Endpoint singleEndpoint = (Endpoint) endpoints.get(0);
- String eprAddress = null;
- if (singleEndpoint.getAddress() != null) {
- eprAddress = singleEndpoint.getAddress().toString();
- } else {
- singleEndpoint = synCtx.getConfiguration().getNamedEndpoint(
- singleEndpoint.getRef());
- eprAddress = singleEndpoint.getAddress().toString();
- }
+ try {
+ // TODO this may be really strange but true.. unless you call the below, sometimes it
+ // results in an unbound URI exception for no credible reason - needs more investigation
+ // seems like a woodstox issue. Use hack for now
+ // synCtx.getEnvelope().build();
+
if (shouldTrace) {
- trace.trace("Sending to Endpoint : " + eprAddress);
- }
- if (singleEndpoint.isForcePOX()) {
- synCtx.setDoingPOX(true);
- } else if (singleEndpoint.isForceSOAP()) {
- synCtx.setDoingPOX(false);
+ trace.trace("Start : Send mediator");
+ trace.trace("Sending Message :: " + synCtx.getEnvelope());
}
+ // if no endpoints are defined, send where implicitly stated
+ if (endpoints.isEmpty()) {
+ log.debug("Sending message using implicit message properties..");
+ log.debug("Sending To: " + (synCtx.getTo() != null ?
+ synCtx.getTo().getAddress() : "null"));
+ log.debug("SOAPAction: " + (synCtx.getWSAAction() != null ?
+ synCtx.getWSAAction() : "null"));
+ log.debug("Body : \n" + synCtx.getEnvelope());
+ synCtx.getEnvironment().send(synCtx);
+
+ } else if (endpoints.size() == 1) {
+ Endpoint singleEndpoint = (Endpoint) endpoints.get(0);
+ String eprAddress = null;
+ if (singleEndpoint.getAddress() != null) {
+ eprAddress = singleEndpoint.getAddress().toString();
+ } else {
+ singleEndpoint = synCtx.getConfiguration().getNamedEndpoint(
+ singleEndpoint.getRef());
+ eprAddress = singleEndpoint.getAddress().toString();
+ }
- if (singleEndpoint.isUseMTOM()) {
- synCtx.setDoingMTOM(true);
- } else if (singleEndpoint.isUseSwa()) {
- synCtx.setDoingSWA(true);
- }
+ if (shouldTrace) {
+ trace.trace("Sending to Endpoint : " + eprAddress);
+ }
+ if (singleEndpoint.isForcePOX()) {
+ synCtx.setDoingPOX(true);
+ } else if (singleEndpoint.isForceSOAP()) {
+ synCtx.setDoingPOX(false);
+ }
- if (singleEndpoint.isUseSeparateListener())
- {
- synCtx.setProperty(Constants.OUTFLOW_USE_SEPARATE_LISTENER, Boolean.TRUE);
- }
-
- log.debug("Sending message to endpoint :: name = " +
- singleEndpoint.getName() + " resolved address = " + eprAddress);
-
- synCtx.setTo(new EndpointReference(eprAddress));
- log.debug("Sending To: " + (synCtx.getTo() != null ?
- synCtx.getTo().getAddress() : "null"));
- log.debug("SOAPAction: " + (synCtx.getWSAAction() != null ?
- synCtx.getWSAAction() : "null"));
- log.debug("Body : \n" + synCtx.getEnvelope());
-
- // if RM is turned on
- if (singleEndpoint.isReliableMessagingOn()) {
- synCtx.setProperty(Constants.OUTFLOW_ADDRESSING_ON, Boolean.TRUE);
- synCtx.setProperty(Constants.OUTFLOW_RM_ON, Boolean.TRUE);
- if (singleEndpoint.getWsRMPolicyKey() != null) {
- synCtx.setProperty(Constants.OUTFLOW_RM_POLICY,
- singleEndpoint.getWsRMPolicyKey());
+ if (singleEndpoint.isForcePOX()) {
+ synCtx.setDoingPOX(true);
+ } else if (singleEndpoint.isForceSOAP()) {
+ synCtx.setDoingPOX(false);
}
- }
- // if WS Security is specified
- if (singleEndpoint.isSecurityOn()) {
- synCtx.setProperty(Constants.OUTFLOW_ADDRESSING_ON, Boolean.TRUE);
- synCtx.setProperty(Constants.OUTFLOW_SECURITY_ON, Boolean.TRUE);
- if (singleEndpoint.getWsSecPolicyKey() != null) {
- synCtx.setProperty(Constants.OUTFLOW_SEC_POLICY,
- singleEndpoint.getWsSecPolicyKey());
+ if (singleEndpoint.isUseMTOM()) {
+ synCtx.setDoingMTOM(true);
+ } else if (singleEndpoint.isUseSwa()) {
+ synCtx.setDoingSWA(true);
}
- }
- // if WS Addressing is specified
- if (singleEndpoint.isAddressingOn()) {
- synCtx.setProperty(Constants.OUTFLOW_ADDRESSING_ON, Boolean.TRUE);
- }
+ if (singleEndpoint.isUseSeparateListener()) {
+ synCtx.setProperty(Constants.OUTFLOW_USE_SEPARATE_LISTENER, Boolean.TRUE);
+ }
+ String endPointName = singleEndpoint.getName();
+ log.debug("Sending message to endpoint :: name = " +
+ endPointName + " resolved address = " + eprAddress);
+
+ // Setting Required property to collect the End Point statistics
+ boolean statisticsEnable = (org.apache.synapse.Constants.STATISTICS_ON == singleEndpoint.getStatisticsEnable());
+ if (endPointName != null && statisticsEnable) {
+ EndPointStatisticsStack endPointStatisticsStack = new EndPointStatisticsStack();
+ endPointStatisticsStack.put(endPointName, System.currentTimeMillis(), !synCtx.isResponse(), statisticsEnable);
+ synCtx.setCorrelationProperty(org.apache.synapse.Constants.ENDPOINT_STATISTICS_STACK, endPointStatisticsStack);
+ }
+ synCtx.setTo(new EndpointReference(eprAddress));
+ log.debug("Sending To: " + (synCtx.getTo() != null ?
+ synCtx.getTo().getAddress() : "null"));
+ log.debug("SOAPAction: " + (synCtx.getWSAAction() != null ?
+ synCtx.getWSAAction() : "null"));
+ log.debug("Body : \n" + synCtx.getEnvelope());
+
+ // if RM is turned on
+ if (singleEndpoint.isReliableMessagingOn()) {
+ synCtx.setProperty(Constants.OUTFLOW_ADDRESSING_ON, Boolean.TRUE);
+ synCtx.setProperty(Constants.OUTFLOW_RM_ON, Boolean.TRUE);
+ if (singleEndpoint.getWsRMPolicyKey() != null) {
+ synCtx.setProperty(Constants.OUTFLOW_RM_POLICY,
+ singleEndpoint.getWsRMPolicyKey());
+ }
+ }
- synCtx.getEnvironment().send(synCtx);
+ // if WS Security is specified
+ if (singleEndpoint.isSecurityOn()) {
+ synCtx.setProperty(Constants.OUTFLOW_ADDRESSING_ON, Boolean.TRUE);
+ synCtx.setProperty(Constants.OUTFLOW_SECURITY_ON, Boolean.TRUE);
+ if (singleEndpoint.getWsSecPolicyKey() != null) {
+ synCtx.setProperty(Constants.OUTFLOW_SEC_POLICY,
+ singleEndpoint.getWsSecPolicyKey());
+ }
+ }
- } else {
- String msg = "The send mediator currently supports only one endpoint";
- log.error(msg);
- throw new UnsupportedOperationException(msg);
- }
- if (shouldTrace) {
- trace.trace("End : Send mediator");
+ // if WS Addressing is specified
+ if (singleEndpoint.isAddressingOn()) {
+ synCtx.setProperty(Constants.OUTFLOW_ADDRESSING_ON, Boolean.TRUE);
+ }
+ synCtx.getEnvironment().send(synCtx);
+ } else {
+ String msg = "The send mediator currently supports only one endpoint";
+ synCtx.setProperty(Constants.SYNAPSE_ERROR, Boolean.TRUE);
+ log.error(msg);
+ throw new UnsupportedOperationException(msg);
+ }
+ } finally {
+ if (shouldTrace) {
+ trace.trace("End : Send mediator");
+ }
}
return false;
}
Added: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/Statistics.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/Statistics.java?view=auto&rev=498943
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/Statistics.java (added)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/Statistics.java Mon Jan 22 23:26:34 2007
@@ -0,0 +1,97 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.synapse.statistics;
+
+/**
+ * The statistics data structure
+ */
+
+public class Statistics {
+
+ /** Maximum Processing time for a one way flow */
+ private long maxProcessingTime = 0;
+ /** Minmum Processing time for a one way flow */
+ private long minProcessingTime = -1;
+ /** Avarage Processing time for a one way flow */
+ private double avgProcessingTime = 0;
+ /** Total Processing time for a one way flow */
+ private double totalProcessingTime;
+ /** The number of access count for a one way flow */
+ private int count = 0;
+ /** The number of fault count for a one way flow */
+ private int faultCount = 0;
+
+ /**
+ * Update the statistics
+ *
+ * @param inTime - The processing start time
+ * @param outTime - The processing end time
+ * @param isFault - A boolean value that indicate whether falut has occured or not
+ */
+ public void update(long inTime, long outTime, boolean isFault) {
+ count++;
+ if (isFault) {
+ faultCount++;
+ }
+ long responseTime = outTime - inTime;
+ if (maxProcessingTime < responseTime) {
+ maxProcessingTime = responseTime;
+ }
+ if (minProcessingTime > responseTime) {
+ minProcessingTime = responseTime;
+ }
+ if (minProcessingTime == -1) {
+ minProcessingTime = responseTime;
+ }
+ totalProcessingTime = totalProcessingTime + responseTime;
+ avgProcessingTime = totalProcessingTime / count;
+ }
+
+ /**
+ * @return Returns the Maximum processing time
+ */
+ public long getMaxProcessingTime() {
+ return maxProcessingTime;
+ }
+
+ /**
+ * @return Returns the Avarage processing time
+ */
+ public double getAvgProcessingTime() {
+ return avgProcessingTime;
+ }
+
+ /**
+ * @return Returns the minimum processing time
+ */
+ public long getMinProcessingTime() {
+ return minProcessingTime;
+ }
+
+ /**
+ * @return Returns the fault count
+ */
+ public int getFaultCount() {
+ return faultCount;
+ }
+
+ /**
+ * @return Returns the total count that represents number of access in a one way flow
+ */
+ public int getCount() {
+ return count;
+ }
+}
Added: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsCollector.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsCollector.java?view=auto&rev=498943
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsCollector.java (added)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsCollector.java Mon Jan 22 23:26:34 2007
@@ -0,0 +1,124 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.synapse.statistics;
+
+import org.apache.synapse.Constants;
+
+import java.util.*;
+
+/**
+ * To collect statistics
+ */
+
+public class StatisticsCollector {
+
+ /** A synchronized map for holding sequence statistics */
+ private Map sequenceStatistics = Collections.synchronizedMap(new HashMap());
+
+ /** A synchronized map for holding end point statistics */
+ private Map endpointStatistics = Collections.synchronizedMap(new HashMap());
+
+ /** A synchronized map for holding proxy services statistics */
+ private Map proxyServicesStatistics = Collections.synchronizedMap(new HashMap());
+
+ /**
+ * To report the statistics related to a EndPonit
+ *
+ * @param keyOfStatistic - key for hold Statistic
+ * @param isResponse - A boolean value that indicate whether message flow is in or out
+ * @param inTime - The processing start time
+ * @param outTime - The processing end time
+ * @param isFault - A boolean value that indicate whether falut has occured or not
+ */
+ public void reportForEndPoint(String keyOfStatistic, boolean isResponse, long inTime, long outTime, boolean isFault) {
+ StatisticsHolder statisticsHolder = (StatisticsHolder) endpointStatistics.get(keyOfStatistic);
+ if (statisticsHolder == null) {
+ statisticsHolder = new StatisticsHolder();
+ statisticsHolder.setKey(keyOfStatistic);
+ statisticsHolder.setStatisticsCategory(Constants.ENDPOINT_STATISTICS);
+ endpointStatistics.put(keyOfStatistic, statisticsHolder);
+ }
+ statisticsHolder.update(isResponse, inTime, outTime, isFault);
+
+ }
+
+ /**
+ * To report the statistics related to a ProxyService
+ *
+ * @param keyOfStatistic - key for hold Statistic
+ * @param isResponse - A boolean value that indicate whether message flow is in or out
+ * @param inTime - The processing start time
+ * @param outTime - The processing end time
+ * @param isFault - A boolean value that indicate whether falut has occured or not
+ */
+ public void reportForProxyService(String keyOfStatistic, boolean isResponse, long inTime, long outTime, boolean isFault) {
+ StatisticsHolder statisticsHolder = (StatisticsHolder) proxyServicesStatistics.get(keyOfStatistic);
+ if (statisticsHolder == null) {
+ statisticsHolder = new StatisticsHolder();
+ statisticsHolder.setKey(keyOfStatistic);
+ statisticsHolder.setStatisticsCategory(Constants.PROXYSERVICE_STATISTICS);
+ proxyServicesStatistics.put(keyOfStatistic, statisticsHolder);
+ }
+ statisticsHolder.update(isResponse, inTime, outTime, isFault);
+ }
+
+ /**
+ * To report the statistics related to a Sequence
+ *
+ * @param keyOfStatistic - key for hold Statistic
+ * @param isResponse - A boolean value that indicate whether message flow is in or out
+ * @param inTime - The processing start time
+ * @param outTime - The processing end time
+ * @param isFault - A boolean value that indicate whether falut has occured or not
+ */
+ public void reportForSequence(String keyOfStatistic, boolean isResponse, long inTime, long outTime, boolean isFault) {
+ StatisticsHolder statisticsHolder = (StatisticsHolder) sequenceStatistics.get(keyOfStatistic);
+ if (statisticsHolder == null) {
+ statisticsHolder = new StatisticsHolder();
+ statisticsHolder.setKey(keyOfStatistic);
+ statisticsHolder.setStatisticsCategory(Constants.SEQUENCE_STATISTICS);
+ sequenceStatistics.put(keyOfStatistic, statisticsHolder);
+ }
+ statisticsHolder.update(isResponse, inTime, outTime, isFault);
+ }
+
+ /**
+ * To access all sequence statistics
+ *
+ * @return all sequence statistics
+ */
+ public Iterator getSequenceStatistics() {
+ return sequenceStatistics.values().iterator();
+ }
+
+ /**
+ * To access all proxy services statistics
+ *
+ * @return all proxy services statistics
+ */
+ public Iterator getProxyServiceStatistics() {
+ return proxyServicesStatistics.values().iterator();
+ }
+
+ /**
+ * To access all endpoint statistics
+ *
+ * @return all endpoint statistics
+ */
+ public Iterator getEndPointStatistics() {
+ return endpointStatistics.values().iterator();
+ }
+}
Added: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsHolder.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsHolder.java?view=auto&rev=498943
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsHolder.java (added)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsHolder.java Mon Jan 22 23:26:34 2007
@@ -0,0 +1,114 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.synapse.statistics;
+
+import org.apache.synapse.Constants;
+
+/**
+ * To hold statistics that will collected during both of in and out message mediation
+ */
+
+public class StatisticsHolder {
+
+ private int statisticsCategory ;
+
+ private String key ;
+
+ /** The statistics that will collect during in coming message mediation */
+ private Statistics inFlowStatistics;
+
+ /** The statistics that will collect during out going message mediation */
+ private Statistics outFlowStatistics;
+
+ /**
+ * To update the statistics
+ *
+ * @param isResponse - A boolean value that indicate whether message flow is in or out
+ * @param inTime - The processing start time
+ * @param outTime - The processing end time
+ * @param isFault - A boolean value that indicate whether falut has occured or not
+ */
+ public synchronized void update(boolean isResponse, long inTime, long outTime, boolean isFault) {
+ if (isResponse) {
+ if (outFlowStatistics == null) {
+ outFlowStatistics = new Statistics();
+ }
+ outFlowStatistics.update(inTime, outTime, isFault);
+ } else {
+ if (inFlowStatistics == null) {
+ inFlowStatistics = new Statistics();
+ }
+ inFlowStatistics.update(inTime, outTime, isFault);
+ }
+
+ }
+
+ /**
+ * To get Statistics related to the In Flow
+ * @return Statistics related to the In Flow
+ */
+ public synchronized Statistics getInFlowStatistics() {
+ return inFlowStatistics;
+ }
+
+ /**
+ * To get Statistics related to the Out Flow
+ * @return Statistics related to the Out Flow
+ */
+ public synchronized Statistics getOutFlowStatistics() {
+ return outFlowStatistics;
+ }
+
+ /**
+ * To get statistics category
+ * @return Statistics Category
+ */
+ public int getStatisticsCategory() {
+ return statisticsCategory;
+ }
+
+ /**
+ * To set statistics category
+ * @param statisticsCategory
+ */
+ public void setStatisticsCategory(int statisticsCategory) {
+ this.statisticsCategory = statisticsCategory;
+ }
+
+ /**
+ * To get key of statistics
+ * @return key of statistics
+ */
+ public String getKey() {
+ return key;
+ }
+
+ /**
+ * To set key of statistics
+ * @param key
+ */
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ /**
+ * To clear stored statistics
+ */
+ public synchronized void clearStatistics(){
+ this.inFlowStatistics =null;
+ this.outFlowStatistics=null;
+ }
+}
Added: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsStack.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsStack.java?view=auto&rev=498943
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsStack.java (added)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsStack.java Mon Jan 22 23:26:34 2007
@@ -0,0 +1,47 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.synapse.statistics;
+
+/**
+ * This interface need to be implemented by each of the entry that
+ * need to collect statistics
+ *
+ */
+
+public interface StatisticsStack {
+
+ /**
+ * This method is used to put current statistics
+ * @param key
+ * @param initTime
+ * @param isInFlow
+ * @param isStatisticsEnable
+ */
+ public void put(String key,long initTime, boolean isInFlow, boolean isStatisticsEnable);
+
+ /**
+ * This method used to report the latest statistics to the StatisticsCollector
+ * @param statisticsCollector
+ */
+ public void reportToStatisticsCollector(StatisticsCollector statisticsCollector);
+
+ /**
+ * This method used to unreported all statistics to the StatisticsCollector
+ * @param statisticsCollector
+ */
+ public void reportAllToStatisticsCollector(StatisticsCollector statisticsCollector);
+
+}
Added: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsUtils.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsUtils.java?view=auto&rev=498943
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsUtils.java (added)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsUtils.java Mon Jan 22 23:26:34 2007
@@ -0,0 +1,90 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.synapse.statistics;
+
+import org.apache.synapse.Constants;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.core.SynapseEnvironment;
+import org.apache.synapse.statistics.impl.SequenceStatisticsStack;
+import org.apache.synapse.statistics.impl.EndPointStatisticsStack;
+import org.apache.synapse.statistics.impl.ProxyServiceStatisticsStack;
+
+/**
+ * A utils to process statistics
+ *
+ */
+
+public class StatisticsUtils {
+
+ /**
+ * To process statistics related to the proxy services
+ *
+ * @param synCtx
+ */
+ public static void processProxyServiceStatistics(MessageContext synCtx) {
+
+ StatisticsCollector statisticsCollector = getStatisticsCollector(synCtx);
+ ProxyServiceStatisticsStack proxyServiceStatisticsStack = (ProxyServiceStatisticsStack) synCtx.getProperty(Constants.PROXYSERVICE_STATISTICS_STACK);
+ if (proxyServiceStatisticsStack != null) {
+ proxyServiceStatisticsStack.reportToStatisticsCollector(statisticsCollector);
+ }
+ }
+
+ /**
+ * To process statistics related to the End Points
+ *
+ * @param synCtx
+ */
+ public static void processEndPointStatistics(MessageContext synCtx) {
+ StatisticsCollector statisticsCollector = getStatisticsCollector(synCtx);
+ EndPointStatisticsStack endPointStatisticsStack = (EndPointStatisticsStack) synCtx.getProperty(Constants.ENDPOINT_STATISTICS_STACK);
+ if (endPointStatisticsStack != null) {
+ endPointStatisticsStack.reportToStatisticsCollector(statisticsCollector);
+ }
+ }
+
+ /**
+ * To process statistics related to the sequence
+ *
+ * @param synCtx
+ */
+ public static void processSequenceStatistics(MessageContext synCtx) {
+ StatisticsCollector statisticsCollector = getStatisticsCollector(synCtx);
+ SequenceStatisticsStack sequenceStatisticsStack = (SequenceStatisticsStack) synCtx.getProperty(Constants.SEQUENCE_STATISTICS_STACK);
+ if (sequenceStatisticsStack != null) {
+ sequenceStatisticsStack.reportToStatisticsCollector(statisticsCollector);
+ }
+ }
+
+ /**
+ * A helper method to get StatisticsCollector from the Synapse Message Context
+ *
+ * @param synCtx
+ * @return StatisticsCollector
+ */
+ private static StatisticsCollector getStatisticsCollector(MessageContext synCtx) {
+ SynapseEnvironment synEnv = synCtx.getEnvironment();
+ StatisticsCollector statisticsCollector = null;
+ if (synEnv != null) {
+ statisticsCollector = synEnv.getStatisticsCollector();
+ if (statisticsCollector == null) {
+ statisticsCollector = new StatisticsCollector();
+ synEnv.setStatisticsCollector(statisticsCollector);
+ }
+ }
+ return statisticsCollector;
+ }
+}
Added: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/impl/EndPointStatisticsStack.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/impl/EndPointStatisticsStack.java?view=auto&rev=498943
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/impl/EndPointStatisticsStack.java (added)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/impl/EndPointStatisticsStack.java Mon Jan 22 23:26:34 2007
@@ -0,0 +1,69 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.synapse.statistics.impl;
+
+import org.apache.synapse.statistics.StatisticsStack;
+import org.apache.synapse.statistics.StatisticsCollector;
+
+/**
+ * The data structure to hold statistics related to the end points
+ *
+ */
+
+public class EndPointStatisticsStack implements StatisticsStack {
+
+ /** The name of the endpoint */
+ private String endPointName;
+ /** The time which starts to collect statistics */
+ private long initTime;
+ /** To check whether IN message flow or not */
+ private boolean isInFlow;
+ /** To check whether statistics is enabled or not */
+ private boolean isStatisticsEnable;
+
+ /**
+ * To put statistics
+ * @param key - The name of the End Point
+ * @param initTime
+ * @param isInFlow
+ * @param isStatisticsEnable
+ */
+ public void put(String key, long initTime, boolean isInFlow, boolean isStatisticsEnable) {
+ this.endPointName = key;
+ this.initTime = initTime;
+ this.isInFlow = isInFlow;
+ this.isStatisticsEnable = isStatisticsEnable;
+ }
+
+ /**
+ * This method used to report the latest statistics to the StatisticsCollector
+ * @param statisticsCollector
+ */
+ public void reportToStatisticsCollector(StatisticsCollector statisticsCollector) {
+ if (isStatisticsEnable && endPointName!=null) {
+ statisticsCollector.reportForEndPoint(endPointName, !isInFlow, initTime, System.currentTimeMillis(), false);
+ endPointName =null;
+ }
+ }
+
+ /**
+ * This method used to unreported all statistics to the StatisticsCollector
+ * @param statisticsCollector
+ */
+ public void reportAllToStatisticsCollector(StatisticsCollector statisticsCollector) {
+ reportToStatisticsCollector(statisticsCollector);
+ }
+}
Added: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/impl/ProxyServiceStatisticsStack.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/impl/ProxyServiceStatisticsStack.java?view=auto&rev=498943
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/impl/ProxyServiceStatisticsStack.java (added)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/impl/ProxyServiceStatisticsStack.java Mon Jan 22 23:26:34 2007
@@ -0,0 +1,76 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.synapse.statistics.impl;
+
+import org.apache.synapse.statistics.StatisticsStack;
+import org.apache.synapse.statistics.StatisticsCollector;
+
+/**
+ * The data structure to hold statistics related to the Proxy Services
+ *
+ */
+
+public class ProxyServiceStatisticsStack implements StatisticsStack {
+
+ /** The name of the proxy service*/
+ private String proxyServiceName;
+ /** To check whether statistics is enabled or not */
+ private boolean isStatisticsEnable = false;
+ /** The time which starts to collect statistics for IN flow */
+ private long inTimeForInFlow = -1;
+ /** The time which starts to collect statistics for OUT flow */
+ private long inTimeForOutFlow = -1;
+
+ /**
+ * To put a statistics
+ * @param key - The Name of the proxy service
+ * @param initTime
+ * @param isInFlow
+ * @param isStatisticsEnable
+ */
+ public void put(String key, long initTime, boolean isInFlow, boolean isStatisticsEnable) {
+
+ if (isInFlow) {
+ this.proxyServiceName = key;
+ this.isStatisticsEnable = isStatisticsEnable;
+ this.inTimeForInFlow = initTime;
+ }
+ }
+
+ /**
+ * This method used to report the latest statistics to the StatisticsCollector
+ * @param statisticsCollector
+ */
+ public void reportToStatisticsCollector(StatisticsCollector statisticsCollector) {
+
+ if (proxyServiceName != null && isStatisticsEnable && inTimeForInFlow != -1) {
+ inTimeForOutFlow = System.currentTimeMillis();
+ statisticsCollector.reportForProxyService(proxyServiceName, false, inTimeForInFlow, inTimeForOutFlow, false);
+ inTimeForInFlow = -1;
+ } else if (inTimeForOutFlow != -1) {
+ statisticsCollector.reportForProxyService(proxyServiceName, true, inTimeForOutFlow, System.currentTimeMillis(), false);
+ inTimeForOutFlow = -1;
+ }
+ }
+
+ /**
+ * This method used to unreported all statistics to the StatisticsCollector
+ * @param statisticsCollector
+ */
+ public void reportAllToStatisticsCollector(StatisticsCollector statisticsCollector) {
+ reportToStatisticsCollector(statisticsCollector);
+ }
+}
Added: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/impl/SequenceStatisticsStack.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/impl/SequenceStatisticsStack.java?view=auto&rev=498943
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/impl/SequenceStatisticsStack.java (added)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/impl/SequenceStatisticsStack.java Mon Jan 22 23:26:34 2007
@@ -0,0 +1,97 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.synapse.statistics.impl;
+
+import org.apache.synapse.statistics.StatisticsStack;
+import org.apache.synapse.statistics.StatisticsCollector;
+
+import java.util.ArrayList;
+
+/**
+ * The data structure to hold statistics related to Sequences
+ *
+ */
+
+public class SequenceStatisticsStack implements StatisticsStack {
+
+ /** The list to hols SequenceStatistics */
+ private ArrayList sequenceStatisticsList = new ArrayList();
+
+ /**
+ * To put a statistics
+ * @param sequenceName - The name of the sequence
+ * @param initTime
+ * @param isInFlow
+ * @param isStatisticsEnable
+ */
+ public void put(String sequenceName, long initTime, boolean isInFlow, boolean isStatisticsEnable) {
+ sequenceStatisticsList.add(new SequenceStatistics(sequenceName, initTime, isInFlow, isStatisticsEnable));
+ }
+ /**
+ * This method used to report the latest statistics to the StatisticsCollector
+ * @param statisticsCollector
+ */
+ public void reportToStatisticsCollector(StatisticsCollector statisticsCollector) {
+ popSequenceStatistics(sequenceStatisticsList.size() - 1, statisticsCollector);
+ }
+ /**
+ * This method used to unreported all statistics to the StatisticsCollector
+ * @param statisticsCollector
+ */
+ public void reportAllToStatisticsCollector(StatisticsCollector statisticsCollector) {
+ for (int i = sequenceStatisticsList.size(); i < 0; i--) {
+ popSequenceStatistics(i, statisticsCollector);
+ }
+ }
+
+ /**
+ * A helper method to pop a SequenceStatistics
+ * @param index
+ * @param statisticsCollector
+ */
+ private void popSequenceStatistics(int index, StatisticsCollector statisticsCollector) {
+ SequenceStatistics sequenceStatistics = (SequenceStatistics) sequenceStatisticsList.get(index);
+ if (sequenceStatistics != null) {
+ if (sequenceStatistics.isStatisticsEnable && sequenceStatistics.sequenceName != null) {
+ statisticsCollector.reportForSequence(sequenceStatistics.sequenceName, !sequenceStatistics.isInFlow, sequenceStatistics.initTime, System.currentTimeMillis(), false);
+ }
+ sequenceStatisticsList.remove(index);
+ }
+ }
+
+ /**
+ * The SequenceStatistics data structure
+ */
+ class SequenceStatistics {
+
+ /** The name of the Sequence */
+ String sequenceName;
+ /** The time which starts to collect statistics */
+ long initTime;
+ /** To check whether IN message flow or not */
+ boolean isInFlow;
+ /** To check whether statistics is enabled or not */
+ boolean isStatisticsEnable;
+
+ public SequenceStatistics(String sequenceName, long initTime, boolean inFlow, boolean statisticsEnable) {
+ this.sequenceName = sequenceName;
+ this.initTime = initTime;
+ isInFlow = inFlow;
+ isStatisticsEnable = statisticsEnable;
+ }
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org