use of com.hortonworks.streamline.streams.layout.component.rule.action.Action in project streamline by hortonworks.
the class TopologyBranchRule method fromMap.
@Override
public Storable fromMap(Map<String, Object> map) {
super.fromMap(map);
setId((Long) map.get(ID));
setVersionId((Long) map.get(VERSION_ID));
setTopologyId((Long) map.get(TOPOLOGY_ID));
setName((String) map.get(NAME));
setDescription((String) map.get(DESCRIPTION));
setCondition((String) map.get(CONDITION));
setParsedRuleStr((String) map.get(PARSED_RULE_STR));
setStream((String) map.get(STREAM));
try {
ObjectMapper mapper = new ObjectMapper();
String outputStreamsStr = (String) map.get(OUTPUT_STREAMS);
if (!StringUtils.isEmpty(outputStreamsStr)) {
List<String> outputStreams = mapper.readValue(outputStreamsStr, new TypeReference<List<String>>() {
});
setOutputStreams(outputStreams);
}
String actionsStr = (String) map.get(ACTIONS);
if (!StringUtils.isEmpty(actionsStr)) {
List<Action> actions = mapper.readValue(actionsStr, new TypeReference<List<Action>>() {
});
setActions(actions);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return this;
}
use of com.hortonworks.streamline.streams.layout.component.rule.action.Action in project streamline by hortonworks.
the class TopologyBranchRule method toMap.
@Override
public Map<String, Object> toMap() {
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> map = super.toMap();
try {
map.put(OUTPUT_STREAMS, outputStreams != null ? mapper.writeValueAsString(outputStreams) : "");
map.put(ACTIONS, actions != null ? mapper.writerFor(new TypeReference<List<Action>>() {
}).writeValueAsString(actions) : "");
} catch (Exception e) {
throw new RuntimeException(e);
}
return map;
}
use of com.hortonworks.streamline.streams.layout.component.rule.action.Action in project streamline by hortonworks.
the class TopologyRule method toMap.
@Override
public Map<String, Object> toMap() {
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> map = super.toMap();
try {
map.put(STREAMS, streams != null ? mapper.writeValueAsString(streams) : "");
map.put(OUTPUT_STREAMS, outputStreams != null ? mapper.writeValueAsString(outputStreams) : "");
map.put(WINDOW, window != null ? mapper.writeValueAsString(window) : "");
map.put(PROJECTIONS, projections != null ? mapper.writerFor(new TypeReference<List<Projection>>() {
}).writeValueAsString(projections) : "");
map.put(ACTIONS, actions != null ? mapper.writerFor(new TypeReference<List<Action>>() {
}).writeValueAsString(actions) : "");
} catch (Exception e) {
throw new RuntimeException(e);
}
return map;
}
use of com.hortonworks.streamline.streams.layout.component.rule.action.Action 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);
}
}
}
}
}
use of com.hortonworks.streamline.streams.layout.component.rule.action.Action in project streamline by hortonworks.
the class RuleProcessorRuntime method createActionRuntimes.
private List<ActionRuntime> createActionRuntimes(Rule rule) {
List<ActionRuntime> runtimeActions = new ArrayList<>();
for (Action action : rule.getActions()) {
final ActionRuntime actionRuntime = ActionRuntimeService.get().get(action);
actionRuntime.setActionRuntimeContext(new ActionRuntimeContext(rule, action));
runtimeActions.add(actionRuntime);
}
return runtimeActions;
}
Aggregations