Package org.jgroups.util

Examples of org.jgroups.util.RspList


        if(dests != null && dests.isEmpty()) {
            // don't send if dest list is empty
            if(log.isTraceEnabled())
                log.trace(new StringBuilder("destination list of ").append(method_call.getName()).
                        append("() is empty: no need to send message"));
            return new RspList();
        }

        if(log.isTraceEnabled())
            log.trace(new StringBuilder("dests=").append(dests).append(", method_call=").append(method_call).
                    append(", mode=").append(mode).append(", timeout=").append(timeout));

        Object buf;
        try {
            buf=req_marshaller != null? req_marshaller.objectToBuffer(method_call) : Util.objectToByteBuffer(method_call);
        }
        catch(Exception e) {
            // if(log.isErrorEnabled()) log.error("exception", e);
            // we will change this in 2.4 to add the exception to the signature
            // (see http://jira.jboss.com/jira/browse/JGRP-193). The reason for a RTE is that we cannot change the
            // signature in 2.3, otherwise 2.3 would be *not* API compatible to prev releases
            throw new RuntimeException("failure to marshal argument(s)", e);
        }

        Message msg=new Message();
        if(buf instanceof Buffer)
            msg.setBuffer((Buffer)buf);
        else
            msg.setBuffer((byte[])buf);
        if(oob)
            msg.setFlag(Message.OOB);
        RspList  retval=super.castMessage(dests, msg, mode, timeout, use_anycasting, filter);
        if(log.isTraceEnabled()) log.trace("responses: " + retval);
        return retval;
    }
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

            log.trace("real_dests=" + real_dests);

        if(real_dests.isEmpty()) {
            if(log.isTraceEnabled())
                log.trace("destination list is empty, won't send message");
            return new RspList(); // return empty response list
        }

        _req=new GroupRequest(msg, corr, real_dests, mode, timeout, 0);
        _req.setCaller(this.local_addr);
        _req.setResponseFilter(filter);
View Full Code Here

     * Sends a message to a single member (destination = msg.dest) and returns the response. The message's destination
     * must be non-zero !
     */
    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);
View Full Code Here

      if (trace)
      {
         this.log.trace("calling synchronous method on cluster, serviceName="+serviceName
            +", methodName="+methodName+", members="+this.groupView+", excludeSelf="+excludeSelf);
      }
      RspList rsp = this.dispatcher.callRemoteMethods(null, m, ro);
      ArrayList<T> result = this.processResponseList(rsp, returnType, trace);
     
      if (!excludeSelf && this.directlyInvokeLocal && (filter == null || filter.needMoreResponses()))
      {
         try
View Full Code Here

     {      
       if (trace) { log.trace(this + " multicasting " + request + " to control channel, sync=" + sync); }
 
       Message message = new Message(null, null, writeRequest(request));

       RspList rspList =
         dispatcher.castMessage(null, message, sync ? GroupRequest.GET_ALL: GroupRequest.GET_NONE, castTimeout)
      
       if (sync)
       {          
         Iterator iter = rspList.values().iterator();
        
         while (iter.hasNext())
         {
           Rsp rsp = (Rsp)iter.next();
          
View Full Code Here

       Message message = new Message(address, null, writeRequest(request));

       Vector v = new Vector();
       v.add(address);
      
       RspList rspList =
         dispatcher.castMessage(v, message, sync ? GroupRequest.GET_ALL: GroupRequest.GET_NONE, castTimeout)
      
       if (sync)
       {          
         Iterator iter = rspList.values().iterator();
        
         while (iter.hasNext())
         {
           Rsp rsp = (Rsp)iter.next();
          
View Full Code Here

      }
      catch (Exception e)
      {
         throw new RPCException("Could not call the method Message.setObject");
      }
      RspList rsps = SecurityHelper.doPrivilegedAction(new PrivilegedAction<RspList>()
      {
         public RspList run()
         {
            return dispatcher.castMessage(dests, msg, synchronous ? GroupRequest.GET_ALL : GroupRequest.GET_NONE,
               timeout);
         }
      });

      if (LOG.isTraceEnabled())
         LOG.trace("responses: " + rsps);
      if (rsps == null)
         throw new RPCException("Could not get the responses for command " + commandId + ".");
      if (!synchronous)
         return Collections.emptyList();// async case
      if (LOG.isTraceEnabled())
      {
         LOG.trace("(" + channel.getLocalAddress() + "): responses for command " + commandId + ":\n" + rsps);
      }
      List<Object> retval = new ArrayList<Object>(rsps.size());
      for (Address dest : dests)
      {
         Rsp rsp = rsps.get(dest);
         if (rsp == null || (rsp.wasSuspected() && !rsp.wasReceived()))
         {
            // The corresponding member has left
            retval.add(new MemberHasLeftException("No response for the member " + dest
               + ", this member has probably left the cluster."));
View Full Code Here

        boolean trace = this.log.isTraceEnabled();
        if (trace) {
            this.log.trace("calling synchronous method on cluster, serviceName=" + serviceName + ", methodName=" + methodName
                    + ", members=" + this.groupView + ", excludeSelf=" + excludeSelf);
        }
        RspList rsp = this.dispatcher.callRemoteMethods(null, m, ro);
        ArrayList<T> result = this.processResponseList(rsp, returnType, trace);

        if (!excludeSelf && this.directlyInvokeLocal && (filter == null || filter.needMoreResponses())) {
            try {
                invokeDirectly(serviceName, methodName, args, types, returnType, result, filter);
View Full Code Here

   {
      if (dests != null && dests.isEmpty())
      {
         // don't send if dest list is empty
         if (trace) log.trace("Destination list is empty: no need to send message");
         return new RspList();
      }

      if (trace)
         log.trace(new StringBuilder("dests=").append(dests).append(", command=").append(command).
               append(", mode=").append(mode).append(", timeout=").append(timeout));

      boolean supportReplay = configuration.isNonBlockingStateTransfer();
      ReplicationTask replicationTask = new ReplicationTask(command, oob, dests, mode, timeout, anycasting, supportReplay, filter);
      Future<RspList> response = replicationProcessor.submit(replicationTask);
      if (asyncSerial)
      {
         // don't care about the response.  return.
         return null;
      }
      else
      {
         RspList retval = response.get();
         if (retval.isEmpty() || containsOnlyNulls(retval))
            return null;
         else
            return retval;
      }
   }
View Full Code Here

TOP

Related Classes of org.jgroups.util.RspList

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.