use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.
the class DefaultConfigPusher method start.
@SuppressWarnings("checkstyle:IllegalCatch")
public void start() {
try {
final InstanceIdentifier<FlowCapableNode> path = InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class);
final DataTreeIdentifier<FlowCapableNode> identifier = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, path);
final SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
listenerRegistration = looper.loopUntilNoException(() -> dataBroker.registerDataTreeChangeListener(identifier, DefaultConfigPusher.this));
} catch (Exception e) {
LOG.error("DataTreeChangeListener registration failed: {}", e);
throw new IllegalStateException("DefaultConfigPusher startup failed!", e);
}
LOG.info("DefaultConfigPusher has started.");
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.
the class DefaultConfigPusher method onDataTreeChanged.
@Override
public void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<FlowCapableNode>> modifications) {
for (DataTreeModification<FlowCapableNode> modification : modifications) {
if (modification.getRootNode().getModificationType() == ModificationType.WRITE) {
SetConfigInputBuilder setConfigInputBuilder = new SetConfigInputBuilder();
setConfigInputBuilder.setFlag(SwitchConfigFlag.FRAGNORMAL.toString());
setConfigInputBuilder.setMissSearchLength(OFConstants.OFPCML_NO_BUFFER);
setConfigInputBuilder.setNode(new NodeRef(modification.getRootPath().getRootIdentifier().firstIdentifierOf(Node.class)));
final Future<RpcResult<SetConfigOutput>> resultFuture = nodeConfigService.setConfig(setConfigInputBuilder.build());
JdkFutures.addErrorLogging(resultFuture, LOG, "addFlow");
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.
the class NodeNotificationSupplierImplTest method testDeleteChangeEvent.
@Test
public void testDeleteChangeEvent() {
final TestData testData = new TestData(createTestFlowCapableNodePath(), createTestFlowCapableNode(), null, DataObjectModification.ModificationType.DELETE);
Collection<DataTreeModification<FlowCapableNode>> collection = new ArrayList<>();
collection.add(testData);
notifSupplierImpl.onDataTreeChanged(collection);
verify(notifProviderService, times(1)).publish(Matchers.any(NodeRemoved.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.
the class StatisticsGatheringUtilsTest method testGatherStatistics_flow.
@Test
public void testGatherStatistics_flow() throws Exception {
final short tableId = 0;
final MultipartType type = MultipartType.OFPMPFLOW;
final InstanceIdentifier<FlowCapableNode> nodePath = deviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
final TableBuilder tableDataBld = new TableBuilder();
tableDataBld.setId(tableId);
final FlowCapableNodeBuilder flowNodeBuilder = new FlowCapableNodeBuilder();
flowNodeBuilder.setTable(Collections.singletonList(tableDataBld.build()));
final Optional<FlowCapableNode> flowNodeOpt = Optional.of(flowNodeBuilder.build());
final CheckedFuture<Optional<FlowCapableNode>, ReadFailedException> flowNodeFuture = Futures.immediateCheckedFuture(flowNodeOpt);
when(readTx.read(LogicalDatastoreType.OPERATIONAL, nodePath)).thenReturn(flowNodeFuture);
when(flowDescriptor.getFlowId()).thenReturn(flowId);
final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder matchBld = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder().setMatchEntry(Collections.<MatchEntry>emptyList());
final FlowStatsBuilder flowStatsBld = new FlowStatsBuilder().setByteCount(BigInteger.valueOf(55L)).setPacketCount(BigInteger.valueOf(56L)).setDurationSec(57L).setDurationNsec(58L).setTableId((short) 0).setMatch(matchBld.build()).setFlags(new FlowModFlags(true, false, false, false, true));
final MultipartReplyFlowBuilder mpReplyFlowBld = new MultipartReplyFlowBuilder();
mpReplyFlowBld.setFlowStats(Lists.newArrayList(flowStatsBld.build()));
final MultipartReplyFlowCaseBuilder mpReplyFlowCaseBld = new MultipartReplyFlowCaseBuilder();
mpReplyFlowCaseBld.setMultipartReplyFlow(mpReplyFlowBld.build());
final MultipartReply flowStatsUpdated = assembleMPReplyMessage(type, mpReplyFlowCaseBld.build());
final List<MultipartReply> statsData = Collections.singletonList(flowStatsUpdated);
fireAndCheck(type, statsData);
final FlowBuilder flowBld = new FlowBuilder().setTableId((short) 0).setMatch(new MatchBuilder().build());
final KeyedInstanceIdentifier<Table, TableKey> tablePath = dummyNodePath.augmentation(FlowCapableNode.class).child(Table.class, new TableKey((short) 0));
final KeyedInstanceIdentifier<Flow, FlowKey> flowPath = tablePath.child(Flow.class, new FlowKey(flowId));
verify(deviceContext, Mockito.never()).addDeleteToTxChain(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.<InstanceIdentifier<?>>any());
final InOrder inOrder = Mockito.inOrder(deviceContext);
inOrder.verify(deviceContext).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.any(), Matchers.any());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.
the class StatisticsGatheringUtilsTest method testDeleteAllKnownFlows.
@Test
public void testDeleteAllKnownFlows() throws Exception {
final short tableId = 0;
final InstanceIdentifier<FlowCapableNode> nodePath = deviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
final TableBuilder tableDataBld = new TableBuilder();
tableDataBld.setId(tableId);
final FlowCapableNodeBuilder flowNodeBuilder = new FlowCapableNodeBuilder();
flowNodeBuilder.setTable(Collections.singletonList(tableDataBld.build()));
final Optional<FlowCapableNode> flowNodeOpt = Optional.of(flowNodeBuilder.build());
final CheckedFuture<Optional<FlowCapableNode>, ReadFailedException> flowNodeFuture = Futures.immediateCheckedFuture(flowNodeOpt);
when(readTx.read(LogicalDatastoreType.OPERATIONAL, nodePath)).thenReturn(flowNodeFuture);
StatisticsGatheringUtils.deleteAllKnownFlows(deviceContext, deviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class), deviceFlowRegistry);
verify(deviceContext).isTransactionsEnabled();
verify(deviceContext).getReadTransaction();
verify(deviceContext).writeToTransaction(Mockito.eq(LogicalDatastoreType.OPERATIONAL), Mockito.any(), Mockito.any());
}
Aggregations