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

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

本文整理了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

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

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

  1. public int join() throws InterruptedException, IOException {
  2. try {
  3. return p.join();
  4. } finally {
  5. // make sure I/O is delivered to the remote before we return
  6. try {
  7. Channel.current().syncIO();
  8. } catch (Throwable t) {
  9. // this includes a failure to sync, agent.jar too old, etc
  10. }
  11. }
  12. }

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

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

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

  1. /**
  2. * If {@link ProxyWriter} gets garbage collected, it should unexport the entry but shouldn't try to close the stream.
  3. */
  4. @Bug(20769)
  5. public void testRemoteGC() throws InterruptedException, IOException {
  6. // in the legacy mode ProxyWriter will try to close the stream, so can't run this test
  7. if (channelRunner.getName().equals("local-compatibility"))
  8. return;
  9. StringWriter sw = new StringWriter() {
  10. @Override
  11. public void close() throws IOException {
  12. streamClosed = true;
  13. }
  14. };
  15. final RemoteWriter w = new RemoteWriter(sw);
  16. channel.call(new WeakReferenceCallable(w));
  17. // induce a GC. There's no good reliable way to do this,
  18. // and if GC doesn't happen within this loop, the test can pass
  19. // even when the underlying problem exists.
  20. for (int i=0; i<30; i++) {
  21. assertTrue("There shouldn't be any errors: " + log.toString(), log.size() == 0);
  22. Thread.sleep(100);
  23. if (channel.call(new GcCallable()))
  24. break;
  25. }
  26. channel.syncIO();
  27. assertFalse(streamClosed);
  28. }

相关文章