org.apache.sshd.common.util.threads.ThreadUtils Java Examples

The following examples show how to use org.apache.sshd.common.util.threads.ThreadUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WindowAdjustTest.java    From termd with Apache License 2.0 6 votes vote down vote up
@Override
public void start(Environment env) throws IOException {
    log.info("Starting");

    ExecutorService service = ThreadUtils.newSingleThreadExecutor(getClass().getSimpleName() + "-" + POOL_COUNT.incrementAndGet());
    executorHolder.set(service);

    futureHolder.set(service.submit(new Runnable() {
        @SuppressWarnings("synthetic-access")
        @Override
        public void run() {
            log.info("Start heavy load sending " + sendCount + " messages of " + msg.length + " bytes");
            for (int i = 0; i < sendCount; i++) {
                pendingWrapper.write(new ByteArrayBuffer(msg));
            }
            log.info("Sending EOF signal");
            pendingWrapper.write(new ByteArrayBuffer(new byte[]{eofSignal}));
        }
    }));
    log.info("Started");
}
 
Example #2
Source File: WindowAdjustTest.java    From termd with Apache License 2.0 6 votes vote down vote up
@Override
public void start(Environment env) throws IOException {
    log.info("Starting");

    ExecutorService service = ThreadUtils.newSingleThreadExecutor(getClass().getSimpleName() + "-" + POOL_COUNT.incrementAndGet());
    executorHolder.set(service);

    futureHolder.set(service.submit(new Runnable() {
        @SuppressWarnings("synthetic-access")
        @Override
        public void run() {
            log.info("Start heavy load sending " + sendCount + " messages of " + msg.length + " bytes");
            for (int i = 0; i < sendCount; i++) {
                pendingWrapper.write(new ByteArrayBuffer(msg));
            }
            log.info("Sending EOF signal");
            pendingWrapper.write(new ByteArrayBuffer(new byte[]{eofSignal}));
        }
    }));
    log.info("Started");
}
 
Example #3
Source File: NetconfSshdTestSubsystem.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * @param executorService The {@link ExecutorService} to be used by
 *                        the {@link SftpSubsystem} command when starting execution. If
 *                        {@code null} then a single-threaded ad-hoc service is used.
 * @param shutdownOnExit  If {@code true} the {@link ExecutorService#shutdownNow()}
 *                        will be called when subsystem terminates - unless it is the ad-hoc
 *                        service, which will be shutdown regardless
 * @see ThreadUtils#newSingleThreadExecutor(String)
 */
public NetconfSshdTestSubsystem(ExecutorService executorService, boolean shutdownOnExit) {
    executors = executorService;
    if (executorService == null) {
        executors = ThreadUtils.newSingleThreadExecutor(getClass().getSimpleName());
        shutdownExecutor = true;    // we always close the ad-hoc executor service
    } else {
        shutdownExecutor = shutdownOnExit;
    }
}