Satish K
Committed by Gerrit Code Review

Function issue fix in Distributed Label Resource Store

Change-Id: I28dd57f1a709640bb274d1a49db75c3a33f1d292
...@@ -212,8 +212,7 @@ public class DistributedLabelResourceStore ...@@ -212,8 +212,7 @@ public class DistributedLabelResourceStore
212 @Override 212 @Override
213 public boolean createGlobalPool(LabelResourceId beginLabel, 213 public boolean createGlobalPool(LabelResourceId beginLabel,
214 LabelResourceId endLabel) { 214 LabelResourceId endLabel) {
215 - LabelResourcePool pool = new LabelResourcePool( 215 + LabelResourcePool pool = new LabelResourcePool(GLOBAL_RESOURCE_POOL_DEVICE_ID,
216 - GLOBAL_RESOURCE_POOL_DEVICE_ID,
217 beginLabel.labelId(), 216 beginLabel.labelId(),
218 endLabel.labelId()); 217 endLabel.labelId());
219 return this.internalCreate(pool); 218 return this.internalCreate(pool);
...@@ -251,8 +250,7 @@ public class DistributedLabelResourceStore ...@@ -251,8 +250,7 @@ public class DistributedLabelResourceStore
251 .get(pool.deviceId()); 250 .get(pool.deviceId());
252 if (poolOld == null) { 251 if (poolOld == null) {
253 resourcePool.put(pool.deviceId(), pool); 252 resourcePool.put(pool.deviceId(), pool);
254 - LabelResourceEvent event = new LabelResourceEvent( 253 + LabelResourceEvent event = new LabelResourceEvent(Type.POOL_CREATED,
255 - Type.POOL_CREATED,
256 pool); 254 pool);
257 notifyDelegate(event); 255 notifyDelegate(event);
258 return true; 256 return true;
...@@ -292,8 +290,7 @@ public class DistributedLabelResourceStore ...@@ -292,8 +290,7 @@ public class DistributedLabelResourceStore
292 Versioned<LabelResourcePool> poolOld = resourcePool.get(deviceId); 290 Versioned<LabelResourcePool> poolOld = resourcePool.get(deviceId);
293 if (poolOld != null) { 291 if (poolOld != null) {
294 resourcePool.remove(deviceId); 292 resourcePool.remove(deviceId);
295 - LabelResourceEvent event = new LabelResourceEvent( 293 + LabelResourceEvent event = new LabelResourceEvent(Type.POOL_DESTROYED,
296 - Type.POOL_CREATED,
297 poolOld.value()); 294 poolOld.value());
298 notifyDelegate(event); 295 notifyDelegate(event);
299 } 296 }
...@@ -309,8 +306,7 @@ public class DistributedLabelResourceStore ...@@ -309,8 +306,7 @@ public class DistributedLabelResourceStore
309 if (device == null) { 306 if (device == null) {
310 return Collections.emptyList(); 307 return Collections.emptyList();
311 } 308 }
312 - LabelResourceRequest request = new LabelResourceRequest( 309 + LabelResourceRequest request = new LabelResourceRequest(deviceId,
313 - deviceId,
314 LabelResourceRequest.Type.APPLY, 310 LabelResourceRequest.Type.APPLY,
315 applyNum, null); 311 applyNum, null);
316 NodeId master = mastershipService.getMasterFor(deviceId); 312 NodeId master = mastershipService.getMasterFor(deviceId);
...@@ -345,8 +341,7 @@ public class DistributedLabelResourceStore ...@@ -345,8 +341,7 @@ public class DistributedLabelResourceStore
345 log.info("the free number of the label resource pool of deviceId {} is not enough."); 341 log.info("the free number of the label resource pool of deviceId {} is not enough.");
346 return Collections.emptyList(); 342 return Collections.emptyList();
347 } 343 }
348 - Set<LabelResource> releaseLabels = new HashSet<LabelResource>( 344 + Set<LabelResource> releaseLabels = new HashSet<LabelResource>(pool.releaseLabelId());
349 - pool.releaseLabelId());
350 long tmp = releaseLabels.size() > applyNum ? applyNum : releaseLabels 345 long tmp = releaseLabels.size() > applyNum ? applyNum : releaseLabels
351 .size(); 346 .size();
352 LabelResource resource = null; 347 LabelResource resource = null;
...@@ -394,8 +389,7 @@ public class DistributedLabelResourceStore ...@@ -394,8 +389,7 @@ public class DistributedLabelResourceStore
394 } 389 }
395 ImmutableSet<LabelResource> collection = ImmutableSet.copyOf(maps 390 ImmutableSet<LabelResource> collection = ImmutableSet.copyOf(maps
396 .get(deviceId)); 391 .get(deviceId));
397 - request = new LabelResourceRequest( 392 + request = new LabelResourceRequest(deviceId,
398 - deviceId,
399 LabelResourceRequest.Type.RELEASE, 393 LabelResourceRequest.Type.RELEASE,
400 0, collection); 394 0, collection);
401 NodeId master = mastershipService.getMasterFor(deviceId); 395 NodeId master = mastershipService.getMasterFor(deviceId);
...@@ -430,8 +424,7 @@ public class DistributedLabelResourceStore ...@@ -430,8 +424,7 @@ public class DistributedLabelResourceStore
430 log.info("the label resource pool of device id {} does not exist"); 424 log.info("the label resource pool of device id {} does not exist");
431 return false; 425 return false;
432 } 426 }
433 - Set<LabelResource> storeSet = new HashSet<LabelResource>( 427 + Set<LabelResource> storeSet = new HashSet<LabelResource>(pool.releaseLabelId());
434 - pool.releaseLabelId());
435 LabelResource labelResource = null; 428 LabelResource labelResource = null;
436 long realReleasedNum = 0; 429 long realReleasedNum = 0;
437 for (Iterator<LabelResource> it = release.iterator(); it.hasNext();) { 430 for (Iterator<LabelResource> it = release.iterator(); it.hasNext();) {
...@@ -499,8 +492,7 @@ public class DistributedLabelResourceStore ...@@ -499,8 +492,7 @@ public class DistributedLabelResourceStore
499 492
500 @Override 493 @Override
501 public Collection<LabelResource> applyFromGlobalPool(long applyNum) { 494 public Collection<LabelResource> applyFromGlobalPool(long applyNum) {
502 - LabelResourceRequest request = new LabelResourceRequest( 495 + LabelResourceRequest request = new LabelResourceRequest(DeviceId.deviceId(GLOBAL_RESOURCE_POOL_DEVICE_ID),
503 - DeviceId.deviceId(GLOBAL_RESOURCE_POOL_DEVICE_ID),
504 LabelResourceRequest.Type.APPLY, 496 LabelResourceRequest.Type.APPLY,
505 applyNum, null); 497 applyNum, null);
506 return this.internalApply(request); 498 return this.internalApply(request);
...@@ -511,17 +503,14 @@ public class DistributedLabelResourceStore ...@@ -511,17 +503,14 @@ public class DistributedLabelResourceStore
511 Set<LabelResource> set = new HashSet<LabelResource>(); 503 Set<LabelResource> set = new HashSet<LabelResource>();
512 DefaultLabelResource resource = null; 504 DefaultLabelResource resource = null;
513 for (LabelResourceId labelResource : release) { 505 for (LabelResourceId labelResource : release) {
514 - resource = new DefaultLabelResource( 506 + resource = new DefaultLabelResource(DeviceId.deviceId(GLOBAL_RESOURCE_POOL_DEVICE_ID),
515 - DeviceId.deviceId(GLOBAL_RESOURCE_POOL_DEVICE_ID),
516 labelResource); 507 labelResource);
517 set.add(resource); 508 set.add(resource);
518 } 509 }
519 - LabelResourceRequest request = new LabelResourceRequest( 510 + LabelResourceRequest request = new LabelResourceRequest(DeviceId.deviceId(GLOBAL_RESOURCE_POOL_DEVICE_ID),
520 - DeviceId.deviceId(GLOBAL_RESOURCE_POOL_DEVICE_ID),
521 LabelResourceRequest.Type.APPLY, 511 LabelResourceRequest.Type.APPLY,
522 0, 512 0,
523 - ImmutableSet 513 + ImmutableSet.copyOf(set));
524 - .copyOf(set));
525 return this.internalRelease(request); 514 return this.internalRelease(request);
526 } 515 }
527 516
......