From 777c94332871b8c34f56f7f2010de1536cb759ba Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 11 Mar 2022 11:35:45 +0100 Subject: [PATCH] Bump MRI upstreams Adopt the following versions: - odlparent-10.0.0 - infrautils-3.0.0 - yangtools-8.0.2 - controller-5.0.1 - aaa-0.15.1 - netconf-3.0.0 Also reconcile leaf-list mapping and correct feature packaging, so that we do not repackage upstream bundles. Change-Id: I5fc015361626e3c8721ac30255e8a4efacfb568e Signed-off-by: Robert Varga --- .../ArbitratorReconciliationManagerImpl.java | 24 +-- applications/arbitratorreconciliation/pom.xml | 2 +- .../bulk/o/matic/SalBulkFlowServiceImpl.java | 4 +- .../frm/impl/AbstractListeningCommiter.java | 8 +- .../frm/impl/BundleFlowForwarder.java | 22 +-- .../frm/impl/DeviceMastershipManager.java | 6 +- .../applications/frm/impl/FlowForwarder.java | 16 +- ...wNodeConnectorInventoryTranslatorImpl.java | 3 +- .../frm/impl/FlowNodeReconciliationImpl.java | 7 - .../frm/impl/ForwardingRulesManagerImpl.java | 84 ++++----- .../impl/FrmReconciliationServiceImpl.java | 6 +- .../OpenflowServiceRecoveryHandlerImpl.java | 2 +- .../impl/SyncReactorGuardDecorator.java | 3 - .../impl/clustering/DeviceMastership.java | 6 +- .../frsync/impl/strategy/FlowForwarder.java | 10 +- .../SyncPlanPushStrategyFlatBatchImpl.java | 3 - .../SyncPlanPushStrategyIncrementalImpl.java | 6 +- .../frsync/util/ReconcileUtil.java | 23 +-- ...ConnectorInventoryEventTranslatorTest.java | 6 +- applications/pom.xml | 2 +- applications/reconciliation-framework/pom.xml | 8 +- applications/southbound-cli/pom.xml | 8 +- .../southboundcli/NodeListener.java | 46 ++--- .../ReconciliationServiceImpl.java | 23 ++- .../cli/GetAllNodesCommandProvider.java | 10 - .../southboundcli/cli/Reconciliation.java | 13 +- .../southboundcli/util/ShellUtil.java | 2 +- .../resources/OSGI-INF/blueprint/commands.xml | 1 - .../topology/lldp/LLDPLinkAger.java | 28 ++- .../topology/lldp/LLDPLinkAgerTest.java | 5 - .../lldp/utils/LLDPDiscoveryUtilsTest.java | 5 - artifacts/pom.xml | 2 +- distribution/karaf/pom.xml | 2 +- drop-test-karaf/pom.xml | 21 +-- .../features-openflowplugin-extension/pom.xml | 2 +- .../pom.xml | 2 +- .../odl-openflowplugin-nxm-extensions/pom.xml | 2 +- .../odl-openflowplugin-onf-extensions/pom.xml | 2 +- .../features-extension-aggregator/pom.xml | 2 +- .../nx/codec/match/NxmHeader.java | 28 +-- extension/pom.xml | 2 +- .../features-openflowplugin/pom.xml | 2 +- .../pom.xml | 12 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../odl-openflowplugin-app-topology/pom.xml | 2 +- .../odl-openflowplugin-drop-test/pom.xml | 2 +- .../pom.xml | 4 +- .../odl-openflowplugin-flow-services/pom.xml | 2 +- .../odl-openflowplugin-libraries/pom.xml | 8 +- .../src/main/feature/feature.xml | 3 +- .../odl-openflowplugin-nsf-model/pom.xml | 12 +- .../src/main/feature/feature.xml | 3 +- .../odl-openflowplugin-southbound/pom.xml | 6 +- .../src/main/feature/feature.xml | 4 +- features-aggregator/pom.xml | 2 +- libraries/pom.xml | 2 +- .../main/yang/opendaylight-group-types.yang | 172 +++++++++--------- .../main/yang/opendaylight-table-types.yang | 16 +- model/pom.xml | 2 +- .../features-openflowjava/pom.xml | 2 +- .../odl-openflowjava-protocol/pom.xml | 19 +- .../src/main/feature/feature.xml | 7 +- .../features-openflowjava-aggregator/pom.xml | 2 +- .../src/main/yang/openflow-protocol.yang | 7 +- .../connection/TlsConfigurationImplTest.java | 6 +- openflowjava/openflow-protocol-impl/pom.xml | 12 +- .../impl/core/TcpChannelInitializer.java | 3 +- .../AbstractOutboundQueueManager.java | 3 + .../core/connection/AbstractRpcListener.java | 5 +- .../GetAsyncReplyMessageFactory.java | 40 ++-- .../MultipartReplyMessageFactory.java | 4 +- .../SetAsyncInputMessageFactory.java | 47 ++--- .../GetAsyncReplyMessageFactory.java | 3 +- .../SetAsyncInputMessageFactory.java | 3 +- ...blishingChannelInitializerFactoryTest.java | 5 +- .../PublishingChannelInitializerTest.java | 5 +- .../impl/core/SslContextFactoryTest.java | 5 +- .../SwitchConnectionProviderImpl02Test.java | 4 +- .../SwitchConnectionProviderImplTest.java | 4 +- .../GetAsyncReplyMessageFactoryTest.java | 81 +++------ .../SetAsyncInputMessageFactoryTest.java | 77 +++----- .../OF13SetFieldActionSerializerTest.java | 3 +- .../GetAsyncReplyMessageFactoryTest.java | 76 +++----- .../SetAsyncInputMessageFactoryTest.java | 76 +++----- .../it/integration/IntegrationTest.java | 2 +- .../openflow-switch-connection-config.yang | 1 + .../openflowplugin/api/OFConstants.java | 5 +- openflowplugin-impl/pom.xml | 10 +- .../common/MultipartReplyTranslatorUtil.java | 51 +++--- .../device/BuildSwitchCapabilitiesOF10.java | 44 +++-- .../device/BuildSwitchCapabilitiesOF13.java | 40 ++-- .../impl/device/SwitchFeaturesUtil.java | 38 ++-- .../initialization/OF10DeviceInitializer.java | 3 - .../lifecycle/ContextChainHolderImpl.java | 6 +- ...ltipartReplyGroupFeaturesDeserializer.java | 68 +++---- ...ltipartReplyMeterFeaturesDeserializer.java | 37 ++-- .../AbstractMultipartRequestCallback.java | 4 +- ...tractMultipartRequestOnTheFlyCallback.java | 15 +- .../services/AbstractRequestCallback.java | 8 +- .../impl/services/AbstractService.java | 9 +- ...ltiLayerAggregateFlowMultipartService.java | 11 +- ...ultiLayerExperimenterMultipartService.java | 2 +- .../multilayer/MultiLayerFlowService.java | 3 +- .../MultiLayerTableMultipartService.java | 2 +- .../sal/SalAsyncConfigServiceImpl.java | 8 +- .../services/sal/SalBundleServiceImpl.java | 15 +- .../impl/services/sal/SalFlowServiceImpl.java | 3 +- ...gleLayerAggregateFlowMultipartService.java | 3 +- ...ngleLayerExperimenterMultipartService.java | 2 +- .../SingleLayerTableMultipartService.java | 2 +- .../services/util/RequestContextUtil.java | 5 +- .../statistics/StatisticsManagerImpl.java | 13 +- .../services/GroupFeaturesService.java | 31 ++-- .../services/MeterFeaturesService.java | 16 +- ...endaylightDirectStatisticsServiceImpl.java | 4 +- .../FlowDirectStatisticsService.java | 3 +- .../GroupDirectStatisticsService.java | 3 +- .../impl/util/DeviceInitializationUtil.java | 7 +- .../impl/device/SwitchFeaturesUtilTest.java | 19 +- .../device/TransactionChainManagerTest.java | 2 +- ...artReplyGroupFeaturesDeserializerTest.java | 11 +- .../MultipartRequestOnTheFlyCallbackTest.java | 5 +- .../batch/FlatBatchFlowAdaptersTest.java | 4 +- .../batch/FlatBatchGroupAdaptersTest.java | 4 +- .../batch/FlatBatchMeterAdaptersTest.java | 4 +- .../sal/SalFlatBatchServiceImplTest.java | 8 +- .../sal/SalFlowsBatchServiceImplTest.java | 8 +- .../sal/SalGroupsBatchServiceImplTest.java | 8 +- .../sal/SalMetersBatchServiceImplTest.java | 8 +- .../impl/util/FlatBatchUtilTest.java | 8 +- .../impl/util/FlowUtilTest.java | 8 +- .../impl/util/GroupUtilTest.java | 10 +- .../impl/util/MeterUtilTest.java | 10 +- .../sal/convertor/TableFeaturesConvertor.java | 31 ++-- parent/pom.xml | 6 +- samples/pom.xml | 2 +- test-provider/pom.xml | 6 +- 146 files changed, 856 insertions(+), 1010 deletions(-) diff --git a/applications/arbitratorreconciliation/impl/src/main/java/org/opendaylight/openflowplugin/applications/arbitratorreconciliation/impl/ArbitratorReconciliationManagerImpl.java b/applications/arbitratorreconciliation/impl/src/main/java/org/opendaylight/openflowplugin/applications/arbitratorreconciliation/impl/ArbitratorReconciliationManagerImpl.java index 0c31367e60..8eec6568fb 100644 --- a/applications/arbitratorreconciliation/impl/src/main/java/org/opendaylight/openflowplugin/applications/arbitratorreconciliation/impl/ArbitratorReconciliationManagerImpl.java +++ b/applications/arbitratorreconciliation/impl/src/main/java/org/opendaylight/openflowplugin/applications/arbitratorreconciliation/impl/ArbitratorReconciliationManagerImpl.java @@ -11,17 +11,15 @@ import static java.util.Objects.requireNonNull; import com.google.common.base.Function; import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableSet; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -81,6 +79,7 @@ import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.binding.RpcService; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; @@ -131,7 +130,7 @@ public class ArbitratorReconciliationManagerImpl implements ArbitratorReconcileS final UpgradeState upgradeState) { Preconditions.checkArgument(rpcRegistry != null, "RpcConsumerRegistry cannot be null !"); this.reconciliationManager = requireNonNull(reconciliationManager, "ReconciliationManager cannot be null!"); - this.salBundleService = requireNonNull(rpcRegistry.getRpcService(SalBundleService.class), + salBundleService = requireNonNull(rpcRegistry.getRpcService(SalBundleService.class), "RPC SalBundleService not found."); this.rpcProviderService = rpcProviderService; this.upgradeState = requireNonNull(upgradeState, "UpgradeState cannot be null!"); @@ -181,8 +180,8 @@ public class ArbitratorReconciliationManagerImpl implements ArbitratorReconcileS } return RpcResultBuilder.success(new CommitActiveBundleOutputBuilder() .setResult(null).build()) - .withRpcErrors(Collections.singleton(RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION, - null, "No active bundle found for the node" + nodeId.toString()))).buildFuture(); + .withRpcErrors(List.of(RpcResultBuilder.newError(ErrorType.APPLICATION, + null, "No active bundle found for the node" + nodeId))).buildFuture(); } @Override @@ -198,9 +197,9 @@ public class ArbitratorReconciliationManagerImpl implements ArbitratorReconcileS .setResult(bundleDetails.getBundleId()) .build()) .buildFuture(); - } catch (InterruptedException | ExecutionException | NullPointerException e) { + } catch (InterruptedException | ExecutionException e) { return RpcResultBuilder.failed() - .withRpcErrors(Collections.singleton(RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION, + .withRpcErrors(List.of(RpcResultBuilder.newError(ErrorType.APPLICATION, null, e.getMessage()))).buildFuture(); } } @@ -249,8 +248,6 @@ public class ArbitratorReconciliationManagerImpl implements ArbitratorReconcileS return executor.submit(upgradeReconTask); } - @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", - justification = "https://github.com/spotbugs/spotbugs/issues/811") private static Messages createMessages(final NodeRef nodeRef) { final List messages = new ArrayList<>(); messages.add(new MessageBuilder() @@ -365,7 +362,7 @@ public class ArbitratorReconciliationManagerImpl implements ArbitratorReconcileS } } else { resultSink = RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "action of " + action + " failed"); + .withError(ErrorType.APPLICATION, "action of " + action + " failed"); } return resultSink.build(); }; @@ -376,8 +373,7 @@ public class ArbitratorReconciliationManagerImpl implements ArbitratorReconcileS .child(Node.class, new NodeKey(node.getNodeId())); LOG.debug("The path is registered : {}", path); ObjectRegistration rpcRegistration = - rpcProviderService.registerRpcImplementation(ArbitratorReconcileService.class, - this, ImmutableSet.of(path)); + rpcProviderService.registerRpcImplementation(ArbitratorReconcileService.class, this, Set.of(path)); rpcRegistrations.put(node.getNodeId().getValue(), rpcRegistration); } @@ -410,8 +406,6 @@ public class ArbitratorReconciliationManagerImpl implements ArbitratorReconcileS } } - @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", - justification = "https://github.com/spotbugs/spotbugs/issues/811") private static Uint64 getDpnIdFromNodeName(final String nodeName) { String dpnId = nodeName.substring(nodeName.lastIndexOf(SEPARATOR) + 1); return Uint64.valueOf(dpnId); diff --git a/applications/arbitratorreconciliation/pom.xml b/applications/arbitratorreconciliation/pom.xml index 65063296b2..3e0bfe557a 100644 --- a/applications/arbitratorreconciliation/pom.xml +++ b/applications/arbitratorreconciliation/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.odlparent odlparent-lite - 9.0.13 + 10.0.0 diff --git a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImpl.java b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImpl.java index d4392cfa25..ea323eedf4 100644 --- a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImpl.java +++ b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImpl.java @@ -71,7 +71,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalF import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; @@ -159,7 +159,7 @@ public class SalBulkFlowServiceImpl implements SalBulkFlowService { @Override public void onFailure(final Throwable throwable) { RpcResultBuilder rpcResultBld = RpcResultBuilder.failed() - .withRpcErrors(Collections.singleton(RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION, + .withRpcErrors(Collections.singleton(RpcResultBuilder.newError(ErrorType.APPLICATION, null, throwable.getMessage()))); rpcResult.set(rpcResultBld.build()); } diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/AbstractListeningCommiter.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/AbstractListeningCommiter.java index f7145b82cc..731232da9a 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/AbstractListeningCommiter.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/AbstractListeningCommiter.java @@ -12,6 +12,7 @@ import static java.util.Objects.requireNonNull; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.MoreExecutors; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.Collection; import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.mdsal.binding.api.DataBroker; @@ -44,12 +45,15 @@ public abstract class AbstractListeningCommiter protected final ListenerRegistrationHelper registrationHelper; protected ListenerRegistration listenerRegistration; - public AbstractListeningCommiter(final ForwardingRulesManager provider, final DataBroker dataBroker, + @SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", justification = "See FIXME below") + protected AbstractListeningCommiter(final ForwardingRulesManager provider, final DataBroker dataBroker, final ListenerRegistrationHelper registrationHelper) { this.provider = requireNonNull(provider, "ForwardingRulesManager can not be null!"); this.nodeConfigurator = requireNonNull(provider.getNodeConfigurator(), "NodeConfigurator can not be null!"); this.dataBroker = requireNonNull(dataBroker, "DataBroker can not be null!"); this.registrationHelper = requireNonNull(registrationHelper, "registrationHelper can not be null!"); + + // FIXME: this may start listening on an uninitialized object: clean up the lifecycle here registerListener(); provider.addRecoverableListener(this); } @@ -112,7 +116,7 @@ public abstract class AbstractListeningCommiter } @Override - public void registerListener() { + public final void registerListener() { final DataTreeIdentifier treeId = DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, getWildCardPath()); Futures.addCallback(registrationHelper.checkedRegisterListener(treeId, this), diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/BundleFlowForwarder.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/BundleFlowForwarder.java index 26d02fe6b6..93ddbb3bd4 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/BundleFlowForwarder.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/BundleFlowForwarder.java @@ -55,7 +55,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.on import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleId; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.common.Uint32; @@ -72,7 +72,7 @@ public class BundleFlowForwarder implements BundleMessagesCommiter { public BundleFlowForwarder(final ForwardingRulesManager forwardingRulesManager) { this.forwardingRulesManager = requireNonNull(forwardingRulesManager, "ForwardingRulesManager can not be null!"); - this.nodeConfigurator = requireNonNull(forwardingRulesManager.getNodeConfigurator(), + nodeConfigurator = requireNonNull(forwardingRulesManager.getNodeConfigurator(), "NodeConfigurator can not be null!"); } @@ -200,19 +200,19 @@ public class BundleFlowForwarder implements BundleMessagesCommiter { }, MoreExecutors.directExecutor()); } else { LOG.debug("Group {} not present in the config inventory", groupId); - resultFuture = Futures.immediateFuture(RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, - "Group " + groupId + " not present in the config inventory").build()); + resultFuture = RpcResultBuilder.failed() + .withError(ErrorType.APPLICATION, + "Group " + groupId + " not present in the config inventory").buildFuture(); } } catch (InterruptedException | ExecutionException e) { LOG.error("Error while reading group from config datastore for the group ID {}", groupId, e); - resultFuture = Futures.immediateFuture(RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, - "Group " + groupId + " not present in the config inventory").build()); + resultFuture = RpcResultBuilder.failed() + .withError(ErrorType.APPLICATION, + "Group " + groupId + " not present in the config inventory").buildFuture(); } } } else { - resultFuture = Futures.immediateFuture(RpcResultBuilder.success().build()); + resultFuture = RpcResultBuilder.success().buildFuture(); } return resultFuture; } @@ -233,8 +233,8 @@ public class BundleFlowForwarder implements BundleMessagesCommiter { this.bundleId = bundleId; this.messages = messages; this.resultFuture = resultFuture; - this.flowId = getFlowId(identifier); - this.tableId = getTableId(identifier); + flowId = getFlowId(identifier); + tableId = getTableId(identifier); nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent); } diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastershipManager.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastershipManager.java index 366847bb51..f10635c544 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastershipManager.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastershipManager.java @@ -10,6 +10,7 @@ package org.opendaylight.openflowplugin.applications.frm.impl; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.Collection; import java.util.Collections; import java.util.Set; @@ -61,6 +62,7 @@ public class DeviceMastershipManager implements ClusteredDataTreeChangeListener< private Set> activeNodes = Collections.emptySet(); private MastershipChangeRegistration mastershipChangeServiceRegistration; + @SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", justification = "Non-final for mocking") public DeviceMastershipManager(final ClusterSingletonServiceProvider clusterSingletonService, final FlowNodeReconciliation reconcliationAgent, final DataBroker dataBroker, @@ -70,10 +72,10 @@ public class DeviceMastershipManager implements ClusteredDataTreeChangeListener< this.clusterSingletonService = clusterSingletonService; this.reconcliationAgent = reconcliationAgent; this.rpcProviderService = rpcProviderService; - this.reconcliationService = reconciliationService; + reconcliationService = reconciliationService; this.dataBroker = dataBroker; registerNodeListener(); - this.mastershipChangeServiceRegistration = mastershipChangeServiceManager.register(this); + mastershipChangeServiceRegistration = mastershipChangeServiceManager.register(this); } public boolean isDeviceMastered(final NodeId nodeId) { diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowForwarder.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowForwarder.java index a0d3306797..75131a3cfa 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowForwarder.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowForwarder.java @@ -62,7 +62,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleId; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.common.Uint32; @@ -340,17 +340,17 @@ public class FlowForwarder extends AbstractListeningCommiter { builder.setGroupRef(new GroupRef(nodeIdent)); builder.setTransactionUri(new Uri(provider.getNewTransactionId())); AddGroupInput addGroupInput = builder.build(); - resultFuture = this.provider.getSalGroupService().addGroup(addGroupInput); + resultFuture = provider.getSalGroupService().addGroup(addGroupInput); } else { - resultFuture = Futures.immediateFuture(RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, - "Group " + groupId + " not present in the config inventory").build()); + resultFuture = RpcResultBuilder.failed() + .withError(ErrorType.APPLICATION, + "Group " + groupId + " not present in the config inventory").buildFuture(); } } catch (InterruptedException | ExecutionException e) { LOG.error("Error while reading group from config datastore for the group ID {}", groupId, e); - resultFuture = Futures.immediateFuture(RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, - "Error while reading group " + groupId + " from inventory").build()); + resultFuture = RpcResultBuilder.failed() + .withError(ErrorType.APPLICATION, + "Error while reading group " + groupId + " from inventory").buildFuture(); } return resultFuture; } diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeConnectorInventoryTranslatorImpl.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeConnectorInventoryTranslatorImpl.java index c37efe6cac..95e5cadc51 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeConnectorInventoryTranslatorImpl.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeConnectorInventoryTranslatorImpl.java @@ -28,7 +28,8 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class FlowNodeConnectorInventoryTranslatorImpl extends AbstractNodeConnectorCommitter +public final class FlowNodeConnectorInventoryTranslatorImpl + extends AbstractNodeConnectorCommitter implements FlowNodeConnectorInventoryTranslator { private static final Logger LOG = LoggerFactory.getLogger(FlowNodeConnectorInventoryTranslatorImpl.class); diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java index 2d9ab20f8c..f9d2378e30 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java @@ -19,7 +19,6 @@ import com.google.common.util.concurrent.JdkFutureAdapters; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.ThreadFactoryBuilder; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.math.BigInteger; import java.time.LocalDateTime; import java.util.ArrayList; @@ -595,8 +594,6 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation { } } - @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", - justification = "https://github.com/spotbugs/spotbugs/issues/811") private static BigInteger getDpnIdFromNodeName(final String nodeName) { String dpId = nodeName.substring(nodeName.lastIndexOf(SEPARATOR) + 1); return new BigInteger(dpId); @@ -742,8 +739,6 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation { return nodeIdent.child(StaleMeter.class, new StaleMeterKey(new MeterId(staleMeter.getMeterId()))); } - @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", - justification = "https://github.com/spotbugs/spotbugs/issues/811") private List>> addBundleMessages(final FlowCapableNode flowNode, final BundleId bundleIdValue, final InstanceIdentifier nodeIdentity) { @@ -789,8 +784,6 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation { .build(); } - @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", - justification = "https://github.com/spotbugs/spotbugs/issues/811") private static Messages createMessages(final NodeRef nodeRef) { final List messages = new ArrayList<>(); messages.add(new MessageBuilder().setNode(nodeRef) diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerImpl.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerImpl.java index 7e4b901325..7b62d70250 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerImpl.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerImpl.java @@ -68,7 +68,7 @@ import org.slf4j.LoggerFactory; * */ @Singleton -public class ForwardingRulesManagerImpl implements ForwardingRulesManager { +public final class ForwardingRulesManagerImpl implements ForwardingRulesManager { private static final Logger LOG = LoggerFactory.getLogger(ForwardingRulesManagerImpl.class); static final int STARTUP_LOOP_TICK = 1000; @@ -127,10 +127,10 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager { staleMarkingEnabled = config.getStaleMarkingEnabled(); reconciliationRetryCount = config.getReconciliationRetryCount().toJava(); isBundleBasedReconciliationEnabled = config.getBundleBasedReconciliationEnabled(); - this.configurationServiceRegistration = configurationService.registerListener(this); + configurationServiceRegistration = configurationService.registerListener(this); this.registrationHelper = requireNonNull(registrationHelper, "RegistrationHelper cannot be null"); - this.dataService = requireNonNull(dataBroker, "DataBroker can not be null!"); - this.clusterSingletonServiceProvider = requireNonNull(clusterSingletonService, + dataService = requireNonNull(dataBroker, "DataBroker can not be null!"); + clusterSingletonServiceProvider = requireNonNull(clusterSingletonService, "ClusterSingletonService provider can not be null"); this.reconciliationManager = reconciliationManager; this.rpcProviderService = rpcProviderService; @@ -139,21 +139,21 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager { Preconditions.checkArgument(rpcRegistry != null, "RpcProviderRegistry can not be null !"); - this.salFlowService = requireNonNull(rpcRegistry.getRpcService(SalFlowService.class), + salFlowService = requireNonNull(rpcRegistry.getRpcService(SalFlowService.class), "RPC SalFlowService not found."); - this.salGroupService = requireNonNull(rpcRegistry.getRpcService(SalGroupService.class), + salGroupService = requireNonNull(rpcRegistry.getRpcService(SalGroupService.class), "RPC SalGroupService not found."); - this.salMeterService = requireNonNull(rpcRegistry.getRpcService(SalMeterService.class), + salMeterService = requireNonNull(rpcRegistry.getRpcService(SalMeterService.class), "RPC SalMeterService not found."); - this.salTableService = requireNonNull(rpcRegistry.getRpcService(SalTableService.class), + salTableService = requireNonNull(rpcRegistry.getRpcService(SalTableService.class), "RPC SalTableService not found."); - this.salBundleService = requireNonNull(rpcRegistry.getRpcService(SalBundleService.class), + salBundleService = requireNonNull(rpcRegistry.getRpcService(SalBundleService.class), "RPC SalBundlService not found."); this.openflowServiceRecoveryHandler = requireNonNull(openflowServiceRecoveryHandler, "Openflow service recovery handler cannot be null"); this.serviceRecoveryRegistry = requireNonNull(serviceRecoveryRegistry, "Service recovery registry cannot be null"); - this.arbitratorReconciliationManager = + arbitratorReconciliationManager = requireNonNull(rpcRegistry.getRpcService(ArbitratorReconcileService.class), "ArbitratorReconciliationManager can not be null!"); } @@ -162,26 +162,26 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager { @PostConstruct public void start() { nodeConfigurator = new NodeConfiguratorImpl(); - this.devicesGroupRegistry = new DevicesGroupRegistry(); - this.nodeListener = new FlowNodeReconciliationImpl(this, dataService, SERVICE_NAME, FRM_RECONCILIATION_PRIORITY, + devicesGroupRegistry = new DevicesGroupRegistry(); + nodeListener = new FlowNodeReconciliationImpl(this, dataService, SERVICE_NAME, FRM_RECONCILIATION_PRIORITY, ResultState.DONOTHING, flowGroupCacheManager); if (this.isReconciliationDisabled()) { LOG.debug("Reconciliation is disabled by user"); } else { - this.reconciliationNotificationRegistration = reconciliationManager.registerService(this.nodeListener); + reconciliationNotificationRegistration = reconciliationManager.registerService(nodeListener); LOG.debug("Reconciliation is enabled by user and successfully registered to the reconciliation framework"); } - this.deviceMastershipManager = new DeviceMastershipManager(clusterSingletonServiceProvider, this.nodeListener, + deviceMastershipManager = new DeviceMastershipManager(clusterSingletonServiceProvider, nodeListener, dataService, mastershipChangeServiceManager, rpcProviderService, new FrmReconciliationServiceImpl(this)); flowNodeConnectorInventoryTranslatorImpl = new FlowNodeConnectorInventoryTranslatorImpl(dataService); - this.bundleFlowListener = new BundleFlowForwarder(this); - this.bundleGroupListener = new BundleGroupForwarder(this); - this.flowListener = new FlowForwarder(this, dataService, registrationHelper); - this.groupListener = new GroupForwarder(this, dataService, registrationHelper); - this.meterListener = new MeterForwarder(this, dataService, registrationHelper); - this.tableListener = new TableForwarder(this, dataService, registrationHelper); + bundleFlowListener = new BundleFlowForwarder(this); + bundleGroupListener = new BundleGroupForwarder(this); + flowListener = new FlowForwarder(this, dataService, registrationHelper); + groupListener = new GroupForwarder(this, dataService, registrationHelper); + meterListener = new MeterForwarder(this, dataService, registrationHelper); + tableListener = new TableForwarder(this, dataService, registrationHelper); LOG.info("ForwardingRulesManager has started successfully."); } @@ -190,32 +190,32 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager { public void close() throws Exception { configurationServiceRegistration.close(); - if (this.flowListener != null) { - this.flowListener.close(); - this.flowListener = null; + if (flowListener != null) { + flowListener.close(); + flowListener = null; } - if (this.groupListener != null) { - this.groupListener.close(); - this.groupListener = null; + if (groupListener != null) { + groupListener.close(); + groupListener = null; } - if (this.meterListener != null) { - this.meterListener.close(); - this.meterListener = null; + if (meterListener != null) { + meterListener.close(); + meterListener = null; } - if (this.tableListener != null) { - this.tableListener.close(); - this.tableListener = null; + if (tableListener != null) { + tableListener.close(); + tableListener = null; } - if (this.nodeListener != null) { - this.nodeListener.close(); - this.nodeListener = null; + if (nodeListener != null) { + nodeListener.close(); + nodeListener = null; } if (deviceMastershipManager != null) { deviceMastershipManager.close(); } - if (this.reconciliationNotificationRegistration != null) { - this.reconciliationNotificationRegistration.close(); - this.reconciliationNotificationRegistration = null; + if (reconciliationNotificationRegistration != null) { + reconciliationNotificationRegistration.close(); + reconciliationNotificationRegistration = null; } } @@ -276,7 +276,7 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager { @Override public DevicesGroupRegistry getDevicesGroupRegistry() { - return this.devicesGroupRegistry; + return devicesGroupRegistry; } @Override @@ -375,16 +375,16 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager { if (forwardingRulesProperty != null) { switch (forwardingRulesProperty) { case DISABLE_RECONCILIATION: - disableReconciliation = Boolean.valueOf(propertyValue); + disableReconciliation = Boolean.parseBoolean(propertyValue); break; case STALE_MARKING_ENABLED: - staleMarkingEnabled = Boolean.valueOf(propertyValue); + staleMarkingEnabled = Boolean.parseBoolean(propertyValue); break; case RECONCILIATION_RETRY_COUNT: reconciliationRetryCount = Integer.parseInt(propertyValue); break; case BUNDLE_BASED_RECONCILIATION_ENABLED: - isBundleBasedReconciliationEnabled = Boolean.valueOf(propertyValue); + isBundleBasedReconciliationEnabled = Boolean.parseBoolean(propertyValue); break; default: LOG.warn("No forwarding rule property found."); diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FrmReconciliationServiceImpl.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FrmReconciliationServiceImpl.java index 37a14c0e41..9e43568b9a 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FrmReconciliationServiceImpl.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FrmReconciliationServiceImpl.java @@ -25,7 +25,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.frm.reconciliation.service.rev180227.ReconcileNodeOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.frm.reconciliation.service.rev180227.ReconcileNodeOutputBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; @@ -79,7 +79,7 @@ public class FrmReconciliationServiceImpl implements FrmReconciliationService { futureResult.set(RpcResultBuilder.success(output).build()); } else { futureResult.set(RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "Error while triggering reconciliation").build()); + .withError(ErrorType.APPLICATION, "Error while triggering reconciliation").build()); } } @@ -88,7 +88,7 @@ public class FrmReconciliationServiceImpl implements FrmReconciliationService { public void onFailure(Throwable error) { LOG.error("initReconciliation failed", error); futureResult.set(RpcResultBuilder.failed() - .withError(RpcError.ErrorType.RPC,"Error while calling RPC").build()); + .withError(ErrorType.RPC, "Error while calling RPC").build()); } } } diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/recovery/impl/OpenflowServiceRecoveryHandlerImpl.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/recovery/impl/OpenflowServiceRecoveryHandlerImpl.java index b9bd0f3083..a6e16c6bd6 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/recovery/impl/OpenflowServiceRecoveryHandlerImpl.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/recovery/impl/OpenflowServiceRecoveryHandlerImpl.java @@ -18,7 +18,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Singleton -public class OpenflowServiceRecoveryHandlerImpl implements ServiceRecoveryInterface, +public final class OpenflowServiceRecoveryHandlerImpl implements ServiceRecoveryInterface, OpenflowServiceRecoveryHandler { private static final Logger LOG = LoggerFactory.getLogger(OpenflowServiceRecoveryHandlerImpl.class); diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecorator.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecorator.java index 8587082085..ebd10d89ef 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecorator.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecorator.java @@ -11,7 +11,6 @@ import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; import org.opendaylight.openflowplugin.applications.frsync.SemaphoreKeeper; @@ -86,8 +85,6 @@ public class SyncReactorGuardDecorator implements SyncReactor { }; } - @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", - justification = "https://github.com/spotbugs/spotbugs/issues/811") private static String formatNanos(final long nanos) { return "'" + TimeUnit.NANOSECONDS.toMillis(nanos) + " ms'"; } diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/clustering/DeviceMastership.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/clustering/DeviceMastership.java index 1771f89dea..49c15ca012 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/clustering/DeviceMastership.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/clustering/DeviceMastership.java @@ -21,7 +21,7 @@ import org.slf4j.LoggerFactory; /** * {@link ClusterSingletonService} clusterSingletonServiceRegistration per connected device. */ -public class DeviceMastership implements ClusterSingletonService, AutoCloseable { +public final class DeviceMastership implements ClusterSingletonService, AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(DeviceMastership.class); private final NodeId nodeId; private final ServiceGroupIdentifier identifier; @@ -33,9 +33,9 @@ public class DeviceMastership implements ClusterSingletonService, AutoCloseable final ReconciliationRegistry reconciliationRegistry, final ClusterSingletonServiceProvider clusterSingletonService) { this.nodeId = nodeId; - this.identifier = ServiceGroupIdentifier.create(nodeId.getValue()); + identifier = ServiceGroupIdentifier.create(nodeId.getValue()); this.reconciliationRegistry = reconciliationRegistry; - this.deviceMastered = false; + deviceMastered = false; clusterSingletonServiceRegistration = clusterSingletonService.registerClusterSingletonService(this); } diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/FlowForwarder.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/FlowForwarder.java index bb9e4baaeb..f4c54b4def 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/FlowForwarder.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/FlowForwarder.java @@ -30,7 +30,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRe import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; @@ -70,7 +70,7 @@ public class FlowForwarder implements ForwardingRulesCommitterfailed() - .withError(RpcError.ErrorType.APPLICATION, TABLE_ID_MISMATCH).buildFuture(); + .withError(ErrorType.APPLICATION, TABLE_ID_MISMATCH).buildFuture(); } } @@ -97,7 +97,7 @@ public class FlowForwarder implements ForwardingRulesCommitterfailed() - .withError(RpcError.ErrorType.APPLICATION, TABLE_ID_MISMATCH).buildFuture(); + .withError(ErrorType.APPLICATION, TABLE_ID_MISMATCH).buildFuture(); } return output; @@ -120,8 +120,8 @@ public class FlowForwarder implements ForwardingRulesCommitterfailed().withError(RpcError.ErrorType.APPLICATION, - TABLE_ID_MISMATCH).buildFuture(); + output = RpcResultBuilder.failed().withError(ErrorType.APPLICATION, TABLE_ID_MISMATCH) + .buildFuture(); } return output; } diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImpl.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImpl.java index 25c833a175..d954cf2129 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImpl.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImpl.java @@ -15,7 +15,6 @@ import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.ArrayList; import java.util.Collection; import java.util.LinkedHashMap; @@ -186,8 +185,6 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy { }; } - @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", - justification = "https://github.com/spotbugs/spotbugs/issues/811") private static void decrementBatchFailuresCounters(final Collection batchFailures, final Map, Batch> batchMap, final SyncCrudCounters counters) { diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyIncrementalImpl.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyIncrementalImpl.java index edc463d89a..da2117120f 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyIncrementalImpl.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyIncrementalImpl.java @@ -45,7 +45,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.Upd import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; @@ -286,7 +286,7 @@ public class SyncPlanPushStrategyIncrementalImpl implements SyncPlanPushStrategy } } catch (IllegalStateException e) { chainedResult = RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "failed to add missing groups", e) + .withError(ErrorType.APPLICATION, "failed to add missing groups", e) .buildFuture(); } @@ -470,7 +470,7 @@ public class SyncPlanPushStrategyIncrementalImpl implements SyncPlanPushStrategy } } catch (IllegalStateException e) { chainedResult = RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "failed to add missing groups", e) + .withError(ErrorType.APPLICATION, "failed to add missing groups", e) .buildFuture(); } diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtil.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtil.java index 1832ad76b0..af58030a84 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtil.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtil.java @@ -40,6 +40,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; @@ -83,7 +84,7 @@ public final class ReconcileUtil { } } else { resultSink = RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "previous " + previousItemAction + " failed"); + .withError(ErrorType.APPLICATION, "previous " + previousItemAction + " failed"); } return resultSink.build(); }; @@ -110,7 +111,7 @@ public final class ReconcileUtil { } } else { resultSink = RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "action of " + actionDescription + " failed"); + .withError(ErrorType.APPLICATION, "action of " + actionDescription + " failed"); } return resultSink.build(); }; @@ -183,21 +184,13 @@ public final class ReconcileUtil { final Group existingGroup = installedGroups.get(group.getGroupId().getValue()); if (existingGroup != null) { - if (!gatherUpdates) { + if (!gatherUpdates || group.equals(existingGroup)) { iterator.remove(); - } else { + } else if (checkGroupPrecondition(installedGroups.keySet(), group)) { // check buckets and eventually update - if (group.equals(existingGroup)) { - iterator.remove(); - } else { - if (checkGroupPrecondition(installedGroups.keySet(), group)) { - iterator.remove(); - LOG.trace("Group {} on device {} differs - planned for update", group.getGroupId(), - nodeId); - stepPlan.getItemsToUpdate().add(new ItemSyncBox.ItemUpdateTuple<>(existingGroup, - group)); - } - } + iterator.remove(); + LOG.trace("Group {} on device {} differs - planned for update", group.getGroupId(), nodeId); + stepPlan.getItemsToUpdate().add(new ItemSyncBox.ItemUpdateTuple<>(existingGroup, group)); } } else if (checkGroupPrecondition(installedGroups.keySet(), group)) { iterator.remove(); diff --git a/applications/lldp-speaker/src/test/java/org/opendaylight/openflowplugin/applications/lldpspeaker/NodeConnectorInventoryEventTranslatorTest.java b/applications/lldp-speaker/src/test/java/org/opendaylight/openflowplugin/applications/lldpspeaker/NodeConnectorInventoryEventTranslatorTest.java index 92a4754367..b3da817d89 100644 --- a/applications/lldp-speaker/src/test/java/org/opendaylight/openflowplugin/applications/lldpspeaker/NodeConnectorInventoryEventTranslatorTest.java +++ b/applications/lldp-speaker/src/test/java/org/opendaylight/openflowplugin/applications/lldpspeaker/NodeConnectorInventoryEventTranslatorTest.java @@ -10,7 +10,7 @@ package org.opendaylight.openflowplugin.applications.lldpspeaker; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.when; import static org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.DELETE; import static org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.SUBTREE_MODIFIED; @@ -81,7 +81,7 @@ public class NodeConnectorInventoryEventTranslatorTest { FlowCapableNodeConnector fcnc = TestUtils.createFlowCapableNodeConnector(true, false).build(); DataTreeModification dataTreeModification = setupDataTreeChange(WRITE, ID, fcnc); translator.onDataTreeChanged(Collections.singleton(dataTreeModification)); - verifyZeroInteractions(eventsObserver); + verifyNoInteractions(eventsObserver); } /** @@ -92,7 +92,7 @@ public class NodeConnectorInventoryEventTranslatorTest { FlowCapableNodeConnector fcnc = TestUtils.createFlowCapableNodeConnector(false, true).build(); DataTreeModification dataTreeModification = setupDataTreeChange(WRITE, ID, fcnc); translator.onDataTreeChanged(Collections.singleton(dataTreeModification)); - verifyZeroInteractions(eventsObserver); + verifyNoInteractions(eventsObserver); } /** diff --git a/applications/pom.xml b/applications/pom.xml index 22b78c2368..d404784805 100644 --- a/applications/pom.xml +++ b/applications/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.odlparent odlparent-lite - 9.0.13 + 10.0.0 diff --git a/applications/reconciliation-framework/pom.xml b/applications/reconciliation-framework/pom.xml index d9e5998fa9..5254c0be56 100644 --- a/applications/reconciliation-framework/pom.xml +++ b/applications/reconciliation-framework/pom.xml @@ -13,10 +13,6 @@ bundle - - org.osgi - osgi.core - org.opendaylight.openflowplugin openflowplugin-api @@ -26,6 +22,10 @@ org.apache.karaf.shell.console provided + + org.osgi + org.osgi.framework + com.guicedee.services javax.inject diff --git a/applications/southbound-cli/pom.xml b/applications/southbound-cli/pom.xml index e95bd08fe3..c9f2aa9965 100644 --- a/applications/southbound-cli/pom.xml +++ b/applications/southbound-cli/pom.xml @@ -13,10 +13,6 @@ bundle - - org.osgi - osgi.core - org.opendaylight.mdsal mdsal-binding-api @@ -38,6 +34,10 @@ org.apache.karaf.shell.console provided + + org.osgi + org.osgi.framework + org.opendaylight.openflowplugin.applications forwardingrules-manager diff --git a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/NodeListener.java b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/NodeListener.java index fd22171e69..0285b727e4 100644 --- a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/NodeListener.java +++ b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/NodeListener.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.applications.southboundcli; import static java.util.Objects.requireNonNull; @@ -13,7 +12,6 @@ import static java.util.Objects.requireNonNull; import java.util.Collection; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.binding.api.DataObjectModification; @@ -33,12 +31,12 @@ public class NodeListener implements ClusteredDataTreeChangeListener dpnIdToNameCache = new ConcurrentHashMap<>(); private final DataBroker dataBroker; private ListenerRegistration listenerReg; - private Map dpnIdToNameCache; - public NodeListener(DataBroker broker) { - this.dataBroker = broker; + public NodeListener(final DataBroker broker) { + dataBroker = broker; } public void start() { @@ -47,7 +45,6 @@ public class NodeListener implements ClusteredDataTreeChangeListener identifier = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, path); listenerReg = dataBroker.registerDataTreeChangeListener(identifier, NodeListener.this); - dpnIdToNameCache = new ConcurrentHashMap<>(); } @Override @@ -58,7 +55,7 @@ public class NodeListener implements ClusteredDataTreeChangeListener> changes) { + public void onDataTreeChanged(final Collection> changes) { requireNonNull(changes, "Changes may not be null!"); for (DataTreeModification change : changes) { final InstanceIdentifier key = change.getRootPath().getRootIdentifier(); @@ -84,7 +81,7 @@ public class NodeListener implements ClusteredDataTreeChangeListener instId, FlowCapableNode delNode) { + private void remove(final InstanceIdentifier instId, final FlowCapableNode delNode) { LOG.trace("Received remove notification for {}", delNode); String[] node = instId.firstKeyOf(Node.class).getId().getValue().split(SEPARATOR); if (node.length < 2) { @@ -96,44 +93,33 @@ public class NodeListener implements ClusteredDataTreeChangeListener instId, FlowCapableNode dataObjectModificationBefore, - FlowCapableNode dataObjectModificationAfter) { + private void update(final InstanceIdentifier instId, + final FlowCapableNode dataObjectModificationBefore, final FlowCapableNode dataObjectModificationAfter) { LOG.trace("Received update notification {}", instId); String[] node = instId.firstKeyOf(Node.class).getId().getValue().split(SEPARATOR); if (node.length < 2) { - LOG.error("Failed to add Unexpected nodeId {}", instId.firstKeyOf(Node.class).getId() - .getValue()); + LOG.error("Failed to add Unexpected nodeId {}", instId.firstKeyOf(Node.class).getId().getValue()); return; } long dpnId = Long.parseLong(node[1]); - try { - String nodeName = dataObjectModificationAfter.getDescription(); - if (nodeName != null) { - dpnIdToNameCache.put(dpnId, nodeName); - } else { - dpnIdToNameCache.put(dpnId , DEFAULT_DPN_NAME); - } - } catch (NullPointerException e) { - LOG.error("Error while converting Node:{} to FlowCapableNode: ", dpnId, e); + String nodeName = dataObjectModificationAfter == null ? null : dataObjectModificationAfter.getDescription(); + if (nodeName != null) { + dpnIdToNameCache.put(dpnId, nodeName); + } else { + dpnIdToNameCache.put(dpnId, DEFAULT_DPN_NAME); } } - private void add(InstanceIdentifier instId, FlowCapableNode addNode) { + private void add(final InstanceIdentifier instId, final FlowCapableNode addNode) { LOG.trace("Received ADD notification for {}", instId); String[] node = instId.firstKeyOf(Node.class).getId().getValue().split(SEPARATOR); if (node.length < 2) { - LOG.error("Failed to add Unexpected nodeId {}", instId.firstKeyOf(Node.class).getId() - .getValue()); + LOG.error("Failed to add Unexpected nodeId {}", instId.firstKeyOf(Node.class).getId().getValue()); return; } long dpnId = Long.parseLong(node[1]); - String dpnName = null; - try { - dpnName = addNode.getDescription(); - } catch (NullPointerException e) { - LOG.error("Error while converting Node:{} to FlowCapableNode: ", dpnId, e); - } + String dpnName = addNode == null ? null : addNode.getDescription(); LOG.trace("Adding DPNID {} to cache", dpnId); if (dpnName == null) { dpnName = DEFAULT_DPN_NAME; diff --git a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/ReconciliationServiceImpl.java b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/ReconciliationServiceImpl.java index f7f7e7b19a..d20ba88a75 100644 --- a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/ReconciliationServiceImpl.java +++ b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/ReconciliationServiceImpl.java @@ -12,15 +12,16 @@ import static org.opendaylight.openflowplugin.api.openflow.ReconciliationState.R import static org.opendaylight.openflowplugin.api.openflow.ReconciliationState.ReconciliationStatus.FAILED; import static org.opendaylight.openflowplugin.api.openflow.ReconciliationState.ReconciliationStatus.STARTED; +import com.google.common.collect.ImmutableSet; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; import java.text.SimpleDateFormat; import java.time.LocalDateTime; -import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -53,7 +54,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.reconciliation.service.rev180227.reconciliation.counter.ReconcileCounterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.reconciliation.service.rev180227.reconciliation.counter.ReconcileCounterKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorTag; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.common.Uint32; @@ -94,9 +96,9 @@ public class ReconciliationServiceImpl implements ReconciliationService, AutoClo @Override public ListenableFuture> reconcile(final ReconcileInput input) { boolean reconcileAllNodes = input.getReconcileAllNodes(); - List inputNodes = input.getNodes(); + Set inputNodes = input.getNodes(); if (inputNodes == null) { - inputNodes = new ArrayList<>(); + inputNodes = Set.of(); } if (reconcileAllNodes && inputNodes.size() > 0) { return buildErrorResponse("Error executing command reconcile. " @@ -116,7 +118,7 @@ public class ReconciliationServiceImpl implements ReconciliationService, AutoClo return buildErrorResponse("Error executing command reconcile. " + "Node(s) not found: " + String.join(", ", unresolvedNodes.toString())); } - List inprogressNodes = new ArrayList<>(); + ImmutableSet.Builder inprogressNodes = ImmutableSet.builder(); nodesToReconcile.parallelStream().forEach(nodeId -> { ReconciliationState state = getReconciliationState(nodeId); if (state != null && state.getState().equals(STARTED)) { @@ -130,7 +132,7 @@ public class ReconciliationServiceImpl implements ReconciliationService, AutoClo } }); ReconcileOutput reconcilingInProgress = new ReconcileOutputBuilder() - .setInprogressNodes(inprogressNodes) + .setInprogressNodes(inprogressNodes.build()) .build(); result.set(RpcResultBuilder.success(reconcilingInProgress).build()); return result; @@ -147,7 +149,7 @@ public class ReconciliationServiceImpl implements ReconciliationService, AutoClo private static ListenableFuture> buildErrorResponse(final String msg) { LOG.error("Error {}", msg); return RpcResultBuilder.failed() - .withError(RpcError.ErrorType.PROTOCOL, "reconcile", msg) + .withError(ErrorType.PROTOCOL, new ErrorTag("reconcile"), msg) .buildFuture(); } @@ -180,22 +182,23 @@ public class ReconciliationServiceImpl implements ReconciliationService, AutoClo if (rpcResult.isSuccessful()) { increaseReconcileCount(true); updateReconciliationState(COMPLETED); - LOG.info("Reconciliation successfully completed for node {}", this.nodeId); + LOG.info("Reconciliation successfully completed for node {}", nodeId); } else { increaseReconcileCount(false); updateReconciliationState(FAILED); - LOG.error("Reconciliation failed for node {} with error {}", this.nodeId, rpcResult.getErrors()); + LOG.error("Reconciliation failed for node {} with error {}", nodeId, rpcResult.getErrors()); } } catch (ExecutionException | InterruptedException e) { increaseReconcileCount(false); updateReconciliationState(FAILED); - LOG.error("Error occurred while invoking reconcile RPC for node {}", this.nodeId, e); + LOG.error("Error occurred while invoking reconcile RPC for node {}", nodeId, e); } finally { alarmAgent.clearNodeReconciliationAlarm(nodeId.longValue()); } } private void increaseReconcileCount(final boolean isSuccess) { + // FIXME: do not use SimpleDateFormat final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_AND_TIME_FORMAT); InstanceIdentifier instanceIdentifier = InstanceIdentifier .builder(ReconciliationCounter.class).child(ReconcileCounter.class, diff --git a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/GetAllNodesCommandProvider.java b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/GetAllNodesCommandProvider.java index 135e8498ae..5653acb17d 100644 --- a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/GetAllNodesCommandProvider.java +++ b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/GetAllNodesCommandProvider.java @@ -11,24 +11,14 @@ import java.util.Formatter; import java.util.List; import org.apache.felix.gogo.commands.Command; import org.apache.karaf.shell.console.OsgiCommandSupport; -import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.openflowplugin.applications.southboundcli.NodeListener; import org.opendaylight.openflowplugin.applications.southboundcli.util.OFNode; import org.opendaylight.openflowplugin.applications.southboundcli.util.ShellUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; @Command(scope = "openflow", name = "getallnodes", description = "Print all nodes from the operational datastore") public class GetAllNodesCommandProvider extends OsgiCommandSupport { - private static final Logger LOG = LoggerFactory.getLogger(GetAllNodesCommandProvider.class); - - private DataBroker dataBroker; private NodeListener nodeListener; - public void setDataBroker(final DataBroker dataBroker) { - this.dataBroker = dataBroker; - } - public void setNodeListener(final NodeListener nodeListener) { this.nodeListener = nodeListener; } diff --git a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/Reconciliation.java b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/Reconciliation.java index 0239a46ced..5872cbd983 100644 --- a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/Reconciliation.java +++ b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/Reconciliation.java @@ -5,12 +5,11 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.applications.southboundcli.cli; -import java.util.ArrayList; import java.util.Formatter; import java.util.List; +import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.stream.Collectors; @@ -46,9 +45,9 @@ public class Reconciliation extends OsgiCommandSupport { @SuppressWarnings("checkstyle:RegexpSinglelineJava") @Override protected Object doExecute() throws Exception { - List nodes = nodeIds == null - ? new ArrayList<>() - : nodeIds.stream().distinct().map(Uint64::valueOf).collect(Collectors.toList()); + Set nodes = nodeIds == null + ? Set.of() + : nodeIds.stream().distinct().map(Uint64::valueOf).collect(Collectors.toUnmodifiableSet()); LOG.debug("Triggering reconciliation for nodes {}", nodes); ReconcileInput rpcInput = new ReconcileInputBuilder().setNodes(nodes) .setReconcileAllNodes(reconcileAllNodes).build(); @@ -69,7 +68,7 @@ public class Reconciliation extends OsgiCommandSupport { @SuppressWarnings("checkstyle:RegexpSinglelineJava") private static void printInProgressNodes(ReconcileOutput reconcileOutput) { - List inprogressNodes = reconcileOutput.getInprogressNodes(); + Set inprogressNodes = reconcileOutput.getInprogressNodes(); if (inprogressNodes.size() > 0) { StringBuilder stringBuilder = new StringBuilder(); final Formatter formatter = new Formatter(stringBuilder); @@ -88,4 +87,4 @@ public class Reconciliation extends OsgiCommandSupport { formatter.close(); return header; } -} \ No newline at end of file +} diff --git a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/util/ShellUtil.java b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/util/ShellUtil.java index d72029bf36..66112519ed 100644 --- a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/util/ShellUtil.java +++ b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/util/ShellUtil.java @@ -122,7 +122,7 @@ public final class ShellUtil { if (result.isPresent()) { output = result.get().nonnullReconcileCounter().values(); } - } catch (ExecutionException | InterruptedException | NullPointerException e) { + } catch (ExecutionException | InterruptedException e) { LOG.error("Error reading reconciliation counter from datastore", e); } return output; diff --git a/applications/southbound-cli/src/main/resources/OSGI-INF/blueprint/commands.xml b/applications/southbound-cli/src/main/resources/OSGI-INF/blueprint/commands.xml index 04634716b5..2ab42185d9 100644 --- a/applications/southbound-cli/src/main/resources/OSGI-INF/blueprint/commands.xml +++ b/applications/southbound-cli/src/main/resources/OSGI-INF/blueprint/commands.xml @@ -20,7 +20,6 @@ - diff --git a/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPLinkAger.java b/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPLinkAger.java index fbc382f6b5..2c2a181bbe 100644 --- a/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPLinkAger.java +++ b/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPLinkAger.java @@ -10,11 +10,11 @@ package org.opendaylight.openflowplugin.applications.topology.lldp; import com.google.common.annotations.VisibleForTesting; import java.util.Collection; import java.util.Date; -import java.util.Map; import java.util.Map.Entry; import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import javax.annotation.PreDestroy; import javax.inject.Inject; import javax.inject.Singleton; @@ -22,7 +22,6 @@ import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.binding.api.DataObjectModification; -import org.opendaylight.mdsal.binding.api.DataTreeChangeListener; import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.mdsal.binding.api.NotificationPublishService; @@ -48,19 +47,20 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Singleton -public class LLDPLinkAger implements ConfigurationListener, ClusteredDataTreeChangeListener, AutoCloseable { +public final class LLDPLinkAger implements ConfigurationListener, ClusteredDataTreeChangeListener, AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(LLDPLinkAger.class); static final String TOPOLOGY_ID = "flow:1"; static final InstanceIdentifier II_TO_LINK = InstanceIdentifier.create(NetworkTopology.class) .child(Topology.class, new TopologyKey(new TopologyId(TOPOLOGY_ID))).child(Link.class); private final long linkExpirationTime; - private final Map linkToDate; - private final Timer timer; + // FIXME: use Instant instead of Date + private final ConcurrentMap linkToDate = new ConcurrentHashMap<>(); + private final Timer timer = new Timer(); private final NotificationPublishService notificationService; private final AutoCloseable configurationServiceRegistration; private final EntityOwnershipService eos; - private ListenerRegistration listenerRegistration; + private ListenerRegistration listenerRegistration; /** * default ctor - start timer. @@ -72,13 +72,11 @@ public class LLDPLinkAger implements ConfigurationListener, ClusteredDataTreeCha final ConfigurationService configurationService, final EntityOwnershipService entityOwnershipService, final DataBroker dataBroker) { - this.linkExpirationTime = topologyLldpDiscoveryConfig.getTopologyLldpExpirationInterval().getValue().toJava(); + linkExpirationTime = topologyLldpDiscoveryConfig.getTopologyLldpExpirationInterval().getValue().toJava(); this.notificationService = notificationService; - this.configurationServiceRegistration = configurationService.registerListener(this); - this.eos = entityOwnershipService; - linkToDate = new ConcurrentHashMap<>(); - timer = new Timer(); - final DataTreeIdentifier dtiToNodeConnector = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, + configurationServiceRegistration = configurationService.registerListener(this); + eos = entityOwnershipService; + final DataTreeIdentifier dtiToNodeConnector = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, II_TO_LINK); try { listenerRegistration = dataBroker.registerDataTreeChangeListener(dtiToNodeConnector, LLDPLinkAger.this); @@ -110,7 +108,7 @@ public class LLDPLinkAger implements ConfigurationListener, ClusteredDataTreeCha @Override public void onDataTreeChanged(@NonNull Collection> changes) { - for (DataTreeModification modification : changes) { + for (DataTreeModification modification : changes) { switch (modification.getRootNode().getModificationType()) { case WRITE: break; @@ -153,8 +151,8 @@ public class LLDPLinkAger implements ConfigurationListener, ClusteredDataTreeCha return linkToDate.containsKey(linkDiscovered); } - private void processLinkDeleted(DataObjectModification rootNode) { - Link link = (Link) rootNode.getDataBefore(); + private void processLinkDeleted(DataObjectModification rootNode) { + Link link = rootNode.getDataBefore(); LOG.trace("Removing link {} from linkToDate cache", link); LinkDiscovered linkDiscovered = LLDPDiscoveryUtils.toLLDPLinkDiscovered(link); linkToDate.remove(linkDiscovered); diff --git a/applications/topology-lldp-discovery/src/test/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPLinkAgerTest.java b/applications/topology-lldp-discovery/src/test/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPLinkAgerTest.java index 9a0a335677..4628f02b1e 100644 --- a/applications/topology-lldp-discovery/src/test/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPLinkAgerTest.java +++ b/applications/topology-lldp-discovery/src/test/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPLinkAgerTest.java @@ -37,17 +37,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.lldp.discovery.config.rev160511.TopologyLldpDiscoveryConfigBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.Uint32; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Test for {@link LLDPLinkAger}. */ @RunWith(MockitoJUnitRunner.class) public class LLDPLinkAgerTest { - - private static final Logger LOG = LoggerFactory.getLogger(LLDPLinkAgerTest.class); - private static final Uint32 LLDP_INTERVAL = Uint32.valueOf(5); private static final Uint32 LINK_EXPIRATION_TIME = Uint32.TEN; diff --git a/applications/topology-lldp-discovery/src/test/java/org/opendaylight/openflowplugin/applications/topology/lldp/utils/LLDPDiscoveryUtilsTest.java b/applications/topology-lldp-discovery/src/test/java/org/opendaylight/openflowplugin/applications/topology/lldp/utils/LLDPDiscoveryUtilsTest.java index 299f7e4ba5..e17b8cbaa1 100644 --- a/applications/topology-lldp-discovery/src/test/java/org/opendaylight/openflowplugin/applications/topology/lldp/utils/LLDPDiscoveryUtilsTest.java +++ b/applications/topology-lldp-discovery/src/test/java/org/opendaylight/openflowplugin/applications/topology/lldp/utils/LLDPDiscoveryUtilsTest.java @@ -18,17 +18,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.No import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Test for {@link LLDPDiscoveryUtils}. */ @RunWith(MockitoJUnitRunner.class) public class LLDPDiscoveryUtilsTest { - - private static final Logger LOG = LoggerFactory.getLogger(LLDPDiscoveryUtilsTest.class); - @Test public void testLldpToNodeConnectorRefLLDP() { byte[] packetLLDP = { diff --git a/artifacts/pom.xml b/artifacts/pom.xml index ffa66b0224..d004c601b4 100644 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -13,7 +13,7 @@ org.opendaylight.odlparent odlparent-lite - 9.0.13 + 10.0.0 diff --git a/distribution/karaf/pom.xml b/distribution/karaf/pom.xml index 434f190997..65ef1e2e12 100644 --- a/distribution/karaf/pom.xml +++ b/distribution/karaf/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent karaf4-parent - 9.0.13 + 10.0.0 org.opendaylight.openflowplugin openflowplugin-karaf diff --git a/drop-test-karaf/pom.xml b/drop-test-karaf/pom.xml index 24936ac2dd..ac3964183a 100644 --- a/drop-test-karaf/pom.xml +++ b/drop-test-karaf/pom.xml @@ -14,18 +14,10 @@ scm:git:ssh://git.opendaylight.org:29418/openflowplugin.git - - org.osgi - osgi.core - org.opendaylight.openflowplugin test-common - - com.google.guava - guava - org.opendaylight.mdsal mdsal-binding-api @@ -34,24 +26,15 @@ org.opendaylight.openflowplugin.model model-flow-service - - org.opendaylight.openflowplugin.model - model-flow-base - - - org.opendaylight.openflowplugin.model - model-inventory - org.apache.karaf.shell org.apache.karaf.shell.console provided - commons-lang - commons-lang + org.osgi + org.osgi.framework - diff --git a/extension/features-extension-aggregator/features-openflowplugin-extension/pom.xml b/extension/features-extension-aggregator/features-openflowplugin-extension/pom.xml index 611766b2e9..678985ba7a 100644 --- a/extension/features-extension-aggregator/features-openflowplugin-extension/pom.xml +++ b/extension/features-extension-aggregator/features-openflowplugin-extension/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent feature-repo-parent - 9.0.13 + 10.0.0 diff --git a/extension/features-extension-aggregator/odl-openflowplugin-eric-extensions/pom.xml b/extension/features-extension-aggregator/odl-openflowplugin-eric-extensions/pom.xml index c57c0a9235..30920784ec 100644 --- a/extension/features-extension-aggregator/odl-openflowplugin-eric-extensions/pom.xml +++ b/extension/features-extension-aggregator/odl-openflowplugin-eric-extensions/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 diff --git a/extension/features-extension-aggregator/odl-openflowplugin-nxm-extensions/pom.xml b/extension/features-extension-aggregator/odl-openflowplugin-nxm-extensions/pom.xml index 62a730551e..540d54b5e7 100644 --- a/extension/features-extension-aggregator/odl-openflowplugin-nxm-extensions/pom.xml +++ b/extension/features-extension-aggregator/odl-openflowplugin-nxm-extensions/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 diff --git a/extension/features-extension-aggregator/odl-openflowplugin-onf-extensions/pom.xml b/extension/features-extension-aggregator/odl-openflowplugin-onf-extensions/pom.xml index a11de5237f..e90ac9dca1 100644 --- a/extension/features-extension-aggregator/odl-openflowplugin-onf-extensions/pom.xml +++ b/extension/features-extension-aggregator/odl-openflowplugin-onf-extensions/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 diff --git a/extension/features-extension-aggregator/pom.xml b/extension/features-extension-aggregator/pom.xml index 5c8a4e35c2..6d1050ec6f 100644 --- a/extension/features-extension-aggregator/pom.xml +++ b/extension/features-extension-aggregator/pom.xml @@ -3,7 +3,7 @@ org.opendaylight.odlparent odlparent-lite - 9.0.13 + 10.0.0 4.0.0 diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NxmHeader.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NxmHeader.java index 13452259de..e1e0d7ad28 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NxmHeader.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NxmHeader.java @@ -18,7 +18,7 @@ import org.opendaylight.yangtools.yang.common.Uint64; * * @author msunal */ -public class NxmHeader { +public final class NxmHeader { // Full 4 or 8 byte header as big integer private final Uint64 header; @@ -41,21 +41,21 @@ public class NxmHeader { * @see NxmHeader#NxmHeader(long) */ public NxmHeader(final Uint64 header) { - this.headerAsLong = header.longValue(); + headerAsLong = header.longValue(); if (isExperimenter(header)) { - this.experimenterId = (int) this.headerAsLong; - this.shortHeader = this.headerAsLong >>> 32; + experimenterId = (int) headerAsLong; + shortHeader = headerAsLong >>> 32; } else { - this.shortHeader = this.headerAsLong; - this.experimenterId = -1; + shortHeader = headerAsLong; + experimenterId = -1; } this.header = header; try { - this.oxmClass = Math.toIntExact(extractSub(this.shortHeader, 16, 16)); - this.nxmField = Math.toIntExact(extractSub(this.shortHeader, 7, 9)); - this.hasMask = extractSub(this.shortHeader, 1, 8) == 1; - this.length = Math.toIntExact(extractSub(this.shortHeader, 8, 0)); + oxmClass = Math.toIntExact(extractSub(shortHeader, 16, 16)); + nxmField = Math.toIntExact(extractSub(shortHeader, 7, 9)); + hasMask = extractSub(shortHeader, 1, 8) == 1; + length = Math.toIntExact(extractSub(shortHeader, 8, 0)); } catch (ArithmeticException e) { throw new IllegalArgumentException(e); } @@ -105,14 +105,14 @@ public class NxmHeader { this.nxmField = nxmField; this.hasMask = hasMask; this.length = length; - this.shortHeader = (long) oxmClass << 16 | nxmField << 9 | (hasMask ? 1 : 0) << 8 | length; + shortHeader = (long) oxmClass << 16 | nxmField << 9 | (hasMask ? 1 : 0) << 8 | length; this.experimenterId = experimenterId; if (isExperimenter()) { - this.header = Uint64.fromLongBits((this.shortHeader << 32) + experimenterId); + header = Uint64.fromLongBits((shortHeader << 32) + experimenterId); } else { - this.header = Uint64.valueOf(this.shortHeader); + header = Uint64.valueOf(shortHeader); } - this.headerAsLong = this.header.longValue(); + headerAsLong = header.longValue(); } private static long extractSub(final long value, final int nrBits, final int offset) { diff --git a/extension/pom.xml b/extension/pom.xml index a49d8d960c..078bbd431c 100644 --- a/extension/pom.xml +++ b/extension/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.odlparent odlparent-lite - 9.0.13 + 10.0.0 diff --git a/features-aggregator/features-openflowplugin/pom.xml b/features-aggregator/features-openflowplugin/pom.xml index eb115d2fe6..3db0a23119 100644 --- a/features-aggregator/features-openflowplugin/pom.xml +++ b/features-aggregator/features-openflowplugin/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent feature-repo-parent - 9.0.13 + 10.0.0 diff --git a/features-aggregator/odl-openflowplugin-app-arbitratorreconciliation/pom.xml b/features-aggregator/odl-openflowplugin-app-arbitratorreconciliation/pom.xml index b9a9423e04..bec0f3177a 100644 --- a/features-aggregator/odl-openflowplugin-app-arbitratorreconciliation/pom.xml +++ b/features-aggregator/odl-openflowplugin-app-arbitratorreconciliation/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 @@ -24,12 +24,18 @@ features xml + + ${project.groupId} + odl-openflowplugin-app-reconciliation-framework + ${project.version} + features + xml + + org.opendaylight.openflowplugin.applications arbitratorreconciliation-impl ${project.version} - - diff --git a/features-aggregator/odl-openflowplugin-app-bulk-o-matic/pom.xml b/features-aggregator/odl-openflowplugin-app-bulk-o-matic/pom.xml index adc8f95c57..076bfa1c16 100644 --- a/features-aggregator/odl-openflowplugin-app-bulk-o-matic/pom.xml +++ b/features-aggregator/odl-openflowplugin-app-bulk-o-matic/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 diff --git a/features-aggregator/odl-openflowplugin-app-config-pusher/pom.xml b/features-aggregator/odl-openflowplugin-app-config-pusher/pom.xml index e932b6f9e1..d45f655a09 100644 --- a/features-aggregator/odl-openflowplugin-app-config-pusher/pom.xml +++ b/features-aggregator/odl-openflowplugin-app-config-pusher/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 diff --git a/features-aggregator/odl-openflowplugin-app-forwardingrules-manager/pom.xml b/features-aggregator/odl-openflowplugin-app-forwardingrules-manager/pom.xml index 91e8aa5d3b..41cdffe43d 100644 --- a/features-aggregator/odl-openflowplugin-app-forwardingrules-manager/pom.xml +++ b/features-aggregator/odl-openflowplugin-app-forwardingrules-manager/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 diff --git a/features-aggregator/odl-openflowplugin-app-forwardingrules-sync/pom.xml b/features-aggregator/odl-openflowplugin-app-forwardingrules-sync/pom.xml index 4d7505aad2..4107a3dedd 100644 --- a/features-aggregator/odl-openflowplugin-app-forwardingrules-sync/pom.xml +++ b/features-aggregator/odl-openflowplugin-app-forwardingrules-sync/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 diff --git a/features-aggregator/odl-openflowplugin-app-lldp-speaker/pom.xml b/features-aggregator/odl-openflowplugin-app-lldp-speaker/pom.xml index f676f7403e..2e031d1a20 100644 --- a/features-aggregator/odl-openflowplugin-app-lldp-speaker/pom.xml +++ b/features-aggregator/odl-openflowplugin-app-lldp-speaker/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 diff --git a/features-aggregator/odl-openflowplugin-app-reconciliation-framework/pom.xml b/features-aggregator/odl-openflowplugin-app-reconciliation-framework/pom.xml index 5018186b66..4e2c8b399d 100644 --- a/features-aggregator/odl-openflowplugin-app-reconciliation-framework/pom.xml +++ b/features-aggregator/odl-openflowplugin-app-reconciliation-framework/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 diff --git a/features-aggregator/odl-openflowplugin-app-southbound-cli/pom.xml b/features-aggregator/odl-openflowplugin-app-southbound-cli/pom.xml index 6bf7e1df32..4ec5bb9efa 100644 --- a/features-aggregator/odl-openflowplugin-app-southbound-cli/pom.xml +++ b/features-aggregator/odl-openflowplugin-app-southbound-cli/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 diff --git a/features-aggregator/odl-openflowplugin-app-table-miss-enforcer/pom.xml b/features-aggregator/odl-openflowplugin-app-table-miss-enforcer/pom.xml index d18c0bba37..80586f410e 100644 --- a/features-aggregator/odl-openflowplugin-app-table-miss-enforcer/pom.xml +++ b/features-aggregator/odl-openflowplugin-app-table-miss-enforcer/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 diff --git a/features-aggregator/odl-openflowplugin-app-topology-lldp-discovery/pom.xml b/features-aggregator/odl-openflowplugin-app-topology-lldp-discovery/pom.xml index 650a751985..de94e97cba 100644 --- a/features-aggregator/odl-openflowplugin-app-topology-lldp-discovery/pom.xml +++ b/features-aggregator/odl-openflowplugin-app-topology-lldp-discovery/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 diff --git a/features-aggregator/odl-openflowplugin-app-topology-manager/pom.xml b/features-aggregator/odl-openflowplugin-app-topology-manager/pom.xml index 29b4173b74..8752eaf0a4 100644 --- a/features-aggregator/odl-openflowplugin-app-topology-manager/pom.xml +++ b/features-aggregator/odl-openflowplugin-app-topology-manager/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 diff --git a/features-aggregator/odl-openflowplugin-app-topology/pom.xml b/features-aggregator/odl-openflowplugin-app-topology/pom.xml index e6d88becf1..1227d71ab9 100644 --- a/features-aggregator/odl-openflowplugin-app-topology/pom.xml +++ b/features-aggregator/odl-openflowplugin-app-topology/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 diff --git a/features-aggregator/odl-openflowplugin-drop-test/pom.xml b/features-aggregator/odl-openflowplugin-drop-test/pom.xml index efa972673e..7566906398 100644 --- a/features-aggregator/odl-openflowplugin-drop-test/pom.xml +++ b/features-aggregator/odl-openflowplugin-drop-test/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 diff --git a/features-aggregator/odl-openflowplugin-flow-services-rest/pom.xml b/features-aggregator/odl-openflowplugin-flow-services-rest/pom.xml index 4644b88dd8..532ce6dfaa 100644 --- a/features-aggregator/odl-openflowplugin-flow-services-rest/pom.xml +++ b/features-aggregator/odl-openflowplugin-flow-services-rest/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 @@ -21,7 +21,7 @@ org.opendaylight.netconf netconf-artifacts - 2.0.14 + 3.0.0 import pom diff --git a/features-aggregator/odl-openflowplugin-flow-services/pom.xml b/features-aggregator/odl-openflowplugin-flow-services/pom.xml index 01e322b4fc..d0c8395242 100644 --- a/features-aggregator/odl-openflowplugin-flow-services/pom.xml +++ b/features-aggregator/odl-openflowplugin-flow-services/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 diff --git a/features-aggregator/odl-openflowplugin-libraries/pom.xml b/features-aggregator/odl-openflowplugin-libraries/pom.xml index 6dfc6625d0..f980f9ecc5 100644 --- a/features-aggregator/odl-openflowplugin-libraries/pom.xml +++ b/features-aggregator/odl-openflowplugin-libraries/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 @@ -16,6 +16,12 @@ OpenDaylight :: Openflow Plugin :: Libraries + + org.opendaylight.odlparent + odl-apache-commons-lang3 + xml + features + org.opendaylight.odlparent odl-guava diff --git a/features-aggregator/odl-openflowplugin-libraries/src/main/feature/feature.xml b/features-aggregator/odl-openflowplugin-libraries/src/main/feature/feature.xml index f819fecba3..3c3d621afb 100644 --- a/features-aggregator/odl-openflowplugin-libraries/src/main/feature/feature.xml +++ b/features-aggregator/odl-openflowplugin-libraries/src/main/feature/feature.xml @@ -1,6 +1,7 @@ - odl-guava + odl-apache-commons-lang3 + odl-guava diff --git a/features-aggregator/odl-openflowplugin-nsf-model/pom.xml b/features-aggregator/odl-openflowplugin-nsf-model/pom.xml index 1e17c28c63..fa3901f7db 100644 --- a/features-aggregator/odl-openflowplugin-nsf-model/pom.xml +++ b/features-aggregator/odl-openflowplugin-nsf-model/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 @@ -21,7 +21,7 @@ org.opendaylight.mdsal mdsal-artifacts - 8.0.11 + 9.0.1 import pom @@ -30,7 +30,7 @@ org.opendaylight.controller controller-artifacts - 4.0.10 + 5.0.1 import pom @@ -39,6 +39,12 @@ + + org.opendaylight.mdsal.model + odl-mdsal-model-draft-clemm-netmod-yang-network-topo-01-minimal + features + xml + org.opendaylight.mdsal.model odl-mdsal-model-odl-l2-types diff --git a/features-aggregator/odl-openflowplugin-nsf-model/src/main/feature/feature.xml b/features-aggregator/odl-openflowplugin-nsf-model/src/main/feature/feature.xml index 021d737cbf..1193e93769 100644 --- a/features-aggregator/odl-openflowplugin-nsf-model/src/main/feature/feature.xml +++ b/features-aggregator/odl-openflowplugin-nsf-model/src/main/feature/feature.xml @@ -1,6 +1,7 @@ - odl-mdsal-model-odl-l2-types + odl-mdsal-model-draft-clemm-netmod-yang-network-topo-01-minimal + odl-mdsal-model-odl-l2-types diff --git a/features-aggregator/odl-openflowplugin-southbound/pom.xml b/features-aggregator/odl-openflowplugin-southbound/pom.xml index faeee7da88..cb371bc27d 100644 --- a/features-aggregator/odl-openflowplugin-southbound/pom.xml +++ b/features-aggregator/odl-openflowplugin-southbound/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 @@ -29,14 +29,14 @@ org.opendaylight.controller controller-artifacts - 4.0.10 + 5.0.1 import pom org.opendaylight.infrautils infrautils-artifacts - 2.0.13 + 3.0.0 import pom diff --git a/features-aggregator/odl-openflowplugin-southbound/src/main/feature/feature.xml b/features-aggregator/odl-openflowplugin-southbound/src/main/feature/feature.xml index a2b463ebf6..83cff02e6c 100644 --- a/features-aggregator/odl-openflowplugin-southbound/src/main/feature/feature.xml +++ b/features-aggregator/odl-openflowplugin-southbound/src/main/feature/feature.xml @@ -2,7 +2,7 @@ mvn:org.opendaylight.openflowplugin/openflowplugin-blueprint-config/${project.version}/cfg/config - odl-mdsal-broker - odl-infrautils-diagstatus + odl-mdsal-broker + odl-infrautils-diagstatus diff --git a/features-aggregator/pom.xml b/features-aggregator/pom.xml index 517e87c038..c223c19d77 100644 --- a/features-aggregator/pom.xml +++ b/features-aggregator/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent odlparent-lite - 9.0.13 + 10.0.0 diff --git a/libraries/pom.xml b/libraries/pom.xml index 9ede9d9b36..3faf57cdb2 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.odlparent odlparent-lite - 9.0.13 + 10.0.0 diff --git a/model/model-flow-base/src/main/yang/opendaylight-group-types.yang b/model/model-flow-base/src/main/yang/opendaylight-group-types.yang index e012172a1b..b2d56304e0 100644 --- a/model/model-flow-base/src/main/yang/opendaylight-group-types.yang +++ b/model/model-flow-base/src/main/yang/opendaylight-group-types.yang @@ -14,141 +14,141 @@ module opendaylight-group-types { typedef group-id { type uint32; } - + typedef bucket-id { - type uint32; + type uint32; } - - typedef group-types { + + typedef group-types { type enumeration { enum group-all; enum group-select; enum group-indirect; enum group-ff; - } + } } - - typedef group-capabilities { + + typedef group-capabilities { type enumeration { enum select-weight; enum select-liveness; enum chaining; enum chaining-checks; - } + } } - + identity group-type { - description "Base identity for all the available group types"; + description "Base identity for all the available group types"; } - + identity group-all { - base group-type; - description "All (multicast/broadcast) group"; + base group-type; + description "All (multicast/broadcast) group"; } - + identity group-select { - base group-type; - description "Select group"; + base group-type; + description "Select group"; } - + identity group-indirect { - base group-type; - description "Indirect group"; + base group-type; + description "Indirect group"; } - + identity group-ff { - base group-type; - description "Fast failover group"; + base group-type; + description "Fast failover group"; } - + identity group-capability { - description "Base identity for all the supported group capabilities"; + description "Base identity for all the supported group capabilities"; } - + identity select-weight{ - base group-capability; - description "Support weight for select groups"; + base group-capability; + description "Support weight for select groups"; } identity select-liveness{ - base group-capability; - description "Support liveness for select groups"; + base group-capability; + description "Support liveness for select groups"; } identity chaining{ - base group-capability; - description "Support chaining groups"; + base group-capability; + description "Support chaining groups"; } identity chaining-checks{ - base group-capability; - description "Check chaining for loops and delete"; + base group-capability; + description "Check chaining for loops and delete"; } - + typedef group-ref { type instance-identifier; } - + grouping group { - + leaf group-type { type group-types; } - + leaf group-id { type group-id; } - + leaf group-name { type string; } - + leaf container-name { - type string; + type string; } - + leaf barrier { - type boolean; - } - + type boolean; + } + container buckets { list bucket { key "bucket-id"; leaf bucket-id { type bucket-id; } - + leaf weight { type uint16; } - + leaf watch_port { type uint32; } - + leaf watch_group { type uint32; } - + uses action:action-list; } } } - + grouping group-statistics { - + leaf group-id { type group-id; } - + leaf ref-count { type yang:counter32; } - + leaf packet-count { type yang:counter64; - } - + } + leaf byte-count { type yang:counter64; } @@ -161,86 +161,88 @@ module opendaylight-group-types { type yang:counter32; } } - + container buckets { list bucket-counter { key "bucket-id"; leaf bucket-id { type bucket-id; } - + leaf packet-count { type yang:counter64; - } - + } + leaf byte-count { type yang:counter64; } } - } + } } grouping group-features { - - leaf-list group-types-supported { - type identityref { - base group-type; - } - } - - leaf-list group-capabilities-supported { - type identityref { - base group-capability; - } - } + + leaf-list group-types-supported { + type identityref { + base group-type; + } + } + + leaf-list group-capabilities-supported { + type identityref { + base group-capability; + } + } leaf-list max-groups { type uint32; description "Maximum number of groups for each type"; max-elements 4; + ordered-by user; } - + leaf-list actions { type uint32; description "Bitmap number OFPAT_* that are supported"; max-elements 4; + ordered-by user; } } - + grouping group-statistics-request { list group-stats { - key "group-id"; + key "group-id"; leaf group-id { type group-id; - } + } } } - + grouping group-statistics-reply { - + list group-stats { key "group-id"; uses group-statistics; } } - + grouping group-desc-stats-reply { - + list group-desc-stats { - key "group-id"; + key "group-id"; uses group; } } - + grouping group-features-reply { - uses group-features; + uses group-features; } - + grouping groups { list group { - key "group-id"; - + key "group-id"; + uses group; } diff --git a/model/model-flow-base/src/main/yang/opendaylight-table-types.yang b/model/model-flow-base/src/main/yang/opendaylight-table-types.yang index f67159bfb5..da48369777 100644 --- a/model/model-flow-base/src/main/yang/opendaylight-table-types.yang +++ b/model/model-flow-base/src/main/yang/opendaylight-table-types.yang @@ -11,7 +11,7 @@ module opendaylight-table-types { } typedef table-id { - type uint8; + type uint8; } typedef table-ref { @@ -204,7 +204,7 @@ module opendaylight-table-types { grouping set-field-match { list set-field-match { - key "match-type"; + key "match-type"; leaf match-type { type identityref { base match-field; @@ -234,6 +234,7 @@ module opendaylight-table-types { container tables { leaf-list table-ids { type uint8; + ordered-by user; } } } @@ -242,6 +243,7 @@ module opendaylight-table-types { container tables-miss { leaf-list table-ids { type uint8; + ordered-by user; } } } @@ -271,19 +273,19 @@ module opendaylight-table-types { } case match { - container match-setfield { - uses set-field-match; - } + container match-setfield { + uses set-field-match; + } } case wildcards { - container wildcard-setfield { + container wildcard-setfield { uses set-field-match; } } case write-setfield { - container write-setfield { + container write-setfield { uses set-field-match; } } diff --git a/model/pom.xml b/model/pom.xml index 38b938a60e..405aaafe8a 100644 --- a/model/pom.xml +++ b/model/pom.xml @@ -6,7 +6,7 @@ org.opendaylight.odlparent odlparent-lite - 9.0.13 + 10.0.0 diff --git a/openflowjava/features-openflowjava-aggregator/features-openflowjava/pom.xml b/openflowjava/features-openflowjava-aggregator/features-openflowjava/pom.xml index 8edcf6ad84..0b4944b1f3 100644 --- a/openflowjava/features-openflowjava-aggregator/features-openflowjava/pom.xml +++ b/openflowjava/features-openflowjava-aggregator/features-openflowjava/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent feature-repo-parent - 9.0.13 + 10.0.0 diff --git a/openflowjava/features-openflowjava-aggregator/odl-openflowjava-protocol/pom.xml b/openflowjava/features-openflowjava-aggregator/odl-openflowjava-protocol/pom.xml index 4c68a78a25..5432968bcb 100644 --- a/openflowjava/features-openflowjava-aggregator/odl-openflowjava-protocol/pom.xml +++ b/openflowjava/features-openflowjava-aggregator/odl-openflowjava-protocol/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 @@ -33,7 +33,16 @@ org.opendaylight.infrautils infrautils-artifacts - 2.0.13 + 3.0.0 + import + pom + + + + + org.opendaylight.yangtools + yangtools-artifacts + 8.0.2 import pom @@ -42,7 +51,7 @@ org.opendaylight.mdsal mdsal-artifacts - 8.0.11 + 9.0.1 import pom @@ -58,8 +67,8 @@ features - org.opendaylight.odlparent - odl-netty-4 + org.opendaylight.yangtools + odl-yangtools-netty xml features diff --git a/openflowjava/features-openflowjava-aggregator/odl-openflowjava-protocol/src/main/feature/feature.xml b/openflowjava/features-openflowjava-aggregator/odl-openflowjava-protocol/src/main/feature/feature.xml index 6b9bc77586..041b124d84 100644 --- a/openflowjava/features-openflowjava-aggregator/odl-openflowjava-protocol/src/main/feature/feature.xml +++ b/openflowjava/features-openflowjava-aggregator/odl-openflowjava-protocol/src/main/feature/feature.xml @@ -4,8 +4,9 @@ mvn:org.opendaylight.openflowplugin.openflowjava/openflowjava-blueprint-config/${project.version}/xml/config mvn:org.opendaylight.openflowplugin.openflowjava/openflowjava-blueprint-config/${project.version}/xml/legacyConfig - odl-netty-4 - odl-mdsal-model-rfc6991 - odl-infrautils-diagstatus + odl-yangtools-netty + odl-mdsal-model-rfc6991 + odl-mdsal-model-rfc6991 + odl-infrautils-diagstatus diff --git a/openflowjava/features-openflowjava-aggregator/pom.xml b/openflowjava/features-openflowjava-aggregator/pom.xml index bf71f34509..45ab4d2a89 100644 --- a/openflowjava/features-openflowjava-aggregator/pom.xml +++ b/openflowjava/features-openflowjava-aggregator/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent odlparent-lite - 9.0.13 + 10.0.0 diff --git a/openflowjava/openflow-protocol-api/src/main/yang/openflow-protocol.yang b/openflowjava/openflow-protocol-api/src/main/yang/openflow-protocol.yang index 7e42a2b9bf..5c2b59c351 100644 --- a/openflowjava/openflow-protocol-api/src/main/yang/openflow-protocol.yang +++ b/openflowjava/openflow-protocol-api/src/main/yang/openflow-protocol.yang @@ -165,6 +165,7 @@ leaf-list version-bitmap { type boolean; + ordered-by user; } } } @@ -947,9 +948,13 @@ } leaf-list max_groups { type uint32; + ordered-by user; + // FIXME: min-elements = max-elements = 4 } leaf-list actions-bitmap { type oft:action-type; + ordered-by user; + // FIXME: min-elements = max-elements = 4 } } } @@ -1435,4 +1440,4 @@ uses meter-mod; } } /* Controller/switch message */ -} \ No newline at end of file +} diff --git a/openflowjava/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImplTest.java b/openflowjava/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImplTest.java index 6c729cee56..5fe9e0fe2f 100644 --- a/openflowjava/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImplTest.java +++ b/openflowjava/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImplTest.java @@ -5,12 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.protocol.api.connection; import static org.junit.Assert.assertEquals; -import com.google.common.collect.Lists; import java.util.List; import org.junit.Test; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; @@ -22,14 +20,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.P * @author michal.polkorab */ public class TlsConfigurationImplTest { - /** * Test correct TlsConfigurationImpl creation. */ @Test public void test() { - List cipherSuites = Lists.newArrayList("TLS_RSA_WITH_AES_128_CBC_SHA", - "TLS_RSA_WITH_AES_128_CBC_SHA256"); + List cipherSuites = List.of("TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA256"); TlsConfigurationImpl config = new TlsConfigurationImpl(KeystoreType.JKS, "user/dir", PathType.CLASSPATH, KeystoreType.PKCS12, "/var/lib", PathType.PATH, cipherSuites); assertEquals("Wrong keystore location", "/var/lib", config.getTlsKeystore()); diff --git a/openflowjava/openflow-protocol-impl/pom.xml b/openflowjava/openflow-protocol-impl/pom.xml index eed268f4ef..dbcc6ad094 100644 --- a/openflowjava/openflow-protocol-impl/pom.xml +++ b/openflowjava/openflow-protocol-impl/pom.xml @@ -106,16 +106,16 @@ org.opendaylight.yangtools yang-common-netty + + io.netty + netty-transport-classes-epoll + + io.netty netty-transport-native-epoll - - linux-x86_64 + test diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java index c06803c47b..94df5fd9f8 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java @@ -88,8 +88,7 @@ public class TcpChannelInitializer extends ProtocolChannelInitializer suitesList = getTlsConfiguration().getCipherSuites(); if (suitesList != null && !suitesList.isEmpty()) { LOG.debug("Requested Cipher Suites are: {}", suitesList); - String[] suites = suitesList.toArray(new String[suitesList.size()]); - engine.setEnabledCipherSuites(suites); + engine.setEnabledCipherSuites(suitesList.toArray(new String[0])); LOG.debug("Cipher suites enabled in SSLEngine are: {}", Arrays.toString(engine.getEnabledCipherSuites())); } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java index db77d1a747..27ba9cdd93 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java @@ -10,6 +10,7 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection; import static com.google.common.base.Preconditions.checkArgument; import static java.util.Objects.requireNonNull; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.util.concurrent.Future; @@ -83,6 +84,8 @@ abstract class AbstractOutboundQueueManager implements GenericFutureListener { private static final Logger LOG = LoggerFactory.getLogger(AbstractRpcListener.class); private static final String APPLICATION_TAG = "OPENFLOW_LIBRARY"; - private static final String TAG = "OPENFLOW"; + private static final ErrorTag TAG = new ErrorTag("OPENFLOW"); private final SettableFuture> result = SettableFuture.create(); private final String failureInfo; private Object message; diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactory.java index caf897d08b..8dbe69a71d 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactory.java @@ -9,9 +9,11 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; +import com.google.common.collect.ImmutableSet; import io.netty.buffer.ByteBuf; import java.util.ArrayList; import java.util.List; +import java.util.Set; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason; @@ -79,48 +81,48 @@ public class GetAsyncReplyMessageFactory implements OFDeserializer decodePacketInReasons(long input) { - List reasons = new ArrayList<>(); + private static Set decodePacketInReasons(long input) { + final var builder = ImmutableSet.builder(); if ((input & 1 << 0) != 0) { - reasons.add(PacketInReason.OFPRNOMATCH); + builder.add(PacketInReason.OFPRNOMATCH); } if ((input & 1 << 1) != 0) { - reasons.add(PacketInReason.OFPRACTION); + builder.add(PacketInReason.OFPRACTION); } if ((input & 1 << 2) != 0) { - reasons.add(PacketInReason.OFPRINVALIDTTL); + builder.add(PacketInReason.OFPRINVALIDTTL); } - return reasons; + return builder.build(); } - private static List decodePortReasons(long input) { - List reasons = new ArrayList<>(); + private static Set decodePortReasons(long input) { + final var builder = ImmutableSet.builder(); if ((input & 1 << 0) != 0) { - reasons.add(PortReason.OFPPRADD); + builder.add(PortReason.OFPPRADD); } if ((input & 1 << 1) != 0) { - reasons.add(PortReason.OFPPRDELETE); + builder.add(PortReason.OFPPRDELETE); } if ((input & 1 << 2) != 0) { - reasons.add(PortReason.OFPPRMODIFY); + builder.add(PortReason.OFPPRMODIFY); } - return reasons; + return builder.build(); } - private static List decodeFlowRemovedReasons(long input) { - List reasons = new ArrayList<>(); + private static Set decodeFlowRemovedReasons(long input) { + final var builder = ImmutableSet.builder(); if ((input & 1 << 0) != 0) { - reasons.add(FlowRemovedReason.OFPRRIDLETIMEOUT); + builder.add(FlowRemovedReason.OFPRRIDLETIMEOUT); } if ((input & 1 << 1) != 0) { - reasons.add(FlowRemovedReason.OFPRRHARDTIMEOUT); + builder.add(FlowRemovedReason.OFPRRHARDTIMEOUT); } if ((input & 1 << 2) != 0) { - reasons.add(FlowRemovedReason.OFPRRDELETE); + builder.add(FlowRemovedReason.OFPRRDELETE); } if ((input & 1 << 3) != 0) { - reasons.add(FlowRemovedReason.OFPRRGROUPDELETE); + builder.add(FlowRemovedReason.OFPRRGROUPDELETE); } - return reasons; + return builder.build(); } } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java index 6ce1f45fa0..6ef0132c3a 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java @@ -732,12 +732,12 @@ public class MultipartReplyMessageFactory implements OFDeserializer maxGroupsList = new ArrayList<>(); + List maxGroupsList = new ArrayList<>(GROUP_TYPES); for (int i = 0; i < GROUP_TYPES; i++) { maxGroupsList.add(Uint32.valueOf(rawMessage.readUnsignedInt())); } featuresBuilder.setMaxGroups(maxGroupsList); - List actionBitmaps = new ArrayList<>(); + List actionBitmaps = new ArrayList<>(GROUP_TYPES); for (int i = 0; i < GROUP_TYPES; i++) { actionBitmaps.add(createActionBitmap(rawMessage.readUnsignedInt())); } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetAsyncInputMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetAsyncInputMessageFactory.java index 264a91bf6e..b84dd58a18 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetAsyncInputMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetAsyncInputMessageFactory.java @@ -9,9 +9,11 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; +import com.google.common.collect.ImmutableSet; import io.netty.buffer.ByteBuf; import java.util.ArrayList; import java.util.List; +import java.util.Set; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason; @@ -32,7 +34,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 * @author giuseppex.petralia@intel.com */ public class SetAsyncInputMessageFactory implements OFDeserializer { - private static final byte SEPARATE_ROLES = 2; @Override @@ -47,7 +48,7 @@ public class SetAsyncInputMessageFactory implements OFDeserializer decodePacketInMask(ByteBuf input) { - List inMasks = new ArrayList<>(); + List inMasks = new ArrayList<>(SEPARATE_ROLES); PacketInMaskBuilder maskBuilder; for (int i = 0; i < SEPARATE_ROLES; i++) { maskBuilder = new PacketInMaskBuilder(); @@ -57,22 +58,22 @@ public class SetAsyncInputMessageFactory implements OFDeserializer decodePacketInReasons(long input) { - List reasons = new ArrayList<>(); + private static Set decodePacketInReasons(long input) { + final var builder = ImmutableSet.builder(); if ((input & 1 << 0) != 0) { - reasons.add(PacketInReason.OFPRNOMATCH); + builder.add(PacketInReason.OFPRNOMATCH); } if ((input & 1 << 1) != 0) { - reasons.add(PacketInReason.OFPRACTION); + builder.add(PacketInReason.OFPRACTION); } if ((input & 1 << 2) != 0) { - reasons.add(PacketInReason.OFPRINVALIDTTL); + builder.add(PacketInReason.OFPRINVALIDTTL); } - return reasons; + return builder.build(); } private static List decodePortStatusMask(ByteBuf input) { - List inMasks = new ArrayList<>(); + List inMasks = new ArrayList<>(SEPARATE_ROLES); PortStatusMaskBuilder maskBuilder; for (int i = 0; i < SEPARATE_ROLES; i++) { maskBuilder = new PortStatusMaskBuilder(); @@ -82,22 +83,22 @@ public class SetAsyncInputMessageFactory implements OFDeserializer decodePortReasons(long input) { - List reasons = new ArrayList<>(); + private static Set decodePortReasons(long input) { + final var builder = ImmutableSet.builder(); if ((input & 1 << 0) != 0) { - reasons.add(PortReason.OFPPRADD); + builder.add(PortReason.OFPPRADD); } if ((input & 1 << 1) != 0) { - reasons.add(PortReason.OFPPRDELETE); + builder.add(PortReason.OFPPRDELETE); } if ((input & 1 << 2) != 0) { - reasons.add(PortReason.OFPPRMODIFY); + builder.add(PortReason.OFPPRMODIFY); } - return reasons; + return builder.build(); } private static List decodeFlowRemovedMask(ByteBuf input) { - List inMasks = new ArrayList<>(); + List inMasks = new ArrayList<>(SEPARATE_ROLES); FlowRemovedMaskBuilder maskBuilder; for (int i = 0; i < SEPARATE_ROLES; i++) { maskBuilder = new FlowRemovedMaskBuilder(); @@ -107,20 +108,20 @@ public class SetAsyncInputMessageFactory implements OFDeserializer decodeFlowRemovedReasons(long input) { - List reasons = new ArrayList<>(); + private static Set decodeFlowRemovedReasons(long input) { + final var builder = ImmutableSet.builder(); if ((input & 1 << 0) != 0) { - reasons.add(FlowRemovedReason.OFPRRIDLETIMEOUT); + builder.add(FlowRemovedReason.OFPRRIDLETIMEOUT); } if ((input & 1 << 1) != 0) { - reasons.add(FlowRemovedReason.OFPRRHARDTIMEOUT); + builder.add(FlowRemovedReason.OFPRRHARDTIMEOUT); } if ((input & 1 << 2) != 0) { - reasons.add(FlowRemovedReason.OFPRRDELETE); + builder.add(FlowRemovedReason.OFPRRDELETE); } if ((input & 1 << 3) != 0) { - reasons.add(FlowRemovedReason.OFPRRGROUPDELETE); + builder.add(FlowRemovedReason.OFPRRGROUPDELETE); } - return reasons; + return builder.build(); } } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncReplyMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncReplyMessageFactory.java index bdc1b0731c..b5dfc76a4f 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncReplyMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncReplyMessageFactory.java @@ -8,6 +8,7 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.factories; import io.netty.buffer.ByteBuf; +import java.util.Collection; import java.util.List; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; @@ -59,7 +60,7 @@ public class GetAsyncReplyMessageFactory implements OFSerializer } } - private static void serializeReasons(final List reasons, final ByteBuf outBuffer) { + private static void serializeReasons(final Collection reasons, final ByteBuf outBuffer) { if (reasons != null) { int bitmap = 0; for (Enumeration reason : reasons) { diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactory.java index ffee4e9ff3..064ea27adb 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactory.java @@ -9,6 +9,7 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.factories; import io.netty.buffer.ByteBuf; +import java.util.Collection; import java.util.List; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; @@ -62,7 +63,7 @@ public class SetAsyncInputMessageFactory implements OFSerializer } } - private static void serializeReasons(final List reasons, final ByteBuf outBuffer) { + private static void serializeReasons(final Collection reasons, final ByteBuf outBuffer) { if (reasons != null) { int bitmap = 0; for (Enumeration reason : reasons) { diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactoryTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactoryTest.java index 26079c3855..c1449d3705 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactoryTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactoryTest.java @@ -5,12 +5,11 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.protocol.impl.core; import static org.junit.Assert.assertNotNull; -import com.google.common.collect.Lists; +import java.util.List; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -47,7 +46,7 @@ public class PublishingChannelInitializerFactoryTest { factory = new ChannelInitializerFactory(); tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/exemplary-ctlTrustStore", PathType.CLASSPATH, KeystoreType.JKS, "/exemplary-ctlKeystore", PathType.CLASSPATH, - Lists.newArrayList("TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA256")); + List.of("TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA256")); factory.setDeserializationFactory(deserializationFactory); factory.setSerializationFactory(serializationFactory); factory.setSwitchConnectionHandler(switchConnectionHandler); diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java index b1aa5013a7..3a488d30fa 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.protocol.impl.core; import static org.junit.Assert.assertEquals; @@ -16,7 +15,6 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import com.google.common.collect.Lists; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelPipeline; import io.netty.channel.group.DefaultChannelGroup; @@ -25,6 +23,7 @@ import io.netty.handler.ssl.SslHandler; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.UnknownHostException; +import java.util.List; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -91,7 +90,7 @@ public class PublishingChannelInitializerTest { tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/selfSignedSwitch", PathType.CLASSPATH, KeystoreType.JKS, "/selfSignedController", PathType.CLASSPATH, - Lists.newArrayList("TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA256")); + List.of("TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA256")); } diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java index 751b5c455b..cf00ef7a16 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java @@ -5,12 +5,11 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.protocol.impl.core; import static org.junit.Assert.assertNotNull; -import com.google.common.collect.Lists; +import java.util.List; import javax.net.ssl.SSLContext; import org.junit.Before; import org.junit.Test; @@ -36,7 +35,7 @@ public class SslContextFactoryTest { public void setUp() { tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/exemplary-ctlTrustStore", PathType.CLASSPATH, KeystoreType.JKS, "/exemplary-ctlKeystore", PathType.CLASSPATH, - Lists.newArrayList("TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA256")) ; + List.of("TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA256")); sslContextFactory = new SslContextFactory(tlsConfiguration); } diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java index 027edfc55f..21acd56900 100755 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java @@ -7,10 +7,10 @@ */ package org.opendaylight.openflowjava.protocol.impl.core.connection; -import com.google.common.collect.Lists; import com.google.common.util.concurrent.ListenableFuture; import java.net.InetAddress; import java.net.UnknownHostException; +import java.util.List; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -101,7 +101,7 @@ public class SwitchConnectionProviderImpl02Test { tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/selfSignedSwitch", PathType.CLASSPATH, KeystoreType.JKS, "/selfSignedController", PathType.CLASSPATH, - Lists.newArrayList("TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA256")) ; + List.of("TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA256")); } config = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT, true, false, CHANNEL_OUTBOUND_QUEUE_SIZE); diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java index e7178c746c..fee78164da 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java @@ -8,10 +8,10 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection; -import com.google.common.collect.Lists; import com.google.common.util.concurrent.ListenableFuture; import java.net.InetAddress; import java.net.UnknownHostException; +import java.util.List; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -70,7 +70,7 @@ public class SwitchConnectionProviderImplTest { tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/selfSignedSwitch", PathType.CLASSPATH, KeystoreType.JKS, "/selfSignedController", PathType.CLASSPATH, - Lists.newArrayList("TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA256")) ; + List.of("TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA256")); } config = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT, true, false, CHANNEL_OUTBOUND_QUEUE_SIZE); diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactoryTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactoryTest.java index f61805431f..361b7a6781 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactoryTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactoryTest.java @@ -8,8 +8,8 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; -import java.util.ArrayList; import java.util.List; +import java.util.Set; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -60,65 +60,42 @@ public class GetAsyncReplyMessageFactoryTest { GetAsyncOutput builtByFactory = BufferHelper.deserialize(asyncFactory, bb); BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong packetInMask",createPacketInMask(), builtByFactory.getPacketInMask()); - Assert.assertEquals("Wrong portStatusMask",createPortStatusMask(), builtByFactory.getPortStatusMask()); - Assert.assertEquals("Wrong flowRemovedMask",createFlowRemovedMask(), builtByFactory.getFlowRemovedMask()); + Assert.assertEquals("Wrong packetInMask", createPacketInMask(), builtByFactory.getPacketInMask()); + Assert.assertEquals("Wrong portStatusMask", createPortStatusMask(), builtByFactory.getPortStatusMask()); + Assert.assertEquals("Wrong flowRemovedMask", createFlowRemovedMask(), builtByFactory.getFlowRemovedMask()); } private static List createPacketInMask() { - final List inMasks = new ArrayList<>(); - PacketInMaskBuilder maskBuilder; - // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER - maskBuilder = new PacketInMaskBuilder(); - List reasons = new ArrayList<>(); - reasons.add(PacketInReason.OFPRNOMATCH); - reasons.add(PacketInReason.OFPRACTION); - reasons.add(PacketInReason.OFPRINVALIDTTL); - maskBuilder.setMask(reasons); - inMasks.add(maskBuilder.build()); - // OFPCR_ROLE_SLAVE - maskBuilder = new PacketInMaskBuilder(); - reasons = new ArrayList<>(); - maskBuilder.setMask(reasons); - inMasks.add(maskBuilder.build()); - return inMasks; + return List.of( + // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER + new PacketInMaskBuilder() + .setMask(Set.of(PacketInReason.OFPRNOMATCH, PacketInReason.OFPRACTION, PacketInReason.OFPRINVALIDTTL)) + .build(), + // OFPCR_ROLE_SLAVE + new PacketInMaskBuilder().setMask(Set.of()).build()); } private static List createPortStatusMask() { - final List inMasks = new ArrayList<>(); - PortStatusMaskBuilder maskBuilder; - // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER - maskBuilder = new PortStatusMaskBuilder(); - List reasons = new ArrayList<>(); - reasons.add(PortReason.OFPPRADD); - reasons.add(PortReason.OFPPRDELETE); - reasons.add(PortReason.OFPPRMODIFY); - inMasks.add(maskBuilder.setMask(reasons).build()); - // OFPCR_ROLE_SLAVE - maskBuilder = new PortStatusMaskBuilder(); - reasons = new ArrayList<>(); - maskBuilder.setMask(reasons); - inMasks.add(maskBuilder.build()); - return inMasks; + return List.of( + // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER + new PortStatusMaskBuilder() + .setMask(Set.of(PortReason.OFPPRADD, PortReason.OFPPRDELETE, PortReason.OFPPRMODIFY)) + .build(), + // OFPCR_ROLE_SLAVE + new PortStatusMaskBuilder().setMask(Set.of()).build()); } private static List createFlowRemovedMask() { - final List inMasks = new ArrayList<>(); - FlowRemovedMaskBuilder maskBuilder; - // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER - maskBuilder = new FlowRemovedMaskBuilder(); - List reasons = new ArrayList<>(); - reasons.add(FlowRemovedReason.OFPRRIDLETIMEOUT); - reasons.add(FlowRemovedReason.OFPRRHARDTIMEOUT); - reasons.add(FlowRemovedReason.OFPRRDELETE); - reasons.add(FlowRemovedReason.OFPRRGROUPDELETE); - maskBuilder.setMask(reasons); - inMasks.add(maskBuilder.build()); - // OFPCR_ROLE_SLAVE - maskBuilder = new FlowRemovedMaskBuilder(); - reasons = new ArrayList<>(); - maskBuilder.setMask(reasons); - inMasks.add(maskBuilder.build()); - return inMasks; + return List.of( + // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER + new FlowRemovedMaskBuilder() + .setMask(Set.of( + FlowRemovedReason.OFPRRIDLETIMEOUT, + FlowRemovedReason.OFPRRHARDTIMEOUT, + FlowRemovedReason.OFPRRDELETE, + FlowRemovedReason.OFPRRGROUPDELETE)) + .build(), + // OFPCR_ROLE_SLAVE + new FlowRemovedMaskBuilder().setMask(Set.of()).build()); } } diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetAsyncInputMessageFactoryTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetAsyncInputMessageFactoryTest.java index 95e4b8b78b..7b86b2ef15 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetAsyncInputMessageFactoryTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetAsyncInputMessageFactoryTest.java @@ -8,8 +8,8 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; -import java.util.ArrayList; import java.util.List; +import java.util.Set; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -70,61 +70,36 @@ public class SetAsyncInputMessageFactoryTest { } private static List createPacketInMask() { - final List masks = new ArrayList<>(); - PacketInMaskBuilder builder; - // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER - builder = new PacketInMaskBuilder(); - List packetInReasonList = new ArrayList<>(); - packetInReasonList.add(PacketInReason.OFPRNOMATCH); - packetInReasonList.add(PacketInReason.OFPRACTION); - packetInReasonList.add(PacketInReason.OFPRINVALIDTTL); - builder.setMask(packetInReasonList); - masks.add(builder.build()); - // OFPCR_ROLE_SLAVE - builder = new PacketInMaskBuilder(); - packetInReasonList = new ArrayList<>(); - builder.setMask(packetInReasonList); - masks.add(builder.build()); - return masks; + return List.of( + // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER + new PacketInMaskBuilder() + .setMask(Set.of(PacketInReason.OFPRNOMATCH, PacketInReason.OFPRACTION, PacketInReason.OFPRINVALIDTTL)) + .build(), + // OFPCR_ROLE_SLAVE + new PacketInMaskBuilder().setMask(Set.of()).build()); } private static List createPortStatusMask() { - final List masks = new ArrayList<>(); - PortStatusMaskBuilder builder; - builder = new PortStatusMaskBuilder(); - // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER - List portReasonList = new ArrayList<>(); - portReasonList.add(PortReason.OFPPRADD); - portReasonList.add(PortReason.OFPPRDELETE); - portReasonList.add(PortReason.OFPPRMODIFY); - builder.setMask(portReasonList); - masks.add(builder.build()); - // OFPCR_ROLE_SLAVE - builder = new PortStatusMaskBuilder(); - portReasonList = new ArrayList<>(); - builder.setMask(portReasonList); - masks.add(builder.build()); - return masks; + return List.of( + // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER + new PortStatusMaskBuilder() + .setMask(Set.of(PortReason.OFPPRADD, PortReason.OFPPRDELETE, PortReason.OFPPRMODIFY)) + .build(), + // OFPCR_ROLE_SLAVE + new PortStatusMaskBuilder().setMask(Set.of()).build()); } private static List createFlowRemowedMask() { - final List masks = new ArrayList<>(); - FlowRemovedMaskBuilder builder; - // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER - builder = new FlowRemovedMaskBuilder(); - List flowRemovedReasonList = new ArrayList<>(); - flowRemovedReasonList.add(FlowRemovedReason.OFPRRIDLETIMEOUT); - flowRemovedReasonList.add(FlowRemovedReason.OFPRRHARDTIMEOUT); - flowRemovedReasonList.add(FlowRemovedReason.OFPRRDELETE); - flowRemovedReasonList.add(FlowRemovedReason.OFPRRGROUPDELETE); - builder.setMask(flowRemovedReasonList); - masks.add(builder.build()); - // OFPCR_ROLE_SLAVE - builder = new FlowRemovedMaskBuilder(); - flowRemovedReasonList = new ArrayList<>(); - builder.setMask(flowRemovedReasonList); - masks.add(builder.build()); - return masks; + return List.of( + // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER + new FlowRemovedMaskBuilder() + .setMask(Set.of( + FlowRemovedReason.OFPRRIDLETIMEOUT, + FlowRemovedReason.OFPRRHARDTIMEOUT, + FlowRemovedReason.OFPRRDELETE, + FlowRemovedReason.OFPRRGROUPDELETE)) + .build(), + // OFPCR_ROLE_SLAVE + new FlowRemovedMaskBuilder().setMask(Set.of()).build()); } - } diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializerTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializerTest.java index eefc3d9598..2bf6c90b56 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializerTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializerTest.java @@ -88,8 +88,7 @@ public class OF13SetFieldActionSerializerTest { registry.registerSerializer(key, serializerMock); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); ser.serialize(actionBuilder.build(), out); - Mockito.verify(serializerMock, Mockito.times(1)).serialize(Mockito.anyObject(), - Mockito.anyObject()); + Mockito.verify(serializerMock, Mockito.times(1)).serialize(Mockito.any(), Mockito.any()); int lenght = out.readableBytes(); Assert.assertEquals("Wrong - bad field code", ActionConstants.SET_FIELD_CODE, out.readUnsignedShort()); Assert.assertEquals("Wrong - bad lenght", lenght, out.readUnsignedShort()); diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncReplyMessageFactoryTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncReplyMessageFactoryTest.java index a0a6de17bb..e82e86f6a2 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncReplyMessageFactoryTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncReplyMessageFactoryTest.java @@ -9,8 +9,8 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.factories; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; -import java.util.ArrayList; import java.util.List; +import java.util.Set; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -69,61 +69,37 @@ public class GetAsyncReplyMessageFactoryTest { } private static List createPacketInMask() { - final List masks = new ArrayList<>(); - PacketInMaskBuilder builder; - // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER - builder = new PacketInMaskBuilder(); - List packetInReasonList = new ArrayList<>(); - packetInReasonList.add(PacketInReason.OFPRNOMATCH); - packetInReasonList.add(PacketInReason.OFPRACTION); - packetInReasonList.add(PacketInReason.OFPRINVALIDTTL); - builder.setMask(packetInReasonList); - masks.add(builder.build()); - // OFPCR_ROLE_SLAVE - builder = new PacketInMaskBuilder(); - packetInReasonList = new ArrayList<>(); - builder.setMask(packetInReasonList); - masks.add(builder.build()); - return masks; + return List.of( + // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER + new PacketInMaskBuilder() + .setMask(Set.of(PacketInReason.OFPRNOMATCH, PacketInReason.OFPRACTION, PacketInReason.OFPRINVALIDTTL)) + .build(), + // OFPCR_ROLE_SLAVE + new PacketInMaskBuilder().setMask(Set.of()).build()); } private static List createPortStatusMask() { - final List masks = new ArrayList<>(); - PortStatusMaskBuilder builder; - builder = new PortStatusMaskBuilder(); - // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER - List portReasonList = new ArrayList<>(); - portReasonList.add(PortReason.OFPPRADD); - portReasonList.add(PortReason.OFPPRDELETE); - portReasonList.add(PortReason.OFPPRMODIFY); - builder.setMask(portReasonList); - masks.add(builder.build()); - // OFPCR_ROLE_SLAVE - builder = new PortStatusMaskBuilder(); - portReasonList = new ArrayList<>(); - builder.setMask(portReasonList); - masks.add(builder.build()); - return masks; + return List.of( + // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER + new PortStatusMaskBuilder() + .setMask(Set.of(PortReason.OFPPRADD, PortReason.OFPPRDELETE, PortReason.OFPPRMODIFY)) + .build(), + // OFPCR_ROLE_SLAVE + new PortStatusMaskBuilder().setMask(Set.of()).build()); } private static List createFlowRemowedMask() { - final List masks = new ArrayList<>(); - FlowRemovedMaskBuilder builder; - // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER - builder = new FlowRemovedMaskBuilder(); - List flowRemovedReasonList = new ArrayList<>(); - flowRemovedReasonList.add(FlowRemovedReason.OFPRRIDLETIMEOUT); - flowRemovedReasonList.add(FlowRemovedReason.OFPRRHARDTIMEOUT); - flowRemovedReasonList.add(FlowRemovedReason.OFPRRDELETE); - flowRemovedReasonList.add(FlowRemovedReason.OFPRRGROUPDELETE); - builder.setMask(flowRemovedReasonList); - masks.add(builder.build()); - // OFPCR_ROLE_SLAVE - builder = new FlowRemovedMaskBuilder(); - flowRemovedReasonList = new ArrayList<>(); - builder.setMask(flowRemovedReasonList); - masks.add(builder.build()); - return masks; + return List.of( + // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER + new FlowRemovedMaskBuilder() + .setMask(Set.of( + FlowRemovedReason.OFPRRIDLETIMEOUT, + FlowRemovedReason.OFPRRHARDTIMEOUT, + FlowRemovedReason.OFPRRDELETE, + FlowRemovedReason.OFPRRGROUPDELETE)) + .build(), + // OFPCR_ROLE_SLAVE + new FlowRemovedMaskBuilder().setMask(Set.of()).build()); } @Test diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java index 6046460585..2504a38949 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java @@ -9,8 +9,8 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.factories; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; -import java.util.ArrayList; import java.util.List; +import java.util.Set; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -80,61 +80,37 @@ public class SetAsyncInputMessageFactoryTest { } private static List createPacketInMask() { - final List masks = new ArrayList<>(); - PacketInMaskBuilder builder; - // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER - builder = new PacketInMaskBuilder(); - List packetInReasonList = new ArrayList<>(); - packetInReasonList.add(PacketInReason.OFPRNOMATCH); - packetInReasonList.add(PacketInReason.OFPRACTION); - packetInReasonList.add(PacketInReason.OFPRINVALIDTTL); - builder.setMask(packetInReasonList); - masks.add(builder.build()); - // OFPCR_ROLE_SLAVE - builder = new PacketInMaskBuilder(); - packetInReasonList = new ArrayList<>(); - builder.setMask(packetInReasonList); - masks.add(builder.build()); - return masks; + return List.of( + // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER + new PacketInMaskBuilder() + .setMask(Set.of(PacketInReason.OFPRNOMATCH, PacketInReason.OFPRACTION, PacketInReason.OFPRINVALIDTTL)) + .build(), + // OFPCR_ROLE_SLAVE + new PacketInMaskBuilder().setMask(Set.of()).build()); } private static List createPortStatusMask() { - final List masks = new ArrayList<>(); - PortStatusMaskBuilder builder; - builder = new PortStatusMaskBuilder(); - // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER - List portReasonList = new ArrayList<>(); - portReasonList.add(PortReason.OFPPRADD); - portReasonList.add(PortReason.OFPPRDELETE); - portReasonList.add(PortReason.OFPPRMODIFY); - builder.setMask(portReasonList); - masks.add(builder.build()); - // OFPCR_ROLE_SLAVE - builder = new PortStatusMaskBuilder(); - portReasonList = new ArrayList<>(); - builder.setMask(portReasonList); - masks.add(builder.build()); - return masks; + return List.of( + // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER + new PortStatusMaskBuilder() + .setMask(Set.of(PortReason.OFPPRADD, PortReason.OFPPRDELETE, PortReason.OFPPRMODIFY)) + .build(), + // OFPCR_ROLE_SLAVE + new PortStatusMaskBuilder().setMask(Set.of()).build()); } private static List createFlowRemowedMask() { - final List masks = new ArrayList<>(); - FlowRemovedMaskBuilder builder; - // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER - builder = new FlowRemovedMaskBuilder(); - List flowRemovedReasonList = new ArrayList<>(); - flowRemovedReasonList.add(FlowRemovedReason.OFPRRIDLETIMEOUT); - flowRemovedReasonList.add(FlowRemovedReason.OFPRRHARDTIMEOUT); - flowRemovedReasonList.add(FlowRemovedReason.OFPRRDELETE); - flowRemovedReasonList.add(FlowRemovedReason.OFPRRGROUPDELETE); - builder.setMask(flowRemovedReasonList); - masks.add(builder.build()); - // OFPCR_ROLE_SLAVE - builder = new FlowRemovedMaskBuilder(); - flowRemovedReasonList = new ArrayList<>(); - builder.setMask(flowRemovedReasonList); - masks.add(builder.build()); - return masks; + return List.of( + // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER + new FlowRemovedMaskBuilder() + .setMask(Set.of( + FlowRemovedReason.OFPRRIDLETIMEOUT, + FlowRemovedReason.OFPRRHARDTIMEOUT, + FlowRemovedReason.OFPRRDELETE, + FlowRemovedReason.OFPRRGROUPDELETE)) + .build(), + // OFPCR_ROLE_SLAVE + new FlowRemovedMaskBuilder().setMask(Set.of()).build()); } /** diff --git a/openflowjava/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java b/openflowjava/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java index efaab0c15a..fde9d56876 100644 --- a/openflowjava/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java +++ b/openflowjava/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java @@ -92,7 +92,7 @@ public class IntegrationTest { tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/selfSignedSwitch", PathType.CLASSPATH, KeystoreType.JKS, "/selfSignedController", PathType.CLASSPATH, - new ArrayList()); + List.of()); } connConfig = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT, true, false, CHANNEL_OUTBOUND_QUEUE_SIZE); diff --git a/openflowjava/openflow-protocol-spi/src/main/yang/openflow-switch-connection-config.yang b/openflowjava/openflow-protocol-spi/src/main/yang/openflow-switch-connection-config.yang index 3e742fcfb3..6794bae339 100644 --- a/openflowjava/openflow-protocol-spi/src/main/yang/openflow-switch-connection-config.yang +++ b/openflowjava/openflow-protocol-spi/src/main/yang/openflow-switch-connection-config.yang @@ -112,6 +112,7 @@ module openflow-switch-connection-config { leaf-list cipher-suites { description "combination of cryptographic algorithms used by TLS connection"; type string; + ordered-by user; } } diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/OFConstants.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/OFConstants.java index 4c00e421d3..37aac30724 100644 --- a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/OFConstants.java +++ b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/OFConstants.java @@ -11,6 +11,7 @@ import java.util.List; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; +import org.opendaylight.yangtools.yang.common.ErrorTag; import org.opendaylight.yangtools.yang.common.Uint16; import org.opendaylight.yangtools.yang.common.Uint32; import org.opendaylight.yangtools.yang.common.Uint64; @@ -68,9 +69,7 @@ public final class OFConstants { public static final int SIGNUM_UNSIGNED = 1; /** RpcError application tag. */ - public static final String APPLICATION_TAG = "OPENFLOW_PLUGIN"; - /** RpcError tag - timeout. */ - public static final String ERROR_TAG_TIMEOUT = "TIMOUT"; + public static final ErrorTag APPLICATION_TAG = new ErrorTag("OPENFLOW_PLUGIN"); /** Persistent ID of OpenFlowPlugin configuration file. */ public static final String CONFIG_FILE_ID = "org.opendaylight.openflowplugin"; diff --git a/openflowplugin-impl/pom.xml b/openflowplugin-impl/pom.xml index 4e213fc9c9..bea91fa89c 100644 --- a/openflowplugin-impl/pom.xml +++ b/openflowplugin-impl/pom.xml @@ -19,7 +19,11 @@ org.osgi - osgi.core + org.osgi.framework + + + org.osgi + org.osgi.service.cm org.opendaylight.openflowplugin @@ -109,10 +113,6 @@ ${project.groupId}.openflowjava openflow-protocol-impl - - org.osgi - osgi.cmpn - org.opendaylight.openflowplugin openflowplugin-common diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/MultipartReplyTranslatorUtil.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/MultipartReplyTranslatorUtil.java index 1724b6a5a4..39403cf047 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/MultipartReplyTranslatorUtil.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/MultipartReplyTranslatorUtil.java @@ -7,7 +7,7 @@ */ package org.opendaylight.openflowplugin.impl.common; -import java.util.ArrayList; +import com.google.common.collect.ImmutableSet; import java.util.List; import java.util.Map; import java.util.Optional; @@ -344,38 +344,41 @@ public final class MultipartReplyTranslatorUtil { .reply.body.MultipartReplyGroupFeatures translateGroupFeatures(final MultipartReply msg) { final MultipartReplyGroupFeatures replyBody = ((MultipartReplyGroupFeaturesCase) msg.getMultipartReplyBody()) .getMultipartReplyGroupFeatures(); - final List> supportedGroups = new ArrayList<>(); - if (replyBody.getTypes().getOFPGTALL()) { + + final var replyTypes = replyBody.getTypes(); + final var supportedGroups = ImmutableSet.>builder(); + if (replyTypes.getOFPGTALL()) { supportedGroups.add(GroupAll.class); } - if (replyBody.getTypes().getOFPGTSELECT()) { + if (replyTypes.getOFPGTSELECT()) { supportedGroups.add(GroupSelect.class); } - if (replyBody.getTypes().getOFPGTINDIRECT()) { + if (replyTypes.getOFPGTINDIRECT()) { supportedGroups.add(GroupIndirect.class); } - if (replyBody.getTypes().getOFPGTFF()) { + if (replyTypes.getOFPGTFF()) { supportedGroups.add(GroupFf.class); } - List> supportedCapabilities = new ArrayList<>(); - if (replyBody.getCapabilities().getOFPGFCCHAINING()) { + final var replyCapabilities = replyBody.getCapabilities(); + final var supportedCapabilities = ImmutableSet.>builder(); + if (replyCapabilities.getOFPGFCCHAINING()) { supportedCapabilities.add(Chaining.class); } - if (replyBody.getCapabilities().getOFPGFCCHAININGCHECKS()) { + if (replyCapabilities.getOFPGFCCHAININGCHECKS()) { supportedCapabilities.add(ChainingChecks.class); } - if (replyBody.getCapabilities().getOFPGFCSELECTLIVENESS()) { + if (replyCapabilities.getOFPGFCSELECTLIVENESS()) { supportedCapabilities.add(SelectLiveness.class); } - if (replyBody.getCapabilities().getOFPGFCSELECTWEIGHT()) { + if (replyCapabilities.getOFPGFCSELECTWEIGHT()) { supportedCapabilities.add(SelectWeight.class); } return new MultipartReplyGroupFeaturesBuilder() - .setGroupTypesSupported(supportedGroups) + .setGroupTypesSupported(supportedGroups.build()) .setMaxGroups(replyBody.getMaxGroups()) - .setGroupCapabilitiesSupported(supportedCapabilities) + .setGroupCapabilitiesSupported(supportedCapabilities.build()) .setActions(GroupUtil.extractGroupActionsSupportBitmap(replyBody.getActionsBitmap())) .build(); } @@ -419,25 +422,27 @@ public final class MultipartReplyTranslatorUtil { MultipartReplyMeterFeaturesCase caseBody = (MultipartReplyMeterFeaturesCase) msg.getMultipartReplyBody(); MultipartReplyMeterFeatures replyBody = caseBody.getMultipartReplyMeterFeatures(); - final List> supportedCapabilities = new ArrayList<>(); - if (replyBody.getCapabilities().getOFPMFBURST()) { + final var replyCapabilities = replyBody.getCapabilities(); + final var supportedCapabilities = ImmutableSet.>builder(); + if (replyCapabilities.getOFPMFBURST()) { supportedCapabilities.add(MeterBurst.class); } - if (replyBody.getCapabilities().getOFPMFKBPS()) { + if (replyCapabilities.getOFPMFKBPS()) { supportedCapabilities.add(MeterKbps.class); } - if (replyBody.getCapabilities().getOFPMFPKTPS()) { + if (replyCapabilities.getOFPMFPKTPS()) { supportedCapabilities.add(MeterPktps.class); } - if (replyBody.getCapabilities().getOFPMFSTATS()) { + if (replyCapabilities.getOFPMFSTATS()) { supportedCapabilities.add(MeterStats.class); } - final List> supportedMeterBand = new ArrayList<>(); - if (replyBody.getBandTypes().getOFPMBTDROP()) { + final var replyMeterBand = replyBody.getBandTypes(); + final var supportedMeterBand = ImmutableSet.>builder(); + if (replyMeterBand.getOFPMBTDROP()) { supportedMeterBand.add(MeterBandDrop.class); } - if (replyBody.getBandTypes().getOFPMBTDSCPREMARK()) { + if (replyMeterBand.getOFPMBTDSCPREMARK()) { supportedMeterBand.add(MeterBandDscpRemark.class); } @@ -445,8 +450,8 @@ public final class MultipartReplyTranslatorUtil { .setMaxBands(replyBody.getMaxBands()) .setMaxColor(replyBody.getMaxColor()) .setMaxMeter(new Counter32(replyBody.getMaxMeter())) - .setMeterCapabilitiesSupported(supportedCapabilities) - .setMeterBandSupported(supportedMeterBand) + .setMeterCapabilitiesSupported(supportedCapabilities.build()) + .setMeterBandSupported(supportedMeterBand.build()) .build(); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/BuildSwitchCapabilitiesOF10.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/BuildSwitchCapabilitiesOF10.java index aeeb684a2c..046c0046ff 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/BuildSwitchCapabilitiesOF10.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/BuildSwitchCapabilitiesOF10.java @@ -7,8 +7,7 @@ */ package org.opendaylight.openflowplugin.impl.device; -import java.util.ArrayList; -import java.util.List; +import com.google.common.collect.ImmutableSet; import org.opendaylight.openflowplugin.api.openflow.md.core.sal.BuildSwitchFeatures; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FeatureCapability; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowFeatureCapabilityArpMatchIp; @@ -44,36 +43,41 @@ public final class BuildSwitchCapabilitiesOF10 implements BuildSwitchFeatures { @Override public SwitchFeatures build(final GetFeaturesOutput features) { - List> capabilities = new ArrayList<>(); - if (features.getCapabilitiesV10().getOFPCARPMATCHIP()) { - capabilities.add(FlowFeatureCapabilityArpMatchIp.class); + final var capabilities = features.getCapabilitiesV10(); + if (capabilities == null) { + return null; } - if (features.getCapabilitiesV10().getOFPCFLOWSTATS()) { - capabilities.add(FlowFeatureCapabilityFlowStats.class); + + final var builder = ImmutableSet.>builder(); + if (capabilities.getOFPCARPMATCHIP()) { + builder.add(FlowFeatureCapabilityArpMatchIp.class); + } + if (capabilities.getOFPCFLOWSTATS()) { + builder.add(FlowFeatureCapabilityFlowStats.class); } - if (features.getCapabilitiesV10().getOFPCIPREASM()) { - capabilities.add(FlowFeatureCapabilityIpReasm.class); + if (capabilities.getOFPCIPREASM()) { + builder.add(FlowFeatureCapabilityIpReasm.class); } - if (features.getCapabilitiesV10().getOFPCPORTSTATS()) { - capabilities.add(FlowFeatureCapabilityPortStats.class); + if (capabilities.getOFPCPORTSTATS()) { + builder.add(FlowFeatureCapabilityPortStats.class); } - if (features.getCapabilitiesV10().getOFPCQUEUESTATS()) { - capabilities.add(FlowFeatureCapabilityQueueStats.class); + if (capabilities.getOFPCQUEUESTATS()) { + builder.add(FlowFeatureCapabilityQueueStats.class); } - if (features.getCapabilitiesV10().getOFPCRESERVED()) { - capabilities.add(FlowFeatureCapabilityReserved.class); + if (capabilities.getOFPCRESERVED()) { + builder.add(FlowFeatureCapabilityReserved.class); } - if (features.getCapabilitiesV10().getOFPCSTP()) { - capabilities.add(FlowFeatureCapabilityStp.class); + if (capabilities.getOFPCSTP()) { + builder.add(FlowFeatureCapabilityStp.class); } - if (features.getCapabilitiesV10().getOFPCTABLESTATS()) { - capabilities.add(FlowFeatureCapabilityTableStats.class); + if (capabilities.getOFPCTABLESTATS()) { + builder.add(FlowFeatureCapabilityTableStats.class); } return new SwitchFeaturesBuilder() .setMaxBuffers(features.getBuffers()) .setMaxTables(features.getTables()) - .setCapabilities(capabilities) + .setCapabilities(builder.build()) .build(); } } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/BuildSwitchCapabilitiesOF13.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/BuildSwitchCapabilitiesOF13.java index c7c370523c..b502cd2d9d 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/BuildSwitchCapabilitiesOF13.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/BuildSwitchCapabilitiesOF13.java @@ -7,8 +7,7 @@ */ package org.opendaylight.openflowplugin.impl.device; -import java.util.ArrayList; -import java.util.List; +import com.google.common.collect.ImmutableSet; import org.opendaylight.openflowplugin.api.openflow.md.core.sal.BuildSwitchFeatures; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FeatureCapability; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowFeatureCapabilityFlowStats; @@ -43,33 +42,38 @@ public final class BuildSwitchCapabilitiesOF13 implements BuildSwitchFeatures { @Override public SwitchFeatures build(final GetFeaturesOutput features) { - List> capabilities = new ArrayList<>(); - if (features.getCapabilities().getOFPCFLOWSTATS()) { - capabilities.add(FlowFeatureCapabilityFlowStats.class); + final var capabilities = features.getCapabilities(); + if (capabilities == null) { + return null; } - if (features.getCapabilities().getOFPCGROUPSTATS()) { - capabilities.add(FlowFeatureCapabilityGroupStats.class); + + final var builder = ImmutableSet.>builder(); + if (capabilities.getOFPCFLOWSTATS()) { + builder.add(FlowFeatureCapabilityFlowStats.class); + } + if (capabilities.getOFPCGROUPSTATS()) { + builder.add(FlowFeatureCapabilityGroupStats.class); } - if (features.getCapabilities().getOFPCIPREASM()) { - capabilities.add(FlowFeatureCapabilityIpReasm.class); + if (capabilities.getOFPCIPREASM()) { + builder.add(FlowFeatureCapabilityIpReasm.class); } - if (features.getCapabilities().getOFPCPORTBLOCKED()) { - capabilities.add(FlowFeatureCapabilityPortBlocked.class); + if (capabilities.getOFPCPORTBLOCKED()) { + builder.add(FlowFeatureCapabilityPortBlocked.class); } - if (features.getCapabilities().getOFPCPORTSTATS()) { - capabilities.add(FlowFeatureCapabilityPortStats.class); + if (capabilities.getOFPCPORTSTATS()) { + builder.add(FlowFeatureCapabilityPortStats.class); } - if (features.getCapabilities().getOFPCQUEUESTATS()) { - capabilities.add(FlowFeatureCapabilityQueueStats.class); + if (capabilities.getOFPCQUEUESTATS()) { + builder.add(FlowFeatureCapabilityQueueStats.class); } - if (features.getCapabilities().getOFPCTABLESTATS()) { - capabilities.add(FlowFeatureCapabilityTableStats.class); + if (capabilities.getOFPCTABLESTATS()) { + builder.add(FlowFeatureCapabilityTableStats.class); } return new SwitchFeaturesBuilder() .setMaxBuffers(features.getBuffers()) .setMaxTables(features.getTables()) - .setCapabilities(capabilities) + .setCapabilities(builder.build()) .build(); } } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/SwitchFeaturesUtil.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/SwitchFeaturesUtil.java index e71780330b..93932451fb 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/SwitchFeaturesUtil.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/SwitchFeaturesUtil.java @@ -10,7 +10,6 @@ package org.opendaylight.openflowplugin.impl.device; 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; import org.opendaylight.openflowplugin.api.openflow.md.core.sal.BuildSwitchFeatures; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.SwitchFeatures; @@ -20,25 +19,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public final class SwitchFeaturesUtil { - private static final Logger LOG = LoggerFactory.getLogger(SwitchFeaturesUtil.class); - private static SwitchFeaturesUtil instance = new SwitchFeaturesUtil(); - private final Map swFeaturesBuilders; + private static final Map SWITCH_FEATURES_BUILDERS = Map.of( + OFP_VERSION_1_0, BuildSwitchCapabilitiesOF10.getInstance(), + OFP_VERSION_1_3, BuildSwitchCapabilitiesOF13.getInstance()); private SwitchFeaturesUtil() { - swFeaturesBuilders = new HashMap<>(); - swFeaturesBuilders.put(OFP_VERSION_1_0, BuildSwitchCapabilitiesOF10.getInstance()); - swFeaturesBuilders.put(OFP_VERSION_1_3, BuildSwitchCapabilitiesOF13.getInstance()); - } - - /** - * Get singleton instance. - * - * @return instance - */ - public static SwitchFeaturesUtil getInstance() { - return instance; + // Hidden on purpose } /** @@ -48,18 +36,14 @@ public final class SwitchFeaturesUtil { * {@link org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput} * @return switch features */ - public SwitchFeatures buildSwitchFeatures(final GetFeaturesOutput features) { - if (swFeaturesBuilders.containsKey(features.getVersion())) { - LOG.debug("map contains version {}", features.getVersion()); - try { - return swFeaturesBuilders.get(features.getVersion()).build(features); - } catch (NullPointerException e) { - LOG.warn("error while building switch features: {}", e.getMessage()); - LOG.debug("error while building switch features.. ", e); - } - } else { - LOG.warn("unknown version: {}", features.getVersion()); + public static SwitchFeatures buildSwitchFeatures(final GetFeaturesOutput features) { + final var version = features.getVersion(); + final var builder = SWITCH_FEATURES_BUILDERS.get(version); + if (builder != null) { + LOG.debug("map contains version {}", version); + return builder.build(features); } + LOG.warn("unknown version: {}", version); return null; } } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializer.java index 811a88889a..5f2b1c2664 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializer.java @@ -12,7 +12,6 @@ import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; @@ -131,8 +130,6 @@ public class OF10DeviceInitializer extends AbstractDeviceInitializer { } @SuppressWarnings("checkstyle:IllegalCatch") - @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", - justification = "https://github.com/spotbugs/spotbugs/issues/811") private static void makeEmptyFlowCapableNode(final TxFacade txFacade, final DeviceInfo deviceInfo) { try { txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL, diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImpl.java index 73bb3fe0c6..24574fb594 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImpl.java @@ -66,7 +66,7 @@ import org.opendaylight.yangtools.yang.common.Uint8; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ContextChainHolderImpl implements ContextChainHolder, MasterChecker { +public final class ContextChainHolderImpl implements ContextChainHolder, MasterChecker { private static final Logger LOG = LoggerFactory.getLogger(ContextChainHolderImpl.class); private static final Logger OF_EVENT_LOG = LoggerFactory.getLogger("OfEventLog"); @@ -105,7 +105,7 @@ public class ContextChainHolderImpl implements ContextChainHolder, MasterChecker this.ownershipChangeListener.setMasterChecker(this); this.entityOwnershipService = entityOwnershipService; this.config = config; - this.eosListenerRegistration = Objects + eosListenerRegistration = Objects .requireNonNull(entityOwnershipService.registerListener(ASYNC_SERVICE_ENTITY_TYPE, this)); } @@ -361,7 +361,7 @@ public class ContextChainHolderImpl implements ContextChainHolder, MasterChecker LOG.warn("Seems like device is still owned by other controller instance. Skip deleting {} " + "node from operational datastore.", entityName); } - } catch (TimeoutException | ExecutionException | NullPointerException | InterruptedException e) { + } catch (TimeoutException | ExecutionException | InterruptedException e) { LOG.warn("Not able to remove device {} from operational DS. ", entityName, e); } }, config.getDeviceDatastoreRemovalDelay().getValue().toJava(), TimeUnit.MILLISECONDS); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupFeaturesDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupFeaturesDeserializer.java index 80f2d9006f..9f51e39f3b 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupFeaturesDeserializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupFeaturesDeserializer.java @@ -9,9 +9,9 @@ package org.opendaylight.openflowplugin.impl.protocol.deserialization.multipart; import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; +import com.google.common.collect.ImmutableSet; import io.netty.buffer.ByteBuf; -import java.util.ArrayList; -import java.util.List; +import java.util.Set; import java.util.stream.Collectors; import java.util.stream.IntStream; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; @@ -33,67 +33,53 @@ public class MultipartReplyGroupFeaturesDeserializer implements OFDeserializer readUint32(message)) - .collect(Collectors.toList())) + .collect(Collectors.toUnmodifiableList())) .setActions(IntStream.range(0, GROUP_TYPES) .mapToObj(i -> readUint32(message)) - .collect(Collectors.toList())) + .collect(Collectors.toUnmodifiableList())) .build(); } - private static List> readGroupCapabilities(final ByteBuf message) { - final List> groupCapabilities = new ArrayList<>(); + private static Set> readGroupCapabilities(final ByteBuf message) { final long capabilitiesMask = message.readUnsignedInt(); - final boolean gcSelectWeight = (capabilitiesMask & 1 << 0) != 0; - final boolean gcSelectLiveness = (capabilitiesMask & 1 << 1) != 0; - final boolean gcChaining = (capabilitiesMask & 1 << 2) != 0; - final boolean gcChainingChecks = (capabilitiesMask & 1 << 3) != 0; - - if (gcSelectWeight) { - groupCapabilities.add(SelectWeight.class); + final var builder = ImmutableSet.>builder(); + if ((capabilitiesMask & 1 << 0) != 0) { + builder.add(SelectWeight.class); } - if (gcSelectLiveness) { - groupCapabilities.add(SelectLiveness.class); + if ((capabilitiesMask & 1 << 1) != 0) { + builder.add(SelectLiveness.class); } - if (gcChaining) { - groupCapabilities.add(Chaining.class); + if ((capabilitiesMask & 1 << 2) != 0) { + builder.add(Chaining.class); } - if (gcChainingChecks) { - groupCapabilities.add(ChainingChecks.class); + if ((capabilitiesMask & 1 << 3) != 0) { + builder.add(ChainingChecks.class); } - - return groupCapabilities; + return builder.build(); } - private static List> readGroupTypes(final ByteBuf message) { - final List> groupTypes = new ArrayList<>(); + private static Set> readGroupTypes(final ByteBuf message) { final long typesMask = message.readUnsignedInt(); - final boolean gtAll = (typesMask & 1 << 0) != 0; - final boolean gtSelect = (typesMask & 1 << 1) != 0; - final boolean gtIndirect = (typesMask & 1 << 2) != 0; - final boolean gtFF = (typesMask & 1 << 3) != 0; - - if (gtAll) { - groupTypes.add(GroupAll.class); + final var builder = ImmutableSet.>builder(); + if ((typesMask & 1 << 0) != 0) { + builder.add(GroupAll.class); } - if (gtSelect) { - groupTypes.add(GroupSelect.class); + if ((typesMask & 1 << 1) != 0) { + builder.add(GroupSelect.class); } - if (gtIndirect) { - groupTypes.add(GroupIndirect.class); + if ((typesMask & 1 << 2) != 0) { + builder.add(GroupIndirect.class); } - if (gtFF) { - groupTypes.add(GroupFf.class); + if ((typesMask & 1 << 3) != 0) { + builder.add(GroupFf.class); } - - return groupTypes; + return builder.build(); } } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyMeterFeaturesDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyMeterFeaturesDeserializer.java index 2465a7505c..4c24be8396 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyMeterFeaturesDeserializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyMeterFeaturesDeserializer.java @@ -10,9 +10,9 @@ package org.opendaylight.openflowplugin.impl.protocol.deserialization.multipart; import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; +import com.google.common.collect.ImmutableSet; import io.netty.buffer.ByteBuf; -import java.util.ArrayList; -import java.util.List; +import java.util.Set; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesBuilder; @@ -39,45 +39,36 @@ public class MultipartReplyMeterFeaturesDeserializer implements OFDeserializer> readMeterBands(final ByteBuf message) { - final List> bandTypes = new ArrayList<>(); + private static Set> readMeterBands(final ByteBuf message) { final long typesMask = message.readUnsignedInt(); - final boolean mbtDrop = (typesMask & 1) != 0; - final boolean mbtDscpRemark = (typesMask & 1 << 1) != 0; - if (mbtDrop) { + final var bandTypes = ImmutableSet.>builder(); + if ((typesMask & 1) != 0) { bandTypes.add(MeterBandDrop.class); } - if (mbtDscpRemark) { + if ((typesMask & 1 << 1) != 0) { bandTypes.add(MeterBandDscpRemark.class); } - - return bandTypes; + return bandTypes.build(); } - private static List> readMeterCapabilities(final ByteBuf message) { - final List> meterCapabilities = new ArrayList<>(); + private static Set> readMeterCapabilities(final ByteBuf message) { final long capabilitiesMask = message.readUnsignedInt(); - final boolean mfKbps = (capabilitiesMask & 1) != 0; - final boolean mfPktps = (capabilitiesMask & 1 << 1) != 0; - final boolean mfBurst = (capabilitiesMask & 1 << 2) != 0; - final boolean mfStats = (capabilitiesMask & 1 << 3) != 0; - - if (mfKbps) { + final var meterCapabilities = ImmutableSet.>builder(); + if ((capabilitiesMask & 1) != 0) { meterCapabilities.add(MeterKbps.class); } - if (mfPktps) { + if ((capabilitiesMask & 1 << 1) != 0) { meterCapabilities.add(MeterPktps.class); } - if (mfBurst) { + if ((capabilitiesMask & 1 << 2) != 0) { meterCapabilities.add(MeterBurst.class); } - if (mfStats) { + if ((capabilitiesMask & 1 << 3) != 0) { meterCapabilities.add(MeterStats.class); } - return meterCapabilities; + return meterCapabilities.build(); } - } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractMultipartRequestCallback.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractMultipartRequestCallback.java index 082591d1bb..f46310ea32 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractMultipartRequestCallback.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractMultipartRequestCallback.java @@ -13,7 +13,7 @@ import org.opendaylight.openflowplugin.api.openflow.device.RequestContext; import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector; import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,7 +45,7 @@ public abstract class AbstractMultipartRequestCallback exten setResult(RpcResultBuilder .>failed() - .withError(RpcError.ErrorType.APPLICATION, + .withError(ErrorType.APPLICATION, String.format("Unexpected response type received: %s.", result.getClass())) .build()); } else { diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractMultipartRequestOnTheFlyCallback.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractMultipartRequestOnTheFlyCallback.java index 038612c609..3ddc8dd25c 100755 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractMultipartRequestOnTheFlyCallback.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractMultipartRequestOnTheFlyCallback.java @@ -8,6 +8,7 @@ package org.opendaylight.openflowplugin.impl.services; import com.google.common.util.concurrent.Service; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.Collections; import java.util.List; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; @@ -26,7 +27,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.Fl import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,15 +35,19 @@ import org.slf4j.LoggerFactory; public abstract class AbstractMultipartRequestOnTheFlyCallback extends AbstractMultipartRequestCallback { private static final Logger LOG = LoggerFactory.getLogger(AbstractMultipartRequestOnTheFlyCallback.class); + private final DeviceInfo deviceInfo; private final EventIdentifier doneEventIdentifier; private final TxFacade txFacade; private final MultipartWriterProvider statisticsWriterProvider; private final DeviceRegistry deviceRegistry; - private volatile Service.State gatheringState = Service.State.NEW; private final ConvertorExecutor convertorExecutor; - public AbstractMultipartRequestOnTheFlyCallback(final RequestContext> context, Class requestType, + private volatile Service.State gatheringState = Service.State.NEW; + + @SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", + justification = "getMultipartType() should be okay to call") + public AbstractMultipartRequestOnTheFlyCallback(final RequestContext> context, final Class requestType, final DeviceContext deviceContext, final EventIdentifier eventIdentifier, final MultipartWriterProvider statisticsWriterProvider, @@ -75,7 +80,7 @@ public abstract class AbstractMultipartRequestOnTheFlyCallback>failed().withError(RpcError.ErrorType.APPLICATION, + setResult(RpcResultBuilder.>failed().withError(ErrorType.APPLICATION, String.format("Unexpected response type received: %s.", result.getClass())).build()); endCollecting(false); } else { @@ -100,7 +105,7 @@ public abstract class AbstractMultipartRequestOnTheFlyCallback>failed().withError(RpcError.ErrorType.APPLICATION, + setResult(RpcResultBuilder.>failed().withError(ErrorType.APPLICATION, String.format("Unexpected exception occurred while translating response: %s. %s", result.getClass(), ex)).build()); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractRequestCallback.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractRequestCallback.java index 0181afee89..4544e933f9 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractRequestCallback.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractRequestCallback.java @@ -20,7 +20,7 @@ import org.opendaylight.openflowplugin.impl.services.util.RequestContextUtil; import org.opendaylight.openflowplugin.impl.statistics.ofpspecific.EventsTimeCounter; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; @@ -65,16 +65,16 @@ public abstract class AbstractRequestCallback implements FutureCallbackfailed().withError(RpcError.ErrorType.APPLICATION, errorString, throwable); + builder = RpcResultBuilder.failed().withError(ErrorType.APPLICATION, errorString, throwable); spyMessage(StatisticsGroup.TO_SWITCH_SUBMIT_FAILURE); } else { if (throwable != null) { builder = RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable); + .withError(ErrorType.APPLICATION, throwable.getMessage(), throwable); } else { Throwable deviceReadFailedThrowable = new Throwable("Failed to read from device."); builder = RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, deviceReadFailedThrowable.getMessage(), + .withError(ErrorType.APPLICATION, deviceReadFailedThrowable.getMessage(), deviceReadFailedThrowable); } spyMessage(StatisticsGroup.TO_SWITCH_SUBMIT_ERROR); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractService.java index d5a99fa8aa..d916cd3568 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractService.java @@ -29,7 +29,8 @@ import org.opendaylight.openflowplugin.impl.services.util.RequestContextUtil; import org.opendaylight.openflowplugin.impl.services.util.ServiceException; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yangtools.yang.binding.DataContainer; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorTag; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.common.Uint32; @@ -70,11 +71,11 @@ public abstract class AbstractService { this.eventIdentifier = eventIdentifier; } - public Uint8 getVersion() { + public final Uint8 getVersion() { return version; } - public Uint64 getDatapathId() { + public final Uint64 getDatapathId() { return datapathId; } @@ -129,7 +130,7 @@ public abstract class AbstractService { getMessageSpy().spyMessage(AbstractService.class, MessageSpy.StatisticsGroup.TO_SWITCH_DISREGARDED); return Futures.immediateFuture(RpcResultBuilder .failed() - .withError(RpcError.ErrorType.APPLICATION, "", "Request quota exceeded") + .withError(ErrorType.APPLICATION, ErrorTag.ACCESS_DENIED, "Request quota exceeded") .build()); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerAggregateFlowMultipartService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerAggregateFlowMultipartService.java index 3093bc4302..0f696787f7 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerAggregateFlowMultipartService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerAggregateFlowMultipartService.java @@ -8,8 +8,9 @@ package org.opendaylight.openflowplugin.impl.services.multilayer; +import static java.util.Objects.requireNonNull; + import com.google.common.base.MoreObjects; -import com.google.common.base.Preconditions; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; @@ -57,7 +58,7 @@ public class MultiLayerAggregateFlowMultipartService extends AbstractAggregateFl super(requestContextStack, deviceContext); this.convertorExecutor = convertorExecutor; this.translatorLibrary = translatorLibrary; - this.data = new VersionConvertorData(getVersion()); + data = new VersionConvertorData(getVersion()); } @@ -118,7 +119,7 @@ public class MultiLayerAggregateFlowMultipartService extends AbstractAggregateFl final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) { return Futures.transform(handleServiceCall(input), result -> { - if (Preconditions.checkNotNull(result).isSuccessful()) { + if (requireNonNull(result).isSuccessful()) { final MessageTranslator messageTranslator = translatorLibrary.lookupTranslator( new TranslatorKey(getVersion(), @@ -133,8 +134,8 @@ public class MultiLayerAggregateFlowMultipartService extends AbstractAggregateFl multipartReply, getDeviceInfo(), null)) - .collect(Collectors - .toList()))) + .collect(Collectors.toList())) + .build()) .build(); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerExperimenterMultipartService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerExperimenterMultipartService.java index bebf8e4e6f..9077b096ed 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerExperimenterMultipartService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerExperimenterMultipartService.java @@ -44,7 +44,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.experimenter.core.message.ExperimenterMessageOfChoice; -import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerFlowService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerFlowService.java index b14d770a94..f0b3920a6e 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerFlowService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerFlowService.java @@ -27,6 +27,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; @@ -73,7 +74,7 @@ public final class MultiLayerFlowService extends AbstractS for (RpcResult flowModResult : results) { if (flowModResult == null) { errors.add(RpcResultBuilder.newError( - RpcError.ErrorType.PROTOCOL, OFConstants.APPLICATION_TAG, + ErrorType.PROTOCOL, OFConstants.APPLICATION_TAG, "unexpected flowMod result (null) occurred")); } else if (!flowModResult.isSuccessful()) { errors.addAll(flowModResult.getErrors()); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerTableMultipartService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerTableMultipartService.java index 8d75d6b5d0..d39de7398c 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerTableMultipartService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerTableMultipartService.java @@ -39,7 +39,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.Upd import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures; import org.opendaylight.yangtools.yang.binding.util.BindingMap; -import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.common.Uint32; diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalAsyncConfigServiceImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalAsyncConfigServiceImpl.java index 142f074d48..bc9f7217c2 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalAsyncConfigServiceImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalAsyncConfigServiceImpl.java @@ -30,19 +30,19 @@ public class SalAsyncConfigServiceImpl implements SalAsyncConfigService { public SalAsyncConfigServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) { setAsyncConfigService = new SingleLayerSetAsyncConfigService(requestContextStack, deviceContext); - this.getAsyncConfigService = new SingleLayerGetAsyncConfigService(requestContextStack, deviceContext); + getAsyncConfigService = new SingleLayerGetAsyncConfigService(requestContextStack, deviceContext); } @Override - public ListenableFuture> setAsync(SetAsyncInput input) { + public ListenableFuture> setAsync(final SetAsyncInput input) { return setAsyncConfigService.handleServiceCall(input); } @Override - public ListenableFuture> getAsync(GetAsyncInput input) { + public ListenableFuture> getAsync(final GetAsyncInput input) { return Futures.transform(getAsyncConfigService.handleServiceCall(input), result -> result != null && result.isSuccessful() - ? RpcResultBuilder.success(new GetAsyncOutputBuilder(result.getResult())).build() + ? RpcResultBuilder.success(new GetAsyncOutputBuilder(result.getResult()).build()).build() : RpcResultBuilder.failed().build(), MoreExecutors.directExecutor()); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalBundleServiceImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalBundleServiceImpl.java index d1c223a081..30b60e127c 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalBundleServiceImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalBundleServiceImpl.java @@ -28,6 +28,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.on import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.send.experimenter.input.experimenter.message.of.choice.BundleControlSalBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.send.experimenter.input.experimenter.message.of.choice.bundle.add.message.sal.SalAddMessageDataBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.send.experimenter.input.experimenter.message.of.choice.bundle.control.sal.SalControlDataBuilder; +import org.opendaylight.yangtools.yang.common.ErrorTag; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; @@ -47,7 +49,7 @@ public class SalBundleServiceImpl implements SalBundleService { } @Override - public ListenableFuture> controlBundle(ControlBundleInput input) { + public ListenableFuture> controlBundle(final ControlBundleInput input) { LOG.debug("Control message for device {} and bundle type {}", input.getNode(), input.getType()); final SendExperimenterInputBuilder experimenterInputBuilder = new SendExperimenterInputBuilder(); experimenterInputBuilder.setNode(input.getNode()); @@ -64,7 +66,7 @@ public class SalBundleServiceImpl implements SalBundleService { } @Override - public ListenableFuture> addBundleMessages(AddBundleMessagesInput input) { + public ListenableFuture> addBundleMessages(final AddBundleMessagesInput input) { final List>> partialResults = new ArrayList<>(); final SendExperimenterInputBuilder experimenterInputBuilder = new SendExperimenterInputBuilder(); final BundleAddMessageSalBuilder bundleAddMessageBuilder = new BundleAddMessageSalBuilder(); @@ -89,13 +91,14 @@ public class SalBundleServiceImpl implements SalBundleService { Futures.addCallback(Futures.successfulAsList(partialResults),new FutureCallback< List>>() { @Override - public void onSuccess(List> results) { + public void onSuccess(final List> results) { final ArrayList errors = new ArrayList<>(); final RpcResultBuilder rpcResultBuilder; for (RpcResult res : results) { if (res == null) { - errors.add(RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION, "BundleExtensionService", - "RpcResult is null.")); + // FIXME: this should never happen + errors.add(RpcResultBuilder.newError(ErrorType.APPLICATION, + new ErrorTag("BundleExtensionService"), "RpcResult is null.")); } else if (!res.isSuccessful()) { errors.addAll(res.getErrors()); } @@ -109,7 +112,7 @@ public class SalBundleServiceImpl implements SalBundleService { } @Override - public void onFailure(Throwable throwable) { + public void onFailure(final Throwable throwable) { RpcResultBuilder rpcResultBuilder = RpcResultBuilder.failed(); result.set(rpcResultBuilder.build()); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowServiceImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowServiceImpl.java index 22e6270370..6542234329 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowServiceImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowServiceImpl.java @@ -43,6 +43,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; @@ -140,7 +141,7 @@ public class SalFlowServiceImpl implements SalFlowService { for (RpcResult flowModResult : results) { if (flowModResult == null) { errors.add(RpcResultBuilder.newError( - RpcError.ErrorType.PROTOCOL, OFConstants.APPLICATION_TAG, + ErrorType.PROTOCOL, OFConstants.APPLICATION_TAG, "unexpected flowMod result (null) occurred")); } else if (!flowModResult.isSuccessful()) { errors.addAll(flowModResult.getErrors()); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerAggregateFlowMultipartService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerAggregateFlowMultipartService.java index 700eb0f783..96d572d6b1 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerAggregateFlowMultipartService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerAggregateFlowMultipartService.java @@ -66,7 +66,8 @@ public class SingleLayerAggregateFlowMultipartService new AggregatedFlowStatisticsBuilder( (MultipartReplyFlowAggregateStats) multipartReplyBody) .build()) - .collect(Collectors.toList()))) + .collect(Collectors.toList())) + .build()) .build(); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerExperimenterMultipartService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerExperimenterMultipartService.java index 2783b254d3..7ab5c4daa0 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerExperimenterMultipartService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerExperimenterMultipartService.java @@ -29,7 +29,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.M import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.multipart.reply.multipart.reply.body.MultipartReplyExperimenter; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.multipart.request.multipart.request.body.MultipartRequestExperimenterBuilder; -import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerTableMultipartService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerTableMultipartService.java index 1fe13f4567..66825f9bb2 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerTableMultipartService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerTableMultipartService.java @@ -29,7 +29,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.Upd import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeatures; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.request.multipart.request.body.MultipartRequestTableFeaturesBuilder; import org.opendaylight.yangtools.yang.binding.util.BindingMap; -import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.common.Uint64; diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/util/RequestContextUtil.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/util/RequestContextUtil.java index 5bdb5f598f..05a36fc01b 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/util/RequestContextUtil.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/util/RequestContextUtil.java @@ -9,7 +9,8 @@ package org.opendaylight.openflowplugin.impl.services.util; import com.google.common.util.concurrent.ListenableFuture; import org.opendaylight.openflowplugin.api.openflow.device.RequestContext; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorTag; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; @@ -25,7 +26,7 @@ public final class RequestContextUtil { final RequestContext requestContext, final String errorMessage) { RpcResultBuilder rpcResultBuilder = RpcResultBuilder.failed().withRpcError(RpcResultBuilder - .newError(RpcError.ErrorType.APPLICATION, "", errorMessage)); + .newError(ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, errorMessage)); requestContext.setResult(rpcResultBuilder.build()); closeRequestContext(requestContext); return requestContext.getFuture(); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java index 70d87626c5..1e5f1b7dd3 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java @@ -32,13 +32,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.StatisticsManagerControlService; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.StatisticsWorkMode; import org.opendaylight.yangtools.concepts.ObjectRegistration; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class StatisticsManagerImpl implements StatisticsManager, StatisticsManagerControlService { +public final class StatisticsManagerImpl implements StatisticsManager, StatisticsManagerControlService { private static final Logger LOG = LoggerFactory.getLogger(StatisticsManagerImpl.class); @@ -56,10 +56,10 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag final ConvertorExecutor convertorExecutor, @NonNull final Executor executor) { this.config = config; - this.converterExecutor = convertorExecutor; - this.controlServiceRegistration = requireNonNull(rpcProviderRegistry - .registerRpcImplementation(StatisticsManagerControlService.class, this)); this.executor = executor; + converterExecutor = convertorExecutor; + controlServiceRegistration = requireNonNull(rpcProviderRegistry) + .registerRpcImplementation(StatisticsManagerControlService.class, this); } @Override @@ -95,8 +95,7 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag } return RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, - "Statistics work mode change is already in progress") + .withError(ErrorType.APPLICATION, "Statistics work mode change is already in progress") .buildFuture(); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupFeaturesService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupFeaturesService.java index 0314b94067..12a03ea269 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupFeaturesService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupFeaturesService.java @@ -9,8 +9,9 @@ package org.opendaylight.openflowplugin.impl.statistics.services; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; -import java.util.ArrayList; +import com.google.common.collect.ImmutableSet; import java.util.List; +import java.util.Set; import java.util.concurrent.atomic.AtomicLong; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack; @@ -94,38 +95,38 @@ final class GroupFeaturesService } @VisibleForTesting - static List> extractSupportedCapabilities(final GroupCapabilities capabilities) { - List> supportedCapabilities = new ArrayList<>(); + static Set> extractSupportedCapabilities(final GroupCapabilities capabilities) { + final var builder = ImmutableSet.>builder(); if (capabilities.getOFPGFCCHAINING()) { - supportedCapabilities.add(Chaining.class); + builder.add(Chaining.class); } if (capabilities.getOFPGFCCHAININGCHECKS()) { - supportedCapabilities.add(ChainingChecks.class); + builder.add(ChainingChecks.class); } if (capabilities.getOFPGFCSELECTLIVENESS()) { - supportedCapabilities.add(SelectLiveness.class); + builder.add(SelectLiveness.class); } if (capabilities.getOFPGFCSELECTWEIGHT()) { - supportedCapabilities.add(SelectWeight.class); + builder.add(SelectWeight.class); } - return supportedCapabilities; + return builder.build(); } @VisibleForTesting - static List> extractSupportedGroupTypes(final GroupTypes types) { - List> supportedGroups = new ArrayList<>(); + static Set> extractSupportedGroupTypes(final GroupTypes types) { + final var builder = ImmutableSet.>builder(); if (types.getOFPGTALL()) { - supportedGroups.add(GroupAll.class); + builder.add(GroupAll.class); } if (types.getOFPGTSELECT()) { - supportedGroups.add(GroupSelect.class); + builder.add(GroupSelect.class); } if (types.getOFPGTINDIRECT()) { - supportedGroups.add(GroupIndirect.class); + builder.add(GroupIndirect.class); } if (types.getOFPGTFF()) { - supportedGroups.add(GroupFf.class); + builder.add(GroupFf.class); } - return supportedGroups; + return builder.build(); } } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/MeterFeaturesService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/MeterFeaturesService.java index 89772e19e7..fb01bda3d4 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/MeterFeaturesService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/MeterFeaturesService.java @@ -9,8 +9,9 @@ package org.opendaylight.openflowplugin.impl.statistics.services; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; -import java.util.ArrayList; +import com.google.common.collect.ImmutableSet; import java.util.List; +import java.util.Set; import java.util.concurrent.atomic.AtomicLong; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack; @@ -91,22 +92,21 @@ final class MeterFeaturesService } @VisibleForTesting - protected static List> extractSupportedMeterBand( + protected static Set> extractSupportedMeterBand( final MultipartReplyMeterFeatures replyBody, final MeterBandTypeBitmap bandTypes) { - List> supportedMeterBand = new ArrayList<>(); + final var supportedMeterBand = ImmutableSet.>builder(); if (bandTypes.getOFPMBTDROP()) { supportedMeterBand.add(MeterBandDrop.class); } if (replyBody.getBandTypes().getOFPMBTDSCPREMARK()) { supportedMeterBand.add(MeterBandDscpRemark.class); } - return supportedMeterBand; + return supportedMeterBand.build(); } @VisibleForTesting - protected static List> extractMeterCapabilities(final MeterFlags capabilities) { - List> supportedCapabilities = new ArrayList<>(); - + protected static Set> extractMeterCapabilities(final MeterFlags capabilities) { + final var supportedCapabilities = ImmutableSet.>builder(); if (capabilities.getOFPMFBURST()) { supportedCapabilities.add(MeterBurst.class); } @@ -119,6 +119,6 @@ final class MeterFeaturesService if (capabilities.getOFPMFSTATS()) { supportedCapabilities.add(MeterStats.class); } - return supportedCapabilities; + return supportedCapabilities.build(); } } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/OpendaylightDirectStatisticsServiceImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/OpendaylightDirectStatisticsServiceImpl.java index d8faf06d5f..5b4ef7879e 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/OpendaylightDirectStatisticsServiceImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/OpendaylightDirectStatisticsServiceImpl.java @@ -21,7 +21,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetQueueStatisticsOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.OpendaylightDirectStatisticsService; import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; @@ -84,7 +84,7 @@ public class OpendaylightDirectStatisticsServiceImpl implements OpendaylightDire private static ListenableFuture> missingImplementation(Class service) { return RpcResultBuilder.failed().withError( - RpcError.ErrorType.APPLICATION, + ErrorType.APPLICATION, String.format("No implementation found for direct statistics service %s.", service.getCanonicalName())) .buildFuture(); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/FlowDirectStatisticsService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/FlowDirectStatisticsService.java index f506ddfe8f..0d9f471e98 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/FlowDirectStatisticsService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/FlowDirectStatisticsService.java @@ -35,8 +35,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder; import org.opendaylight.yangtools.yang.common.Uint32; -public class FlowDirectStatisticsService extends AbstractFlowDirectStatisticsService { - +public final class FlowDirectStatisticsService extends AbstractFlowDirectStatisticsService { private final FlowStatsResponseConvertorData data; public FlowDirectStatisticsService(final RequestContextStack requestContextStack, diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/GroupDirectStatisticsService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/GroupDirectStatisticsService.java index 30269830fe..3b25b34056 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/GroupDirectStatisticsService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/GroupDirectStatisticsService.java @@ -32,8 +32,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder; import org.opendaylight.yangtools.yang.binding.util.BindingMap; -public class GroupDirectStatisticsService extends AbstractGroupDirectStatisticsService { - +public final class GroupDirectStatisticsService extends AbstractGroupDirectStatisticsService { private final VersionConvertorData data; public GroupDirectStatisticsService(final RequestContextStack requestContextStack, diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtil.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtil.java index 0848ba4b33..d4a4e9dd7c 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtil.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtil.java @@ -134,11 +134,8 @@ public final class DeviceInitializationUtil { * @return switch features */ public static SwitchFeatures getSwitchFeatures(final ConnectionContext connectionContext) { - return SwitchFeaturesUtil - .getInstance() - .buildSwitchFeatures(new GetFeaturesOutputBuilder(connectionContext - .getFeatures()) - .build()); + return SwitchFeaturesUtil.buildSwitchFeatures(new GetFeaturesOutputBuilder(connectionContext.getFeatures()) + .build()); } private static @Nullable InetSocketAddress getRemoteAddress(final ConnectionContext connectionContext, diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/SwitchFeaturesUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/SwitchFeaturesUtilTest.java index 870437bb23..07fdccf01b 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/SwitchFeaturesUtilTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/SwitchFeaturesUtilTest.java @@ -7,8 +7,10 @@ */ package org.opendaylight.openflowplugin.impl.device; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities; @@ -22,10 +24,7 @@ import org.opendaylight.yangtools.yang.common.Uint8; * @author jsebin */ public class SwitchFeaturesUtilTest { - private GetFeaturesOutputBuilder featuresOutputBuilder; - private SwitchFeaturesUtil swUtil; - /** * Initialization of @@ -36,13 +35,11 @@ public class SwitchFeaturesUtilTest { @Before public void setUp() { featuresOutputBuilder = new GetFeaturesOutputBuilder(); - swUtil = SwitchFeaturesUtil.getInstance(); } @After public void tearDown() { featuresOutputBuilder = null; - swUtil = null; } /** @@ -56,7 +53,7 @@ public class SwitchFeaturesUtilTest { CapabilitiesV10 capabilities = new CapabilitiesV10(true, false, true, false, true, false, true, false); featuresOutputBuilder.setCapabilitiesV10(capabilities).setVersion(Uint8.ONE); - Assert.assertNotNull(swUtil.buildSwitchFeatures(featuresOutputBuilder.build())); + assertNotNull(SwitchFeaturesUtil.buildSwitchFeatures(featuresOutputBuilder.build())); } /** @@ -70,7 +67,7 @@ public class SwitchFeaturesUtilTest { Capabilities capabilities = new Capabilities(true, false, true, false, true, false, true); featuresOutputBuilder.setCapabilities(capabilities).setCapabilitiesV10(null).setVersion(Uint8.valueOf(4)); - Assert.assertNotNull(swUtil.buildSwitchFeatures(featuresOutputBuilder.build())); + assertNotNull(SwitchFeaturesUtil.buildSwitchFeatures(featuresOutputBuilder.build())); } /** @@ -84,7 +81,7 @@ public class SwitchFeaturesUtilTest { CapabilitiesV10 capabilities = new CapabilitiesV10(true, false, true, false, true, false, true, null); featuresOutputBuilder.setCapabilitiesV10(capabilities).setCapabilities(null).setVersion(Uint8.ONE); - Assert.assertNull(swUtil.buildSwitchFeatures(featuresOutputBuilder.build())); + assertNull(SwitchFeaturesUtil.buildSwitchFeatures(featuresOutputBuilder.build())); } /** @@ -98,7 +95,7 @@ public class SwitchFeaturesUtilTest { CapabilitiesV10 capabilities = new CapabilitiesV10(true, false, true, false, true, false, true, false); featuresOutputBuilder.setCapabilitiesV10(capabilities).setCapabilities(null).setVersion(Uint8.valueOf(4)); - Assert.assertNull(swUtil.buildSwitchFeatures(featuresOutputBuilder.build())); + assertNull(SwitchFeaturesUtil.buildSwitchFeatures(featuresOutputBuilder.build())); } /** @@ -111,6 +108,6 @@ public class SwitchFeaturesUtilTest { CapabilitiesV10 capabilities = new CapabilitiesV10(true, false, true, false, true, false, true, false); featuresOutputBuilder.setCapabilitiesV10(capabilities).setCapabilities(null).setVersion(Uint8.ZERO); - Assert.assertNull(swUtil.buildSwitchFeatures(featuresOutputBuilder.build())); + assertNull(SwitchFeaturesUtil.buildSwitchFeatures(featuresOutputBuilder.build())); } } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/TransactionChainManagerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/TransactionChainManagerTest.java index 5610f5e2a0..d6d77acab5 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/TransactionChainManagerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/TransactionChainManagerTest.java @@ -156,7 +156,7 @@ public class TransactionChainManagerTest { public void testOnTransactionChainSuccessful() { txChainManager.onTransactionChainSuccessful(transactionChain); // NOOP - Mockito.verifyZeroInteractions(transactionChain); + Mockito.verifyNoInteractions(transactionChain); } @Test diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupFeaturesDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupFeaturesDeserializerTest.java index 4d47dd6c4b..22a929b835 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupFeaturesDeserializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupFeaturesDeserializerTest.java @@ -15,6 +15,7 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; import java.util.Arrays; import java.util.List; +import java.util.Set; import org.junit.Test; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupFeatures; @@ -75,14 +76,8 @@ public class MultipartReplyGroupFeaturesDeserializerTest extends AbstractMultipa assertTrue(reply.getActions().containsAll(ACTIONS_LIST)); assertTrue(reply.getMaxGroups().containsAll(MAX_GROUPS_LIST)); - assertEquals(GROUP_TYPES_SUPPORTED.size(), reply.getGroupTypesSupported().size()); - assertEquals(GroupAll.class, reply.getGroupTypesSupported().get(0)); - assertEquals(GroupSelect.class, reply.getGroupTypesSupported().get(1)); - assertEquals(GroupIndirect.class, reply.getGroupTypesSupported().get(2)); - - assertEquals(GROUP_CAPABILITIES_SUPPORTED.size(), reply.getGroupCapabilitiesSupported().size()); - assertEquals(Chaining.class, reply.getGroupCapabilitiesSupported().get(0)); - assertEquals(ChainingChecks.class, reply.getGroupCapabilitiesSupported().get(1)); + assertEquals(Set.of(GroupAll.class, GroupSelect.class, GroupIndirect.class), reply.getGroupTypesSupported()); + assertEquals(Set.of(Chaining.class, ChainingChecks.class), reply.getGroupCapabilitiesSupported()); assertEquals(0, buffer.readableBytes()); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestOnTheFlyCallbackTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestOnTheFlyCallbackTest.java index b033ceecef..761935b2ff 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestOnTheFlyCallbackTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestOnTheFlyCallbackTest.java @@ -67,6 +67,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.binding.util.BindingMap; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; @@ -172,7 +173,7 @@ public class MultipartRequestOnTheFlyCallbackTest { multipartRequestOnTheFlyCallback.onSuccess(mockedHelloMessage); final RpcResult> expectedRpcResult = - RpcResultBuilder.>failed().withError(RpcError.ErrorType.APPLICATION, + RpcResultBuilder.>failed().withError(ErrorType.APPLICATION, String.format("Unexpected response type received: %s.", mockedHelloMessage.getClass())).build(); final RpcResult> actualResult = dummyRequestContext.getFuture().get(); assertNotNull(actualResult.getErrors()); @@ -182,7 +183,7 @@ public class MultipartRequestOnTheFlyCallbackTest { assertEquals(actualError.getMessage(), String.format("Unexpected response type received: %s.", mockedHelloMessage.getClass())); - assertEquals(actualError.getErrorType(),RpcError.ErrorType.APPLICATION); + assertEquals(actualError.getErrorType(), ErrorType.APPLICATION); assertEquals(expectedRpcResult.getResult(), actualResult.getResult()); assertEquals(expectedRpcResult.isSuccessful(), actualResult.isSuccessful()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchFlowAdaptersTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchFlowAdaptersTest.java index 0d98ca8e6e..2c9d5e802d 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchFlowAdaptersTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchFlowAdaptersTest.java @@ -43,7 +43,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.util.BindingMap; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.common.Uint16; @@ -129,7 +129,7 @@ public class FlatBatchFlowAdaptersTest { @Test public void testCreateBatchFlowChainingFunction_failures() { final RpcResult input = RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "ut-flowError") + .withError(ErrorType.APPLICATION, "ut-flowError") .withResult(new AddFlowsBatchOutputBuilder() .setBatchFailedFlowsOutput(BindingMap.ordered( createBatchFailedFlowsOutput(Uint16.ZERO, "f1"), diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchGroupAdaptersTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchGroupAdaptersTest.java index ec7e2f0014..4a68ba3f4f 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchGroupAdaptersTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchGroupAdaptersTest.java @@ -41,7 +41,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.util.BindingMap; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.common.Uint16; @@ -141,7 +141,7 @@ public class FlatBatchGroupAdaptersTest { @Test public void testCreateBatchGroupChainingFunction_failures() { final RpcResult input = RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "ut-groupError") + .withError(ErrorType.APPLICATION, "ut-groupError") .withResult(new AddGroupsBatchOutputBuilder() .setBatchFailedGroupsOutput(BindingMap.ordered( createBatchFailedGroupsOutput(Uint16.ZERO, Uint32.ONE), diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchMeterAdaptersTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchMeterAdaptersTest.java index ee5790e716..d20702aecf 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchMeterAdaptersTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchMeterAdaptersTest.java @@ -41,7 +41,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.ba import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.remove.meters.batch.input.BatchRemoveMeters; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.util.BindingMap; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.common.Uint16; @@ -142,7 +142,7 @@ public class FlatBatchMeterAdaptersTest { @Test public void testCreateBatchMeterChainingFunction_failures() { final RpcResult input = RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "ut-meterError") + .withError(ErrorType.APPLICATION, "ut-meterError") .withResult(new AddMetersBatchOutputBuilder() .setBatchFailedMetersOutput(BindingMap.ordered( createBatchFailedMetersOutput(Uint16.ZERO, Uint32.ONE), diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlatBatchServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlatBatchServiceImplTest.java index 31f41faf81..64bf758e65 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlatBatchServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlatBatchServiceImplTest.java @@ -92,7 +92,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.ba import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.input.update.grouping.UpdatedBatchedMeterBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.util.BindingMap; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.common.Uint16; @@ -295,7 +295,7 @@ public class SalFlatBatchServiceImplTest { .setFlowId(new FlowId("123")) .build())) .build()) - .withError(RpcError.ErrorType.APPLICATION, "ut-firstFlowAddError") + .withError(ErrorType.APPLICATION, "ut-firstFlowAddError") .buildFuture()); Mockito.when(salFlowsBatchService.updateFlowsBatch(ArgumentMatchers.any())) .thenReturn(RpcResultBuilder.success(new UpdateFlowsBatchOutputBuilder().build()).buildFuture()); @@ -467,7 +467,7 @@ public class SalFlatBatchServiceImplTest { FlatBatchUtil.createEmptyRpcBatchResultFuture(true); final ListenableFuture> failedChainOutput = RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "ut-chainError") + .withError(ErrorType.APPLICATION, "ut-chainError") .withResult(createFlatBatchOutput(createFlowBatchFailure(Uint16.ZERO, "f1"), createFlowBatchFailure(Uint16.ONE, "f2"))) .buildFuture(); @@ -576,7 +576,7 @@ public class SalFlatBatchServiceImplTest { .setFlowId(new FlowId("f2")) .build())) .build()) - .withError(RpcError.ErrorType.APPLICATION, "ut-addFlowBatchError") + .withError(ErrorType.APPLICATION, "ut-addFlowBatchError") .buildFuture()); final Future> rpcResultFuture = diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowsBatchServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowsBatchServiceImplTest.java index 09f6c43b3b..5825acd5a0 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowsBatchServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowsBatchServiceImplTest.java @@ -62,7 +62,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.util.BindingMap; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.common.Uint16; @@ -151,7 +151,7 @@ public class SalFlowsBatchServiceImplTest { public void testRemoveFlowsBatch_failed() throws Exception { Mockito.when(salFlowService.removeFlow(ArgumentMatchers.any())) .thenReturn(RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "flow-remove-fail-1") + .withError(ErrorType.APPLICATION, "flow-remove-fail-1") .buildFuture()); final BatchRemoveFlows batchFlow1 = createEmptyBatchRemoveFlow(FLOW_ID_VALUE_1, 42); @@ -246,7 +246,7 @@ public class SalFlowsBatchServiceImplTest { public void testAddFlowsBatch_failed() throws Exception { Mockito.when(salFlowService.addFlow(ArgumentMatchers.any())) .thenReturn(RpcResultBuilder - .failed().withError(RpcError.ErrorType.APPLICATION, "ut-groupAddError") + .failed().withError(ErrorType.APPLICATION, "ut-groupAddError") .buildFuture()); final AddFlowsBatchInput input = new AddFlowsBatchInputBuilder() @@ -314,7 +314,7 @@ public class SalFlowsBatchServiceImplTest { public void testUpdateFlowsBatch_failure() throws Exception { Mockito.when(salFlowService.updateFlow(ArgumentMatchers.any())) .thenReturn(RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "ut-flowUpdateError") + .withError(ErrorType.APPLICATION, "ut-flowUpdateError") .buildFuture()); final UpdateFlowsBatchInput input = new UpdateFlowsBatchInputBuilder() diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalGroupsBatchServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalGroupsBatchServiceImplTest.java index 07787f78bb..a1bcdf19c9 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalGroupsBatchServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalGroupsBatchServiceImplTest.java @@ -62,7 +62,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.util.BindingMap; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.common.Uint32; @@ -139,7 +139,7 @@ public class SalGroupsBatchServiceImplTest { public void testUpdateGroupsBatch_failure() throws Exception { Mockito.when(salGroupService.updateGroup(Mockito.any())) .thenReturn(RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "ur-groupUpdateError") + .withError(ErrorType.APPLICATION, "ur-groupUpdateError") .buildFuture()); final UpdateGroupsBatchInput input = new UpdateGroupsBatchInputBuilder() @@ -207,7 +207,7 @@ public class SalGroupsBatchServiceImplTest { public void testAddGroupsBatch_failure() throws Exception { Mockito.when(salGroupService.addGroup(Mockito.any())) .thenReturn(RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "ut-groupAddError") + .withError(ErrorType.APPLICATION, "ut-groupAddError") .buildFuture()); final AddGroupsBatchInput input = new AddGroupsBatchInputBuilder() @@ -273,7 +273,7 @@ public class SalGroupsBatchServiceImplTest { public void testRemoveGroupsBatch_failure() throws Exception { Mockito.when(salGroupService.removeGroup(Mockito.any())) .thenReturn(RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "ut-groupRemoveError") + .withError(ErrorType.APPLICATION, "ut-groupRemoveError") .buildFuture()); final RemoveGroupsBatchInput input = new RemoveGroupsBatchInputBuilder() diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalMetersBatchServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalMetersBatchServiceImplTest.java index 216f381a39..1789fcc355 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalMetersBatchServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalMetersBatchServiceImplTest.java @@ -64,7 +64,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.up import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.update.meters.batch.input.BatchUpdateMetersBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.util.BindingMap; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.common.Uint32; @@ -140,7 +140,7 @@ public class SalMetersBatchServiceImplTest { public void testUpdateMetersBatch_failure() throws Exception { Mockito.when(salMeterService.updateMeter(Mockito.any())) .thenReturn(RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "ur-groupUpdateError") + .withError(ErrorType.APPLICATION, "ur-groupUpdateError") .buildFuture()); final UpdateMetersBatchInput input = new UpdateMetersBatchInputBuilder() @@ -208,7 +208,7 @@ public class SalMetersBatchServiceImplTest { public void testAddMetersBatch_failure() throws Exception { Mockito.when(salMeterService.addMeter(Mockito.any())) .thenReturn(RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "ut-groupAddError") + .withError(ErrorType.APPLICATION, "ut-groupAddError") .buildFuture()); final AddMetersBatchInput input = new AddMetersBatchInputBuilder() @@ -274,7 +274,7 @@ public class SalMetersBatchServiceImplTest { public void testRemoveMetersBatch_failure() throws Exception { Mockito.when(salMeterService.removeMeter(Mockito.any())) .thenReturn(RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "ut-groupRemoveError") + .withError(ErrorType.APPLICATION, "ut-groupRemoveError") .buildFuture()); final RemoveMetersBatchInput input = new RemoveMetersBatchInputBuilder() diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlatBatchUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlatBatchUtilTest.java index 299c8ef62b..96a73c6d4b 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlatBatchUtilTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlatBatchUtilTest.java @@ -62,7 +62,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev16032 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailureKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId; import org.opendaylight.yangtools.yang.binding.util.BindingMap; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.common.Uint16; @@ -380,14 +380,14 @@ public class FlatBatchUtilTest { = new ProcessFlatBatchOutputBuilder().setBatchFailure(BindingMap.of(batchFailure_1)).build(); final RpcResult rpcResultFailed = RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "ut-rpcError") + .withError(ErrorType.APPLICATION, "ut-rpcError") .withResult(output).build(); final RpcResult rpcResultFailed_1 = RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "ut-rpcError") + .withError(ErrorType.APPLICATION, "ut-rpcError") .withResult(output_1).build(); final RpcResult rpcResultSuccess = RpcResultBuilder.success() - .withResult(new ProcessFlatBatchOutputBuilder().setBatchFailure(Map.of())).build(); + .withResult(new ProcessFlatBatchOutputBuilder().setBatchFailure(Map.of()).build()).build(); final RpcResult rpcResult1 = FlatBatchUtil.mergeRpcResults().apply(Lists.newArrayList(rpcResultFailed, rpcResultSuccess)); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlowUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlowUtilTest.java index abc4aab24c..384d9664a4 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlowUtilTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlowUtilTest.java @@ -34,7 +34,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.util.BindingMap; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.common.Uint16; @@ -68,7 +68,7 @@ public class FlowUtilTest { final RpcResult> summary = function.apply(Lists.newArrayList( RpcResultBuilder.success("a").build(), RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "action-failed reason") + .withError(ErrorType.APPLICATION, "action-failed reason") .build())); Assert.assertFalse(summary.isSuccessful()); @@ -137,7 +137,7 @@ public class FlowUtilTest { private static RpcResult> createBatchOutcomeWithError() { return RpcResultBuilder.>failed() - .withError(RpcError.ErrorType.APPLICATION, "ut-flowAddFail") + .withError(ErrorType.APPLICATION, "ut-flowAddFail") .withResult(Collections.singletonList(new BatchFailedFlowsOutputBuilder() .setFlowId(DUMMY_FLOW_ID) .setBatchOrder(Uint16.ZERO) @@ -225,7 +225,7 @@ public class FlowUtilTest { private static RpcResult createBarrierFailureOutcome() { return RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "ut-barrier-error") + .withError(ErrorType.APPLICATION, "ut-barrier-error") .build(); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/GroupUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/GroupUtilTest.java index ec1d6d7dea..e242331c9f 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/GroupUtilTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/GroupUtilTest.java @@ -33,7 +33,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.util.BindingMap; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.common.Uint16; @@ -71,7 +71,7 @@ public class GroupUtilTest { final RpcResult> summary = function.apply(Lists.newArrayList( RpcResultBuilder.success("a").build(), RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "action-failed reason") + .withError(ErrorType.APPLICATION, "action-failed reason") .build())); Assert.assertFalse(summary.isSuccessful()); @@ -136,8 +136,8 @@ public class GroupUtilTest { private static RpcResult> createBatchOutcomeWithError() { return RpcResultBuilder.>failed() - .withError(RpcError.ErrorType.APPLICATION, "ut-flowAddFail") - .withResult(Collections.singletonList(new BatchFailedGroupsOutputBuilder() + .withError(ErrorType.APPLICATION, "ut-flowAddFail") + .withResult(List.of(new BatchFailedGroupsOutputBuilder() .setBatchOrder(Uint16.ZERO) .setGroupId(DUMMY_GROUP_ID) .build())) @@ -230,7 +230,7 @@ public class GroupUtilTest { private static RpcResult createBarrierFailureOutcome() { return RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "ut-barrier-error") + .withError(ErrorType.APPLICATION, "ut-barrier-error") .build(); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MeterUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MeterUtilTest.java index 8adbad1e0c..2008329b5f 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MeterUtilTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MeterUtilTest.java @@ -32,7 +32,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.ba import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.output.list.grouping.BatchFailedMetersOutputKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.util.BindingMap; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.common.Uint16; @@ -69,7 +69,7 @@ public class MeterUtilTest { final RpcResult> output = function.apply(Lists.newArrayList( RpcResultBuilder.success("a").build(), RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "ut-meter-error") + .withError(ErrorType.APPLICATION, "ut-meter-error") .build())); Assert.assertFalse(output.isSuccessful()); @@ -136,8 +136,8 @@ public class MeterUtilTest { private static RpcResult> createBatchOutcomeWithError() { return RpcResultBuilder.>failed() - .withError(RpcError.ErrorType.APPLICATION, "ut-flowAddFail") - .withResult(Collections.singletonList(new BatchFailedMetersOutputBuilder() + .withError(ErrorType.APPLICATION, "ut-flowAddFail") + .withResult(List.of(new BatchFailedMetersOutputBuilder() .setBatchOrder(Uint16.ZERO) .setMeterId(DUMMY_METER_ID) .build())) @@ -224,7 +224,7 @@ public class MeterUtilTest { private static RpcResult createBarrierFailureOutcome() { return RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "ut-barrier-error") + .withError(ErrorType.APPLICATION, "ut-barrier-error") .build(); } diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertor.java index 5ab27a60d4..397f86149c 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertor.java @@ -13,7 +13,6 @@ import com.google.common.collect.Ordering; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.Map; import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor; @@ -242,7 +241,7 @@ public class TableFeaturesConvertor extends Convertor< final org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features .TableProperties tableProperties) { if (tableProperties == null) { - return Collections.emptyList(); + return List.of(); } List ofTablePropertiesList = new ArrayList<>(); @@ -314,7 +313,7 @@ public class TableFeaturesConvertor extends Convertor< setSetFieldTableFeatureProperty( propBuilder, TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS, - setFieldMatch == null ? Collections.emptyMap() : setFieldMatch); + setFieldMatch == null ? Map.of() : setFieldMatch); } private static void setTableFeatureProperty(final ApplySetfield propType, @@ -330,7 +329,7 @@ public class TableFeaturesConvertor extends Convertor< setSetFieldTableFeatureProperty( propBuilder, TableFeaturesPropType.OFPTFPTAPPLYSETFIELD, - setFieldMatch == null ? Collections.emptyMap() : setFieldMatch); + setFieldMatch == null ? Map.of() : setFieldMatch); } private static void setTableFeatureProperty(final WriteSetfieldMiss propType, @@ -346,7 +345,7 @@ public class TableFeaturesConvertor extends Convertor< setSetFieldTableFeatureProperty( propBuilder, TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS, - setFieldMatch == null ? Collections.emptyMap() : setFieldMatch); + setFieldMatch == null ? Map.of() : setFieldMatch); } private static void setTableFeatureProperty(final WriteSetfield propType, @@ -362,7 +361,7 @@ public class TableFeaturesConvertor extends Convertor< setSetFieldTableFeatureProperty( propBuilder, TableFeaturesPropType.OFPTFPTWRITESETFIELD, - setFieldMatch == null ? Collections.emptyMap() : setFieldMatch); + setFieldMatch == null ? Map.of() : setFieldMatch); } private static void setTableFeatureProperty(final Wildcards propType, @@ -377,7 +376,7 @@ public class TableFeaturesConvertor extends Convertor< setSetFieldTableFeatureProperty( propBuilder, TableFeaturesPropType.OFPTFPTWILDCARDS, - setFieldMatch == null ? Collections.emptyMap() : setFieldMatch); + setFieldMatch == null ? Map.of() : setFieldMatch); } private static void setTableFeatureProperty(final Match propType, final TableFeaturePropertiesBuilder propBuilder) { @@ -391,7 +390,7 @@ public class TableFeaturesConvertor extends Convertor< setSetFieldTableFeatureProperty( propBuilder, TableFeaturesPropType.OFPTFPTMATCH, - setFieldMatch == null ? Collections.emptyMap() : setFieldMatch); + setFieldMatch == null ? Map.of() : setFieldMatch); } private static void setTableFeatureProperty(final ApplyActionsMiss propType, @@ -401,7 +400,7 @@ public class TableFeaturesConvertor extends Convertor< setActionTableFeatureProperty( propBuilder, TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS, - applyActionsMiss == null ? Collections.emptyMap() : applyActionsMiss.nonnullAction()); + applyActionsMiss == null ? Map.of() : applyActionsMiss.nonnullAction()); } private static void setTableFeatureProperty(final ApplyActions propType, @@ -411,7 +410,7 @@ public class TableFeaturesConvertor extends Convertor< setActionTableFeatureProperty( propBuilder, TableFeaturesPropType.OFPTFPTAPPLYACTIONS, - applyActions == null ? Collections.emptyMap() : applyActions.nonnullAction()); + applyActions == null ? Map.of() : applyActions.nonnullAction()); } private static void setTableFeatureProperty(final WriteActionsMiss propType, @@ -421,7 +420,7 @@ public class TableFeaturesConvertor extends Convertor< setActionTableFeatureProperty( propBuilder, TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS, - writeActionsMiss == null ? Collections.emptyMap() : writeActionsMiss.nonnullAction()); + writeActionsMiss == null ? Map.of() : writeActionsMiss.nonnullAction()); } private static void setTableFeatureProperty(final WriteActions propType, @@ -431,7 +430,7 @@ public class TableFeaturesConvertor extends Convertor< setActionTableFeatureProperty( propBuilder, TableFeaturesPropType.OFPTFPTWRITEACTIONS, - writeActions == null ? Collections.emptyMap() : writeActions.nonnullAction()); + writeActions == null ? Map.of() : writeActions.nonnullAction()); } private static void setTableFeatureProperty(final NextTableMiss propType, @@ -454,7 +453,7 @@ public class TableFeaturesConvertor extends Convertor< org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop .type.instructions.miss.InstructionsMiss instructions = propType.getInstructionsMiss(); setInstructionTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS, - instructions == null ? Collections.emptyMap() : instructions.nonnullInstruction()); + instructions == null ? Map.of() : instructions.nonnullInstruction()); } private static void setTableFeatureProperty(final Instructions propType, @@ -462,7 +461,7 @@ public class TableFeaturesConvertor extends Convertor< org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop .type.instructions.Instructions instructions = propType.getInstructions(); setInstructionTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTINSTRUCTIONS, - instructions == null ? Collections.emptyMap() : instructions.nonnullInstruction()); + instructions == null ? Map.of() : instructions.nonnullInstruction()); } private static void setInstructionTableFeatureProperty(final TableFeaturePropertiesBuilder builder, @@ -511,9 +510,7 @@ public class TableFeaturesConvertor extends Convertor< List nextTableIdsList = new ArrayList<>(); for (Uint8 tableId : tableIds) { - NextTableIdsBuilder nextTableId = new NextTableIdsBuilder(); - nextTableId.setTableId(tableId); - nextTableIdsList.add(nextTableId.build()); + nextTableIdsList.add(new NextTableIdsBuilder().setTableId(tableId).build()); } builder.setType(type).addAugmentation(new NextTableRelatedTableFeaturePropertyBuilder() diff --git a/parent/pom.xml b/parent/pom.xml index 1373fd329e..c244768ef9 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.mdsal binding-parent - 8.0.11 + 9.0.1 @@ -41,14 +41,14 @@ org.opendaylight.controller controller-artifacts - 4.0.10 + 5.0.1 pom import org.opendaylight.infrautils infrautils-artifacts - 2.0.13 + 3.0.0 pom import diff --git a/samples/pom.xml b/samples/pom.xml index c5dd140d04..bd6af31eae 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.odlparent odlparent-lite - 9.0.13 + 10.0.0 diff --git a/test-provider/pom.xml b/test-provider/pom.xml index 3007e4b6ab..4c0a73b2e2 100644 --- a/test-provider/pom.xml +++ b/test-provider/pom.xml @@ -56,7 +56,11 @@ org.osgi - osgi.cmpn + org.osgi.framework + + + org.osgi + org.osgi.service.component.annotations -- 2.36.6