use of org.graylog.plugins.pipelineprocessor.ast.Pipeline in project graylog2-server by Graylog2.
the class PipelineFacade method delete.
@Override
public void delete(PipelineDao nativeEntity) {
final Set<PipelineConnections> pipelineConnections = connectionsService.loadByPipelineId(nativeEntity.id());
for (PipelineConnections connections : pipelineConnections) {
final Set<String> pipelineIds = connections.pipelineIds().stream().filter(pipelineId -> !pipelineId.equals(nativeEntity.id())).collect(Collectors.toSet());
if (pipelineIds.isEmpty()) {
LOG.trace("Removing pipeline connections for stream {}", connections.streamId());
connectionsService.delete(connections.streamId());
} else {
final PipelineConnections newConnections = connections.toBuilder().pipelineIds(pipelineIds).build();
LOG.trace("Saving updated pipeline connections: {}", newConnections);
connectionsService.save(newConnections);
}
}
pipelineService.delete(nativeEntity.id());
}
use of org.graylog.plugins.pipelineprocessor.ast.Pipeline in project graylog2-server by Graylog2.
the class PipelineRuleParserTest method pipelineDeclaration.
@Test
public void pipelineDeclaration() throws Exception {
final List<Pipeline> pipelines = parser.parsePipelines(ruleForTest());
assertEquals(1, pipelines.size());
final Pipeline pipeline = Iterables.getOnlyElement(pipelines);
assertEquals("cisco", pipeline.name());
assertEquals(2, pipeline.stages().size());
final Stage stage1 = pipeline.stages().first();
final Stage stage2 = pipeline.stages().last();
assertEquals(Stage.Match.ALL, stage1.match());
assertEquals(1, stage1.stage());
assertArrayEquals(new Object[] { "check_ip_whitelist", "cisco_device" }, stage1.ruleReferences().toArray());
assertEquals(Stage.Match.EITHER, stage2.match());
assertEquals(2, stage2.stage());
assertArrayEquals(new Object[] { "parse_cisco_time", "extract_src_dest", "normalize_src_dest", "lookup_ips", "resolve_ips" }, stage2.ruleReferences().toArray());
}
use of org.graylog.plugins.pipelineprocessor.ast.Pipeline in project graylog2-server by Graylog2.
the class StageIteratorTest method singlePipelineNoStage.
@Test
public void singlePipelineNoStage() {
final ImmutableSet<Pipeline> input = ImmutableSet.of(Pipeline.builder().name("hallo").stages(of(Stage.builder().stage(0).match(Stage.Match.ALL).ruleReferences(Collections.emptyList()).build())).build());
final StageIterator iterator = new StageIterator(input);
assertTrue(iterator.hasNext());
final List<Stage> nextStages = iterator.next();
assertEquals(1, nextStages.size());
final Stage stage = Iterables.getOnlyElement(nextStages);
assertEquals(0, stage.ruleReferences().size());
}
Aggregations