Package org.jgroups.util

Examples of org.jgroups.util.Rsp


            else if(suspects.contains(sender)) {
                if(log.isWarnEnabled())
                    log.warn("received response from suspected member " + sender + "; discarding");
            }         
            else {
                Rsp rsp=requests.get(sender);               
                if(rsp != null) {
                    if(!rsp.wasReceived()) {
                        boolean responseReceived =(rsp_filter == null) || rsp_filter.isAcceptable(response_value, sender);
                        rsp.setValue(response_value);
                        rsp.setReceived(responseReceived);
                        if(log.isTraceEnabled())
                            log.trace(new StringBuilder("received response for request ").append(req_id)
                                                                                         .append(", sender=")
                                                                                         .append(sender)
                                                                                         .append(", val=")
View Full Code Here


            return;

        lock.lock();
        try {
            addSuspect(suspected_member);
            Rsp rsp=requests.get(suspected_member);
            if(rsp != null) {
                rsp.setSuspected(true);
                rsp.setValue(null);
                completed.signalAll();
            }
        }
        finally {
            lock.unlock();
View Full Code Here

                return;

            this.members.clear();
            this.members.addAll(mbrs);

            Rsp rsp;
            Set<Address> tmp=null;
            for(Map.Entry<Address,Rsp> entry: requests.entrySet()) {
                mbr=entry.getKey();
                if(!mbrs.contains(mbr)) {
                    if(tmp == null)
                        tmp=new HashSet<Address>();
                    tmp.add(mbr);
                    addSuspect(mbr);
                    rsp=entry.getValue();
                    rsp.setValue(null);
                    rsp.setSuspected(true);
                }
            }

            if(tmp != null) {
                for(Address suspect: tmp) {
View Full Code Here

        try {
            if(!requests.isEmpty()) {
                ret.append("entries:\n");
                for(Map.Entry<Address,Rsp> entry: requests.entrySet()) {
                    Address mbr=entry.getKey();
                    Rsp rsp=entry.getValue();
                    ret.append(mbr).append(": ").append(rsp).append("\n");
                }
            }
        }
        finally {
View Full Code Here

    private void adjustMembership() {
        if(requests.isEmpty())
            return;

        Address mbr;
        Rsp rsp;
        for(Map.Entry<Address,Rsp> entry: requests.entrySet()) {
            mbr=entry.getKey();
            if((!this.members.contains(mbr)) || suspects.contains(mbr)) {
                addSuspect(mbr);
                rsp=entry.getValue();
                rsp.setValue(null);
                rsp.setSuspected(true);
            }
        }
    }
View Full Code Here

        this.req_id=getRequestId()
        this.timeout=timeout;
        this.expected_mbrs=expected_mbrs;
        if(mbrs != null) {           
            for(Address mbr: mbrs) {
                requests.put(mbr, new Rsp(mbr));
            }           
            this.members.clear();
            this.members.addAll(mbrs);
        }
    }
View Full Code Here

               if (retval == null) {
                  Object response = objectFuture.get();
                  if (trace) log.tracef("Received response: %s from %s", response, sender);
                  filter.isAcceptable(response, sender);
                  if (!filter.needMoreResponses()) {
                     retval = new RspList(Collections.singleton(new Rsp(sender, response)));
                     done = true;
                     //TODO cancel other tasks?
                  }
               } else {
                  if (trace) log.tracef("Skipping response from %s since a valid response for this request has already been received", sender);
View Full Code Here

     */
    public Object sendMessage(Message msg, int mode, long timeout) throws TimeoutException, SuspectedException {
        Vector mbrs=new Vector();
        RspList rsp_list=null;
        Object dest=msg.getDest();
        Rsp rsp;
        GroupRequest _req=null;

        if(dest == null) {
            if(log.isErrorEnabled())
                log.error("the message's destination is null, cannot send message");
            return null;
        }

        mbrs.addElement(dest);   // dummy membership (of destination address)

        _req=new GroupRequest(msg, corr, mbrs, mode, timeout, 0);
        _req.setCaller(local_addr);
        try {
            _req.execute();
        }
        catch(Exception t) {
            throw new RuntimeException("failed executing request " + _req, t);
        }

        if(mode == GroupRequest.GET_NONE) {
            return null;
        }

        rsp_list=_req.getResults();

        if(rsp_list.isEmpty()) {
            if(log.isWarnEnabled())
                log.warn(" response list is empty");
            return null;
        }
        if(rsp_list.size() > 1) {
            if(log.isWarnEnabled())
                log.warn("response list contains more that 1 response; returning first response !");
        }
        rsp=(Rsp)rsp_list.elementAt(0);
        if(rsp.wasSuspected()) {
            throw new SuspectedException(dest);
        }
        if(!rsp.wasReceived()) {
            throw new TimeoutException("timeout sending message to " + dest);
        }
        return rsp.getValue();
    }
View Full Code Here

       {          
         Iterator iter = rspList.values().iterator();
        
         while (iter.hasNext())
         {
           Rsp rsp = (Rsp)iter.next();
          
           if (!rsp.wasReceived())
           {
              // https://jira.jboss.org/jira/browse/JBMESSAGING-1657
                  if (!rsp.wasSuspected())
                  {
                     throw new IllegalStateException(this + " response not received from " + rsp.getSender() + " - there may be others");
                  }
           }
         }   
       }
     }
View Full Code Here

       {          
         Iterator iter = rspList.values().iterator();
        
         while (iter.hasNext())
         {
           Rsp rsp = (Rsp)iter.next();
          
           if (!rsp.wasReceived())
           {
             throw new IllegalStateException(this + " response not received from " + rsp.getSender() + " - there may be others");
           }
         }   
       }
     }
   }
View Full Code Here

TOP

Related Classes of org.jgroups.util.Rsp

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.