use of org.onosproject.workflow.api.SystemWorkflowContext in project onos by opennetworkinglab.
the class WorkFlowEngine method eventMapTrigger.
@Override
public void eventMapTrigger(Event event, EventHintSupplier supplier) {
if (event.subject() instanceof SystemWorkflowContext) {
return;
}
Map<String, String> eventMap;
String eventHint;
try {
eventHint = supplier.apply(event);
} catch (Throwable e) {
log.error("Exception: ", e);
return;
}
if (eventHint == null) {
// do nothing
log.error("Invalid eventHint, event: {}", event);
return;
}
try {
eventMap = eventMapStore.getEventMapByHint(event.getClass().getName(), eventHint);
} catch (WorkflowException e) {
log.error("Exception: ", e);
return;
}
if (Objects.isNull(eventMap) || eventMap.isEmpty()) {
// do nothing;
log.debug("Invalid eventMap, event: {}", event);
return;
}
for (Map.Entry<String, String> entry : eventMap.entrySet()) {
String contextName = entry.getKey();
String strProgramCounter = entry.getValue();
ProgramCounter pc;
try {
pc = ProgramCounter.valueOf(strProgramCounter);
} catch (IllegalArgumentException e) {
log.error("Exception: ", e);
return;
}
WorkflowContext context = workplaceStore.getContext(contextName);
if (Objects.isNull(context)) {
log.info("Invalid context: {}, event: {}", contextName, event);
continue;
}
EventTask eventtask = null;
try {
eventtask = EventTask.builder().event(event).eventHint(eventHint).context(context).programCounter(pc).build();
} catch (WorkflowException e) {
log.error("Exception: ", e);
}
log.debug("eventtaskAccumulator.add: task: {}", eventtask);
if (!Objects.isNull(eventtask)) {
eventtaskAccumulator.add(eventtask);
}
}
}
Aggregations