* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-
import org.onap.ccsdk.sli.adaptors.lock.comp.LockHelper;
import org.onap.ccsdk.sli.adaptors.rm.dao.ResourceDao;
import org.onap.ccsdk.sli.adaptors.rm.data.AllocationOutcome;
private LockHelper lockHelper;
private ResourceDao resourceDao;
- private String applicationId;
private int lockTimeout = 10 * 60; // Default 10 min
public ResourceManagerImpl() {
@Override
public List<Resource> getResourceUnion(String resourceUnionId) {
List<Resource> rlist = resourceDao.getResourceUnion(resourceUnionId);
- for (Resource r : rlist)
+ for (Resource r : rlist) {
ResourceUtil.recalculate(r);
+ }
return rlist;
}
@Override
public AllocationOutcome allocateResources(AllocationRequest allocationRequest) {
- if (allocationRequest == null)
+ if (allocationRequest == null) {
throw new IllegalArgumentException("allocateResources called with null argument");
+ }
AllocationFunction allocationFunction =
- new AllocationFunction(lockHelper, resourceDao, applicationId, allocationRequest, lockTimeout);
+ new AllocationFunction(lockHelper, resourceDao, allocationRequest, lockTimeout);
allocationFunction.exec();
AllocationOutcome allocationOutcome = allocationFunction.getAllocationOutcome();
@Override
public void releaseResourceSet(String resourceSetId) {
List<Resource> resourceList = resourceDao.getResourceSet(resourceSetId);
- if (resourceList == null || resourceList.isEmpty())
+ if (resourceList == null || resourceList.isEmpty()) {
return;
+ }
Set<String> lockNames = getLockNames(resourceList);
ReleaseFunction releaseFunction =
@Override
public void releaseResourceUnion(String resourceUnionId) {
List<Resource> resourceList = resourceDao.getResourceUnion(resourceUnionId);
- if (resourceList == null || resourceList.isEmpty())
+ if (resourceList == null || resourceList.isEmpty()) {
return;
+ }
Set<String> lockNames = getLockNames(resourceList);
ReleaseFunction releaseFunction =
}
private Set<String> getLockNames(List<Resource> resourceList) {
- Set<String> lockNames = new HashSet<String>();
- for (Resource r : resourceList)
+ Set<String> lockNames = new HashSet<>();
+ for (Resource r : resourceList) {
lockNames.add(r.resourceKey.assetId);
+ }
return lockNames;
}
this.lockTimeout = lockTimeout;
}
- public void setApplicationId(String applicationId) {
- this.applicationId = applicationId;
- }
-
public void setLockHelper(LockHelper lockHelper) {
this.lockHelper = lockHelper;
}