@Test public void getReadySwitchesTest() { NodeId nIdDisconected = mock(NodeId.class); NodeId nIdReady = mock(NodeId.class); SwitchState sDisconected = new SwitchState(nIdDisconected); sDisconected.status = SwitchStatus.DISCONNECTED; SwitchState sReady = new SwitchState(nIdReady); sReady.status = SwitchStatus.READY; SwitchManager.switches.put(nIdDisconected, sDisconected); SwitchManager.switches.put(nIdReady, sReady); Collection<NodeId> readySwitches = switchManager.getReadySwitches(); Assert.assertFalse(readySwitches.contains(nIdDisconected)); Assert.assertTrue(readySwitches.contains(nIdReady)); }
public synchronized Collection<NodeId> getReadySwitches() { ImmutableList<NodeId> readySwitches = FluentIterable.from(switches.values()) .filter(new Predicate<SwitchState>() { @Override public boolean apply(SwitchState input) { return input.status == SwitchStatus.READY; } }) .transform(new Function<SwitchState, NodeId>() { @Override public NodeId apply(SwitchState input) { return input.nodeId; } }) .toList(); LOG.trace("Get ready switches: {}", readySwitches); return readySwitches; }
SwitchManager implements AutoCloseable { public synchronized Collection<NodeId> getReadySwitches() { ImmutableList<NodeId> readySwitches = FluentIterable.from(switches.values()) .filter(new Predicate<SwitchState>() { @Override public boolean apply(SwitchState input) { return input.status == SwitchStatus.READY; } }) .transform(new Function<SwitchState, NodeId>() { @Override public NodeId apply(SwitchState input) { return input.nodeId; } }) .toList(); LOG.trace("Get ready switches: {}", readySwitches); return readySwitches; } }
SwitchManager implements AutoCloseable { public synchronized Collection<NodeId> getReadySwitches() { ImmutableList<NodeId> readySwitches = FluentIterable.from(switches.values()) .filter(new Predicate<SwitchState>() { @Override public boolean apply(SwitchState input) { return input.status == SwitchStatus.READY; } }) .transform(new Function<SwitchState, NodeId>() { @Override public NodeId apply(SwitchState input) { return input.nodeId; } }) .toList(); LOG.trace("Get ready switches: {}", readySwitches); return readySwitches; } SwitchManager(DataBroker dataProvider); }
SwitchManager implements AutoCloseable { public synchronized Collection<NodeId> getReadySwitches() { ImmutableList<NodeId> readySwitches = FluentIterable.from(switches.values()) .filter(new Predicate<SwitchState>() { @Override public boolean apply(SwitchState input) { return input.status == SwitchStatus.READY; } }) .transform(new Function<SwitchState, NodeId>() { @Override public NodeId apply(SwitchState input) { return input.nodeId; } }) .toList(); LOG.trace("Get ready switches: {}", readySwitches); return readySwitches; } SwitchManager(DataBroker dataProvider); static void activatingSwitch(NodeId nodeId); static void deactivatingSwitch(NodeId nodeId); synchronized InstanceIdentifier<NodeConnector> getNodeConnectorIidForPortName(Name portName); synchronized Collection<NodeId> getReadySwitches(); synchronized Set<NodeConnectorId> getExternalPorts(NodeId nodeId); Set<Long> getExternalPortNumbers(NodeId nodeId); synchronized Collection<NodeConnectorId> getTunnelPorts(NodeId nodeId); synchronized NodeConnectorId getTunnelPort(NodeId nodeId, Class<? extends TunnelTypeBase> tunnelType); synchronized IpAddress getTunnelIP(NodeId nodeId, Class<? extends TunnelTypeBase> tunnelType); void registerListener(SwitchListener listener); void setEncapsulationFormat(EncapsulationFormat format); @Override void close(); }
SwitchManager implements AutoCloseable { public synchronized Collection<NodeId> getReadySwitches() { ImmutableList<NodeId> readySwitches = FluentIterable.from(switches.values()) .filter(new Predicate<SwitchState>() { @Override public boolean apply(SwitchState input) { return input.status == SwitchStatus.READY; } }) .transform(new Function<SwitchState, NodeId>() { @Override public NodeId apply(SwitchState input) { return input.nodeId; } }) .toList(); LOG.trace("Get ready switches: {}", readySwitches); return readySwitches; } SwitchManager(DataBroker dataProvider); static void activatingSwitch(NodeId nodeId); static void deactivatingSwitch(NodeId nodeId); synchronized InstanceIdentifier<NodeConnector> getNodeConnectorIidForPortName(Name portName); synchronized Collection<NodeId> getReadySwitches(); synchronized Set<NodeConnectorId> getExternalPorts(NodeId nodeId); Set<Long> getExternalPortNumbers(NodeId nodeId); synchronized Collection<NodeConnectorId> getTunnelPorts(NodeId nodeId); synchronized NodeConnectorId getTunnelPort(NodeId nodeId, Class<? extends TunnelTypeBase> tunnelType); synchronized IpAddress getTunnelIP(NodeId nodeId, Class<? extends TunnelTypeBase> tunnelType); void registerListener(SwitchListener listener); void setEncapsulationFormat(EncapsulationFormat format); @Override void close();  }