public ObjectNode encode(Objective objective, CodecContext context) { checkNotNull(objective, "Objective cannot be null"); ObjectNode result = context.mapper().createObjectNode() .put(ID, objective.id()) .put(OPERATION, objective.op().toString()) .put(PERMANENT, String.valueOf(objective.permanent())) .put(PRIORITY, objective.priority()) .put(TIMEOUT, objective.timeout()); if (objective.appId() != null) { result.put(APP_ID, objective.appId().toString()); } return result; }
for (PendingFlowObjective pn : pnext) { pend.append("\n NextOp: ") .append(pn.flowObjective().op()) .append(", DeviceId: ") .append(pn.deviceId())
int priority = obj.priority(); LogLevel logLevel = (obj.op() == Objective.Operation.VERIFY) ? LogLevel.TRACE : LogLevel.DEBUG; Tools.log(log, logLevel, "Enqueue {}", obj);
int priority = obj.priority(); LogLevel logLevel = (obj.op() == Objective.Operation.VERIFY) ? LogLevel.TRACE : LogLevel.DEBUG; Tools.log(log, logLevel, "Dequeue {}", obj);
private void installObjective(FlowRule.Builder ruleBuilder, Objective objective) { FlowRuleOperations.Builder flowBuilder = FlowRuleOperations.builder(); switch (objective.op()) { case ADD: flowBuilder.add(ruleBuilder.build()); break; case REMOVE: flowBuilder.remove(ruleBuilder.build()); break; default: log.warn("Unknown operation {}", objective.op()); } flowRuleService.apply(flowBuilder.build(new FlowRuleOperationsContext() { @Override public void onSuccess(FlowRuleOperations ops) { objective.context().ifPresent(context -> context.onSuccess(objective)); } @Override public void onError(FlowRuleOperations ops) { objective.context() .ifPresent(context -> context.onError(objective, ObjectiveError.FLOWINSTALLATIONFAILED)); } })); }
if (ctx.objective.op() == Objective.Operation.ADD && ctx.objective instanceof NextObjective) { break; case GROUPMISSING: if (ctx.objective.op() == Objective.Operation.ADD_TO_EXISTING) { ctx.increaseRetryValue(); flowObjectiveService.apply(ctx.deviceId, ctx.objective); } else if (ctx.objective.op() == Objective.Operation.REMOVE || ctx.objective.op() == Objective.Operation.REMOVE_FROM_EXISTING) {
/** * Submit the flow objective. Starting from this point on, the execution order is not guaranteed. * Therefore we must be certain that this method is called in-order. * * @param deviceId Device ID * @param obj Flow objective */ private void execute(DeviceId deviceId, Objective obj) { LogLevel logLevel = (obj.op() == Objective.Operation.VERIFY) ? LogLevel.TRACE : LogLevel.DEBUG; Tools.log(log, logLevel, "Submit objective installer, deviceId {}, obj {}", deviceId, obj); int priority = obj.priority(); if (obj instanceof FilteringObjective) { FilteringObjQueueKey k = new FilteringObjQueueKey(deviceId, priority, ((FilteringObjective) obj).key()); filtObjQueueHead.put(k, obj); super.filter(deviceId, (FilteringObjective) obj); } else if (obj instanceof ForwardingObjective) { ForwardingObjQueueKey k = new ForwardingObjQueueKey(deviceId, priority, ((ForwardingObjective) obj).selector()); fwdObjQueueHead.put(k, obj); super.forward(deviceId, (ForwardingObjective) obj); } else if (obj instanceof NextObjective) { NextObjQueueKey k = new NextObjQueueKey(deviceId, obj.id()); nextObjQueueHead.put(k, obj); super.next(deviceId, (NextObjective) obj); } else { log.error("Unknown flow objective instance: {}", obj.getClass().getName()); } }