You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by in...@apache.org on 2010/03/30 19:37:42 UTC
svn commit: r929198 - in
/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse: aspects/
aspects/statistics/ config/ core/axis2/
Author: indika
Date: Tue Mar 30 17:37:41 2010
New Revision: 929198
URL: http://svn.apache.org/viewvc?rev=929198&view=rev
Log:
improve stats collection code
remove unwanted code ..add java doc, etc ...
Removed:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/AspectConfigurationDetectionStrategy.java
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/ComponentType.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/ErrorLog.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/ErrorLogFactory.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/StatisticsCollector.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/StatisticsLog.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/StatisticsRecord.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/StatisticsRecordFactory.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/StatisticsReporter.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfigUtils.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2Sender.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseMessageReceiver.java
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/ComponentType.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/ComponentType.java?rev=929198&r1=929197&r2=929198&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/ComponentType.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/ComponentType.java Tue Mar 30 17:37:41 2010
@@ -19,7 +19,7 @@
package org.apache.synapse.aspects;
/**
- * Types for set of abstractions
+ * Types for a set of abstractions
*/
public enum ComponentType {
PROXYSERVICE,
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/ErrorLog.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/ErrorLog.java?rev=929198&r1=929197&r2=929198&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/ErrorLog.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/ErrorLog.java Tue Mar 30 17:37:41 2010
@@ -19,8 +19,9 @@
package org.apache.synapse.aspects.statistics;
/**
- * Represent the error logs *
+ * Represent the error logs
*/
+@SuppressWarnings("unused")
public class ErrorLog {
/**
@@ -78,4 +79,11 @@ public class ErrorLog {
public void setErrorDetail(String errorDetail) {
this.errorDetail = errorDetail;
}
+
+ @Override
+ public String toString() {
+ return "ErrorLog{" +
+ "errorCode='" + errorCode + '\'' +
+ '}';
+ }
}
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/ErrorLogFactory.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/ErrorLogFactory.java?rev=929198&r1=929197&r2=929198&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/ErrorLogFactory.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/ErrorLogFactory.java Tue Mar 30 17:37:41 2010
@@ -18,6 +18,8 @@
*/
package org.apache.synapse.aspects.statistics;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.synapse.SynapseConstants;
import org.apache.synapse.config.SynapsePropertiesLoader;
@@ -26,15 +28,19 @@ import org.apache.synapse.config.Synapse
*/
public class ErrorLogFactory {
- private static boolean enabledErrorInfo;
+ private static final Log log = LogFactory.getLog(ErrorLogFactory.class);
+
+ private static boolean enabledErrorDetails;
static {
- enabledErrorInfo = Boolean.parseBoolean(SynapsePropertiesLoader.getPropertyValue(
+ enabledErrorDetails = Boolean.parseBoolean(SynapsePropertiesLoader.getPropertyValue(
"synapse.detailederrorlogging.enable", "false"));
}
/**
* Create an ErrorLog from the information in the synapse MessageContext
+ * By default only the error code is logged and if the 'synapse.detailederrorlogging.enable'
+ * has been set, then the error message, details and exception are also logged
*
* @param synCtx MessageContext instance
* @return <code>ErrorLog</code> instance
@@ -43,28 +49,37 @@ public class ErrorLogFactory {
String errorCode = String.valueOf(synCtx.getProperty(SynapseConstants.ERROR_CODE));
ErrorLog errorLog = new ErrorLog(errorCode);
- if (enabledErrorInfo) {
+ if (enabledErrorDetails) {
errorLog.setErrorMessage((String) synCtx.getProperty(SynapseConstants.ERROR_MESSAGE));
errorLog.setErrorDetail((String) synCtx.getProperty(SynapseConstants.ERROR_DETAIL));
errorLog.setException((Exception) synCtx.getProperty(SynapseConstants.ERROR_EXCEPTION));
}
+ if (log.isDebugEnabled()) {
+ log.debug("Created a Error Log : " + errorLog);
+ }
return errorLog;
}
/**
* Create an ErrorLog from the information in the Axis2 MessageContext
+ * By default only the error code is logged and if the 'synapse.detailederrorlogging.enable'
+ * has been set, then the error message, details and exception are also logged
*
* @param axisCtx Axis2 MessageContext instance
* @return <code>ErrorLog</code> instance
*/
public static ErrorLog createErrorLog(org.apache.axis2.context.MessageContext axisCtx) {
+
String errorCode = String.valueOf(axisCtx.getProperty(SynapseConstants.ERROR_CODE));
ErrorLog errorLog = new ErrorLog(errorCode);
- if (enabledErrorInfo) {
+ if (enabledErrorDetails) {
errorLog.setErrorMessage((String) axisCtx.getProperty(SynapseConstants.ERROR_MESSAGE));
errorLog.setErrorDetail((String) axisCtx.getProperty(SynapseConstants.ERROR_DETAIL));
errorLog.setException((Exception) axisCtx.getProperty(SynapseConstants.ERROR_EXCEPTION));
}
+ if (log.isDebugEnabled()) {
+ log.debug("Created a Error Log : " + errorLog);
+ }
return errorLog;
}
}
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/StatisticsCollector.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/StatisticsCollector.java?rev=929198&r1=929197&r2=929198&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/StatisticsCollector.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/StatisticsCollector.java Tue Mar 30 17:37:41 2010
@@ -30,7 +30,7 @@ import java.util.concurrent.ConcurrentLi
/**
* Collects statistics and provides those collected data
*/
-
+@SuppressWarnings("unused")
public class StatisticsCollector {
private static final Log log = LogFactory.getLog(StatisticsCollector.class);
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/StatisticsLog.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/StatisticsLog.java?rev=929198&r1=929197&r2=929198&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/StatisticsLog.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/StatisticsLog.java Tue Mar 30 17:37:41 2010
@@ -92,4 +92,12 @@ public class StatisticsLog {
public void setErrorLog(ErrorLog errorLog) {
this.errorLog = errorLog;
}
+
+ @Override
+ public String toString() {
+ return "StatisticsLog{" +
+ "id='" + id + '\'' +
+ ", componentType=" + componentType +
+ '}';
+ }
}
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/StatisticsRecord.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/StatisticsRecord.java?rev=929198&r1=929197&r2=929198&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/StatisticsRecord.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/StatisticsRecord.java Tue Mar 30 17:37:41 2010
@@ -29,6 +29,7 @@ import java.util.List;
/**
* Holds a record for statistics for current message
*/
+@SuppressWarnings("unused")
public class StatisticsRecord {
private static final Log log = LogFactory.getLog(StatisticsRecord.class);
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/StatisticsRecordFactory.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/StatisticsRecordFactory.java?rev=929198&r1=929197&r2=929198&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/StatisticsRecordFactory.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/StatisticsRecordFactory.java Tue Mar 30 17:37:41 2010
@@ -25,14 +25,14 @@ import org.apache.synapse.core.axis2.Axi
import org.apache.synapse.transport.nhttp.NhttpConstants;
/**
- * Factory for creating a StatisticsRecord
+ * Factory for creating <code>StatisticsRecord</code> instances
*/
public class StatisticsRecordFactory {
private static final Log log = LogFactory.getLog(StatisticsRecordFactory.class);
/**
- * Factory method to create a a StatisticsRecord
+ * Factory method to create <code>StatisticsRecord</code> instances
*
* @param synCtx Current Message through synapse
* @return StatisticsRecord instance
@@ -47,7 +47,7 @@ public class StatisticsRecordFactory {
String domainName = (String) axisMC.getPropertyNonReplicable(NhttpConstants.REMOTE_HOST);
StatisticsRecord statisticsRecord = new StatisticsRecord(messageId, remoteIP, domainName);
if (log.isDebugEnabled()) {
- log.debug("Created a StatisticsRecord with " + statisticsRecord.toString());
+ log.debug("Created a StatisticsRecord : " + statisticsRecord);
}
return statisticsRecord;
}
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/StatisticsReporter.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/StatisticsReporter.java?rev=929198&r1=929197&r2=929198&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/StatisticsReporter.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/aspects/statistics/StatisticsReporter.java Tue Mar 30 17:37:41 2010
@@ -26,10 +26,10 @@ import org.apache.synapse.MessageContext
import org.apache.synapse.SynapseConstants;
import org.apache.synapse.aspects.AspectConfiguration;
import org.apache.synapse.aspects.ComponentType;
-import org.apache.synapse.endpoints.EndpointDefinition;
/**
- * A utility to report statistics
+ * A utility to report statistics at various check points in the message flow
+ * TODO - This class should be removed after a flow based statistics collection is done.
*/
public class StatisticsReporter {
@@ -37,32 +37,65 @@ public class StatisticsReporter {
private static final Log log = LogFactory.getLog(StatisticsReporter.class);
/**
- * Collects statistics for the given component
+ * Collects statistics for the given component.This is the starting point of
+ * collecting stats for a particular component
*
- * @param synCtx Current Message through synapse
- * @param configurable Instance that can be configured it's audit
- * @param componentType Type of the component need aspect
+ * @param synCtx the current message being passed through the synapse
+ * @param configurable a component that can be configured it's audit
+ * @param componentType the type of the component which needs to collect statistics
*/
public static void reportForComponent(MessageContext synCtx,
StatisticsConfigurable configurable,
ComponentType componentType) {
- if (configurable instanceof Identifiable && configurable.isStatisticsEnable()) {
- StatisticsRecord record = getStatisticsRecord(synCtx);
- record.setOwner(componentType);
- record.collect(createStatisticsLog((Identifiable) configurable, componentType, synCtx));
+
+ if (!(configurable instanceof Identifiable)) {
+ // provided configuration is not a Identifiable
+ return;
+ }
+
+ if (!configurable.isStatisticsEnable()) {
+ // statistics is disabled
+ return;
}
+
+ StatisticsRecord record =
+ (StatisticsRecord) synCtx.getProperty(SynapseConstants.STATISTICS_STACK);
+ if (record == null) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Setting a statistics stack on the message context.");
+ }
+ record = StatisticsRecordFactory.getStatisticsRecord(synCtx);
+ synCtx.setProperty(SynapseConstants.STATISTICS_STACK, record);
+ }
+
+ record.setOwner(componentType);
+ record.collect(createStatisticsLog((Identifiable) configurable, componentType, synCtx));
+
}
/**
- * Collects statistics for any component
+ * Collects statistics for any component when a response for a request is received.
+ * Any component means that this statistics log (check point) is valid for sequence, endpoint,
+ * and proxy.
*
- * @param synCtx Current Message through synapse
+ * @param synCtx the current message being passed through the synapse
*/
public static void reportForAllOnResponseReceived(MessageContext synCtx) {
+
+ // remove the property that have been set when sending the request
synCtx.setProperty(SynapseConstants.SENDING_REQUEST, false);
+
+ // if there is a statistics record
StatisticsRecord statisticsRecord =
(StatisticsRecord) synCtx.getProperty(SynapseConstants.STATISTICS_STACK);
if (statisticsRecord != null) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Reporting a statistics on a response is received : " +
+ statisticsRecord);
+ }
+
AspectConfiguration configuration = new AspectConfiguration(
SynapseConstants.SYNAPSE_ASPECTS);
configuration.enableStatistics();
@@ -71,7 +104,9 @@ public class StatisticsReporter {
}
/**
- * Reporting a fault
+ * Reporting a fault for any component when a response for a request is received.
+ * Any component means that this statistics log (check point) is valid for sequence, endpoint,
+ * and proxy.
*
* @param synCtx synCtx Current Message through synapse
* @param errorLog the received error information
@@ -81,9 +116,11 @@ public class StatisticsReporter {
StatisticsRecord statisticsRecord =
(StatisticsRecord) synCtx.getProperty(SynapseConstants.STATISTICS_STACK);
if (statisticsRecord != null) {
+
if (log.isDebugEnabled()) {
log.debug("Reporting a fault : " + statisticsRecord);
}
+
StatisticsLog statisticsLog = new StatisticsLog(SynapseConstants.SYNAPSE_ASPECTS,
ComponentType.ANY);
statisticsLog.setResponse(synCtx.isResponse() || synCtx.isFaultResponse());
@@ -94,99 +131,52 @@ public class StatisticsReporter {
}
/**
- * Reports statistics on the response message Sent
+ * Reports statistics for any component on the response message is sent
+ * Any component means that this statistics log (check point) is valid for sequence, endpoint,
+ * and proxy.
*
- * @param synCtx MessageContext instance
- * @param endpoint EndpointDefinition instance
- */
- public static void reportForAllOnResponseSent(MessageContext synCtx,
- EndpointDefinition endpoint) {
- if (endpoint != null) {
- if (synCtx.getProperty(SynapseConstants.OUT_ONLY) != null) {
- endReportForAll(synCtx, endpoint.isStatisticsEnable());
- }
- } else {
- endReportForAll(synCtx, false);
- }
- }
-
- /**
- * Ends statistics reporting for any component
- *
- * @param synCtx MessageContext instance
- * @param isStatisticsEnable is stat enable
- */
- private static void endReportForAll(MessageContext synCtx, boolean isStatisticsEnable) {
- StatisticsRecord statisticsRecord =
- (StatisticsRecord) synCtx.getProperty(SynapseConstants.STATISTICS_STACK);
- if (isStatisticsEnable || statisticsRecord != null) {
- if (!statisticsRecord.isEndReported()) {
- StatisticsLog statisticsLog = new StatisticsLog(SynapseConstants.SYNAPSE_ASPECTS,
- ComponentType.ANY);
- statisticsLog.setResponse(synCtx.isResponse() || synCtx.isFaultResponse());
- if (isFault(synCtx)) {
- statisticsLog.setFault(true);
- statisticsLog.setErrorLog(ErrorLogFactory.createErrorLog(synCtx));
- }
- statisticsLog.setEndAnyLog(true);
- statisticsRecord.collect(statisticsLog);
- statisticsRecord.setEndReported(true);
- addStatistics(synCtx, statisticsRecord);
- }
- }
- }
-
- /**
- * Ends statistics reporting after request processed
- *
- * @param synCtx MessageContext instance
- * @param aspectConfiguration main component's aspect conf
+ * @param synCtx MessageContext instance
*/
- public static void endReportForAllOnRequestProcessed(MessageContext synCtx,
- AspectConfiguration aspectConfiguration) {
-
- boolean isOutOnly = Boolean.parseBoolean(
- String.valueOf(synCtx.getProperty(SynapseConstants.OUT_ONLY)));
- if (!isOutOnly) {
- isOutOnly = (!Boolean.parseBoolean(
- String.valueOf(synCtx.getProperty(SynapseConstants.SENDING_REQUEST)))
- && !synCtx.isResponse());
- }
- if (isOutOnly) {
- endReportForAll(synCtx,
- (aspectConfiguration != null && aspectConfiguration.isStatisticsEnable()));
- }
+ public static void reportForAllOnResponseSent(MessageContext synCtx) {
+ endReportForAll(synCtx);
}
/**
- * Gets a StatisticsRecord
+ * Ends statistics reporting for any component. Only at this point, the statistics record is put
+ * into the <code>StatisticsCollector </code>
+ * Any component means that this statistics log (check point) is valid for sequence, endpoint,
+ * and proxy.
*
* @param synCtx MessageContext instance
- * @return a StatisticsRecord
*/
- private static StatisticsRecord getStatisticsRecord(MessageContext synCtx) {
+ private static void endReportForAll(MessageContext synCtx) {
- StatisticsRecord statisticsRecord =
+ StatisticsRecord record =
(StatisticsRecord) synCtx.getProperty(SynapseConstants.STATISTICS_STACK);
- if (statisticsRecord == null) {
+ if (record == null) {
+ //There is no statistics record.
+ return;
+ }
+ if (record.isEndReported()) {
if (log.isDebugEnabled()) {
- log.debug("Setting statistics stack on the message context.");
+ log.debug("The statistics record has been already reported.");
}
- statisticsRecord = StatisticsRecordFactory.getStatisticsRecord(synCtx);
- synCtx.setProperty(SynapseConstants.STATISTICS_STACK, statisticsRecord);
+ return;
}
- return statisticsRecord;
- }
- /**
- * Collects statistics
- *
- * @param synCtx MessageContext instance
- * @param record StatisticsRecord instance
- */
- private static void addStatistics(MessageContext synCtx,
- StatisticsRecord record) {
+ StatisticsLog statisticsLog = new StatisticsLog(SynapseConstants.SYNAPSE_ASPECTS,
+ ComponentType.ANY);
+ statisticsLog.setResponse(synCtx.isResponse() || synCtx.isFaultResponse());
+
+ if (isFault(synCtx)) {
+ statisticsLog.setFault(true);
+ statisticsLog.setErrorLog(ErrorLogFactory.createErrorLog(synCtx));
+ }
+
+ statisticsLog.setEndAnyLog(true);
+ record.collect(statisticsLog);
+ record.setEndReported(true);
StatisticsCollector collector = synCtx.getEnvironment().getStatisticsCollector();
if (collector == null) {
@@ -197,14 +187,47 @@ public class StatisticsReporter {
collector = new StatisticsCollector();
synCtx.getEnvironment().setStatisticsCollector(collector);
}
+
synCtx.getPropertyKeySet().remove(SynapseConstants.STATISTICS_STACK);
+
if (!collector.contains(record)) {
collector.collect(record);
}
}
/**
- * Factory method to create a StatisticsLog
+ * Ends statistics reporting for any component after the request processed.
+ * Any component means that this statistics log (check point) is valid for sequence, endpoint,
+ * and proxy.
+ * Only if the message is out-only, the stats are reported
+ *
+ * @param synCtx MessageContext instance
+ */
+ public static void endReportForAllOnRequestProcessed(MessageContext synCtx) {
+
+ StatisticsRecord statisticsRecord =
+ (StatisticsRecord) synCtx.getProperty(SynapseConstants.STATISTICS_STACK);
+ if (statisticsRecord == null) {
+ //There is no statistics record.
+ return;
+ }
+
+ boolean isOutOnly = Boolean.parseBoolean(
+ String.valueOf(synCtx.getProperty(SynapseConstants.OUT_ONLY)));
+ if (!isOutOnly) {
+ isOutOnly = (!Boolean.parseBoolean(
+ String.valueOf(synCtx.getProperty(SynapseConstants.SENDING_REQUEST)))
+ && !synCtx.isResponse());
+ }
+
+ if (isOutOnly) {
+ endReportForAll(synCtx);
+ }
+ }
+
+
+ /**
+ * Factory method to create <code>StatisticsLog</code> instances
*
* @param identifiable component
* @param componentType component type
@@ -222,16 +245,19 @@ public class StatisticsReporter {
statisticsLog.setFault(true);
statisticsLog.setErrorLog(ErrorLogFactory.createErrorLog(synCtx));
}
+ if (log.isDebugEnabled()) {
+ log.debug("Created statistics log : " + statisticsLog);
+ }
return statisticsLog;
}
return null;
}
/**
- * Checks the validity of the component
+ * Checks the validity of a component
*
- * @param identifiable component as a
- * @return true if the component is valid
+ * @param identifiable component
+ * @return <code>true</code> if the component is valid
*/
private static boolean isValid(Identifiable identifiable) {
@@ -256,7 +282,7 @@ public class StatisticsReporter {
* Detects a fault
*
* @param context MessageContext context
- * @return true if this is a fault
+ * @return <code>true</code> if this is a fault
*/
private static boolean isFault(MessageContext context) {
boolean isFault = context.isFaultResponse();
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfigUtils.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfigUtils.java?rev=929198&r1=929197&r2=929198&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfigUtils.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfigUtils.java Tue Mar 30 17:37:41 2010
@@ -32,6 +32,7 @@ import org.apache.synapse.commons.securi
import org.apache.synapse.commons.security.definition.KeyStoreInformation;
import org.apache.synapse.commons.security.definition.TrustKeyStoreInformation;
import org.apache.synapse.commons.security.definition.factory.KeyStoreInformationFactory;
+import org.apache.synapse.config.xml.XMLConfigConstants;
import org.apache.synapse.core.SynapseEnvironment;
import org.apache.synapse.mediators.MediatorProperty;
import org.apache.synapse.mediators.base.SequenceMediator;
@@ -801,5 +802,33 @@ public class SynapseConfigUtils {
config.addSequence(org.apache.synapse.SynapseConstants.FAULT_SEQUENCE_KEY, fault);
}
+
+
+ /**
+ * Factory method to create the AspectConfiguration when there is no a defined main sequence and
+ * only there is a set of mediators. This is useful when collecting stats for messages going
+ * through the main sequence
+ * //TODO cache
+ * @param synCtx Message Context
+ * @return an AspectConfiguration instance
+ */
+ public static AspectConfiguration getGlobalAspectConfiguration(MessageContext synCtx) {
+
+ boolean statisticsEnable = false;
+
+ if (XMLConfigConstants.STATISTICS_ENABLE.equals(
+ synCtx.getConfiguration().getProperty(
+ SynapseConstants.SYNAPSE_STATISTICS_STATE))) {
+ statisticsEnable = true;
+ }
+
+ if (statisticsEnable) {
+ AspectConfiguration configuration = new AspectConfiguration(
+ SynapseConstants.SYNAPSE_ASPECTS);
+ configuration.enableStatistics();
+ return configuration;
+ }
+ return null;
+ }
}
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2Sender.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2Sender.java?rev=929198&r1=929197&r2=929198&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2Sender.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2Sender.java Tue Mar 30 17:37:41 2010
@@ -62,7 +62,7 @@ public class Axis2Sender {
if (synapseInMessageContext.isResponse()) {
// report stats for any component at response sending check point
- StatisticsReporter.reportForAllOnResponseSent(synapseInMessageContext, endpoint);
+ StatisticsReporter.reportForAllOnResponseSent(synapseInMessageContext);
}
} catch (Exception e) {
@@ -142,7 +142,7 @@ public class Axis2Sender {
Axis2FlexibleMEPClient.clearSecurtityProperties(messageContext.getOptions());
// report stats for any component at response sending check point
- StatisticsReporter.reportForAllOnResponseSent(smc, null);
+ StatisticsReporter.reportForAllOnResponseSent(smc);
AxisEngine.send(messageContext);
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java?rev=929198&r1=929197&r2=929198&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java Tue Mar 30 17:37:41 2010
@@ -185,8 +185,7 @@ public class ProxyServiceMessageReceiver
"message dropped", synCtx);
}
} finally {
- StatisticsReporter.endReportForAllOnRequestProcessed(synCtx,
- proxy.getAspectConfiguration());
+ StatisticsReporter.endReportForAllOnRequestProcessed(synCtx);
}
}
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseMessageReceiver.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseMessageReceiver.java?rev=929198&r1=929197&r2=929198&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseMessageReceiver.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseMessageReceiver.java Tue Mar 30 17:37:41 2010
@@ -27,9 +27,9 @@ import org.apache.synapse.FaultHandler;
import org.apache.synapse.MessageContext;
import org.apache.synapse.SynapseConstants;
import org.apache.synapse.SynapseException;
-import org.apache.synapse.aspects.AspectConfigurationDetectionStrategy;
import org.apache.synapse.aspects.ComponentType;
import org.apache.synapse.aspects.statistics.StatisticsReporter;
+import org.apache.synapse.config.SynapseConfigUtils;
import org.apache.synapse.mediators.MediatorFaultHandler;
/**
@@ -47,9 +47,9 @@ public class SynapseMessageReceiver impl
MessageContext synCtx = MessageContextCreatorForAxis2.getSynapseMessageContext(mc);
StatisticsReporter.reportForComponent(synCtx,
- AspectConfigurationDetectionStrategy.getAspectConfiguration(synCtx),
+ SynapseConfigUtils.getGlobalAspectConfiguration(synCtx),
ComponentType.PROXYSERVICE);
-
+
boolean traceOn = synCtx.getMainSequence().getTraceState() == SynapseConstants.TRACING_ON;
boolean traceOrDebugOn = traceOn || log.isDebugEnabled();
@@ -96,7 +96,7 @@ public class SynapseMessageReceiver impl
"message dropped", synCtx);
}
} finally {
- StatisticsReporter.endReportForAllOnRequestProcessed(synCtx, null);
+ StatisticsReporter.endReportForAllOnRequestProcessed(synCtx);
}
}