public ListenableFuture<Boolean> apply(final RpcResult<List<MultipartReply>> rpcResult) {
boolean isMultipartProcessed = Boolean.TRUE;
if (rpcResult.isSuccessful()) {
- LOG.debug("Stats reply successfully received for node {} of type {}", deviceInfo.getNodeId(), type);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Stats reply successfully received for node {} of type {}",
+ deviceInfo.getNodeId(), type);
+ }
// TODO: in case the result value is null then multipart data probably got processed on the fly -
// TODO: this contract should by clearly stated and enforced - now simple true value is returned
multipartData = multipartDataList.get(0);
allMultipartData = Iterables.concat(allMultipartData, multipartDataList);
}
- } catch (final Exception e) {
- LOG.warn("stats processing of type {} for node {} failed during transfomation step",
+ } catch (final TransactionChainClosedException e) {
+ LOG.warn("stats processing of type {} for node {} failed during transformation step",
type, deviceInfo.getNodeId(), e);
return Futures.immediateFailedFuture(e);
}
} else {
isMultipartProcessed = Boolean.FALSE;
}
- } catch (final Exception e) {
+ } catch (final TransactionChainClosedException e) {
LOG.warn("stats processing of type {} for node {} failed during write-to-tx step",
type, deviceInfo.getNodeId(), e);
return Futures.immediateFailedFuture(e);
}
- LOG.debug("Stats reply added to transaction for node {} of type {}",
- deviceInfo.getNodeId(), type);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Stats reply added to transaction for node {} of type {}",
+ deviceInfo.getNodeId(), type);
+ }
//TODO : implement experimenter
} else {
- LOG.debug("Stats reply was empty for node {} of type {}",
- deviceInfo.getNodeId(), type);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Stats reply was empty for node {} of type {}",
+ deviceInfo.getNodeId(), type);
+ }
}
} else {
- LOG.debug("Stats reply FAILED for node {} of type {}: {}",
- deviceInfo.getNodeId(), type, rpcResult.getErrors());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Stats reply FAILED for node {} of type {}: {}",
+ deviceInfo.getNodeId(), type, rpcResult.getErrors());
+ }
isMultipartProcessed = Boolean.FALSE;
}
return Futures.immediateFuture(isMultipartProcessed);
private static void processMeterConfigStatsUpdated(final Iterable<MeterConfigStatsUpdated> data,
final DeviceInfo deviceInfo,
final TxFacade txFacade,
- final DeviceMeterRegistry meterRegistry) throws Exception {
+ final DeviceMeterRegistry meterRegistry)
+ throws TransactionChainClosedException {
final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceInfo);
deleteAllKnownMeters(meterRegistry, fNodeIdent, txFacade);
for (final MeterConfigStatsUpdated meterConfigStatsUpdated : data) {
final ListenableFuture<Void> deleteFuture
= initial ? Futures.immediateFuture(null) : deleteAllKnownFlows(deviceInfo,
flowRegistry, txFacade);
- return Futures.transform(deleteFuture, new Function<Void, Boolean>() {
-
- @Override
- public Boolean apply(final Void input) {
- writeFlowStatistics(data, deviceInfo, flowRegistry, txFacade);
- txFacade.submitTransaction();
- EventsTimeCounter.markEnd(eventIdentifier);
- return Boolean.TRUE;
- }
+ return Futures.transform(deleteFuture, (Function<Void, Boolean>) input -> {
+ writeFlowStatistics(data, deviceInfo, flowRegistry, txFacade);
+ txFacade.submitTransaction();
+ EventsTimeCounter.markEnd(eventIdentifier);
+ return Boolean.TRUE;
});
}
txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL, flowIdent, flowBuilder.build());
}
}
- } catch (Exception e) {
+ } catch (TransactionChainClosedException e) {
LOG.warn("Not able to write to transaction: {}", e.getMessage());
}
}
private static void processQueueStatistics(
final Iterable<QueueStatisticsUpdate> data,
final DeviceInfo deviceInfo,
- final TxFacade txFacade) throws Exception {
+ final TxFacade txFacade) throws TransactionChainClosedException {
// TODO: clean all queues of all node-connectors before writing up-to-date stats
final InstanceIdentifier<Node> nodeIdent = deviceInfo.getNodeInstanceIdentifier();
for (final QueueStatisticsUpdate queueStatisticsUpdate : data) {
private static void processFlowTableStatistics(
final Iterable<FlowTableStatisticsUpdate> data,
final DeviceInfo deviceInfo,
- final TxFacade txFacade) throws Exception {
+ final TxFacade txFacade) throws TransactionChainClosedException {
final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceInfo);
for (final FlowTableStatisticsUpdate flowTableStatisticsUpdate : data) {
private static void processNodeConnectorStatistics(
final Iterable<NodeConnectorStatisticsUpdate> data,
final DeviceInfo deviceInfo,
- final TxFacade txFacade) throws Exception {
+ final TxFacade txFacade) throws TransactionChainClosedException {
final InstanceIdentifier<Node> nodeIdent = deviceInfo.getNodeInstanceIdentifier();
for (final NodeConnectorStatisticsUpdate nodeConnectorStatisticsUpdate : data) {
for (final NodeConnectorStatisticsAndPortNumberMap nodeConnectPort :
private static void processMetersStatistics(final Iterable<MeterStatisticsUpdated> data,
final DeviceInfo deviceInfo,
- final TxFacade txFacade) throws Exception {
+ final TxFacade txFacade) throws TransactionChainClosedException {
final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceInfo);
for (final MeterStatisticsUpdated meterStatisticsUpdated : data) {
for (final MeterStats meterStats : meterStatisticsUpdated.getMeterStats()) {
private static void deleteAllKnownMeters(
final DeviceMeterRegistry meterRegistry,
final InstanceIdentifier<FlowCapableNode> flowNodeIdent,
- final TxFacade txFacade) throws Exception {
+ final TxFacade txFacade) throws TransactionChainClosedException {
for (final MeterId meterId : meterRegistry.getAllMeterIds()) {
final InstanceIdentifier<Meter> meterIdent = flowNodeIdent.child(Meter.class, new MeterKey(meterId));
txFacade.addDeleteToTxChain(LogicalDatastoreType.OPERATIONAL, meterIdent);
final Iterable<GroupDescStatsUpdated> data,
final DeviceInfo deviceInfo,
final TxFacade txFacade,
- final DeviceGroupRegistry groupRegistry) throws Exception {
+ final DeviceGroupRegistry groupRegistry) throws TransactionChainClosedException {
final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceInfo);
deleteAllKnownGroups(txFacade, fNodeIdent, groupRegistry);
private static void deleteAllKnownGroups(
final TxFacade txFacade,
final InstanceIdentifier<FlowCapableNode> flowNodeIdent,
- final DeviceGroupRegistry groupRegistry) throws Exception {
+ final DeviceGroupRegistry groupRegistry) throws TransactionChainClosedException {
for (final GroupId groupId : groupRegistry.getAllGroupIds()) {
final InstanceIdentifier<Group> groupIdent = flowNodeIdent.child(Group.class, new GroupKey(groupId));
txFacade.addDeleteToTxChain(LogicalDatastoreType.OPERATIONAL, groupIdent);
private static void processGroupStatistics(
final Iterable<GroupStatisticsUpdated> data,
final DeviceInfo deviceInfo,
- final TxFacade txFacade) throws Exception {
+ final TxFacade txFacade) throws TransactionChainClosedException {
final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceInfo);
for (final GroupStatisticsUpdated groupStatistics : data) {
for (final GroupStats groupStats : groupStatistics.getGroupStats()) {
import org.opendaylight.openflowplugin.api.openflow.registry.meter.DeviceMeterRegistry;
import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier;
import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.StatisticsGatherer;
-import org.opendaylight.openflowplugin.impl.registry.flow.FlowRegistryKeyFactory;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
fireAndCheck(type, statsData);
final InstanceIdentifier<GroupStatistics> groupPath = dummyNodePath.augmentation(FlowCapableNode.class)
- .child(Group.class, new GroupKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId(groupIdValue)))
+ .child(Group.class, new GroupKey(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId(groupIdValue)))
.augmentation(NodeGroupStatistics.class)
.child(GroupStatistics.class);
verify(txFacade).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL),
fireAndCheck(type, statsData);
- final org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId storedGroupId = new org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId(groupIdValue);
- final KeyedInstanceIdentifier<Group, GroupKey> groupPath = dummyNodePath.augmentation(FlowCapableNode.class).child(Group.class, new GroupKey(storedGroupId));
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId storedGroupId
+ = new org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId(groupIdValue);
+ final KeyedInstanceIdentifier<Group, GroupKey> groupPath
+ = dummyNodePath.augmentation(FlowCapableNode.class).child(Group.class, new GroupKey(storedGroupId));
- verify(deviceContext, Mockito.never()).addDeleteToTxChain(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.<InstanceIdentifier<?>> any());
+ verify(deviceContext, Mockito.never()).addDeleteToTxChain(
+ Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.<InstanceIdentifier<?>>any());
verify(deviceGroupRegistry).removeMarked();
verify(deviceGroupRegistry).store(storedGroupId);
verify(txFacade).writeToTransaction(
fireAndCheck(type, statsData);
final InstanceIdentifier<MeterStatistics> meterPath = dummyNodePath.augmentation(FlowCapableNode.class)
- .child(Meter.class, new MeterKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId(meterIdValue)))
+ .child(Meter.class, new MeterKey(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId(meterIdValue)))
.augmentation(NodeMeterStatistics.class)
.child(MeterStatistics.class);
verify(txFacade).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL),
fireAndCheck(type, statsData);
final InstanceIdentifier<FlowCapableNodeConnectorStatistics> portPath = dummyNodePath
- .child(NodeConnector.class, new NodeConnectorKey(new NodeConnectorId("openflow:" + DUMMY_NODE_ID_VALUE + ":11")))
+ .child(NodeConnector.class, new NodeConnectorKey(
+ new NodeConnectorId("openflow:" + DUMMY_NODE_ID_VALUE + ":11")))
.augmentation(FlowCapableNodeConnectorStatisticsData.class)
.child(FlowCapableNodeConnectorStatistics.class);
verify(txFacade).writeToTransaction(
fireAndCheck(type, statsData);
final KeyedInstanceIdentifier<Queue, QueueKey> queuePath = dummyNodePath
- .child(NodeConnector.class, new NodeConnectorKey(new NodeConnectorId("openflow:" + DUMMY_NODE_ID_VALUE + ":11")))
+ .child(NodeConnector.class, new NodeConnectorKey(
+ new NodeConnectorId("openflow:" + DUMMY_NODE_ID_VALUE + ":11")))
.augmentation(FlowCapableNodeConnector.class)
.child(Queue.class, new QueueKey(new QueueId(queueIdValue)));
verify(txFacade).writeToTransaction(
final short tableId = 0;
final MultipartType type = MultipartType.OFPMPFLOW;
- final InstanceIdentifier<FlowCapableNode> nodePath = deviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
+ 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);
+ 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 =
+ 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()
.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());
+ verify(deviceContext, Mockito.never()).addDeleteToTxChain(
+ Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.<InstanceIdentifier<?>>any());
final InOrder inOrder = Mockito.inOrder(txFacade);
- inOrder.verify(txFacade).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(tablePath), Matchers.any(Table.class));
+ inOrder.verify(txFacade).writeToTransaction(Matchers.eq(
+ LogicalDatastoreType.OPERATIONAL), Matchers.eq(tablePath), Matchers.any(Table.class));
}
@Test
final MultipartReplyMeterConfigBuilder mpReplyMeterConfigBld = new MultipartReplyMeterConfigBuilder();
mpReplyMeterConfigBld.setMeterConfig(Lists.newArrayList(meterConfigBld.build()));
- final MultipartReplyMeterConfigCaseBuilder mpReplyMeterConfigCaseBld = new MultipartReplyMeterConfigCaseBuilder();
+ final MultipartReplyMeterConfigCaseBuilder mpReplyMeterConfigCaseBld
+ = new MultipartReplyMeterConfigCaseBuilder();
mpReplyMeterConfigCaseBld.setMultipartReplyMeterConfig(mpReplyMeterConfigBld.build());
final MultipartReply meterConfigUpdated = assembleMPReplyMessage(type, mpReplyMeterConfigCaseBld.build());
new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId(meterIdValue);
final KeyedInstanceIdentifier<Meter, MeterKey> meterPath = dummyNodePath.augmentation(FlowCapableNode.class)
.child(Meter.class, new MeterKey(meterId));
- verify(deviceContext, Mockito.never()).addDeleteToTxChain(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.<InstanceIdentifier<?>>any());
+ verify(deviceContext, Mockito.never()).addDeleteToTxChain(
+ Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.<InstanceIdentifier<?>>any());
verify(deviceMeterRegistry).store(meterId);
- verify(txFacade).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(meterPath), Matchers.any(Meter.class));
+ verify(txFacade).writeToTransaction(
+ Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(meterPath), Matchers.any(Meter.class));
}
- private void fireAndCheck(final MultipartType type, final List<MultipartReply> statsData) throws InterruptedException, ExecutionException, TimeoutException {
+ private void fireAndCheck(
+ final MultipartType type,
+ final List<MultipartReply> statsData) throws InterruptedException, ExecutionException, TimeoutException {
when(statisticsService.getStatisticsOfType(Matchers.any(EventIdentifier.class), Matchers.eq(type)))
.thenReturn(Futures.immediateFuture(RpcResultBuilder.success(statsData).build()));
deviceContext,
false,
singlePurposeMultipartReplyTranslator);
- Assert.assertTrue(gatherStatisticsResult.get(1, TimeUnit.SECONDS).booleanValue());
+ Assert.assertTrue(gatherStatisticsResult.get(1, TimeUnit.SECONDS));
verify(txFacade).submitTransaction();
}
- private static MultipartReplyMessage assembleMPReplyMessage(final MultipartType type, final MultipartReplyBody mpReplyGroupCaseBld) {
+ private static MultipartReplyMessage assembleMPReplyMessage(
+ final MultipartType type,
+ final MultipartReplyBody mpReplyGroupCaseBld) {
return new MultipartReplyMessageBuilder()
.setMultipartReplyBody(mpReplyGroupCaseBld)
.setType(type)
}
private static BucketStats createBucketStat(final long byteCount, final long packetCount) {
- return new BucketStatsBuilder().setByteCount(BigInteger.valueOf(byteCount)).setPacketCount(BigInteger.valueOf(packetCount)).build();
+ return new BucketStatsBuilder().setByteCount(
+ BigInteger.valueOf(byteCount)).setPacketCount(BigInteger.valueOf(packetCount)).build();
}
@Test
public void testDeleteAllKnownFlows() throws Exception {
final short tableId = 0;
- final InstanceIdentifier<FlowCapableNode> nodePath = deviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
+ 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);
+ final CheckedFuture<Optional<FlowCapableNode>, ReadFailedException> flowNodeFuture
+ = Futures.immediateCheckedFuture(flowNodeOpt);
when(readTx.read(LogicalDatastoreType.OPERATIONAL, nodePath)).thenReturn(flowNodeFuture);
final KeyedInstanceIdentifier<Table, TableKey> tablePath = deviceInfo.getNodeInstanceIdentifier()
.augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tableId));