All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jgroups.fork.ForkProtocol Maven / Gradle / Ivy

Go to download

This artifact provides a single jar that contains all classes required to use remote EJB and JMS, including all dependencies. It is intended for use by those not using maven, maven users should just import the EJB and JMS BOM's instead (shaded JAR's cause lots of problems with maven, as it is very easy to inadvertently end up with different versions on classes on the class path).

There is a newer version: 34.0.0.Final
Show newest version
package org.jgroups.fork;

import org.jgroups.Event;
import org.jgroups.Message;
import org.jgroups.protocols.FORK;
import org.jgroups.stack.Protocol;

/**
 * Acts as bottom protocol of a fork-stack. Knows about the fork-stack-id and inserts it into the ForkHeader of messages
 * sent down the stack
 * @author Bela Ban
 * @since  3.4
 */
public class ForkProtocol extends Protocol {
    protected final String       fork_stack_id;

    public ForkProtocol(String fork_stack_id) {
        this.fork_stack_id=fork_stack_id;
    }


    public Object down(Event evt) {
        switch(evt.getType()) {
            case Event.VIEW_CHANGE:
            case Event.CONNECT:
            case Event.CONNECT_USE_FLUSH:
            case Event.CONNECT_WITH_STATE_TRANSFER:
            case Event.CONNECT_WITH_STATE_TRANSFER_USE_FLUSH:
            case Event.DISCONNECT:
                return null; // don't propagate further down, this is only important for the main stack
        }
        return down_prot.down(evt);
    }

    public Object down(Message msg) {
        FORK.ForkHeader hdr=msg.getHeader(FORK.ID);
        if(hdr == null)
            msg.putHeader(FORK.ID, hdr=new FORK.ForkHeader(fork_stack_id, null));
        else
            hdr.setForkStackId(fork_stack_id);
        return down_prot.down(msg);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy