Package org.jgroups

Examples of org.jgroups.Event


                data=packet.getData();
                inp_stream=new ExposedByteArrayInputStream(data, 0, data.length);
                inp=new DataInputStream(inp_stream);
                msg=new Message();
                msg.readFrom(inp);
                up(new Event(Event.MSG, msg));
            }
            catch(SocketException socketEx) {
                break;
            }
            catch(Throwable ex) {
View Full Code Here


 
  public void test() throws Exception {

    logger.info("'org.jgroups.Event' test");
   
    Event event = new Event(100);
    logger.info(event.getArg());
    logger.info(event);
    logger.info(event.getType());
  }
View Full Code Here


  /* 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) {}
      }
View Full Code Here

  // block sending of messages (only if not already blocked !)
  if(!blocked) {
      blocked=true;
      synchronized(block_mutex) {
    passUp(new Event(Event.BLOCK));
    try {block_mutex.wait(block_timeout);}
    catch(Exception e) {}
      }
  }
View Full Code Here


    /** Returns the highest seqnos (for each member) seen so far (using the NAKACK layer) */
    void getHighestDeliveredSeqnos() {
  synchronized(highest_delivered_mutex) {
      passDown(new Event(Event.GET_MSGS_RECEIVED));
      try {
    highest_delivered_mutex.wait(4000);
      }
      catch(Exception e) {
    if(log.isDebugEnabled()) log.debug("exception is " + e);
View Full Code Here


    /** Interacts with a lower layer to retrieve unstable messages (e.g. NAKACK) */
    void getMessageDigest(long[] highest_seqnos) {
  synchronized(digest_mutex) {
      passDown(new Event(Event.GET_MSG_DIGEST, highest_seqnos));
      try {
    digest_mutex.wait(digest_timeout);
      }
      catch(Exception e) {}
  }
View Full Code Here

  switch(evt.getType()) {
  case Event.FLUSH:
      dests=(Vector)evt.getArg();
      if(dests == null) dests=new Vector();
      rsp=flush(dests);
      passUp(new Event(Event.FLUSH_OK, rsp));
      return false; // don't pass down

  case Event.BECOME_SERVER:
      is_server=true;
      break;
View Full Code Here

       (in parallel to the FLUSH event), which causes the FLUSH event processing to return.
    */
    public void receiveDownEvent(Event evt) {
  if(evt.getType() == Event.BLOCK_OK) { // priority handling, otherwise FLUSH would block !
      synchronized(down_queue) {
    Event event;
    try {
        while(down_queue.size() > 0) {
      event=(Event)down_queue.remove(10); // wait 10ms at most; queue is *not* empty !
      down(event);
        }
View Full Code Here

    class ControlReceiver extends ExtendedReceiverAdapter {
        public void viewAccepted(View v) {
            member_size=v.size();
            if(mainFrame != null)
                mainFrame.setTitle(member_size + " mbrs");
            data_channel.down(new Event(Event.VIEW_CHANGE, v));
        }
View Full Code Here

        List tmp_mbrs;
        Address mbr_addr;

        if(group_addr == null) {
            if(log.isErrorEnabled()) log.error("[FIND_INITIAL_MBRS]: group_addr is null, cannot get mbrship");
            passUp(new Event(Event.FIND_INITIAL_MBRS_OK, EMPTY_VECTOR));
            return;
        }
        if(trace) log.trace("fetching members from GossipRouter(s)");
        tmp_mbrs=gossip_client.getMembers(group_addr);
        if(tmp_mbrs == null || tmp_mbrs.size() == 0) {
            if(log.isErrorEnabled()) log.error("[FIND_INITIAL_MBRS]: gossip client found no members");
            passUp(new Event(Event.FIND_INITIAL_MBRS_OK, EMPTY_VECTOR));
            return;
        }
        if(trace) log.trace("consolidated mbrs from GossipRouter(s) are " + tmp_mbrs);

        // 1. 'Mcast' GET_MBRS_REQ message
        hdr=new PingHeader(PingHeader.GET_MBRS_REQ, null);
        msg=new Message(null);
        msg.putHeader(name, hdr);

        for(Iterator it=tmp_mbrs.iterator(); it.hasNext();) {
            mbr_addr=(Address)it.next();
            copy=msg.copy();
            copy.setDest(mbr_addr);
            if(trace) log.trace("[FIND_INITIAL_MBRS] sending PING request to " + copy.getDest());
            passDown(new Event(Event.MSG, copy));
        }
    }
View Full Code Here

TOP

Related Classes of org.jgroups.Event

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.