Examples of RspList


Examples of org.jgroups.util.RspList

        Assert.assertEquals(2, c2.getView().size());
        System.out.println("view: " + c2.getView());

        System.out.println("casting message");
        start=System.currentTimeMillis();
        RspList rsps=d1.castMessage(null, new Message(), new RequestOptions(Request.GET_ALL, 0));
        stop=System.currentTimeMillis();
        System.out.println("rsps:\n" + rsps);
        System.out.println("call took " + (stop - start) + " ms");
        assertNotNull(rsps);
        Assert.assertEquals(2, rsps.size());
        Rsp rsp=rsps.get(c1.getAddress());
        assertNotNull(rsp);
        Object ret=rsp.getValue();
        assert ret == null;

        rsp=rsps.get(c2.getAddress());
        assertNotNull(rsp);
        ret=rsp.getValue();
        assert ret == null;

        Util.close(c2);
View Full Code Here

Examples of org.jgroups.util.RspList

    private void sendMessage(int size) {
        long start, stop;
        MyHandler handler=new MyHandler(new byte[size]);
        d1.setRequestHandler(handler);
        start=System.currentTimeMillis();
        RspList rsps=d1.castMessage(null, new Message(), new RequestOptions(Request.GET_ALL, 0));
        stop=System.currentTimeMillis();
        System.out.println("rsps:\n" + rsps);
        System.out.println("call took " + (stop - start) + " ms");
        assertNotNull(rsps);
        Assert.assertEquals(1, rsps.size());
        byte[] buf=(byte[])rsps.getFirst();
        assertNotNull(buf);
        Assert.assertEquals(size, buf.length);
    }
View Full Code Here

Examples of org.jgroups.util.RspList

        c2.connect("MessageDispatcherUnitTest");
        Assert.assertEquals(2, c2.getView().size());

        System.out.println("casting message");
        start=System.currentTimeMillis();
        RspList rsps=d1.castMessage(null, new Message(), new RequestOptions(Request.GET_ALL, 0));
        stop=System.currentTimeMillis();
        System.out.println("rsps:\n" + rsps);
        System.out.println("call took " + (stop - start) + " ms");
        assertNotNull(rsps);
        Assert.assertEquals(2, rsps.size());
        Rsp rsp=rsps.get(c1.getAddress());
        assertNotNull(rsp);
        byte[] ret=(byte[])rsp.getValue();
        Assert.assertEquals(size, ret.length);

        rsp=rsps.get(c2.getAddress());
        assertNotNull(rsp);
        ret=(byte[])rsp.getValue();
        Assert.assertEquals(size, ret.length);

        Util.close(c2);
View Full Code Here

Examples of org.jgroups.util.RspList



    /** Returns the results as a RspList */
    public RspList getResults() {
        RspList list=new RspList();
        for(Rsp rsp: responses)
            list.put(rsp.getSender(), rsp);
        return list;
    }
View Full Code Here

Examples of org.jgroups.util.RspList

    Rsp rsp1, rsp2, rsp3, rsp4, rsp5;


    @BeforeMethod
    public void setUp() throws Exception {
        rl=new RspList();
        a1=Util.createRandomAddress();
        a2=Util.createRandomAddress();
        a3=Util.createRandomAddress();
        a4=Util.createRandomAddress();
        a5=Util.createRandomAddress();
View Full Code Here

Examples of org.jgroups.util.RspList


    public void testConstructor() {
        Collection<Rsp> c=new LinkedList<Rsp>();
        c.add(rsp1); c.add(rsp2); c.add(rsp3);
        RspList tmp=new RspList(c);
        Assert.assertEquals(c.size(), tmp.size());
        assert tmp.containsKey(a1);
        assert tmp.containsKey(a2);
        assert tmp.containsKey(a3);
        assert tmp.containsValue(rsp1);
        assert tmp.containsValue(rsp2);
        assert tmp.containsValue(rsp3);
    }
View Full Code Here

Examples of org.jgroups.util.RspList

        assert tmp.containsValue(rsp3);
    }


    public void testIsEmpty() {
        RspList tmp=new RspList();
        assert tmp.isEmpty();
        tmp.addRsp(a1, rsp1);
        assert !(tmp.isEmpty());
    }
View Full Code Here

Examples of org.jgroups.util.RspList

        Assert.assertEquals(0, rl.size());
    }


    public static void testKeySet() {
        RspList tmp=new RspList();
        Set keys=tmp.keySet();
        assert keys != null;
        Assert.assertEquals(0, keys.size());
    }
View Full Code Here

Examples of org.jgroups.util.RspList

       @param dests A list of members to which the FLUSH is to be sent
       @return FlushRsp Contains result (true or false), list of unstable messages and list of members
         failed during the FLUSH.
     */
    private FlushRsp flush(Vector dests) {
  RspList     rsp_list;
  FlushRsp    retval=new FlushRsp();
  Digest      digest;
  long[]      min, max;
  long[]      lower[];
  List        unstable_msgs=new List();
  boolean     get_lower_msgs=false;

  highest_delivered_msgs=new long[members.size()];
  min=new long[members.size()];
  max=new long[members.size()];


  /* Determine the highest seqno (for each member) that was delivered to the application
     (i.e., consumed by the application). Stores result in array 'highest_delivered_msgs' */
  getHighestDeliveredSeqnos();

  for(int i=0; i < highest_delivered_msgs.length; i++)
      min[i]=max[i]=highest_delivered_msgs[i];


  /* Call the handleFlush() method of all existing members. The highest seqnos seen by the coord
     is the argument */
   if(log.isInfoEnabled()) log.info("calling handleFlush(" + dests + ')');
  passDown(new Event(Event.SWITCH_OUT_OF_BAND)); // we need out-of-band control for FLUSH ...
  MethodCall call = new MethodCall("handleFlush", new Object[] {dests, highest_delivered_msgs.clone()},
    new String[] {Vector.class.getName(), long[].class.getName()});
  rsp_list=callRemoteMethods(dests, call, GroupRequest.GET_ALL, 0);
   if(log.isInfoEnabled()) log.info("flush done");


  /* Process all the responses (Digest): compute a range of messages (min and max seqno) for each
     member that has to be re-broadcast; FlushRsp contains those messages. They will be re-braodcast
     by the cordinator (in the GMS protocol). */
  for(int i=0; i < rsp_list.size(); i++) {
      Rsp rsp=(Rsp)rsp_list.elementAt(i);
      if(rsp.wasReceived()) {
    digest=(Digest)rsp.getValue();
    if(digest != null) {
        for(int j=0; j < digest.highest_seqnos.length && j < min.length; j++) {
      min[j]=Math.min(min[j], digest.highest_seqnos[j]);
      max[j]=Math.max(max[j], digest.highest_seqnos[j]);
        }
        if(digest.msgs.size() > 0) {
      for(Enumeration e=digest.msgs.elements(); e.hasMoreElements();)
          unstable_msgs.add(e.nextElement());
        }
    }
      }
  } // end for-loop



  /* If any of the highest msgs of the flush replies were lower than the ones sent by this
     coordinator, we have to re-broadcast them. (This won't occur often)
     Compute the range between min and highest_delivered_msgs */
  lower=new long[min.length][]; // stores (for each mbr) the range of seqnos (e.g. 20 24): send msgs
              // 21, 22 and 23 and 24 (excluding lower and including upper range)

  for(int i=0; i < min.length; i++) {
      if(min[i] < highest_delivered_msgs[i]) {    // will almost never be the case
    lower[i]=new long[2];
    lower[i][0]=min[i];                     // lower boundary (excluding)
    lower[i][1]=highest_delivered_msgs[i]// upper boundary (including)
    get_lower_msgs=true;
      }
  }
  if(get_lower_msgs) {
      get_msgs=null;
      synchronized(get_msgs_mutex) {
    passDown(new Event(Event.GET_MSGS, lower));
    try {
        get_msgs_mutex.wait(get_msgs_timeout);
    }
    catch(Exception e) {}
      }
      if(get_msgs != null) {
    for(Enumeration e=get_msgs.elements(); e.hasMoreElements();)
        unstable_msgs.add(e.nextElement());
      }
  }
  retval.unstable_msgs=unstable_msgs.getContents();
  if(rsp_list.numSuspectedMembers() > 0) {
      retval.result=false;
      retval.failed_mbrs=rsp_list.getSuspectedMembers();
  }

  return retval;
    }
View Full Code Here

Examples of org.jgroups.util.RspList

    /** Returns the results as a RspList */
    public RspList getResults() {
        synchronized(requests) {
            Collection rsps=requests.values();
            return new RspList(rsps);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.