Package org.jgroups.stack

Examples of org.jgroups.stack.ProtocolStack$ProtocolStackFactory


     */
    public static void shutdown(Channel ch) throws Exception {
        DISCARD discard=new DISCARD();
        discard.setLocalAddress(ch.getAddress());
        discard.setDiscardAll(true);
        ProtocolStack stack=ch.getProtocolStack();
        TP transport=stack.getTransport();
        stack.insertProtocol(discard,ProtocolStack.ABOVE,transport.getClass());

        //abruptly shutdown FD_SOCK just as in real life when member gets killed non gracefully
        FD_SOCK fd=(FD_SOCK)ch.getProtocolStack().findProtocol(FD_SOCK.class);
        if(fd != null)
            fd.stopServerSocket(false);

        View view=ch.getView();
        if(view != null) {
            ViewId vid=view.getViewId();
            List<Address> members=Arrays.asList(ch.getAddress());

            ViewId new_vid=new ViewId(ch.getAddress(),vid.getId() + 1);
            View new_view=new View(new_vid,members);

            // inject view in which the shut down member is the only element
            GMS gms=(GMS)stack.findProtocol(GMS.class);
            gms.installView(new_view);
        }
        Util.close(ch);
    }
View Full Code Here


    }


    public static JChannel createChannel(Protocol... prots) throws Exception {
        JChannel ch=new JChannel(false);
        ProtocolStack stack=new ProtocolStack();
        ch.setProtocolStack(stack);
        for(Protocol prot : prots) {
            stack.addProtocol(prot);
            prot.setProtocolStack(stack);
        }
        stack.init();
        return ch;
    }
View Full Code Here

        for(Map.Entry<String,List<ProtocolConfiguration>> entry: protocols.entrySet()) {
            String fork_stack_id=entry.getKey();
            if(get(fork_stack_id) != null && !replace_existing)
                continue;

            ProtocolStack  fork_prot_stack=new ForkProtocolStack();
            List<Protocol> prots=createProtocols(fork_prot_stack,entry.getValue());
            createForkStack(fork_stack_id, fork_prot_stack, replace_existing, prots);
        }
    }
View Full Code Here

     * the MBean server
     * @param channel
     * @param prefix
     */
    public static void registerProtocols(MBeanServer server, org.jgroups.JChannel channel, String prefix) throws Exception {
        ProtocolStack stack=channel.getProtocolStack();
        Vector protocols=stack.getProtocols();
        org.jgroups.stack.Protocol prot;
        org.jgroups.jmx.Protocol p=null;
        for(int i=0; i < protocols.size(); i++) {
            prot=(org.jgroups.stack.Protocol)protocols.get(i);
            try {
View Full Code Here

            server.registerMBean(p, prot_name);
        }
    }

    public static void unregisterProtocols(MBeanServer server, org.jgroups.JChannel channel, String channel_name) {
        ProtocolStack stack=channel.getProtocolStack();
        Vector protocols=stack.getProtocols();
        org.jgroups.stack.Protocol prot;
        ObjectName prot_name=null;
        for(int i=0; i < protocols.size(); i++) {
            prot=(org.jgroups.stack.Protocol)protocols.get(i);
            try {
View Full Code Here

    /**
     * Returns a pretty-printed form of all the protocols. If include_properties
     * is set, the properties for each protocol will also be printed.
     */
    public String printProtocolSpec(boolean include_properties) {
        ProtocolStack ps=getProtocolStack();
        return ps != null? ps.printProtocolSpec(include_properties) : null;
    }
View Full Code Here

        try {
            mq.reset();

            // new stack is created on open() - bela June 12 2003
            prot_stack=new ProtocolStack(this, props);
            prot_stack.setup();
            closed=false;
        }
        catch(Exception e) {
            throw new ChannelException("failed to open channel" , e);
View Full Code Here

    protected final void init(ProtocolStackConfigurator configurator) throws ChannelException {
        if(log.isInfoEnabled())
            log.info("JGroups version: " + Version.description);
        ConfiguratorFactory.substituteVariables(configurator); // replace vars with system props
        props=configurator.getProtocolStackString();
        prot_stack=new ProtocolStack(this, props);
        try {
            prot_stack.setup(); // Setup protocol stack (creates protocol, calls init() on them)
        }
        catch(Throwable e) {
            throw new ChannelException("unable to setup the protocol stack: " + e.getMessage(), e);
View Full Code Here

    }


    protected static FORK getFORK(Channel ch, int position, Class<? extends Protocol> neighbor,
                                  boolean create_fork_if_absent) throws Exception {
        ProtocolStack stack=ch.getProtocolStack();
        FORK fork=(FORK)stack.findProtocol(FORK.class);
        if(fork == null) {
            if(!create_fork_if_absent)
                throw new IllegalArgumentException("FORK not found in main stack");
            fork=new FORK();
            stack.insertProtocol(fork, position, neighbor);
        }
        return fork;
    }
View Full Code Here

        return socket_factory;
    }

    public void setSocketFactory(SocketFactory factory) {
        socket_factory=factory;
        ProtocolStack stack=getProtocolStack();
        Protocol prot=stack != null? stack.getTopProtocol() : null;
        if(prot != null)
            prot.setSocketFactory(factory);
    }
View Full Code Here

TOP

Related Classes of org.jgroups.stack.ProtocolStack$ProtocolStackFactory

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.