Search in sources :

Example 16 with Rule

use of com.hortonworks.streamline.streams.layout.component.rule.Rule in project streamline by hortonworks.

the class RulesProcessor method setRules.

public void setRules(List<Rule> rules) {
    this.rules = rules;
    Set<String> streamIds = new HashSet<>(Collections2.transform(getOutputStreams(), new Function<Stream, String>() {

        @Override
        public String apply(Stream input) {
            return input.getId();
        }
    }));
    for (Rule rule : rules) {
        for (Action action : rule.getActions()) {
            for (String stream : action.getOutputStreams()) {
                if (!streamIds.contains(stream)) {
                    String errorMsg = String.format("Action [%s] stream [%s] does not exist in processor [%s]'s output streams [%s]", action, stream, getName(), streamIds);
                    log.error(errorMsg);
                    throw new IllegalArgumentException(errorMsg);
                }
            }
        }
    }
}
Also used : Function(com.google.common.base.Function) Action(com.hortonworks.streamline.streams.layout.component.rule.action.Action) Stream(com.hortonworks.streamline.streams.layout.component.Stream) Rule(com.hortonworks.streamline.streams.layout.component.rule.Rule) HashSet(java.util.HashSet)

Aggregations

Rule (com.hortonworks.streamline.streams.layout.component.rule.Rule)16 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)7 TopologyBranchRule (com.hortonworks.streamline.streams.catalog.TopologyBranchRule)7 TopologyRule (com.hortonworks.streamline.streams.catalog.TopologyRule)7 Function (com.google.common.base.Function)5 HashSet (java.util.HashSet)5 BaseTopologyRule (com.hortonworks.streamline.streams.catalog.BaseTopologyRule)4 Stream (com.hortonworks.streamline.streams.layout.component.Stream)4 RulesProcessor (com.hortonworks.streamline.streams.layout.component.impl.RulesProcessor)4 ArrayList (java.util.ArrayList)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 Collections2 (com.google.common.collect.Collections2)2 QueryParam (com.hortonworks.registries.common.QueryParam)2 TopologyWindow (com.hortonworks.streamline.streams.catalog.TopologyWindow)2 UDF (com.hortonworks.streamline.streams.catalog.UDF)2 Window (com.hortonworks.streamline.streams.layout.component.rule.expression.Window)2 List (java.util.List)2 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)1 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1