eagle-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h..@apache.org
Subject incubator-eagle git commit: [EAGLE-398] Refine example application for developer to easily know how to create a new app
Date Wed, 27 Jul 2016 10:49:52 GMT
Repository: incubator-eagle
Updated Branches:
  refs/heads/develop c017fe4cd -> 8777936d2


[EAGLE-398] Refine example application for developer to easily know how to create a new app

https://issues.apache.org/jira/browse/EAGLE-398

Author: Hao Chen <hao@apache.org>

Closes #279 from haoch/fix-example-app.


Project: http://git-wip-us.apache.org/repos/asf/incubator-eagle/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-eagle/commit/8777936d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-eagle/tree/8777936d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-eagle/diff/8777936d

Branch: refs/heads/develop
Commit: 8777936d2edfd02ff55f3f7cd6a9caa78b8c74bd
Parents: c017fe4
Author: Hao Chen <hao@apache.org>
Authored: Wed Jul 27 18:49:38 2016 +0800
Committer: Hao Chen <hao@apache.org>
Committed: Wed Jul 27 18:49:38 2016 +0800

----------------------------------------------------------------------
 .../app/spi/AbstractApplicationProvider.java    |   2 +-
 .../app/example/ExampleApplicationProvider.java |  33 +-----
 .../example/ExampleApplicationProvider2.java    |  33 +++++-
 .../resources/ExampleApplicationMetadata.xml    | 109 -------------------
 .../META-INF/apps/example/metadata.xml          |   2 +-
 5 files changed, 35 insertions(+), 144 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/8777936d/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/spi/AbstractApplicationProvider.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/spi/AbstractApplicationProvider.java
b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/spi/AbstractApplicationProvider.java
index 37311eb..4cb4367 100644
--- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/spi/AbstractApplicationProvider.java
+++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/spi/AbstractApplicationProvider.java
@@ -47,7 +47,7 @@ public abstract class AbstractApplicationProvider<T extends Application>
impleme
     protected void configure (){
         // do nothing by default
     }
-
+Å
     protected AbstractApplicationProvider(String applicationDescConfig) {
         this();
         ApplicationProviderDescConfig descWrapperConfig = ApplicationProviderDescConfig.loadFromXML(applicationDescConfig);

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/8777936d/eagle-examples/eagle-app-example/src/main/java/org/apache/eagle/app/example/ExampleApplicationProvider.java
----------------------------------------------------------------------
diff --git a/eagle-examples/eagle-app-example/src/main/java/org/apache/eagle/app/example/ExampleApplicationProvider.java
b/eagle-examples/eagle-app-example/src/main/java/org/apache/eagle/app/example/ExampleApplicationProvider.java
index 5949853..0efc7e1 100644
--- a/eagle-examples/eagle-app-example/src/main/java/org/apache/eagle/app/example/ExampleApplicationProvider.java
+++ b/eagle-examples/eagle-app-example/src/main/java/org/apache/eagle/app/example/ExampleApplicationProvider.java
@@ -16,43 +16,14 @@
  */
 package org.apache.eagle.app.example;
 
-import org.apache.eagle.alert.engine.coordinator.StreamColumn;
-import org.apache.eagle.alert.engine.coordinator.StreamDefinition;
 import org.apache.eagle.app.spi.AbstractApplicationProvider;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
 /**
  * Define application provider programmatically
  */
 public class ExampleApplicationProvider extends AbstractApplicationProvider<ExampleApplication>
{
-    @Override
-    protected void configure() {
-        setType("EXAMPLE_APPLICATION");
-        setName("Example Monitoring Application");
-        setVersion("0.5.0-incubating");
-        setAppClass(ExampleApplication.class);
-        setViewPath("/apps/example");
-        setAppConfig("ExampleApplicationConf.xml");
-        setStreams(Arrays.asList(createSampleStreamDefinition("SAMPLE_STREAM_1"), createSampleStreamDefinition("SAMPLE_STREAM_2")));
-    }
-
-    private static StreamDefinition createSampleStreamDefinition(String streamId){
-        StreamDefinition sampleStreamDefinition = new StreamDefinition();
-        sampleStreamDefinition.setStreamId(streamId);
-        sampleStreamDefinition.setTimeseries(true);
-        sampleStreamDefinition.setValidate(true);
-        sampleStreamDefinition.setDescription("Auto generated sample Schema for "+streamId);
-        List<StreamColumn> streamColumns = new ArrayList<>();
-
-        streamColumns.add(new StreamColumn.Builder().name("metric").type(StreamColumn.Type.STRING).build());
-        streamColumns.add(new StreamColumn.Builder().name("source").type(StreamColumn.Type.STRING).build());
-        streamColumns.add(new StreamColumn.Builder().name("timestamp").type(StreamColumn.Type.LONG).build());
-        streamColumns.add(new StreamColumn.Builder().name("value").type(StreamColumn.Type.DOUBLE).build());
-        sampleStreamDefinition.setColumns(streamColumns);
-        return sampleStreamDefinition;
+    public ExampleApplicationProvider() {
+        super("/META-INF/apps/example/metadata.xml");
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/8777936d/eagle-examples/eagle-app-example/src/main/java/org/apache/eagle/app/example/ExampleApplicationProvider2.java
----------------------------------------------------------------------
diff --git a/eagle-examples/eagle-app-example/src/main/java/org/apache/eagle/app/example/ExampleApplicationProvider2.java
b/eagle-examples/eagle-app-example/src/main/java/org/apache/eagle/app/example/ExampleApplicationProvider2.java
index ca5a69b..b11aa37 100644
--- a/eagle-examples/eagle-app-example/src/main/java/org/apache/eagle/app/example/ExampleApplicationProvider2.java
+++ b/eagle-examples/eagle-app-example/src/main/java/org/apache/eagle/app/example/ExampleApplicationProvider2.java
@@ -16,14 +16,43 @@
  */
 package org.apache.eagle.app.example;
 
+import org.apache.eagle.alert.engine.coordinator.StreamColumn;
+import org.apache.eagle.alert.engine.coordinator.StreamDefinition;
 import org.apache.eagle.app.spi.AbstractApplicationProvider;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
 /**
  * Define application provider with metadata.xml
  */
 public class ExampleApplicationProvider2 extends AbstractApplicationProvider<ExampleApplication>
{
-    public ExampleApplicationProvider2() {
-        super("/META-INF/apps/example/metadata.xml");
+    @Override
+    protected void configure() {
+        setType("EXAMPLE_APPLICATION_2");
+        setName("Example Monitoring Application 2");
+        setVersion("0.5.0-incubating");
+        setAppClass(ExampleApplication.class);
+        setViewPath("/apps/example");
+        setAppConfig("ExampleApplicationConf.xml");
+        setStreams(Arrays.asList(createSampleStreamDefinition("SAMPLE_STREAM_1"), createSampleStreamDefinition("SAMPLE_STREAM_2")));
+    }
+
+    private static StreamDefinition createSampleStreamDefinition(String streamId){
+        StreamDefinition sampleStreamDefinition = new StreamDefinition();
+        sampleStreamDefinition.setStreamId(streamId);
+        sampleStreamDefinition.setTimeseries(true);
+        sampleStreamDefinition.setValidate(true);
+        sampleStreamDefinition.setDescription("Auto generated sample Schema for "+streamId);
+        List<StreamColumn> streamColumns = new ArrayList<>();
+
+        streamColumns.add(new StreamColumn.Builder().name("metric").type(StreamColumn.Type.STRING).build());
+        streamColumns.add(new StreamColumn.Builder().name("source").type(StreamColumn.Type.STRING).build());
+        streamColumns.add(new StreamColumn.Builder().name("timestamp").type(StreamColumn.Type.LONG).build());
+        streamColumns.add(new StreamColumn.Builder().name("value").type(StreamColumn.Type.DOUBLE).build());
+        sampleStreamDefinition.setColumns(streamColumns);
+        return sampleStreamDefinition;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/8777936d/eagle-examples/eagle-app-example/src/main/resources/ExampleApplicationMetadata.xml
----------------------------------------------------------------------
diff --git a/eagle-examples/eagle-app-example/src/main/resources/ExampleApplicationMetadata.xml
b/eagle-examples/eagle-app-example/src/main/resources/ExampleApplicationMetadata.xml
deleted file mode 100644
index 0e5536c..0000000
--- a/eagle-examples/eagle-app-example/src/main/resources/ExampleApplicationMetadata.xml
+++ /dev/null
@@ -1,109 +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.
-  -->
-
-<application>
-    <type>EXAMPLE_APPLICATION_2</type>
-    <name>Example Monitoring Application</name>
-    <version>0.5.0-incubating</version>
-    <appClass>org.apache.eagle.app.example.ExampleApplication</appClass>
-    <viewPath>/apps/example</viewPath>
-    <configuration>
-        <property>
-            <name>message</name>
-            <displayName>Message</displayName>
-            <value>Hello, example application!</value>
-            <description>Just an sample configuration property</description>
-        </property>
-    </configuration>
-    <streams>
-        <stream>
-            <streamId>SAMPLE_STREAM_1</streamId>
-            <description>Sample output stream #1</description>
-            <validate>true</validate>
-            <timeseries>true</timeseries>
-            <columns>
-                <column>
-                    <name>metric</name>
-                    <type>string</type>
-                </column>
-                <column>
-                    <name>source</name>
-                    <type>string</type>
-                </column>
-                <column>
-                    <name>value</name>
-                    <type>double</type>
-                    <defaultValue>0.0</defaultValue>
-                </column>
-            </columns>
-        </stream>
-        <stream>
-            <streamId>SAMPLE_STREAM_2</streamId>
-            <description>Sample output stream #2</description>
-            <validate>true</validate>
-            <timeseries>true</timeseries>
-            <columns>
-                <column>
-                    <name>metric</name>
-                    <type>string</type>
-                </column>
-                <column>
-                    <name>source</name>
-                    <type>string</type>
-                </column>
-                <column>
-                    <name>value</name>
-                    <type>double</type>
-                    <defaultValue>0.0</defaultValue>
-                </column>
-            </columns>
-        </stream>
-    </streams>
-    <docs>
-        <install>
-# Step 1: Create source kafka topic named "${site}_example_source_topic"
-
-./bin/kafka-topics.sh --create --topic example_source_topic --replication-factor 1 --replication
1
-
-# Step 2: Set up data collector to flow data into kafka topic in
-
-./bin/logstash -f log_collector.conf
-
-## `log_collector.conf` sample as following:
-
-input {
-
-}
-filter {
-
-}
-output{
-
-}
-
-# Step 3: start application
-
-# Step 4: monitor with featured portal or alert with policies
-        </install>
-        <uninstall>
-# Step 1: stop and uninstall application
-# Step 2: delete kafka topic named "${site}_example_source_topic"
-# Step 3: stop logstash
-        </uninstall>
-    </docs>
-</application>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/8777936d/eagle-examples/eagle-app-example/src/main/resources/META-INF/apps/example/metadata.xml
----------------------------------------------------------------------
diff --git a/eagle-examples/eagle-app-example/src/main/resources/META-INF/apps/example/metadata.xml
b/eagle-examples/eagle-app-example/src/main/resources/META-INF/apps/example/metadata.xml
index 0e5536c..b6a8569 100644
--- a/eagle-examples/eagle-app-example/src/main/resources/META-INF/apps/example/metadata.xml
+++ b/eagle-examples/eagle-app-example/src/main/resources/META-INF/apps/example/metadata.xml
@@ -17,7 +17,7 @@
   -->
 
 <application>
-    <type>EXAMPLE_APPLICATION_2</type>
+    <type>EXAMPLE_APPLICATION</type>
     <name>Example Monitoring Application</name>
     <version>0.5.0-incubating</version>
     <appClass>org.apache.eagle.app.example.ExampleApplication</appClass>


Mime
View raw message