示例#1
0
 public final void runInner() throws IOException {
   while (!isStopped()) {
     ThreadU.sleepMillis(pollInterval);
     write();
   }
   MutexU.notifyAll(this);
 }
示例#2
0
 @SuppressWarnings("PMD.AssignmentInOperand")
 private void runInner() throws IOException {
   CommandToDo command;
   while ((command = script.getCommandToDo()) != null) {
     runCommand(command);
   }
   MutexU.notifyAll(this);
 }
示例#3
0
 private void write() throws IOException {
   final int length = byteBuffer.getLength();
   if (length > 0) {
     final byte[] bytes = byteBuffer.getBytes(true);
     os.write(bytes);
     MutexU.notifyAll(this);
   }
 }
示例#4
0
 @SuppressWarnings({"PMD.GuardLogStatementJavaUtil", "PMD.GuardLogStatement"})
 private Integer monitorCommand(final CommandWork commandWork, final Session session)
     throws IOException {
   final ExecutorService executorStream = context.getExecutorStream();
   final long pollInterval = context.getPollInterval();
   final ByteBuffer bufferStdin = commandWork.getByteBufferStdin();
   final ByteBuffer bufferStdout = commandWork.getByteBufferStdout();
   final ByteBuffer bufferStderr = commandWork.getByteBufferStderr();
   final OutputStream stdin = session.getStdin();
   final InputStream stdout = session.getStdout();
   final InputStream stderr = session.getStderr();
   // allow for supplemental process input
   final OutputStreamRunnable runnableStdin =
       new OutputStreamRunnable(stdin, bufferStdin, pollInterval);
   executorStream.execute(runnableStdin);
   // monitor process
   final InputStreamRunnable runnableStdout =
       new InputStreamRunnable(stdout, bufferStdout, pollInterval);
   final InputStreamRunnable runnableStderr =
       new InputStreamRunnable(stderr, bufferStderr, pollInterval);
   final InputStreamRunnable[] streams = {runnableStdout, runnableStderr};
   for (final InputStreamRunnable stream : streams) {
     executorStream.execute(stream);
   }
   // monitor process
   final int conditionExit = session.waitForCondition(ChannelCondition.EXIT_STATUS, 0L);
   logger.finest("conditionExitStatus/" + conditionExit); // i18n log
   final int conditionData = waitForData(session, runnableStdout.getPollInterval());
   logger.finest("conditionData/" + conditionData); // i18n log
   final Integer exitValue = session.getExitStatus();
   // allow process complete
   runnableStdin.stop();
   for (final InputStreamRunnable stream : streams) {
     stream.waitForComplete();
   }
   // notify caller thread
   MutexU.notifyAll(this);
   return exitValue;
 }