[GitHub] incubator-eagle pull request #732: [EAGLE-837] Stream definition change does...

2016-12-15 Thread garrettlish
Github user garrettlish commented on a diff in the pull request:

https://github.com/apache/incubator-eagle/pull/732#discussion_r92740230
  
--- Diff: 
eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/java/org/apache/eagle/alert/engine/router/TestAlertBolt.java
 ---
@@ -443,6 +447,83 @@ public void reportError(Throwable error) {
 
 Assert.assertTrue(recieved.get());
 }
+
+@Test
+public void testStreamDefinitionChange() throws IOException {
+PolicyDefinition def = new PolicyDefinition();
+def.setName("policy-definition");
+def.setInputStreams(Arrays.asList(TEST_STREAM));
+
+PolicyDefinition.Definition definition = new 
PolicyDefinition.Definition();
+definition.setType(PolicyStreamHandlers.CUSTOMIZED_ENGINE);
+
definition.setHandlerClass("org.apache.eagle.alert.engine.router.CustomizedHandler");
+definition.setValue("PT0M,plain,1,host,host1");
+def.setDefinition(definition);
+def.setPartitionSpec(Arrays.asList(createPartition()));
+
+AlertBoltSpec boltSpecs = new AlertBoltSpec();
+
+AtomicBoolean recieved = new AtomicBoolean(false);
+OutputCollector collector = new OutputCollector(new 
IOutputCollector() {
+@Override
+public List emit(String streamId, Collection 
anchors, List tuple) {
+recieved.set(true);
+return Collections.emptyList();
+}
+
+@Override
+public void emitDirect(int taskId, String streamId, 
Collection anchors, List tuple) {
+}
+
+@Override
+public void ack(Tuple input) {
+}
+
+@Override
+public void fail(Tuple input) {
+}
+
+@Override
+public void reportError(Throwable error) {
+}
+});
+AlertBolt bolt = createAlertBolt(collector);
+
+boltSpecs.getBoltPoliciesMap().put(bolt.getBoltId(), 
Arrays.asList(def));
+boltSpecs.setVersion("spec_" + System.currentTimeMillis());
+// stream def map
+Map sds = new HashMap();
+StreamDefinition sdTest = new StreamDefinition();
+sdTest.setStreamId(TEST_STREAM);
+sds.put(sdTest.getStreamId(), sdTest);
+
+boltSpecs.addPublishPartition(TEST_STREAM, "policy-definition", 
"testAlertPublish", null);
+
+bolt.onAlertBoltSpecChange(boltSpecs, sds);
+
+// how to assert
+Tuple t = createTuple(bolt, boltSpecs.getVersion());
+
+bolt.execute(t);
+
+Assert.assertTrue(recieved.get());
+
+LOG.info("Update stream");
+sds = new HashMap();
+sdTest = new StreamDefinition();
+sdTest.setStreamId(TEST_STREAM);
+sds.put(sdTest.getStreamId(), sdTest);
+sdTest.setDescription("update the stream");
+bolt.onAlertBoltSpecChange(boltSpecs, sds);
+
+LOG.info("No any change");
+sds = new HashMap();
+sdTest = new StreamDefinition();
+sdTest.setStreamId(TEST_STREAM);
+sds.put(sdTest.getStreamId(), sdTest);
+sdTest.setDescription("update the stream");
+bolt.onAlertBoltSpecChange(boltSpecs, sds);
--- End diff --

asserts updated in https://github.com/apache/incubator-eagle/pull/738


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-eagle pull request #732: [EAGLE-837] Stream definition change does...

2016-12-15 Thread garrettlish
Github user garrettlish closed the pull request at:

https://github.com/apache/incubator-eagle/pull/732


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-eagle pull request #732: [EAGLE-837] Stream definition change does...

2016-12-13 Thread wujinhu
Github user wujinhu commented on a diff in the pull request:

https://github.com/apache/incubator-eagle/pull/732#discussion_r92129224
  
--- Diff: 
eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/java/org/apache/eagle/alert/engine/router/TestAlertBolt.java
 ---
@@ -443,6 +447,83 @@ public void reportError(Throwable error) {
 
 Assert.assertTrue(recieved.get());
 }
+
+@Test
+public void testStreamDefinitionChange() throws IOException {
+PolicyDefinition def = new PolicyDefinition();
+def.setName("policy-definition");
+def.setInputStreams(Arrays.asList(TEST_STREAM));
+
+PolicyDefinition.Definition definition = new 
PolicyDefinition.Definition();
+definition.setType(PolicyStreamHandlers.CUSTOMIZED_ENGINE);
+
definition.setHandlerClass("org.apache.eagle.alert.engine.router.CustomizedHandler");
+definition.setValue("PT0M,plain,1,host,host1");
+def.setDefinition(definition);
+def.setPartitionSpec(Arrays.asList(createPartition()));
+
+AlertBoltSpec boltSpecs = new AlertBoltSpec();
+
+AtomicBoolean recieved = new AtomicBoolean(false);
+OutputCollector collector = new OutputCollector(new 
IOutputCollector() {
+@Override
+public List emit(String streamId, Collection 
anchors, List tuple) {
+recieved.set(true);
+return Collections.emptyList();
+}
+
+@Override
+public void emitDirect(int taskId, String streamId, 
Collection anchors, List tuple) {
+}
+
+@Override
+public void ack(Tuple input) {
+}
+
+@Override
+public void fail(Tuple input) {
+}
+
+@Override
+public void reportError(Throwable error) {
+}
+});
+AlertBolt bolt = createAlertBolt(collector);
+
+boltSpecs.getBoltPoliciesMap().put(bolt.getBoltId(), 
Arrays.asList(def));
+boltSpecs.setVersion("spec_" + System.currentTimeMillis());
+// stream def map
+Map sds = new HashMap();
+StreamDefinition sdTest = new StreamDefinition();
+sdTest.setStreamId(TEST_STREAM);
+sds.put(sdTest.getStreamId(), sdTest);
+
+boltSpecs.addPublishPartition(TEST_STREAM, "policy-definition", 
"testAlertPublish", null);
+
+bolt.onAlertBoltSpecChange(boltSpecs, sds);
+
+// how to assert
+Tuple t = createTuple(bolt, boltSpecs.getVersion());
+
+bolt.execute(t);
+
+Assert.assertTrue(recieved.get());
+
+LOG.info("Update stream");
+sds = new HashMap();
+sdTest = new StreamDefinition();
+sdTest.setStreamId(TEST_STREAM);
+sds.put(sdTest.getStreamId(), sdTest);
+sdTest.setDescription("update the stream");
+bolt.onAlertBoltSpecChange(boltSpecs, sds);
+
+LOG.info("No any change");
+sds = new HashMap();
+sdTest = new StreamDefinition();
+sdTest.setStreamId(TEST_STREAM);
+sds.put(sdTest.getStreamId(), sdTest);
+sdTest.setDescription("update the stream");
+bolt.onAlertBoltSpecChange(boltSpecs, sds);
--- End diff --

It seems some tests have no asserts, does it ok?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-eagle pull request #732: EAGLE-837: Stream definition change does ...

2016-12-12 Thread garrettlish
GitHub user garrettlish opened a pull request:

https://github.com/apache/incubator-eagle/pull/732

EAGLE-837: Stream definition change does not reflect in AlertBolt

Stream definition change only trigger router bolt & publisher update, we 
don't update corresponding alert bolt stream definition references. It will 
cause alert bolt still use old stream definition references, it could produce 
array index out of bound exception.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/garrettlish/incubator-eagle eagle837

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-eagle/pull/732.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #732


commit d5353dd7e5e7f91c805dc698c29516809597071f
Author: Xiancheng Li 
Date:   2016-12-12T11:17:47Z

EAGLE-837: Stream definition change does not reflect in AlertBolt

Stream definition change only trigger router bolt & publisher update, we 
don't update corresponding alert bolt stream definition references. It will 
cause alert bolt still use old stream definition references, it could produce 
array index out of bound exception.




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---