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()); } } }
@Override public void heartbeat() { super.heartbeat(); if (!getUseThread()) sendPing(); }
protected void sendPingMessage(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 messageReceived(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); }//messageReceived
@Override public void run() { while (running) { try { sleep(interval); sendPing(); }catch ( InterruptedException ix ) { // Ignore. Probably triggered by a call to stop(). // In the highly unlikely event it was a different trigger, // simply ignore it and continue. }catch ( Exception x ) { log.warn("Unable to send ping from TCP ping thread.",x); } } } }
@Override public synchronized void start(int svc) throws ChannelException { super.start(svc); running = true; if ( thread == null && useThread) { thread = new PingThread(); thread.setDaemon(true); String channelName = ""; if (getChannel().getName() != null) channelName = "[" + getChannel().getName() + "]"; thread.setName("TcpPingInterceptor.PingThread" + channelName +"-"+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)next); if ( next instanceof StaticMembershipInterceptor ) staticMembers = new WeakReference<>((StaticMembershipInterceptor)next); next = next.getNext(); } }
@Override public synchronized void start(int svc) throws ChannelException { super.start(svc); running = true; if ( thread == null && useThread) { 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)next); if ( next instanceof StaticMembershipInterceptor ) staticMembers = new WeakReference<>((StaticMembershipInterceptor)next); next = next.getNext(); } }
protected void sendPingMessage(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()); data.setMessage(new XByteBuffer(TCP_PING_DATA, false)); try { super.sendMessage(members, data, null); }catch (ChannelException x) { log.warn("Unable to send TCP ping.",x); } }
@Override public void messageReceived(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); }//messageReceived
public void run() { while (running) { try { sleep(interval); sendPing(); }catch ( InterruptedException ix ) { interrupted(); }catch ( Exception x ) { log.warn("Unable to send ping from TCP ping thread.",x); } } } }
public synchronized void start(int svc) throws ChannelException { 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(); } }
protected void sendPingMessage(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()); data.setMessage(new XByteBuffer(TCP_PING_DATA, false)); try { super.sendMessage(members, data, null); }catch (ChannelException x) { log.warn("Unable to send TCP ping.",x); } }
@Override public void heartbeat() { super.heartbeat(); if (!getUseThread()) sendPing(); }
protected void sendPing() { TcpFailureDetector tcpFailureDetector = failureDetector != null ? failureDetector.get() : null; if (tcpFailureDetector != null) { // We have a reference to the failure detector // Piggy back on it tcpFailureDetector.checkMembers(true); } else { StaticMembershipInterceptor smi = staticOnly && staticMembers != null ? staticMembers.get() : null; if (smi != null) { sendPingMessage(smi.getMembers()); } else { sendPingMessage(getMembers()); } } }
@Override public void messageReceived(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); }//messageReceived
@Override public void run() { while (running) { try { sleep(interval); sendPing(); }catch ( InterruptedException ix ) { interrupted(); }catch ( Exception x ) { log.warn("Unable to send ping from TCP ping thread.",x); } } } }
@Override public synchronized void start(int svc) throws ChannelException { super.start(svc); running = true; if ( thread == null && useThread) { 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(); } }
protected void sendPingMessage(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()); data.setMessage(new XByteBuffer(TCP_PING_DATA, false)); try { super.sendMessage(members, data, null); }catch (ChannelException x) { log.warn(sm.getString("tcpPingInterceptor.ping.failed"),x); } }
@Override public void heartbeat() { super.heartbeat(); if (!getUseThread()) sendPing(); }
protected void sendPing() { TcpFailureDetector tcpFailureDetector = failureDetector != null ? failureDetector.get() : null; if (tcpFailureDetector != null) { // We have a reference to the failure detector // Piggy back on it tcpFailureDetector.checkMembers(true); } else { StaticMembershipInterceptor smi = staticOnly && staticMembers != null ? staticMembers.get() : null; if (smi != null) { sendPingMessage(smi.getMembers()); } else { sendPingMessage(getMembers()); } } }