- public void onSuccess(final Object o) {
- messageSpy.spyMessage(input.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMITTED_SUCCESS);
- short version = deviceContext.getPrimaryConnectionContext().getFeatures().getVersion();
- FlowHash flowHash = FlowHashFactory.create(original, version);
- deviceContext.getDeviceFlowRegistry().markToBeremoved(flowHash);
-
- flowHash = FlowHashFactory.create(updated, version);
- FlowId flowId = input.getFlowRef().getValue().firstKeyOf(Flow.class, FlowKey.class).getId();
- FlowDescriptor flowDescriptor = FlowDescriptorFactory.create(updated.getTableId(), flowId);
- deviceContext.getDeviceFlowRegistry().store(flowHash, flowDescriptor);
-
- }
-
- @Override
- public void onFailure(final Throwable throwable) {
- messageSpy.spyMessage(input.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMITTED_FAILURE);
- }
- });
- return future;
- }
-
- private <T> ListenableFuture<RpcResult<T>> processFlowModInputBuilders(
- final List<FlowModInputBuilder> ofFlowModInputs) {
- final List<ListenableFuture<RpcResult<T>>> partialFutures = new ArrayList<>();
-
- for (FlowModInputBuilder flowModInputBuilder : ofFlowModInputs) {
- DataCrateBuilder<T> dataCrateBuilder = DataCrateBuilder.<T>builder().setFlowModInputBuilder(flowModInputBuilder);
- ListenableFuture<RpcResult<T>> partialFuture = handleServiceCall(
- PRIMARY_CONNECTION,
- new Function<DataCrate<T>, ListenableFuture<RpcResult<Void>>>() {
- @Override
- public ListenableFuture<RpcResult<Void>> apply(final DataCrate<T> data) {
- return createResultForFlowMod(data);
- }
- },
- dataCrateBuilder
- );
- partialFutures.add(partialFuture);
- }
-
- // processing of final (optionally composite future)
- final ListenableFuture<List<RpcResult<T>>> allFutures = Futures.successfulAsList(partialFutures);
- final SettableFuture<RpcResult<T>> finalFuture = SettableFuture.create();
- Futures.addCallback(allFutures, new FutureCallback<List<RpcResult<T>>>() {
- @Override
- public void onSuccess(List<RpcResult<T>> results) {
- List<RpcError> rpcErrorLot = new ArrayList<>();
- RpcResultBuilder<T> resultBuilder;
-
- Iterator<FlowModInputBuilder> flowModInputBldIterator = ofFlowModInputs.iterator();
- Iterator<RpcResult<T>> resultIterator = results.iterator();
-
- for (ListenableFuture<RpcResult<T>> partFutureFromRqCtx : partialFutures) {
- FlowModInputBuilder flowModInputBld = flowModInputBldIterator.next();
- RpcResult<T> result = resultIterator.next();
- Long xid = flowModInputBld.getXid();
-
-
- LOG.trace("flowMod future processing [{}], result={}", xid, result);
- if (partFutureFromRqCtx.isCancelled()) { // one and only positive case
- if (LOG.isTraceEnabled()) {
- LOG.trace("flow future result was cancelled [{}] = barrier passed it without error", xid);
- }
- } else { // all negative cases
- if (result == null) { // there is exception or null value set
- try {
- partFutureFromRqCtx.get();
- } catch (Exception e) {
- rpcErrorLot.add(RpcResultBuilder.newError(ErrorType.APPLICATION, "",
- "flow future result [" + xid + "] failed with exception",
- OFConstants.APPLICATION_TAG, e.getMessage(), e));
-
- // xid might be not available in case requestContext not even stored
- if (xid != null) {
- deviceContext.unhookRequestCtx(new Xid(xid));
- }
- }
- } else {
- if (result.isSuccessful()) { // positive confirmation - never happens
- LOG.warn("Positive confirmation of flow push is not supported by OF-spec");
- LOG.warn("flow future result was successful [{}] = this should have never happen",
- xid);
- rpcErrorLot.add(RpcResultBuilder.newError(ErrorType.APPLICATION, "",
- "flow future result was successful [" + xid + "] = this should have never happen"));
- } else { // standard error occurred
- LOG.trace("passing original rpcErrors [{}]", xid);
- if (LOG.isTraceEnabled()) {
- for (RpcError rpcError : result.getErrors()) {
- LOG.trace("passed rpcError [{}]: {}", xid, rpcError);
- }
- }
- rpcErrorLot.addAll(result.getErrors());
- }
- }
+ public void onSuccess(final RpcResult<UpdateFlowOutput> o) {
+ FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(original);
+
+ FlowRegistryKey updatedflowRegistryKey = FlowRegistryKeyFactory.create(updated);
+ final FlowRef flowRef = input.getFlowRef();
+ final DeviceFlowRegistry deviceFlowRegistry = deviceContext.getDeviceFlowRegistry();
+ deviceFlowRegistry.markToBeremoved(flowRegistryKey);
+
+ if (itemLifecycleListener != null) {
+ final FlowDescriptor flowDescriptor = deviceContext.getDeviceFlowRegistry().retrieveIdForFlow(flowRegistryKey);
+ if (flowDescriptor != null) {
+ KeyedInstanceIdentifier<Flow, FlowKey> flowPath = createFlowPath(flowDescriptor,
+ deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
+ itemLifecycleListener.onRemoved(flowPath);