Package hudson.remoting

Examples of hudson.remoting.Channel


    public static void applyConfiguration(SAXReader reader, Object context) throws IOException, InterruptedException {
        Collection<ParserConfigurator> all = Collections.emptyList();

        if (Jenkins.getInstance()==null) {
            Channel ch = Channel.current();
            if (ch!=null)
                all = ch.call(new Callable<Collection<ParserConfigurator>, IOException>() {

                    private static final long serialVersionUID = -2178106894481500733L;

                    public Collection<ParserConfigurator> call() throws IOException {
                        return new ArrayList<ParserConfigurator>(all());
View Full Code Here


    public boolean isRemote() {
        return channel!=null;
    }

    private void writeObject(ObjectOutputStream oos) throws IOException {
        Channel target = Channel.current();

        if(channel!=null && channel!=target)
            throw new IllegalStateException("Can't send a remote FilePath to a different remote channel");

        oos.defaultWriteObject();
View Full Code Here

        oos.defaultWriteObject();
        oos.writeBoolean(channel==null);
    }

    private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
        Channel channel = Channel.current();
        assert channel!=null;

        ois.defaultReadObject();
        if(ois.readBoolean()) {
            this.channel = channel;
View Full Code Here

    /**
     * Creates a channel that wraps a remote process, so that when we shut down the connection
     * we kill the process.
     */
    public static Channel forProcess(String name, ExecutorService execService, InputStream in, OutputStream out, OutputStream header, final Proc proc) throws IOException {
        return new Channel(name, execService, in, out, header) {
            /**
             * Kill the process when the channel is severed.
             */
            @Override
            protected synchronized void terminate(IOException e) {
View Full Code Here

    public static Channel forProcess(String name, ExecutorService execService, final Process proc, OutputStream header) throws IOException {
        final Thread thread = new StreamCopyThread(name + " stderr", proc.getErrorStream(), header);
        thread.start();

        return new Channel(name, execService, proc.getInputStream(), proc.getOutputStream(), header) {
            /**
             * Kill the process when the channel is severed.
             */
            @Override
            protected synchronized void terminate(IOException e) {
View Full Code Here

        long now = System.currentTimeMillis();
        for (Computer c: Jenkins.getInstance().getComputers()) {
            VirtualChannel ch = c.getChannel();
            if (ch instanceof Channel) {
                Channel channel = (Channel) ch;
                if (now-channel.getLastHeard() > TIME_TILL_PING) {
                    // haven't heard from this slave for a while.
                    Long lastPing = (Long)channel.getProperty(ConnectionActivityMonitor.class);

                    if (lastPing!=null && now-lastPing > TIMEOUT) {
                        LOGGER.info("Repeated ping attempts failed on "+c.getName()+". Disconnecting");
                        c.disconnect(OfflineCause.create(Messages._ConnectionActivityMonitor_OfflineCause()));
                    } else {
                        // send a ping. if we receive a reply, it will be reflected in the next getLastHeard() call.
                        channel.callAsync(PING_COMMAND);
                        if (lastPing==null)
                            channel.setProperty(ConnectionActivityMonitor.class,now);
                    }
                } else {
                    // we are receiving data nicely
                    channel.setProperty(ConnectionActivityMonitor.class,null);
                }
            }
        }
    }
View Full Code Here

        // wait until we have the other channel
        while(upload==null)
            wait();

        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
View Full Code Here

        final FastPipedOutputStream p1o = new FastPipedOutputStream(p1i);
        final FastPipedOutputStream p2o = new FastPipedOutputStream(p2i);

        Future<Channel> f1 = executors.submit(new Callable<Channel>() {
            public Channel call() throws Exception {
                return new Channel("This side of the channel", executors, p1i, p2o);
            }
        });
        Future<Channel> f2 = executors.submit(new Callable<Channel>() {
            public Channel call() throws Exception {
                return new Channel("The other side of the channel", executors, p2i, p1o);
            }
        });
        french = f1.get();
        british = f2.get();
    }
View Full Code Here

        printCommandLine(cmd, _workDir);

        try {
            Process proc = launcher.launch(Util.join(asList(cmd), " "), _workDir.getRemote());

            return new Channel("channel over named pipe to "+launcher.getHostName(),
                Computer.threadPoolForRemoting, proc.getInputStream(), new BufferedOutputStream(proc.getOutputStream()));
        } catch (JIException e) {
            throw new IOException2(e);
        }
    }
View Full Code Here

        /**
         * 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, Jenkins.getInstance().pluginManager.uberClassLoader);
            channel.setProperty(CliEntryPoint.class.getName(),new CliManagerImpl(channel));
            channel.join();
        }
View Full Code Here

TOP

Related Classes of hudson.remoting.Channel

Copyright © 2018 www.massapicom. 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.