Search in sources :

Example 46 with DiscreteResource

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));
}
Also used : DiscreteResource(org.onosproject.net.resource.DiscreteResource) Test(org.junit.Test)

Example 47 with DiscreteResource

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;
}
Also used : DiscreteResource(org.onosproject.net.resource.DiscreteResource) ResourceConsumerId(org.onosproject.net.resource.ResourceConsumerId)

Aggregations

DiscreteResource (org.onosproject.net.resource.DiscreteResource)47 Test (org.junit.Test)38 Resource (org.onosproject.net.resource.Resource)6 ImmutableSet (com.google.common.collect.ImmutableSet)4 Set (java.util.Set)4 ContinuousResource (org.onosproject.net.resource.ContinuousResource)4 Resources (org.onosproject.net.resource.Resources)4 LinkedHashMap (java.util.LinkedHashMap)3 List (java.util.List)3 Optional (java.util.Optional)3 ExecutionException (java.util.concurrent.ExecutionException)3 TimeoutException (java.util.concurrent.TimeoutException)3 Collectors (java.util.stream.Collectors)3 Stream (java.util.stream.Stream)3 PortNumber (org.onosproject.net.PortNumber)3 ResourceConsumerId (org.onosproject.net.resource.ResourceConsumerId)3 LinkedHashSet (java.util.LinkedHashSet)2 Map (java.util.Map)2 VlanId (org.onlab.packet.VlanId)2 DeviceId (org.onosproject.net.DeviceId)2