use of org.onosproject.net.resource.DiscreteResource in project onos by opennetworkinglab.
the class EmptyDiscreteResourcesTest method testContainsAny.
@Test
public void testContainsAny() {
DiscreteResource res1 = Resources.discrete(DeviceId.deviceId("a")).resource();
DiscreteResource res2 = Resources.discrete(DeviceId.deviceId("b")).resource();
assertThat(sut.containsAny(ImmutableSet.of(res1)), is(false));
assertThat(sut.containsAny(ImmutableSet.of(res2)), is(false));
}
use of org.onosproject.net.resource.DiscreteResource in project onos by opennetworkinglab.
the class TransactionalDiscreteResourceSubStore method allocate.
@Override
public boolean allocate(ResourceConsumerId consumerId, DiscreteResource resource) {
// if the resource is not registered, then abort
Optional<DiscreteResource> lookedUp = lookup(resource.id());
if (!lookedUp.isPresent()) {
return false;
}
ResourceConsumerId oldValue = consumers.put(resource.id(), consumerId);
return oldValue == null;
}
Aggregations