Search in sources :

Example 56 with FlowCapableNode

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.

the class SyncPlanPushStrategyIncrementalImpl method flushRemoveGroupPortionAndBarrier.

private ListenableFuture<RpcResult<Void>> flushRemoveGroupPortionAndBarrier(final InstanceIdentifier<FlowCapableNode> nodeIdent, final ItemSyncBox<Group> groupsPortion) {
    List<ListenableFuture<RpcResult<RemoveGroupOutput>>> allResults = new ArrayList<>();
    for (Group group : groupsPortion.getItemsToPush()) {
        final KeyedInstanceIdentifier<Group, GroupKey> groupIdent = nodeIdent.child(Group.class, group.getKey());
        allResults.add(JdkFutureAdapters.listenInPoolThread(groupForwarder.remove(groupIdent, group, nodeIdent)));
    }
    final ListenableFuture<RpcResult<Void>> singleVoidResult = Futures.transform(Futures.allAsList(allResults), ReconcileUtil.<RemoveGroupOutput>createRpcResultCondenser("group remove"), MoreExecutors.directExecutor());
    return Futures.transformAsync(singleVoidResult, ReconcileUtil.chainBarrierFlush(PathUtil.digNodePath(nodeIdent), transactionService), MoreExecutors.directExecutor());
}
Also used : Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) RemoveGroupOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutput) ArrayList(java.util.ArrayList) GroupKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ListenableFuture(com.google.common.util.concurrent.ListenableFuture)

Example 57 with FlowCapableNode

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.

the class SyncPlanPushStrategyIncrementalImpl method addMissingFlows.

ListenableFuture<RpcResult<Void>> addMissingFlows(final NodeId nodeId, final InstanceIdentifier<FlowCapableNode> nodeIdent, final Map<TableKey, ItemSyncBox<Flow>> flowsInTablesSyncBox, final SyncCrudCounters counters) {
    if (flowsInTablesSyncBox.isEmpty()) {
        LOG.trace("no tables in config for node: {} -> SKIPPING", nodeId.getValue());
        return RpcResultBuilder.<Void>success().buildFuture();
    }
    final List<ListenableFuture<RpcResult<AddFlowOutput>>> allResults = new ArrayList<>();
    final List<ListenableFuture<RpcResult<UpdateFlowOutput>>> allUpdateResults = new ArrayList<>();
    final CrudCounts flowCrudCounts = counters.getFlowCrudCounts();
    for (Map.Entry<TableKey, ItemSyncBox<Flow>> flowsInTableBoxEntry : flowsInTablesSyncBox.entrySet()) {
        final TableKey tableKey = flowsInTableBoxEntry.getKey();
        final ItemSyncBox<Flow> flowSyncBox = flowsInTableBoxEntry.getValue();
        final KeyedInstanceIdentifier<Table, TableKey> tableIdent = nodeIdent.child(Table.class, tableKey);
        for (final Flow flow : flowSyncBox.getItemsToPush()) {
            final KeyedInstanceIdentifier<Flow, FlowKey> flowIdent = tableIdent.child(Flow.class, flow.getKey());
            LOG.trace("adding flow {} in table {} - absent on device {} match{}", flow.getId(), tableKey, nodeId, flow.getMatch());
            allResults.add(JdkFutureAdapters.listenInPoolThread(flowForwarder.add(flowIdent, flow, nodeIdent)));
            flowCrudCounts.incAdded();
        }
        for (final ItemSyncBox.ItemUpdateTuple<Flow> flowUpdate : flowSyncBox.getItemsToUpdate()) {
            final Flow existingFlow = flowUpdate.getOriginal();
            final Flow updatedFlow = flowUpdate.getUpdated();
            final KeyedInstanceIdentifier<Flow, FlowKey> flowIdent = tableIdent.child(Flow.class, updatedFlow.getKey());
            LOG.trace("flow {} in table {} - needs update on device {} match{}", updatedFlow.getId(), tableKey, nodeId, updatedFlow.getMatch());
            allUpdateResults.add(JdkFutureAdapters.listenInPoolThread(flowForwarder.update(flowIdent, existingFlow, updatedFlow, nodeIdent)));
            flowCrudCounts.incUpdated();
        }
    }
    final ListenableFuture<RpcResult<Void>> singleVoidAddResult = Futures.transform(Futures.allAsList(allResults), ReconcileUtil.<AddFlowOutput>createRpcResultCondenser("flow adding"), MoreExecutors.directExecutor());
    final ListenableFuture<RpcResult<Void>> singleVoidUpdateResult = Futures.transform(Futures.allAsList(allUpdateResults), ReconcileUtil.<UpdateFlowOutput>createRpcResultCondenser("flow updating"), MoreExecutors.directExecutor());
    return Futures.transform(Futures.allAsList(singleVoidAddResult, singleVoidUpdateResult), ReconcileUtil.<Void>createRpcResultCondenser("flow add/update"), MoreExecutors.directExecutor());
}
Also used : AddFlowOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) ItemSyncBox(org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox) ArrayList(java.util.ArrayList) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) CrudCounts(org.opendaylight.openflowplugin.applications.frsync.util.CrudCounts) UpdateFlowOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Map(java.util.Map)

Example 58 with FlowCapableNode

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.

the class SyncPlanPushStrategyIncrementalImpl method removeRedundantMeters.

ListenableFuture<RpcResult<Void>> removeRedundantMeters(final NodeId nodeId, final InstanceIdentifier<FlowCapableNode> nodeIdent, final ItemSyncBox<Meter> meterRemovalPlan, final SyncCrudCounters counters) {
    if (meterRemovalPlan.isEmpty()) {
        LOG.trace("no meters on device for node: {} -> SKIPPING", nodeId.getValue());
        return RpcResultBuilder.<Void>success().buildFuture();
    }
    final CrudCounts meterCrudCounts = counters.getMeterCrudCounts();
    final List<ListenableFuture<RpcResult<RemoveMeterOutput>>> allResults = new ArrayList<>();
    for (Meter meter : meterRemovalPlan.getItemsToPush()) {
        LOG.trace("removing meter {} - absent in config {}", meter.getMeterId(), nodeId);
        final KeyedInstanceIdentifier<Meter, MeterKey> meterIdent = nodeIdent.child(Meter.class, meter.getKey());
        allResults.add(JdkFutureAdapters.listenInPoolThread(meterForwarder.remove(meterIdent, meter, nodeIdent)));
        meterCrudCounts.incRemoved();
    }
    return Futures.transform(Futures.allAsList(allResults), ReconcileUtil.<RemoveMeterOutput>createRpcResultCondenser("meter remove"), MoreExecutors.directExecutor());
}
Also used : CrudCounts(org.opendaylight.openflowplugin.applications.frsync.util.CrudCounts) MeterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey) Meter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter) RemoveMeterOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutput) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture)

Example 59 with FlowCapableNode

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.

the class SyncPlanPushStrategyIncrementalImpl method removeRedundantGroups.

ListenableFuture<RpcResult<Void>> removeRedundantGroups(final NodeId nodeId, final InstanceIdentifier<FlowCapableNode> nodeIdent, final List<ItemSyncBox<Group>> groupsRemovalPlan, final SyncCrudCounters counters) {
    if (groupsRemovalPlan.isEmpty()) {
        LOG.trace("no groups on device for node: {} -> SKIPPING", nodeId.getValue());
        return RpcResultBuilder.<Void>success().buildFuture();
    }
    final CrudCounts groupCrudCounts = counters.getGroupCrudCounts();
    ListenableFuture<RpcResult<Void>> chainedResult = RpcResultBuilder.<Void>success().buildFuture();
    try {
        groupCrudCounts.setRemoved(ReconcileUtil.countTotalPushed(groupsRemovalPlan));
        if (LOG.isDebugEnabled()) {
            LOG.debug("removing groups: planSteps={}, toRemoveTotal={}", groupsRemovalPlan.size(), groupCrudCounts.getRemoved());
        }
        Collections.reverse(groupsRemovalPlan);
        for (final ItemSyncBox<Group> groupsPortion : groupsRemovalPlan) {
            chainedResult = Futures.transformAsync(chainedResult, input -> {
                final ListenableFuture<RpcResult<Void>> result;
                if (input.isSuccessful()) {
                    result = flushRemoveGroupPortionAndBarrier(nodeIdent, groupsPortion);
                } else {
                    // pass through original unsuccessful rpcResult
                    result = Futures.immediateFuture(input);
                }
                return result;
            }, MoreExecutors.directExecutor());
        }
    } catch (IllegalStateException e) {
        chainedResult = RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, "failed to add missing groups", e).buildFuture();
    }
    return chainedResult;
}
Also used : CrudCounts(org.opendaylight.openflowplugin.applications.frsync.util.CrudCounts) AddFlowOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput) Iterables(com.google.common.collect.Iterables) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) MeterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey) CrudCounts(org.opendaylight.openflowplugin.applications.frsync.util.CrudCounts) LoggerFactory(org.slf4j.LoggerFactory) FlowCapableTransactionService(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.FlowCapableTransactionService) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Meter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter) JdkFutureAdapters(com.google.common.util.concurrent.JdkFutureAdapters) RemoveGroupOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutput) UpdateGroupOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput) ArrayList(java.util.ArrayList) GroupKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey) UpdateMeterOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) Map(java.util.Map) RemoveMeterOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutput) SyncPlanPushStrategy(org.opendaylight.openflowplugin.applications.frsync.SyncPlanPushStrategy) PathUtil(org.opendaylight.openflowplugin.applications.frsync.util.PathUtil) ItemSyncBox(org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox) UpdateTableOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput) Logger(org.slf4j.Logger) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) FxChainUtil(org.opendaylight.openflowplugin.applications.frsync.util.FxChainUtil) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Futures(com.google.common.util.concurrent.Futures) List(java.util.List) RemoveFlowOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutput) AddGroupOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) RpcResultBuilder(org.opendaylight.yangtools.yang.common.RpcResultBuilder) SyncCrudCounters(org.opendaylight.openflowplugin.applications.frsync.util.SyncCrudCounters) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) AddMeterOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterOutput) ReconcileUtil(org.opendaylight.openflowplugin.applications.frsync.util.ReconcileUtil) Collections(java.util.Collections) UpdateFlowOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) RpcError(org.opendaylight.yangtools.yang.common.RpcError) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ListenableFuture(com.google.common.util.concurrent.ListenableFuture)

Example 60 with FlowCapableNode

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.

the class TableForwarder method update.

@Override
public Future<RpcResult<UpdateTableOutput>> update(final InstanceIdentifier<TableFeatures> identifier, final TableFeatures original, final TableFeatures update, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
    LOG.debug("Forwarding Table Update request [Tbl id, node Id {} {}", identifier, nodeIdent);
    final UpdateTableInputBuilder builder = new UpdateTableInputBuilder();
    builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
    final InstanceIdentifier<Table> iiToTable = nodeIdent.child(Table.class, new TableKey(identifier.firstKeyOf(TableFeatures.class).getTableId()));
    builder.setTableRef(new TableRef(iiToTable));
    builder.setUpdatedTable(new UpdatedTableBuilder().setTableFeatures(Collections.singletonList(update)).build());
    builder.setOriginalTable(new OriginalTableBuilder().setTableFeatures(Collections.singletonList(original)).build());
    LOG.debug("Invoking SalTableService {} ", nodeIdent);
    return salTableService.updateTable(builder.build());
}
Also used : NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) OriginalTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.OriginalTableBuilder) TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures) UpdatedTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTableBuilder) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) UpdateTableInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInputBuilder) TableRef(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableRef)

Aggregations

FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)48 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)29 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)26 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)22 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)20 ArrayList (java.util.ArrayList)17 Table (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)15 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)15 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)15 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)15 Test (org.junit.Test)14 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)14 Uri (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)13 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)11 Meter (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter)11 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)10 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)9 GroupKey (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey)9 CrudCounts (org.opendaylight.openflowplugin.applications.frsync.util.CrudCounts)8 FlowCapableNodeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder)8