Tabnine Logo
StreamGobbler.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
org.apache.brooklyn.util.stream.StreamGobbler
constructor

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

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

outgobbler = new StreamGobbler(outstream, out, (Logger) null);
outgobbler.start();
errgobbler = new StreamGobbler(errstream, err, (Logger) null);
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

outgobbler = new StreamGobbler(outstream, out, (Logger) null);
outgobbler.start();
errgobbler = new StreamGobbler(errstream, err, (Logger) null);
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 = new StreamGobbler(output.getInputStream(), out, (Logger)null);
outgobbler.start();
errgobbler = new StreamGobbler(output.getErrorStream(), err, (Logger)null);
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

outgobbler = new StreamGobbler(outstream, out, (Logger)null);
outgobbler.start();
errgobbler = new StreamGobbler(errstream, err, (Logger)null);
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.streamStreamGobbler<init>

Popular methods of StreamGobbler

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

Popular in Java

  • Running tasks concurrently on multiple threads
  • addToBackStack (FragmentTransaction)
  • setScale (BigDecimal)
  • setContentView (Activity)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • Permission (java.security)
    Legacy security code; do not use.
  • JComboBox (javax.swing)
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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