Package org.jgroups

Examples of org.jgroups.Event


    }

    public void start() throws Exception {
        corr=new RequestCorrelator(getName(), this, this);
        passUp(new Event(Event.CONFIG, map));
    }
View Full Code Here


                info=(StateTransferInfo)evt.getArg();
                coord=determineCoordinator();

                if(coord == null || coord.equals(local_addr)) {
                    event_list=new Vector(1);
                    event_list.addElement(new Event(Event.GET_STATE_OK, new StateTransferInfo()));
                    passUp(new Event(Event.STOP_QUEUEING, event_list));
                    return;             // don't pass down any further !
                }



                try {
                    sendMakeCopyMessage()// multicast MAKE_COPY to all members (including me)
                    state=getStateFromSingle(info.target);
                }
                catch(Throwable t) {
                    if(log.isErrorEnabled())
                        log.error("failed sending state request", t);
                    state=null;
                }

                /* Pass up the state to the application layer (insert into JChannel's event queue */
                event_list=new Vector(1);
                event_list.addElement(new Event(Event.GET_STATE_OK, new StateTransferInfo(null, info.state_id, 0L, (byte[])state)));

                /* Now stop queueing */
                passUp(new Event(Event.STOP_QUEUEING, event_list));
                return;                 // don't pass down any further !

            case Event.GET_APPLSTATE_OK:
                synchronized(state_xfer_mutex) {
                    info=(StateTransferInfo)evt.getArg();
View Full Code Here

     * STATE_TRANSFER down). If client, start queueing events. Queuing will be stopped when
     * state has been retrieved (or not) from single or all member(s).
     */
    void makeCopy(Object sender) {
        if(sender.equals(local_addr)) { // was sent by us, has to start queueing
            passUp(new Event(Event.START_QUEUEING));
        }
        else {               // only retrieve state from appl when not in client state anymore
            if(is_server) {  // get state from application and store it locally
                synchronized(state_xfer_mutex) {
                    cached_state=null;
                    StateTransferInfo info=new StateTransferInfo(local_addr);
                    passUp(new Event(Event.GET_APPLSTATE, info));
                    if(cached_state == null) {
                        try {
                            state_xfer_mutex.wait(timeout_get_appl_state); // wait for STATE_TRANSFER_OK
                        }
                        catch(Exception e) {
View Full Code Here


    public void run() {
        Vector responses=findInitialMembers();
        if(parent != null)
            parent.passUp(new Event(Event.FIND_INITIAL_MBRS_OK, responses));
    }
View Full Code Here

     *
     * @param mbr Our own address (assigned through SET_LOCAL_ADDRESS)
     */
    public void join(Address mbr) {
        Address coord;
        Event view_evt;

        while(!joined) {
            findInitialMembers();
            if(joined) {
                 if(log.isInfoEnabled()) log.info("joined successfully");
                return;
            }
            if(initial_mbrs.size() == 0) {
                if(gms.disable_initial_coord) {
                    if(log.isInfoEnabled()) log.info("received an initial membership of 0, but " +
                            "cannot become coordinator (disable_initial_coord=" + gms.disable_initial_coord +
                            "), will retry fetching the initial membership");
                    continue;
                }
                joined=true;
                gms.view_id=new ViewId(mbr);       // create singleton view with mbr as only member
                gms.mbrs.add(mbr);
                view_evt=new Event(Event.VIEW_CHANGE,
                                   GMS.makeView(gms.mbrs.getMembers(), gms.view_id));
                gms.passDown(view_evt);
                gms.passUp(view_evt);
                gms.becomeCoordinator();

                gms.passUp(new Event(Event.BECOME_SERVER));
                gms.passDown(new Event(Event.BECOME_SERVER));
                if(log.isInfoEnabled()) log.info("created group (first member)");
                break;
            }

            coord=determineCoord(initial_mbrs);
View Full Code Here

            synchronized(view_installation_mutex) {  // wait until JOIN is sent (above)
                joined=true;
                view_installation_mutex.notifyAll();
                gms.installView(new_view, mems);
                gms.becomeParticipant();
                gms.passUp(new Event(Event.BECOME_SERVER));
                gms.passDown(new Event(Event.BECOME_SERVER));
            }
            synchronized(initial_mbrs) {    // in case findInitialMembers() is still running:
                initial_mbrs.notifyAll();   // this will unblock it
            }
        }
View Full Code Here

        if(log.isDebugEnabled()){
            log.debug("GMSHeader created for failure JOIN_RSP");
        }

        return new Event(Event.MSG, msg);
    }
View Full Code Here

        int num_received=0;
        Receiver r=new Receiver();
        s.setReceiver(r);
        for(int i=1; i <= NUM_MSGS; i++) {
            Message msg=new Message(a1, null, createPayload(SIZE, i)); // unicast message
            Event evt=new Event(Event.MSG, msg);
            s.send(evt);
            if(i % 1000 == 0)
                System.out.println("==> " + i);
        }
        int num_tries=10;
View Full Code Here

        synchronized(mutex) {
            for(int i=0; i < NUM_MSGS; i++) {
                big_msg=createBigMessage(MSG_SIZE);
                big_msg.setSrc(local_addr);
                System.out.println("sending msg #" + i + " [" + big_msg.getLength() + " bytes]");
                frag_receiver.down(new Event(Event.MSG, big_msg));
                Util.sleep(10);
            }
        }
        t.stop();
    }
View Full Code Here

    /** Removes events from mq and calls handler.up(evt) */
    public void run() {
        while(!mq.closed()) {
            try {
                Event evt=(Event)mq.remove();
                if(evt == null) {
                    if(log.isWarnEnabled()) log.warn("removed null event");
                    continue;
                }

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.