Examples of VirtualChannel


Examples of hudson.remoting.VirtualChannel

    @TestExtension
    public static class ComputerListenerImpl extends ComputerListener {
        @Override
        public void onOnline(Computer c, TaskListener listener) throws IOException, InterruptedException {
            VirtualChannel ch = c.getChannel();
            if (ch instanceof Channel)
            TestEnvironment.get().testCase.addChannel((Channel)ch);
        }
View Full Code Here

Examples of hudson.remoting.VirtualChannel

    public String getHostName() throws IOException, InterruptedException {
        if(hostNameCached)
            // in the worst case we end up having multiple threads computing the host name simultaneously, but that's not harmful, just wasteful.
            return cachedHostName;

        VirtualChannel channel = getChannel();
        if(channel==null)   return null; // can't compute right now

        for( String address : channel.call(new ListPossibleNames())) {
            try {
                InetAddress ia = InetAddress.getByName(address);
                if(!(ia instanceof Inet4Address)) {
                    LOGGER.fine(address+" is not an IPv4 address");
                    continue;
                }
                if(!ComputerPinger.checkIsReachable(ia, 3)) {
                    LOGGER.fine(address+" didn't respond to ping");
                    continue;
                }
                cachedHostName = ia.getCanonicalHostName();
                hostNameCached = true;
                return cachedHostName;
            } catch (IOException e) {
                // if a given name fails to parse on this host, we get this error
                LOGGER.log(Level.FINE, "Failed to parse "+address,e);
            }
        }

        // allow the administrator to manually specify the host name as a fallback. HUDSON-5373
        cachedHostName = channel.call(new GetFallbackName());
        hostNameCached = true;
        return cachedHostName;
    }
View Full Code Here

Examples of hudson.remoting.VirtualChannel

        // this is a debug probe and may expose sensitive information
        checkPermission(Jenkins.ADMINISTER);

        rsp.setContentType("text/plain");
        PrintWriter w = new PrintWriter(rsp.getCompressedWriter(req));
        VirtualChannel vc = getChannel();
        if (vc instanceof Channel) {
            w.println("Master to slave");
            ((Channel)vc).dumpExportTable(w);
            w.flush(); // flush here once so that even if the dump from the slave fails, the client gets some useful info

            w.println("\n\n\nSlave to master");
            w.print(vc.call(new DumpExportTableTask()));
        } else {
            w.println(Messages.Computer_BadChannel());
        }
        w.close();
    }
View Full Code Here

Examples of hudson.remoting.VirtualChannel

    /**
     * Gets the {@link FilePath} on this node.
     */
    public FilePath createPath(String absolutePath) {
        VirtualChannel ch = getChannel();
        if(ch==null)    return null;    // offline
        return new FilePath(ch,absolutePath);
    }
View Full Code Here

Examples of hudson.remoting.VirtualChannel

     * Obtains the list of killers.
     */
    /*package*/ final List<ProcessKiller> getKillers() throws InterruptedException {
        if (killers==null)
            try {
                VirtualChannel channelToMaster = SlaveComputer.getChannelToMaster();
                if (channelToMaster!=null) {
                    killers = channelToMaster.call(new Callable<List<ProcessKiller>, IOException>() {
                        public List<ProcessKiller> call() throws IOException {
                            return new ArrayList<ProcessKiller>(ProcessKiller.all());
                        }
                    });
                } else {
View Full Code Here

Examples of hudson.remoting.VirtualChannel

    protected void execute(TaskListener listener) throws IOException, InterruptedException {
        if (!enabled)   return;

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

Examples of hudson.remoting.VirtualChannel

    /**
     * Makes sure that the output flushing and {@link RemoteProc#join()} is synced.
     */
    @Bug(7809)
    public void testRemoteProcOutputSync() throws Exception {
        VirtualChannel ch = createSlaveChannel();

        // keep the pipe fairly busy
        final Pipe p = Pipe.createRemoteToLocal();
        for (int i=0; i<10; i++)
            ch.callAsync(new ChannelFiller(p.getOut()));
        new Thread() {
            @Override
            public void run() {
                try {
                    IOUtils.drain(p.getIn());
                } catch (IOException e) {
                }
            }
        }.start();

        RemoteLauncher launcher = new RemoteLauncher(StreamTaskListener.NULL, ch, true);

        String str="";
        for (int i=0; i<256; i++)
            str += "oxox";

        for (int i=0; i<1000; i++) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            launcher.launch().cmds("echo",str).stdout(baos).join();
            assertEquals(str, baos.toString().trim());
        }

        ch.close();
    }
View Full Code Here

Examples of hudson.remoting.VirtualChannel

    }

    private VirtualChannel createSlaveChannel() throws Exception {
        DumbSlave s = createSlave();
        s.toComputer().connect(false).get();
        VirtualChannel ch=null;
        while (ch==null) {
            ch = s.toComputer().getChannel();
            Thread.sleep(100);
        }
        return ch;
View Full Code Here

Examples of hudson.remoting.VirtualChannel

    public String getLabelString() {
        return Util.fixNull(label).trim();
    }

    public ClockDifference getClockDifference() throws IOException, InterruptedException {
        VirtualChannel channel = getChannel();
        if(channel==null)
            throw new IOException(getNodeName()+" is offline");

        long startTime = System.currentTimeMillis();
        long slaveTime = channel.call(new GetSystemTime());
        long endTime = System.currentTimeMillis();

        return new ClockDifference((startTime+endTime)/2 - slaveTime);
    }
View Full Code Here

Examples of hudson.remoting.VirtualChannel

    /**
     * Starts a new priviledge-escalated environment, execute a closure, and shut it down.
     */
    public static <V,T extends Throwable> V execute(TaskListener listener, String rootUsername, String rootPassword, final Callable<V, T> closure) throws T, IOException, InterruptedException {
        VirtualChannel ch = start(listener, rootUsername, rootPassword);
        try {
            return ch.call(closure);
        } finally {
            ch.close();
            ch.join(3000); // give some time for orderly shutdown, but don't block forever.
        }
    }
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.