use of org.opendaylight.netconf.client.NetconfClientDispatcherImpl in project lighty-netconf-simulator by PANTHEONtech.
the class NotificationTest method setupClass.
@BeforeAll
public static void setupClass() {
deviceSimulator = new Main();
deviceSimulator.start(new String[] { DEVICE_SIMULATOR_PORT + "" }, false);
nettyGroup = new NioEventLoopGroup(1, new DefaultThreadFactory(NetconfClientDispatcher.class));
dispatcher = new NetconfClientDispatcherImpl(nettyGroup, nettyGroup, new HashedWheelTimer());
}
use of org.opendaylight.netconf.client.NetconfClientDispatcherImpl in project lighty-netconf-simulator by PANTHEONtech.
the class ActionDeviceTest method setUpClass.
@BeforeAll
public static void setUpClass() {
deviceSimulator = new Main();
deviceSimulator.start(new String[] { DEVICE_SIMULATOR_PORT + "" }, false);
nettyGroup = new NioEventLoopGroup(1, new DefaultThreadFactory(NetconfClientDispatcher.class));
dispatcher = new NetconfClientDispatcherImpl(nettyGroup, nettyGroup, new HashedWheelTimer());
}
use of org.opendaylight.netconf.client.NetconfClientDispatcherImpl in project netconf by opendaylight.
the class ConcurrentClientsTest method setUp.
@Before
public void setUp() throws Exception {
hashedWheelTimer = new HashedWheelTimer();
nettyGroup = new NioEventLoopGroup(nettyThreads);
netconfClientDispatcher = new NetconfClientDispatcherImpl(nettyGroup, nettyGroup, hashedWheelTimer);
AggregatedNetconfOperationServiceFactory factoriesListener = new AggregatedNetconfOperationServiceFactory();
testingNetconfOperation = new TestingNetconfOperation();
factoriesListener.onAddNetconfOperationServiceFactory(new TestingOperationServiceFactory(testingNetconfOperation));
SessionIdProvider idProvider = new SessionIdProvider();
NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactoryBuilder().setTimer(hashedWheelTimer).setAggregatedOpService(factoriesListener).setIdProvider(idProvider).setConnectionTimeoutMillis(5000).setMonitoringService(createMockedMonitoringService()).setBaseCapabilities(serverCaps).build();
ServerChannelInitializer serverChannelInitializer = new ServerChannelInitializer(serverNegotiatorFactory);
final NetconfServerDispatcherImpl dispatch = new NetconfServerDispatcherImpl(serverChannelInitializer, nettyGroup, nettyGroup);
ChannelFuture server = dispatch.createServer(NETCONF_ADDRESS);
server.await();
}
use of org.opendaylight.netconf.client.NetconfClientDispatcherImpl in project netconf by opendaylight.
the class StressClient method main.
public static void main(final String[] args) {
params = parseArgs(args, Parameters.getParser());
params.validate();
final ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
root.setLevel(params.debug ? Level.DEBUG : Level.INFO);
final int threadAmount = params.threadAmount;
LOG.info("thread amount: {}", threadAmount);
final int requestsPerThread = params.editCount / params.threadAmount;
LOG.info("requestsPerThread: {}", requestsPerThread);
final int leftoverRequests = params.editCount % params.threadAmount;
LOG.info("leftoverRequests: {}", leftoverRequests);
LOG.info("Preparing messages");
// Prepare all msgs up front
final List<List<NetconfMessage>> allPreparedMessages = new ArrayList<>(threadAmount);
for (int i = 0; i < threadAmount; i++) {
if (i != threadAmount - 1) {
allPreparedMessages.add(new ArrayList<>(requestsPerThread));
} else {
allPreparedMessages.add(new ArrayList<>(requestsPerThread + leftoverRequests));
}
}
final String editContentString;
try {
editContentString = Files.asCharSource(params.editContent, StandardCharsets.UTF_8).read();
} catch (final IOException e) {
throw new IllegalArgumentException("Cannot read content of " + params.editContent, e);
}
for (int i = 0; i < threadAmount; i++) {
final List<NetconfMessage> preparedMessages = allPreparedMessages.get(i);
int padding = 0;
if (i == threadAmount - 1) {
padding = leftoverRequests;
}
for (int j = 0; j < requestsPerThread + padding; j++) {
LOG.debug("id: {}", i * requestsPerThread + j);
preparedMessages.add(prepareMessage(i * requestsPerThread + j, editContentString));
}
}
final NioEventLoopGroup nioGroup = new NioEventLoopGroup();
final Timer timer = new HashedWheelTimer();
final NetconfClientDispatcherImpl netconfClientDispatcher = configureClientDispatcher(nioGroup, timer);
final List<StressClientCallable> callables = new ArrayList<>(threadAmount);
for (final List<NetconfMessage> messages : allPreparedMessages) {
callables.add(new StressClientCallable(params, netconfClientDispatcher, messages));
}
final ExecutorService executorService = Executors.newFixedThreadPool(threadAmount);
LOG.info("Starting stress test");
final Stopwatch started = Stopwatch.createStarted();
try {
final List<Future<Boolean>> futures = executorService.invokeAll(callables);
for (final Future<Boolean> future : futures) {
try {
future.get(4L, TimeUnit.MINUTES);
} catch (ExecutionException | TimeoutException e) {
throw new RuntimeException(e);
}
}
executorService.shutdownNow();
} catch (final InterruptedException e) {
throw new RuntimeException("Unable to execute requests", e);
}
started.stop();
LOG.info("FINISHED. Execution time: {}", started);
LOG.info("Requests per second: {}", params.editCount * 1000.0 / started.elapsed(TimeUnit.MILLISECONDS));
// Cleanup
timer.stop();
try {
nioGroup.shutdownGracefully().get(20L, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
LOG.warn("Unable to close executor properly", e);
}
// stop the underlying ssh thread that gets spawned if we use ssh
if (params.ssh) {
AsyncSshHandler.DEFAULT_CLIENT.stop();
}
}
use of org.opendaylight.netconf.client.NetconfClientDispatcherImpl in project netconf by opendaylight.
the class TestToolTest method setUpClass.
@BeforeClass
public static void setUpClass() {
HashedWheelTimer hashedWheelTimer = new HashedWheelTimer();
nettyGroup = new NioEventLoopGroup(1, new DefaultThreadFactory(NetconfClientDispatcher.class));
dispatcher = new NetconfClientDispatcherImpl(nettyGroup, nettyGroup, hashedWheelTimer);
}
Aggregations