You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eagle.apache.org by ha...@apache.org on 2016/10/20 14:21:11 UTC
incubator-eagle git commit: [MINOR] Fix cobertura.totalLineRate as 25
and improve some UT
Repository: incubator-eagle
Updated Branches:
refs/heads/master 538e88f71 -> 49db82c5e
[MINOR] Fix cobertura.totalLineRate as 25 and improve some UT
[MINOR] Fix `cobertura.totalLineRate` as 25 and improve some unit test cases
Author: Hao Chen <ha...@apache.org>
Closes #543 from haoch/FixCoberturaRatioAndAddUT.
Project: http://git-wip-us.apache.org/repos/asf/incubator-eagle/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-eagle/commit/49db82c5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-eagle/tree/49db82c5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-eagle/diff/49db82c5
Branch: refs/heads/master
Commit: 49db82c5e129c7dc1d0bd5932c97518891c6158e
Parents: 538e88f
Author: Hao Chen <ha...@apache.org>
Authored: Thu Oct 20 22:21:01 2016 +0800
Committer: Hao Chen <ha...@apache.org>
Committed: Thu Oct 20 22:21:01 2016 +0800
----------------------------------------------------------------------
.../app/AlertUnitTopologyAppProviderTest.java | 69 ++++++++++++++++
.../src/test/resource/application.conf | 65 +++++++++++++++
.../eagle/alert/model/StreamEventTest.java | 68 ++++++++++++++++
.../correlation/meta/StreamPartitionTest.java | 36 +++++++++
.../org/apache/eagle/app/StaticApplication.java | 10 +--
.../environment/ExecutionRuntimeManager.java | 2 +-
.../app/environment/impl/StaticEnvironment.java | 39 +++++++++
.../impl/StaticExecutionRuntime.java | 68 ++++++++++++++++
.../app/environment/impl/WebEnvironment.java | 39 ---------
.../environment/impl/WebExecutionRuntime.java | 68 ----------------
.../app/test/ApplicationSimulatorImpl.java | 6 +-
.../app/environment/StaticEnvironmentTest.java | 35 +++++++++
.../app/resource/ApplicationResourceTest.java | 83 ++++++++++++++++++++
.../eagle/common/TestSerializableUtils.java | 53 +++++++++++++
pom.xml | 4 +
15 files changed, 528 insertions(+), 117 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/49db82c5/eagle-core/eagle-alert-parent/eagle-alert-app/src/test/java/org/apache/eagle/alert/app/AlertUnitTopologyAppProviderTest.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert-app/src/test/java/org/apache/eagle/alert/app/AlertUnitTopologyAppProviderTest.java b/eagle-core/eagle-alert-parent/eagle-alert-app/src/test/java/org/apache/eagle/alert/app/AlertUnitTopologyAppProviderTest.java
new file mode 100644
index 0000000..927d505
--- /dev/null
+++ b/eagle-core/eagle-alert-parent/eagle-alert-app/src/test/java/org/apache/eagle/alert/app/AlertUnitTopologyAppProviderTest.java
@@ -0,0 +1,69 @@
+/*
+ * 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.alert.app;
+
+import com.google.inject.Inject;
+import org.apache.eagle.app.resource.ApplicationResource;
+import org.apache.eagle.app.service.ApplicationOperations;
+import org.apache.eagle.app.test.ApplicationTestBase;
+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.Ignore;
+import org.junit.Test;
+
+@Ignore
+public class AlertUnitTopologyAppProviderTest extends ApplicationTestBase {
+
+ @Inject
+ private SiteResource siteResource;
+ @Inject
+ private ApplicationResource applicationResource;
+ @Inject
+ ApplicationStatusUpdateService statusUpdateService;
+
+ @Test
+ public void testApplicationLifecycle() throws InterruptedException {
+ // Create local site
+ SiteEntity siteEntity = new SiteEntity();
+ siteEntity.setSiteId("test_site");
+ siteEntity.setSiteName("Test Site");
+ siteEntity.setDescription("Test Site for ExampleApplicationProviderTest");
+ siteResource.createSite(siteEntity);
+ Assert.assertNotNull(siteEntity.getUuid());
+
+ ApplicationOperations.InstallOperation installOperation = new ApplicationOperations.InstallOperation("test_site", "AlertUnitTopologyApp", ApplicationEntity.Mode.LOCAL);
+ // Install application
+ 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 {
+ applicationResource.getApplicationEntityByUUID(applicationEntity.getUuid());
+ Assert.fail("Application instance (UUID: " + applicationEntity.getUuid() + ") should have been uninstalled");
+ } catch (Exception ex) {
+ // Expected exception
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/49db82c5/eagle-core/eagle-alert-parent/eagle-alert-app/src/test/resource/application.conf
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert-app/src/test/resource/application.conf b/eagle-core/eagle-alert-parent/eagle-alert-app/src/test/resource/application.conf
new file mode 100644
index 0000000..cfb2d47
--- /dev/null
+++ b/eagle-core/eagle-alert-parent/eagle-alert-app/src/test/resource/application.conf
@@ -0,0 +1,65 @@
+# 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.
+# 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.
+
+{
+ "coordinator": {
+ "policiesPerBolt": 5,
+ "boltParallelism": 5,
+ "policyDefaultParallelism": 5,
+ "boltLoadUpbound": 0.8,
+ "topologyLoadUpbound": 0.8,
+ "numOfAlertBoltsPerTopology": 5,
+ "zkConfig": {
+ "zkQuorum": "localhost:2181",
+ "zkRoot": "/alert",
+ "zkSessionTimeoutMs": 10000,
+ "connectionTimeoutMs": 10000,
+ "zkRetryTimes": 3,
+ "zkRetryInterval": 3000
+ }
+ "metadataService": {
+ "host": "localhost",
+ "port": 8080,
+ "context": "/rest"
+ }
+ "metadataDynamicCheck": {
+ "initDelayMillis": 1000,
+ "delayMillis": 30000
+ },
+ "kafkaProducer": {
+ "bootstrapServers": "localhost:9092"
+ },
+ "email": {
+ "sender": "eagle@eagle.com",
+ "recipients": "test@eagle.com",
+ "mailSmtpHost": "test.eagle.com",
+ "mailSmtpPort": "25"
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/49db82c5/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/model/StreamEventTest.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/model/StreamEventTest.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/model/StreamEventTest.java
new file mode 100644
index 0000000..e8ec1ad
--- /dev/null
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/model/StreamEventTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.alert.model;
+
+import org.apache.eagle.alert.engine.coordinator.StreamColumn;
+import org.apache.eagle.alert.engine.coordinator.StreamDefinition;
+import org.apache.eagle.alert.engine.model.StreamEvent;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+public class StreamEventTest {
+ @Test
+ public void testStreamEventEqual() {
+ Long timestamp = System.currentTimeMillis();
+ StreamEvent event1 = mockSimpleStreamEvent(timestamp);
+ StreamEvent event2 = mockSimpleStreamEvent(timestamp);
+ StreamEvent event3 = event2.copy();
+ Assert.assertEquals(event1, event2);
+ Assert.assertEquals(event2, event3);
+ }
+
+ private static StreamEvent mockSimpleStreamEvent(Long timestamp) {
+ return StreamEvent.builder()
+ .schema(mockStreamDefinition("sampleStream_1"))
+ .streamId("sampleStream_1")
+ .timestamep(timestamp)
+ .attributes(new HashMap<String, Object>() {{
+ put("name", "cpu");
+ put("value", 60.0);
+ put("unknown", "unknown column value");
+ }}).build();
+ }
+
+ private static StreamDefinition mockStreamDefinition(String streamId) {
+ StreamDefinition sampleStreamDefinition = new StreamDefinition();
+ List<StreamColumn> streamColumns = new ArrayList<>();
+ streamColumns.add(new StreamColumn.Builder().name("name").type(StreamColumn.Type.STRING).build());
+ streamColumns.add(new StreamColumn.Builder().name("host").type(StreamColumn.Type.STRING).build());
+ streamColumns.add(new StreamColumn.Builder().name("flag").type(StreamColumn.Type.BOOL).build());
+ streamColumns.add(new StreamColumn.Builder().name("timestamp").type(StreamColumn.Type.LONG).build());
+ streamColumns.add(new StreamColumn.Builder().name("value").type(StreamColumn.Type.DOUBLE).build());
+
+ sampleStreamDefinition.setStreamId(streamId);
+ sampleStreamDefinition.setTimeseries(true);
+ sampleStreamDefinition.setValidate(true);
+ sampleStreamDefinition.setDescription("Schema for " + streamId);
+ sampleStreamDefinition.setColumns(streamColumns);
+ return sampleStreamDefinition;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/49db82c5/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/correlation/meta/StreamPartitionTest.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/correlation/meta/StreamPartitionTest.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/correlation/meta/StreamPartitionTest.java
new file mode 100644
index 0000000..524f76a
--- /dev/null
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/correlation/meta/StreamPartitionTest.java
@@ -0,0 +1,36 @@
+/*
+ * 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.correlation.meta;
+
+import org.apache.eagle.alert.engine.coordinator.StreamPartition;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Arrays;
+
+public class StreamPartitionTest {
+ @Test
+ public void testStreamPartitionEqual(){
+ StreamPartition partition1 = new StreamPartition();
+ partition1.setStreamId("unittest");
+ partition1.setColumns(Arrays.asList("col1","col2"));
+ StreamPartition partition2 = new StreamPartition();
+ partition2.setStreamId("unittest");
+ partition2.setColumns(Arrays.asList("col1","col2"));
+ Assert.assertTrue(partition1.equals(partition2));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/49db82c5/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/StaticApplication.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/StaticApplication.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/StaticApplication.java
index 116d658..2aecb7e 100644
--- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/StaticApplication.java
+++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/StaticApplication.java
@@ -18,14 +18,14 @@ package org.apache.eagle.app;
import com.typesafe.config.Config;
import org.apache.eagle.app.environment.impl.StaticApplicationExecutor;
-import org.apache.eagle.app.environment.impl.WebEnvironment;
+import org.apache.eagle.app.environment.impl.StaticEnvironment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Static Application without executable process.
*/
-public class StaticApplication implements Application<WebEnvironment, StaticApplicationExecutor> {
+public class StaticApplication implements Application<StaticEnvironment, StaticApplicationExecutor> {
private static final Logger LOGGER = LoggerFactory.getLogger(StaticApplication.class);
private final String name;
@@ -34,14 +34,14 @@ public class StaticApplication implements Application<WebEnvironment, StaticAppl
}
@Override
- public StaticApplicationExecutor execute(Config config, WebEnvironment environment) {
+ public StaticApplicationExecutor execute(Config config, StaticEnvironment environment) {
LOGGER.warn("Executing Static application");
return new StaticApplicationExecutor(this);
}
@Override
- public Class<? extends WebEnvironment> getEnvironmentType() {
- return WebEnvironment.class;
+ public Class<? extends StaticEnvironment> getEnvironmentType() {
+ return StaticEnvironment.class;
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/49db82c5/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/ExecutionRuntimeManager.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/ExecutionRuntimeManager.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/ExecutionRuntimeManager.java
index d51b8b5..f75a798 100644
--- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/ExecutionRuntimeManager.java
+++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/ExecutionRuntimeManager.java
@@ -39,7 +39,7 @@ public class ExecutionRuntimeManager {
static {
getInstance().register(StormEnvironment.class, new StormExecutionRuntime.Provider());
getInstance().register(SparkEnvironment.class, new SparkExecutionRuntime.Provider());
- getInstance().register(WebEnvironment.class, new WebExecutionRuntime.Provider());
+ getInstance().register(StaticEnvironment.class, new StaticExecutionRuntime.Provider());
}
private final Map<Class<? extends Environment>, ExecutionRuntimeProvider> executionRuntimeProviders;
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/49db82c5/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/StaticEnvironment.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/StaticEnvironment.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/StaticEnvironment.java
new file mode 100644
index 0000000..1c297fb
--- /dev/null
+++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/StaticEnvironment.java
@@ -0,0 +1,39 @@
+/*
+ * 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.environment.impl;
+
+import com.typesafe.config.Config;
+import org.apache.eagle.app.environment.Environment;
+import org.apache.eagle.app.sink.StreamSinkProvider;
+
+public class StaticEnvironment implements Environment {
+ private final Config config;
+
+ public StaticEnvironment(Config config) {
+ this.config = config;
+ }
+
+ @Override
+ public Config config() {
+ return this.config;
+ }
+
+ @Override
+ public StreamSinkProvider streamSink() {
+ throw new IllegalStateException("streamSink() is not supported in " + StaticEnvironment.class.getSimpleName());
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/49db82c5/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/StaticExecutionRuntime.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/StaticExecutionRuntime.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/StaticExecutionRuntime.java
new file mode 100644
index 0000000..b6e3fed
--- /dev/null
+++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/StaticExecutionRuntime.java
@@ -0,0 +1,68 @@
+/*
+ * 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.environment.impl;
+
+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;
+
+/**
+ * StaticExecutionRuntime.
+ */
+public class StaticExecutionRuntime implements ExecutionRuntime<StaticEnvironment,StaticApplicationExecutor> {
+ private static final Logger LOGGER = LoggerFactory.getLogger(StaticExecutionRuntime.class);
+
+ private StaticEnvironment environment;
+
+ @Override
+ public void prepare(StaticEnvironment environment) {
+ this.environment = environment;
+ }
+
+ @Override
+ public StaticEnvironment environment() {
+ return this.environment;
+ }
+
+ @Override
+ public void start(Application<StaticEnvironment, StaticApplicationExecutor> executor, Config config) {
+ LOGGER.warn("Starting {}, do nothing",executor);
+ }
+
+ @Override
+ public void stop(Application<StaticEnvironment, StaticApplicationExecutor> executor, Config config) {
+ LOGGER.warn("Stopping {}, do nothing",executor);
+ }
+
+ @Override
+ public ApplicationEntity.Status status(Application<StaticEnvironment, StaticApplicationExecutor> executor, Config config) {
+ LOGGER.warn("Checking status {}, do nothing",executor);
+ return ApplicationEntity.Status.INITIALIZED;
+ }
+
+ public static class Provider implements ExecutionRuntimeProvider<StaticEnvironment,StaticApplicationExecutor> {
+ @Override
+ public ExecutionRuntime<StaticEnvironment, StaticApplicationExecutor> get() {
+ return new StaticExecutionRuntime();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/49db82c5/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/WebEnvironment.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/WebEnvironment.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/WebEnvironment.java
deleted file mode 100644
index 2bb8dc7..0000000
--- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/WebEnvironment.java
+++ /dev/null
@@ -1,39 +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
- * <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.environment.impl;
-
-import com.typesafe.config.Config;
-import org.apache.eagle.app.environment.Environment;
-import org.apache.eagle.app.sink.StreamSinkProvider;
-
-public class WebEnvironment implements Environment {
- private final Config config;
-
- public WebEnvironment(Config config) {
- this.config = config;
- }
-
- @Override
- public Config config() {
- return this.config;
- }
-
- @Override
- public StreamSinkProvider streamSink() {
- throw new IllegalStateException("streamSink() is not supported in " + WebEnvironment.class.getSimpleName());
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/49db82c5/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
deleted file mode 100644
index 7426c1c..0000000
--- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/impl/WebExecutionRuntime.java
+++ /dev/null
@@ -1,68 +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
- * <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.environment.impl;
-
-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;
-
-/**
- * WebExecutionRuntime.
- */
-public class WebExecutionRuntime implements ExecutionRuntime<WebEnvironment,StaticApplicationExecutor> {
- private static final Logger LOGGER = LoggerFactory.getLogger(WebExecutionRuntime.class);
-
- private WebEnvironment environment;
-
- @Override
- public void prepare(WebEnvironment environment) {
- this.environment = environment;
- }
-
- @Override
- public WebEnvironment environment() {
- return this.environment;
- }
-
- @Override
- public void start(Application<WebEnvironment, StaticApplicationExecutor> executor, Config config) {
- LOGGER.warn("Starting {}, do nothing",executor);
- }
-
- @Override
- public void stop(Application<WebEnvironment, StaticApplicationExecutor> executor, Config config) {
- LOGGER.warn("Stopping {}, do nothing",executor);
- }
-
- @Override
- public ApplicationEntity.Status status(Application<WebEnvironment, StaticApplicationExecutor> executor, Config config) {
- LOGGER.warn("Checking status {}, do nothing",executor);
- return ApplicationEntity.Status.INITIALIZED;
- }
-
- public static class Provider implements ExecutionRuntimeProvider<WebEnvironment,StaticApplicationExecutor> {
- @Override
- public ExecutionRuntime<WebEnvironment, StaticApplicationExecutor> get() {
- return new WebExecutionRuntime();
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/49db82c5/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationSimulatorImpl.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationSimulatorImpl.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationSimulatorImpl.java
index 1abdb6b..bc66ab4 100644
--- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationSimulatorImpl.java
+++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationSimulatorImpl.java
@@ -16,16 +16,14 @@
*/
package org.apache.eagle.app.test;
-import org.apache.eagle.app.config.ApplicationProviderConfig;
+import com.google.inject.Inject;
+import com.typesafe.config.Config;
import org.apache.eagle.app.resource.ApplicationResource;
import org.apache.eagle.app.service.ApplicationOperations;
import org.apache.eagle.app.spi.ApplicationProvider;
-import org.apache.eagle.app.utils.DynamicJarPathFinder;
import org.apache.eagle.metadata.model.ApplicationEntity;
import org.apache.eagle.metadata.model.SiteEntity;
import org.apache.eagle.metadata.resource.SiteResource;
-import com.google.inject.Inject;
-import com.typesafe.config.Config;
import org.junit.Assert;
import java.util.HashMap;
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/49db82c5/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/environment/StaticEnvironmentTest.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/environment/StaticEnvironmentTest.java b/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/environment/StaticEnvironmentTest.java
new file mode 100644
index 0000000..797eba8
--- /dev/null
+++ b/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/environment/StaticEnvironmentTest.java
@@ -0,0 +1,35 @@
+/*
+ * 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.environment;
+
+import org.apache.eagle.app.environment.impl.StaticEnvironment;
+import org.junit.Before;
+import org.junit.Test;
+
+public class StaticEnvironmentTest {
+ private StaticEnvironment environment;
+
+ @Before
+ public void setUp(){
+ environment = new StaticEnvironment(null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testNotSupport(){
+ environment.streamSink();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/49db82c5/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/resource/ApplicationResourceTest.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/resource/ApplicationResourceTest.java b/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/resource/ApplicationResourceTest.java
new file mode 100644
index 0000000..59925fd
--- /dev/null
+++ b/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/resource/ApplicationResourceTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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.resource;
+
+import com.google.inject.Inject;
+import org.apache.eagle.app.service.ApplicationOperations;
+import org.apache.eagle.app.test.ApplicationTestBase;
+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.Ignore;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Ignore
+public class ApplicationResourceTest extends ApplicationTestBase {
+
+ @Inject
+ private SiteResource siteResource;
+ @Inject
+ private ApplicationResource applicationResource;
+ @Inject
+ ApplicationStatusUpdateService statusUpdateService;
+
+ @Test
+ public void testApplicationLifecycle() throws InterruptedException {
+ // Create local site
+ SiteEntity siteEntity = new SiteEntity();
+ siteEntity.setSiteId("test_site");
+ siteEntity.setSiteName("Test Site");
+ siteEntity.setDescription("Test Site for ExampleApplicationProviderTest");
+ siteResource.createSite(siteEntity);
+ Assert.assertNotNull(siteEntity.getUuid());
+
+ ApplicationOperations.InstallOperation installOperation = new ApplicationOperations.InstallOperation("test_site", "TEST_APPLICATION", ApplicationEntity.Mode.LOCAL);
+ installOperation.setConfiguration(getConf());
+ // Install application
+ 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 {
+ applicationResource.getApplicationEntityByUUID(applicationEntity.getUuid());
+ Assert.fail("Application instance (UUID: " + applicationEntity.getUuid() + ") should have been uninstalled");
+ } catch (Exception ex) {
+ // Expected exception
+ }
+ }
+
+ private Map<String, Object> getConf() {
+ Map<String, Object> conf = new HashMap<>();
+ conf.put("dataSinkConfig.topic", "testTopic");
+ conf.put("dataSinkConfig.brokerList", "broker");
+ conf.put("dataSinkConfig.serializerClass", "serializerClass");
+ conf.put("dataSinkConfig.keySerializerClass", "keySerializerClass");
+ conf.put("spoutNum", 2);
+ conf.put("mode", "LOCAL");
+ return conf;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/49db82c5/eagle-core/eagle-common/src/test/java/org/apache/eagle/common/TestSerializableUtils.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-common/src/test/java/org/apache/eagle/common/TestSerializableUtils.java b/eagle-core/eagle-common/src/test/java/org/apache/eagle/common/TestSerializableUtils.java
new file mode 100644
index 0000000..4404258
--- /dev/null
+++ b/eagle-core/eagle-common/src/test/java/org/apache/eagle/common/TestSerializableUtils.java
@@ -0,0 +1,53 @@
+/*
+ * 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.common;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.Serializable;
+
+public class TestSerializableUtils {
+ @Test
+ public void testSerializeObject(){
+ SerializableUtils.ensureSerializable(0.5);
+ byte[] bytes = SerializableUtils.serializeToByteArray(0.5);
+ Assert.assertNotNull(bytes);
+ Assert.assertEquals(0.5,SerializableUtils.deserializeFromByteArray(bytes,"0.5"));
+ }
+ @Test
+ public void testSerializeObjectWithCompression(){
+ SerializableUtils.ensureSerializable(0.5);
+ byte[] bytes = SerializableUtils.serializeToCompressedByteArray(0.5);
+ Assert.assertNotNull(bytes);
+ Assert.assertEquals(0.5,SerializableUtils.deserializeFromCompressedByteArray(bytes,"0.5"));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testUnserializableObject(){
+ SerializableUtils.serializeToByteArray(new Object());
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testEnsureUnserializableObject(){
+ SerializableUtils.ensureSerializable(new UnserializablePOJO());
+ }
+
+ private class UnserializablePOJO implements Serializable {
+ private Object obj;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/49db82c5/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index ae97bb3..f2e08ef 100755
--- a/pom.xml
+++ b/pom.xml
@@ -1154,6 +1154,10 @@
<maxmem>256m</maxmem>
<!-- aggregated reports for multi-module projects -->
<aggregate>true</aggregate>
+ <check>
+ <totalBranchRate>25</totalBranchRate>
+ <totalLineRate>25</totalLineRate>
+ </check>
</configuration>
<dependencies>
<!--Use asm-5.0 to support Java 8-->