Search in sources :

Example 1 with Transform

use of com.hortonworks.streamline.streams.layout.Transform in project streamline by hortonworks.

the class TransformActionRuntime method getTransformRuntimes.

private List<TransformRuntime> getTransformRuntimes(List<Transform> transforms) {
    if (transforms == null || transforms.isEmpty()) {
        return Collections.<TransformRuntime>singletonList(new IdentityTransformRuntime());
    }
    List<TransformRuntime> transformRuntimes = new ArrayList<>();
    for (Transform transform : transforms) {
        TransformRuntime transformRuntime = TransformRuntimeService.get().get(transform);
        transformRuntimes.add(transformRuntime);
    }
    return transformRuntimes;
}
Also used : IdentityTransformRuntime(com.hortonworks.streamline.streams.runtime.transform.IdentityTransformRuntime) ArrayList(java.util.ArrayList) IdentityTransformRuntime(com.hortonworks.streamline.streams.runtime.transform.IdentityTransformRuntime) Transform(com.hortonworks.streamline.streams.layout.Transform)

Example 2 with Transform

use of com.hortonworks.streamline.streams.layout.Transform in project streamline by hortonworks.

the class NotifierActionRuntime method getNotificationTransforms.

/**
 * Returns the necessary transforms to perform based on the action.
 */
private List<Transform> getNotificationTransforms(NotifierAction action, Long ruleId) {
    List<Transform> transforms = new ArrayList<>();
    if (action.getOutputFieldsAndDefaults() != null && !action.getOutputFieldsAndDefaults().isEmpty()) {
        transforms.add(new MergeTransform(action.getOutputFieldsAndDefaults()));
        transforms.add(new SubstituteTransform(action.getOutputFieldsAndDefaults().keySet()));
        transforms.add(new ProjectionTransform("projection-" + ruleId, action.getOutputFieldsAndDefaults().keySet()));
    }
    Map<String, Object> headers = new HashMap<>();
    headers.put(AddHeaderTransformRuntime.HEADER_FIELD_NOTIFIER_NAME, action.getNotifierName());
    headers.put(AddHeaderTransformRuntime.HEADER_FIELD_RULE_ID, ruleId);
    transforms.add(new AddHeaderTransform(headers));
    return transforms;
}
Also used : ProjectionTransform(com.hortonworks.streamline.streams.layout.component.rule.action.transform.ProjectionTransform) AddHeaderTransform(com.hortonworks.streamline.streams.layout.component.rule.action.transform.AddHeaderTransform) MergeTransform(com.hortonworks.streamline.streams.layout.component.rule.action.transform.MergeTransform) SubstituteTransform(com.hortonworks.streamline.streams.layout.component.rule.action.transform.SubstituteTransform) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Transform(com.hortonworks.streamline.streams.layout.Transform) ProjectionTransform(com.hortonworks.streamline.streams.layout.component.rule.action.transform.ProjectionTransform) MergeTransform(com.hortonworks.streamline.streams.layout.component.rule.action.transform.MergeTransform) AddHeaderTransform(com.hortonworks.streamline.streams.layout.component.rule.action.transform.AddHeaderTransform) SubstituteTransform(com.hortonworks.streamline.streams.layout.component.rule.action.transform.SubstituteTransform)

Example 3 with Transform

use of com.hortonworks.streamline.streams.layout.Transform in project streamline by hortonworks.

the class StageActionRuntime method buildTransformActionRuntime.

protected void buildTransformActionRuntime() {
    final List<Transform> transforms = stageAction.getTransforms();
    if (stageAction.getOutputStreams().size() != 1) {
        throw new RuntimeException("Stage can only have one output stream.");
    }
    transformActionRuntime = new TransformActionRuntime(new TransformAction(transforms, stageAction.getOutputStreams()));
}
Also used : TransformActionRuntime(com.hortonworks.streamline.streams.runtime.TransformActionRuntime) TransformAction(com.hortonworks.streamline.streams.layout.component.rule.action.TransformAction) Transform(com.hortonworks.streamline.streams.layout.Transform)

Aggregations

Transform (com.hortonworks.streamline.streams.layout.Transform)3 ArrayList (java.util.ArrayList)2 TransformAction (com.hortonworks.streamline.streams.layout.component.rule.action.TransformAction)1 AddHeaderTransform (com.hortonworks.streamline.streams.layout.component.rule.action.transform.AddHeaderTransform)1 MergeTransform (com.hortonworks.streamline.streams.layout.component.rule.action.transform.MergeTransform)1 ProjectionTransform (com.hortonworks.streamline.streams.layout.component.rule.action.transform.ProjectionTransform)1 SubstituteTransform (com.hortonworks.streamline.streams.layout.component.rule.action.transform.SubstituteTransform)1 TransformActionRuntime (com.hortonworks.streamline.streams.runtime.TransformActionRuntime)1 IdentityTransformRuntime (com.hortonworks.streamline.streams.runtime.transform.IdentityTransformRuntime)1 HashMap (java.util.HashMap)1