hudson.remoting.Channel.setProperty()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(192)

本文整理了Java中hudson.remoting.Channel.setProperty()方法的一些代码示例,展示了Channel.setProperty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Channel.setProperty()方法的具体详情如下:
包路径:hudson.remoting.Channel
类名称:Channel
方法名:setProperty

Channel.setProperty介绍

[英]Sets the property value on this side of the channel.
[中]设置通道这一侧的特性值。

代码示例

代码示例来源:origin: jenkinsci/jenkins

@SuppressWarnings("deprecation")
  @Override
  protected void main(Channel channel) throws IOException, InterruptedException {
    // capture the identity given by the transport, since this can be useful for SecurityRealm.createCliAuthenticator()
    channel.setProperty(CLICommand.TRANSPORT_AUTHENTICATION, Jenkins.getAuthentication());
    channel.setProperty(CliEntryPoint.class.getName(), new CliManagerImpl(channel));
  }
};

代码示例来源:origin: jenkinsci/jenkins

public Void call() {
  SLAVE_LOG_HANDLER = new RingBufferLogHandler(ringBufferSize);
  // avoid double installation of the handler. JNLP agents can reconnect to the master multiple times
  // and each connection gets a different RemoteClassLoader, so we need to evict them by class name,
  // not by their identity.
  for (Handler h : LOGGER.getHandlers()) {
    if (h.getClass().getName().equals(SLAVE_LOG_HANDLER.getClass().getName()))
      LOGGER.removeHandler(h);
  }
  LOGGER.addHandler(SLAVE_LOG_HANDLER);
  // remove Sun PKCS11 provider if present. See http://wiki.jenkins-ci.org/display/JENKINS/Solaris+Issue+6276483
  try {
    Security.removeProvider("SunPKCS11-Solaris");
  } catch (SecurityException e) {
    // ignore this error.
  }
  try {
    getChannelOrFail().setProperty("slave",Boolean.TRUE); // indicate that this side of the channel is the agent side.
  } catch (ChannelClosedException e) {
    throw new IllegalStateException(e);
  }
  return null;
}
private static final long serialVersionUID = 1L;

代码示例来源:origin: jenkinsci/jenkins

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();
    }
  }

代码示例来源:origin: jenkinsci/jenkins

protected void execute(TaskListener listener) throws IOException, InterruptedException {
  if (!enabled)   return;
  long now = System.currentTimeMillis();
  for (Computer c: Jenkins.get().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 agent 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);
      }
    }
  }
}

代码示例来源:origin: jenkinsci/jenkins

PrintStream log = taskListener.getLogger();
channel.setProperty(SlaveComputer.class, this);

代码示例来源:origin: jenkinsci/remoting

public <T> T setProperty(ChannelProperty<T> key, T value) {
  return key.type.cast(setProperty((Object) key, value));
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

@SuppressWarnings("deprecation")
  @Override
  protected void main(Channel channel) throws IOException, InterruptedException {
    // capture the identity given by the transport, since this can be useful for SecurityRealm.createCliAuthenticator()
    channel.setProperty(CLICommand.TRANSPORT_AUTHENTICATION, Jenkins.getAuthentication());
    channel.setProperty(CliEntryPoint.class.getName(), new CliManagerImpl(channel));
  }
};

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

protected void main(Channel channel) throws IOException, InterruptedException {
    // capture the identity given by the transport, since this can be useful for SecurityRealm.createCliAuthenticator()
    channel.setProperty(CLICommand.TRANSPORT_AUTHENTICATION, getAuthentication());
    channel.setProperty(CliEntryPoint.class.getName(), new CliManagerImpl());
  }
});

代码示例来源:origin: hudson/hudson-2.x

protected void main(Channel channel) throws IOException, InterruptedException {
    // capture the identity given by the transport, since this can be useful for SecurityRealm.createCliAuthenticator()
    channel.setProperty(CLICommand.TRANSPORT_AUTHENTICATION, getAuthentication());
    channel.setProperty(CliEntryPoint.class.getName(), new CliManagerImpl());
  }
});

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

protected void main(Channel channel) throws IOException, InterruptedException {
    // capture the identity given by the transport, since this can be useful for SecurityRealm.createCliAuthenticator()
    channel.setProperty(CLICommand.TRANSPORT_AUTHENTICATION, getAuthentication());
    channel.setProperty(CliEntryPoint.class.getName(), new CliManagerImpl());
  }
});

代码示例来源:origin: org.eclipse.hudson/hudson-core

protected void main(Channel channel) throws IOException, InterruptedException {
    // capture the identity given by the transport, since this can be useful for SecurityRealm.createCliAuthenticator()
    channel.setProperty(CLICommand.TRANSPORT_AUTHENTICATION, getAuthentication());
    channel.setProperty(CliEntryPoint.class.getName(), new CliManagerImpl());
  }
});

代码示例来源:origin: jenkinsci/selenium-plugin

public String call() throws Exception {
  Logger log = Logger.getLogger(SelfRegisteringRemote.class.getName());
  Logger.getLogger("org").setLevel(Level.ALL);
  log.fine("instances " + PropertyUtils.getProperty(SeleniumConstants.PROPERTY_INSTANCE));
  SelfRegisteringRemote srr = PropertyUtils.getProperty(SeleniumConstants.PROPERTY_INSTANCE);
  String url = getRemoteURL(srr);
  srr.stopRemoteServer();
  Channel.current().setProperty(SeleniumConstants.PROPERTY_LOCK, new Object());
  return url;
}

代码示例来源:origin: jenkinsci/remoting

protected JarLoader getJarLoader(Channel channel) throws InterruptedException {
  JarLoader jl = channel.getProperty(JarLoader.THEIRS);
  if (jl==null) {// even if two threads run this simultaneously, it is harmless
    jl = (JarLoader) channel.waitForRemoteProperty(JarLoader.OURS);
    channel.setProperty(JarLoader.THEIRS,jl);
  }
  return jl;
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
 * 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();
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

/**
 * 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();
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

/**
 * 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();
}

代码示例来源:origin: hudson/hudson-2.x

/**
 * 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();
}

代码示例来源:origin: jenkinsci/remoting

public Void call() throws Exception {
    Thread.sleep(500);
    getChannelOrFail().setProperty("foo","bar");
    return null;
  }
}

代码示例来源:origin: jenkinsci/remoting

/**
 * Tests the use of user-defined classes in remote property access
 */
public void testRemoteProperty() throws Exception {
  // this test cannot run in the compatibility mode without the multi-classloader serialization support,
  // because it uses the class loader specified during proxy construction.
  if (channelRunner instanceof InProcessCompatibilityRunner)
    return;
  DummyClassLoader cl = new DummyClassLoader(TestCallable.class);
  Callable c = (Callable) cl.load(TestCallable.class);
  assertSame(c.getClass().getClassLoader(), cl);
  channel.setProperty("test",c);
  channel.call(new RemotePropertyVerifier());
}

代码示例来源:origin: jenkinsci/remoting

public void testGetSetProperty() throws Exception {
  channel.setProperty("foo","bar");
  assertEquals("bar", channel.getProperty("foo"));
  assertEquals("bar",channel.waitForProperty("foo"));
  ChannelProperty<Class> typedProp = new ChannelProperty<Class>(Class.class,"a type-safe property");
  channel.setProperty(typedProp, Void.class);
  assertEquals(Void.class, channel.getProperty(typedProp));
  assertEquals(Void.class, channel.waitForProperty(typedProp));
}

相关文章