private AlertBoltSpec createAlertSpec() throws Exception { AlertBoltSpec spec = new AlertBoltSpec(); spec.setVersion("version1"); spec.setTopologyName("testTopology"); List<PolicyDefinition> policies = mapper.readValue(TestStateCheckPolicy.class.getResourceAsStream("/statecheck/policies.json"), new TypeReference<List<PolicyDefinition>>() { }); Assert.assertTrue(policies.size() > 0); spec.addBoltPolicy("alertBolt1", policies.get(0).getName()); spec.getBoltPoliciesMap().put("alertBolt1", new ArrayList<>(policies)); return spec; }
AlertBoltSpec alertSpec = alertSpecs.get(u.getTopoName()); if (alertSpec == null) { alertSpec = new AlertBoltSpec(u.getTopoName()); alertSpecs.put(u.getTopoName(), alertSpec);
private void pushAlertBoltSpec(StreamPartition sp, AlertBolt bolt) { Map<String, StreamDefinition> sds = new HashMap<>(); sds.put("correlatedStream", createCorrelateStream("correlatedStream")); sds.put("symptomaticAlertOutputStream", createCorrelateStream("symptomaticAlertOutputStream")); // output of updated correlatedStream sds.put("deviceDownAlertStream", createCorrelateStream("deviceDownAlertStream")); PolicyDefinition pd = new PolicyDefinition(); pd.setName("network_symptomatic"); pd.setInputStreams(Arrays.asList("correlatedStream")); pd.setOutputStreams(Arrays.asList("deviceDownAlertStream", "symptomaticAlertOutputStream")); pd.setPartitionSpec(Arrays.asList(sp)); PolicyDefinition.Definition def = new PolicyDefinition.Definition(); def.setType(PolicyStreamHandlers.SIDDHI_ENGINE); def.setValue("from correlatedStream#window.externalTime(timestamp, 3 min) select UUID() as docId, linkedSwitch, '' as parentKey, timestamp group by linkedSwitch having count() > 0 insert into deviceDownAlertStream; " + " from correlatedStream#window.externalTime(timestamp, 3 min) as left join deviceDownAlertStream#window.time(3 min) as right on left.linkedSwitch == right.linkedSwitch" + " select left.docId, left.timestamp, left.linkedSwitch, right.docId as parentKey insert into symptomaticAlertOutputStream;"); pd.setDefinition(def); AlertBoltSpec spec = new AlertBoltSpec(); spec.setVersion("version1"); spec.setTopologyName("testTopology"); spec.addBoltPolicy("alertBolt1", pd.getName()); spec.getBoltPoliciesMap().put("alertBolt1", new ArrayList<>(Arrays.asList(pd))); bolt.onAlertBoltSpecChange(spec, sds); }
bolt.onAlertBoltSpecChange(new AlertBoltSpec(), new HashMap()); sds.put(sdTest.getStreamId(), sdTest); AlertBoltSpec boltSpecs = new AlertBoltSpec(); boltSpecs.setVersion("specVersion-" + System.currentTimeMillis());
sds.put(sdTest.getStreamId(), sdTest); AlertBoltSpec boltSpecs = new AlertBoltSpec(); boltSpecs.setVersion("spec_version_" + System.currentTimeMillis()); boltSpecs.setTopologyName("alertUnitTopology_1");
def.setPartitionSpec(Arrays.asList(createPartition())); AlertBoltSpec boltSpecs = new AlertBoltSpec();
def.setPartitionSpec(Arrays.asList(createPartition())); AlertBoltSpec boltSpecs = new AlertBoltSpec();
@Test public void testAlertBoltSpec() { String topologyName = "testTopology"; AlertBoltSpec spec = new AlertBoltSpec(); List<String> topics = Arrays.asList("testTopic3", "testTopic4", "testTopic5"); for (String topic : topics) {
sp.setType(StreamPartition.Type.GROUPBY); AlertBoltSpec spec = new AlertBoltSpec(); spec.setVersion("version1"); spec.setTopologyName("testTopology");