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

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

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

Channel.syncIO介绍

[英]Blocks until all the I/O packets sent before this gets fully executed by the remote side, then return.
[中]阻塞,直到远程端完全执行之前发送的所有I/O数据包,然后返回。

代码示例

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

public int join() throws InterruptedException, IOException {
  try {
    return p.join();
  } finally {
    // make sure I/O is delivered to the remote before we return
    Channel taskChannel = null;
    try {
      // Sync IO will fail automatically if the channel is being closed, no need to use getOpenChannelOrFail()
      // TODOL Replace by Channel#currentOrFail() when Remoting version allows
      taskChannel = Channel.current();
      if (taskChannel == null) {
        throw new IOException("No Remoting channel associated with this thread");
      }
      taskChannel.syncIO();
    } catch (Throwable t) {
      // this includes a failure to sync, agent.jar too old, etc
      LOGGER.log(Level.INFO, "Failed to synchronize IO streams on the channel " + taskChannel, t);
    }
  }
}

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

public int join() throws InterruptedException, IOException {
  try {
    return p.join();
  } finally {
    // make sure I/O is delivered to the remote before we return
    try {
      Channel.current().syncIO();
    } catch (Throwable t) {
      // this includes a failure to sync, agent.jar too old, etc
    }
  }
}

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

private void commandStreamTestSequence() throws Exception {
  north.syncIO(); // any synchronous RPC call would do
  assertTrue(getAttack().contains("eisenhower>south"));
    north.syncIO(); // transport_chunking hangs if this is 'south.syncIO', because somehow south

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

/**
 * If {@link ProxyWriter} gets garbage collected, it should unexport the entry but shouldn't try to close the stream.
 */
@Bug(20769)
public void testRemoteGC() throws InterruptedException, IOException {
  // in the legacy mode ProxyWriter will try to close the stream, so can't run this test
  if (channelRunner.getName().equals("local-compatibility"))
    return;
  StringWriter sw = new StringWriter() {
    @Override
    public void close() throws IOException {
      streamClosed = true;
    }
  };
  final RemoteWriter w = new RemoteWriter(sw);
  channel.call(new WeakReferenceCallable(w));
  // induce a GC. There's no good reliable way to do this,
  // and if GC doesn't happen within this loop, the test can pass
  // even when the underlying problem exists.
  for (int i=0; i<30; i++) {
    assertTrue("There shouldn't be any errors: " + log.toString(), log.size() == 0);
    Thread.sleep(100);
    if (channel.call(new GcCallable()))
      break;
  }
  channel.syncIO();
  assertFalse(streamClosed);
}

相关文章