org.jgroups.mux
Class Multiplexer

java.lang.Object
  extended by org.jgroups.mux.Multiplexer
All Implemented Interfaces:
UpHandler

public class Multiplexer
extends java.lang.Object
implements UpHandler

Used for dispatching incoming messages. The Multiplexer implements UpHandler and registers with the associated JChannel (there can only be 1 Multiplexer per JChannel). When up() is called with a message, the header of the message is removed and the MuxChannel corresponding to the header's service ID is retrieved from the map, and MuxChannel.up() is called with the message.

Version:
$Id: Multiplexer.java,v 1.35.2.4 2007/02/12 18:42:34 vlada Exp $
Author:
Bela Ban

Constructor Summary
Multiplexer()
           
Multiplexer(JChannel channel)
           
 
Method Summary
 void addServiceIfNotPresent(java.lang.String id, MuxChannel ch)
           
 void blockOk()
          Called by a MuxChannel when BLOCK_OK is sent down
 boolean close()
           
 void closeAll()
           
 Channel createMuxChannel(JChannelFactory f, java.lang.String id, java.lang.String stack_name)
           
 void disconnect()
          Closes the underlying JChannel if all MuxChannels have been disconnected
 void fetchServiceInformation()
          Fetches the map of services and hosts from the coordinator (Multiplexer).
 java.util.Set getApplicationIds()
          Deprecated. Use ${link #getServiceIds()} instead
 java.util.Set getServiceIds()
           
 long getServicesResponseTimeout()
           
 View getServiceView(java.lang.String service_id)
          Returns a copy of the current view minus the nodes on which service service_id is not running
 boolean getState(Address target, java.lang.String id, long timeout)
           
 Address getStateProvider(Address preferredTarget, java.lang.String service_id)
          Returns an Address of a state provider for a given service_id.
 void registerForStateTransfer(java.lang.String appl_id, java.lang.String substate_id)
           
 MuxChannel remove(java.lang.String id)
           
 void sendServiceDownMessage(java.lang.String service, Address host, boolean bypassFlush)
           
 void sendServiceUpMessage(java.lang.String service, Address host, boolean bypassFlush)
           
 void setServicesResponseTimeout(long services_rsp_timeout)
           
 boolean shutdown()
           
 boolean stateTransferListenersPresent()
           
 void unregister(java.lang.String appl_id)
           
 void up(Event evt)
          Invoked for all channel events except connection management and state transfer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Multiplexer

public Multiplexer()

Multiplexer

public Multiplexer(JChannel channel)
Method Detail

getApplicationIds

public java.util.Set getApplicationIds()
Deprecated. Use ${link #getServiceIds()} instead

Returns:
The set of service IDs

getServiceIds

public java.util.Set getServiceIds()

getServicesResponseTimeout

public long getServicesResponseTimeout()

setServicesResponseTimeout

public void setServicesResponseTimeout(long services_rsp_timeout)

getServiceView

public View getServiceView(java.lang.String service_id)
Returns a copy of the current view minus the nodes on which service service_id is not running

Parameters:
service_id -
Returns:
The service view

stateTransferListenersPresent

public boolean stateTransferListenersPresent()

blockOk

public void blockOk()
Called by a MuxChannel when BLOCK_OK is sent down


registerForStateTransfer

public void registerForStateTransfer(java.lang.String appl_id,
                                     java.lang.String substate_id)

getState

public boolean getState(Address target,
                        java.lang.String id,
                        long timeout)
                 throws ChannelNotConnectedException,
                        ChannelClosedException
Throws:
ChannelNotConnectedException
ChannelClosedException

fetchServiceInformation

public void fetchServiceInformation()
                             throws java.lang.Exception
Fetches the map of services and hosts from the coordinator (Multiplexer). No-op if we are the coordinator

Throws:
java.lang.Exception

sendServiceUpMessage

public void sendServiceUpMessage(java.lang.String service,
                                 Address host,
                                 boolean bypassFlush)
                          throws java.lang.Exception
Throws:
java.lang.Exception

sendServiceDownMessage

public void sendServiceDownMessage(java.lang.String service,
                                   Address host,
                                   boolean bypassFlush)
                            throws java.lang.Exception
Throws:
java.lang.Exception

up

public void up(Event evt)
Description copied from interface: UpHandler
Invoked for all channel events except connection management and state transfer.

Specified by:
up in interface UpHandler

createMuxChannel

public Channel createMuxChannel(JChannelFactory f,
                                java.lang.String id,
                                java.lang.String stack_name)
                         throws java.lang.Exception
Throws:
java.lang.Exception

remove

public MuxChannel remove(java.lang.String id)

disconnect

public void disconnect()
Closes the underlying JChannel if all MuxChannels have been disconnected


unregister

public void unregister(java.lang.String appl_id)

close

public boolean close()

closeAll

public void closeAll()

shutdown

public boolean shutdown()

getStateProvider

public Address getStateProvider(Address preferredTarget,
                                java.lang.String service_id)
Returns an Address of a state provider for a given service_id. If preferredTarget is a member of a service view for a given service_id then preferredTarget is returned. Otherwise, service view coordinator is returned if such node exists. If service view is empty for a given service_id null is returned.

Parameters:
preferredTarget -
service_id -
Returns:

addServiceIfNotPresent

public void addServiceIfNotPresent(java.lang.String id,
                                   MuxChannel ch)


Copyright ? 1998-2006 Bela Ban. All Rights Reserved.