use of org.opendaylight.openflowjava.protocol.impl.clients.ListeningSimpleClient in project openflowplugin by opendaylight.
the class IntegrationTest method createAndStartClient.
/**
* Creates and start a client.
*
* @param amountOfCLients number of clients
* @param protocol true if encrypted connection should be used
* @return new clients up and running
* @throws ExecutionException if some client could not start
*/
private List<OFClient> createAndStartClient(final int amountOfCLients, final ScenarioHandler scenarioHandler, final TransportProtocol protocol, final ClientType clientType) throws ExecutionException, InterruptedException, TimeoutException {
final List<OFClient> clientsHorde = new ArrayList<>();
for (int i = 0; i < amountOfCLients; i++) {
LOGGER.debug("startup address in createclient: {}", startupAddress.getHostAddress());
OFClient sc = null;
if (clientType == ClientType.SIMPLE) {
if (protocol.equals(TransportProtocol.TCP)) {
sc = new SimpleClient(startupAddress.getHostAddress(), port);
sc.setSecuredClient(false);
} else if (protocol.equals(TransportProtocol.TLS)) {
sc = new SimpleClient(startupAddress.getHostAddress(), port);
sc.setSecuredClient(true);
} else {
sc = new UdpSimpleClient(startupAddress.getHostAddress(), port);
}
} else if (clientType == ClientType.LISTENING) {
sc = new ListeningSimpleClient(0);
sc.setScenarioHandler(scenarioHandler);
sc.setSecuredClient(false);
} else {
LOGGER.error("Unknown type of client.");
throw new IllegalStateException("Unknown type of client.");
}
sc.setScenarioHandler(scenarioHandler);
clientsHorde.add(sc);
// sc.run();
thread = new Thread(sc);
thread.start();
}
for (final OFClient sc : clientsHorde) {
sc.getIsOnlineFuture().get(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS);
}
return clientsHorde;
}
use of org.opendaylight.openflowjava.protocol.impl.clients.ListeningSimpleClient in project openflowplugin by opendaylight.
the class IntegrationTest method testInitiateConnection.
@Test
public void testInitiateConnection() throws Exception {
setUp(TransportProtocol.TCP);
final Deque<ClientEvent> scenario = ScenarioFactory.createHandshakeScenario();
final ScenarioHandler handler = new ScenarioHandler(scenario);
final List<OFClient> clients = createAndStartClient(1, handler, TransportProtocol.TCP, ClientType.LISTENING);
final OFClient ofClient = clients.get(0);
ofClient.getIsOnlineFuture().get(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS);
final int listeningClientPort = ((ListeningSimpleClient) ofClient).getPort();
mockPlugin.initiateConnection(switchConnectionProvider, "localhost", listeningClientPort);
ofClient.getScenarioDone().get();
LOGGER.debug("testInitiateConnection() Finished");
}
Aggregations