Examples of PingThread


Examples of hudson.remoting.PingThread

        FullDuplexHttpStream con = new FullDuplexHttpStream(jenkins,authorization);
        Channel ch = new Channel("Chunked connection to "+jenkins,
                pool,con.getInputStream(),con.getOutputStream());
        final long interval = 15*1000;
        final long timeout = (interval * 3) / 4;
        new PingThread(ch,timeout,interval) {
            protected void onDead() {
                // noop. the point of ping is to keep the connection alive
                // as most HTTP servers have a rather short read time out
            }
        }.start();
View Full Code Here

Examples of hudson.remoting.PingThread

        }
    }

    private static void setUpPingForChannel(final Channel channel, int interval) {
        final AtomicBoolean isInClosed = new AtomicBoolean(false);
        final PingThread t = new PingThread(channel, interval * 60 * 1000) {
            protected void onDead(Throwable cause) {
                try {
                    if (isInClosed.get()) {
                        LOGGER.log(FINE,"Ping failed after the channel is already partially closed",cause);
                    } else {
                        LOGGER.log(INFO,"Ping failed. Terminating the channel.",cause);
                        channel.close(cause);
                    }
                } catch (IOException e) {
                    LOGGER.log(SEVERE,"Failed to terminate the channel: ",e);
                }
            }
            protected void onDead() {
                onDead(null);
            }
        };

        channel.addListener(new Channel.Listener() {
            @Override
            public void onClosed(Channel channel, IOException cause) {
                LOGGER.fine("Terminating ping thread for " + channel);
                isInClosed.set(true);
                t.interrupt()// make sure the ping thread is terminated
            }
        });

        t.start();
        LOGGER.fine("Ping thread started for " + channel + " with a " + interval + " minute interval");
    }
View Full Code Here

Examples of hudson.remoting.PingThread

        try {
            channel = new Channel("HTTP full-duplex channel " + uuid,
                    Computer.threadPoolForRemoting, Mode.BINARY, upload, out, 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();
        } finally {
            // publish that we are done
            completed=true;
            notify();
        }
View Full Code Here

Examples of hudson.remoting.PingThread

            hudson = new URL(url);

            FullDuplexHttpStream con = new FullDuplexHttpStream(hudson);
            channel = new Channel("Chunked connection to "+hudson,
                    pool,con.getInputStream(),con.getOutputStream());
            new PingThread(channel,30*1000) {
                protected void onDead() {
                    // noop. the point of ping is to keep the connection alive
                    // as most HTTP servers have a rather short read time out
                }
            }.start();
View Full Code Here

Examples of hudson.remoting.PingThread

        try {
            channel = new Channel("HTTP full-duplex channel " + uuid,
                    Computer.threadPoolForRemoting, Mode.BINARY, upload, out, null, restricted);

            // so that we can detect dead clients, periodically send something
            PingThread ping = new PingThread(channel) {
                @Override
                protected void onDead() {
                    LOGGER.info("Duplex-HTTP session " + uuid + " is terminated");
                    // 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);
                    }
                }
            };
            ping.start();
            main(channel);
            channel.join();
            ping.interrupt();
        } finally {
            // publish that we are done
            completed=true;
            notify();
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.