use of com.hortonworks.streamline.streams.layout.component.impl.splitjoin.StageAction in project streamline by hortonworks.
the class SplitJoinTest method testStageProcessor.
@Test
public void testStageProcessor() {
final String enrichFieldName = "foo";
final String enrichedValue = "foo-enriched-value";
Map<Object, Object> data = new HashMap<Object, Object>() {
{
put("foo-value", enrichedValue);
}
};
InmemoryTransformDataProvider transformDataProvider = new InmemoryTransformDataProvider(data);
EnrichmentTransform enrichmentTransform = new EnrichmentTransform("enricher", Collections.singletonList(enrichFieldName), transformDataProvider);
StageAction stageAction = new StageAction(Collections.<Transform>singletonList(enrichmentTransform));
stageAction.setOutputStreams(Collections.singleton("output-stream"));
StageActionRuntime stageActionRuntime = new StageActionRuntime(stageAction);
stageActionRuntime.setActionRuntimeContext(new ActionRuntimeContext(null, stageAction));
stageActionRuntime.initialize(Collections.<String, Object>emptyMap());
final List<Result> results = stageActionRuntime.execute(createRootEvent());
for (Result result : results) {
for (StreamlineEvent event : result.events) {
final Map enrichments = (Map) event.getAuxiliaryFieldsAndValues().get(EnrichmentTransform.ENRICHMENTS_FIELD_NAME);
Assert.assertEquals(enrichments.get(enrichFieldName), enrichedValue);
}
}
}
use of com.hortonworks.streamline.streams.layout.component.impl.splitjoin.StageAction in project streamline by hortonworks.
the class SplitJoinTest method testStageProcessorWithRules.
@Test
public void testStageProcessorWithRules() {
final String enrichFieldName = "foo";
final String enrichedValue = "foo-enriched-value";
Map<Object, Object> data = new HashMap<Object, Object>() {
{
put("foo-value", enrichedValue);
}
};
InmemoryTransformDataProvider transformDataProvider = new InmemoryTransformDataProvider(data);
EnrichmentTransform enrichmentTransform = new EnrichmentTransform("enricher", Collections.singletonList(enrichFieldName), transformDataProvider);
StageAction stageAction = new StageAction(Collections.<Transform>singletonList(enrichmentTransform));
SplitJoinRule stageRule = new SplitJoinRule("stage-1", stageAction, Collections.singleton("output-stream"));
StageActionRuntime stageActionRuntime = new StageActionRuntime(stageAction);
stageActionRuntime.setActionRuntimeContext(new ActionRuntimeContext(stageRule, stageAction));
stageActionRuntime.initialize(Collections.<String, Object>emptyMap());
final List<Result> results = stageActionRuntime.execute(createRootEvent());
for (Result result : results) {
for (StreamlineEvent event : result.events) {
final Map enrichments = (Map) event.getAuxiliaryFieldsAndValues().get(EnrichmentTransform.ENRICHMENTS_FIELD_NAME);
Assert.assertEquals(enrichments.get(enrichFieldName), enrichedValue);
}
}
}
use of com.hortonworks.streamline.streams.layout.component.impl.splitjoin.StageAction in project streamline by hortonworks.
the class TopologyComponentFactory method stageProcessorProvider.
private Map.Entry<String, Provider<StreamlineProcessor>> stageProcessorProvider() {
Provider<StreamlineProcessor> provider = new Provider<StreamlineProcessor>() {
@Override
public StreamlineProcessor create(TopologyComponent component) {
Object stageConfig = component.getConfig().getAny(StageProcessor.CONFIG_KEY_STAGE);
ObjectMapper objectMapper = new ObjectMapper();
StageAction stageAction = objectMapper.convertValue(stageConfig, StageAction.class);
StageProcessor stageProcessor = new StageProcessor();
stageProcessor.setStageAction(stageAction);
return stageProcessor;
}
};
return new SimpleImmutableEntry<>(STAGE, provider);
}
Aggregations