mdsalutil-api clean up Checkstyle violations (not enforced yet) 31/51131/3
authorMichael Vorburger <vorburger@redhat.com>
Fri, 27 Jan 2017 07:51:13 +0000 (08:51 +0100)
committerDavid Suarez <david.suarez.fuentes@ericsson.com>
Wed, 1 Feb 2017 13:53:59 +0000 (13:53 +0000)
These are clean now:
 * src/main
    ** org.opendaylight.genius.mdsalutil.instructions
    ** org.opendaylight.genius.mdsalutil.interfaces
    ** org.opendaylight.genius.utils.batching
    ** org.opendaylight.genius.utils.clustering
    ** org.opendaylight.genius.utils.hwvtep
 * src/test

Change-Id: If81ba9be91d1e5d8bd8a9d775d53f7a21c3a71d5
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
15 files changed:
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/instructions/InstructionApplyActions.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/instructions/InstructionGotoTable.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/instructions/InstructionWriteMetadata.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/interfaces/IMdsalApiManager.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/utils/batching/ActionableResource.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/utils/batching/DefaultBatchHandler.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/utils/batching/ResourceBatchingManager.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/utils/batching/ResourceHandler.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/utils/batching/SubTransaction.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/utils/clustering/EntityOwnerUtils.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/utils/hwvtep/HwvtepHACache.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/utils/hwvtep/HwvtepSouthboundConstants.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/utils/hwvtep/HwvtepSouthboundUtils.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/utils/hwvtep/HwvtepUtils.java
mdsalutil/mdsalutil-api/src/test/java/org/opendaylight/genius/mdsalutil/hwvtep/HwvtepHACacheTest.java

index b7e09ee8785e79173d26a111b087c84a6a70fc84..f1b4cb83142654353231eb38803827d272668142 100644 (file)
@@ -8,8 +8,8 @@
 package org.opendaylight.genius.mdsalutil.instructions;
 
 import java.util.List;
-import org.opendaylight.genius.mdsalutil.ActionInfoList;
 import org.opendaylight.genius.mdsalutil.ActionInfo;
+import org.opendaylight.genius.mdsalutil.ActionInfoList;
 import org.opendaylight.genius.mdsalutil.InstructionInfo;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
index a4979df89c79ae482d84911458755a0354f8ea84..72874cc6d4d71a65caaa753c2cae483a1866cfc4 100644 (file)
@@ -39,17 +39,21 @@ public class InstructionGotoTable implements InstructionInfo {
     }
 
     @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
+    public boolean equals(Object other) {
+        if (this == other) {
+            return true;
+        }
+        if (other == null || getClass() != other.getClass()) {
+            return false;
+        }
 
-        InstructionGotoTable that = (InstructionGotoTable) o;
+        InstructionGotoTable that = (InstructionGotoTable) other;
 
         return tableId == that.tableId;
     }
 
     @Override
     public int hashCode() {
-        return (int) tableId;
+        return tableId;
     }
 }
index 167585491e9521f817e84f83fa81155691fbdaba..9bcba4b4115aa1253bfabd27010fc28d2777c26e 100644 (file)
@@ -43,13 +43,19 @@ public class InstructionWriteMetadata implements InstructionInfo {
     }
 
     @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
+    public boolean equals(Object other) {
+        if (this == other) {
+            return true;
+        }
+        if (other == null || getClass() != other.getClass()) {
+            return false;
+        }
 
-        InstructionWriteMetadata that = (InstructionWriteMetadata) o;
+        InstructionWriteMetadata that = (InstructionWriteMetadata) other;
 
-        if (metadata != null ? !metadata.equals(that.metadata) : that.metadata != null) return false;
+        if (metadata != null ? !metadata.equals(that.metadata) : that.metadata != null) {
+            return false;
+        }
         return mask != null ? mask.equals(that.mask) : that.mask == null;
     }
 
index c6801a8cb9de07db73e3ffdfa6e6604a07dd1882..8b34e67be56cdd8678f5043dc62752c94a281d6f 100644 (file)
@@ -22,6 +22,10 @@ public interface IMdsalApiManager {
 
     void installFlow(FlowEntity flowEntity);
 
+    CheckedFuture<Void,TransactionCommitFailedException> installFlow(BigInteger dpId, Flow flowEntity);
+
+    CheckedFuture<Void,TransactionCommitFailedException> installFlow(BigInteger dpId, FlowEntity flowEntity);
+
     /**
      * Add a Flow to batched transaction.
      * This is used to batch multiple ConfigDS changes in a single transaction.
@@ -33,8 +37,6 @@ public interface IMdsalApiManager {
      */
     void addFlowToTx(FlowEntity flowEntity, WriteTransaction tx);
 
-    CheckedFuture<Void,TransactionCommitFailedException> installFlow(BigInteger dpId, Flow flowEntity);
-
     /**
      * Add a Flow to batched transaction
      * This is used to batch multiple ConfigDS changes in a single transaction and programming on specific DPN.
@@ -48,6 +50,8 @@ public interface IMdsalApiManager {
      */
     void addFlowToTx(BigInteger dpId, Flow flow, WriteTransaction tx);
 
+    void removeFlow(FlowEntity flowEntity);
+
     CheckedFuture<Void,TransactionCommitFailedException> removeFlow(BigInteger dpId, Flow flowEntity);
 
     CheckedFuture<Void,TransactionCommitFailedException> removeFlow(BigInteger dpId, FlowEntity flowEntity);
@@ -65,10 +69,6 @@ public interface IMdsalApiManager {
      */
     void removeFlowToTx(BigInteger dpId, Flow flow, WriteTransaction tx);
 
-    CheckedFuture<Void,TransactionCommitFailedException> installFlow(BigInteger dpId, FlowEntity flowEntity);
-
-    void removeFlow(FlowEntity flowEntity);
-
     /**
      *  Remove a Flow using batched transaction.
      *  This is used to batch multiple ConfigDS changes in a single transaction
@@ -159,8 +159,6 @@ public interface IMdsalApiManager {
     /**
      * API to remove the Group on Data Plane Node synchronously. It internally waits for
      * Group Change Notification to confirm group delete request is being sent.
-     *
-     * @param groupEntity
      */
     void syncRemoveGroup(GroupEntity groupEntity);
 
index a111abd01a3fdf0d77491b5a6faa42f466860a54..1807401d429fa9a7654e3389fb77a933f44712fb 100644 (file)
@@ -10,18 +10,28 @@ package org.opendaylight.genius.utils.batching;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public interface ActionableResource {
+
     short CREATE = 1;
     short UPDATE = 2;
     short DELETE = 3;
 
     InstanceIdentifier getInstanceIdentifier();
+
     void setInstanceIdentifier(InstanceIdentifier identifier);
+
     Object getInstance();
+
     void setInstance(Object instance);
+
     Object getOldInstance();
+
     void setOldInstance(Object oldInstance);
+
     short getAction();
+
     void setAction(short action);
+
     String getKey();
+
     void setKey(String key);
 }
index 5145d8ed6c640c5d07e4a120456a23fb7bfe0a78..9b01f2ee6d4b5b99c25f9f13bdb3b3bc8e353fce 100644 (file)
@@ -18,22 +18,23 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public class DefaultBatchHandler implements ResourceHandler {
 
-    private DataBroker dataBroker;
-    private Integer batchSize;
-    private Integer batchInterval;
-    private LogicalDatastoreType datastoreType;
-
-    public DefaultBatchHandler(DataBroker  dataBroker,LogicalDatastoreType dataStoreType,Integer batchSize,Integer batchInterval) {
+    private final DataBroker dataBroker;
+    private final Integer batchSize;
+    private final Integer batchInterval;
+    private final LogicalDatastoreType datastoreType;
 
+    public DefaultBatchHandler(DataBroker dataBroker, LogicalDatastoreType dataStoreType, Integer batchSize,
+            Integer batchInterval) {
         this.dataBroker = dataBroker;
         this.batchSize = batchSize;
         this.batchInterval = batchInterval;
         this.datastoreType = dataStoreType;
-
     }
-    public void update(WriteTransaction tx, LogicalDatastoreType datastoreType,
-                       final InstanceIdentifier identifier, final Object original, final Object update, List<SubTransaction> transactionObjects) {
-        if ((update != null) && !(update instanceof DataObject)) {
+
+    @Override
+    public void update(WriteTransaction tx, LogicalDatastoreType datastoreType, final InstanceIdentifier identifier,
+            final Object original, final Object update, List<SubTransaction> transactionObjects) {
+        if (update != null && !(update instanceof DataObject)) {
             return;
         }
         if (datastoreType != getDatastoreType()) {
@@ -49,9 +50,10 @@ public class DefaultBatchHandler implements ResourceHandler {
         tx.merge(datastoreType, identifier, (DataObject) update, true);
     }
 
+    @Override
     public void create(WriteTransaction tx, final LogicalDatastoreType datastoreType,
-                       final InstanceIdentifier identifier, final Object data, List<SubTransaction> transactionObjects) {
-        if ((data != null) && !(data instanceof DataObject)) {
+            final InstanceIdentifier identifier, final Object data, List<SubTransaction> transactionObjects) {
+        if (data != null && !(data instanceof DataObject)) {
             return;
         }
         if (datastoreType != getDatastoreType()) {
@@ -67,9 +69,10 @@ public class DefaultBatchHandler implements ResourceHandler {
         tx.put(datastoreType, identifier, (DataObject) data, true);
     }
 
+    @Override
     public void delete(WriteTransaction tx, final LogicalDatastoreType datastoreType,
-                       final InstanceIdentifier identifier, final Object data, List<SubTransaction> transactionObjects) {
-        if ((data != null) && !(data instanceof DataObject)) {
+            final InstanceIdentifier identifier, final Object data, List<SubTransaction> transactionObjects) {
+        if (data != null && !(data instanceof DataObject)) {
             return;
         }
         if (datastoreType != getDatastoreType()) {
@@ -84,18 +87,22 @@ public class DefaultBatchHandler implements ResourceHandler {
         tx.delete(datastoreType, identifier);
     }
 
+    @Override
     public DataBroker getResourceBroker() {
         return dataBroker;
     }
 
+    @Override
     public int getBatchSize() {
         return batchSize;
     }
 
+    @Override
     public int getBatchInterval() {
         return batchInterval;
     }
 
+    @Override
     public LogicalDatastoreType getDatastoreType() {
         return datastoreType;
     }
index 0a910a180e124dd1b15addc99bdc51890eed42f3..682c915524668ce4138bd3b5ed53fb80d239a859 100644 (file)
@@ -64,7 +64,8 @@ public class ResourceBatchingManager implements AutoCloseable {
             throw new RuntimeException("Resource type already registered");
         }
         resourceHandlerMapper.put(resourceType, new ImmutablePair<>(resQueue, resHandler));
-        ScheduledThreadPoolExecutor resDelegatorService = (ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(1);
+        ScheduledThreadPoolExecutor resDelegatorService = (ScheduledThreadPoolExecutor)
+                Executors.newScheduledThreadPool(1);
         resourceBatchingThreadMapper.put(resourceType, resDelegatorService);
         LOG.info("Registered resourceType {} with batchSize {} and batchInterval {}", resourceType,
                 resHandler.getBatchSize(), resHandler.getBatchInterval());
@@ -175,6 +176,7 @@ public class ResourceBatchingManager implements AutoCloseable {
             this.actResourceList = actResourceList;
         }
 
+        @SuppressWarnings("checkstyle:IllegalCatch")
         public void process() {
             InstanceIdentifier<T> identifier;
             Object instance;
@@ -229,20 +231,22 @@ public class ResourceBatchingManager implements AutoCloseable {
                         WriteTransaction writeTransaction = broker.newWriteOnlyTransaction();
                         switch (object.getAction()) {
                             case SubTransaction.CREATE :
-                                writeTransaction.put(dsType, object.getInstanceIdentifier(), (DataObject)object.getInstance(), true);
+                                writeTransaction.put(dsType, object.getInstanceIdentifier(),
+                                    (DataObject) object.getInstance(), true);
                                 break;
                             case SubTransaction.DELETE :
                                 writeTransaction.delete(dsType, object.getInstanceIdentifier());
                                 break;
                             case SubTransaction.UPDATE :
-                                writeTransaction.merge(dsType, object.getInstanceIdentifier(), (DataObject)object.getInstance(), true);
+                                writeTransaction.merge(dsType, object.getInstanceIdentifier(),
+                                    (DataObject) object.getInstance(), true);
                                 break;
                             default:
-                                LOG.error("Unable to determine Action for transaction object with id {}", object.getInstanceIdentifier());
+                                LOG.error("Unable to determine Action for transaction object with id {}",
+                                    object.getInstanceIdentifier());
                         }
-                        CheckedFuture<Void, TransactionCommitFailedException> futureOperation = writeTransaction.submit();
                         try {
-                            futureOperation.get();
+                            writeTransaction.submit().get();
                         } catch (InterruptedException | ExecutionException exception) {
                             LOG.error("Error {} to datastore (path, data) : ({}, {})", object.getAction(),
                                     object.getInstanceIdentifier(), object.getInstance(), exception);
index a2a898cbf4c0e8017583f0e1bf22de5078d51fda..3fe49ba822a2628f033b3bcfd02480e94bf17336 100644 (file)
@@ -14,12 +14,21 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public interface ResourceHandler {
-    void create(WriteTransaction tx, LogicalDatastoreType datastoreType, InstanceIdentifier identifer, Object vrfEntry,List<SubTransaction> transactionObjects);
-    void delete(WriteTransaction tx, LogicalDatastoreType datastoreType, InstanceIdentifier identifer, Object vrfEntry,List<SubTransaction> transactionObjects);
+
+    void create(WriteTransaction tx, LogicalDatastoreType datastoreType, InstanceIdentifier identifer, Object vrfEntry,
+            List<SubTransaction> transactionObjects);
+
+    void delete(WriteTransaction tx, LogicalDatastoreType datastoreType, InstanceIdentifier identifer, Object vrfEntry,
+            List<SubTransaction> transactionObjects);
+
     void update(WriteTransaction tx, LogicalDatastoreType datastoreType, InstanceIdentifier identifier, Object original,
-                Object update,List<SubTransaction> transactionObjects);
+            Object update, List<SubTransaction> transactionObjects);
+
     LogicalDatastoreType getDatastoreType();
+
     int getBatchSize();
+
     int getBatchInterval();
+
     DataBroker getResourceBroker();
 }
index 7eb5a995423a9ca9207a1026c2103c1ec199b074..4044dced11d7b689f23c62890786421f1b654f31 100644 (file)
@@ -10,14 +10,20 @@ package org.opendaylight.genius.utils.batching;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public interface SubTransaction {
+
     short CREATE = 1;
     short UPDATE = 2;
     short DELETE = 3;
 
     InstanceIdentifier getInstanceIdentifier();
+
     void setInstanceIdentifier(InstanceIdentifier identifier);
+
     Object getInstance();
+
     void setInstance(Object instance);
+
     short getAction();
+
     void setAction(short action);
 }
index cf3dd1dd81cbbd3e6c6d9bdb72db0ea7c5f37311..0d67c804c5481a09bb78f1d34ad27071a1630ba3 100644 (file)
@@ -19,40 +19,50 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class EntityOwnerUtils {
-    public static final String ENTITY_OWNER_CACHE = "entity.owner.cache";
+
     private static final Logger LOG = LoggerFactory.getLogger(EntityOwnerUtils.class);
-    static final ArrayList<EntityEvent> eventsHistory = new ArrayList<>();
+
+    public  static final String ENTITY_OWNER_CACHE = "entity.owner.cache";
+    private static final ArrayList<EntityEvent> EVENTS_HISTORY = new ArrayList<>();
+
     public static class EntityEvent {
-        long time;
-        String entityName;
-        boolean isOwner;
-        boolean hasOwner;
+        private final long time;
+        private final String entityName;
+        private final boolean isOwner;
+        private final boolean hasOwner;
+
         public EntityEvent(long time, String entityName, boolean hasOwner, boolean isOwner) {
             this.time = time;
             this.entityName = entityName;
             this.hasOwner = hasOwner;
             this.isOwner = isOwner;
         }
+
         public long getTime() {
             return time;
         }
+
         public String getEntityName() {
             return entityName;
         }
+
         public boolean isOwner() {
             return isOwner;
         }
+
         public boolean hasOwner() {
             return hasOwner;
         }
     }
+
     public static ArrayList<EntityEvent> getEventsHistory() {
-        return eventsHistory;
+        return EVENTS_HISTORY;
     }
 
     static {
         createEntityOwnerCache();
     }
+
     private static void createEntityOwnerCache() {
         if (CacheUtil.getCache(ENTITY_OWNER_CACHE) == null) {
             CacheUtil.createCache(ENTITY_OWNER_CACHE);
@@ -68,7 +78,7 @@ public class EntityOwnerUtils {
                 (ConcurrentMap<String, Boolean>) CacheUtil.getCache(ENTITY_OWNER_CACHE);
         String entity = getEntity(entityType, entityName);
         if (entityOwnerCache != null) {
-            LOG.trace("updating entity owner "+isOwner+ " "+entity );
+            LOG.trace("updating entity owner " + isOwner + " " + entity);
             entityOwnerCache.put(entity, isOwner);
         }
     }
@@ -91,18 +101,15 @@ public class EntityOwnerUtils {
 
     /**
      * Registers the entityName for ownership for given entityType
-     * adds a local listener which takes care of updating the cached entity status
-     * @param entityOwnershipService
-     * @param entityType
-     * @param entityName
+     * adds a local listener which takes care of updating the cached entity status.
+     *
      * @param listener also adds this listener for ownership events if provided
-     * @throws CandidateAlreadyRegisteredException
      */
-    public static void registerEntityCandidateForOwnerShip  (
+    public static void registerEntityCandidateForOwnerShip(
             EntityOwnershipService entityOwnershipService,
             String entityType, String entityName, EntityOwnershipListener listener)
             throws CandidateAlreadyRegisteredException {
-        LOG.info("registering for entity ownership for type "+entityType);
+        LOG.info("registering for entity ownership for type {}", entityType);
         Entity candidateEntity = new Entity(entityType, entityName);
         entityOwnershipService.registerCandidate(
                 candidateEntity);
@@ -111,25 +118,26 @@ public class EntityOwnerUtils {
         if (listener != null) {
             entityOwnershipService.registerListener(entityType, listener);
         }
-        LOG.info("registered for entity ownership for type "+entityType);
+        LOG.info("registered for entity ownership for type {}", entityType);
         //TODO track registrations for closing
     }
 
     private static Listener entityOwnershipListener = new Listener();
+
     static class Listener implements EntityOwnershipListener {
 
         @Override
         public void ownershipChanged(EntityOwnershipChange ownershipChange) {
             String entityType = ownershipChange.getEntity().getType();
             String entityName = ownershipChange.getEntity().getId().toString();
-            LOG.info("entity ownership changed for "+entityType);
-            eventsHistory.add(new EntityEvent(System.currentTimeMillis(), entityName, ownershipChange.hasOwner() ,
+            LOG.info("entity ownership changed for {}", entityType);
+            EVENTS_HISTORY.add(new EntityEvent(System.currentTimeMillis(), entityName, ownershipChange.hasOwner() ,
                     ownershipChange.isOwner()));
             if (ownershipChange.hasOwner() && ownershipChange.isOwner()) {
-                LOG.info("entity ownership change became owner for type "+entityType);
+                LOG.info("entity ownership change became owner for type {}", entityType);
                 updateEntityOwner(entityType, entityName, Boolean.TRUE);
             } else {
-                LOG.info("entity ownership lost ownership for type "+entityType);
+                LOG.info("entity ownership lost ownership for type {} ", entityType);
                 updateEntityOwner(entityType, entityName, Boolean.FALSE);
             }
         }
index cdb9aabc63db60b299658f5509e076728713c632..a4fee7f2588ff16736155c5614f160e4fbdd37bf 100644 (file)
@@ -28,11 +28,17 @@ public class HwvtepHACache {
 
     private static HwvtepHACache instance = new HwvtepHACache();
 
-    private ConcurrentHashMap<InstanceIdentifier<Node>, Set<InstanceIdentifier<Node>>> parentToChildMap = new ConcurrentHashMap<>();
-    private ConcurrentHashMap<InstanceIdentifier<Node>, InstanceIdentifier<Node>> childToParentMap = new ConcurrentHashMap<>();
-    private ConcurrentHashMap<String, Boolean> childNodeIds = new ConcurrentHashMap<>();
-    private ConcurrentHashMap<String, Boolean> connectedNodes = new ConcurrentHashMap<>();
-    private LinkedBlockingQueue<DebugEvent> debugEvents = new LinkedBlockingQueue<>(MAX_EVENT_BUFFER_SIZE);
+    private final ConcurrentHashMap<InstanceIdentifier<Node>, Set<InstanceIdentifier<Node>>>
+        parentToChildMap = new ConcurrentHashMap<>();
+
+    private final ConcurrentHashMap<InstanceIdentifier<Node>, InstanceIdentifier<Node>>
+        childToParentMap = new ConcurrentHashMap<>();
+
+    private final ConcurrentHashMap<String, Boolean> childNodeIds = new ConcurrentHashMap<>();
+
+    private final ConcurrentHashMap<String, Boolean> connectedNodes = new ConcurrentHashMap<>();
+
+    private final LinkedBlockingQueue<DebugEvent> debugEvents = new LinkedBlockingQueue<>(MAX_EVENT_BUFFER_SIZE);
 
     public static HwvtepHACache getInstance() {
         return instance;
index b399a54eed1a918ea67e0e86f410d02566859501..08de4a637597dc0325804087f4b01ea457ede499 100644 (file)
@@ -17,8 +17,11 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
 public class HwvtepSouthboundConstants {
 
     public static final String HWVTEP_ENTITY_TYPE = "hwvtep";
-    public static final ImmutableBiMap<Class<? extends EncapsulationTypeBase>, String> ENCAPS_TYPE_MAP = new ImmutableBiMap.Builder<Class<? extends EncapsulationTypeBase>, String>()
+
+    public static final ImmutableBiMap<Class<? extends EncapsulationTypeBase>, String> ENCAPS_TYPE_MAP
+        = new ImmutableBiMap.Builder<Class<? extends EncapsulationTypeBase>, String>()
             .put(EncapsulationTypeVxlanOverIpv4.class, "vxlan_over_ipv4").build();
+
     public static final String ELAN_ENTITY_TYPE = "elan";
     public static final String ELAN_ENTITY_NAME = "elan";
     public static final String TEP_PREFIX = "vxlan_over_ipv4:";
index 2eeb5a7fb98153b7bd1297b8a05b70f880972d5a..2c16bdcb95d7fed0d55d8c36ae2ff75c027a6ffc 100644 (file)
@@ -96,7 +96,7 @@ public class HwvtepSouthboundUtils {
      * @return the instance identifier
      */
     public static InstanceIdentifier<LogicalSwitches> createLogicalSwitchesInstanceIdentifier(NodeId nodeId,
-                                                                                              HwvtepNodeName hwvtepNodeName) {
+            HwvtepNodeName hwvtepNodeName) {
         return createInstanceIdentifier(nodeId).augmentation(HwvtepGlobalAugmentation.class)
                 .child(LogicalSwitches.class, new LogicalSwitchesKey(hwvtepNodeName));
     }
@@ -149,7 +149,7 @@ public class HwvtepSouthboundUtils {
      * @return the instance identifier
      */
     public static InstanceIdentifier<RemoteMcastMacs> createRemoteMcastMacsInstanceIdentifier(NodeId nodeId,
-                                                                                              String logicalSwitchName, MacAddress mac) {
+            String logicalSwitchName, MacAddress mac) {
         InstanceIdentifier<LogicalSwitches> logicalSwitch = createLogicalSwitchesInstanceIdentifier(nodeId,
                 new HwvtepNodeName(logicalSwitchName));
         return createInstanceIdentifier(nodeId).augmentation(HwvtepGlobalAugmentation.class)
@@ -166,7 +166,7 @@ public class HwvtepSouthboundUtils {
      * @return the instance identifier
      */
     public static InstanceIdentifier<RemoteMcastMacs> createRemoteMcastMacsInstanceIdentifier(NodeId nodeId,
-                                                                                              RemoteMcastMacsKey remoteMcastMacsKey) {
+            RemoteMcastMacsKey remoteMcastMacsKey) {
         return createInstanceIdentifier(nodeId).augmentation(HwvtepGlobalAugmentation.class)
                 .child(RemoteMcastMacs.class, remoteMcastMacsKey);
     }
@@ -181,7 +181,7 @@ public class HwvtepSouthboundUtils {
      * @return the instance identifier
      */
     public static InstanceIdentifier<TerminationPoint> createPhysicalLocatorInstanceIdentifier(NodeId nodeId,
-                                                                                               HwvtepPhysicalLocatorAugmentation physicalLocatorAug) {
+            HwvtepPhysicalLocatorAugmentation physicalLocatorAug) {
         return createInstanceIdentifier(nodeId).child(TerminationPoint.class,
                 getTerminationPointKey(physicalLocatorAug));
     }
@@ -236,6 +236,15 @@ public class HwvtepSouthboundUtils {
         return tpKey;
     }
 
+    public static TerminationPointKey getTerminationPointKey(String ipAddress) {
+        TerminationPointKey tpKey = null;
+        String tpKeyStr = getTerminationPointKeyString(ipAddress);
+        if (tpKeyStr != null) {
+            tpKey = new TerminationPointKey(new TpId(tpKeyStr));
+        }
+        return tpKey;
+    }
+
     /**
      * Creates the managed node id.
      *
@@ -289,8 +298,8 @@ public class HwvtepSouthboundUtils {
         if (type.isEmpty()) {
             return EncapsulationTypeVxlanOverIpv4.class;
         } else {
-            ImmutableBiMap<String, Class<? extends EncapsulationTypeBase>> mapper = HwvtepSouthboundConstants.ENCAPS_TYPE_MAP
-                    .inverse();
+            ImmutableBiMap<String, Class<? extends EncapsulationTypeBase>> mapper
+                = HwvtepSouthboundConstants.ENCAPS_TYPE_MAP.inverse();
             return mapper.get(type);
         }
     }
@@ -311,7 +320,7 @@ public class HwvtepSouthboundUtils {
      * @return the remote ucast macs
      */
     public static RemoteUcastMacs createRemoteUcastMac(NodeId nodeId, String mac, IpAddress ipAddress,
-                                                       String logicalSwitchName, HwvtepPhysicalLocatorAugmentation physicalLocatorAug) {
+            String logicalSwitchName, HwvtepPhysicalLocatorAugmentation physicalLocatorAug) {
         HwvtepLogicalSwitchRef lsRef = new HwvtepLogicalSwitchRef(
                 createLogicalSwitchesInstanceIdentifier(nodeId, new HwvtepNodeName(logicalSwitchName)));
         HwvtepPhysicalLocatorRef phyLocRef = new HwvtepPhysicalLocatorRef(
@@ -338,7 +347,7 @@ public class HwvtepSouthboundUtils {
      * @return the remote mcast macs
      */
     public static RemoteMcastMacs createRemoteMcastMac(NodeId nodeId, String mac, IpAddress ipAddress,
-                                                       String logicalSwitchName, List<HwvtepPhysicalLocatorAugmentation> lstPhysicalLocatorAug) {
+            String logicalSwitchName, List<HwvtepPhysicalLocatorAugmentation> lstPhysicalLocatorAug) {
         HwvtepLogicalSwitchRef lsRef = new HwvtepLogicalSwitchRef(
                 createLogicalSwitchesInstanceIdentifier(nodeId, new HwvtepNodeName(logicalSwitchName)));
 
@@ -378,15 +387,6 @@ public class HwvtepSouthboundUtils {
         return vbBuilder.build();
     }
 
-    public static TerminationPointKey getTerminationPointKey(String ipAddress) {
-        TerminationPointKey tpKey = null;
-        String tpKeyStr = getTerminationPointKeyString(ipAddress);
-        if (tpKeyStr != null) {
-            tpKey = new TerminationPointKey(new TpId(tpKeyStr));
-        }
-        return tpKey;
-    }
-
     public static String getTerminationPointKeyString(String ipAddress) {
         String tpKeyStr = null;
         if (ipAddress != null) {
index cd12c2e8c3cc5f523ae5163540a89d9a803c56ab..07287abace8449a4f130840317fbb79bdd76ff5d 100644 (file)
@@ -76,6 +76,7 @@ public final class HwvtepUtils {
         putLogicalSwitch(transaction,logicalDatastoreType, nodeId, logicalSwitch);
         return transaction.submit();
     }
+
     /**
      * Put the logical switches in the transaction.
      *
@@ -163,7 +164,7 @@ public final class HwvtepUtils {
     }
 
     /**
-     * Gets physical port termination point
+     * Gets physical port termination point.
      *
      * @param broker
      *          the broker
@@ -255,7 +256,7 @@ public final class HwvtepUtils {
      * @return the physical locator
      */
     public static HwvtepPhysicalLocatorAugmentation getPhysicalLocator(DataBroker broker,
-                                                                       LogicalDatastoreType datastoreType, NodeId nodeId, final IpAddress phyLocatorIp) {
+            LogicalDatastoreType datastoreType, NodeId nodeId, final IpAddress phyLocatorIp) {
         HwvtepPhysicalLocatorAugmentation phyLocatorAug = HwvtepSouthboundUtils
                 .createHwvtepPhysicalLocatorAugmentation(String.valueOf(phyLocatorIp.getValue()));
         InstanceIdentifier<HwvtepPhysicalLocatorAugmentation> iid = HwvtepSouthboundUtils
@@ -337,6 +338,22 @@ public final class HwvtepUtils {
         return transaction.submit();
     }
 
+    /**
+     * Delete remote ucast mac from the transaction.
+     *
+     * @param transaction
+     *            the transaction
+     * @param nodeId
+     *            the node id
+     * @param mac
+     *            the mac
+     */
+    public static void deleteRemoteUcastMac(final WriteTransaction transaction, final NodeId nodeId,
+                                            String logialSwitchName, final MacAddress mac) {
+        transaction.delete(LogicalDatastoreType.CONFIGURATION,
+                HwvtepSouthboundUtils.createRemoteUcastMacsInstanceIdentifier(nodeId, logialSwitchName, mac));
+    }
+
     /**
      * Delete remote ucast macs from the config DS.
      *
@@ -374,22 +391,6 @@ public final class HwvtepUtils {
         }
     }
 
-    /**
-     * Delete remote ucast mac from the transaction.
-     *
-     * @param transaction
-     *            the transaction
-     * @param nodeId
-     *            the node id
-     * @param mac
-     *            the mac
-     */
-    public static void deleteRemoteUcastMac(final WriteTransaction transaction, final NodeId nodeId,
-                                            String logialSwitchName, final MacAddress mac) {
-        transaction.delete(LogicalDatastoreType.CONFIGURATION,
-                HwvtepSouthboundUtils.createRemoteUcastMacsInstanceIdentifier(nodeId, logialSwitchName, mac));
-    }
-
     /**
      * Adds the remote mcast macs into config DS.
      *
@@ -451,6 +452,7 @@ public final class HwvtepUtils {
                 remoteMcastMac.getKey());
         transaction.put(logicalDatastoreType, iid, remoteMcastMac, true);
     }
+
     /**
      * Gets the remote mcast mac.
      *
@@ -489,6 +491,22 @@ public final class HwvtepUtils {
         return transaction.submit();
     }
 
+    /**
+     * Delete remote mcast mac from the transaction.
+     *
+     * @param transaction
+     *            the transaction
+     * @param nodeId
+     *            the node id
+     * @param remoteMcastMacsKey
+     *            the remote mcast macs key
+     */
+    public static void deleteRemoteMcastMac(final WriteTransaction transaction, final NodeId nodeId,
+                                            final RemoteMcastMacsKey remoteMcastMacsKey) {
+        transaction.delete(LogicalDatastoreType.CONFIGURATION,
+                HwvtepSouthboundUtils.createRemoteMcastMacsInstanceIdentifier(nodeId, remoteMcastMacsKey));
+    }
+
     /**
      * Delete remote mcast macs from config DS.
      *
@@ -526,22 +544,6 @@ public final class HwvtepUtils {
         }
     }
 
-    /**
-     * Delete remote mcast mac from the transaction.
-     *
-     * @param transaction
-     *            the transaction
-     * @param nodeId
-     *            the node id
-     * @param remoteMcastMacsKey
-     *            the remote mcast macs key
-     */
-    public static void deleteRemoteMcastMac(final WriteTransaction transaction, final NodeId nodeId,
-                                            final RemoteMcastMacsKey remoteMcastMacsKey) {
-        transaction.delete(LogicalDatastoreType.CONFIGURATION,
-                HwvtepSouthboundUtils.createRemoteMcastMacsInstanceIdentifier(nodeId, remoteMcastMacsKey));
-    }
-
     /**
      * Merge vlan bindings in the transaction.
      *
@@ -557,7 +559,7 @@ public final class HwvtepUtils {
      *            the vlan bindings
      */
     public static void mergeVlanBindings(final WriteTransaction transaction, final NodeId nodeId,
-                                         final String phySwitchName, final String phyPortName, final List<VlanBindings> vlanBindings) {
+            final String phySwitchName, final String phyPortName, final List<VlanBindings> vlanBindings) {
         NodeId physicalSwitchNodeId = HwvtepSouthboundUtils.createManagedNodeId(nodeId, phySwitchName);
         mergeVlanBindings(transaction, physicalSwitchNodeId, phyPortName, vlanBindings);
     }
index 76f241882c7d0952a7e4f876ca2bd8a4f55e9152..11b0b267ff4c1cb61c6db5c3b729729f0d6d45b9 100644 (file)
@@ -31,18 +31,15 @@ public class HwvtepHACacheTest {
 
     @Test
     public void testAddHAChild() {
-
         InstanceIdentifier<Node> parent = newNodeInstanceIdentifier("ha");
         InstanceIdentifier<Node> child1 = newNodeInstanceIdentifier("d1");
-        InstanceIdentifier<Node> child2 = newNodeInstanceIdentifier("d1");
-        String child1NodeId = child1.firstKeyOf(Node.class).getNodeId().getValue();
-        String child2NodeId = child2.firstKeyOf(Node.class).getNodeId().getValue();
 
         hwvtepHACache.addChild(parent, child1);
 
         assertTrue(hwvtepHACache.isHAEnabledDevice(child1));
         assertTrue(hwvtepHACache.isHAParentNode(parent));
 
+        InstanceIdentifier<Node> child2 = newNodeInstanceIdentifier("d1");
         hwvtepHACache.addChild(parent, child2);
         assertTrue(hwvtepHACache.isHAEnabledDevice(child1));
         assertTrue(hwvtepHACache.isHAEnabledDevice(child2));
@@ -55,6 +52,9 @@ public class HwvtepHACacheTest {
         assertTrue(hwvtepHACache.getChildrenForHANode(parent).contains(child1));
         assertTrue(hwvtepHACache.getChildrenForHANode(parent).contains(child2));
 
+        String child1NodeId = child1.firstKeyOf(Node.class).getNodeId().getValue();
+        String child2NodeId = child2.firstKeyOf(Node.class).getNodeId().getValue();
+
         List<DebugEvent> events = hwvtepHACache.getNodeEvents();
         assertTrue(events.contains(new NodeEvent.ChildAddedEvent(child1NodeId)));
         assertTrue(events.contains(new NodeEvent.ChildAddedEvent(child2NodeId)));