Adding DAS Artifacts

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

Branch: refs/heads/master
Commit: 9ceab963b7c7fb5a5e85fc2f54c4d034348ce6e8
Parents: 218b5fd
Author: Thanuja <[email protected]>
Authored: Thu Jul 23 17:27:35 2015 +0530
Committer: Thanuja <[email protected]>
Committed: Thu Jul 23 17:27:35 2015 +0530

----------------------------------------------------------------------
 extensions/das/artifacts/CCEventReceiver.xml    |  29 +++++
 extensions/das/artifacts/SparkQuery.txt         |  19 ++++
 ...g.apache.stratos.cloud.controller_1.0.0.json | 112 +++++++++++++++++++
 .../org_apache_stratos_cloud_controller.xml     |   1 +
 extensions/das/spark-time-udf/pom.xml           |  12 ++
 .../stratos/das/spark/udf/time/TimeUDF.java     |  49 ++++++++
 6 files changed, 222 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/9ceab963/extensions/das/artifacts/CCEventReceiver.xml
----------------------------------------------------------------------
diff --git a/extensions/das/artifacts/CCEventReceiver.xml 
b/extensions/das/artifacts/CCEventReceiver.xml
new file mode 100644
index 0000000..2d4a3c4
--- /dev/null
+++ b/extensions/das/artifacts/CCEventReceiver.xml
@@ -0,0 +1,29 @@
+<?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.
+
+-->
+<eventReceiver name="CCEventReceiver" statistics="disable"
+    trace="enable" xmlns="http://wso2.org/carbon/eventreceiver";>
+    <from eventAdapterType="wso2event">
+        <property name="events.duplicated.in.cluster">false</property>
+    </from>
+    <mapping customMapping="disable" type="wso2event"/>
+    <to streamName="org.apache.stratos.cloud.controller" version="1.0.0"/>
+</eventReceiver>

http://git-wip-us.apache.org/repos/asf/stratos/blob/9ceab963/extensions/das/artifacts/SparkQuery.txt
----------------------------------------------------------------------
diff --git a/extensions/das/artifacts/SparkQuery.txt 
b/extensions/das/artifacts/SparkQuery.txt
new file mode 100644
index 0000000..39f7d47
--- /dev/null
+++ b/extensions/das/artifacts/SparkQuery.txt
@@ -0,0 +1,19 @@
+CREATE TEMPORARY TABLE memberstatus
+USING CarbonAnalytics 
+OPTIONS (tableName "ORG_APACHE_STRATOS_CLOUD_CONTROLLER");
+
+CREATE TEMPORARY TABLE memberstatusnew
+USING CarbonAnalytics 
+OPTIONS (tableName "CLUSTER_MEMBER_NEW", 
+         schema "startTime String, endTime String, clusterId STRING, 
activatedInstanceCount INT, terminatedInstanceCount INT, activeInstanceCount 
INT");
+
+         
+;WITH InstanceCount as 
+(select clusterId, count(case when status='Active' and timeStamp > 
current_time(null)-60000 and timeStamp <= current_time(null) then 1 else NULL 
end) as activatedInstanceCount, count(case when status='Terminated' and 
timeStamp > current_time(null)-60000 and timeStamp <= current_time(null) then 1 
else NULL end) as terminatedInstanceCount, (sum(case when status='Active' then 
1 else 0 end) - sum(case when status='Terminated' then 1 else 0 end))as 
activeInstanceCount from memberstatus group by clusterId)
+INSERT INTO table memberstatusnew select 
time(current_time(null)-60000),time(current_time(null)),clusterId, 
activatedInstanceCount, terminatedInstanceCount,activeInstanceCount from 
InstanceCount;  
+
+CREATE TEMPORARY TABLE membersnew
+USING CarbonAnalytics 
+OPTIONS (tableName "MEMBER_NEW",schema "clusterId STRING, clusterInstanceId 
STRING, partitionId STRING, networkId STRING, cartridgeType STRING, 
instanceType STRING, memberId STRING, scalingTime LONG,scalingReason STRING, 
timeStamp LONG");
+
+INSERT INTO TABLE membersnew select clusterId, 
clusterInstanceId,partitionId,networkId,cartridgeType,instanceType, memberId, 
time(scalingTime),scalingReason,time(timeStamp) FROM memberstatus where 
status='Created';

http://git-wip-us.apache.org/repos/asf/stratos/blob/9ceab963/extensions/das/artifacts/org.apache.stratos.cloud.controller_1.0.0.json
----------------------------------------------------------------------
diff --git 
a/extensions/das/artifacts/org.apache.stratos.cloud.controller_1.0.0.json 
b/extensions/das/artifacts/org.apache.stratos.cloud.controller_1.0.0.json
new file mode 100644
index 0000000..c0bc66b
--- /dev/null
+++ b/extensions/das/artifacts/org.apache.stratos.cloud.controller_1.0.0.json
@@ -0,0 +1,112 @@
+{
+  "name": "org.apache.stratos.cloud.controller",
+  "version": "1.0.0",
+  "nickName": "cloud.controller",
+  "description": "Instances booted up by the Cloud Controller",
+  "payloadData": [
+    {
+      "name": "timeStamp",
+      "type": "LONG"
+    },
+    {
+      "name": "memberId",
+      "type": "STRING"
+    },
+    {
+      "name": "cartridgeType",
+      "type": "STRING"
+    },
+    {
+      "name": "clusterId",
+      "type": "STRING"
+    },
+    {
+      "name": "clusterInstanceId",
+      "type": "STRING"
+    },
+    {
+      "name": "lbclusterId",
+      "type": "STRING"
+    },
+    {
+      "name": "partitionId",
+      "type": "STRING"
+    },
+    {
+      "name": "networkId",
+      "type": "STRING"
+    },
+    {
+      "name": "instanceType",
+      "type": "STRING"
+    },
+    {
+      "name": "scalingReason",
+      "type": "STRING"
+    },
+    {
+      "name": "scalingTime",
+      "type": "LONG"
+    },
+    {
+      "name": "isMultiTenant",
+      "type": "STRING"
+    },
+    {
+      "name": "iaas",
+      "type": "STRING"
+    },
+    {
+      "name": "status",
+      "type": "STRING"
+    },
+    {
+      "name": "hostName",
+      "type": "STRING"
+    },
+    {
+      "name": "hypervisor",
+      "type": "STRING"
+    },
+    {
+      "name": "ram",
+      "type": "STRING"
+    },
+    {
+      "name": "imageId",
+      "type": "STRING"
+    },
+    {
+      "name": "loginPort",
+      "type": "INT"
+    },
+    {
+      "name": "osName",
+      "type": "STRING"
+    },
+    {
+      "name": "osVersion",
+      "type": "STRING"
+    },
+    {
+      "name": "osArch",
+      "type": "STRING"
+    },
+    {
+      "name": "is64bitOS",
+      "type": "STRING"
+    },
+    {
+      "name": "privateIPAddresses",
+      "type": "STRING"
+    },
+    {
+      "name": "publicIPAddresses",
+      "type": "STRING"
+    },
+    {
+      "name": "allocateIPAddresses",
+      "type": "STRING"
+    }
+  ]
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/9ceab963/extensions/das/artifacts/org_apache_stratos_cloud_controller.xml
----------------------------------------------------------------------
diff --git a/extensions/das/artifacts/org_apache_stratos_cloud_controller.xml 
b/extensions/das/artifacts/org_apache_stratos_cloud_controller.xml
new file mode 100644
index 0000000..ee99acd
--- /dev/null
+++ b/extensions/das/artifacts/org_apache_stratos_cloud_controller.xml
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8" 
standalone="yes"?><EventStoreConfiguration><TableSchema><ColumnDefinition><Name>timeStamp</Name><EnableIndexing>false</EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScoreParam>false</EnableScoreParam><Type>LONG</Type></ColumnDefinition><ColumnDefinition><Name>memberId</Name><EnableIndexing>false</EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScoreParam>false</EnableScoreParam><Type>STRING</Type></ColumnDefinition><ColumnDefinition><Name>cartridgeType</Name><EnableIndexing>false</EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScoreParam>false</EnableScoreParam><Type>STRING</Type></ColumnDefinition><ColumnDefinition><Name>clusterId</Name><EnableIndexing>false</EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScoreParam>false</EnableScoreParam><Type>STRING</Type></ColumnDefinition><ColumnDefinition><Name>clusterInstanceId</Name><EnableIndexing>false</EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScorePar
 
am>false</EnableScoreParam><Type>STRING</Type></ColumnDefinition><ColumnDefinition><Name>lbclusterId</Name><EnableIndexing>false</EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScoreParam>false</EnableScoreParam><Type>STRING</Type></ColumnDefinition><ColumnDefinition><Name>partitionId</Name><EnableIndexing>false</EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScoreParam>false</EnableScoreParam><Type>STRING</Type></ColumnDefinition><ColumnDefinition><Name>networkId</Name><EnableIndexing>false</EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScoreParam>false</EnableScoreParam><Type>STRING</Type></ColumnDefinition><ColumnDefinition><Name>instanceType</Name><EnableIndexing>false</EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScoreParam>false</EnableScoreParam><Type>STRING</Type></ColumnDefinition><ColumnDefinition><Name>scalingReason</Name><EnableIndexing>false</EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScoreParam>false</EnableScoreParam
 ><Type>STRING</Type></ColumnDefinition><ColumnDefinition><Name>scalingTime</Name><EnableIndexing>false</EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScoreParam>false</EnableScoreParam><Type>LONG</Type></ColumnDefinition><ColumnDefinition><Name>isMultiTenant</Name><EnableIndexing>false</EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScoreParam>false</EnableScoreParam><Type>STRING</Type></ColumnDefinition><ColumnDefinition><Name>iaas</Name><EnableIndexing>false</EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScoreParam>false</EnableScoreParam><Type>STRING</Type></ColumnDefinition><ColumnDefinition><Name>status</Name><EnableIndexing>false</EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScoreParam>false</EnableScoreParam><Type>STRING</Type></ColumnDefinition><ColumnDefinition><Name>hostName</Name><EnableIndexing>false</EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScoreParam>false</EnableScoreParam><Type>STRING</Type></ColumnDefinition><Co
 
lumnDefinition><Name>hypervisor</Name><EnableIndexing>false</EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScoreParam>false</EnableScoreParam><Type>STRING</Type></ColumnDefinition><ColumnDefinition><Name>ram</Name><EnableIndexing>false</EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScoreParam>false</EnableScoreParam><Type>STRING</Type></ColumnDefinition><ColumnDefinition><Name>imageId</Name><EnableIndexing>false</EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScoreParam>false</EnableScoreParam><Type>STRING</Type></ColumnDefinition><ColumnDefinition><Name>loginPort</Name><EnableIndexing>false</EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScoreParam>false</EnableScoreParam><Type>INTEGER</Type></ColumnDefinition><ColumnDefinition><Name>osName</Name><EnableIndexing>false</EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScoreParam>false</EnableScoreParam><Type>STRING</Type></ColumnDefinition><ColumnDefinition><Name>osVersion</Name><EnableIn
 
dexing>false</EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScoreParam>false</EnableScoreParam><Type>STRING</Type></ColumnDefinition><ColumnDefinition><Name>osArch</Name><EnableIndexing>false</EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScoreParam>false</EnableScoreParam><Type>STRING</Type></ColumnDefinition><ColumnDefinition><Name>is64bitOS</Name><EnableIndexing>false</EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScoreParam>false</EnableScoreParam><Type>STRING</Type></ColumnDefinition><ColumnDefinition><Name>privateIPAddresses</Name><EnableIndexing>false</EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScoreParam>false</EnableScoreParam><Type>STRING</Type></ColumnDefinition><ColumnDefinition><Name>publicIPAddresses</Name><EnableIndexing>false</EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScoreParam>false</EnableScoreParam><Type>STRING</Type></ColumnDefinition><ColumnDefinition><Name>allocateIPAddresses</Name><EnableIndexing>false<
 
/EnableIndexing><IsPrimaryKey>false</IsPrimaryKey><EnableScoreParam>false</EnableScoreParam><Type>STRING</Type></ColumnDefinition></TableSchema><Source><StreamId>org.apache.stratos.cloud.controller:1.0.0</StreamId></Source><RecordStoreName>EVENT_STORE</RecordStoreName></EventStoreConfiguration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/9ceab963/extensions/das/spark-time-udf/pom.xml
----------------------------------------------------------------------
diff --git a/extensions/das/spark-time-udf/pom.xml 
b/extensions/das/spark-time-udf/pom.xml
new file mode 100644
index 0000000..fd69c39
--- /dev/null
+++ b/extensions/das/spark-time-udf/pom.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.stratos</groupId>
+    <artifactId>stratos-extensions</artifactId>
+    <version>4.1.0</version>
+
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/9ceab963/extensions/das/spark-time-udf/src/main/java/org/apache/stratos/das/spark/udf/time/TimeUDF.java
----------------------------------------------------------------------
diff --git 
a/extensions/das/spark-time-udf/src/main/java/org/apache/stratos/das/spark/udf/time/TimeUDF.java
 
b/extensions/das/spark-time-udf/src/main/java/org/apache/stratos/das/spark/udf/time/TimeUDF.java
new file mode 100644
index 0000000..330c5b2
--- /dev/null
+++ 
b/extensions/das/spark-time-udf/src/main/java/org/apache/stratos/das/spark/udf/time/TimeUDF.java
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+package org.apache.stratos.das.spark.udf.time;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Implementing UDF for implementing spark sql query related to time.
+ */
+public class TimeUDF {
+    /**
+     * Convert time(ms) to DateFormat
+     *
+     * @param timeStamp time in ms
+     * @return date as String
+     */
+    public String time(Long timeStamp) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+        Date date = new Date(timeStamp.longValue());
+        return sdf.format(date);
+    }
+
+    /**
+     * Get the current time in ms
+     *
+     * @param param
+     * @return
+     */
+    public long current_time(int param) {
+        return System.currentTimeMillis();
+    }
+}

Reply via email to