You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eagle.apache.org by qi...@apache.org on 2016/04/25 06:01:59 UTC
[5/5] incubator-eagle git commit: EAGLE-271 Topology management in
remote/local mode including start/stop operations
EAGLE-271 Topology management in remote/local mode including start/stop operations
https://issues.apache.org/jira/browse/EAGLE-272
https://issues.apache.org/jira/browse/EAGLE-271
https://issues.apache.org/jira/browse/EAGLE-238
Author: Qingwen Zhao, Jilin Jiang
Reviewer: Ralph Su
Closes #160
Project: http://git-wip-us.apache.org/repos/asf/incubator-eagle/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-eagle/commit/ecf75b28
Tree: http://git-wip-us.apache.org/repos/asf/incubator-eagle/tree/ecf75b28
Diff: http://git-wip-us.apache.org/repos/asf/incubator-eagle/diff/ecf75b28
Branch: refs/heads/dev
Commit: ecf75b280ba63733b285ee18925f0489f69601f0
Parents: 99b2575
Author: Zhao, Qingwen <qi...@ebay.com>
Authored: Mon Apr 25 11:57:47 2016 +0800
Committer: Zhao, Qingwen <qi...@ebay.com>
Committed: Mon Apr 25 11:57:47 2016 +0800
----------------------------------------------------------------------
eagle-assembly/src/assembly/eagle-bin.xml | 6 +-
eagle-assembly/src/main/bin/eagle-service.sh | 7 +
.../src/main/bin/eagle-topology-init.sh | 7 +-
.../src/main/conf/eagle-scheduler.conf | 41 +++
eagle-assembly/src/main/conf/eagle-service.conf | 26 +-
.../sandbox-hbaseSecurityLog-application.conf | 2 +-
.../service/alert/SiteApplicationObject.java | 62 +++++
.../service/alert/SiteApplicationResource.java | 189 ++++++++++++++
.../alert/resolver/SiteApplicationObject.java | 62 -----
.../alert/resolver/SiteApplicationResource.java | 189 --------------
.../eagle-application-service/pom.xml | 56 ++++
.../application/AppManagerConstants.java | 42 +++
.../ApplicationManagementResource.java | 101 ++++++++
.../application/dao/ApplicationManagerDAO.java | 32 +++
.../dao/ApplicationManagerDaoImpl.java | 77 ++++++
.../entity/ApplicationEntityRepo.java | 30 +++
.../entity/TopologyDescriptionEntity.java | 104 ++++++++
.../entity/TopologyExecutionEntity.java | 132 ++++++++++
.../entity/TopologyExecutionStatus.java | 38 +++
.../entity/TopologyOperationEntity.java | 105 ++++++++
.../eagle-stream-application-manager/pom.xml | 144 +++++++++++
.../stream/application/TopologyException.java | 26 ++
.../stream/application/TopologyExecutable.java | 27 ++
.../stream/application/TopologyFactory.java | 55 ++++
.../AbstractDynamicApplication.scala | 32 +++
.../stream/application/ApplicationManager.scala | 126 +++++++++
.../application/ApplicationManagerUtils.scala | 38 +++
.../ApplicationSchedulerAsyncDAO.scala | 179 +++++++++++++
.../stream/application/ExecutionPlatform.scala | 30 +++
.../application/ExecutionPlatformFactory.scala | 49 ++++
.../eagle/stream/application/TaskExecutor.scala | 41 +++
.../application/impl/StormDynamicTopology.scala | 44 ++++
.../impl/StormExecutionPlatform.scala | 197 ++++++++++++++
.../scheduler/AppCommandExecutor.scala | 170 +++++++++++++
.../scheduler/AppCommandLoader.scala | 78 ++++++
.../scheduler/ApplicationScheduler.scala | 81 ++++++
.../scheduler/StreamAppCoordinator.scala | 54 ++++
.../src/test/resources/application.conf | 42 +++
.../src/test/resources/log4j.properties | 35 +++
.../application/scheduler/MockTopology.scala | 30 +++
.../scheduler/StormApplicationManagerSpec.scala | 40 +++
.../application/scheduler/TestScheduler.scala | 61 +++++
eagle-core/eagle-application-management/pom.xml | 40 +++
.../eagle/stream/pipeline/parser/Pipeline.scala | 6 +
.../storm/StormTopologyExecutorImpl.scala | 14 +-
.../apache/eagle/policy/common/Constants.java | 4 +
.../common/config/EagleConfigConstants.java | 3 +
.../eagle/storage/operation/CompiledQuery.java | 21 +-
.../criteria/impl/QueryCriteriaBuilder.java | 2 +-
.../schema/JdbcEntityDefinitionManager.java | 2 +-
eagle-core/pom.xml | 1 +
eagle-docs/images/appManager/admin-page.png | Bin 0 -> 208534 bytes
.../images/appManager/start-topology-1.png | Bin 0 -> 212648 bytes
.../images/appManager/start-topology-2.png | Bin 0 -> 235826 bytes
.../images/appManager/stop-topology-1.png | Bin 0 -> 238503 bytes
.../images/appManager/stop-topology-2.png | Bin 0 -> 238064 bytes
.../images/appManager/stop-topology-3.png | Bin 0 -> 236337 bytes
.../appManager/topology-configuration-1.png | Bin 0 -> 241252 bytes
.../appManager/topology-configuration-2.png | Bin 0 -> 288253 bytes
.../appManager/topology-configuration-save.png | Bin 0 -> 243119 bytes
.../images/appManager/topology-description.png | Bin 0 -> 218471 bytes
.../images/appManager/topology-execution.png | Bin 0 -> 219798 bytes
.../images/appManager/topology-monitor.png | Bin 0 -> 197752 bytes
.../tutorial/application_manager_tutorial.md | 109 ++++++++
.../tutorial/getting_started_with_eagle.md | 2 -
eagle-hadoop-metric/pom.xml | 5 +
.../HadoopJmxMetricMonitoringTopology.java | 37 +++
.../src/main/resources/hadoop-metric-init.sh | 2 +-
.../resolver/MetadataAccessConfigRepo.java | 15 +-
.../AbstractResourceSensitivityPollingJob.java | 2 +-
.../eagle/security/util/ExternalDataJoiner.java | 8 +-
.../audit/TestMetaDataAccessConfigRepo.java | 37 ++-
.../eagle-security-hbase-securitylog/pom.xml | 5 +
.../hbase/HbaseAuditLogMonitoringTopology.java | 42 +++
.../parse/HbaseAuditLogKafkaDeserializer.java | 29 +--
.../hbase/parse/HbaseAuditLogParser.java | 144 ++++-------
.../src/main/resources/log4j.properties | 21 ++
.../hbase/TestHbaseAuditLogProcessTopology.java | 44 ++++
.../src/test/resources/application.conf | 66 +++++
.../src/test/resources/log4j.properties | 35 +++
.../eagle-security-hdfs-auditlog/pom.xml | 5 +
.../HdfsAuditLogMonitoringTopology.java | 40 +++
.../timer/FileSensitivityPollingJob.java | 2 +-
.../auditlog/timer/IPZonePollingJob.java | 2 +-
eagle-security/eagle-security-hive/pom.xml | 7 +-
.../hive/HiveJobRunningMonitoringTopology.java | 48 ++++
...HiveJobRunningSourcedStormSpoutProvider.java | 9 +-
.../HiveResourceSensitivityPollingJob.java | 2 +-
eagle-topology-assembly/pom.xml | 4 +-
.../src/assembly/eagle-topology-assembly.xml | 4 +-
eagle-webservice/pom.xml | 19 +-
.../profile/ApplicationSchedulerListener.java | 59 +++++
.../profile/EagleServiceProfileInitializer.java | 3 +
.../src/main/resources/application-derby.conf | 30 +++
.../src/main/resources/application.conf | 24 +-
.../src/main/resources/eagle-scheduler.conf | 41 +++
.../src/main/webapp/WEB-INF/web.xml | 6 +
.../src/main/webapp/app/public/css/main.css | 8 +
.../app/public/feature/metrics/controller.js | 2 +-
.../app/public/feature/topology/controller.js | 255 +++++++++++++++++++
.../feature/topology/page/management.html | 52 ++++
.../feature/topology/page/monitoring.html | 151 +++++++++++
.../src/main/webapp/app/public/js/app.config.js | 12 +-
.../src/main/webapp/app/public/js/common.js | 49 +++-
.../public/js/ctrl/configurationController.js | 6 +-
.../webapp/app/public/js/srv/entitiesSrv.js | 30 +--
.../main/webapp/app/public/js/srv/siteSrv.js | 2 +-
.../src/main/webapp/app/public/js/srv/uiSrv.js | 24 +-
mkdocs.yml | 1 +
109 files changed, 4008 insertions(+), 472 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ecf75b28/eagle-assembly/src/assembly/eagle-bin.xml
----------------------------------------------------------------------
diff --git a/eagle-assembly/src/assembly/eagle-bin.xml b/eagle-assembly/src/assembly/eagle-bin.xml
index 336dcef..c4a8e10 100644
--- a/eagle-assembly/src/assembly/eagle-bin.xml
+++ b/eagle-assembly/src/assembly/eagle-bin.xml
@@ -172,9 +172,9 @@
<exclude>WEB-INF/classes/config.properties</exclude>
<exclude>WEB-INF/lib/servlet-api-*.jar</exclude>
<exclude>WEB-INF/lib/jsp-api-*.jar</exclude>
- <exclude>WEB-INF/lib/storm-*.jar</exclude>
- <exclude>WEB-INF/lib/kafka_*.jar</exclude>
- <exclude>WEB-INF/lib/kafka-*.jar</exclude>
+ <!--<exclude>WEB-INF/lib/storm-*.jar</exclude> -->
+ <!--<exclude>WEB-INF/lib/kafka_*.jar</exclude> -->
+ <exclude>WEB-INF/lib/slf4j-log4j12-*.jar</exclude>
<exclude>WEB-INF/lib/*-tests.jar</exclude>
<exclude>WEB-INF/lib/hadoop-mapreduce-*.jar</exclude>
<exclude>WEB-INF/lib/hadoop-minicluster-*.jar</exclude>
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ecf75b28/eagle-assembly/src/main/bin/eagle-service.sh
----------------------------------------------------------------------
diff --git a/eagle-assembly/src/main/bin/eagle-service.sh b/eagle-assembly/src/main/bin/eagle-service.sh
index d104f73..844a079 100755
--- a/eagle-assembly/src/main/bin/eagle-service.sh
+++ b/eagle-assembly/src/main/bin/eagle-service.sh
@@ -34,6 +34,7 @@ export CATALINA_LOGDIR=$EAGLE_HOME/logs
export CATALINA_TMPDIR=$EAGLE_HOME/temp
export CATALINA_OUT=$CATALINA_LOGDIR/eagle-service.out
export CATALINA_PID=$CATALINA_TMPDIR/service.pid
+export JAVA_OPTS="-Xmx3072m -XX:MaxPermSize=1024m"
# CLASSPATH
export CLASSPATH=$CLASSPATH:$EAGLE_HOME/conf
@@ -51,6 +52,7 @@ fi
EAGLE_SERVICE_CONF="eagle-service.conf"
EAGLE_LDAP_CONF="ldap.properties"
+EAGLE_SCHEDULER_CONF="eagle-scheduler.conf"
# Always copy conf/eagle-service.properties to lib/tomcat/webapps/eagle-service/WEB-INF/classes/application.conf before starting
if [ ! -e ${EAGLE_HOME}/conf/${EAGLE_SERVICE_CONF} ]
@@ -64,6 +66,11 @@ if [ -e ${EAGLE_HOME}/conf/${EAGLE_LDAP_CONF} ]
then
cp -f $EAGLE_HOME/conf/$EAGLE_LDAP_CONF ${EAGLE_HOME}/lib/tomcat/webapps/eagle-service/WEB-INF/classes/
fi
+if [ -e ${EAGLE_HOME}/conf/${EAGLE_SCHEDULER_CONF} ]
+then
+ cp -f $EAGLE_HOME/conf/$EAGLE_SCHEDULER_CONF ${EAGLE_HOME}/lib/tomcat/webapps/eagle-service/WEB-INF/classes/
+fi
+
case $1 in
"start")
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ecf75b28/eagle-assembly/src/main/bin/eagle-topology-init.sh
----------------------------------------------------------------------
diff --git a/eagle-assembly/src/main/bin/eagle-topology-init.sh b/eagle-assembly/src/main/bin/eagle-topology-init.sh
index 6fd7ac9..9d296fc 100755
--- a/eagle-assembly/src/main/bin/eagle-topology-init.sh
+++ b/eagle-assembly/src/main/bin/eagle-topology-init.sh
@@ -33,11 +33,12 @@ curl -silent -u ${EAGLE_SERVICE_USER}:${EAGLE_SERVICE_PASSWD} -X POST -H 'Conten
echo ""
echo "Importing applications for sample site ..."
-curl -silent -u ${EAGLE_SERVICE_USER}:${EAGLE_SERVICE_PASSWD} -X POST -H 'Content-Type:application/json' "http://${EAGLE_SERVICE_HOST}:${EAGLE_SERVICE_PORT}/eagle-service/rest/entities?serviceName=SiteApplicationService" -d '[{"prefix":"eagleSiteApplication","tags":{"site" : "sandbox", "application":"hdfsAuditLog"}, "enabled": true, "config" : "web.fs.defaultFS: \"hdfs://sandbox.hortonworks.com:8020\""}]'
-curl -silent -u ${EAGLE_SERVICE_USER}:${EAGLE_SERVICE_PASSWD} -X POST -H 'Content-Type:application/json' "http://${EAGLE_SERVICE_HOST}:${EAGLE_SERVICE_PORT}/eagle-service/rest/entities?serviceName=SiteApplicationService" -d '[{"prefix":"eagleSiteApplication","tags":{"site" : "sandbox", "application":"hbaseSecurityLog"}, "enabled": true, "config" : "web.hbase.zookeeper.property.clientPort: \"2181\", web.hbase.zookeeper.quorum: \"localhost\""}]'
+curl -silent -u ${EAGLE_SERVICE_USER}:${EAGLE_SERVICE_PASSWD} -X POST -H 'Content-Type:application/json' "http://${EAGLE_SERVICE_HOST}:${EAGLE_SERVICE_PORT}/eagle-service/rest/entities?serviceName=SiteApplicationService" -d '[{"prefix":"eagleSiteApplication","tags":{"site" : "sandbox", "application":"hdfsAuditLog"}, "enabled": true, "config" : "classification.fs.defaultFS=hdfs://sandbox.hortonworks.com:8020"}]'
-curl -silent -u ${EAGLE_SERVICE_USER}:${EAGLE_SERVICE_PASSWD} -X POST -H 'Content-Type:application/json' "http://${EAGLE_SERVICE_HOST}:${EAGLE_SERVICE_PORT}/eagle-service/rest/entities?serviceName=SiteApplicationService" -d '[{"prefix":"eagleSiteApplication","tags":{"site" : "sandbox", "application":"hiveQueryLog"}, "enabled": true, "config":"web.accessType:\"metastoredb_jdbc\",web.password:\"hive\",web.user:\"hive\",web.jdbcDriverClassName:\"com.mysql.jdbc.Driver\",web.jdbcUrl:\"jdbc:mysql://sandbox.hortonworks.com/hive?createDatabaseIfNotExist=true\""}]'
+curl -silent -u ${EAGLE_SERVICE_USER}:${EAGLE_SERVICE_PASSWD} -X POST -H 'Content-Type:application/json' "http://${EAGLE_SERVICE_HOST}:${EAGLE_SERVICE_PORT}/eagle-service/rest/entities?serviceName=SiteApplicationService" -d '[{"prefix":"eagleSiteApplication","tags":{"site" : "sandbox", "application":"hbaseSecurityLog"}, "enabled": true, "config" : "classification.hbase.zookeeper.property.clientPort=2181\nclassification.hbase.zookeeper.quorum=localhost"}]'
+
+curl -silent -u ${EAGLE_SERVICE_USER}:${EAGLE_SERVICE_PASSWD} -X POST -H 'Content-Type:application/json' "http://${EAGLE_SERVICE_HOST}:${EAGLE_SERVICE_PORT}/eagle-service/rest/entities?serviceName=SiteApplicationService" -d '[{"prefix":"eagleSiteApplication","tags":{"site" : "sandbox", "application":"hiveQueryLog"}, "enabled": true, "config":"classification.accessType=metastoredb_jdbc\nclassification.password=hive\nclassification.user=hive\nclassification.jdbcDriverClassName=com.mysql.jdbc.Driver\nclassification.jdbcUrl=jdbc:mysql://sandbox.hortonworks.com/hive?createDatabaseIfNotExist=true"}]'
echo ""
echo "Importing application definitions ..."
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ecf75b28/eagle-assembly/src/main/conf/eagle-scheduler.conf
----------------------------------------------------------------------
diff --git a/eagle-assembly/src/main/conf/eagle-scheduler.conf b/eagle-assembly/src/main/conf/eagle-scheduler.conf
new file mode 100644
index 0000000..aaab131
--- /dev/null
+++ b/eagle-assembly/src/main/conf/eagle-scheduler.conf
@@ -0,0 +1,41 @@
+# 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.
+
+
+### scheduler propertise
+appCommandLoaderIntervalSecs = 1
+appHealthCheckIntervalSecs = 5
+
+### execution platform properties
+envContextConfig.env = "storm"
+envContextConfig.url = "http://sandbox.hortonworks.com:8744"
+envContextConfig.nimbusHost = "sandbox.hortonworks.com"
+envContextConfig.nimbusThriftPort = 6627
+envContextConfig.jarFile = "/dir-to-jar/eagle-topology-0.3.0-incubating-assembly.jar"
+
+### default topology properties
+eagleProps.mailHost = "mailHost.com"
+eagleProps.mailSmtpPort = "25"
+eagleProps.mailDebug = "true"
+eagleProps.eagleService.host = "localhost"
+eagleProps.eagleService.port = 9099
+eagleProps.eagleService.username = "admin"
+eagleProps.eagleService.password = "secret"
+eagleProps.dataJoinPollIntervalSec = 30
+
+dynamicConfigSource.enabled = true
+dynamicConfigSource.initDelayMillis = 0
+dynamicConfigSource.delayMillis = 30000
+
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ecf75b28/eagle-assembly/src/main/conf/eagle-service.conf
----------------------------------------------------------------------
diff --git a/eagle-assembly/src/main/conf/eagle-service.conf b/eagle-assembly/src/main/conf/eagle-service.conf
index 59e970f..49e40ee 100644
--- a/eagle-assembly/src/main/conf/eagle-service.conf
+++ b/eagle-assembly/src/main/conf/eagle-service.conf
@@ -13,16 +13,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-eagle {
- service {
- storage-type="jdbc"
- storage-adapter="derby"
- storage-username="eagle"
- storage-password=eagle
- storage-database=eagle
- storage-connection-url="jdbc:derby:/tmp/eagle-db-local;create=true"
- storage-connection-props="encoding=UTF-8"
- storage-driver-class="org.apache.derby.jdbc.EmbeddedDriver"
- storage-connection-max=8
+
+eagle{
+ service{
+ storage-type="hbase"
+ hbase-zookeeper-quorum="sandbox.hortonworks.com"
+ hbase-zookeeper-property-clientPort=2181
+ zookeeper-znode-parent="/hbase-unsecure",
+ springActiveProfile="sandbox"
+ audit-enabled=true
}
-}
\ No newline at end of file
+}
+
+
+
+
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ecf75b28/eagle-assembly/src/main/conf/sandbox-hbaseSecurityLog-application.conf
----------------------------------------------------------------------
diff --git a/eagle-assembly/src/main/conf/sandbox-hbaseSecurityLog-application.conf b/eagle-assembly/src/main/conf/sandbox-hbaseSecurityLog-application.conf
index 58468ea..875bb0b 100644
--- a/eagle-assembly/src/main/conf/sandbox-hbaseSecurityLog-application.conf
+++ b/eagle-assembly/src/main/conf/sandbox-hbaseSecurityLog-application.conf
@@ -28,7 +28,7 @@
"topic" : "sandbox_hbase_security_log",
"zkConnection" : "127.0.0.1:2181",
"zkConnectionTimeoutMS" : 15000,
- "consumerGroupId" : "EagleConsumer",
+ "brokerZkPath" : "/brokers",
"fetchSize" : 1048586,
"deserializerClass" : "org.apache.eagle.security.hbase.parse.HbaseAuditLogKafkaDeserializer",
"transactionZKServers" : "127.0.0.1",
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ecf75b28/eagle-core/eagle-alert/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/SiteApplicationObject.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/SiteApplicationObject.java b/eagle-core/eagle-alert/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/SiteApplicationObject.java
new file mode 100644
index 0000000..41ece1d
--- /dev/null
+++ b/eagle-core/eagle-alert/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/SiteApplicationObject.java
@@ -0,0 +1,62 @@
+/*
+ * 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.eagle.service.alert;
+
+
+import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
+import org.apache.eagle.alert.entity.SiteApplicationServiceEntity;
+
+import java.util.List;
+import java.util.Map;
+
+public class SiteApplicationObject extends TaggedLogAPIEntity {
+
+ public Boolean getEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(Boolean enabled) {
+ this.enabled = enabled;
+ valueChanged("enabled");
+ }
+
+ public List<SiteApplicationServiceEntity> getApplications() {
+ return applications;
+ }
+
+ public void setApplications(List<SiteApplicationServiceEntity> applications) {
+ this.applications = applications;
+ valueChanged("applicationList");
+ }
+
+ @Override
+ public Map<String, String> getTags() {
+ return tags;
+ }
+
+ @Override
+ public void setTags(Map<String, String> tags) {
+ this.tags = tags;
+ valueChanged("tags");
+ }
+
+ Map<String, String> tags;
+ Boolean enabled;
+ List<SiteApplicationServiceEntity> applications;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ecf75b28/eagle-core/eagle-alert/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/SiteApplicationResource.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/SiteApplicationResource.java b/eagle-core/eagle-alert/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/SiteApplicationResource.java
new file mode 100644
index 0000000..e399189
--- /dev/null
+++ b/eagle-core/eagle-alert/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/SiteApplicationResource.java
@@ -0,0 +1,189 @@
+/*
+ * 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.eagle.service.alert;
+
+import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
+import org.apache.eagle.log.entity.GenericServiceAPIResponseEntity;
+import org.apache.eagle.policy.common.Constants;
+import org.apache.eagle.alert.entity.SiteDescServiceEntity;
+import org.apache.eagle.service.generic.GenericEntityServiceResource;
+import org.apache.eagle.alert.entity.ApplicationDescServiceEntity;
+import org.apache.eagle.alert.entity.SiteApplicationServiceEntity;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.type.TypeFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.*;
+
+@Path(SiteApplicationResource.ROOT_PATH)
+public class SiteApplicationResource {
+ private final static Logger LOG = LoggerFactory.getLogger(SiteApplicationResource.class);
+ private final static GenericEntityServiceResource resource = new GenericEntityServiceResource();
+ public final static String ROOT_PATH = "/module";
+
+ @Path("site")
+ @DELETE
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public GenericServiceAPIResponseEntity deleteSite(@QueryParam("site") String site) {
+ String siteQuery = Constants.SITE_DESCRIPTION_SERVICE_ENDPOINT_NAME+ "[@site=\"" + site + "\"]{*}";
+ String siteApplicationQuery = Constants.SITE_APPLICATION_SERVICE_ENDPOINT_NAME + "[@site=\"" + site + "\"]{*}";
+ int pageSize = Integer.MAX_VALUE;
+
+ GenericServiceAPIResponseEntity response = resource.deleteByQuery(siteQuery, null, null, pageSize, null, false, false, 0L, 0, true, 0, null, false);
+ if(response.isSuccess()) {
+ response = resource.deleteByQuery(siteApplicationQuery, null, null, pageSize, null, false, false, 0L, 0, true, 0, null, false);
+ if(!response.isSuccess()) {
+ LOG.error(response.getException());
+ }
+ } else {
+ LOG.error(response.getException());
+ }
+ return response;
+ }
+
+ @Path("application")
+ @DELETE
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public GenericServiceAPIResponseEntity deleteApplication(@QueryParam("application") String application) {
+ String applicationQuery = Constants.APPLICATION_DESCRIPTION_SERVICE_ENDPOINT_NAME+ "[@application=\"" + application + "\"]{*}";
+ String siteApplicationQuery = Constants.SITE_APPLICATION_SERVICE_ENDPOINT_NAME + "[@application=\"" + application + "\"]{*}";
+ int pageSize = Integer.MAX_VALUE;
+
+ GenericServiceAPIResponseEntity response = resource.deleteByQuery(applicationQuery, null, null, pageSize, null, false, false, 0L, 0, true, 0, null, false);
+ if(response.isSuccess()) {
+ response = resource.deleteByQuery(siteApplicationQuery, null, null, pageSize, null, false, false, 0L, 0, true, 0, null, false);
+ if(!response.isSuccess()) {
+ LOG.error(response.getException());
+ }
+ } else {
+ LOG.error(response.getException());
+ }
+ return response;
+ }
+
+ @Path("feature")
+ @DELETE
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public GenericServiceAPIResponseEntity deleteFeature(@QueryParam("feature") String feature) {
+ String featureQuery = Constants.FEATURE_DESCRIPTION_SERVICE_ENDPOINT_NAME+ "[@feature=\"" + feature + "\"]{*}";
+ String applicationQuery = Constants.APPLICATION_DESCRIPTION_SERVICE_ENDPOINT_NAME + "[]{*}";
+ int pageSize = Integer.MAX_VALUE;
+
+ GenericServiceAPIResponseEntity response = resource.deleteByQuery(featureQuery, null, null, pageSize, null, false, false, 0L, 0, true, 0, null, false);
+ if(response.isSuccess()) {
+ response = resource.search(applicationQuery, null, null, pageSize, null, false, false, 0L, 0, true, 0, null, false);
+ if(response.isSuccess()) {
+ List<ApplicationDescServiceEntity> entityList = response.getObj();
+ Boolean isModified = false;
+ for(ApplicationDescServiceEntity entity : entityList) {
+ if(entity.getFeatures().contains(feature)) {
+ List<String> features = entity.getFeatures();
+ features.remove(feature);
+ entity.setFeatures(features);
+ isModified = true;
+ }
+ }
+ if(isModified) {
+ response = resource.updateEntities(entityList, Constants.APPLICATION_DESCRIPTION_SERVICE_ENDPOINT_NAME);
+ }
+ }
+ }
+ if(!response.isSuccess()) {
+ LOG.error(response.getException());
+ }
+ return response;
+ }
+
+ @Path("siteApplication")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public GenericServiceAPIResponseEntity createSiteApplications(InputStream inputStream) {
+ GenericServiceAPIResponseEntity response = new GenericServiceAPIResponseEntity<>();
+ int pageSize = Integer.MAX_VALUE;
+ try {
+ List<SiteApplicationObject> entities = (List<SiteApplicationObject>) unmarshalSiteApplicationEntities(inputStream);
+ if(entities == null) {
+ throw new IllegalArgumentException("cannot convert to SiteApplicationObject");
+ }
+ List<SiteDescServiceEntity> siteEntities = new LinkedList<>();
+ List<SiteApplicationServiceEntity> applicationEntities = new LinkedList<>();
+ Set<String> sites = new HashSet<>();
+ for(SiteApplicationObject e : entities) {
+ sites.add(e.getTags().get("site"));
+ SiteDescServiceEntity entity = new SiteDescServiceEntity();
+ entity.setEnabled(e.getEnabled());
+ entity.setTags(e.getTags());
+ siteEntities.add(entity);
+ applicationEntities.addAll(e.getApplications());
+ }
+ response = resource.updateEntities(siteEntities, Constants.SITE_DESCRIPTION_SERVICE_ENDPOINT_NAME);
+ if(response.isSuccess()) {
+ String query = buildQueryWithAttributeList(Constants.SITE_APPLICATION_SERVICE_ENDPOINT_NAME, "site", sites);
+ LOG.info("query=" + query);
+ response = resource.search(query, null, null, pageSize, null, false, false, 0L, 0, true, 0, null, false);
+ if(response.isSuccess()) {
+ List<SiteApplicationServiceEntity> applications = response.getObj();
+ for(SiteApplicationServiceEntity app : applications) {
+ app.setEnabled(false);
+ }
+ response = resource.updateEntities(applications, Constants.SITE_APPLICATION_SERVICE_ENDPOINT_NAME);
+ if(response.isSuccess()) {
+ response = resource.updateEntities(applicationEntities, Constants.SITE_APPLICATION_SERVICE_ENDPOINT_NAME);
+ }
+ }
+ }
+ if(!response.isSuccess()) {
+ LOG.error(response.getException());
+ }
+ } catch (Exception ex) {
+ LOG.error(ex.getMessage(), ex);
+ response.setException(ex);
+ }
+ return response;
+ }
+
+ private String buildQueryWithAttributeList(String serviceName, String attr, Set<String> sets) {
+ StringBuilder builder = new StringBuilder(serviceName + "[");
+ String attribute = "@" + attr + "=";
+ String condition = " OR ";
+ for(String s : sets) {
+ String value = String.format("\"%s\"", s);
+ builder.append(attribute + value);
+ builder.append(condition);
+ }
+ String result = builder.substring(0, builder.length()-condition.length());
+ result = result + "]{*}";
+ return result;
+ }
+
+ private List<? extends TaggedLogAPIEntity> unmarshalSiteApplicationEntities(InputStream inputStream) throws IllegalAccessException, InstantiationException, IOException {
+ ObjectMapper objectMapper = new ObjectMapper();
+ return objectMapper.readValue(inputStream, TypeFactory.defaultInstance().constructCollectionType(LinkedList.class, SiteApplicationObject.class));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ecf75b28/eagle-core/eagle-alert/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/SiteApplicationObject.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/SiteApplicationObject.java b/eagle-core/eagle-alert/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/SiteApplicationObject.java
deleted file mode 100644
index 42f95f7..0000000
--- a/eagle-core/eagle-alert/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/SiteApplicationObject.java
+++ /dev/null
@@ -1,62 +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.eagle.service.alert.resolver;
-
-
-import org.apache.eagle.alert.entity.SiteApplicationServiceEntity;
-import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
-
-import java.util.List;
-import java.util.Map;
-
-public class SiteApplicationObject extends TaggedLogAPIEntity {
-
- public Boolean getEnabled() {
- return enabled;
- }
-
- public void setEnabled(Boolean enabled) {
- this.enabled = enabled;
- valueChanged("enabled");
- }
-
- public List<SiteApplicationServiceEntity> getApplications() {
- return applications;
- }
-
- public void setApplications(List<SiteApplicationServiceEntity> applications) {
- this.applications = applications;
- valueChanged("applicationList");
- }
-
- @Override
- public Map<String, String> getTags() {
- return tags;
- }
-
- @Override
- public void setTags(Map<String, String> tags) {
- this.tags = tags;
- valueChanged("tags");
- }
-
- Map<String, String> tags;
- Boolean enabled;
- List<SiteApplicationServiceEntity> applications;
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ecf75b28/eagle-core/eagle-alert/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/SiteApplicationResource.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/SiteApplicationResource.java b/eagle-core/eagle-alert/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/SiteApplicationResource.java
deleted file mode 100644
index 903a220..0000000
--- a/eagle-core/eagle-alert/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/SiteApplicationResource.java
+++ /dev/null
@@ -1,189 +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.eagle.service.alert.resolver;
-
-import org.apache.eagle.alert.entity.ApplicationDescServiceEntity;
-import org.apache.eagle.alert.entity.SiteApplicationServiceEntity;
-import org.apache.eagle.alert.entity.SiteDescServiceEntity;
-import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
-import org.apache.eagle.log.entity.GenericServiceAPIResponseEntity;
-import org.apache.eagle.policy.common.Constants;
-import org.apache.eagle.service.generic.GenericEntityServiceResource;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.type.TypeFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.*;
-import javax.ws.rs.core.MediaType;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.*;
-
-@Path(SiteApplicationResource.ROOT_PATH)
-public class SiteApplicationResource {
- private final static Logger LOG = LoggerFactory.getLogger(SiteApplicationResource.class);
- private final static GenericEntityServiceResource resource = new GenericEntityServiceResource();
- public final static String ROOT_PATH = "/module";
-
- @Path("site")
- @DELETE
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public GenericServiceAPIResponseEntity deleteSite(@QueryParam("site") String site) {
- String siteQuery = Constants.SITE_DESCRIPTION_SERVICE_ENDPOINT_NAME+ "[@site=\"" + site + "\"]{*}";
- String siteApplicationQuery = Constants.SITE_APPLICATION_SERVICE_ENDPOINT_NAME + "[@site=\"" + site + "\"]{*}";
- int pageSize = Integer.MAX_VALUE;
-
- GenericServiceAPIResponseEntity response = resource.deleteByQuery(siteQuery, null, null, pageSize, null, false, false, 0L, 0, true, 0, null, false);
- if(response.isSuccess()) {
- response = resource.deleteByQuery(siteApplicationQuery, null, null, pageSize, null, false, false, 0L, 0, true, 0, null, false);
- if(!response.isSuccess()) {
- LOG.error(response.getException());
- }
- } else {
- LOG.error(response.getException());
- }
- return response;
- }
-
- @Path("application")
- @DELETE
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public GenericServiceAPIResponseEntity deleteApplication(@QueryParam("application") String application) {
- String applicationQuery = Constants.APPLICATION_DESCRIPTION_SERVICE_ENDPOINT_NAME+ "[@application=\"" + application + "\"]{*}";
- String siteApplicationQuery = Constants.SITE_APPLICATION_SERVICE_ENDPOINT_NAME + "[@application=\"" + application + "\"]{*}";
- int pageSize = Integer.MAX_VALUE;
-
- GenericServiceAPIResponseEntity response = resource.deleteByQuery(applicationQuery, null, null, pageSize, null, false, false, 0L, 0, true, 0, null, false);
- if(response.isSuccess()) {
- response = resource.deleteByQuery(siteApplicationQuery, null, null, pageSize, null, false, false, 0L, 0, true, 0, null, false);
- if(!response.isSuccess()) {
- LOG.error(response.getException());
- }
- } else {
- LOG.error(response.getException());
- }
- return response;
- }
-
- @Path("feature")
- @DELETE
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public GenericServiceAPIResponseEntity deleteFeature(@QueryParam("feature") String feature) {
- String featureQuery = Constants.FEATURE_DESCRIPTION_SERVICE_ENDPOINT_NAME+ "[@feature=\"" + feature + "\"]{*}";
- String applicationQuery = Constants.APPLICATION_DESCRIPTION_SERVICE_ENDPOINT_NAME + "[]{*}";
- int pageSize = Integer.MAX_VALUE;
-
- GenericServiceAPIResponseEntity response = resource.deleteByQuery(featureQuery, null, null, pageSize, null, false, false, 0L, 0, true, 0, null, false);
- if(response.isSuccess()) {
- response = resource.search(applicationQuery, null, null, pageSize, null, false, false, 0L, 0, true, 0, null, false);
- if(response.isSuccess()) {
- List<ApplicationDescServiceEntity> entityList = response.getObj();
- Boolean isModified = false;
- for(ApplicationDescServiceEntity entity : entityList) {
- if(entity.getFeatures().contains(feature)) {
- List<String> features = entity.getFeatures();
- features.remove(feature);
- entity.setFeatures(features);
- isModified = true;
- }
- }
- if(isModified) {
- response = resource.updateEntities(entityList, Constants.APPLICATION_DESCRIPTION_SERVICE_ENDPOINT_NAME);
- }
- }
- }
- if(!response.isSuccess()) {
- LOG.error(response.getException());
- }
- return response;
- }
-
- @Path("siteApplication")
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public GenericServiceAPIResponseEntity createSiteApplications(InputStream inputStream) {
- GenericServiceAPIResponseEntity response = new GenericServiceAPIResponseEntity<>();
- int pageSize = Integer.MAX_VALUE;
- try {
- List<SiteApplicationObject> entities = (List<SiteApplicationObject>) unmarshalSiteApplicationEntities(inputStream);
- if(entities == null) {
- throw new IllegalArgumentException("cannot convert to SiteApplicationObject");
- }
- List<SiteDescServiceEntity> siteEntities = new LinkedList<>();
- List<SiteApplicationServiceEntity> applicationEntities = new LinkedList<>();
- Set<String> sites = new HashSet<>();
- for(SiteApplicationObject e : entities) {
- sites.add(e.getTags().get("site"));
- SiteDescServiceEntity entity = new SiteDescServiceEntity();
- entity.setEnabled(e.getEnabled());
- entity.setTags(e.getTags());
- siteEntities.add(entity);
- applicationEntities.addAll(e.getApplications());
- }
- response = resource.updateEntities(siteEntities, Constants.SITE_DESCRIPTION_SERVICE_ENDPOINT_NAME);
- if(response.isSuccess()) {
- String query = buildQueryWithAttributeList(Constants.SITE_APPLICATION_SERVICE_ENDPOINT_NAME, "site", sites);
- LOG.info("query=" + query);
- response = resource.search(query, null, null, pageSize, null, false, false, 0L, 0, true, 0, null, false);
- if(response.isSuccess()) {
- List<SiteApplicationServiceEntity> applications = response.getObj();
- for(SiteApplicationServiceEntity app : applications) {
- app.setEnabled(false);
- }
- response = resource.updateEntities(applications, Constants.SITE_APPLICATION_SERVICE_ENDPOINT_NAME);
- if(response.isSuccess()) {
- response = resource.updateEntities(applicationEntities, Constants.SITE_APPLICATION_SERVICE_ENDPOINT_NAME);
- }
- }
- }
- if(!response.isSuccess()) {
- LOG.error(response.getException());
- }
- } catch (Exception ex) {
- LOG.error(ex.getMessage(), ex);
- response.setException(ex);
- }
- return response;
- }
-
- private String buildQueryWithAttributeList(String serviceName, String attr, Set<String> sets) {
- StringBuilder builder = new StringBuilder(serviceName + "[");
- String attribute = "@" + attr + "=";
- String condition = " OR ";
- for(String s : sets) {
- String value = String.format("\"%s\"", s);
- builder.append(attribute + value);
- builder.append(condition);
- }
- String result = builder.substring(0, builder.length()-condition.length());
- result = result + "]{*}";
- return result;
- }
-
- private List<? extends TaggedLogAPIEntity> unmarshalSiteApplicationEntities(InputStream inputStream) throws IllegalAccessException, InstantiationException, IOException {
- ObjectMapper objectMapper = new ObjectMapper();
- return objectMapper.readValue(inputStream, TypeFactory.defaultInstance().constructCollectionType(LinkedList.class, SiteApplicationObject.class));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ecf75b28/eagle-core/eagle-application-management/eagle-application-service/pom.xml
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-application-management/eagle-application-service/pom.xml b/eagle-core/eagle-application-management/eagle-application-service/pom.xml
new file mode 100644
index 0000000..ade47d7
--- /dev/null
+++ b/eagle-core/eagle-application-management/eagle-application-service/pom.xml
@@ -0,0 +1,56 @@
+<?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>eagle-application-management</artifactId>
+ <groupId>org.apache.eagle</groupId>
+ <version>0.3.0-incubating</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>eagle-application-service</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.eagle</groupId>
+ <artifactId>eagle-policy-base</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.eagle</groupId>
+ <artifactId>eagle-service-base</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>true</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ecf75b28/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/AppManagerConstants.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/AppManagerConstants.java b/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/AppManagerConstants.java
new file mode 100644
index 0000000..dafd7fb
--- /dev/null
+++ b/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/AppManagerConstants.java
@@ -0,0 +1,42 @@
+/*
+ * 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.eagle.service.application;
+
+
+public class AppManagerConstants {
+ public final static String SITE_TAG = "site";
+ public final static String APPLICATION_TAG = "application";
+ public final static String OPERATION_TAG = "operation";
+ public final static String OPERATION_ID_TAG = "operationID";
+ public final static String TOPOLOGY_TAG = "topology";
+ public final static String FULLNAME = "fullName";
+ public final static String APPLICATION_ID = "id";
+
+ public final static String CLUSTER_ENV = "envContextConfig.env";
+ public final static String CLUSTER_URL = "envContextConfig.url";
+ public final static String DEFAULT_CLUSTER_URL = "http://sandbox.hortonworks.com:8744";
+
+ public final static String RUNNING_MODE = "envContextConfig.mode";
+ public final static String EAGLE_CLUSTER_STORM = "storm";
+ public final static String EAGLE_CLUSTER_SPARK = "spark";
+
+ public final static String APP_COMMAND_LOADER_INTERVAL_SECS = "appCommandLoaderIntervalSecs";
+ public final static String APP_HEALTH_CHECK_INTERVAL_SECS = "appHealthCheckIntervalSecs";
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ecf75b28/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/ApplicationManagementResource.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/ApplicationManagementResource.java b/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/ApplicationManagementResource.java
new file mode 100644
index 0000000..779fbe5
--- /dev/null
+++ b/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/ApplicationManagementResource.java
@@ -0,0 +1,101 @@
+/*
+ * 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.eagle.service.application;
+
+
+import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
+import org.apache.eagle.log.entity.GenericServiceAPIResponseEntity;
+import org.apache.eagle.service.application.dao.ApplicationManagerDAO;
+import org.apache.eagle.service.application.dao.ApplicationManagerDaoImpl;
+import org.apache.eagle.service.application.entity.TopologyExecutionStatus;
+import org.apache.eagle.service.application.entity.TopologyOperationEntity;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.type.TypeFactory;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.*;
+
+@Path(ApplicationManagementResource.ROOT_PATH)
+public class ApplicationManagementResource {
+ private final static ApplicationManagerDAO dao = new ApplicationManagerDaoImpl();
+ public final static String ROOT_PATH = "/app";
+
+ @Path("operation")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public GenericServiceAPIResponseEntity createOperation(InputStream inputStream) {
+ GenericServiceAPIResponseEntity response = new GenericServiceAPIResponseEntity<>();
+ List<TopologyOperationEntity> operations = new LinkedList<>();
+ try {
+ List<TopologyOperationEntity> entities = (List<TopologyOperationEntity>) unmarshalOperationEntities(inputStream);
+ if (entities == null) {
+ throw new IllegalArgumentException("inputStream cannot convert to TopologyOperationEntity");
+ }
+ for (TopologyOperationEntity entity : entities) {
+ String status = dao.loadTopologyExecutionStatus(entity.getSite(), entity.getApplication(), entity.getTopology());
+ if(status == null) {
+ throw new Exception(String.format("Fail to fetch the topology execution status by site=%s, application=%s, topology=%s", entity.getSite(), entity.getApplication(), entity.getTopology()));
+ }
+ int operationsInRunning = dao.loadTopologyOperationsInRunning(entity.getSite(), entity.getApplication(), entity.getTopology());
+ if(operationsInRunning !=0) {
+ throw new Exception(operationsInRunning + "operations are running, please wait for a minute");
+ }
+ if (validateOperation(entity.getOperation(), status)) {
+ Map<String, String> tags = entity.getTags();
+ tags.put(AppManagerConstants.OPERATION_ID_TAG, UUID.randomUUID().toString());
+ entity.setTags(tags);
+ entity.setLastModifiedDate(System.currentTimeMillis());
+ entity.setTimestamp(System.currentTimeMillis());
+ operations.add(entity);
+ } else {
+ throw new Exception(String.format("%s is an invalid operation, as the topology's current status is %s", entity.getOperation(), status));
+ }
+ }
+ response = dao.createOperation(operations);
+ } catch (Exception e) {
+ response.setSuccess(false);
+ response.setException(e);
+ }
+ return response;
+ }
+
+ private boolean validateOperation(String operation, String status) {
+ boolean ret = false;
+ switch (operation) {
+ case TopologyOperationEntity.OPERATION.START:
+ return TopologyExecutionStatus.isReadyToStart(status);
+ case TopologyOperationEntity.OPERATION.STOP:
+ return TopologyExecutionStatus.isReadyToStop(status);
+ default: break;
+ }
+ return ret;
+ }
+
+ private List<? extends TaggedLogAPIEntity> unmarshalOperationEntities(InputStream inputStream) throws IllegalAccessException, InstantiationException, IOException {
+ ObjectMapper objectMapper = new ObjectMapper();
+ return objectMapper.readValue(inputStream, TypeFactory.defaultInstance().constructCollectionType(LinkedList.class, TopologyOperationEntity.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ecf75b28/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/dao/ApplicationManagerDAO.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/dao/ApplicationManagerDAO.java b/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/dao/ApplicationManagerDAO.java
new file mode 100644
index 0000000..189370b
--- /dev/null
+++ b/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/dao/ApplicationManagerDAO.java
@@ -0,0 +1,32 @@
+/*
+ * 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.eagle.service.application.dao;
+
+
+import org.apache.eagle.log.entity.GenericServiceAPIResponseEntity;
+import org.apache.eagle.service.application.entity.TopologyExecutionStatus;
+import org.apache.eagle.service.application.entity.TopologyOperationEntity;
+
+import java.util.List;
+
+public interface ApplicationManagerDAO {
+ String loadTopologyExecutionStatus(String site, String application, String topology);
+ int loadTopologyOperationsInRunning(String site, String application, String topology) throws Exception;
+ GenericServiceAPIResponseEntity createOperation(List<TopologyOperationEntity> entities) throws Exception;
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ecf75b28/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/dao/ApplicationManagerDaoImpl.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/dao/ApplicationManagerDaoImpl.java b/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/dao/ApplicationManagerDaoImpl.java
new file mode 100644
index 0000000..e21f624
--- /dev/null
+++ b/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/dao/ApplicationManagerDaoImpl.java
@@ -0,0 +1,77 @@
+/*
+ * 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.eagle.service.application.dao;
+
+
+import org.apache.eagle.log.entity.GenericServiceAPIResponseEntity;
+import org.apache.eagle.policy.common.Constants;
+import org.apache.eagle.service.application.entity.TopologyExecutionEntity;
+import org.apache.eagle.service.application.entity.TopologyExecutionStatus;
+import org.apache.eagle.service.application.entity.TopologyOperationEntity;
+import org.apache.eagle.service.generic.GenericEntityServiceResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+public class ApplicationManagerDaoImpl implements ApplicationManagerDAO {
+ private static Logger LOG = LoggerFactory.getLogger(ApplicationManagerDaoImpl.class);
+ GenericEntityServiceResource resource = new GenericEntityServiceResource();
+
+ @Override
+ public String loadTopologyExecutionStatus(String site, String application, String topology) {
+ String query = String.format("%s[@site=\"%s\" AND @application=\"%s\" AND @topology=\"%s\"]{*}", Constants.TOPOLOGY_EXECUTION_SERVICE_ENDPOINT_NAME, site, application, topology);
+ GenericServiceAPIResponseEntity<TopologyExecutionEntity> response = resource.search(query, null, null, Integer.MAX_VALUE, null, false, false, 0L, 0, false, 0, null, false);
+ if(!response.isSuccess()) {
+ LOG.error(response.getException());
+ return null;
+ }
+ List<TopologyExecutionEntity> list = response.getObj();
+ if(list == null || list.size() != 1) {
+ LOG.error("ERROR: fetching 0 or more than 1 topology execution entities");
+ return null;
+ }
+ return list.get(0).getStatus();
+ }
+
+ @Override
+ public int loadTopologyOperationsInRunning(String site, String application, String topology) throws Exception {
+ int ret = 0;
+ String query = String.format("%s[@site=\"%s\" AND @application=\"%s\" AND @topology=\"%s\" AND (@status=\"%s\" OR @status=\"%s\")]{*}", Constants.TOPOLOGY_OPERATION_SERVICE_ENDPOINT_NAME, site, application, topology, TopologyOperationEntity.OPERATION_STATUS.INITIALIZED, TopologyOperationEntity.OPERATION_STATUS.PENDING);
+ GenericServiceAPIResponseEntity<TopologyExecutionEntity> response = resource.search(query, null, null, Integer.MAX_VALUE, null, false, false, 0L, 0, false, 0, null, false);
+ if(!response.isSuccess()) {
+ throw new Exception(response.getException());
+ }
+ if(response.getObj() != null && response.getObj().size() != 0) {
+ ret = response.getObj().size();
+ }
+ return ret;
+ }
+
+ @Override
+ public GenericServiceAPIResponseEntity createOperation(List<TopologyOperationEntity> entities) throws Exception {
+ if(entities.size() == 0) {
+ LOG.info("TopologyOperationEntity set is empty.");
+ }
+ GenericServiceAPIResponseEntity response = resource.updateEntities(entities, Constants.TOPOLOGY_OPERATION_SERVICE_ENDPOINT_NAME);
+ return response;
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ecf75b28/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/entity/ApplicationEntityRepo.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/entity/ApplicationEntityRepo.java b/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/entity/ApplicationEntityRepo.java
new file mode 100644
index 0000000..3226650
--- /dev/null
+++ b/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/entity/ApplicationEntityRepo.java
@@ -0,0 +1,30 @@
+/*
+ * 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.eagle.service.application.entity;
+
+
+import org.apache.eagle.log.entity.repo.EntityRepository;
+
+public class ApplicationEntityRepo extends EntityRepository {
+ public ApplicationEntityRepo() {
+ this.registerEntity(TopologyDescriptionEntity.class);
+ this.registerEntity(TopologyExecutionEntity.class);
+ this.registerEntity(TopologyOperationEntity.class);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ecf75b28/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/entity/TopologyDescriptionEntity.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/entity/TopologyDescriptionEntity.java b/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/entity/TopologyDescriptionEntity.java
new file mode 100644
index 0000000..6442e6c
--- /dev/null
+++ b/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/entity/TopologyDescriptionEntity.java
@@ -0,0 +1,104 @@
+/*
+ * 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.eagle.service.application.entity;
+
+
+import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
+import org.apache.eagle.log.entity.meta.*;
+import org.apache.eagle.policy.common.Constants;
+import org.apache.eagle.service.application.AppManagerConstants;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+@Table("eagle_metadata")
+@ColumnFamily("f")
+@Prefix("topologyDescription")
+@Service(Constants.TOPOLOGY_DESCRIPTION_SERVICE_ENDPOINT_NAME)
+@JsonIgnoreProperties(ignoreUnknown = true)
+@TimeSeries(false)
+@Tags({"topology"})
+public class TopologyDescriptionEntity extends TaggedLogAPIEntity {
+ @Column("a")
+ private String exeClass;
+ @Column("b")
+ private String type;
+ @Column("c")
+ private String description;
+ @Column("d")
+ private String version;
+ private String context;
+ public String getContext() {
+ return context;
+ }
+
+ public void setContext(String context) {
+ this.context = context;
+ }
+
+ public String getExeClass() {
+ return exeClass;
+ }
+
+ public void setExeClass(String exeClass) {
+ this.exeClass = exeClass;
+ valueChanged("exeClass");
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ valueChanged("type");
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ valueChanged("description");
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ valueChanged("version");
+ }
+
+ public String getTopology() {
+ return this.getTags().get(AppManagerConstants.TOPOLOGY_TAG);
+ }
+
+ public final static class TYPE {
+ public final static String DYNAMIC = "DYNAMIC";
+ public final static String CLASS = "CLASS";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ecf75b28/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/entity/TopologyExecutionEntity.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/entity/TopologyExecutionEntity.java b/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/entity/TopologyExecutionEntity.java
new file mode 100644
index 0000000..9991d3b
--- /dev/null
+++ b/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/entity/TopologyExecutionEntity.java
@@ -0,0 +1,132 @@
+/*
+ * 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.eagle.service.application.entity;
+
+import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
+import org.apache.eagle.log.entity.meta.*;
+import org.apache.eagle.policy.common.Constants;
+
+import org.apache.eagle.service.application.AppManagerConstants;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+@Table("eagle_metadata")
+@ColumnFamily("f")
+@Prefix("topologyExecution")
+@Service(Constants.TOPOLOGY_EXECUTION_SERVICE_ENDPOINT_NAME)
+@JsonIgnoreProperties(ignoreUnknown = true)
+@TimeSeries(false)
+@Tags({"site", "application", "topology"})
+public class TopologyExecutionEntity extends TaggedLogAPIEntity {
+ @Column("a")
+ private String fullName;
+ @Column("b")
+ private String url;
+ @Column("c")
+ private String description;
+ @Column("d")
+ private String status;
+ @Column("e")
+ private long lastModifiedDate;
+ @Column("f")
+ private String mode;
+ @Column("g")
+ private String environment;
+
+ public String getEnvironment() {
+ return environment;
+ }
+
+ public void setEnvironment(String environment) {
+ this.environment = environment;
+ valueChanged("environment");
+ }
+
+ public String getMode() {
+ return mode;
+ }
+
+ public void setMode(String mode) {
+ this.mode = mode;
+ valueChanged("mode");
+ }
+
+ public String getFullName() {
+ return fullName;
+ }
+
+ public void setFullName(String fullName) {
+ this.fullName = fullName;
+ valueChanged("fullName");
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ valueChanged("url");
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ valueChanged("description");
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ valueChanged("status");
+ }
+
+ public long getLastModifiedDate() {
+ return lastModifiedDate;
+ }
+
+ public void setLastModifiedDate(long lastModifiedDate) {
+ this.lastModifiedDate = lastModifiedDate;
+ valueChanged("lastModifiedDate");
+ }
+
+ public String getSite() {
+ return this.getTags().get(AppManagerConstants.SITE_TAG);
+ }
+
+ public String getApplication() {
+ return this.getTags().get(AppManagerConstants.APPLICATION_TAG);
+ }
+
+ public String getTopology() {
+ return this.getTags().get(AppManagerConstants.TOPOLOGY_TAG);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ecf75b28/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/entity/TopologyExecutionStatus.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/entity/TopologyExecutionStatus.java b/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/entity/TopologyExecutionStatus.java
new file mode 100644
index 0000000..f62ad8a
--- /dev/null
+++ b/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/entity/TopologyExecutionStatus.java
@@ -0,0 +1,38 @@
+/*
+ * 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.eagle.service.application.entity;
+
+
+public class TopologyExecutionStatus {
+ public final static String STOPPED = "STOPPED";
+ public final static String STARTED = "STARTED";
+ public final static String STARTING = "STARTING";
+ public final static String STOPPING = "STOPPING";
+ public final static String NEW = "NEW";
+
+ public static boolean isReadyToStart(String status){
+ return status.equals(STOPPED) || status.equals(NEW);
+ }
+
+ public static boolean isReadyToStop(String status){
+ return status.equals(STARTED);
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ecf75b28/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/entity/TopologyOperationEntity.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/entity/TopologyOperationEntity.java b/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/entity/TopologyOperationEntity.java
new file mode 100644
index 0000000..6d8f1a0
--- /dev/null
+++ b/eagle-core/eagle-application-management/eagle-application-service/src/main/java/org/apache/eagle/service/application/entity/TopologyOperationEntity.java
@@ -0,0 +1,105 @@
+/*
+ * 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.eagle.service.application.entity;
+
+import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
+import org.apache.eagle.log.entity.meta.*;
+import org.apache.eagle.policy.common.Constants;
+
+import org.apache.eagle.service.application.AppManagerConstants;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+@Table("eagle_metadata")
+@ColumnFamily("f")
+@Prefix("topologyOperation")
+@Service(Constants.TOPOLOGY_OPERATION_SERVICE_ENDPOINT_NAME)
+@JsonIgnoreProperties(ignoreUnknown = true)
+@TimeSeries(true)
+@Tags({"site", "application", "topology", "operationID", "operation"})
+public class TopologyOperationEntity extends TaggedLogAPIEntity {
+ @Column("a")
+ private String status;
+ @Column("b")
+ private String message;
+ @Column("c")
+ private long lastModifiedDate;
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ valueChanged("status");
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ valueChanged("message");
+ }
+
+ public long getLastModifiedDate() {
+ return lastModifiedDate;
+ }
+
+ public void setLastModifiedDate(long lastModifiedDate) {
+ this.lastModifiedDate = lastModifiedDate;
+ valueChanged("lastModifiedDate");
+ }
+
+ public final static class OPERATION {
+ public final static String START = "START";
+ public final static String STOP = "STOP";
+ public final static String STATUS = "STATUS";
+ }
+
+ public final static class OPERATION_STATUS {
+ public final static String PENDING = "PENDING";
+ public final static String INITIALIZED = "INITIALIZED";
+ public final static String SUCCESS = "SUCCESS";
+ public final static String FAILED = "FAILED";
+ }
+
+ public String getSite() {
+ return this.getTags().get(AppManagerConstants.SITE_TAG);
+ }
+
+ public String getApplication() {
+ return this.getTags().get(AppManagerConstants.APPLICATION_TAG);
+ }
+
+ public String getTopology() {
+ return this.getTags().get(AppManagerConstants.TOPOLOGY_TAG);
+ }
+
+ public String getOperation() {
+ return this.getTags().get(AppManagerConstants.OPERATION_TAG);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ecf75b28/eagle-core/eagle-application-management/eagle-stream-application-manager/pom.xml
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-application-management/eagle-stream-application-manager/pom.xml b/eagle-core/eagle-application-management/eagle-stream-application-manager/pom.xml
new file mode 100644
index 0000000..83598c1
--- /dev/null
+++ b/eagle-core/eagle-application-management/eagle-stream-application-manager/pom.xml
@@ -0,0 +1,144 @@
+<?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>eagle-application-management</artifactId>
+ <groupId>org.apache.eagle</groupId>
+ <version>0.3.0-incubating</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>eagle-stream-application-manager</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.eagle</groupId>
+ <artifactId>eagle-application-service</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.eagle</groupId>
+ <artifactId>eagle-stream-pipeline</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.storm</groupId>
+ <artifactId>storm-core</artifactId>
+ <version>${storm.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>log4j-over-slf4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-reflect</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-compiler</artifactId>
+ <version>${scala.version}.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.scalatest</groupId>
+ <artifactId>scalatest_${scala.version}</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.typesafe.akka</groupId>
+ <artifactId>akka-actor_${scala.version}</artifactId>
+ <version>${akka.actor.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.typesafe.akka</groupId>
+ <artifactId>akka-testkit_${scala.version}</artifactId>
+ <version>${akka.actor.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.scala-tools</groupId>
+ <artifactId>maven-scala-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>scala-compile-first</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>add-source</goal>
+ <goal>compile</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>scala-test-compile</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>testCompile</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>true</skipTests>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.scalatest</groupId>
+ <artifactId>scalatest-maven-plugin</artifactId>
+ <configuration>
+ <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
+ <junitxml>.</junitxml>
+ <filereports>TestSuite.txt</filereports>
+ </configuration>
+ <executions>
+ <execution>
+ <id>test</id>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ecf75b28/eagle-core/eagle-application-management/eagle-stream-application-manager/src/main/java/org/apache/eagle/stream/application/TopologyException.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-application-management/eagle-stream-application-manager/src/main/java/org/apache/eagle/stream/application/TopologyException.java b/eagle-core/eagle-application-management/eagle-stream-application-manager/src/main/java/org/apache/eagle/stream/application/TopologyException.java
new file mode 100644
index 0000000..d382629
--- /dev/null
+++ b/eagle-core/eagle-application-management/eagle-stream-application-manager/src/main/java/org/apache/eagle/stream/application/TopologyException.java
@@ -0,0 +1,26 @@
+/*
+ * 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.eagle.stream.application;
+
+
+public class TopologyException extends Exception {
+ public TopologyException(String s, Exception e) { super(s,e); }
+ public TopologyException(Exception e) { super(e); }
+ public TopologyException(String s) { super(s); }
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ecf75b28/eagle-core/eagle-application-management/eagle-stream-application-manager/src/main/java/org/apache/eagle/stream/application/TopologyExecutable.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-application-management/eagle-stream-application-manager/src/main/java/org/apache/eagle/stream/application/TopologyExecutable.java b/eagle-core/eagle-application-management/eagle-stream-application-manager/src/main/java/org/apache/eagle/stream/application/TopologyExecutable.java
new file mode 100644
index 0000000..8f625c7
--- /dev/null
+++ b/eagle-core/eagle-application-management/eagle-stream-application-manager/src/main/java/org/apache/eagle/stream/application/TopologyExecutable.java
@@ -0,0 +1,27 @@
+/*
+ * 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.eagle.stream.application;
+
+
+import com.typesafe.config.Config;
+
+
+public interface TopologyExecutable {
+ void submit(String topology, Config config);
+}