From: Jozef Gloncak Date: Fri, 20 Feb 2015 13:20:37 +0000 (+0100) Subject: BUG 2661 - sonar issues in openflowplugin artifact2 X-Git-Tag: release/lithium~659 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=832efcf1dbb26d66a2c01146c6dcc388ba0abb65;p=openflowplugin.git BUG 2661 - sonar issues in openflowplugin artifact2 Some of sonar issues in openflowplugin artifact in package org.opendaylight.openflowplugin.openflow.md.core were solved. Change-Id: Id2731f16cd5c026245cd6c3894dc1ca90b13c787 Signed-off-by: Jozef Gloncak --- diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/AbstractModelDrivenSwitch.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/AbstractModelDrivenSwitch.java index 1dbec72a52..4cc5bc73c2 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/AbstractModelDrivenSwitch.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/AbstractModelDrivenSwitch.java @@ -37,32 +37,6 @@ public abstract class AbstractModelDrivenSwitch implements ModelDrivenSwitch { private final InstanceIdentifier identifier; - private RoutedRpcRegistration flowRegistration; - - private RoutedRpcRegistration groupRegistration; - - private RoutedRpcRegistration tableRegistration; - - private RoutedRpcRegistration meterRegistration; - - private RoutedRpcRegistration portRegistration; - - private RoutedRpcRegistration nodeConfigRegistration; - - private RoutedRpcRegistration packetRegistration; - - private RoutedRpcRegistration flowStatisticsRegistration; - - private RoutedRpcRegistration groupStatisticsRegistration; - - private RoutedRpcRegistration meterStatisticsRegistration; - - private RoutedRpcRegistration portStatisticsRegistration; - - private RoutedRpcRegistration flowTableStatisticsRegistration; - - private RoutedRpcRegistration queueStatisticsRegistration; - protected final SessionContext sessionContext; protected AbstractModelDrivenSwitch(InstanceIdentifier identifier,SessionContext conductor) { @@ -80,55 +54,55 @@ public abstract class AbstractModelDrivenSwitch implements ModelDrivenSwitch { CompositeObjectRegistrationBuilder builder = CompositeObjectRegistration . builderFor(this); - flowRegistration = ctx.addRoutedRpcImplementation(SalFlowService.class, this); + final RoutedRpcRegistration flowRegistration = ctx.addRoutedRpcImplementation(SalFlowService.class, this); flowRegistration.registerPath(NodeContext.class, getIdentifier()); builder.add(flowRegistration); - - portRegistration = ctx.addRoutedRpcImplementation(SalPortService.class, this); + + final RoutedRpcRegistration portRegistration = ctx.addRoutedRpcImplementation(SalPortService.class, this); portRegistration.registerPath(NodeContext.class, getIdentifier()); builder.add(portRegistration); - meterRegistration = ctx.addRoutedRpcImplementation(SalMeterService.class, this); + final RoutedRpcRegistration meterRegistration = ctx.addRoutedRpcImplementation(SalMeterService.class, this); meterRegistration.registerPath(NodeContext.class, getIdentifier()); builder.add(meterRegistration); - groupRegistration = ctx.addRoutedRpcImplementation(SalGroupService.class, this); + final RoutedRpcRegistration groupRegistration = ctx.addRoutedRpcImplementation(SalGroupService.class, this); groupRegistration.registerPath(NodeContext.class, getIdentifier()); builder.add(groupRegistration); - - tableRegistration = ctx.addRoutedRpcImplementation(SalTableService.class, this); + + final RoutedRpcRegistration tableRegistration = ctx.addRoutedRpcImplementation(SalTableService.class, this); tableRegistration.registerPath(NodeContext.class, getIdentifier()); builder.add(tableRegistration); - packetRegistration = ctx.addRoutedRpcImplementation(PacketProcessingService.class, this); + final RoutedRpcRegistration packetRegistration = ctx.addRoutedRpcImplementation(PacketProcessingService.class, this); packetRegistration.registerPath(NodeContext.class, getIdentifier()); builder.add(packetRegistration); - flowStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightFlowStatisticsService.class, this); + final RoutedRpcRegistration flowStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightFlowStatisticsService.class, this); flowStatisticsRegistration.registerPath(NodeContext.class, getIdentifier()); builder.add(flowStatisticsRegistration); - groupStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightGroupStatisticsService.class, this); + final RoutedRpcRegistration groupStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightGroupStatisticsService.class, this); groupStatisticsRegistration.registerPath(NodeContext.class, getIdentifier()); builder.add(groupStatisticsRegistration); - meterStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightMeterStatisticsService.class, this); + final RoutedRpcRegistration meterStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightMeterStatisticsService.class, this); meterStatisticsRegistration.registerPath(NodeContext.class, getIdentifier()); builder.add(meterStatisticsRegistration); - portStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightPortStatisticsService.class, this); + final RoutedRpcRegistration portStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightPortStatisticsService.class, this); portStatisticsRegistration.registerPath(NodeContext.class, getIdentifier()); builder.add(portStatisticsRegistration); - nodeConfigRegistration = ctx.addRoutedRpcImplementation(NodeConfigService.class, this); + final RoutedRpcRegistration nodeConfigRegistration = ctx.addRoutedRpcImplementation(NodeConfigService.class, this); nodeConfigRegistration.registerPath(NodeContext.class, getIdentifier()); builder.add(nodeConfigRegistration); - - flowTableStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightFlowTableStatisticsService.class, this); + + final RoutedRpcRegistration flowTableStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightFlowTableStatisticsService.class, this); flowTableStatisticsRegistration.registerPath(NodeContext.class, getIdentifier()); builder.add(flowTableStatisticsRegistration); - - queueStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightQueueStatisticsService.class, this); + + final RoutedRpcRegistration queueStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightQueueStatisticsService.class, this); queueStatisticsRegistration.registerPath(NodeContext.class, getIdentifier()); builder.add(queueStatisticsRegistration); diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/BuildSwitchCapabilitiesOF10.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/BuildSwitchCapabilitiesOF10.java index 4d605e4f0a..0fbc1a1e7f 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/BuildSwitchCapabilitiesOF10.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/BuildSwitchCapabilitiesOF10.java @@ -31,7 +31,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 * @author jsebin * */ -public class BuildSwitchCapabilitiesOF10 implements BuildSwitchFeatures { +public final class BuildSwitchCapabilitiesOF10 implements BuildSwitchFeatures { private static BuildSwitchCapabilitiesOF10 instance = new BuildSwitchCapabilitiesOF10(); diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/BuildSwitchCapabilitiesOF13.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/BuildSwitchCapabilitiesOF13.java index 17ea875aef..f9d1f4370f 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/BuildSwitchCapabilitiesOF13.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/BuildSwitchCapabilitiesOF13.java @@ -29,7 +29,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 * @author jsebin * */ -public class BuildSwitchCapabilitiesOF13 implements BuildSwitchFeatures { +public final class BuildSwitchCapabilitiesOF13 implements BuildSwitchFeatures { private static BuildSwitchCapabilitiesOF13 instance = new BuildSwitchCapabilitiesOF13(); diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/ModelDrivenSwitchImpl.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/ModelDrivenSwitchImpl.java index 110af9890b..46eca4f7d9 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/ModelDrivenSwitchImpl.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/ModelDrivenSwitchImpl.java @@ -98,7 +98,6 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch { private final NodeId nodeId; private final IMessageDispatchService messageService; private short version = 0; - private NotificationProviderService rpcNotificationProviderService; private OFRpcTaskContext rpcTaskContext; // TODO:read timeout from configSubsystem @@ -111,7 +110,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch { this.nodeId = nodeId; messageService = sessionContext.getMessageDispatchService(); version = sessionContext.getPrimaryConductor().getVersion(); - rpcNotificationProviderService = OFSessionUtil.getSessionManager().getNotificationProviderService(); + final NotificationProviderService rpcNotificationProviderService = OFSessionUtil.getSessionManager().getNotificationProviderService(); rpcTaskContext = new OFRpcTaskContext(); rpcTaskContext.setSession(sessionContext); @@ -284,248 +283,201 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch { @Override public Future> getGroupDescription(final GetGroupDescriptionInput input) { LOG.debug("Calling the getGroupDescription RPC method on MessageDispatchService"); - SwitchConnectionDistinguisher cookie = null; OFRpcTask> task = - OFRpcTaskFactory.createGetGroupDescriptionTask(rpcTaskContext, input, cookie); - ListenableFuture> result = task.submit(); - return result; + OFRpcTaskFactory.createGetGroupDescriptionTask(rpcTaskContext, input, null); + return task.submit(); } @Override public Future> getGroupFeatures(final GetGroupFeaturesInput input) { LOG.debug("Calling the getGroupFeatures RPC method on MessageDispatchService"); - SwitchConnectionDistinguisher cookie = null; OFRpcTask> task = - OFRpcTaskFactory.createGetGroupFeaturesTask(rpcTaskContext, input, cookie); - ListenableFuture> result = task.submit(); - return result; + OFRpcTaskFactory.createGetGroupFeaturesTask(rpcTaskContext, input, null); + return task.submit(); } @Override public Future> getGroupStatistics(final GetGroupStatisticsInput input) { LOG.debug("Calling the getGroupStatistics RPC method on MessageDispatchService"); - SwitchConnectionDistinguisher cookie = null; OFRpcTask> task = - OFRpcTaskFactory.createGetGroupStatisticsTask(rpcTaskContext, input, cookie); - ListenableFuture> result = task.submit(); - return result; + OFRpcTaskFactory.createGetGroupStatisticsTask(rpcTaskContext, input, null); + return task.submit(); } @Override public Future> getAllMeterConfigStatistics( final GetAllMeterConfigStatisticsInput input) { LOG.debug("Calling the getAllMeterConfigStatistics RPC method on MessageDispatchService"); - SwitchConnectionDistinguisher cookie = null; OFRpcTask> task = - OFRpcTaskFactory.createGetAllMeterConfigStatisticsTask(rpcTaskContext, input, cookie); - ListenableFuture> result = task.submit(); - return result; + OFRpcTaskFactory.createGetAllMeterConfigStatisticsTask(rpcTaskContext, input, null); + return task.submit(); } @Override public Future> getAllMeterStatistics( final GetAllMeterStatisticsInput input) { LOG.debug("Calling the getAllMeterStatistics RPC method on MessageDispatchService"); - SwitchConnectionDistinguisher cookie = null; OFRpcTask> task = - OFRpcTaskFactory.createGetAllMeterStatisticsTask(rpcTaskContext, input, cookie); - ListenableFuture> result = task.submit(); - return result; + OFRpcTaskFactory.createGetAllMeterStatisticsTask(rpcTaskContext, input, null); + return task.submit(); } @Override public Future> getMeterFeatures( final GetMeterFeaturesInput input) { LOG.debug("Calling the getMeterFeatures RPC method on MessageDispatchService"); - SwitchConnectionDistinguisher cookie = null; OFRpcTask> task = - OFRpcTaskFactory.createGetMeterFeaturesTask(rpcTaskContext, input, cookie); - ListenableFuture> result = task.submit(); - return result; + OFRpcTaskFactory.createGetMeterFeaturesTask(rpcTaskContext, input, null); + return task.submit(); } @Override public Future> getMeterStatistics( final GetMeterStatisticsInput input) { LOG.debug("Calling the getMeterStatistics RPC method on MessageDispatchService"); - SwitchConnectionDistinguisher cookie = null; OFRpcTask> task = - OFRpcTaskFactory.createGetMeterStatisticsTask(rpcTaskContext, input, cookie); - ListenableFuture> result = task.submit(); - return result; + OFRpcTaskFactory.createGetMeterStatisticsTask(rpcTaskContext, input, null); + return task.submit(); } @Override public Future> getAllNodeConnectorsStatistics( final GetAllNodeConnectorsStatisticsInput input) { LOG.debug("Calling the getAllNodeConnectorsStatistics RPC method on MessageDispatchService"); - SwitchConnectionDistinguisher cookie = null; OFRpcTask> task = - OFRpcTaskFactory.createGetAllNodeConnectorsStatisticsTask(rpcTaskContext, input, cookie); - ListenableFuture> result = task.submit(); - return result; + OFRpcTaskFactory.createGetAllNodeConnectorsStatisticsTask(rpcTaskContext, input, null); + return task.submit(); } @Override public Future> getNodeConnectorStatistics( final GetNodeConnectorStatisticsInput input) { LOG.debug("Calling the getNodeConnectorStatistics RPC method on MessageDispatchService"); - SwitchConnectionDistinguisher cookie = null; OFRpcTask> task = - OFRpcTaskFactory.createGetNodeConnectorStatisticsTask(rpcTaskContext, input, cookie); - ListenableFuture> result = task.submit(); - return result; + OFRpcTaskFactory.createGetNodeConnectorStatisticsTask(rpcTaskContext, input, null); + return task.submit(); } @Override public Future> updatePort(final UpdatePortInput input) { LOG.debug("Calling the updatePort RPC method on MessageDispatchService"); - // use primary connection - SwitchConnectionDistinguisher cookie = null; - OFRpcTask> task = - OFRpcTaskFactory.createUpdatePortTask(rpcTaskContext, input, cookie); - ListenableFuture> result = task.submit(); - - return result; + OFRpcTaskFactory.createUpdatePortTask(rpcTaskContext, input, null); + return task.submit(); } @Override public Future> updateTable(final UpdateTableInput input) { LOG.debug("Calling the updateTable RPC method on MessageDispatchService"); - SwitchConnectionDistinguisher cookie = null; - OFRpcTask> task = - OFRpcTaskFactory.createUpdateTableTask(rpcTaskContext, input, cookie); - ListenableFuture> result = task.submit(); - - return result; + OFRpcTaskFactory.createUpdateTableTask(rpcTaskContext, input, null); + return task.submit(); } @Override public Future> getAllFlowStatisticsFromFlowTable( final GetAllFlowStatisticsFromFlowTableInput input) { LOG.debug("Calling the getAllFlowStatisticsFromFlowTable RPC method on MessageDispatchService"); - SwitchConnectionDistinguisher cookie = null; OFRpcTask> task = - OFRpcTaskFactory.createGetAllFlowStatisticsFromFlowTableTask(rpcTaskContext, input, cookie); - ListenableFuture> result = task.submit(); - return result; + OFRpcTaskFactory.createGetAllFlowStatisticsFromFlowTableTask(rpcTaskContext, input, null); + return task.submit(); } @Override public Future> getAllFlowsStatisticsFromAllFlowTables( final GetAllFlowsStatisticsFromAllFlowTablesInput input) { LOG.debug("Calling the getAllFlowsStatisticsFromAllFlowTables RPC method on MessageDispatchService"); - SwitchConnectionDistinguisher cookie = null; OFRpcTask> task = - OFRpcTaskFactory.createGetAllFlowsStatisticsFromAllFlowTablesTask(rpcTaskContext, input, cookie); - ListenableFuture> result = task.submit(); - return result; + OFRpcTaskFactory.createGetAllFlowsStatisticsFromAllFlowTablesTask(rpcTaskContext, input, null); + return task.submit(); } @Override public Future> getFlowStatisticsFromFlowTable( final GetFlowStatisticsFromFlowTableInput input) { LOG.debug("Calling the getFlowStatisticsFromFlowTable RPC method on MessageDispatchService"); - SwitchConnectionDistinguisher cookie = null; OFRpcTask> task = - OFRpcTaskFactory.createGetFlowStatisticsFromFlowTableTask(rpcTaskContext, input, cookie); - ListenableFuture> result = task.submit(); - return result; + OFRpcTaskFactory.createGetFlowStatisticsFromFlowTableTask(rpcTaskContext, input, null); + return task.submit(); } @Override public Future> getAggregateFlowStatisticsFromFlowTableForAllFlows( final GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input) { LOG.debug("Calling the getAggregateFlowStatisticsFromFlowTableForAllFlows RPC method on MessageDispatchService"); - SwitchConnectionDistinguisher cookie = null; OFRpcTask> task = - OFRpcTaskFactory.createGetAggregateFlowStatisticsFromFlowTableForAllFlowsTask(rpcTaskContext, input, cookie); - ListenableFuture> result = task.submit(); - return result; + OFRpcTaskFactory.createGetAggregateFlowStatisticsFromFlowTableForAllFlowsTask(rpcTaskContext, input, null); + return task.submit(); } @Override public Future> getAggregateFlowStatisticsFromFlowTableForGivenMatch( final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) { LOG.debug("Calling the getAggregateFlowStatisticsFromFlowTableForGivenMatch RPC method on MessageDispatchService"); - SwitchConnectionDistinguisher cookie = null; OFRpcTask> task = - OFRpcTaskFactory.createGetAggregateFlowStatisticsFromFlowTableForGivenMatchTask(rpcTaskContext, input, cookie); - ListenableFuture> result = task.submit(); - return result; + OFRpcTaskFactory.createGetAggregateFlowStatisticsFromFlowTableForGivenMatchTask(rpcTaskContext, input, null); + return task.submit(); } @Override public Future> getFlowTablesStatistics( final GetFlowTablesStatisticsInput input) { LOG.debug("Calling the getFlowTablesStatistics RPC method on MessageDispatchService"); - SwitchConnectionDistinguisher cookie = null; OFRpcTask> task = - OFRpcTaskFactory.createGetFlowTablesStatisticsTask(rpcTaskContext, input, cookie); - ListenableFuture> result = task.submit(); - return result; + OFRpcTaskFactory.createGetFlowTablesStatisticsTask(rpcTaskContext, input, null); + return task.submit(); } @Override public Future> getAllQueuesStatisticsFromAllPorts( final GetAllQueuesStatisticsFromAllPortsInput input) { LOG.debug("Calling the getAllQueuesStatisticsFromAllPorts RPC method on MessageDispatchService"); - SwitchConnectionDistinguisher cookie = null; OFRpcTask> task = - OFRpcTaskFactory.createGetAllQueuesStatisticsFromAllPortsTask(rpcTaskContext, input, cookie); - ListenableFuture> result = task.submit(); - return result; + OFRpcTaskFactory.createGetAllQueuesStatisticsFromAllPortsTask(rpcTaskContext, input, null); + return task.submit(); } @Override public Future> getAllQueuesStatisticsFromGivenPort( final GetAllQueuesStatisticsFromGivenPortInput input) { LOG.debug("Calling the getAllQueuesStatisticsFromGivenPort RPC method on MessageDispatchService"); - SwitchConnectionDistinguisher cookie = null; OFRpcTask> task = - OFRpcTaskFactory.createGetAllQueuesStatisticsFromGivenPortTask(rpcTaskContext, input, cookie); - ListenableFuture> result = task.submit(); - return result; + OFRpcTaskFactory.createGetAllQueuesStatisticsFromGivenPortTask(rpcTaskContext, input, null); + return task.submit(); } @Override public Future> getQueueStatisticsFromGivenPort( final GetQueueStatisticsFromGivenPortInput input) { LOG.debug("Calling the getQueueStatisticsFromGivenPort RPC method on MessageDispatchService"); - SwitchConnectionDistinguisher cookie = null; OFRpcTask> task = - OFRpcTaskFactory.createGetQueueStatisticsFromGivenPortTask(rpcTaskContext, input, cookie); - ListenableFuture> result = task.submit(); - return result; + OFRpcTaskFactory.createGetQueueStatisticsFromGivenPortTask(rpcTaskContext, input, null); + return task.submit(); } @Override public Future> setConfig(SetConfigInput input) { - SwitchConnectionDistinguisher cookie = null; - OFRpcTask> task = OFRpcTaskFactory.createSetNodeConfigTask(rpcTaskContext, input, cookie); - ListenableFuture> result = task.submit(); - return result; + OFRpcTask> task = OFRpcTaskFactory.createSetNodeConfigTask(rpcTaskContext, input, null); + return task.submit(); } } diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OFRpcFutureResultTransformFactory.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OFRpcFutureResultTransformFactory.java index aa8982043e..dff14ae0ff 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OFRpcFutureResultTransformFactory.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OFRpcFutureResultTransformFactory.java @@ -1,6 +1,6 @@ /** * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * + * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html @@ -8,7 +8,6 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal; import java.util.Collection; - import org.opendaylight.controller.sal.common.util.Rpcs; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutputBuilder; @@ -29,14 +28,14 @@ import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - import com.google.common.base.Function; /** - * collection of transformation functions dedicated to rpc future results + * collection of transformation functions dedicated to rpc future results */ public abstract class OFRpcFutureResultTransformFactory { - + + private static final String MSG_ADD_FLOW_RPC = "Returning the Add Flow RPC result to MD-SAL"; protected static Logger LOG = LoggerFactory .getLogger(OFRpcFutureResultTransformFactory.class); @@ -47,8 +46,7 @@ public abstract class OFRpcFutureResultTransformFactory { */ protected static RpcResult assembleRpcResult(RpcResult input, E result) { Collection errors = input.getErrors(); - RpcResult rpcResult = Rpcs.getRpcResult(input.isSuccessful(), result, errors); - return rpcResult; + return Rpcs.getRpcResult(input.isSuccessful(), result, errors); } /** @@ -67,13 +65,13 @@ public abstract class OFRpcFutureResultTransformFactory { AddFlowOutput result = addFlowOutput.build(); RpcResult rpcResult = assembleRpcResult(input, result); - LOG.debug("Returning the Add Flow RPC result to MD-SAL"); + LOG.debug(MSG_ADD_FLOW_RPC); return rpcResult; } }; } - + /** * @return translator from {@link UpdateFlowOutput} to {@link RemoveFlowOutput} */ @@ -90,13 +88,13 @@ public abstract class OFRpcFutureResultTransformFactory { RemoveFlowOutput result = removeFlowOutput.build(); RpcResult rpcResult = assembleRpcResult(input, result); - LOG.debug("Returning the Add Flow RPC result to MD-SAL"); + LOG.debug(MSG_ADD_FLOW_RPC); return rpcResult; } }; } - + /** * @return translator from {@link UpdateGroupOutput} to {@link AddGroupOutput} */ @@ -106,7 +104,7 @@ public abstract class OFRpcFutureResultTransformFactory { @Override public RpcResult apply(final RpcResult input) { UpdateGroupOutput updateGroupOutput = input.getResult(); - + AddGroupOutputBuilder addGroupOutput = new AddGroupOutputBuilder(); addGroupOutput.setTransactionId(updateGroupOutput.getTransactionId()); AddGroupOutput result = addGroupOutput.build(); @@ -117,7 +115,7 @@ public abstract class OFRpcFutureResultTransformFactory { } }; } - + /** * @return */ @@ -134,13 +132,13 @@ public abstract class OFRpcFutureResultTransformFactory { RemoveGroupOutput result = removeGroupOutput.build(); RpcResult rpcResult = assembleRpcResult(input, result); - LOG.debug("Returning the Add Flow RPC result to MD-SAL"); + LOG.debug(MSG_ADD_FLOW_RPC); return rpcResult; } }; } - + /** * @return translator from {@link UpdateMeterOutput} to {@link AddMeterOutput} */ @@ -150,7 +148,7 @@ public abstract class OFRpcFutureResultTransformFactory { @Override public RpcResult apply(final RpcResult input) { UpdateMeterOutput updateMeterOutput = input.getResult(); - + AddMeterOutputBuilder addMeterOutput = new AddMeterOutputBuilder(); addMeterOutput.setTransactionId(updateMeterOutput.getTransactionId()); AddMeterOutput result = addMeterOutput.build(); @@ -161,8 +159,8 @@ public abstract class OFRpcFutureResultTransformFactory { } }; } - - + + /** * @return */ @@ -172,7 +170,7 @@ public abstract class OFRpcFutureResultTransformFactory { @Override public RpcResult apply(final RpcResult input) { UpdateMeterOutput updateMeterOutput = input.getResult(); - + RemoveMeterOutputBuilder removeMeterOutput = new RemoveMeterOutputBuilder(); removeMeterOutput.setTransactionId(updateMeterOutput.getTransactionId()); RemoveMeterOutput result = removeMeterOutput.build(); @@ -183,8 +181,8 @@ public abstract class OFRpcFutureResultTransformFactory { } }; } - - - - + + + + } diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OpenflowPluginProvider.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OpenflowPluginProvider.java index 7cbbc262e1..3ca9a2676d 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OpenflowPluginProvider.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OpenflowPluginProvider.java @@ -8,9 +8,7 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal; import java.util.Collection; -import java.util.Collections; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; @@ -22,7 +20,6 @@ import org.opendaylight.openflowplugin.api.statistics.MessageCountDumper; import org.opendaylight.openflowplugin.api.statistics.MessageObservatory; import org.opendaylight.openflowplugin.statistics.MessageSpyCounterImpl; import org.opendaylight.yangtools.yang.binding.DataContainer; -import org.opendaylight.yangtools.yang.binding.RpcService; import org.osgi.framework.BundleContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -32,7 +29,7 @@ import org.slf4j.LoggerFactory; */ public class OpenflowPluginProvider implements BindingAwareProvider, AutoCloseable { - private static Logger LOG = LoggerFactory.getLogger(OpenflowPluginProvider.class); + private static final Logger LOG = LoggerFactory.getLogger(OpenflowPluginProvider.class); private BindingAwareBroker broker; diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/SalRegistrationManager.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/SalRegistrationManager.java index 7b48c623fa..02d60ac110 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/SalRegistrationManager.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/SalRegistrationManager.java @@ -50,7 +50,7 @@ import org.slf4j.LoggerFactory; */ public class SalRegistrationManager implements SessionListener, AutoCloseable { - private final static Logger LOG = LoggerFactory.getLogger(SalRegistrationManager.class); + private static final Logger LOG = LoggerFactory.getLogger(SalRegistrationManager.class); private ProviderContext providerContext; @@ -138,7 +138,7 @@ public class SalRegistrationManager implements SessionListener, AutoCloseable { try { builder2.setIpAddress(getIpAddressOf(sw)); } catch (Exception e) { - LOG.warn("IP address of the node {} cannot be obtained: {}", sw.getNodeId(), e.getMessage()); + LOG.warn("IP address of the node {} cannot be obtained.", sw.getNodeId(), e); } builder2.setSwitchFeatures(swFeaturesUtil.buildSwitchFeatures(features)); builder.addAugmentation(FlowCapableNodeUpdated.class, builder2.build()); @@ -148,10 +148,6 @@ public class SalRegistrationManager implements SessionListener, AutoCloseable { private static IpAddress getIpAddressOf(ModelDrivenSwitch sw) { SessionContext sessionContext = sw.getSessionContext(); -// if (!sessionContext.isValid()) { -// LOG.warn("IP address of the node {} cannot be obtained. Session is not valid.", sw.getNodeId()); -// return null; -// } Preconditions.checkNotNull(sessionContext.getPrimaryConductor(), "primary conductor must not be NULL -> " + sw.getNodeId()); Preconditions.checkNotNull(sessionContext.getPrimaryConductor().getConnectionAdapter(), diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/SwitchFeaturesUtil.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/SwitchFeaturesUtil.java index cb9ff68901..f35f71c58d 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/SwitchFeaturesUtil.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/SwitchFeaturesUtil.java @@ -7,6 +7,9 @@ */ package org.opendaylight.openflowplugin.openflow.md.core.sal; +import static org.opendaylight.openflowplugin.api.OFConstants.OFP_VERSION_1_0; +import static org.opendaylight.openflowplugin.api.OFConstants.OFP_VERSION_1_3; + import java.util.HashMap; import java.util.Map; @@ -20,17 +23,17 @@ import org.slf4j.LoggerFactory; * @author jsebin * */ -public class SwitchFeaturesUtil { +public final class SwitchFeaturesUtil { - protected static final Logger LOG = LoggerFactory.getLogger(SwitchFeaturesUtil.class); + private static final Logger LOG = LoggerFactory.getLogger(SwitchFeaturesUtil.class); private static SwitchFeaturesUtil instance = new SwitchFeaturesUtil(); private Map swFeaturesBuilders; private SwitchFeaturesUtil() { swFeaturesBuilders = new HashMap<>(); - swFeaturesBuilders.put((short) 1, BuildSwitchCapabilitiesOF10.getInstance()); - swFeaturesBuilders.put((short) 4, BuildSwitchCapabilitiesOF13.getInstance()); + swFeaturesBuilders.put(OFP_VERSION_1_0, BuildSwitchCapabilitiesOF10.getInstance()); + swFeaturesBuilders.put(OFP_VERSION_1_3, BuildSwitchCapabilitiesOF13.getInstance()); } /** @@ -48,7 +51,7 @@ public class SwitchFeaturesUtil { */ public SwitchFeatures buildSwitchFeatures(GetFeaturesOutput features) { - if(swFeaturesBuilders.containsKey(features.getVersion()) == true) { + if(swFeaturesBuilders.containsKey(features.getVersion())) { LOG.debug("map contains version {}", features.getVersion()); try { return swFeaturesBuilders.get(features.getVersion()).build(features);