use of org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey in project openflowplugin by opendaylight.
the class SalFlowServiceImpl method addFlow.
@Override
public Future<RpcResult<AddFlowOutput>> addFlow(final AddFlowInput input) {
final FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(deviceContext.getDeviceInfo().getVersion(), input);
final ListenableFuture<RpcResult<AddFlowOutput>> future;
if (flowAddMessage.canUseSingleLayerSerialization()) {
future = flowAddMessage.handleServiceCall(input);
Futures.addCallback(future, new AddFlowCallback(input, flowRegistryKey), MoreExecutors.directExecutor());
} else {
future = flowAdd.processFlowModInputBuilders(flowAdd.toFlowModInputs(input));
Futures.addCallback(future, new AddFlowCallback(input, flowRegistryKey), MoreExecutors.directExecutor());
}
return future;
}
use of org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey in project openflowplugin by opendaylight.
the class FlowStatsMultipartWriter method storeStatistics.
@Override
public void storeStatistics(final FlowAndStatisticsMapList statistics, final boolean withParents) {
statistics.getFlowAndStatisticsMapList().forEach(stat -> {
final FlowBuilder flow = new FlowBuilder(stat).addAugmentation(FlowStatisticsData.class, new FlowStatisticsDataBuilder().setFlowStatistics(new FlowStatisticsBuilder(stat).build()).build());
final FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(version, flow.build());
registry.getDeviceFlowRegistry().store(flowRegistryKey);
final FlowDescriptor flowDescriptor = registry.getDeviceFlowRegistry().retrieveDescriptor(flowRegistryKey);
if (Objects.nonNull(flowDescriptor)) {
final FlowKey key = new FlowKey(flowDescriptor.getFlowId());
writeToTransaction(getInstanceIdentifier().augmentation(FlowCapableNode.class).child(Table.class, new TableKey(stat.getTableId())).child(Flow.class, key), flow.setId(key.getId()).setKey(key).build(), withParents);
}
});
}
use of org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey in project openflowplugin by opendaylight.
the class AbstractFlowDirectStatisticsService method generateFlowId.
/**
* Get flow ID from #{@link org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry} or
* create alien ID.
* @param flowStatistics flow statistics
* @return generated flow ID
*/
protected FlowId generateFlowId(FlowAndStatisticsMapList flowStatistics) {
final FlowStatisticsDataBuilder flowStatisticsDataBld = new FlowStatisticsDataBuilder().setFlowStatistics(new FlowStatisticsBuilder(flowStatistics).build());
final FlowBuilder flowBuilder = new FlowBuilder(flowStatistics).addAugmentation(FlowStatisticsData.class, flowStatisticsDataBld.build());
final FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(getVersion(), flowBuilder.build());
getDeviceRegistry().getDeviceFlowRegistry().store(flowRegistryKey);
return getDeviceRegistry().getDeviceFlowRegistry().retrieveDescriptor(flowRegistryKey).getFlowId();
}
use of org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey in project openflowplugin by opendaylight.
the class DeviceFlowRegistryImplTest method testStoreIfNecessary.
@Test
public void testStoreIfNecessary() throws Exception {
FlowId newFlowId;
// store existing key
deviceFlowRegistry.store(key);
newFlowId = deviceFlowRegistry.retrieveDescriptor(key).getFlowId();
Assert.assertEquals(1, deviceFlowRegistry.getAllFlowDescriptors().size());
Assert.assertEquals(descriptor, deviceFlowRegistry.retrieveDescriptor(key));
Assert.assertEquals(descriptor.getFlowId(), newFlowId);
// store new key
final String alienPrefix = "#UF$TABLE*2-";
final FlowRegistryKey key2 = FlowRegistryKeyFactory.create(OFConstants.OFP_VERSION_1_3, TestFlowHelper.createFlowAndStatisticsMapListBuilder(2).build());
deviceFlowRegistry.store(key2);
newFlowId = deviceFlowRegistry.retrieveDescriptor(key2).getFlowId();
Assert.assertTrue(newFlowId.getValue().startsWith(alienPrefix));
Assert.assertTrue(deviceFlowRegistry.retrieveDescriptor(key2).getFlowId().getValue().startsWith(alienPrefix));
Assert.assertEquals(2, deviceFlowRegistry.getAllFlowDescriptors().size());
}
use of org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey in project openflowplugin by opendaylight.
the class FlowRegistryKeyFactoryTest method testEquals.
@Test
public void testEquals() throws Exception {
FlowsStatisticsUpdate flowStats = FLOWS_STATISTICS_UPDATE_BUILDER.build();
HashSet<FlowRegistryKey> flowRegistryKeys = new HashSet<>();
for (FlowAndStatisticsMapList item : flowStats.getFlowAndStatisticsMapList()) {
final FlowRegistryKey key1 = FlowRegistryKeyFactory.create(deviceInfo.getVersion(), item);
final FlowRegistryKey key2 = FlowRegistryKeyFactory.create(deviceInfo.getVersion(), item);
flowRegistryKeys.add(key1);
flowRegistryKeys.add(key1);
flowRegistryKeys.add(key2);
}
assertEquals(3, flowRegistryKeys.size());
}
Aggregations