Package org.jgroups.mux

Examples of org.jgroups.mux.Multiplexer


                ch=new JChannel(props);
                entry.channel=ch;
                if(expose_channels && server != null)
                    registerChannel(ch, stack_name);
            }
            Multiplexer mux=entry.multiplexer;
            if(mux == null) {
                mux=new Multiplexer(ch);
                entry.multiplexer=mux;
            }
            if(register_for_state_transfer)
                mux.registerForStateTransfer(id, substate_id);
            return mux.createMuxChannel(this, id, stack_name);
        }
    }
View Full Code Here


        synchronized(channels) {
            entry=(Entry)channels.get(ch.getStackName());
        }
        if(entry != null) {
            synchronized(entry) {
                Multiplexer mux=entry.multiplexer;
                if(mux != null) {
                    Address addr=entry.channel.getLocalAddress();
                    try {                             
                        if(entry.channel.flushSupported()){                          
                           boolean successfulFlush = entry.channel.startFlush(3000, false);
                           if(!successfulFlush && log.isWarnEnabled()){
                              log.warn("Flush failed at " + ch.getLocalAddress() + ch.getId());
                           }
                        }
                        mux.sendServiceDownMessage(ch.getId(), addr,true);
                    }
                    catch(Exception e) {
                        if(log.isErrorEnabled())
                            log.error("failed sending SERVICE_DOWN message", e);
                    }
                    finally{                     
                       if(entry.channel.flushSupported())
                          entry.channel.stopFlush();                                  
                    }                 
                    mux.disconnect(); // disconnects JChannel if all MuxChannels are in disconnected state
                }
            }
        }
    }
View Full Code Here

        synchronized(channels) {
            entry=(Entry)channels.get(stack_name);
        }
        if(entry != null) {
            synchronized(entry) {
                Multiplexer mux=entry.multiplexer;
                if(mux != null) {
                    Address addr=entry.channel.getLocalAddress();
                    if(addr != null) {
                        try {
                            if(entry.channel.flushSupported()){                          
                               boolean successfulFlush = entry.channel.startFlush(3000, false);
                               if(!successfulFlush && log.isWarnEnabled()){
                                  log.warn("Flush failed at " + ch.getLocalAddress() + ch.getId());
                               }
                            }                           
                            mux.sendServiceDownMessage(ch.getId(), addr,true);
                        }
                        catch(Exception e) {
                            if(log.isErrorEnabled())
                                log.error("failed sending SERVICE_DOWN message", e);
                        }
                        finally{                          
                           if(entry.channel.flushSupported())
                              entry.channel.stopFlush();                          
                        }
                    }
                    all_closed=mux.close(); // closes JChannel if all MuxChannels are in closed state
                }
            }
            if(all_closed) {
                channels.remove(stack_name);
            }
View Full Code Here

        synchronized(channels) {
            entry=(Entry)channels.get(stack_name);
            if(entry != null) {
                synchronized(entry) {
                    Multiplexer mux=entry.multiplexer;
                    if(mux != null) {
                        Address addr=entry.channel.getLocalAddress();
                        try {
                            if(entry.channel.flushSupported()){                          
                               boolean successfulFlush = entry.channel.startFlush(3000, false);
                               if(!successfulFlush && log.isWarnEnabled()){
                                  log.warn("Flush failed at " + ch.getLocalAddress() + ch.getId());
                               }
                            }
                            mux.sendServiceDownMessage(ch.getId(), addr,true);
                        }
                        catch(Exception e) {
                            if(log.isErrorEnabled())
                                log.error("failed sending SERVICE_DOWN message", e);
                        }
                        finally{
                           if(entry.channel.flushSupported())
                              entry.channel.stopFlush();
                        }
                        all_closed=mux.shutdown(); // closes JChannel if all MuxChannels are in closed state

                        //mux.unregister(ch.getId());
                    }
                }
                if(all_closed) {
View Full Code Here

            throw new IllegalArgumentException("stack name and service ID have to be non null");
       
        if(stack_name.length()==0 || id.length() == 0)
            throw new IllegalArgumentException("stack name and service ID have to non empty strings");
              
        Multiplexer mux = null;
        synchronized (channels) {
            if (!channels.containsKey(stack_name)) {
                JChannel ch = new JChannel(getConfig(stack_name));
                registerChannel(ch, stack_name);
                mux = new Multiplexer(ch);
                channels.put(stack_name, mux);
            } else {
                mux = channels.get(stack_name);
            }
        }
        if(register_for_state_transfer)
            mux.registerForStateTransfer(id, substate_id);
       
        Channel c = mux.createMuxChannel(id, stack_name);
        c.addChannelListener(new MuxFactoryChannelListener());
        return c;
    }
View Full Code Here

     * @param id
     *            service id
     * @return true if such MuxChannel exists, false otherwise
     */
   public boolean hasMuxChannel(String stack_name, String id) {
    Multiplexer entry = channels.get(stack_name);
    if (entry != null) {
      Set<String> services = entry.getServiceIds();
      return (services != null && services.contains(id));
    }
    return false;
  }
View Full Code Here

    @ManagedOperation
    public void destroy() {       
        synchronized (channels) {
            for(Map.Entry<String,Multiplexer> entry: channels.entrySet()){               
                Multiplexer m = entry.getValue();
                if(m != null){
                    m.closeAll();
                    m.close();
                }          
            }   
        }       
        unregister(domain + ":*");       
        channels.clear();
View Full Code Here

    @ManagedOperation
    public String dumpChannels() {
        StringBuilder sb = new StringBuilder();
        synchronized (channels) {
            for (Map.Entry<String, Multiplexer> entry : channels.entrySet()) {               
                Multiplexer m = entry.getValue();
                sb.append(entry.getKey()).append(": ").append(m.getServiceIds()).append("\n");
            }
        }
        return sb.toString();
    }
View Full Code Here

   
    private class MuxFactoryChannelListener extends ChannelListenerAdapter{

        public void channelClosed(Channel channel) {
            MuxChannel mch = (MuxChannel)channel;
            Multiplexer multiplexer = mch.getMultiplexer();
            boolean all_closed = multiplexer.close();
            if(all_closed) {
                channels.remove(mch.getStackName());
                unregister(domain + ":*,cluster=" + mch.getStackName());
            }
        }           
View Full Code Here

TOP

Related Classes of org.jgroups.mux.Multiplexer

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.