You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eagle.apache.org by ha...@apache.org on 2016/10/19 03:27:17 UTC
[02/50] incubator-eagle git commit: [EAGLE-600] Make
AlertUnitTopologyApp compatible with both appId and topology.name
[EAGLE-600] Make AlertUnitTopologyApp compatible with both appId and topology.name
https://issues.apache.org/jira/browse/EAGLE-600
Make sure AlertUnitTopologyApp compatible with both "appId" and "topology.name"
Author: Hao Chen <ha...@apache.org>
Closes #484 from haoch/EAGLE-600.
Project: http://git-wip-us.apache.org/repos/asf/incubator-eagle/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-eagle/commit/d9b82b45
Tree: http://git-wip-us.apache.org/repos/asf/incubator-eagle/tree/d9b82b45
Diff: http://git-wip-us.apache.org/repos/asf/incubator-eagle/diff/d9b82b45
Branch: refs/heads/master
Commit: d9b82b45daa3adb678fff7138855bd07a241afb6
Parents: 0277ff7
Author: Hao Chen <ha...@apache.org>
Authored: Mon Oct 10 17:15:28 2016 +0800
Committer: Zhao, Qingwen <qi...@ebay.com>
Committed: Mon Oct 10 17:15:28 2016 +0800
----------------------------------------------------------------------
.../eagle/alert/app/AlertUnitTopologyApp.java | 3 +-
.../eagle/alert/engine/UnitTopologyMain.java | 21 +++++--
.../environment/impl/StormExecutionRuntime.java | 11 ++--
.../app/utils/ApplicationExecutionConfig.java | 66 ++++++++++++++++++++
eagle-server/pom.xml | 4 ++
5 files changed, 93 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/d9b82b45/eagle-core/eagle-alert-parent/eagle-alert-app/src/main/java/org/apache/eagle/alert/app/AlertUnitTopologyApp.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert-app/src/main/java/org/apache/eagle/alert/app/AlertUnitTopologyApp.java b/eagle-core/eagle-alert-parent/eagle-alert-app/src/main/java/org/apache/eagle/alert/app/AlertUnitTopologyApp.java
index 63e92ff..a122c08 100644
--- a/eagle-core/eagle-alert-parent/eagle-alert-app/src/main/java/org/apache/eagle/alert/app/AlertUnitTopologyApp.java
+++ b/eagle-core/eagle-alert-parent/eagle-alert-app/src/main/java/org/apache/eagle/alert/app/AlertUnitTopologyApp.java
@@ -34,8 +34,7 @@ public class AlertUnitTopologyApp extends StormApplication {
}
public static void main(String[] args) {
- Config config = ConfigFactory.load();
AlertUnitTopologyApp app = new AlertUnitTopologyApp();
- app.run(config);
+ app.run(args);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/d9b82b45/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/UnitTopologyMain.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/UnitTopologyMain.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/UnitTopologyMain.java
index 497d908..01b16b8 100644
--- a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/UnitTopologyMain.java
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/UnitTopologyMain.java
@@ -62,14 +62,14 @@ public class UnitTopologyMain {
Config config = ConfigFactory.load();
// load config and start
- String topologyId = config.getString("topology.name");
+ String topologyId = getTopologyName(config);
ZKMetadataChangeNotifyService changeNotifyService = createZKNotifyService(config, topologyId);
new UnitTopologyRunner(changeNotifyService).run(topologyId, config);
}
public static void runTopology(Config config, backtype.storm.Config stormConfig) {
// load config and start
- String topologyId = config.getString("topology.name");
+ String topologyId = getTopologyName(config);
ZKMetadataChangeNotifyService changeNotifyService = createZKNotifyService(config, topologyId);
new UnitTopologyRunner(changeNotifyService, stormConfig).run(topologyId, config);
}
@@ -81,9 +81,22 @@ public class UnitTopologyMain {
}
public static StormTopology createTopology(Config config) {
- String topologyId = config.getString("topology.name");
+ String topologyId = getTopologyName(config);
ZKMetadataChangeNotifyService changeNotifyService = createZKNotifyService(config, topologyId);
return new UnitTopologyRunner(changeNotifyService).buildTopology(topologyId, config);
}
-}
+
+ /**
+ * Try to get topology name from app framework .e.g "appId" or "topology.name"
+ */
+ private static String getTopologyName(Config config) {
+ if (config.hasPath("topology.name")) {
+ return config.getString("topology.name");
+ } else if (config.hasPath("appId")) {
+ return config.getString("appId");
+ } else {
+ throw new IllegalStateException("Not topology.name or appId provided from config: " + config.toString());
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/d9b82b45/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/StormExecutionRuntime.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/StormExecutionRuntime.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/StormExecutionRuntime.java
index 5f74d01..9821660 100644
--- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/StormExecutionRuntime.java
+++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/StormExecutionRuntime.java
@@ -16,17 +16,16 @@
*/
package org.apache.eagle.app.environment.impl;
-import backtype.storm.utils.Utils;
-import org.apache.eagle.app.Application;
-import org.apache.eagle.app.environment.ExecutionRuntime;
-import org.apache.eagle.app.environment.ExecutionRuntimeProvider;
-import org.apache.eagle.app.utils.DynamicJarPathFinder;
-import org.apache.eagle.metadata.model.ApplicationEntity;
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.generated.*;
import backtype.storm.utils.NimbusClient;
import com.google.common.base.Preconditions;
+import org.apache.eagle.app.Application;
+import org.apache.eagle.app.environment.ExecutionRuntime;
+import org.apache.eagle.app.environment.ExecutionRuntimeProvider;
+import org.apache.eagle.app.utils.DynamicJarPathFinder;
+import org.apache.eagle.metadata.model.ApplicationEntity;
import org.apache.thrift7.TException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/d9b82b45/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/ApplicationExecutionConfig.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/ApplicationExecutionConfig.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/ApplicationExecutionConfig.java
new file mode 100644
index 0000000..73199fe
--- /dev/null
+++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/ApplicationExecutionConfig.java
@@ -0,0 +1,66 @@
+/*
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.eagle.app.utils;
+
+import com.typesafe.config.Config;
+import org.apache.eagle.metadata.model.ApplicationEntity;
+
+/**
+ * Application Execution Must-have base configuration.
+ */
+public class ApplicationExecutionConfig {
+ public static final String APP_ID_KEY = "appId";
+ public static final String MODE_KEY = "mode";
+ public static final String SITE_ID_KEY = "siteId";
+ public static final String JAR_PATH_KEY = "jarPath";
+
+ private final String siteId;
+ private final String mode;
+ private final String appId;
+ private final String jarPath;
+
+ public ApplicationExecutionConfig(ApplicationEntity metadata) {
+ this.siteId = metadata.getSite().getSiteId();
+ this.mode = metadata.getMode().name();
+ this.appId = metadata.getAppId();
+ this.jarPath = metadata.getJarPath();
+ }
+
+ public ApplicationExecutionConfig(Config config) {
+ this.siteId = config.getString(SITE_ID_KEY);
+ this.mode = config.getString(MODE_KEY);
+ this.appId = config.getString(APP_ID_KEY);
+ this.jarPath = config.getString(JAR_PATH_KEY);
+ }
+
+ public String getJarPath() {
+ return jarPath;
+ }
+
+ public String getAppId() {
+ return appId;
+ }
+
+ public String getMode() {
+ return mode;
+ }
+
+ public String getSiteId() {
+ return siteId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/d9b82b45/eagle-server/pom.xml
----------------------------------------------------------------------
diff --git a/eagle-server/pom.xml b/eagle-server/pom.xml
index aa190e4..21bda30 100644
--- a/eagle-server/pom.xml
+++ b/eagle-server/pom.xml
@@ -96,6 +96,10 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>org.wso2.orbit.com.lmax</groupId>
+ <artifactId>disruptor</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>