use of org.onosproject.incubator.net.resource.label.LabelResourceRequest in project onos by opennetworkinglab.
the class DistributedLabelResourceStore method releaseToDevicePool.
@Override
public boolean releaseToDevicePool(Multimap<DeviceId, LabelResource> release) {
Map<DeviceId, Collection<LabelResource>> maps = release.asMap();
Set<DeviceId> deviceIdSet = maps.keySet();
LabelResourceRequest request = null;
for (Iterator<DeviceId> it = deviceIdSet.iterator(); it.hasNext(); ) {
DeviceId deviceId = it.next();
Device device = deviceService.getDevice(deviceId);
if (device == null) {
continue;
}
ImmutableSet<LabelResource> collection = ImmutableSet.copyOf(maps.get(deviceId));
request = new LabelResourceRequest(deviceId, LabelResourceRequest.Type.RELEASE, 0, collection);
NodeId master = mastershipService.getMasterFor(deviceId);
if (master == null) {
log.warn("Failed to releaseToDevicePool: No master for {}", deviceId);
return false;
}
if (master.equals(clusterService.getLocalNode().id())) {
return internalRelease(request);
}
log.trace("Forwarding request to {}, which is the primary (master) for device {}", master, deviceId);
return complete(clusterCommunicator.sendAndReceive(request, LabelResourceMessageSubjects.LABEL_POOL_RELEASE, SERIALIZER::encode, SERIALIZER::decode, master));
}
return false;
}
use of org.onosproject.incubator.net.resource.label.LabelResourceRequest in project onos by opennetworkinglab.
the class DistributedLabelResourceStore method applyFromDevicePool.
@Override
public Collection<LabelResource> applyFromDevicePool(DeviceId deviceId, long applyNum) {
Device device = deviceService.getDevice(deviceId);
if (device == null) {
return Collections.emptyList();
}
LabelResourceRequest request = new LabelResourceRequest(deviceId, LabelResourceRequest.Type.APPLY, applyNum, null);
NodeId master = mastershipService.getMasterFor(deviceId);
if (master == null) {
log.warn("Failed to applyFromDevicePool: No master for {}", deviceId);
return Collections.emptyList();
}
if (master.equals(clusterService.getLocalNode().id())) {
return internalApply(request);
}
log.trace("Forwarding request to {}, which is the primary (master) for device {}", master, deviceId);
return complete(clusterCommunicator.sendAndReceive(request, LabelResourceMessageSubjects.LABEL_POOL_APPLY, SERIALIZER::encode, SERIALIZER::decode, master));
}
use of org.onosproject.incubator.net.resource.label.LabelResourceRequest in project onos by opennetworkinglab.
the class DistributedLabelResourceStore method releaseToGlobalPool.
@Override
public boolean releaseToGlobalPool(Set<LabelResourceId> release) {
Set<LabelResource> set = new HashSet<>();
DefaultLabelResource resource = null;
for (LabelResourceId labelResource : release) {
resource = new DefaultLabelResource(DeviceId.deviceId(GLOBAL_RESOURCE_POOL_DEVICE_ID), labelResource);
set.add(resource);
}
LabelResourceRequest request = new LabelResourceRequest(DeviceId.deviceId(GLOBAL_RESOURCE_POOL_DEVICE_ID), LabelResourceRequest.Type.RELEASE, 0, ImmutableSet.copyOf(set));
return this.internalRelease(request);
}
Aggregations