Adding stratos-das-extension
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/d7ae1d35 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/d7ae1d35 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/d7ae1d35 Branch: refs/heads/master Commit: d7ae1d3566e5fa434920a5099d12eb1fb50d7a3a Parents: 19a021a Author: Thanuja <[email protected]> Authored: Thu Oct 22 12:06:26 2015 +0530 Committer: Akila Perera <[email protected]> Committed: Tue Nov 3 17:13:20 2015 +0530 ---------------------------------------------------------------------- .../das/modules/stratos-das-extension/README.md | 6 +++ .../das/modules/stratos-das-extension/pom.xml | 43 +++++++++++++++++ .../stratos-das-extension/spark-udfs/README.md | 8 ---- .../stratos-das-extension/spark-udfs/pom.xml | 41 ---------------- .../spark-udfs/spark-time-udf/pom.xml | 36 -------------- .../das/extension/spark/udf/TimeUDF.java | 49 -------------------- .../das/extension/spark/udf/TimeUDF.java | 49 ++++++++++++++++++++ extensions/das/pom.xml | 9 ++-- pom.xml | 5 ++ 9 files changed, 108 insertions(+), 138 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/d7ae1d35/extensions/das/modules/stratos-das-extension/README.md ---------------------------------------------------------------------- diff --git a/extensions/das/modules/stratos-das-extension/README.md b/extensions/das/modules/stratos-das-extension/README.md new file mode 100644 index 0000000..58bdd5b --- /dev/null +++ b/extensions/das/modules/stratos-das-extension/README.md @@ -0,0 +1,6 @@ +# Apache Stratos DAS Extension + +This directory contains DAS Extensions needed for Stratos. <br /> +1. Add org.apache.stratos.das.extension-<stratos-version>.jar file to '<DAS-HOME>/repository/components/lib/'. <br /> +2. Add below UDF class path to 'spark-udf-config.xml' file in '<DAS-HOME>/repository/conf/analytics/spark/' folder. <br /> + <class-name>org.apache.stratos.das.extension.TimeUDF</class-name> <br /> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/d7ae1d35/extensions/das/modules/stratos-das-extension/pom.xml ---------------------------------------------------------------------- diff --git a/extensions/das/modules/stratos-das-extension/pom.xml b/extensions/das/modules/stratos-das-extension/pom.xml new file mode 100644 index 0000000..e7d9053 --- /dev/null +++ b/extensions/das/modules/stratos-das-extension/pom.xml @@ -0,0 +1,43 @@ +<?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. + --> +<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"> + <parent> + <groupId>org.apache.stratos</groupId> + <artifactId>das-extension</artifactId> + <version>4.1.5-SNAPSHOT</version> + <relativePath>../../pom.xml</relativePath> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>org.apache.stratos.das.extension</artifactId> + <name>Apache Stratos - DAS Extension</name> + <description>Apache Stratos DAS Extension</description> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + </plugin> + </plugins> + </build> +</project> http://git-wip-us.apache.org/repos/asf/stratos/blob/d7ae1d35/extensions/das/modules/stratos-das-extension/spark-udfs/README.md ---------------------------------------------------------------------- diff --git a/extensions/das/modules/stratos-das-extension/spark-udfs/README.md b/extensions/das/modules/stratos-das-extension/spark-udfs/README.md deleted file mode 100644 index 0aad56b..0000000 --- a/extensions/das/modules/stratos-das-extension/spark-udfs/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Apache Stratos Metering Dashboard Spark UDFs (User Defined Functions) - -This directory contains Spark UDFs (user Defined Function) required for executing the spark queries with UDFs. -Follow the below steps to use UDF in spark environment: -1. Add the jar files of each spark-udfs to '<DAS-HOME>/repository/components/lib'. - Example: org.apache.stratos.das.extension.spark.time.udf-<stratos-version>.jar -2. Add each UDF class path to 'spark-udf-config.xml' file in '<DAS-HOME>/repository/conf/analytics/spark/' folder. - Example: <class-name>org.apache.stratos.das.extension.spark.udf.TimeUDF</class-name> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/d7ae1d35/extensions/das/modules/stratos-das-extension/spark-udfs/pom.xml ---------------------------------------------------------------------- diff --git a/extensions/das/modules/stratos-das-extension/spark-udfs/pom.xml b/extensions/das/modules/stratos-das-extension/spark-udfs/pom.xml deleted file mode 100644 index f4efde7..0000000 --- a/extensions/das/modules/stratos-das-extension/spark-udfs/pom.xml +++ /dev/null @@ -1,41 +0,0 @@ -<?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. - ---> -<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"> - <parent> - <artifactId>stratos-das-extension</artifactId> - <groupId>org.apache.stratos</groupId> - <version>4.1.5-SNAPSHOT</version> - <relativePath>../../../pom.xml</relativePath> - </parent> - <modelVersion>4.0.0</modelVersion> - - <artifactId>spark-udfs</artifactId> - <packaging>pom</packaging> - <name>Apache Stratos - DAS Extension Spark UDFs</name> - <description>Apache Stratos DAS Extension Spark UDFs</description> - <modules> - <module>spark-time-udf</module> - </modules> - -</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/d7ae1d35/extensions/das/modules/stratos-das-extension/spark-udfs/spark-time-udf/pom.xml ---------------------------------------------------------------------- diff --git a/extensions/das/modules/stratos-das-extension/spark-udfs/spark-time-udf/pom.xml b/extensions/das/modules/stratos-das-extension/spark-udfs/spark-time-udf/pom.xml deleted file mode 100644 index 3af090d..0000000 --- a/extensions/das/modules/stratos-das-extension/spark-udfs/spark-time-udf/pom.xml +++ /dev/null @@ -1,36 +0,0 @@ -<?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. - ---> -<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"> - <parent> - <artifactId>spark-udfs</artifactId> - <groupId>org.apache.stratos</groupId> - <version>4.1.5-SNAPSHOT</version> - </parent> - <modelVersion>4.0.0</modelVersion> - - <artifactId>org.apache.stratos.das.extension.spark.time.udf</artifactId> - <name>Apache Stratos - DAS Extension Spark Time UDF</name> - <description>Apache Stratos DAS Extension Spark Time UDF</description> - -</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/d7ae1d35/extensions/das/modules/stratos-das-extension/spark-udfs/spark-time-udf/src/main/java/org/apache/stratos/das/extension/spark/udf/TimeUDF.java ---------------------------------------------------------------------- diff --git a/extensions/das/modules/stratos-das-extension/spark-udfs/spark-time-udf/src/main/java/org/apache/stratos/das/extension/spark/udf/TimeUDF.java b/extensions/das/modules/stratos-das-extension/spark-udfs/spark-time-udf/src/main/java/org/apache/stratos/das/extension/spark/udf/TimeUDF.java deleted file mode 100644 index 0b8f408..0000000 --- a/extensions/das/modules/stratos-das-extension/spark-udfs/spark-time-udf/src/main/java/org/apache/stratos/das/extension/spark/udf/TimeUDF.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.extension.spark.udf; - -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(Integer param) { - return System.currentTimeMillis(); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/d7ae1d35/extensions/das/modules/stratos-das-extension/src/main/java/org/apache/stratos/das/extension/spark/udf/TimeUDF.java ---------------------------------------------------------------------- diff --git a/extensions/das/modules/stratos-das-extension/src/main/java/org/apache/stratos/das/extension/spark/udf/TimeUDF.java b/extensions/das/modules/stratos-das-extension/src/main/java/org/apache/stratos/das/extension/spark/udf/TimeUDF.java new file mode 100644 index 0000000..0b8f408 --- /dev/null +++ b/extensions/das/modules/stratos-das-extension/src/main/java/org/apache/stratos/das/extension/spark/udf/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.extension.spark.udf; + +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(Integer param) { + return System.currentTimeMillis(); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/d7ae1d35/extensions/das/pom.xml ---------------------------------------------------------------------- diff --git a/extensions/das/pom.xml b/extensions/das/pom.xml index e8ad467..13f9a22 100644 --- a/extensions/das/pom.xml +++ b/extensions/das/pom.xml @@ -21,20 +21,21 @@ 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"> <parent> - <artifactId>stratos-extensions</artifactId> <groupId>org.apache.stratos</groupId> + <artifactId>stratos-extensions</artifactId> <version>4.1.5-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> - <artifactId>stratos-das-extension</artifactId> + <artifactId>das-extension</artifactId> <packaging>pom</packaging> <name>Apache Stratos - DAS Extension</name> - <description>Apache Stratos DAS extension.</description> + <description>Apache Stratos DAS extension</description> <modules> <module>modules/artifacts/metering-dashboard/capps</module> + <module>modules/artifacts/monitoring-dashboard/capps</module> + <module>modules/stratos-das-extension</module> <module>modules/distribution</module> - <module>modules/stratos-das-extension/spark-udfs</module> </modules> http://git-wip-us.apache.org/repos/asf/stratos/blob/d7ae1d35/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index dfc0547..1d0dae1 100644 --- a/pom.xml +++ b/pom.xml @@ -315,6 +315,11 @@ <artifactId>commons-exec</artifactId> <version>${commons.exec.version}</version> </dependency> + <dependency> + <groupId>org.apache.stratos</groupId> + <artifactId>org.apache.stratos.das.extension</artifactId> + <version>${project.version}</version> + </dependency> <!-- Automation framework dependencies --> <dependency>
