use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table in project openflowplugin by opendaylight.
the class DeviceFlowRegistryImplTest method testFill.
@Test
public void testFill() throws Exception {
final InstanceIdentifier<FlowCapableNode> path = nodeInstanceIdentifier.augmentation(FlowCapableNode.class);
final Flow flow = new FlowBuilder().setTableId((short) 1).setPriority(10).setCookie(new FlowCookie(BigInteger.TEN)).setId(new FlowId("HELLO")).build();
final Table table = new TableBuilder().setFlow(Collections.singletonList(flow)).build();
final FlowCapableNode flowCapableNode = new FlowCapableNodeBuilder().setTable(Collections.singletonList(table)).build();
final Map<FlowRegistryKey, FlowDescriptor> allFlowDescriptors = fillRegistry(path, flowCapableNode);
key = FlowRegistryKeyFactory.create(OFConstants.OFP_VERSION_1_3, flow);
InOrder order = inOrder(dataBroker, readOnlyTransaction);
order.verify(dataBroker).newReadOnlyTransaction();
order.verify(readOnlyTransaction).read(LogicalDatastoreType.CONFIGURATION, path);
order.verify(dataBroker).newReadOnlyTransaction();
order.verify(readOnlyTransaction).read(LogicalDatastoreType.OPERATIONAL, path);
assertTrue(allFlowDescriptors.containsKey(key));
deviceFlowRegistry.addMark(key);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table in project openflowplugin by opendaylight.
the class ResubmitCodecTest method getSubTypeTest2.
/**
* If table != null or table != OFP_TABLE_ALL
* SUBTYPE should be set to NXAST_RESUBMIT_TABLE_SUBTYPE.
*/
@Test
public void getSubTypeTest2() {
Byte table = new Byte((byte) 1);
action = createAction(null, table);
ActionResubmit actionResubmit = (ActionResubmit) action.getActionChoice();
byte result = resubmitCodec.getSubType(actionResubmit);
assertEquals(NXAST_RESUBMIT_TABLE_SUBTYPE, result);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table in project openflowplugin by opendaylight.
the class FlowModInputMessageFactoryTest method test.
@Test
public void test() throws Exception {
ByteBuf bb = BufferHelper.buildBuffer("ff 01 04 01 06 00 07 01 ff 05 00 00 09 30 00 30 41 02 00 0c 00 00 00 7e 00 " + "00 00 02 00 00 11 46 00 00 00 62 00 0b 00 00 00 01 00 11 80 00 02 04 00 00 00 2a 80 00 12 01 04 00 " + "00 00 00 00 00 00 00 01 00 08 2b 00 00 00 00 02 00 18 00 00 00 00 ff 01 04 01 06 00 07 01 ff 05 00 00 " + "09 30 00 30 00 04 00 18 00 00 00 00 00 00 00 10 00 00 00 2a 00 34 00 00 00 00 00 00");
FlowModInput deserializedMessage = BufferHelper.deserialize(flowFactory, bb);
BufferHelper.checkHeaderV13(deserializedMessage);
byte[] cookie = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01 };
Assert.assertEquals("Wrong cookie", new BigInteger(1, cookie), deserializedMessage.getCookie());
byte[] cookieMask = new byte[] { (byte) 0xFF, 0x05, 0x00, 0x00, 0x09, 0x30, 0x00, 0x30 };
Assert.assertEquals("Wrong cookie mask", new BigInteger(1, cookieMask), deserializedMessage.getCookieMask());
Assert.assertEquals("Wrong table id", new TableId(65L), deserializedMessage.getTableId());
Assert.assertEquals("Wrong command", FlowModCommand.forValue(2), deserializedMessage.getCommand());
Assert.assertEquals("Wrong idle timeout", 12, deserializedMessage.getIdleTimeout().intValue());
Assert.assertEquals("Wrong hard timeout", 0, deserializedMessage.getHardTimeout().intValue());
Assert.assertEquals("Wrong priority", 126, deserializedMessage.getPriority().intValue());
Assert.assertEquals("Wrong buffer id ", 2L, deserializedMessage.getBufferId().longValue());
Assert.assertEquals("Wrong out port", new PortNumber(4422L), deserializedMessage.getOutPort());
Assert.assertEquals("Wrong out group", 98L, deserializedMessage.getOutGroup().longValue());
Assert.assertEquals("Wrong flags", new FlowModFlags(true, false, true, false, true), deserializedMessage.getFlags());
Assert.assertEquals("Wrong match", createMatch(), deserializedMessage.getMatch());
Assert.assertEquals("Wrong instructions", createInstructions(), deserializedMessage.getInstruction());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table in project openflowplugin by opendaylight.
the class DeviceFlowRegistryImpl method fillFromDatastore.
private CheckedFuture<Optional<FlowCapableNode>, ReadFailedException> fillFromDatastore(final LogicalDatastoreType logicalDatastoreType, final InstanceIdentifier<FlowCapableNode> path) {
// Create new read-only transaction
final ReadOnlyTransaction transaction = dataBroker.newReadOnlyTransaction();
// Bail out early if transaction is null
if (transaction == null) {
return Futures.immediateFailedCheckedFuture(new ReadFailedException("Read transaction is null"));
}
// Prepare read operation from datastore for path
final CheckedFuture<Optional<FlowCapableNode>, ReadFailedException> future = transaction.read(logicalDatastoreType, path);
// Bail out early if future is null
if (future == null) {
return Futures.immediateFailedCheckedFuture(new ReadFailedException("Future from read transaction is null"));
}
Futures.addCallback(future, new FutureCallback<Optional<FlowCapableNode>>() {
@Override
public void onSuccess(@Nonnull Optional<FlowCapableNode> result) {
result.asSet().stream().filter(Objects::nonNull).filter(flowCapableNode -> Objects.nonNull(flowCapableNode.getTable())).flatMap(flowCapableNode -> flowCapableNode.getTable().stream()).filter(Objects::nonNull).filter(table -> Objects.nonNull(table.getFlow())).flatMap(table -> table.getFlow().stream()).filter(Objects::nonNull).filter(flow -> Objects.nonNull(flow.getId())).forEach(flowConsumer);
// After we are done with reading from datastore, close the transaction
transaction.close();
}
@Override
public void onFailure(Throwable throwable) {
// Even when read operation failed, close the transaction
transaction.close();
}
}, MoreExecutors.directExecutor());
return future;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table in project openflowplugin by opendaylight.
the class AbstractTableMultipartService method storeStatistics.
/**
* Stores table features to operational datastore.
*/
protected void storeStatistics(List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> result) {
multipartWriterProvider.lookup(MultipartType.OFPMPTABLEFEATURES).ifPresent(writer -> {
writer.write(new TableUpdatedBuilder().setTableFeatures(result).build(), false);
getTxFacade().submitTransaction();
});
}
Aggregations