synchronized(local_addr_mutex) { local_addr=(Address)evt.getArg(); local_addr_mutex.notifyAll(); }
local_addr_promise.setResult(evt.getArg());
    public void up(Event evt) {        int type=evt.getType();        Message msg;        /*if the queue is not available, there is no point in         *processing the message at all*/        if(mq == null) {            if(log.isErrorEnabled()) log.error("message queue is null");            return;        }        switch(type) {            case Event.MSG:                msg=(Message)evt.getArg();                if(!receive_local_msgs) {  // discard local messages (sent by myself to me)                    if(local_addr != null && msg.getSrc() != null)                        if(local_addr.equals(msg.getSrc()))                            return;                }                break;            case Event.VIEW_CHANGE:                my_view=(View)evt.getArg();                // crude solution to bug #775120: if we get our first view *before* the CONNECT_OK,                // we simply set the state to connected                if(connected == false) {                    connected=true;                    synchronized(connect_mutex) { // bug fix contributed by Chris Wampler (bug #943881)                        connect_ok_event_received=true;                        connect_mutex.notify();                    }                }                // unblock queueing of messages due to previous BLOCK event:                down(new Event(Event.STOP_QUEUEING));                if(!receive_views)  // discard if client has not set receving views to on                    return;                //if(connected == false)                //  my_view=(View)evt.getArg();                break;            case Event.SUSPECT:                if(!receive_suspects)                    return;                break;            case Event.GET_APPLSTATE:  // return the application's state                if(!receive_get_states) {  // if not set to handle state transfers, send null state                    down(new Event(Event.GET_APPLSTATE_OK, null));                    return;                }                break;            case Event.CONFIG:                HashMap config=(HashMap)evt.getArg();                if(config != null && config.containsKey("state_transfer"))                    state_transfer_supported=((Boolean)config.get("state_transfer")).booleanValue();                break;            case Event.BLOCK:                // If BLOCK is received by application, then we trust the application to not send                // any more messages until a VIEW_CHANGE is received. Otherwise (BLOCKs are disabled),                // we queue any messages sent until the next VIEW_CHANGE (they will be sent in the                // next view)                if(!receive_blocks) {  // discard if client has not set 'receiving blocks' to 'on'                    down(new Event(Event.BLOCK_OK));                    down(new Event(Event.START_QUEUEING));                    return;                }                break;            case Event.CONNECT_OK:                synchronized(connect_mutex) {                    connect_ok_event_received=true;                    connect_mutex.notify();                }                break;            case Event.DISCONNECT_OK:                synchronized(disconnect_mutex) {                    disconnect_ok_event_received=true;                    disconnect_mutex.notifyAll();                }                break;            case Event.GET_STATE_OK:                try {                    mq.add(new Event(Event.STATE_RECEIVED, evt.getArg()));                }                catch(Exception e) {                }                state_promise.setResult(evt.getArg());                break;            case Event.SET_LOCAL_ADDRESS:                synchronized(local_addr_mutex) {                    local_addr=(Address)evt.getArg();                    local_addr_mutex.notifyAll();                }                break;            case Event.EXIT:                handleExit(evt);                return;  // no need to pass event up; already done in handleExit()            case Event.BLOCK_SEND:                synchronized(flow_control_mutex) {                     if(log.isInfoEnabled()) log.info("received BLOCK_SEND");                    block_sending=true;                    flow_control_mutex.notifyAll();                }                break;            case Event.UNBLOCK_SEND:                synchronized(flow_control_mutex) {                     if(log.isInfoEnabled()) log.info("received UNBLOCK_SEND");                    block_sending=false;                    flow_control_mutex.notifyAll();                }                break;            default:                break;        }        // If UpHandler is installed, pass all events to it and return (UpHandler is e.g. a building block)        if(up_handler != null) {            up_handler.up(evt);            return;        }        if(type == Event.MSG || type == Event.VIEW_CHANGE || type == Event.SUSPECT ||                type == Event.GET_APPLSTATE || type == Event.BLOCK) {            try {                mq.add(evt);            }            catch(Exception e) {                if(log.isErrorEnabled()) log.error("exception: " + e);            }        }    }