congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
StreamGobbler.start
Code IndexAdd Tabnine to your IDE (free)

How to use
start
method
in
org.apache.brooklyn.util.stream.StreamGobbler

Best Java code snippets using org.apache.brooklyn.util.stream.StreamGobbler.start (Showing top 9 results out of 315)

origin: org.apache.brooklyn/brooklyn-utils-common

InputStream outstream = p.getInputStream();
outgobbler = new StreamGobbler(outstream, out, (Logger) null);
outgobbler.start();
errgobbler.start();
origin: org.apache.brooklyn/brooklyn-software-base

@Test(groups="Integration")
@SuppressWarnings("resource")
public void testWhichKnife() throws IOException, InterruptedException {
  // requires that knife is installed on the path of login shells
  Process p = Runtime.getRuntime().exec(new String[] { "bash", "-l", "-c", "which knife" });
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  new StreamGobbler(p.getInputStream(), out, log).start();
  new StreamGobbler(p.getErrorStream(), out, log).start();
  log.info("bash -l -c 'which knife' gives exit code: "+p.waitFor());
  Time.sleep(Duration.millis(1000));
  log.info("output:\n"+out);
  Assert.assertEquals(p.exitValue(), 0);
}
origin: org.apache.brooklyn/brooklyn-core

InputStream outstream = p.getInputStream();
outgobbler = new StreamGobbler(outstream, out, (Logger) null);
outgobbler.start();
errgobbler.start();
origin: org.apache.brooklyn/brooklyn-software-cm-chef

@Test(groups="Integration")
@SuppressWarnings("resource")
public void testWhichKnife() throws IOException, InterruptedException {
  // requires that knife is installed on the path of login shells
  Process p = Runtime.getRuntime().exec(new String[] { "bash", "-l", "-c", "which knife" });
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  new StreamGobbler(p.getInputStream(), out, log).start();
  new StreamGobbler(p.getErrorStream(), out, log).start();
  log.info("bash -l -c 'which knife' gives exit code: "+p.waitFor());
  Time.sleep(Duration.millis(1000));
  log.info("output:\n"+out);
  Assert.assertEquals(p.exitValue(), 0);
}
origin: org.apache.brooklyn/brooklyn-core

outgobbler.start();
errgobbler.start();
origin: org.apache.brooklyn/brooklyn-utils-common

@Test
public void testGobbleStream() throws Exception {
  byte[] bytes = new byte[] {'a','b','c'};
  InputStream stream = new ByteArrayInputStream(bytes);
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  StreamGobbler gobbler = new StreamGobbler(stream, out, null);
  gobbler.start();
  try {
    gobbler.join(10*1000);
    assertFalse(gobbler.isAlive());
    assertEquals(new String(out.toByteArray()), "abc" + NL);
  } finally {
    gobbler.close();
    gobbler.interrupt();
  }
}

origin: org.apache.brooklyn/brooklyn-core

PipedInputStream insO = new PipedInputStream(); OutputStream outO = new PipedOutputStream(insO);
PipedInputStream insE = new PipedInputStream(); OutputStream outE = new PipedOutputStream(insE);
StreamGobbler sgsO = new StreamGobbler(insO, null, LOG); sgsO.setLogPrefix("[curl @ "+address+":stdout] ").start();
StreamGobbler sgsE = new StreamGobbler(insE, null, LOG); sgsE.setLogPrefix("[curl @ "+address+":stdout] ").start();
Map<String, ?> sshProps = MutableMap.<String, Object>builder().putAll(props).put("out", outO).put("err", outE).build();
int result = execScript(sshProps, "copying remote resource "+url+" to server",  ImmutableList.of(
origin: org.apache.brooklyn/brooklyn-core

InputStream outstream = shell.getInputStream();
outgobbler = new StreamGobbler(outstream, out, (Logger)null);
outgobbler.start();
errgobbler.start();
origin: org.apache.brooklyn/brooklyn-utils-common

@Test
public void testGobbleMultiLineBlockingStream() throws Exception {
  PipedOutputStream pipedOutputStream = new PipedOutputStream();
  PipedInputStream stream = new PipedInputStream(pipedOutputStream);
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  StreamGobbler gobbler = new StreamGobbler(stream, out, null);
  gobbler.start();
  try {
    pipedOutputStream.write("line1\n".getBytes());
    pipedOutputStream.flush();
    assertEqualsEventually(out, "line1" + NL);
    pipedOutputStream.write("line2\n".getBytes());
    pipedOutputStream.flush();
    assertEqualsEventually(out, "line1" + NL + "line2" + NL);
    pipedOutputStream.write("line".getBytes());
    pipedOutputStream.write("3\n".getBytes());
    pipedOutputStream.flush();
    assertEqualsEventually(out, "line1" + NL + "line2" + NL + "line3" + NL);
    pipedOutputStream.close();
    
    gobbler.join(10*1000);
    assertFalse(gobbler.isAlive());
    assertEquals(new String(out.toByteArray()), "line1" + NL + "line2" + NL + "line3" + NL);
  } finally {
    gobbler.close();
    gobbler.interrupt();
  }
}

org.apache.brooklyn.util.streamStreamGobblerstart

Popular methods of StreamGobbler

  • <init>
  • close
  • blockUntilFinished
    convenience -- equivalent to calling join()
  • interrupt
  • join
  • setLogPrefix
  • isAlive
  • onChar
  • onClose
  • onLine
  • setPrintPrefix
  • setPrintPrefix

Popular in Java

  • Updating database using SQL prepared statement
  • findViewById (Activity)
  • requestLocationUpdates (LocationManager)
  • scheduleAtFixedRate (Timer)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now