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

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

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

Channel.callAsync介绍

暂无

代码示例

代码示例来源: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/maven-plugin

@Override
public void executeAsync(final BuildCallable<?,?> program) throws IOException {
  futures.add(
      channel.callAsync(
          new AsyncInvoker(core,program)));
}

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

@Override
  public void run(Channel channel) throws Exception, AssertionError {
    channel.callAsync(payload);
  }
};

代码示例来源:origin: org.jvnet.hudson.plugins/ivy

@Override
public void executeAsync(final BuildCallable<?, ?> program) throws IOException {
  futures.add(Channel.current().callAsync(new AsyncInvoker(core, program)));
}

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

@Override
public void executeAsync(final BuildCallable<?,?> program) throws IOException {
  futures.add(Channel.current().callAsync(new AsyncInvoker(core,program)));
}

代码示例来源:origin: org.hudsonci.plugins/ivy

@Override
public void executeAsync(final BuildCallable<?, ?> program) throws IOException {
  futures.add(Channel.current().callAsync(new AsyncInvoker(core, program)));
}

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

@Override
public void executeAsync(final BuildCallable<?,?> program) throws IOException {
  futures.add(Channel.current().callAsync(new AsyncInvoker(core,program)));
}

代码示例来源:origin: org.jenkins-ci.plugins/ivy

@Override
public void executeAsync(final BuildCallable<?,?> program) throws IOException {
  futures.add(Channel.current().callAsync(new AsyncInvoker(core,program)));
}

代码示例来源:origin: org.hudsonci.plugins/ivy

@Override
public void executeAsync(final BuildCallable<?,?> program) throws IOException {
  futures.add(Channel.current().callAsync(new AsyncInvoker(core,program)));
}

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

@Override
public void executeAsync(final BuildCallable<?,?> program) throws IOException {
  futures.add(Channel.current().callAsync(new AsyncInvoker(core,program)));
}

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

private void ping() throws IOException, InterruptedException {
  Future<?> f = channel.callAsync(new Ping());
  try {
    f.get(timeout,MILLISECONDS);
  } catch (ExecutionException e) {
    if (e.getCause() instanceof RequestAbortedException)
      return; // connection has shut down orderly.
    onDead();
  } catch (TimeoutException e) {
    onDead();
  }
}

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

private void ping() throws IOException, InterruptedException {
  Future<?> f = channel.callAsync(new Ping());
  try {
    f.get(timeout,MILLISECONDS);
  } catch (ExecutionException e) {
    if (e.getCause() instanceof RequestAbortedException)
      return; // connection has shut down orderly.
    onDead();
  } catch (TimeoutException e) {
    onDead();
  }
}

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

private void ping() throws IOException, InterruptedException {
  Future<?> f = channel.callAsync(new Ping());
  try {
    f.get(timeout,MILLISECONDS);
  } catch (ExecutionException e) {
    if (e.getCause() instanceof RequestAbortedException)
      return; // connection has shut down orderly.
    onDead();
  } catch (TimeoutException e) {
    onDead();
  }
}

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

@Override
public void executeAsync(final BuildCallable<?,?> program) throws IOException {
  recordAsynchronousExecution(Channel.current().callAsync(new AsyncInvoker(core,program)));
}

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

public void test1Async() throws Exception {
  Future<Integer> r = channel.callAsync(new Callable1());
  System.out.println("result="+r.get());
  assertEquals(5,(int)r.get());
}

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

public void test2Async() throws Exception {
  try {
    Future<Integer> r = channel.callAsync(new Callable2());
    r.get();
    fail();
  } catch (ExecutionException e) {
    assertEquals(e.getCause().getMessage(),"foo");
  }
}

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

public void testLocalWrite2() throws Exception {
  Pipe p = Pipe.createLocalToRemote();
  Future<Integer> f = channel.callAsync(new ReadingCallable(p));
  Thread.sleep(2000); // wait for remote to connect to local.
  write(p);
  int r = f.get();
  System.out.println("result=" + r);
  assertEquals(5,r);
}

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

/**
 * Test the "remote-write local-read" pipe.
 */
public void testRemoteWrite() throws Exception {
  Pipe p = Pipe.createRemoteToLocal();
  Future<Integer> f = channel.callAsync(new WritingCallable(p));
  read(p);
  int r = f.get();
  System.out.println("result=" + r);
  assertEquals(5,r);
}

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

/**
 * Test the "local-write remote-read" pipe.
 */
public void testLocalWrite() throws Exception {
  Pipe p = Pipe.createLocalToRemote();
  Future<Integer> f = channel.callAsync(new ReadingCallable(p));
  write(p);
  int r = f.get();
  System.out.println("result=" + r);
  assertEquals(5,r);
}

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

public void testWaitForRemoteProperty() throws Exception {
  Future<Void> f = channel.callAsync(new WaitForRemotePropertyCallable());
  assertEquals("bar", channel.waitForRemoteProperty("foo"));
  f.get(1, TimeUnit.SECONDS);
}

相关文章