You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eagle.apache.org by da...@apache.org on 2016/09/29 05:45:57 UTC
incubator-eagle git commit: [EAGLE-432] Application status monitoring
https://issues.apache.org/jira/browse/EAGLE-432
Repository: incubator-eagle
Updated Branches:
refs/heads/master 5e59407eb -> 039bf25d6
[EAGLE-432] Application status monitoring
https://issues.apache.org/jira/browse/EAGLE-432
Author: @DadanielZ <da...@apache.org>
Reviewer: @yonzhang <yo...@apache.org>
Closes #461
Project: http://git-wip-us.apache.org/repos/asf/incubator-eagle/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-eagle/commit/039bf25d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-eagle/tree/039bf25d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-eagle/diff/039bf25d
Branch: refs/heads/master
Commit: 039bf25d6bd61f5b0d3227318ddd477a3e4564d7
Parents: 5e59407
Author: DadanielZ <da...@apache.org>
Authored: Wed Sep 28 22:44:10 2016 -0700
Committer: DadanielZ <da...@apache.org>
Committed: Wed Sep 28 22:44:10 2016 -0700
----------------------------------------------------------------------
.../eagle/app/environment/ExecutionRuntime.java | 4 +-
.../environment/impl/SparkExecutionRuntime.java | 3 +-
.../environment/impl/StormExecutionRuntime.java | 32 +++++-
.../environment/impl/WebExecutionRuntime.java | 4 +-
.../app/module/ApplicationGuiceModule.java | 3 +
.../eagle/app/resource/ApplicationResource.java | 17 ++-
.../service/ApplicationManagementService.java | 16 ++-
.../service/ApplicationOperationContext.java | 5 +-
.../app/service/ApplicationOperations.java | 48 +++++++-
.../impl/ApplicationManagementServiceImpl.java | 91 ++++++++++++---
.../ApplicationStatusUpdateServiceImpl.java | 115 +++++++++++++++++++
.../ApplicationWrongStatusException.java | 31 +++++
.../eagle/metadata/model/ApplicationEntity.java | 5 +-
.../service/ApplicationStatusUpdateService.java | 27 +++++
.../example/ExampleApplicationProviderTest.java | 5 +
.../eagle/app/jpm/JPMWebApplicationTest.java | 14 ++-
.../apache/eagle/server/ServerApplication.java | 17 ++-
.../server/managedtask/ApplicationTask.java | 43 +++++++
.../src/main/resources/application.conf | 4 +
19 files changed, 449 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/039bf25d/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/ExecutionRuntime.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/ExecutionRuntime.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/ExecutionRuntime.java
index e9a6366..4bba81b 100644
--- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/ExecutionRuntime.java
+++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/ExecutionRuntime.java
@@ -18,6 +18,7 @@ package org.apache.eagle.app.environment;
import org.apache.eagle.app.Application;
import com.typesafe.config.Config;
+import org.apache.eagle.metadata.model.ApplicationEntity;
/**
* Execution Runtime Adapter.
@@ -54,6 +55,7 @@ public interface ExecutionRuntime<E extends Environment, P> {
*
* @param executor
* @param config
+ * @return status
*/
- void status(Application<E, P> executor, Config config);
+ ApplicationEntity.Status status(Application<E, P> executor, Config config);
}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/039bf25d/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/SparkExecutionRuntime.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/SparkExecutionRuntime.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/SparkExecutionRuntime.java
index e2fc7d5..1cad34f 100644
--- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/SparkExecutionRuntime.java
+++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/SparkExecutionRuntime.java
@@ -20,6 +20,7 @@ import org.apache.eagle.app.Application;
import org.apache.eagle.app.environment.ExecutionRuntime;
import org.apache.eagle.app.environment.ExecutionRuntimeProvider;
import com.typesafe.config.Config;
+import org.apache.eagle.metadata.model.ApplicationEntity;
public class SparkExecutionRuntime implements ExecutionRuntime<SparkEnvironment,Object> {
@Override
@@ -43,7 +44,7 @@ public class SparkExecutionRuntime implements ExecutionRuntime<SparkEnvironment,
}
@Override
- public void status(Application executor, Config config) {
+ public ApplicationEntity.Status status(Application executor, Config config) {
throw new RuntimeException("Not implemented yet");
}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/039bf25d/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 6d12494..702a3e6 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
@@ -33,6 +33,7 @@ import org.slf4j.LoggerFactory;
import scala.Int;
import storm.trident.spout.RichSpoutBatchExecutor;
+import java.util.List;
import java.util.Objects;
public class StormExecutionRuntime implements ExecutionRuntime<StormEnvironment,StormTopology> {
@@ -144,6 +145,7 @@ public class StormExecutionRuntime implements ExecutionRuntime<StormEnvironment,
stormClient.killTopology(appId);
} catch (NotAliveException | TException e) {
LOG.error("Failed to kill topology named {}, due to: {}",appId,e.getMessage(),e.getCause());
+ throw new RuntimeException(e.getMessage(),e);
}
} else {
KillOptions killOptions = new KillOptions();
@@ -154,9 +156,33 @@ public class StormExecutionRuntime implements ExecutionRuntime<StormEnvironment,
}
@Override
- public void status(Application<StormEnvironment, StormTopology> executor, com.typesafe.config.Config config) {
- // TODO: Not implemented yet!
- throw new RuntimeException("TODO: Not implemented yet!");
+ public ApplicationEntity.Status status(Application<StormEnvironment, StormTopology> executor, com.typesafe.config.Config config) {
+ String appId = config.getString("appId");
+ LOG.info("Fetching status of topology {} ..." + appId);
+ List<TopologySummary> topologySummaries ;
+ try {
+ if (Objects.equals(config.getString("mode"), ApplicationEntity.Mode.CLUSTER.name())) {
+ Nimbus.Client stormClient = NimbusClient.getConfiguredClient(getStormConfig(config)).getClient();
+ topologySummaries = stormClient.getClusterInfo().get_topologies();
+ } else {
+ topologySummaries = getLocalCluster().getClusterInfo().get_topologies();
+ }
+ for (TopologySummary topologySummary : topologySummaries) {
+ if (topologySummary.get_name().equalsIgnoreCase(appId)) {
+ if (topologySummary.get_status().equalsIgnoreCase("ACTIVE")) {
+ return ApplicationEntity.Status.RUNNING;
+ } else if (topologySummary.get_status().equalsIgnoreCase("INACTIVE")) {
+ return ApplicationEntity.Status.STOPPED;
+ } else if (topologySummary.get_status().equalsIgnoreCase("KILLED")) {
+ return ApplicationEntity.Status.REMOVED;
+ }
+ }
+ }
+ //If not exist, return removed
+ return ApplicationEntity.Status.REMOVED;
+ } catch (TException e) {
+ return ApplicationEntity.Status.UNKNOWN;
+ }
}
public static class Provider implements ExecutionRuntimeProvider<StormEnvironment,StormTopology> {
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/039bf25d/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/WebExecutionRuntime.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/WebExecutionRuntime.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/WebExecutionRuntime.java
index f8eecef..29a37cf 100644
--- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/WebExecutionRuntime.java
+++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/WebExecutionRuntime.java
@@ -21,6 +21,7 @@ import com.typesafe.config.Config;
import org.apache.eagle.app.Application;
import org.apache.eagle.app.environment.ExecutionRuntime;
import org.apache.eagle.app.environment.ExecutionRuntimeProvider;
+import org.apache.eagle.metadata.model.ApplicationEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,8 +54,9 @@ public class WebExecutionRuntime implements ExecutionRuntime<WebEnvironment,WebE
}
@Override
- public void status(Application<WebEnvironment, WebExecutionContainer> executor, Config config) {
+ public ApplicationEntity.Status status(Application<WebEnvironment, WebExecutionContainer> executor, Config config) {
LOGGER.warn("Checking status {}, do nothing",executor);
+ return ApplicationEntity.Status.INITIALIZED;
}
public static class Provider implements ExecutionRuntimeProvider<WebEnvironment,WebExecutionContainer> {
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/039bf25d/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/module/ApplicationGuiceModule.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/module/ApplicationGuiceModule.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/module/ApplicationGuiceModule.java
index d4a176d..67c7eec 100644
--- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/module/ApplicationGuiceModule.java
+++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/module/ApplicationGuiceModule.java
@@ -19,10 +19,12 @@ package org.apache.eagle.app.module;
import org.apache.eagle.app.service.ApplicationManagementService;
import org.apache.eagle.app.service.ApplicationProviderService;
import org.apache.eagle.app.service.impl.ApplicationManagementServiceImpl;
+import org.apache.eagle.app.service.impl.ApplicationStatusUpdateServiceImpl;
import org.apache.eagle.metadata.service.ApplicationDescService;
import com.google.inject.AbstractModule;
import com.google.inject.Singleton;
import com.google.inject.util.Providers;
+import org.apache.eagle.metadata.service.ApplicationStatusUpdateService;
public class ApplicationGuiceModule extends AbstractModule {
private ApplicationProviderService appProviderInst;
@@ -36,5 +38,6 @@ public class ApplicationGuiceModule extends AbstractModule {
bind(ApplicationProviderService.class).toProvider(Providers.of(appProviderInst));
bind(ApplicationDescService.class).toProvider(Providers.of(appProviderInst));
bind(ApplicationManagementService.class).to(ApplicationManagementServiceImpl.class).in(Singleton.class);
+ bind(ApplicationStatusUpdateService.class).to(ApplicationStatusUpdateServiceImpl.class).in(Singleton.class);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/039bf25d/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/resource/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/resource/ApplicationResource.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/resource/ApplicationResource.java
index 713ced5..717f7c0 100644
--- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/resource/ApplicationResource.java
+++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/resource/ApplicationResource.java
@@ -90,6 +90,18 @@ public class ApplicationResource {
return RESTResponse.async(() -> entityService.getByUUID(appUuid)).get();
}
+ @POST
+ @Path("/status")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public RESTResponse<ApplicationEntity.Status> checkApplicationStatusByUUID(ApplicationOperations.CheckStatusOperation operation) {
+ return RESTResponse.<ApplicationEntity.Status>async((response) -> {
+ ApplicationEntity.Status status = (entityService.getByUUIDOrAppId(null, operation.getAppId())).getStatus();
+ response.success(true).message("Successfully fetched application status");
+ response.data(status);
+ }).get();
+ }
+
/**
* <b>Request:</b>
* <pre>
@@ -148,7 +160,7 @@ public class ApplicationResource {
public RESTResponse<Void> startApplication(ApplicationOperations.StartOperation operation) {
return RESTResponse.<Void>async((response) -> {
ApplicationEntity entity = applicationManagementService.start(operation);
- response.success(true).message("Successfully started application " + entity.getUuid());
+ response.success(true).message("Starting application " + entity.getUuid());
}).get();
}
@@ -169,7 +181,8 @@ public class ApplicationResource {
public RESTResponse<Void> stopApplication(ApplicationOperations.StopOperation operation) {
return RESTResponse.<Void>async((response) -> {
ApplicationEntity entity = applicationManagementService.stop(operation);
- response.success(true).message("Successfully stopped application " + entity.getUuid());
+ response.success(true).message("Stopping application " + entity.getUuid());
}).get();
}
+
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/039bf25d/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/ApplicationManagementService.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/ApplicationManagementService.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/ApplicationManagementService.java
index b93bb77..e5a7e0c 100644
--- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/ApplicationManagementService.java
+++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/ApplicationManagementService.java
@@ -16,6 +16,7 @@
*/
package org.apache.eagle.app.service;
+import org.apache.eagle.metadata.exceptions.ApplicationWrongStatusException;
import org.apache.eagle.metadata.exceptions.EntityNotFoundException;
import org.apache.eagle.metadata.model.ApplicationEntity;
@@ -34,7 +35,7 @@ public interface ApplicationManagementService {
* @param operation
* @return
*/
- ApplicationEntity uninstall(ApplicationOperations.UninstallOperation operation);
+ ApplicationEntity uninstall(ApplicationOperations.UninstallOperation operation) throws ApplicationWrongStatusException;
/**
* Start application.
@@ -42,7 +43,7 @@ public interface ApplicationManagementService {
* @param operation
* @return
*/
- ApplicationEntity start(ApplicationOperations.StartOperation operation);
+ ApplicationEntity start(ApplicationOperations.StartOperation operation) throws ApplicationWrongStatusException;
/**
* Stop application.
@@ -50,5 +51,14 @@ public interface ApplicationManagementService {
* @param operation
* @return
*/
- ApplicationEntity stop(ApplicationOperations.StopOperation operation);
+ ApplicationEntity stop(ApplicationOperations.StopOperation operation) throws ApplicationWrongStatusException;
+
+ /**
+ * get application status.
+ *
+ * @param operation
+ * @return
+ */
+ ApplicationEntity.Status getStatus(ApplicationOperations.CheckStatusOperation operation) throws EntityNotFoundException;
+
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/039bf25d/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/ApplicationOperationContext.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/ApplicationOperationContext.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/ApplicationOperationContext.java
index 82ca659..b4ae9dd 100644
--- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/ApplicationOperationContext.java
+++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/ApplicationOperationContext.java
@@ -24,7 +24,6 @@ import org.apache.eagle.alert.engine.scheme.JsonStringStreamNameSelector;
import org.apache.eagle.alert.metadata.IMetadataDao;
import org.apache.eagle.app.Application;
import org.apache.eagle.app.ApplicationLifecycle;
-import org.apache.eagle.app.StaticWebApplication;
import org.apache.eagle.app.environment.ExecutionRuntime;
import org.apache.eagle.app.environment.ExecutionRuntimeManager;
import org.apache.eagle.app.sink.KafkaStreamSinkConfig;
@@ -147,6 +146,10 @@ public class ApplicationOperationContext implements Serializable, ApplicationLif
this.runtime.stop(this.application, this.config);
}
+ public ApplicationEntity.Status getStatus() {
+ return this.runtime.status(this.application, this.config);
+ }
+
public ApplicationEntity getMetadata() {
return metadata;
}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/039bf25d/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/ApplicationOperations.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/ApplicationOperations.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/ApplicationOperations.java
index 8717f83..36c08b8 100644
--- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/ApplicationOperations.java
+++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/ApplicationOperations.java
@@ -52,10 +52,18 @@ public final class ApplicationOperations {
this.setMode(mode);
}
- public InstallOperation(String siteId, String appType, ApplicationEntity.Mode mode, Map<String, Object> configuration) {
+ public InstallOperation(String siteId, String appType, ApplicationEntity.Mode mode, String jarPath) {
this.setSiteId(siteId);
this.setAppType(appType);
this.setMode(mode);
+ this.setJarPath(jarPath);
+ }
+
+ public InstallOperation(String siteId, String appType, ApplicationEntity.Mode mode, String jarPath, Map<String, Object> configuration) {
+ this.setSiteId(siteId);
+ this.setAppType(appType);
+ this.setMode(mode);
+ this.setJarPath(jarPath);
this.setConfiguration(configuration);
}
@@ -218,4 +226,42 @@ public final class ApplicationOperations {
return STOP;
}
}
+
+ public static class CheckStatusOperation implements Operation {
+ private String uuid;
+ private String appId;
+
+ public CheckStatusOperation() {
+ }
+
+ public CheckStatusOperation(String uuid) {
+ this.setUuid(uuid);
+ }
+
+ public CheckStatusOperation(String uuid, String appId) {
+ this.setUuid(uuid);
+ this.setAppId(appId);
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public String getAppId() {
+ return appId;
+ }
+
+ public void setAppId(String appId) {
+ this.appId = appId;
+ }
+
+ @Override
+ public String getType() {
+ return START;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/039bf25d/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationManagementServiceImpl.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationManagementServiceImpl.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationManagementServiceImpl.java
index ffede54..04a7007 100644
--- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationManagementServiceImpl.java
+++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationManagementServiceImpl.java
@@ -26,6 +26,7 @@ import org.apache.eagle.app.service.ApplicationOperations;
import org.apache.eagle.app.service.ApplicationOperationContext;
import org.apache.eagle.app.service.ApplicationProviderService;
import org.apache.eagle.app.spi.ApplicationProvider;
+import org.apache.eagle.metadata.exceptions.ApplicationWrongStatusException;
import org.apache.eagle.metadata.exceptions.EntityNotFoundException;
import org.apache.eagle.metadata.model.*;
import org.apache.eagle.metadata.service.ApplicationEntityService;
@@ -117,38 +118,100 @@ public class ApplicationManagementServiceImpl implements ApplicationManagementSe
}
@Override
- public ApplicationEntity uninstall(ApplicationOperations.UninstallOperation operation) {
+ public ApplicationEntity uninstall(ApplicationOperations.UninstallOperation operation) throws ApplicationWrongStatusException {
ApplicationEntity applicationEntity = applicationEntityService.getByUUIDOrAppId(operation.getUuid(), operation.getAppId());
ApplicationOperationContext applicationOperationContext = new ApplicationOperationContext(
applicationProviderService.getApplicationProviderByType(applicationEntity.getDescriptor().getType()).getApplication(),
applicationEntity, config, alertMetadataService);
- // TODO: Check status, skip stop if already STOPPED
+
+ ApplicationEntity.Status currentStatus = applicationEntity.getStatus();
try {
- applicationOperationContext.onStop();
+ if (currentStatus == ApplicationEntity.Status.INITIALIZED || currentStatus == ApplicationEntity.Status.STOPPED) {
+ applicationOperationContext.onUninstall();
+ return applicationEntityService.delete(applicationEntity);
+ } else {
+ throw new ApplicationWrongStatusException("App: " + applicationEntity.getAppId() + " status is" + currentStatus + ", uninstall operation is not allowed");
+ }
} catch (Throwable throwable) {
LOGGER.error(throwable.getMessage(), throwable);
+ throw throwable;
}
- applicationOperationContext.onUninstall();
- return applicationEntityService.delete(applicationEntity);
}
@Override
- public ApplicationEntity start(ApplicationOperations.StartOperation operation) {
+ public ApplicationEntity start(ApplicationOperations.StartOperation operation) throws ApplicationWrongStatusException {
ApplicationEntity applicationEntity = applicationEntityService.getByUUIDOrAppId(operation.getUuid(), operation.getAppId());
- ApplicationOperationContext applicationOperationContext = new ApplicationOperationContext(
- applicationProviderService.getApplicationProviderByType(applicationEntity.getDescriptor().getType()).getApplication(),
- applicationEntity, config, alertMetadataService);
- applicationOperationContext.onStart();
- return applicationEntity;
+ ApplicationEntity.Status currentStatus = applicationEntity.getStatus();
+ try {
+ if (currentStatus == ApplicationEntity.Status.INITIALIZED || currentStatus == ApplicationEntity.Status.STOPPED) {
+ ApplicationOperationContext applicationOperationContext = new ApplicationOperationContext(
+ applicationProviderService.getApplicationProviderByType(applicationEntity.getDescriptor().getType()).getApplication(),
+ applicationEntity, config, alertMetadataService);
+
+ applicationOperationContext.onStart();
+ //Only when topology submitted successfully can the state change to STARTING
+ applicationEntityService.delete(applicationEntity);
+ applicationEntity.setStatus(ApplicationEntity.Status.STARTING);
+ return applicationEntityService.create(applicationEntity);
+ } else {
+ throw new ApplicationWrongStatusException("App: " + applicationEntity.getAppId() + " status is " + currentStatus + " start operation is not allowed");
+ }
+ } catch (ApplicationWrongStatusException e) {
+ LOGGER.error(e.getMessage(), e);
+ throw e;
+ } catch (Exception e) {
+ LOGGER.error("Failed to start app " + applicationEntity.getAppId(), e);
+ throw e;
+ } catch (Throwable throwable) {
+ LOGGER.error(throwable.getMessage(), throwable);
+ throw throwable;
+ }
+
}
@Override
- public ApplicationEntity stop(ApplicationOperations.StopOperation operation) {
+ public ApplicationEntity stop(ApplicationOperations.StopOperation operation) throws ApplicationWrongStatusException {
ApplicationEntity applicationEntity = applicationEntityService.getByUUIDOrAppId(operation.getUuid(), operation.getAppId());
ApplicationOperationContext applicationOperationContext = new ApplicationOperationContext(
applicationProviderService.getApplicationProviderByType(applicationEntity.getDescriptor().getType()).getApplication(),
applicationEntity, config, alertMetadataService);
- applicationOperationContext.onStop();
- return applicationEntity;
+ ApplicationEntity.Status currentStatus = applicationEntity.getStatus();
+ try {
+ if (currentStatus == ApplicationEntity.Status.RUNNING) {
+ applicationOperationContext.onStop();
+ //stop -> directly killed
+ applicationEntityService.delete(applicationEntity);
+ applicationEntity.setStatus(ApplicationEntity.Status.STOPPING);
+ return applicationEntityService.create(applicationEntity);
+ } else {
+ throw new ApplicationWrongStatusException("App: " + applicationEntity.getAppId() + " status is " + currentStatus + ", stop operation is not allowed.");
+ }
+ } catch (ApplicationWrongStatusException e) {
+ LOGGER.error(e.getMessage(), e);
+ throw e;
+ } catch (RuntimeException e) {
+ LOGGER.error("Failed to stop app " + applicationEntity.getAppId(), e);
+ throw e;
+ } catch (Throwable throwable) {
+ LOGGER.error(throwable.getMessage(), throwable);
+ throw throwable;
+ }
}
+
+ @Override
+ public ApplicationEntity.Status getStatus(ApplicationOperations.CheckStatusOperation operation) {
+ ApplicationEntity applicationEntity = null;
+ try {
+ applicationEntity = applicationEntityService.getByUUIDOrAppId(operation.getUuid(), operation.getAppId());
+ ApplicationOperationContext applicationOperationContext = new ApplicationOperationContext(
+ applicationProviderService.getApplicationProviderByType(applicationEntity.getDescriptor().getType()).getApplication(),
+ applicationEntity, config, alertMetadataService);
+ ApplicationEntity.Status topologyStatus = applicationOperationContext.getStatus();
+ return topologyStatus;
+ } catch (IllegalArgumentException e) {
+ LOGGER.error("application id not exist", e);
+ throw e;
+ }
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/039bf25d/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationStatusUpdateServiceImpl.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationStatusUpdateServiceImpl.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationStatusUpdateServiceImpl.java
new file mode 100644
index 0000000..2e7b6a2
--- /dev/null
+++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationStatusUpdateServiceImpl.java
@@ -0,0 +1,115 @@
+/**
+ * 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.service.impl;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.typesafe.config.Config;
+import com.typesafe.config.ConfigFactory;
+import org.apache.eagle.app.service.ApplicationOperations;
+import org.apache.eagle.metadata.model.ApplicationEntity;
+import org.apache.eagle.metadata.service.ApplicationEntityService;
+import org.apache.eagle.metadata.service.ApplicationStatusUpdateService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collection;
+import java.util.concurrent.TimeUnit;
+
+@Singleton
+public class ApplicationStatusUpdateServiceImpl extends ApplicationStatusUpdateService {
+ private static final Logger LOG = LoggerFactory.getLogger(ApplicationStatusUpdateServiceImpl.class);
+ private final ApplicationEntityService applicationEntityService;
+ private final ApplicationManagementServiceImpl applicationManagementService;
+
+ // default value 30, 30
+ private int initialDelay = 30;
+ private int period = 30;
+
+
+ @Inject
+ public ApplicationStatusUpdateServiceImpl(ApplicationEntityService applicationEntityService, ApplicationManagementServiceImpl applicationManagementService) {
+ this.applicationEntityService = applicationEntityService;
+ this.applicationManagementService = applicationManagementService;
+ }
+
+ @Override
+ protected void runOneIteration() throws Exception {
+ LOG.info("Checking app status");
+ try {
+ Collection<ApplicationEntity> applicationEntities = applicationEntityService.findAll();
+ for (ApplicationEntity applicationEntity: applicationEntities) {
+ updateApplicationEntityStatus(applicationEntity);
+ }
+ } catch (Exception e) {
+ LOG.error("failed to update app status", e);
+ }
+ }
+
+ @Override
+ protected Scheduler scheduler() {
+ return Scheduler.newFixedRateSchedule(initialDelay, period, TimeUnit.SECONDS);
+ }
+
+ @Override
+ public void updateApplicationEntityStatus(Collection<ApplicationEntity> applicationEntities) {}
+
+ @Override
+ public void updateApplicationEntityStatus(ApplicationEntity applicationEntity) {
+ String appUuid = applicationEntity.getUuid();
+ ApplicationEntity.Status currentStatus = applicationEntity.getStatus();
+ try {
+ ApplicationEntity.Status topologyStatus = applicationManagementService.getStatus(new ApplicationOperations.CheckStatusOperation(appUuid));
+ if (currentStatus == ApplicationEntity.Status.STARTING) {
+ if (topologyStatus == ApplicationEntity.Status.RUNNING) {
+ applicationEntityService.delete(applicationEntity);
+ applicationEntity.setStatus(ApplicationEntity.Status.RUNNING);
+ applicationEntityService.create(applicationEntity);
+ // handle the topology corruption case:
+ } else if (topologyStatus == ApplicationEntity.Status.REMOVED) {
+ applicationEntityService.delete(applicationEntity);
+ applicationEntity.setStatus(ApplicationEntity.Status.INITIALIZED);
+ applicationEntityService.create(applicationEntity);
+ }
+ } else if (currentStatus == ApplicationEntity.Status.STOPPING) {
+ if (topologyStatus == ApplicationEntity.Status.REMOVED) {
+ applicationEntityService.delete(applicationEntity);
+ applicationEntity.setStatus(ApplicationEntity.Status.INITIALIZED);
+ applicationEntityService.create(applicationEntity);
+ }
+ } else if (currentStatus == ApplicationEntity.Status.RUNNING) {
+ // handle the topology corruption case:
+ if (topologyStatus == ApplicationEntity.Status.REMOVED) {
+ applicationEntityService.delete(applicationEntity);
+ applicationEntity.setStatus(ApplicationEntity.Status.INITIALIZED);
+ applicationEntityService.create(applicationEntity);
+ }
+ } else if (currentStatus == ApplicationEntity.Status.INITIALIZED) {
+ //corner case: when Storm service go down, app status-> initialized,
+ //then when storm server is up again, storm topology will be launched automatically->active
+ if (topologyStatus == ApplicationEntity.Status.RUNNING) {
+ applicationEntityService.delete(applicationEntity);
+ applicationEntity.setStatus(ApplicationEntity.Status.RUNNING);
+ applicationEntityService.create(applicationEntity);
+ }
+ }
+ //"STOPPED" is not used in Eagle, so just do nothing.
+ } catch (RuntimeException e) {
+ LOG.error(e.getMessage(), e);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/039bf25d/eagle-core/eagle-metadata/eagle-metadata-base/src/main/java/org/apache/eagle/metadata/exceptions/ApplicationWrongStatusException.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-metadata/eagle-metadata-base/src/main/java/org/apache/eagle/metadata/exceptions/ApplicationWrongStatusException.java b/eagle-core/eagle-metadata/eagle-metadata-base/src/main/java/org/apache/eagle/metadata/exceptions/ApplicationWrongStatusException.java
new file mode 100644
index 0000000..c27446c
--- /dev/null
+++ b/eagle-core/eagle-metadata/eagle-metadata-base/src/main/java/org/apache/eagle/metadata/exceptions/ApplicationWrongStatusException.java
@@ -0,0 +1,31 @@
+/*
+ * 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.metadata.exceptions;
+
+public class ApplicationWrongStatusException extends Exception {
+ public ApplicationWrongStatusException(String message) {
+ super(message);
+ }
+
+ public ApplicationWrongStatusException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ApplicationWrongStatusException(Throwable cause) {
+ super(cause);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/039bf25d/eagle-core/eagle-metadata/eagle-metadata-base/src/main/java/org/apache/eagle/metadata/model/ApplicationEntity.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-metadata/eagle-metadata-base/src/main/java/org/apache/eagle/metadata/model/ApplicationEntity.java b/eagle-core/eagle-metadata/eagle-metadata-base/src/main/java/org/apache/eagle/metadata/model/ApplicationEntity.java
index 4e3f2bc..2e3c387 100644
--- a/eagle-core/eagle-metadata/eagle-metadata-base/src/main/java/org/apache/eagle/metadata/model/ApplicationEntity.java
+++ b/eagle-core/eagle-metadata/eagle-metadata-base/src/main/java/org/apache/eagle/metadata/model/ApplicationEntity.java
@@ -159,7 +159,10 @@ public class ApplicationEntity extends PersistenceEntity {
STARTING("STARTING"),
RUNNING("RUNNING"),
STOPPING("STOPPING"),
- STOPPED("STOPPED");
+ //Todo: currently "stopped" is not used, because "STOP" operation in Eagle equals to "KILL"
+ STOPPED("STOPPED"),
+ REMOVED("REMOVED"),
+ UNKNOWN("UNKNOWN");
private final String status;
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/039bf25d/eagle-core/eagle-metadata/eagle-metadata-base/src/main/java/org/apache/eagle/metadata/service/ApplicationStatusUpdateService.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-metadata/eagle-metadata-base/src/main/java/org/apache/eagle/metadata/service/ApplicationStatusUpdateService.java b/eagle-core/eagle-metadata/eagle-metadata-base/src/main/java/org/apache/eagle/metadata/service/ApplicationStatusUpdateService.java
new file mode 100644
index 0000000..bc34eb9
--- /dev/null
+++ b/eagle-core/eagle-metadata/eagle-metadata-base/src/main/java/org/apache/eagle/metadata/service/ApplicationStatusUpdateService.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
+ * <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.metadata.service;
+
+import com.google.common.util.concurrent.AbstractScheduledService;
+import org.apache.eagle.metadata.model.ApplicationEntity;
+
+import java.util.Collection;
+
+public abstract class ApplicationStatusUpdateService extends AbstractScheduledService {
+ public abstract void updateApplicationEntityStatus(Collection<ApplicationEntity> applicationEntities);
+ public abstract void updateApplicationEntityStatus(ApplicationEntity applicationEntity);
+ }
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/039bf25d/eagle-examples/eagle-app-example/src/test/java/org/apache/eagle/app/example/ExampleApplicationProviderTest.java
----------------------------------------------------------------------
diff --git a/eagle-examples/eagle-app-example/src/test/java/org/apache/eagle/app/example/ExampleApplicationProviderTest.java b/eagle-examples/eagle-app-example/src/test/java/org/apache/eagle/app/example/ExampleApplicationProviderTest.java
index 49e2487..a734421 100644
--- a/eagle-examples/eagle-app-example/src/test/java/org/apache/eagle/app/example/ExampleApplicationProviderTest.java
+++ b/eagle-examples/eagle-app-example/src/test/java/org/apache/eagle/app/example/ExampleApplicationProviderTest.java
@@ -28,6 +28,7 @@ import org.apache.eagle.metadata.model.ApplicationDesc;
import org.apache.eagle.metadata.model.ApplicationEntity;
import org.apache.eagle.metadata.model.SiteEntity;
import org.apache.eagle.metadata.resource.SiteResource;
+import org.apache.eagle.metadata.service.ApplicationStatusUpdateService;
import org.junit.Assert;
import org.junit.Test;
@@ -45,6 +46,8 @@ public class ExampleApplicationProviderTest extends ApplicationTestBase {
private ApplicationSimulator simulator;
@Inject
private ExampleResource exampleResource;
+ @Inject
+ ApplicationStatusUpdateService statusUpdateService;
@Test
public void testApplicationProviderLoading() {
@@ -86,8 +89,10 @@ public class ExampleApplicationProviderTest extends ApplicationTestBase {
ApplicationEntity applicationEntity = applicationResource.installApplication(installOperation).getData();
// Start application
applicationResource.startApplication(new ApplicationOperations.StartOperation(applicationEntity.getUuid()));
+ statusUpdateService.updateApplicationEntityStatus(applicationEntity);
// Stop application
applicationResource.stopApplication(new ApplicationOperations.StopOperation(applicationEntity.getUuid()));
+ statusUpdateService.updateApplicationEntityStatus(applicationEntity);
// Uninstall application
applicationResource.uninstallApplication(new ApplicationOperations.UninstallOperation(applicationEntity.getUuid()));
try {
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/039bf25d/eagle-jpm/eagle-jpm-web/src/test/java/org/apache/eagle/app/jpm/JPMWebApplicationTest.java
----------------------------------------------------------------------
diff --git a/eagle-jpm/eagle-jpm-web/src/test/java/org/apache/eagle/app/jpm/JPMWebApplicationTest.java b/eagle-jpm/eagle-jpm-web/src/test/java/org/apache/eagle/app/jpm/JPMWebApplicationTest.java
index 24c7660..00c6a91 100644
--- a/eagle-jpm/eagle-jpm-web/src/test/java/org/apache/eagle/app/jpm/JPMWebApplicationTest.java
+++ b/eagle-jpm/eagle-jpm-web/src/test/java/org/apache/eagle/app/jpm/JPMWebApplicationTest.java
@@ -24,6 +24,7 @@ import org.apache.eagle.metadata.model.SiteEntity;
import org.apache.eagle.metadata.resource.SiteResource;
import com.google.inject.Inject;
+import org.apache.eagle.metadata.service.ApplicationStatusUpdateService;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -38,6 +39,9 @@ public class JPMWebApplicationTest extends ApplicationTestBase {
@Inject
private ApplicationResource applicationResource;
+ @Inject
+ private ApplicationStatusUpdateService statusUpdateService;
+
private void installDependencies(){
ApplicationOperations.InstallOperation installDependency1 = new ApplicationOperations.InstallOperation("test_site", "MR_RUNNING_JOB_APP", ApplicationEntity.Mode.LOCAL);
installDependency1.setConfiguration(getConf());
@@ -74,12 +78,12 @@ public class JPMWebApplicationTest extends ApplicationTestBase {
// Install application
ApplicationEntity applicationEntity = applicationResource.installApplication(installOperation).getData();
-
+ //Todo: comment these for now, because they haven't been implemented
// Start application
- applicationResource.startApplication(new ApplicationOperations.StartOperation(applicationEntity.getUuid()));
- // Stop application
- applicationResource.stopApplication(new ApplicationOperations.StopOperation(applicationEntity.getUuid()));
- // Uninstall application
+// applicationResource.startApplication(new ApplicationOperations.StartOperation(applicationEntity.getUuid()));
+// // Stop application
+// applicationResource.stopApplication(new ApplicationOperations.StopOperation(applicationEntity.getUuid()));
+ //Uninstall application
applicationResource.uninstallApplication(new ApplicationOperations.UninstallOperation(applicationEntity.getUuid()));
try {
applicationResource.getApplicationEntityByUUID(applicationEntity.getUuid());
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/039bf25d/eagle-server/src/main/java/org/apache/eagle/server/ServerApplication.java
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/java/org/apache/eagle/server/ServerApplication.java b/eagle-server/src/main/java/org/apache/eagle/server/ServerApplication.java
index c22591f..2dc39b1 100644
--- a/eagle-server/src/main/java/org/apache/eagle/server/ServerApplication.java
+++ b/eagle-server/src/main/java/org/apache/eagle/server/ServerApplication.java
@@ -15,11 +15,15 @@
* limitations under the License.
*/
package org.apache.eagle.server;
-
+import com.google.inject.Injector;
+import com.hubspot.dropwizard.guice.GuiceBundle;
+import io.dropwizard.lifecycle.Managed;
import org.apache.eagle.alert.coordinator.CoordinatorListener;
import org.apache.eagle.alert.resource.SimpleCORSFiler;
import org.apache.eagle.log.base.taggedlog.EntityJsonModule;
import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
+import org.apache.eagle.metadata.service.ApplicationStatusUpdateService;
+import org.apache.eagle.server.managedtask.ApplicationTask;
import org.apache.eagle.server.module.GuiceBundleLoader;
import com.sun.jersey.api.core.PackagesResourceConfig;
@@ -34,9 +38,12 @@ import java.util.EnumSet;
import javax.servlet.DispatcherType;
class ServerApplication extends Application<ServerConfig> {
+ private GuiceBundle guiceBundle;
+
@Override
public void initialize(Bootstrap<ServerConfig> bootstrap) {
- bootstrap.addBundle(GuiceBundleLoader.load());
+ guiceBundle = GuiceBundleLoader.load();
+ bootstrap.addBundle(guiceBundle);
bootstrap.addBundle(new AssetsBundle("/assets", "/", "index.html", "/"));
}
@@ -74,5 +81,11 @@ class ServerApplication extends Application<ServerConfig> {
// context listener
environment.servlets().addServletListeners(new CoordinatorListener());
+
+ // run application status service in background
+ Injector injector = guiceBundle.getInjector();
+ ApplicationStatusUpdateService applicationStatusUpdateService = injector.getInstance(ApplicationStatusUpdateService.class);
+ Managed updateAppStatusTask = new ApplicationTask(applicationStatusUpdateService);
+ environment.lifecycle().manage(updateAppStatusTask);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/039bf25d/eagle-server/src/main/java/org/apache/eagle/server/managedtask/ApplicationTask.java
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/java/org/apache/eagle/server/managedtask/ApplicationTask.java b/eagle-server/src/main/java/org/apache/eagle/server/managedtask/ApplicationTask.java
new file mode 100644
index 0000000..d1173a8
--- /dev/null
+++ b/eagle-server/src/main/java/org/apache/eagle/server/managedtask/ApplicationTask.java
@@ -0,0 +1,43 @@
+/**
+ * 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.server.managedtask;
+
+import com.google.common.util.concurrent.AbstractScheduledService;
+import io.dropwizard.lifecycle.Managed;
+import org.apache.eagle.app.service.impl.ApplicationStatusUpdateServiceImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ApplicationTask implements Managed {
+ private final static Logger LOG = LoggerFactory.getLogger(ApplicationTask.class);
+ private final AbstractScheduledService service;
+
+ public ApplicationTask(AbstractScheduledService service){
+ this.service = service;
+ }
+
+ @Override
+ public void start() throws Exception {
+ LOG.info("Application update task started:");
+ service.startAsync().awaitRunning();
+ }
+
+ @Override
+ public void stop() throws Exception {
+ service.stopAsync().awaitTerminated();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/039bf25d/eagle-server/src/main/resources/application.conf
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/resources/application.conf b/eagle-server/src/main/resources/application.conf
index df482ac..f23f9f1 100644
--- a/eagle-server/src/main/resources/application.conf
+++ b/eagle-server/src/main/resources/application.conf
@@ -80,6 +80,10 @@ application {
nimbusHost = "server.eagle.apache.org"
nimbusThriftPort = 6627
}
+ updateStatus: {
+ initialDelay: 10
+ period: 10
+ }
}
# ---------------------------------------------