Package org.jgroups.stack

Examples of org.jgroups.stack.StateTransferInfo


                    }
                    catch(Exception e) {
                        throw new RuntimeException(local_addr + ": failed getting state from application", e);
                    }
                }
                return new StateTransferInfo(null, 0L, tmp_state);
            case Event.BLOCK:
                receiver.block();
                return true;
            case Event.UNBLOCK:
                receiver.unblock();
View Full Code Here


                break;

            // generated by JChannel.getState(). currently, getting the state from more than 1 mbr is not implemented
            case Event.GET_STATE:
                Address target;
                StateTransferInfo info=(StateTransferInfo)evt.getArg();
                if(info.target == null) {
                    target=determineCoordinator();
                }
                else {
                    target=info.target;
                    if(target.equals(local_addr)) {
                        if(log.isErrorEnabled())
                            log.error(local_addr + ": cannot fetch state from myself !");
                        target=null;
                    }
                }
                if(target == null) {
                    if(log.isDebugEnabled())
                        log.debug(local_addr + ": first member (no state)");
                    up_prot.up(new Event(Event.GET_STATE_OK, new StateTransferInfo()));
                }
                else {
                    Message state_req=new Message(target, null, null);
                    state_req.putHeader(this.id, new StateHeader(StateHeader.STATE_REQ));
                    if(log.isDebugEnabled())
View Full Code Here

        }
    }


    protected void getStateFromApplication(Address requester, Digest digest) {
        StateTransferInfo rsp=(StateTransferInfo)up_prot.up(new Event(Event.GET_APPLSTATE));
        byte[] state=rsp.state;

        if(stats) {
            num_state_reqs.incrementAndGet();
            if(state != null)
View Full Code Here

            case Event.VIEW_CHANGE:
                handleViewChange((View)evt.getArg());
                break;

            case Event.GET_STATE:
                StateTransferInfo info=(StateTransferInfo)evt.getArg();
                Address target;
                if(info.target == null) {
                    target=determineCoordinator();
                }
                else {
View Full Code Here

                    if(msg_listener != null) {
                        ByteArrayOutputStream output=new ByteArrayOutputStream(1024);
                        msg_listener.getState(output);
                        tmp_state=output.toByteArray();
                    }
                    return new StateTransferInfo(null, 0L, tmp_state);

                case Event.GET_STATE_OK:
                    if(msg_listener != null) {
                        StateTransferResult result=(StateTransferResult)evt.getArg();
                        ByteArrayInputStream input=new ByteArrayInputStream(result.getBuffer());
View Full Code Here

                        msg_listener.receive((Message) evt.getArg());
                    }
                    break;

                case Event.GET_APPLSTATE: // reply with GET_APPLSTATE_OK
                    StateTransferInfo info=(StateTransferInfo)evt.getArg();
                    String state_id=info.state_id;
                    byte[] tmp_state=null;
                    if(msg_listener != null) {
                        try {
                            if(msg_listener instanceof ExtendedMessageListener && state_id!=null) {
                                tmp_state=((ExtendedMessageListener)msg_listener).getState(state_id);
                            }
                            else {
                                tmp_state=msg_listener.getState();
                            }
                        }
                        catch(Throwable t) {
                            this.log.error("failed getting state from message listener (" + msg_listener + ')', t);
                        }
                    }
                    return new StateTransferInfo(null, state_id, 0L, tmp_state);

                case Event.GET_STATE_OK:
                    if(msg_listener != null) {
                        try {
                            info=(StateTransferInfo)evt.getArg();
                            String id=info.state_id;
                            if(msg_listener instanceof ExtendedMessageListener && id!=null) {
                                ((ExtendedMessageListener)msg_listener).setState(id, info.state);
                            }
                            else {
                                msg_listener.setState(info.state);
                            }
                        }
                        catch(ClassCastException cast_ex) {
                            if(this.log.isErrorEnabled())
                                this.log.error("received SetStateEvent, but argument " +
                                        evt.getArg() + " is not serializable. Discarding message.");
                        }
                    }
                    break;

                case Event.STATE_TRANSFER_OUTPUTSTREAM:
                    StateTransferInfo sti=(StateTransferInfo)evt.getArg();
                    OutputStream os=sti.outputStream;
                    if(msg_listener instanceof ExtendedMessageListener) {                       
                        if(os != null && msg_listener instanceof ExtendedMessageListener) {
                            if(sti.state_id == null)
                                ((ExtendedMessageListener)msg_listener).getState(os);
                            else
                                ((ExtendedMessageListener)msg_listener).getState(sti.state_id, os);
                        }
                        return new StateTransferInfo(null, os, sti.state_id);
                    }
                    else if(msg_listener instanceof MessageListener){
                        if(log.isWarnEnabled()){
                            log.warn("Channel has STREAMING_STATE_TRANSFER, however,"
                                    + " application does not implement ExtendedMessageListener. State is not transfered");
View Full Code Here

            }
            case Event.GET_APPLSTATE:
            case Event.GET_STATE_OK:
            case Event.STATE_TRANSFER_OUTPUTSTREAM:
            case Event.STATE_TRANSFER_INPUTSTREAM: {
                StateTransferInfo info=(StateTransferInfo)evt.getArg();
                String state_id=info.state_id;
                UpHandler basicHandler = null;
                boolean multipleBasic = false;
                for (UpHandler uh: handlers.values())
                {
View Full Code Here

     *
     * @see org.jgroups.blocks.mux.MuxUpHandler#handleStateTransferEvent(org.jgroups.Event)
     */
    @Override
    protected ImmutableReference<Object> handleStateTransferEvent(Event evt) {
        StateTransferInfo info = (StateTransferInfo) evt.getArg();
        for (UpHandler uh : stateTransferHandlers.values()) {
            if (uh instanceof StateTransferFilter) {
                if (((StateTransferFilter) uh).accepts(info.state_id)) {
                    return new ImmutableReference<Object>(uh.up(evt));
                }
View Full Code Here

                throw new IllegalStateException("Could not flush the cluster and proceed with state retrieaval");
            }
        }

        state_promise.reset();
        StateTransferInfo state_info=new StateTransferInfo(target, state_id, timeout);
        down(new Event(Event.GET_STATE, state_info));
        Boolean b=state_promise.getResult(state_info.timeout);
       
        if(initiateFlush)
            stopFlush();
View Full Code Here

     * @param state The state of the application as a byte buffer
     *              (to send over the network).
     */
    public void returnState(byte[] state) {
        try {
            StateTransferInfo state_info=new StateTransferInfo(null, null, 0L, state);
            applstate_exchanger.exchange(state_info);
        }
        catch(InterruptedException e) {
            Thread.currentThread().interrupt();
        }
View Full Code Here

TOP

Related Classes of org.jgroups.stack.StateTransferInfo

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.