/** * Shuts down the channel and closes the underlying connection. */ public void close() throws IOException, InterruptedException { channel.close(); channel.join(); if(ownsPool) pool.shutdown(); for (Closeable c : closables) c.close(); }
protected void runCli(Connection c) throws IOException, InterruptedException { ChannelBuilder cb; String name = "CLI channel from " + socket.getInetAddress(); // Connection can contain cipher wrapper, which can't be NIO-ed. // if (hub!=null) // cb = hub.newChannelBuilder(name, Computer.threadPoolForRemoting); // else cb = new ChannelBuilder(name, Computer.threadPoolForRemoting); Channel channel = cb .withMode(Mode.BINARY) .withRestricted(true) .withBaseLoader(Jenkins.getActiveInstance().pluginManager.uberClassLoader) .build(new BufferedInputStream(c.in), new BufferedOutputStream(c.out)); channel.setProperty(CliEntryPoint.class.getName(),new CliManagerImpl(channel)); channel.join(); } }
@Override protected void run(final InputStream upload, OutputStream download) throws IOException, InterruptedException { channel = new Channel("HTTP full-duplex channel " + uuid, Computer.threadPoolForRemoting, Mode.BINARY, upload, download, null, restricted); // so that we can detect dead clients, periodically send something PingThread ping = new PingThread(channel) { @Override protected void onDead(Throwable diagnosis) { LOGGER.log(Level.INFO, "Duplex-HTTP session " + uuid + " is terminated", diagnosis); // this will cause the channel to abort and subsequently clean up try { upload.close(); } catch (IOException e) { // this can never happen throw new AssertionError(e); } } @Override protected void onDead() { onDead(null); } }; ping.start(); main(channel); channel.join(); ping.interrupt(); }
public void join() throws InterruptedException { log.debug("Joining"); getChannel().join(); log.debug("Joined"); }
public void join() throws InterruptedException { log.debug("Joining"); getChannel().join(); log.debug("Joined"); }
public void close() throws IOException, InterruptedException { channel.close(); channel.join(); if(ownsPool) pool.shutdown(); }
public void join() throws InterruptedException { log.debug("Joining"); getChannel().join(); log.debug("Joined"); }
@Override public synchronized void onTearDown() throws Exception { for (Channel c : channels) c.close(); for (Channel c : channels) c.join(); channels.clear(); } }
@Override public void tearDown() throws IOException { channel.close(); try { channel.join(3000); } catch (InterruptedException e) { throw new IOException(e); } finally { if (conn !=null) conn.close(); conn = null; } }
/** * Handles CLI connection request. */ private void runCliConnect(DataInputStream in, PrintWriter out) throws IOException, InterruptedException { out.println("Welcome"); Channel channel = new Channel("CLI channel from " + s.getInetAddress(), Computer.threadPoolForRemoting, Mode.BINARY, new BufferedInputStream(new SocketInputStream(this.s)), new BufferedOutputStream(new SocketOutputStream(this.s)), null, true); channel.setProperty(CliEntryPoint.class.getName(), new CliManagerImpl()); channel.join(); }
/** * Handles CLI connection request. */ private void runCliConnect(DataInputStream in, PrintWriter out) throws IOException, InterruptedException { out.println("Welcome"); Channel channel = new Channel("CLI channel from " + s.getInetAddress(), Computer.threadPoolForRemoting, Mode.BINARY, new BufferedInputStream(new SocketInputStream(this.s)), new BufferedOutputStream(new SocketOutputStream(this.s)), null, true); channel.setProperty(CliEntryPoint.class.getName(),new CliManagerImpl()); channel.join(); }
/** * Handles CLI connection request. */ private void runCliConnect(DataInputStream in, PrintWriter out) throws IOException, InterruptedException { out.println("Welcome"); Channel channel = new Channel("CLI channel from " + s.getInetAddress(), Computer.threadPoolForRemoting, Mode.BINARY, new BufferedInputStream(new SocketInputStream(this.s)), new BufferedOutputStream(new SocketOutputStream(this.s)), null, true); channel.setProperty(CliEntryPoint.class.getName(),new CliManagerImpl()); channel.join(); }
public void stop(Channel channel) throws Exception { channel.close(); channel.join(); System.out.println("north completed"); executor.shutdown(); if(failure!=null) throw failure; // report a failure in the south side }
/** * Handles CLI connection request. */ private void runCliConnect(DataInputStream in, PrintWriter out) throws IOException, InterruptedException { out.println("Welcome"); Channel channel = new Channel("CLI channel from " + s.getInetAddress(), Computer.threadPoolForRemoting, Mode.BINARY, new BufferedInputStream(new SocketInputStream(this.s)), new BufferedOutputStream(new SocketOutputStream(this.s)), null, true); channel.setProperty(CliEntryPoint.class.getName(),new CliManagerImpl()); channel.join(); }
protected void runCli(Connection c) throws IOException, InterruptedException { ChannelBuilder cb; String name = "CLI channel from " + socket.getInetAddress(); // Connection can contain cipher wrapper, which can't be NIO-ed. // if (hub!=null) // cb = hub.newChannelBuilder(name, Computer.threadPoolForRemoting); // else cb = new ChannelBuilder(name, Computer.threadPoolForRemoting); Channel channel = cb .withMode(Mode.BINARY) .withRestricted(true) .withBaseLoader(Jenkins.getActiveInstance().pluginManager.uberClassLoader) .build(new BufferedInputStream(c.in), new BufferedOutputStream(c.out)); channel.setProperty(CliEntryPoint.class.getName(),new CliManagerImpl(channel)); channel.join(); } }
public static void main(String[] args) throws Exception { ServerSocket ss = new ServerSocket(PORT); while (true) { System.out.println("Ready"); Socket s = ss.accept(); s.setTcpNoDelay(true); System.out.println("Accepted"); Channel ch = new Channel("bogus", Executors.newCachedThreadPool(), new BufferedInputStream(SocketChannelStream.in(s)), new BufferedOutputStream(SocketChannelStream.out(s))); ch.join(); s.close(); } } public static final int PORT = 9532;
public void stop(Channel channel) throws Exception { channel.close(); channel.join(); System.out.println("north completed"); // we initiate the shutdown from north, so by the time it closes south should be all closed, too /* TODO passes reliably on Java 7 but often fails on Java 8 assertTrue(south.isInClosed()); assertTrue(south.isOutClosed()); */ nio.close(); executor.shutdown(); if(failure!=null) throw new AssertionError(failure); // report a failure in the south side }
public void run() { try { Channel south = configureSouth().build(in2,out1); southHandoff.put(south); south.join(); System.out.println("south completed"); } catch (Exception e) { e.printStackTrace(); failure = e; } } };
public void stop(Channel channel) throws Exception { channel.close(); channel.join(10*1000); // System.out.println("north completed"); executor.shutdown(); copier.join(); int r = proc.waitFor(); // System.out.println("south completed"); assertEquals("exit code should have been 0", 0, r); }
public void run() { try { Channel south = nio.newChannelBuilder("south",executor).withMode(Mode.NEGOTIATE) .build(n2s.source(), s2n.sink()); southHandoff.put(south); south.join(); System.out.println("south completed"); } catch (Exception e) { e.printStackTrace(); failure = e; } } });