X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=hwvtepsouthbound%2Fhwvtepsouthbound-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fovsdb%2Fhwvtepsouthbound%2Ftransact%2FHwvtepOperationalState.java;h=afe4c7a40df8836d165a7d272e8ee3f5e9519576;hb=refs%2Fchanges%2F44%2F101744%2F9;hp=1c320e53e59cecc133d097c2e4c7dc4f2b69fd22;hpb=abed5697526843141bd1e7885d21b54baa127a6e;p=ovsdb.git diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/HwvtepOperationalState.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/HwvtepOperationalState.java index 1c320e53e..afe4c7a40 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/HwvtepOperationalState.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/HwvtepOperationalState.java @@ -5,10 +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.ovsdb.hwvtepsouthbound.transact; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -27,7 +27,7 @@ import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepConnectionInstance; import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepDeviceInfo; import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundUtil; import org.opendaylight.ovsdb.lib.notation.UUID; -import org.opendaylight.ovsdb.utils.mdsal.utils.ControllerMdsalUtils; +import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.EncapsulationTypeBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation; @@ -90,19 +90,19 @@ public class HwvtepOperationalState { public HwvtepOperationalState(final DataBroker db, final HwvtepConnectionInstance connectionInstance, final Collection> changes) { this.connectionInstance = connectionInstance; - this.deviceInfo = connectionInstance.getDeviceInfo(); + deviceInfo = connectionInstance.getDeviceInfo(); this.db = db; this.changes = changes; - this.transaction = db.newReadWriteTransaction(); + transaction = db.newReadWriteTransaction(); } public HwvtepOperationalState(final HwvtepConnectionInstance connectionInstance) { this.connectionInstance = connectionInstance; - this.deviceInfo = connectionInstance.getDeviceInfo(); - this.db = connectionInstance.getDataBroker(); - this.changes = null; + deviceInfo = connectionInstance.getDeviceInfo(); + db = connectionInstance.getDataBroker(); + changes = null; transaction = connectionInstance.getDataBroker().newReadWriteTransaction(); - Optional readNode = new ControllerMdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, + Optional readNode = new MdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, connectionInstance.getInstanceIdentifier()); if (readNode.isPresent()) { operationalNodes.put(connectionInstance.getInstanceIdentifier(), readNode.get()); @@ -139,7 +139,7 @@ public class HwvtepOperationalState { if (nodeCreateOrUpdate != null) { transaction = db.newReadWriteTransaction(); for (Entry, Node> entry: nodeCreateOrUpdate.entrySet()) { - Optional readNode = new ControllerMdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, + Optional readNode = new MdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, entry.getKey()); //add related globalNode or physicalSwitchNode to operationalNodes map //for example, when creating physical port, logical switch is needed @@ -156,7 +156,7 @@ public class HwvtepOperationalState { InstanceIdentifier psNodeIid = (InstanceIdentifier) pswitch.getSwitchRef().getValue(); Optional psNode = - new ControllerMdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, psNodeIid); + new MdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, psNodeIid); if (psNode.isPresent()) { operationalNodes.put(psNodeIid, psNode.get()); } @@ -166,7 +166,7 @@ public class HwvtepOperationalState { @SuppressWarnings("unchecked") InstanceIdentifier hgNodeIid = (InstanceIdentifier) psAugmentation.getManagedBy().getValue(); - Optional hgNode = new ControllerMdsalUtils(db).readOptional( + Optional hgNode = new MdsalUtils(db).readOptional( LogicalDatastoreType.OPERATIONAL, hgNodeIid); if (hgNode.isPresent()) { operationalNodes.put(hgNodeIid, hgNode.get()); @@ -183,8 +183,7 @@ public class HwvtepOperationalState { } public Optional getHwvtepGlobalAugmentation(final InstanceIdentifier iid) { - Preconditions.checkNotNull(iid); - Optional nodeOptional = getGlobalNode(iid); + Optional nodeOptional = getGlobalNode(requireNonNull(iid)); if (nodeOptional.isPresent()) { return Optional.ofNullable(nodeOptional.get().augmentation(HwvtepGlobalAugmentation.class)); } @@ -192,8 +191,7 @@ public class HwvtepOperationalState { } public Optional getPhysicalSwitchAugmentation(final InstanceIdentifier iid) { - Preconditions.checkNotNull(iid); - Optional nodeOptional = getGlobalNode(iid); + Optional nodeOptional = getGlobalNode(requireNonNull(iid)); if (nodeOptional.isPresent()) { return Optional.ofNullable(nodeOptional.get().augmentation(PhysicalSwitchAugmentation.class)); } @@ -202,8 +200,7 @@ public class HwvtepOperationalState { public Optional> getTerminationPointList( final InstanceIdentifier iid) { - Preconditions.checkNotNull(iid); - Optional nodeOptional = getGlobalNode(iid); + Optional nodeOptional = getGlobalNode(requireNonNull(iid)); if (nodeOptional.isPresent() && nodeOptional.get().getTerminationPoint() != null) { return Optional.ofNullable(nodeOptional.get().getTerminationPoint()); } @@ -212,8 +209,7 @@ public class HwvtepOperationalState { public Optional getLogicalSwitches(final InstanceIdentifier iid, final LogicalSwitchesKey logicalSwitchesKey) { - Preconditions.checkNotNull(iid); - Optional nodeOptional = getHwvtepGlobalAugmentation(iid); + Optional nodeOptional = getHwvtepGlobalAugmentation(requireNonNull(iid)); if (nodeOptional.isPresent()) { LogicalSwitches lswitch = nodeOptional.get().nonnullLogicalSwitches().get(logicalSwitchesKey); if (lswitch != null) { @@ -224,12 +220,11 @@ public class HwvtepOperationalState { } public Optional getLogicalSwitches(final InstanceIdentifier iid) { - return new ControllerMdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, iid); + return new MdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, iid); } public Optional getTunnels(final InstanceIdentifier iid, final TunnelsKey tunnelsKey) { - Preconditions.checkNotNull(iid); - Optional psOptional = getPhysicalSwitchAugmentation(iid); + Optional psOptional = getPhysicalSwitchAugmentation(requireNonNull(iid)); if (psOptional.isPresent()) { Tunnels tunnel = psOptional.get().nonnullTunnels().get(tunnelsKey); if (tunnel != null) { @@ -240,14 +235,14 @@ public class HwvtepOperationalState { } public Optional getTunnels(final InstanceIdentifier iid) { - Optional tunnels = new ControllerMdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, iid); + Optional tunnels = new MdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, iid); return tunnels; } public Optional getPhysicalPortAugmentation(final InstanceIdentifier iid, final HwvtepNodeName hwvtepNodeName) { - Preconditions.checkNotNull(iid); - Optional> nodeOptional = getTerminationPointList(iid); + Optional> nodeOptional = + getTerminationPointList(requireNonNull(iid)); if (nodeOptional.isPresent()) { for (TerminationPoint tp : nodeOptional.get().values()) { HwvtepPhysicalPortAugmentation hppAugmentation = @@ -261,9 +256,9 @@ public class HwvtepOperationalState { } public Optional getPhysicalLocatorAugmentation(final InstanceIdentifier iid, - final IpAddress dstIp, final Class encapType) { - Preconditions.checkNotNull(iid); - Optional> nodeOptional = getTerminationPointList(iid); + final IpAddress dstIp, final EncapsulationTypeBase encapType) { + Optional> nodeOptional = + getTerminationPointList(requireNonNull(iid)); if (nodeOptional.isPresent()) { for (TerminationPoint tp : nodeOptional.get().values()) { HwvtepPhysicalLocatorAugmentation hppAugmentation = @@ -280,7 +275,7 @@ public class HwvtepOperationalState { public Optional getPhysicalLocatorAugmentation(final InstanceIdentifier iid) { Optional tp = - new ControllerMdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, iid); + new MdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, iid); if (tp.isPresent()) { return Optional.ofNullable(tp.get().augmentation(HwvtepPhysicalLocatorAugmentation.class)); } @@ -288,8 +283,7 @@ public class HwvtepOperationalState { } public Optional getLocalMcastMacs(final InstanceIdentifier iid, final LocalMcastMacsKey key) { - Preconditions.checkNotNull(iid); - Optional nodeOptional = getHwvtepGlobalAugmentation(iid); + Optional nodeOptional = getHwvtepGlobalAugmentation(requireNonNull(iid)); if (nodeOptional.isPresent()) { LocalMcastMacs mac = nodeOptional.get().nonnullLocalMcastMacs().get(key); if (mac != null) { @@ -300,8 +294,7 @@ public class HwvtepOperationalState { } public Optional getRemoteMcastMacs(final InstanceIdentifier iid, final RemoteMcastMacsKey key) { - Preconditions.checkNotNull(iid); - Optional nodeOptional = getHwvtepGlobalAugmentation(iid); + Optional nodeOptional = getHwvtepGlobalAugmentation(requireNonNull(iid)); if (nodeOptional.isPresent()) { RemoteMcastMacs mac = nodeOptional.get().nonnullRemoteMcastMacs().get(key); if (mac != null) { @@ -312,8 +305,7 @@ public class HwvtepOperationalState { } public Optional getLocalUcastMacs(final InstanceIdentifier iid, final LocalUcastMacsKey key) { - Preconditions.checkNotNull(iid); - Optional nodeOptional = getHwvtepGlobalAugmentation(iid); + Optional nodeOptional = getHwvtepGlobalAugmentation(requireNonNull(iid)); if (nodeOptional.isPresent()) { LocalUcastMacs mac = nodeOptional.get().nonnullLocalUcastMacs().get(key); if (mac != null) { @@ -324,8 +316,7 @@ public class HwvtepOperationalState { } public Optional getRemoteUcastMacs(final InstanceIdentifier iid, final RemoteUcastMacsKey key) { - Preconditions.checkNotNull(iid); - Optional nodeOptional = getHwvtepGlobalAugmentation(iid); + Optional nodeOptional = getHwvtepGlobalAugmentation(requireNonNull(iid)); if (nodeOptional.isPresent()) { RemoteUcastMacs mac = nodeOptional.get().nonnullRemoteUcastMacs().get(key); if (mac != null) { @@ -337,8 +328,7 @@ public class HwvtepOperationalState { public Optional getLogicalRouters(final InstanceIdentifier iid, final LogicalRoutersKey logicalRoutersKey) { - Preconditions.checkNotNull(iid); - Optional nodeOptional = getHwvtepGlobalAugmentation(iid); + Optional nodeOptional = getHwvtepGlobalAugmentation(requireNonNull(iid)); if (nodeOptional.isPresent()) { LogicalRouters lrouter = nodeOptional.get().nonnullLogicalRouters().get(logicalRoutersKey); if (lrouter != null) { @@ -349,7 +339,7 @@ public class HwvtepOperationalState { } public Optional getAcls(final InstanceIdentifier iid) { - Optional acl = new ControllerMdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, iid); + Optional acl = new MdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, iid); return acl; } @@ -395,7 +385,7 @@ public class HwvtepOperationalState { if (currentTxDeletedKeys.containsKey(cls)) { return currentTxDeletedKeys.get(cls).keySet(); } - return Collections.EMPTY_SET; + return Collections.emptySet(); } public List getUpdatedData(final InstanceIdentifier key, @@ -405,7 +395,7 @@ public class HwvtepOperationalState { result = modifiedData.get(key).getLeft().get(cls); } if (result == null) { - result = Collections.EMPTY_LIST; + result = Collections.emptyList(); } return result; } @@ -417,7 +407,7 @@ public class HwvtepOperationalState { result = modifiedData.get(key).getRight().get(cls); } if (result == null) { - result = Collections.EMPTY_LIST; + result = Collections.emptyList(); } return result; }