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

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

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

Channel.getLastHeard介绍

暂无

代码示例

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

  1. protected void execute(TaskListener listener) throws IOException, InterruptedException {
  2. if (!enabled) return;
  3. long now = System.currentTimeMillis();
  4. for (Computer c: Jenkins.get().getComputers()) {
  5. VirtualChannel ch = c.getChannel();
  6. if (ch instanceof Channel) {
  7. Channel channel = (Channel) ch;
  8. if (now-channel.getLastHeard() > TIME_TILL_PING) {
  9. // haven't heard from this agent for a while.
  10. Long lastPing = (Long)channel.getProperty(ConnectionActivityMonitor.class);
  11. if (lastPing!=null && now-lastPing > TIMEOUT) {
  12. LOGGER.info("Repeated ping attempts failed on "+c.getName()+". Disconnecting");
  13. c.disconnect(OfflineCause.create(Messages._ConnectionActivityMonitor_OfflineCause()));
  14. } else {
  15. // send a ping. if we receive a reply, it will be reflected in the next getLastHeard() call.
  16. channel.callAsync(PING_COMMAND);
  17. if (lastPing==null)
  18. channel.setProperty(ConnectionActivityMonitor.class,now);
  19. }
  20. } else {
  21. // we are receiving data nicely
  22. channel.setProperty(ConnectionActivityMonitor.class,null);
  23. }
  24. }
  25. }
  26. }

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

  1. protected void execute(TaskListener listener) throws IOException, InterruptedException {
  2. if (!enabled) return;
  3. long now = System.currentTimeMillis();
  4. for (Computer c: Hudson.getInstance().getComputers()) {
  5. VirtualChannel ch = c.getChannel();
  6. if (ch instanceof Channel) {
  7. Channel channel = (Channel) ch;
  8. if (now-channel.getLastHeard() > TIME_TILL_PING) {
  9. // haven't heard from this slave for a while.
  10. Long lastPing = (Long)channel.getProperty(ConnectionActivityMonitor.class);
  11. if (lastPing!=null && now-lastPing > TIMEOUT) {
  12. LOGGER.info("Repeated ping attempts failed on "+c.getName()+". Disconnecting");
  13. c.disconnect(OfflineCause.create(Messages._ConnectionActivityMonitor_OfflineCause()));
  14. } else {
  15. // send a ping. if we receive a reply, it will be reflected in the next getLastHeard() call.
  16. channel.callAsync(PING_COMMAND);
  17. if (lastPing==null)
  18. channel.setProperty(ConnectionActivityMonitor.class,now);
  19. }
  20. } else {
  21. // we are receiving data nicely
  22. channel.setProperty(ConnectionActivityMonitor.class,null);
  23. }
  24. }
  25. }
  26. }

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

  1. protected void execute(TaskListener listener) throws IOException, InterruptedException {
  2. if (!enabled) return;
  3. long now = System.currentTimeMillis();
  4. for (Computer c: Jenkins.getInstance().getComputers()) {
  5. VirtualChannel ch = c.getChannel();
  6. if (ch instanceof Channel) {
  7. Channel channel = (Channel) ch;
  8. if (now-channel.getLastHeard() > TIME_TILL_PING) {
  9. // haven't heard from this agent for a while.
  10. Long lastPing = (Long)channel.getProperty(ConnectionActivityMonitor.class);
  11. if (lastPing!=null && now-lastPing > TIMEOUT) {
  12. LOGGER.info("Repeated ping attempts failed on "+c.getName()+". Disconnecting");
  13. c.disconnect(OfflineCause.create(Messages._ConnectionActivityMonitor_OfflineCause()));
  14. } else {
  15. // send a ping. if we receive a reply, it will be reflected in the next getLastHeard() call.
  16. channel.callAsync(PING_COMMAND);
  17. if (lastPing==null)
  18. channel.setProperty(ConnectionActivityMonitor.class,now);
  19. }
  20. } else {
  21. // we are receiving data nicely
  22. channel.setProperty(ConnectionActivityMonitor.class,null);
  23. }
  24. }
  25. }
  26. }

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

  1. protected void execute(TaskListener listener) throws IOException, InterruptedException {
  2. if (!enabled) return;
  3. long now = System.currentTimeMillis();
  4. for (Computer c: Hudson.getInstance().getComputers()) {
  5. VirtualChannel ch = c.getChannel();
  6. if (ch instanceof Channel) {
  7. Channel channel = (Channel) ch;
  8. if (now-channel.getLastHeard() > TIME_TILL_PING) {
  9. // haven't heard from this slave for a while.
  10. Long lastPing = (Long)channel.getProperty(ConnectionActivityMonitor.class);
  11. if (lastPing!=null && now-lastPing > TIMEOUT) {
  12. LOGGER.info("Repeated ping attempts failed on "+c.getName()+". Disconnecting");
  13. c.disconnect(OfflineCause.create(Messages._ConnectionActivityMonitor_OfflineCause()));
  14. } else {
  15. // send a ping. if we receive a reply, it will be reflected in the next getLastHeard() call.
  16. channel.callAsync(PING_COMMAND);
  17. if (lastPing==null)
  18. channel.setProperty(ConnectionActivityMonitor.class,now);
  19. }
  20. } else {
  21. // we are receiving data nicely
  22. channel.setProperty(ConnectionActivityMonitor.class,null);
  23. }
  24. }
  25. }
  26. }

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

  1. protected void execute(TaskListener listener) throws IOException, InterruptedException {
  2. if (!enabled) return;
  3. long now = System.currentTimeMillis();
  4. for (Computer c: Hudson.getInstance().getComputers()) {
  5. VirtualChannel ch = c.getChannel();
  6. if (ch instanceof Channel) {
  7. Channel channel = (Channel) ch;
  8. if (now-channel.getLastHeard() > TIME_TILL_PING) {
  9. // haven't heard from this slave for a while.
  10. Long lastPing = (Long)channel.getProperty(ConnectionActivityMonitor.class);
  11. if (lastPing!=null && now-lastPing > TIMEOUT) {
  12. LOGGER.info("Repeated ping attempts failed on "+c.getName()+". Disconnecting");
  13. c.disconnect(OfflineCause.create(Messages._ConnectionActivityMonitor_OfflineCause()));
  14. } else {
  15. // send a ping. if we receive a reply, it will be reflected in the next getLastHeard() call.
  16. channel.callAsync(PING_COMMAND);
  17. if (lastPing==null)
  18. channel.setProperty(ConnectionActivityMonitor.class,now);
  19. }
  20. } else {
  21. // we are receiving data nicely
  22. channel.setProperty(ConnectionActivityMonitor.class,null);
  23. }
  24. }
  25. }
  26. }

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

  1. protected void execute(TaskListener listener) throws IOException, InterruptedException {
  2. if (!enabled) {
  3. return;
  4. }
  5. long now = System.currentTimeMillis();
  6. for (Computer c : Hudson.getInstance().getComputers()) {
  7. VirtualChannel ch = c.getChannel();
  8. if (ch instanceof Channel) {
  9. Channel channel = (Channel) ch;
  10. if (now - channel.getLastHeard() > TIME_TILL_PING) {
  11. // haven't heard from this slave for a while.
  12. Long lastPing = (Long) channel.getProperty(ConnectionActivityMonitor.class);
  13. if (lastPing != null && now - lastPing > TIMEOUT) {
  14. LOGGER.info("Repeated ping attempts failed on " + c.getName() + ". Disconnecting");
  15. c.disconnect(OfflineCause.create(Messages._ConnectionActivityMonitor_OfflineCause()));
  16. } else {
  17. // send a ping. if we receive a reply, it will be reflected in the next getLastHeard() call.
  18. channel.callAsync(PING_COMMAND);
  19. if (lastPing == null) {
  20. channel.setProperty(ConnectionActivityMonitor.class, now);
  21. }
  22. }
  23. } else {
  24. // we are receiving data nicely
  25. channel.setProperty(ConnectionActivityMonitor.class, null);
  26. }
  27. }
  28. }
  29. }

相关文章