use of org.opendaylight.openflowjava.protocol.impl.clients.SimpleClient 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.SimpleClient in project openflowplugin by opendaylight.
the class SalIntegrationTest method setUp.
/**
* test setup
* @throws InterruptedException
*/
@Before
public void setUp() throws InterruptedException {
switchSim = new SimpleClient("localhost", 6653);
scenarioPool = new ThreadPoolLoggingExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, SCENARIO_POOL_QUEUE, "scenario");
Thread.sleep(5000L);
}
Aggregations