Merge "Introducing Builders for FlowEntity & Co. beans"
[genius.git] / idmanager / idmanager-impl / src / main / java / org / opendaylight / genius / idmanager / IdUtils.java
index ae40728c4ae5060173def80be2d226ef1bbff372..2710e31b0544d1cac424beea387dfcd8b8505872 100644 (file)
@@ -52,9 +52,9 @@ class IdUtils {
         return idEntry;
     }
 
-    protected static IdEntries createIdEntries(String idKey, long newIdVal) {
+    protected static IdEntries createIdEntries(String idKey, List<Long> newIdVals) {
         return new IdEntriesBuilder().setKey(new IdEntriesKey(idKey))
-                .setIdKey(idKey).setIdValue(newIdVal).build();
+                .setIdKey(idKey).setIdValue(newIdVals).build();
     }
 
     protected static DelayedIdEntries createDelayedIdEntry(long idValue, long delayTime) {
@@ -148,8 +148,9 @@ class IdUtils {
     }
 
     protected static IdPool createLocalIdPool(String localPoolName, IdPool parentIdPool) {
+        IdPoolBuilder idPoolBuilder = new IdPoolBuilder();
         ReleasedIdsHolder releasedIdsHolder = createReleasedIdsHolder(DEFAULT_AVAILABLE_ID_COUNT, DEFAULT_DELAY_TIME);
-        return new IdPoolBuilder().setKey(new IdPoolKey(localPoolName))
+        return idPoolBuilder.setKey(new IdPoolKey(localPoolName))
                 .setPoolName(localPoolName)
                 .setParentPoolName(parentIdPool.getPoolName())
                 .setBlockSize(parentIdPool.getBlockSize())
@@ -259,7 +260,9 @@ class IdUtils {
          Future<RpcResult<Void>> result = lockManager.lock(input);
          try {
              if ((result != null) && (result.get().isSuccessful())) {
-                 LOGGER.debug("Acquired lock {}", poolName);
+                 if (LOGGER.isDebugEnabled()) {
+                     LOGGER.debug("Acquired lock {}", poolName);
+                 }
              } else {
                  throw new RuntimeException(String.format("Unable to getLock for pool %s", poolName));
              }
@@ -274,9 +277,13 @@ class IdUtils {
         Future<RpcResult<Void>> result = lockManager.unlock(input);
         try {
             if ((result != null) && (result.get().isSuccessful())) {
-                LOGGER.debug("Unlocked {}", poolName);
+                if (LOGGER.isDebugEnabled()) {
+                    LOGGER.debug("Unlocked {}", poolName);
+                }
             } else {
-                LOGGER.debug("Unable to unlock pool {}", poolName);
+                if (LOGGER.isDebugEnabled()) {
+                    LOGGER.debug("Unable to unlock pool {}", poolName);
+                }
             }
         } catch (InterruptedException | ExecutionException e) {
             LOGGER.error("Unable to unlock for pool {}", poolName);