org.infinispan.remoting.transport.jgroups
Class JGroupsTransport

java.lang.Object
  extended by org.infinispan.remoting.transport.jgroups.JGroupsTransport
All Implemented Interfaces:
Lifecycle, Transport, org.jgroups.ExtendedMembershipListener, org.jgroups.ExtendedMessageListener, org.jgroups.MembershipListener, org.jgroups.MessageListener

public class JGroupsTransport
extends Object
implements Transport, org.jgroups.ExtendedMembershipListener, org.jgroups.ExtendedMessageListener

An encapsulation of a JGroups transport. JGroups transports can be configured using a variety of methods, usually by passing in one of the following properties:

These are normally passed in as Properties in GlobalConfiguration.setTransportProperties(java.util.Properties) or in the Infinispan XML configuration file.

Since:
4.0
Author:
Manik Surtani, Galder ZamarreƱo

Field Summary
protected  Address address
           
protected  ExecutorService asyncExecutor
           
protected  GlobalConfiguration c
           
protected  org.jgroups.Channel channel
           
static String CHANNEL_LOOKUP
           
static String CONFIGURATION_FILE
           
static String CONFIGURATION_STRING
           
static String CONFIGURATION_XML
           
protected  boolean coordinator
           
protected  boolean createdChannel
           
protected static String DEFAULT_JGROUPS_CONFIGURATION_FILE
           
protected  InboundInvocationHandler inboundInvocationHandler
           
protected  Marshaller marshaller
           
protected  List<Address> members
           
protected  Object membersListLock
           
protected  CacheManagerNotifier notifier
           
protected  Address physicalAddress
           
protected  TypedProperties props
           
protected  boolean startChannel
           
protected  boolean stopChannel
           
 
Constructor Summary
JGroupsTransport()
           
JGroupsTransport(org.jgroups.Channel channel)
          This form is used when the transport is created by an external source and passed in to the GlobalConfiguration.
 
Method Summary
 void block()
           
 Address getAddress()
          Retrieves the current cache instance's network address
 org.jgroups.Channel getChannel()
           
 CommandAwareRpcDispatcher getCommandAwareRpcDispatcher()
           
 Address getCoordinator()
           
 DistributedSync getDistributedSync()
           
 List<Address> getMembers()
          Returns a list of members in the current cluster view.
 List<Address> getPhysicalAddresses()
          Retrieves the current cache instance's physical network addresses.
 byte[] getState()
           
 void getState(OutputStream ostream)
           
 byte[] getState(String state_id)
           
 void getState(String cacheName, OutputStream ostream)
           
 int getViewId()
           
protected  void initChannel()
           
 void initialize(GlobalConfiguration c, Marshaller marshaller, ExecutorService asyncExecutor, InboundInvocationHandler inboundInvocationHandler, CacheManagerNotifier notifier)
          Initializes the transport with global cache configuration and transport-specific properties.
 List<Response> invokeRemotely(Collection<Address> recipients, ReplicableCommand rpcCommand, ResponseMode mode, long timeout, boolean usePriorityQueue, ResponseFilter responseFilter, boolean supportReplay)
          Invokes an RPC call on other caches in the cluster.
 boolean isCoordinator()
           
 boolean isSupportStateTransfer()
          Tests whether the transport supports state transfer
 void receive(org.jgroups.Message msg)
           
 boolean retrieveState(String cacheName, Address address, long timeout)
          Initiates a state retrieval from a specific cache (by typically invoking InboundInvocationHandler.generateState(String, java.io.OutputStream)), and applies this state to the current cache via the InboundInvocationHandler.applyState(String, java.io.InputStream) callback.
 void setState(byte[] state)
           
 void setState(InputStream istream)
           
 void setState(String state_id, byte[] state)
           
 void setState(String cacheName, InputStream istream)
           
 void start()
           
protected  void startJGroupsChannelIfNeeded()
           
 void stop()
           
 void suspect(org.jgroups.Address suspected_mbr)
           
 void unblock()
           
 void viewAccepted(org.jgroups.View newView)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIGURATION_STRING

public static final String CONFIGURATION_STRING
See Also:
Constant Field Values

CONFIGURATION_XML

public static final String CONFIGURATION_XML
See Also:
Constant Field Values

CONFIGURATION_FILE

public static final String CONFIGURATION_FILE
See Also:
Constant Field Values

CHANNEL_LOOKUP

public static final String CHANNEL_LOOKUP
See Also:
Constant Field Values

DEFAULT_JGROUPS_CONFIGURATION_FILE

protected static final String DEFAULT_JGROUPS_CONFIGURATION_FILE
See Also:
Constant Field Values

startChannel

protected boolean startChannel

stopChannel

protected boolean stopChannel

channel

protected org.jgroups.Channel channel

createdChannel

protected boolean createdChannel

address

protected Address address

physicalAddress

protected Address physicalAddress

members

protected volatile List<Address> members

coordinator

protected volatile boolean coordinator

membersListLock

protected final Object membersListLock

c

protected GlobalConfiguration c

props

protected TypedProperties props

inboundInvocationHandler

protected InboundInvocationHandler inboundInvocationHandler

marshaller

protected Marshaller marshaller

asyncExecutor

protected ExecutorService asyncExecutor

notifier

protected CacheManagerNotifier notifier
Constructor Detail

JGroupsTransport

public JGroupsTransport(org.jgroups.Channel channel)
This form is used when the transport is created by an external source and passed in to the GlobalConfiguration.

Parameters:
channel - created and running channel to use

JGroupsTransport

public JGroupsTransport()
Method Detail

initialize

public void initialize(GlobalConfiguration c,
                       Marshaller marshaller,
                       ExecutorService asyncExecutor,
                       InboundInvocationHandler inboundInvocationHandler,
                       CacheManagerNotifier notifier)
Description copied from interface: Transport
Initializes the transport with global cache configuration and transport-specific properties.

Specified by:
initialize in interface Transport
Parameters:
c - global cache-wide configuration
marshaller - marshaller to use for marshalling and unmarshalling
asyncExecutor - executor to use for asynchronous calls
inboundInvocationHandler - handler for invoking remotely originating calls on the local cache
notifier - notifier to use

start

public void start()
Specified by:
start in interface Lifecycle
Specified by:
start in interface Transport

startJGroupsChannelIfNeeded

protected void startJGroupsChannelIfNeeded()

getViewId

public int getViewId()
Specified by:
getViewId in interface Transport

stop

public void stop()
Specified by:
stop in interface Lifecycle
Specified by:
stop in interface Transport

initChannel

protected void initChannel()

isCoordinator

public boolean isCoordinator()
Specified by:
isCoordinator in interface Transport
Returns:
true if the current Channel is the coordinator of the cluster.

getCoordinator

public Address getCoordinator()
Specified by:
getCoordinator in interface Transport
Returns:
the Address of the current coordinator.

getMembers

public List<Address> getMembers()
Description copied from interface: Transport
Returns a list of members in the current cluster view.

Specified by:
getMembers in interface Transport
Returns:
a list of members. Typically, this would be defensively copied.

retrieveState

public boolean retrieveState(String cacheName,
                             Address address,
                             long timeout)
                      throws StateTransferException
Description copied from interface: Transport
Initiates a state retrieval from a specific cache (by typically invoking InboundInvocationHandler.generateState(String, java.io.OutputStream)), and applies this state to the current cache via the InboundInvocationHandler.applyState(String, java.io.InputStream) callback.

Specified by:
retrieveState in interface Transport
Parameters:
cacheName - name of cache for which to retrieve state
address - address of remote cache from which to retrieve state
timeout - state retrieval timeout in milliseconds
Returns:
true if state was transferred and applied successfully, false if it timed out.
Throws:
StateTransferException - if state cannot be retrieved from the specific cache

getDistributedSync

public DistributedSync getDistributedSync()
Specified by:
getDistributedSync in interface Transport
Returns:
an instance of a DistributedSync that can be used to wait for synchronization events across a cluster.

isSupportStateTransfer

public boolean isSupportStateTransfer()
Description copied from interface: Transport
Tests whether the transport supports state transfer

Specified by:
isSupportStateTransfer in interface Transport
Returns:
true if the implementation supports state transfer, false otherwise.

getAddress

public Address getAddress()
Description copied from interface: Transport
Retrieves the current cache instance's network address

Specified by:
getAddress in interface Transport
Returns:
an Address

getPhysicalAddresses

public List<Address> getPhysicalAddresses()
Description copied from interface: Transport
Retrieves the current cache instance's physical network addresses. Some implementations might differentiate between logical and physical addresses in which case, this method allows clients to query the physical ones associated with the logical address. Implementations where logical and physical address are the same will simply return a single entry List that contains the same Address as Transport.getAddress().

Specified by:
getPhysicalAddresses in interface Transport
Returns:
an List of Address

invokeRemotely

public List<Response> invokeRemotely(Collection<Address> recipients,
                                     ReplicableCommand rpcCommand,
                                     ResponseMode mode,
                                     long timeout,
                                     boolean usePriorityQueue,
                                     ResponseFilter responseFilter,
                                     boolean supportReplay)
                              throws Exception
Description copied from interface: Transport
Invokes an RPC call on other caches in the cluster.

Specified by:
invokeRemotely in interface Transport
Parameters:
recipients - a list of Addresses to invoke the call on. If this is null, the call is broadcast to the entire cluster.
rpcCommand - the cache command to invoke
mode - the response mode to use
timeout - a timeout after which to throw a replication exception.
usePriorityQueue - if true, a priority queue is used to deliver messages. May not be supported by all implementations.
responseFilter - a response filter with which to filter out failed/unwanted/invalid responses.
supportReplay - whether replays of missed messages is supported
Returns:
a list of responses from each member contacted.
Throws:
Exception - in the event of problems.

viewAccepted

public void viewAccepted(org.jgroups.View newView)
Specified by:
viewAccepted in interface org.jgroups.MembershipListener

suspect

public void suspect(org.jgroups.Address suspected_mbr)
Specified by:
suspect in interface org.jgroups.MembershipListener

block

public void block()
Specified by:
block in interface org.jgroups.MembershipListener

unblock

public void unblock()
Specified by:
unblock in interface org.jgroups.ExtendedMembershipListener

receive

public void receive(org.jgroups.Message msg)
Specified by:
receive in interface org.jgroups.MessageListener

getState

public byte[] getState()
Specified by:
getState in interface org.jgroups.MessageListener

setState

public void setState(byte[] state)
Specified by:
setState in interface org.jgroups.MessageListener

getState

public byte[] getState(String state_id)
Specified by:
getState in interface org.jgroups.ExtendedMessageListener

setState

public void setState(String state_id,
                     byte[] state)
Specified by:
setState in interface org.jgroups.ExtendedMessageListener

getState

public void getState(OutputStream ostream)
Specified by:
getState in interface org.jgroups.ExtendedMessageListener

getState

public void getState(String cacheName,
                     OutputStream ostream)
Specified by:
getState in interface org.jgroups.ExtendedMessageListener

setState

public void setState(InputStream istream)
Specified by:
setState in interface org.jgroups.ExtendedMessageListener

setState

public void setState(String cacheName,
                     InputStream istream)
Specified by:
setState in interface org.jgroups.ExtendedMessageListener

getCommandAwareRpcDispatcher

public CommandAwareRpcDispatcher getCommandAwareRpcDispatcher()

getChannel

public org.jgroups.Channel getChannel()

Google Analytics

Copyright © 2010 JBoss, a division of Red Hat. All Rights Reserved.