@ManagedAttribute(description="Whether the node crash detection monitor is running") public boolean isNodeCrashMonitorRunning() {return isPingerThreadRunning(); } @ManagedAttribute(description="Whether or not to log suspect messages")
/** * Does *not* need to be synchronized on pinger_mutex because the caller (down()) already has the mutex acquired */ protected synchronized boolean startPingerThread() { if(!isPingerThreadRunning()) { ThreadFactory factory=getThreadFactory(); pinger_thread=factory.newThread(this, "FD_SOCK pinger"); pinger_thread.setDaemon(true); pinger_thread.start(); return true; } return false; }
/** * Interrupts the pinger thread. The Thread.interrupt() method doesn't seem to work under Linux with JDK 1.3.1 * (JDK 1.2.2 had no problems here), therefore we close the socket (setSoLinger has to be set !) if we are * running under Linux. This should be tested under Windows. (Solaris 8 and JDK 1.3.1 definitely works).<p> * Oct 29 2001 (bela): completely removed Thread.interrupt(), but used socket close on all OSs. This makes this * code portable and we don't have to check for OSs.<p/> */ protected synchronized void interruptPingerThread(boolean sendTerminationSignal) { if(isPingerThreadRunning()) { regular_sock_close=true; if (sendTerminationSignal) { sendPingTermination(); // PATCH by Bruce Schuchardt (http://jira.jboss.com/jira/browse/JGRP-246) } teardownPingSocket(); // will wake up the pinger thread. less elegant than Thread.interrupt(), but does the job } }
/** Attempts to obtain the ping_addr first from the cache, then by unicasting q request to {@code mbr}, then by multicasting a request to all members. */ protected IpAddress fetchPingAddress(final Address mbr) { IpAddress ret; if(mbr == null) return null; // 1. Try to get the server socket address from the cache if((ret=cache.get(mbr)) != null) return ret; if(!isPingerThreadRunning()) return null; // 2. Try to get the server socket address from mbr (or all, as fallback) ping_addr_promise.reset(); for(Address dest: Arrays.asList(mbr, null)) { Message msg=new Message(dest).setFlag(Message.Flag.INTERNAL) .putHeader(this.id, new FdHeader(FdHeader.WHO_HAS_SOCK, mbr)); down_prot.down(msg); if((ret=ping_addr_promise.getResult(500)) != null) return ret; if(!isPingerThreadRunning()) return null; } return null; }
regular_sock_close=false; if(ping_dest == null || !isPingerThreadRunning()) break; log.debug("%s: pingable_mbrs=%s, ping_dest=%s", local_addr, pingable_mbrs, ping_dest); if(!setupPingSocket(ping_addr) && isPingerThreadRunning()) {
/** * Determines coordinator C. If C is null and we are the first member, return. Else loop: send GET_CACHE message * to coordinator and wait for GET_CACHE_RSP response. Loop until valid response has been received. */ protected void getCacheFromCoordinator() { Address coord; int attempts=num_tries; get_cache_promise.reset(); while(attempts > 0 && isPingerThreadRunning()) { if((coord=determineCoordinator()) != null) { if(coord.equals(local_addr)) { // we are the first member --> empty cache return; } Message msg=new Message(coord).setFlag(Message.Flag.INTERNAL) .putHeader(this.id, new FdHeader(FdHeader.GET_CACHE)); down_prot.down(msg); Map<Address,IpAddress> result=get_cache_promise.getResult(get_cache_timeout); if(result != null) { cache.addAll(result); log.trace("%s: got cache from %s: cache is %s", local_addr, coord, cache); return; } } --attempts; } }
@ManagedAttribute(description="Whether the node crash detection monitor is running") public boolean isNodeCrashMonitorRunning() {return isPingerThreadRunning(); } @ManagedAttribute(description="Whether or not to log suspect messages")
/** * Does *not* need to be synchronized on pinger_mutex because the caller (down()) already has the mutex acquired */ protected synchronized boolean startPingerThread() { if(!isPingerThreadRunning()) { ThreadFactory factory=getThreadFactory(); pinger_thread=factory.newThread(this, "FD_SOCK pinger"); pinger_thread.setDaemon(true); pinger_thread.start(); return true; } return false; }
/** * Interrupts the pinger thread. The Thread.interrupt() method doesn't seem to work under Linux with JDK 1.3.1 * (JDK 1.2.2 had no problems here), therefore we close the socket (setSoLinger has to be set !) if we are * running under Linux. This should be tested under Windows. (Solaris 8 and JDK 1.3.1 definitely works).<p> * Oct 29 2001 (bela): completely removed Thread.interrupt(), but used socket close on all OSs. This makes this * code portable and we don't have to check for OSs.<p/> */ protected synchronized void interruptPingerThread(boolean sendTerminationSignal) { if(isPingerThreadRunning()) { regular_sock_close=true; if (sendTerminationSignal) { sendPingTermination(); // PATCH by Bruce Schuchardt (http://jira.jboss.com/jira/browse/JGRP-246) } teardownPingSocket(); // will wake up the pinger thread. less elegant than Thread.interrupt(), but does the job } }
/** Attempts to obtain the ping_addr first from the cache, then by unicasting q request to {@code mbr}, then by multicasting a request to all members. */ protected IpAddress fetchPingAddress(final Address mbr) { IpAddress ret; if(mbr == null) return null; // 1. Try to get the server socket address from the cache if((ret=cache.get(mbr)) != null) return ret; if(!isPingerThreadRunning()) return null; // 2. Try to get the server socket address from mbr (or all, as fallback) ping_addr_promise.reset(); for(Address dest: Arrays.asList(mbr, null)) { Message msg=new Message(dest).setFlag(Message.Flag.INTERNAL) .putHeader(this.id, new FdHeader(FdHeader.WHO_HAS_SOCK, mbr)); down_prot.down(msg); if((ret=ping_addr_promise.getResult(500)) != null) return ret; if(!isPingerThreadRunning()) return null; } return null; }
regular_sock_close=false; if(ping_dest == null || !isPingerThreadRunning()) break; log.debug("%s: pingable_mbrs=%s, ping_dest=%s", local_addr, pingable_mbrs, ping_dest); if(!setupPingSocket(ping_addr) && isPingerThreadRunning()) {
/** * Determines coordinator C. If C is null and we are the first member, return. Else loop: send GET_CACHE message * to coordinator and wait for GET_CACHE_RSP response. Loop until valid response has been received. */ protected void getCacheFromCoordinator() { Address coord; int attempts=num_tries; get_cache_promise.reset(); while(attempts > 0 && isPingerThreadRunning()) { if((coord=determineCoordinator()) != null) { if(coord.equals(local_addr)) { // we are the first member --> empty cache return; } Message msg=new Message(coord).setFlag(Message.Flag.INTERNAL) .putHeader(this.id, new FdHeader(FdHeader.GET_CACHE)); down_prot.down(msg); Map<Address,IpAddress> result=get_cache_promise.getResult(get_cache_timeout); if(result != null) { cache.addAll(result); log.trace("%s: got cache from %s: cache is %s", local_addr, coord, cache); return; } } --attempts; } }