clearing typos
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/31c69b39 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/31c69b39 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/31c69b39 Branch: refs/heads/docker-grouping-merge Commit: 31c69b39daacdd196b8d7741f5e1652e164bf96a Parents: 0c4fb18 Author: Asiri LIyana Arachchi <[email protected]> Authored: Tue Nov 4 23:35:43 2014 +0530 Committer: Asiri LIyana Arachchi <[email protected]> Committed: Tue Nov 4 23:35:43 2014 +0530 ---------------------------------------------------------------------- .../AverageRequestsServingCapabilityEvent.java | 31 +++++++++++++ ...eRequestsServingCapabilityEventListener.java | 14 ++++++ ...questsServingCapabilityMessageProcessor.java | 49 ++++++++++++++++++++ .../AverageServedRequestsEventFormatter.xml | 32 +++++++++++++ ...equestHandlingCapabilityWindowProcessor.java | 49 ++++++++++++++++++++ 5 files changed, 175 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/31c69b39/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/health/stat/AverageRequestsServingCapabilityEvent.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/health/stat/AverageRequestsServingCapabilityEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/health/stat/AverageRequestsServingCapabilityEvent.java new file mode 100755 index 0000000..011c75a --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/health/stat/AverageRequestsServingCapabilityEvent.java @@ -0,0 +1,31 @@ +package org.apache.stratos.messaging.event.health.stat; + +/** + * Created by asiri on 8/10/14. + */ +import org.apache.stratos.messaging.event.Event; +public class AverageRequestsServingCapabilityEvent extends Event{ + private final String networkPartitionId; + private final String clusterId; + private final float value; + + public AverageRequestsServingCapabilityEvent(String networkPartitionId, String clusterId, float value) { + this.networkPartitionId = networkPartitionId; + this.clusterId = clusterId; + this.value = value; + + } + public String getClusterId() { + return clusterId; + } + + public float getValue() { + return value; + } + + public String getNetworkPartitionId() { + return networkPartitionId; + } + + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/31c69b39/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/health/stat/AverageRequestsServingCapabilityEventListener.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/health/stat/AverageRequestsServingCapabilityEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/health/stat/AverageRequestsServingCapabilityEventListener.java new file mode 100755 index 0000000..3b79164 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/health/stat/AverageRequestsServingCapabilityEventListener.java @@ -0,0 +1,14 @@ +package org.apache.stratos.messaging.listener.health.stat; + +import org.apache.stratos.messaging.event.Event; +import org.apache.stratos.messaging.listener.EventListener; + +/** + * Created by asiri on 8/10/14. + */ +public class AverageRequestsServingCapabilityEventListener extends EventListener { + @Override + protected void onEvent(Event event) { + + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/31c69b39/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/health/stat/AverageRequestsServingCapabilityMessageProcessor.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/health/stat/AverageRequestsServingCapabilityMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/health/stat/AverageRequestsServingCapabilityMessageProcessor.java new file mode 100755 index 0000000..5d4f04e --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/health/stat/AverageRequestsServingCapabilityMessageProcessor.java @@ -0,0 +1,49 @@ +package org.apache.stratos.messaging.message.processor.health.stat; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.event.health.stat.AverageRequestsServingCapabilityEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; + +/** + * Created by asiri on 8/15/14. + */ +public class AverageRequestsServingCapabilityMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(AverageRequestsServingCapabilityMessageProcessor.class); + + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + if (AverageRequestsServingCapabilityEvent.class.getName().equals(type)) { + + // Parse complete message and build event + AverageRequestsServingCapabilityEvent event = (AverageRequestsServingCapabilityEvent) Util.jsonToObject(message, AverageRequestsServingCapabilityEvent.class); + + // Notify event listeners + notifyEventListeners(event); + + if(log.isDebugEnabled()){ + log.debug(String.format("%s event processor notified listeners ... " , type)); + } + return true; + } + else { + if(nextProcessor != null) { + return nextProcessor.process(type, message, object); + } + else { + throw new RuntimeException(String.format("Failed to process health stat message using available message processors: [type] %s [body] %s", type, message)); + } + } + } + + + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/31c69b39/extensions/cep/artifacts/eventformatters/AverageServedRequestsEventFormatter.xml ---------------------------------------------------------------------- diff --git a/extensions/cep/artifacts/eventformatters/AverageServedRequestsEventFormatter.xml b/extensions/cep/artifacts/eventformatters/AverageServedRequestsEventFormatter.xml new file mode 100755 index 0000000..5de0128 --- /dev/null +++ b/extensions/cep/artifacts/eventformatters/AverageServedRequestsEventFormatter.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you 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. + +--> + +<eventFormatter name="AverageServedRequestsEventFormatter" + statistics="disable" trace="enable" xmlns="http://wso2.org/carbon/eventformatter"> + <from streamName="average_served_request_count" version="1.0.0"/> + <mapping customMapping="enable" type="json"> + <inline>{"org.apache.stratos.messaging.event.health.stat.AverageRuestsServingCapabilityEvent":{"message":{"clusterId":"{{cluster_id}}","networkPartitionId":"{{network_partition_id}}","value":"{{average_served_count}}"}}}</inline> + </mapping> + <to eventAdaptorName="JMSOutputAdaptor" eventAdaptorType="jms"> + <property name="transport.jms.Destination">summarized-health-stats</property> + </to> +</eventFormatter> http://git-wip-us.apache.org/repos/asf/stratos/blob/31c69b39/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/MemeberRequestHandlingCapabilityWindowProcessor.java ---------------------------------------------------------------------- diff --git a/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/MemeberRequestHandlingCapabilityWindowProcessor.java b/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/MemeberRequestHandlingCapabilityWindowProcessor.java new file mode 100755 index 0000000..c2536a5 --- /dev/null +++ b/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/MemeberRequestHandlingCapabilityWindowProcessor.java @@ -0,0 +1,49 @@ +package org.apache.stratos.cep.extension; + +/** + * Created by asiri on 8/9/14. + */ + +import org.wso2.siddhi.core.config.SiddhiContext; +import org.wso2.siddhi.core.executor.function.FunctionExecutor; +import org.wso2.siddhi.query.api.definition.Attribute; +import org.wso2.siddhi.query.api.extension.annotation.SiddhiExtension; + +@SiddhiExtension(namespace = "stratos", function = "divider") +public class MemeberRequestHandlingCapabilityWindowProcessor extends FunctionExecutor { + + Attribute.Type returnType = Attribute.Type.DOUBLE; + + @Override + public void init(Attribute.Type[] types, SiddhiContext siddhiContext) { + } + + @Override + protected Object process(Object obj) { + + double[] value = new double[2]; + if (obj instanceof Object[]) { + int i=0; + for (Object aObj : (Object[]) obj) { + value[i]= Double.parseDouble(String.valueOf(aObj)); + i++; + } + }//to do avoid deviding zero number of active instances won't be zero cz there is min + Double unit = (value[0] / value[1]); + if(!unit.isNaN() && !unit.isInfinite()) + return unit; + else + return 0.0; + + } + + @Override + public void destroy() { + + } + + @Override + public Attribute.Type getReturnType() { + return returnType; + } +}
