@Override protected void processPacket(final InstanceIdentifier<Node> node, final Match match, final Instructions instructions) { final AddFlowInputBuilder fb = BUILDER.get(); // Finally build our flow fb.setMatch(match); fb.setInstructions(instructions); // Construct the flow instance id fb.setNode(new NodeRef(node)); // Add flow final AddFlowInput flow = fb.build(); if (LOG.isDebugEnabled()) { LOG.debug("onPacketReceived - About to write flow (via SalFlowService) {}", flow); } ListenableFuture<RpcResult<AddFlowOutput>> result = JdkFutureAdapters.listenInPoolThread(flowService.addFlow(flow)); Futures.addCallback(result, new FutureCallback<RpcResult<AddFlowOutput>>() { @Override public void onSuccess(final RpcResult<AddFlowOutput> o) { countFutureSuccess(); } @Override public void onFailure(final Throwable throwable) { countFutureError(); } }); }
private static Optional<? extends Flow> injectMatchAndAction(Flow sourceFlow, Match match) { Instructions instructions = (new InstructionsBuilder()) .setInstruction(injectPushActionToInstruction(sourceFlow)) .build(); if (sourceFlow instanceof AddFlowInput) { return Optional.of(new AddFlowInputBuilder(sourceFlow) .setMatch(match).setInstructions(instructions).build()); } else if (sourceFlow instanceof RemoveFlowInput) { return Optional.of(new RemoveFlowInputBuilder(sourceFlow) .setMatch(match).setInstructions(instructions).build()); } else if (sourceFlow instanceof UpdatedFlow) { return Optional.of(new UpdatedFlowBuilder(sourceFlow) .setMatch(match).setInstructions(instructions).build()); } else { return Optional.empty(); } }
@Override public Future<RpcResult<Void>> testFlow(TestFlowInput input) { AddFlowInputBuilder flow = new AddFlowInputBuilder(); flow.setPriority(2); flow.setMatch(createMatchBld().build()); flow.setInstructions(createDecNwTtlInstructionsBld().build()); flow.setBarrier(Boolean.FALSE); BigInteger value = BigInteger.valueOf(10L); flow.setCookie(new FlowCookie(value)); flow.setCookieMask(new FlowCookie(value)); flow.setHardTimeout(0); flow.setIdleTimeout(0); flow.setInstallHw(false); flow.setStrict(false); flow.setContainerName(null); flow.setFlags(new FlowModFlags(false, false, false, false, true)); flow.setTableId((short) 0); flow.setFlowName("NiciraFLOW"); // Construct the flow instance id final InstanceIdentifier<Node> flowInstanceId = InstanceIdentifier .builder(Nodes.class) // File under nodes .child(Node.class, new NodeKey(new NodeId("openflow:1"))).build(); // A particular node identified by nodeKey flow.setNode(new NodeRef(flowInstanceId)); pushFlowViaRpc(flow.build()); return Futures.immediateFuture(RpcResultBuilder.<Void>status(true).build()); }
setMatch(EMPTY_MATCH). setFlags(FLOW_MOD_FLAGS). setInstructions(inst). build();