fixing diff

Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/4e7e7bb8
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/4e7e7bb8
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/4e7e7bb8

Branch: refs/heads/docker-grouping-merge
Commit: 4e7e7bb89e1605f5209b82120a43e9a6cf8d2999
Parents: e1cf308
Author: Asiri LIyana Arachchi <[email protected]>
Authored: Tue Nov 4 23:01:17 2014 +0530
Committer: Asiri LIyana Arachchi <[email protected]>
Committed: Tue Nov 4 23:01:17 2014 +0530

----------------------------------------------------------------------
 ...eRequestsServingCapabilityEventListener.java | 14 ++++++
 ...questsServingCapabilityMessageProcessor.java | 49 ++++++++++++++++++++
 .../AverageServedRequestsEventFormatter.xml     | 32 +++++++++++++
 ...equestHandlingCapabilityWindowProcessor.java | 49 ++++++++++++++++++++
 4 files changed, 144 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/4e7e7bb8/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 100644
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/4e7e7bb8/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 100644
index 0000000..724065e
--- /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.AverageRuestsServingCapabilityEvent;
+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 (AverageRuestsServingCapabilityEvent.class.getName().equals(type)) {
+
+            // Parse complete message and build event
+            AverageRuestsServingCapabilityEvent event = 
(AverageRuestsServingCapabilityEvent) Util.jsonToObject(message, 
AverageRuestsServingCapabilityEvent.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/4e7e7bb8/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 100644
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/4e7e7bb8/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 100644
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;
+    }
+}

Reply via email to