mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-16 09:51:38 +02:00
[ONOS-6806] Add getAvailableDeviceCount method to DeviceStore
Change-Id: I3f9e0bbd502e2a592da98436685fa2a192436ef8
This commit is contained in:
parent
3bf51574a3
commit
0d0c6831cc
@ -38,6 +38,13 @@ public interface DeviceStore extends Store<DeviceEvent, DeviceStoreDelegate> {
|
|||||||
*/
|
*/
|
||||||
int getDeviceCount();
|
int getDeviceCount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of currently available devices known to the system.
|
||||||
|
*
|
||||||
|
* @return number of devices
|
||||||
|
*/
|
||||||
|
int getAvailableDeviceCount();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an iterable collection of all devices known to the system.
|
* Returns an iterable collection of all devices known to the system.
|
||||||
*
|
*
|
||||||
|
@ -35,6 +35,11 @@ public class DeviceStoreAdapter implements DeviceStore {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAvailableDeviceCount() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<Device> getDevices() {
|
public Iterable<Device> getDevices() {
|
||||||
return null;
|
return null;
|
||||||
|
@ -125,6 +125,11 @@ public class SimpleDeviceStore
|
|||||||
return devices.size();
|
return devices.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAvailableDeviceCount() {
|
||||||
|
return availableDevices.size();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<Device> getDevices() {
|
public Iterable<Device> getDevices() {
|
||||||
return Collections.unmodifiableCollection(devices.values());
|
return Collections.unmodifiableCollection(devices.values());
|
||||||
|
@ -155,6 +155,22 @@ public class SimpleDeviceStoreTest {
|
|||||||
assertEquals("expect 2 uniq devices", 2, deviceStore.getDeviceCount());
|
assertEquals("expect 2 uniq devices", 2, deviceStore.getDeviceCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public final void testGetAvailableDeviceCount() {
|
||||||
|
assertEquals("initialy empty", 0, deviceStore.getAvailableDeviceCount());
|
||||||
|
|
||||||
|
putDevice(DID1, SW1);
|
||||||
|
putDevice(DID2, SW2);
|
||||||
|
|
||||||
|
deviceStore.markOffline(DID1);
|
||||||
|
|
||||||
|
assertEquals("expect 1 available device", 1, deviceStore.getAvailableDeviceCount());
|
||||||
|
|
||||||
|
putDevice(DID1, SW1);
|
||||||
|
|
||||||
|
assertEquals("expect 2 available devices", 2, deviceStore.getAvailableDeviceCount());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public final void testGetDevices() {
|
public final void testGetDevices() {
|
||||||
assertEquals("initialy empty", 0, Iterables.size(deviceStore.getDevices()));
|
assertEquals("initialy empty", 0, Iterables.size(deviceStore.getDevices()));
|
||||||
|
@ -246,6 +246,11 @@ public class ECDeviceStore
|
|||||||
return devices.size();
|
return devices.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAvailableDeviceCount() {
|
||||||
|
return availableDevices.size();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Device getDevice(DeviceId deviceId) {
|
public Device getDevice(DeviceId deviceId) {
|
||||||
return devices.get(deviceId);
|
return devices.get(deviceId);
|
||||||
|
@ -275,6 +275,11 @@ public class GossipDeviceStore
|
|||||||
return devices.size();
|
return devices.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAvailableDeviceCount() {
|
||||||
|
return availableDevices.size();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<Device> getDevices() {
|
public Iterable<Device> getDevices() {
|
||||||
return Collections.unmodifiableCollection(devices.values());
|
return Collections.unmodifiableCollection(devices.values());
|
||||||
|
@ -298,6 +298,22 @@ public class GossipDeviceStoreTest {
|
|||||||
assertEquals("expect 2 uniq devices", 2, deviceStore.getDeviceCount());
|
assertEquals("expect 2 uniq devices", 2, deviceStore.getDeviceCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public final void testGetAvailableDeviceCount() {
|
||||||
|
assertEquals("initialy empty", 0, deviceStore.getAvailableDeviceCount());
|
||||||
|
|
||||||
|
putDevice(DID1, SW1);
|
||||||
|
putDevice(DID2, SW2);
|
||||||
|
|
||||||
|
deviceStore.markOffline(DID1);
|
||||||
|
|
||||||
|
assertEquals("expect 1 available device", 1, deviceStore.getAvailableDeviceCount());
|
||||||
|
|
||||||
|
deviceStore.markOnline(DID1);
|
||||||
|
|
||||||
|
assertEquals("expect 2 available devices", 2, deviceStore.getAvailableDeviceCount());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public final void testGetDevices() {
|
public final void testGetDevices() {
|
||||||
assertEquals("initialy empty", 0, Iterables.size(deviceStore.getDevices()));
|
assertEquals("initialy empty", 0, Iterables.size(deviceStore.getDevices()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user