congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
StreamGobbler.interrupt
Code IndexAdd Tabnine to your IDE (free)

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

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

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

@Override
public void close() {
  running.set(false);
  interrupt();
}
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-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.streamStreamGobblerinterrupt

Popular methods of StreamGobbler

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

Popular in Java

  • Finding current android device location
  • setContentView (Activity)
  • getExternalFilesDir (Context)
  • startActivity (Activity)
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • Option (scala)
  • Best IntelliJ plugins
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