/** * Causes all waiting threads to return */ public void reset() { reset(true); }
public synchronized AckCollector reset(Collection<Address> expected_acks, Address ... exclude) { suspected_mbrs.clear(); missing_acks.clear(); addAll(expected_acks, exclude); all_acks_received.reset(); return this; }
public synchronized void reset(Collection<Address> members) { suspected_mbrs.clear(); missing_acks.clear(); addAll(members); all_acks_received.reset(); }
public synchronized AckCollector reset(Collection<Address> expected_acks, Collection<Address> exclude) { suspected_mbrs.clear(); missing_acks.clear(); addAll(expected_acks, exclude); all_acks_received.reset(); return this; }
public void init() throws Exception { super.init(); leave_promise.reset(); }
public void init() throws Exception { super.init(); join_promise.reset(); }
public T getResultWithTimeout(long timeout, boolean reset) throws TimeoutException { if(!reset) return _getResultWithTimeout(timeout); // the lock is acquired because we want to get the result and reset the promise in the same lock scope; if we had // to re-acquire the lock for reset(), some other thread could possibly set a new result before reset() is called ! lock.lock(); try { return _getResultWithTimeout(timeout); } finally { reset(); lock.unlock(); } }
private void waitForUnblock() { try { flush_unblock_promise.reset(); flush_unblock_promise.getResultWithTimeout(end_flush_timeout); } catch (TimeoutException t) { if (log.isWarnEnabled()) log.warn(localAddress + ": waiting for UNBLOCK timed out after " + end_flush_timeout + " ms"); } }
forward_table.put(seqno, msg); while(running && !flushing) { ack_promise.reset(); forward(msg, seqno, true); if(!ack_mode || !running || flushing)
private void startFlush(List<Address> flushParticipants) { if (!flushInProgress.get()) { flush_promise.reset(); synchronized(sharedLock) { if(flushParticipants == null)
/** * Sends a leave request to coord and blocks until a leave response has been received, or the leave timeout has elapsed */ protected void sendLeaveReqTo(Address coord) { leave_promise.reset(); leaving=true; log.trace("%s: sending LEAVE request to %s", gms.local_addr, coord); long start=System.currentTimeMillis(); sendLeaveMessage(coord, gms.local_addr); Boolean result=leave_promise.getResult(gms.leave_timeout); long time=System.currentTimeMillis()-start; if(result != null) log.trace("%s: got LEAVE response from %s in %d ms", gms.local_addr, coord, time); else log.trace("%s: timed out waiting for LEAVE response from %s (after %d ms)", gms.local_addr, coord, time); }
System.out.printf("."); promise.reset(false); byte[] req_buf=new byte[PAYLOAD]; req_buf[0]=REQ;
state_promise.reset(); StateTransferInfo state_info=new StateTransferInfo(target, timeout); long start=System.currentTimeMillis();
if(log.isTraceEnabled()) log.trace(local_addr + ": flushing (forwarding) " + "::" + key + " to target " + target); ack_promise.reset(); down_prot.down(forward_msg); Long ack=ack_promise.getResult(500);
flush_promise.reset(); ArrayList<Address> flushParticipants = null; synchronized (sharedLock) {
/** 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; }
/** * 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; } }
if(log.isTraceEnabled()) log.trace(local_addr + ": flushing (forwarding) " + local_addr + "::" + key + " to coord " + coord); ack_promise.reset(); down_prot.down(forward_msg); Long ack=ack_promise.getResult(500);
long join_attempts=0; leaving=false; join_promise.reset();
public synchronized AckCollector reset(Collection<Address> expected_acks, Address ... exclude) { suspected_mbrs.clear(); missing_acks.clear(); addAll(expected_acks, exclude); all_acks_received.reset(); return this; }