Search in sources :

Example 11 with AspectConfiguration

use of org.apache.synapse.aspects.AspectConfiguration in project wso2-synapse by wso2.

the class Resource method setComponentStatisticsId.

public void setComponentStatisticsId(ArtifactHolder holder) {
    StatisticIdentityGenerator.reportingBranchingEvents(holder);
    if (aspectConfiguration == null) {
        aspectConfiguration = new AspectConfiguration(name);
    }
    String resourceId = StatisticIdentityGenerator.getIdForComponent(getResourceClassName(), ComponentType.RESOURCE, holder);
    aspectConfiguration.setUniqueId(resourceId);
    String childId = null;
    if (inSequenceKey != null) {
        childId = StatisticIdentityGenerator.getIdReferencingComponent(inSequenceKey, ComponentType.SEQUENCE, holder);
        StatisticIdentityGenerator.reportingEndEvent(childId, ComponentType.SEQUENCE, holder);
    }
    if (inSequence != null) {
        inSequence.setComponentStatisticsId(holder);
    }
    if (outSequenceKey != null) {
        childId = StatisticIdentityGenerator.getIdReferencingComponent(outSequenceKey, ComponentType.SEQUENCE, holder);
        StatisticIdentityGenerator.reportingEndEvent(childId, ComponentType.SEQUENCE, holder);
    }
    if (outSequence != null) {
        outSequence.setComponentStatisticsId(holder);
    }
    if (faultSequenceKey != null) {
        childId = StatisticIdentityGenerator.getIdReferencingComponent(faultSequenceKey, ComponentType.SEQUENCE, holder);
        StatisticIdentityGenerator.reportingEndEvent(childId, ComponentType.SEQUENCE, holder);
    }
    if (faultSequence != null) {
        faultSequence.setComponentStatisticsId(holder);
    }
    StatisticIdentityGenerator.reportingEndEvent(resourceId, ComponentType.RESOURCE, holder);
}
Also used : AspectConfiguration(org.apache.synapse.aspects.AspectConfiguration)

Example 12 with AspectConfiguration

use of org.apache.synapse.aspects.AspectConfiguration in project wso2-synapse by wso2.

the class AbstractEndpoint method prepareForEndpointStatistics.

/**
 * Process statistics for this message
 * @param synCtx the current message
 */
protected void prepareForEndpointStatistics(MessageContext synCtx) {
    // Setting Required property to reportForComponent the End Point aspects
    if (definition != null && definition.isStatisticsEnable()) {
        String opName = null;
        if (synCtx.getProperty(SynapseConstants.ENDPOINT_OPERATION) != null) {
            opName = synCtx.getProperty(SynapseConstants.ENDPOINT_OPERATION).toString();
        } else if (synCtx instanceof Axis2MessageContext) {
            AxisOperation operation = ((Axis2MessageContext) synCtx).getAxis2MessageContext().getAxisOperation();
            if (operation != null) {
                opName = operation.getName().getLocalPart();
            }
            if (opName == null || SynapseConstants.SYNAPSE_OPERATION_NAME.getLocalPart().equals(opName)) {
                String soapAction = synCtx.getSoapAction();
                opName = null;
                if (soapAction != null) {
                    int index = soapAction.indexOf("urn:");
                    if (index >= 0) {
                        opName = soapAction.substring("urn:".length());
                    } else {
                        opName = soapAction;
                    }
                }
            }
        }
        AspectConfiguration oldConfiguration = definition.getAspectConfiguration();
        if (opName != null) {
            AspectConfiguration newConfiguration = new AspectConfiguration(oldConfiguration.getId() + SynapseConstants.STATISTICS_KEY_SEPARATOR + opName);
            if (oldConfiguration.isStatisticsEnable()) {
                newConfiguration.enableStatistics();
            }
            if (oldConfiguration.isTracingEnabled()) {
                newConfiguration.enableTracing();
            }
        }
    }
}
Also used : AxisOperation(org.apache.axis2.description.AxisOperation) AspectConfiguration(org.apache.synapse.aspects.AspectConfiguration) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext)

Example 13 with AspectConfiguration

use of org.apache.synapse.aspects.AspectConfiguration in project wso2-synapse by wso2.

the class AbstractEndpoint method setComponentStatisticsId.

public void setComponentStatisticsId(ArtifactHolder holder) {
    if (this instanceof IndirectEndpoint) {
        String sequenceId = StatisticIdentityGenerator.getIdReferencingComponent(((IndirectEndpoint) (this)).getKey(), ComponentType.ENDPOINT, holder);
        StatisticIdentityGenerator.reportingEndEvent(sequenceId, ComponentType.ENDPOINT, holder);
    } else {
        if (definition == null) {
            EndpointDefinition definition = new EndpointDefinition();
            this.setDefinition(definition);
        }
        if (definition.getAspectConfiguration() == null) {
            definition.configure(new AspectConfiguration(getReportingName()));
        }
        String sequenceId = StatisticIdentityGenerator.getIdForComponent(getReportingName(), ComponentType.ENDPOINT, holder);
        definition.getAspectConfiguration().setUniqueId(sequenceId);
        StatisticIdentityGenerator.reportingEndEvent(sequenceId, ComponentType.ENDPOINT, holder);
    }
}
Also used : AspectConfiguration(org.apache.synapse.aspects.AspectConfiguration)

Example 14 with AspectConfiguration

use of org.apache.synapse.aspects.AspectConfiguration in project wso2-synapse by wso2.

the class AbstractMediatorFactory method processAuditStatus.

/**
 * This is to Initialize the mediator regarding tracing and statistics.
 *
 * @param mediator of which trace state has to be set
 * @param mediatorOmElement from which the trace state is extracted
 *
 * @since 2.0
 */
protected void processAuditStatus(Mediator mediator, OMElement mediatorOmElement) {
    String name = null;
    if (mediator instanceof Nameable) {
        name = ((Nameable) mediator).getName();
    }
    if (name == null || "".equals(name)) {
        name = SynapseConstants.ANONYMOUS_SEQUENCE;
    }
    if (mediator instanceof AspectConfigurable) {
        AspectConfiguration configuration = new AspectConfiguration(name);
        ((AspectConfigurable) mediator).configure(configuration);
        OMAttribute statistics = mediatorOmElement.getAttribute(ATT_STATS);
        if (statistics != null) {
            String statisticsValue = statistics.getAttributeValue();
            if (statisticsValue != null) {
                if (XMLConfigConstants.STATISTICS_ENABLE.equals(statisticsValue)) {
                    configuration.enableStatistics();
                }
            }
        }
        OMAttribute trace = mediatorOmElement.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, XMLConfigConstants.TRACE_ATTRIB_NAME));
        if (trace != null) {
            String traceValue = trace.getAttributeValue();
            if (traceValue != null) {
                if (traceValue.equals(XMLConfigConstants.TRACE_ENABLE)) {
                    configuration.enableTracing();
                }
            }
        }
    }
}
Also used : Nameable(org.apache.synapse.Nameable) AspectConfigurable(org.apache.synapse.aspects.AspectConfigurable) QName(javax.xml.namespace.QName) AspectConfiguration(org.apache.synapse.aspects.AspectConfiguration) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 15 with AspectConfiguration

use of org.apache.synapse.aspects.AspectConfiguration in project wso2-synapse by wso2.

the class ThrottleMediator method setComponentStatisticsId.

@Override
public void setComponentStatisticsId(ArtifactHolder holder) {
    if (getAspectConfiguration() == null) {
        configure(new AspectConfiguration(getMediatorName()));
    }
    String mediatorId = StatisticIdentityGenerator.getIdForFlowContinuableMediator(getMediatorName(), ComponentType.MEDIATOR, holder);
    getAspectConfiguration().setUniqueId(mediatorId);
    String childId;
    if (onAcceptSeqKey != null) {
        childId = StatisticIdentityGenerator.getIdReferencingComponent(onAcceptSeqKey, ComponentType.SEQUENCE, holder);
        StatisticIdentityGenerator.reportingEndEvent(childId, ComponentType.SEQUENCE, holder);
    } else if (onAcceptMediator != null) {
        onAcceptMediator.setComponentStatisticsId(holder);
    }
    if (onRejectSeqKey != null) {
        childId = StatisticIdentityGenerator.getIdReferencingComponent(onRejectSeqKey, ComponentType.SEQUENCE, holder);
        StatisticIdentityGenerator.reportingEndEvent(childId, ComponentType.SEQUENCE, holder);
    } else if (onRejectMediator != null) {
        onRejectMediator.setComponentStatisticsId(holder);
    }
    StatisticIdentityGenerator.reportingFlowContinuableEndEvent(mediatorId, ComponentType.MEDIATOR, holder);
}
Also used : AspectConfiguration(org.apache.synapse.aspects.AspectConfiguration)

Aggregations

AspectConfiguration (org.apache.synapse.aspects.AspectConfiguration)30 QName (javax.xml.namespace.QName)5 OMAttribute (org.apache.axiom.om.OMAttribute)5 Iterator (java.util.Iterator)3 OMElement (org.apache.axiom.om.OMElement)3 SynapseException (org.apache.synapse.SynapseException)3 InboundEndpoint (org.apache.synapse.inbound.InboundEndpoint)3 SequenceMediator (org.apache.synapse.mediators.base.SequenceMediator)3 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)2 DropMediator (org.apache.synapse.mediators.builtin.DropMediator)2 LogMediator (org.apache.synapse.mediators.builtin.LogMediator)2 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 StringTokenizer (java.util.StringTokenizer)1 OMText (org.apache.axiom.om.OMText)1 OMTextImpl (org.apache.axiom.om.impl.llom.OMTextImpl)1 AxisOperation (org.apache.axis2.description.AxisOperation)1 Nameable (org.apache.synapse.Nameable)1 AspectConfigurable (org.apache.synapse.aspects.AspectConfigurable)1