Search in sources :

Example 1 with NetconfClientDispatcherImpl

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());
}
Also used : DefaultThreadFactory(io.netty.util.concurrent.DefaultThreadFactory) HashedWheelTimer(io.netty.util.HashedWheelTimer) NetconfClientDispatcherImpl(org.opendaylight.netconf.client.NetconfClientDispatcherImpl) Main(io.lighty.netconf.device.notification.Main) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 2 with NetconfClientDispatcherImpl

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());
}
Also used : DefaultThreadFactory(io.netty.util.concurrent.DefaultThreadFactory) HashedWheelTimer(io.netty.util.HashedWheelTimer) NetconfClientDispatcherImpl(org.opendaylight.netconf.client.NetconfClientDispatcherImpl) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 3 with NetconfClientDispatcherImpl

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();
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) AggregatedNetconfOperationServiceFactory(org.opendaylight.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory) HashedWheelTimer(io.netty.util.HashedWheelTimer) NetconfClientDispatcherImpl(org.opendaylight.netconf.client.NetconfClientDispatcherImpl) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) Before(org.junit.Before)

Example 4 with NetconfClientDispatcherImpl

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();
    }
}
Also used : ArrayList(java.util.ArrayList) Stopwatch(com.google.common.base.Stopwatch) Logger(org.slf4j.Logger) ArrayList(java.util.ArrayList) List(java.util.List) ExecutionException(java.util.concurrent.ExecutionException) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) TimeoutException(java.util.concurrent.TimeoutException) Stopwatch(com.google.common.base.Stopwatch) HashedWheelTimer(io.netty.util.HashedWheelTimer) IOException(java.io.IOException) NetconfClientDispatcherImpl(org.opendaylight.netconf.client.NetconfClientDispatcherImpl) HashedWheelTimer(io.netty.util.HashedWheelTimer) Timer(io.netty.util.Timer) NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) ExecutorService(java.util.concurrent.ExecutorService) Future(java.util.concurrent.Future)

Example 5 with NetconfClientDispatcherImpl

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);
}
Also used : DefaultThreadFactory(io.netty.util.concurrent.DefaultThreadFactory) HashedWheelTimer(io.netty.util.HashedWheelTimer) NetconfClientDispatcherImpl(org.opendaylight.netconf.client.NetconfClientDispatcherImpl) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) BeforeClass(org.junit.BeforeClass)

Aggregations

NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)9 HashedWheelTimer (io.netty.util.HashedWheelTimer)9 NetconfClientDispatcherImpl (org.opendaylight.netconf.client.NetconfClientDispatcherImpl)9 DefaultThreadFactory (io.netty.util.concurrent.DefaultThreadFactory)6 BeforeAll (org.junit.jupiter.api.BeforeAll)5 ChannelFuture (io.netty.channel.ChannelFuture)2 Timer (io.netty.util.Timer)2 TimeoutException (java.util.concurrent.TimeoutException)2 NetconfMessage (org.opendaylight.netconf.api.NetconfMessage)2 Stopwatch (com.google.common.base.Stopwatch)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 Main (io.lighty.netconf.device.notification.Main)1 EventLoopGroup (io.netty.channel.EventLoopGroup)1 Future (io.netty.util.concurrent.Future)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ExecutionException (java.util.concurrent.ExecutionException)1 ExecutorService (java.util.concurrent.ExecutorService)1