/** * 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((coord=determineCoordinator()) != null) { if(coord.equals(local_addr)) { // we are the first member --> empty cache if(log.isDebugEnabled()) log.debug("first member; cache is empty");
/** * 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; } }