Methods Summary |
---|
public long | getInterval()
return interval;
|
public boolean | getStaticOnly()
return staticOnly;
|
public boolean | getUseThread()
return useThread;
|
public void | heartbeat()
super.heartbeat();
if (!getUseThread()) sendPing();
|
public void | messageReceived(org.apache.catalina.tribes.ChannelMessage msg)
//catch incoming
boolean process = true;
if ( okToProcess(msg.getOptions()) ) {
//check to see if it is a ping message, if so, process = false
process = ( (msg.getMessage().getLength() != TCP_PING_DATA.length) ||
(!Arrays.equals(TCP_PING_DATA,msg.getMessage().getBytes()) ) );
}//end if
//ignore the message, it doesnt have the flag set
if ( process ) super.messageReceived(msg);
else if ( log.isDebugEnabled() ) log.debug("Received a TCP ping packet:"+msg);
|
protected void | sendPing()
if (failureDetector.get()!=null) {
//we have a reference to the failure detector
//piggy back on that dude
failureDetector.get().checkMembers(true);
}else {
if (staticOnly && staticMembers.get()!=null) {
sendPingMessage(staticMembers.get().getMembers());
} else {
sendPingMessage(getMembers());
}
}
|
protected void | sendPingMessage(org.apache.catalina.tribes.Member[] members)
if ( members == null || members.length == 0 ) return;
ChannelData data = new ChannelData(true);//generates a unique Id
data.setAddress(getLocalMember(false));
data.setTimestamp(System.currentTimeMillis());
data.setOptions(getOptionFlag());
try {
super.sendMessage(members, data, null);
}catch (ChannelException x) {
log.warn("Unable to send TCP ping.",x);
}
|
public void | setInterval(long interval)
this.interval = interval;
|
public void | setStaticOnly(boolean staticOnly)
this.staticOnly = staticOnly;
|
public void | setUseThread(boolean useThread)
this.useThread = useThread;
|
public synchronized void | start(int svc)
super.start(svc);
running = true;
if ( thread == null ) {
thread = new PingThread();
thread.setDaemon(true);
thread.setName("TcpPingInterceptor.PingThread-"+cnt.addAndGet(1));
thread.start();
}
//acquire the interceptors to invoke on send ping events
ChannelInterceptor next = getNext();
while ( next != null ) {
if ( next instanceof TcpFailureDetector )
failureDetector = new WeakReference<TcpFailureDetector>((TcpFailureDetector)next);
if ( next instanceof StaticMembershipInterceptor )
staticMembers = new WeakReference<StaticMembershipInterceptor>((StaticMembershipInterceptor)next);
next = next.getNext();
}
|
public void | stop(int svc)
running = false;
if ( thread != null ) thread.interrupt();
thread = null;
super.stop(svc);
|