本文整理了Java中hudson.remoting.Channel.getLastHeard()
方法的一些代码示例,展示了Channel.getLastHeard()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Channel.getLastHeard()
方法的具体详情如下:
包路径:hudson.remoting.Channel
类名称:Channel
方法名:getLastHeard
暂无
代码示例来源: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: hudson/hudson-2.x
protected void execute(TaskListener listener) throws IOException, InterruptedException {
if (!enabled) return;
long now = System.currentTimeMillis();
for (Computer c: Hudson.getInstance().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 slave 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: org.jenkins-ci.main/jenkins-core
protected void execute(TaskListener listener) throws IOException, InterruptedException {
if (!enabled) return;
long now = System.currentTimeMillis();
for (Computer c: Jenkins.getInstance().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: org.eclipse.hudson.main/hudson-core
protected void execute(TaskListener listener) throws IOException, InterruptedException {
if (!enabled) return;
long now = System.currentTimeMillis();
for (Computer c: Hudson.getInstance().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 slave 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: org.jvnet.hudson.main/hudson-core
protected void execute(TaskListener listener) throws IOException, InterruptedException {
if (!enabled) return;
long now = System.currentTimeMillis();
for (Computer c: Hudson.getInstance().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 slave 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: org.eclipse.hudson/hudson-core
protected void execute(TaskListener listener) throws IOException, InterruptedException {
if (!enabled) {
return;
}
long now = System.currentTimeMillis();
for (Computer c : Hudson.getInstance().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 slave 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);
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!