Overview | Package | Class | Tree | Deprecated | Index | Help
| Apache Tomcat 7.0.29
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.catalina.tribes.membership
Class McastService

    java.lang.Object
      org.apache.catalina.tribes.membership.McastService

All Implemented Interfaces:
  MembershipListener, MembershipService, MessageListener

    public class McastService

extends Object
implements MembershipService, MembershipListener, MessageListener

A membership implementation using simple multicast. This is the representation of a multicast membership service. This class is responsible for maintaining a list of active cluster nodes in the cluster. If a node fails to send out a heartbeat, the node will be dismissed.

Version:
  $Id: McastService.java 1142672 2011-07-04 14:02:36Z kkolinko $
Author:
  Filip Hanik

Field Summary
`protected byte[]` | `domain`
`protected static Member[]` | `EMPTY_MEMBERS` Return all the members
`protected McastServiceImpl` | `impl` A handle to the actual low level implementation
`protected MembershipListener` | `listener` A membership listener delegate (should be the cluster :)
`protected MemberImpl` | `localMember` The local member
`protected MessageListener` | `msglistener` A message listener delegate for broadcasts
`protected byte[]` | `payload`
`protected Properties` | `properties` The implementation specific properties
`protected static StringManager` | `sm` The string manager for this package.

Fields inherited from interface org.apache.catalina.tribes.MembershipService
`MBR_RX, MBR_TX`

Constructor Summary
`McastService()` Create a membership service.

Method Summary
`boolean` | `accept(ChannelMessage msg)`
`void` | `broadcast(ChannelMessage message)` Broadcasts a message to all members
`Member` | `findMemberByName(String name)` Return the member by name
`String` | `getAddress()`
`String` | `getBind()`
`byte[]` | `getDomain()`
`long` | `getDropTime()`
`long` | `getFrequency()`
`String` | `getInfo()` Return descriptive information about this implementation and the corresponding version number, in the format `<description>/<version>`.
`boolean` | `getLocalLoopbackDisabled(boolean localLoopbackDisabled)`
`Member` | `getLocalMember(boolean alive)` Return the local member
`String` | `getLocalMemberName()` Return the local member name
`String` | `getMcastAddr()` Deprecated. use getAddress
`String` | `getMcastBindAddress()` Deprecated. use getBind
`long` | `getMcastDropTime()` Deprecated. use getDropTime
`long` | `getMcastFrequency()` Deprecated. use getFrequency
`int` | `getMcastPort()` Deprecated. use getPort()
`int` | `getMcastSoTimeout()` Deprecated. use getSoTimeout
`int` | `getMcastTTL()` Deprecated. use getTtl
`Member` | `getMember(Member mbr)`
`Member[]` | `getMembers()` Returns a list of all the members in the cluster.
`String[]` | `getMembersByName()` Return all the members by name
`byte[]` | `getPayload()`
`int` | `getPort()`
`Properties` | `getProperties()` Return the properties, see setProperties
`int` | `getRecoveryCounter()`
`boolean` | `getRecoveryEnabled()`
`long` | `getRecoverySleepTime()`
`int` | `getSoTimeout()`
`int` | `getTtl()`
`boolean` | `hasMembers()` has members?
`protected void` | `hasProperty(Properties properties, String name)` Check if a required property is available.
`static void` | `main(String[] args)` Simple test program
`void` | `memberAdded(Member member)` A member was added to the group
`void` | `memberDisappeared(Member member)` Callback from the impl when a new member has been received
`void` | `messageReceived(ChannelMessage msg)` Receive a message from the IO components in the Channel stack
`void` | `removeMembershipListener()` Remove the membership listener
`void` | `removeMessageListener()`
`void` | `setAddress(String addr)`
`void` | `setBind(String bindaddr)`
`void` | `setDomain(byte[] domain)`
`void` | `setDomain(String domain)`
`void` | `setDropTime(long time)`
`void` | `setFrequency(long time)`
`void` | `setLocalLoopbackDisabled(boolean localLoopbackDisabled)`
`void` | `setLocalMemberProperties(String listenHost, int listenPort, int securePort, int udpPort)` Sets the local member properties for broadcasting
`void` | `setMcastAddr(String addr)` Deprecated. use setAddress
`void` | `setMcastBindAddress(String bindaddr)`
`void` | `setMcastDropTime(long time)`
`void` | `setMcastFrequency(long time)` Deprecated. use setFrequency
`void` | `setMcastPort(int port)` Deprecated. use setPort
`void` | `setMcastSoTimeout(int mcastSoTimeout)` Deprecated. use setSoTimeout
`void` | `setMcastTTL(int mcastTTL)` Deprecated. use setTtl
`void` | `setMembershipListener(MembershipListener listener)` Add a membership listener, this version only supports one listener per service, so calling this method twice will result in only the second listener being active.
`void` | `setMessageListener(MessageListener listener)`
`void` | `setPayload(byte[] payload)` Set a payload to be broadcasted with each membership broadcast.
`void` | `setPort(int port)`
`void` | `setProperties(Properties properties)` Sets the properties for the membership service.
`void` | `setRecoveryCounter(int recoveryCounter)`
`void` | `setRecoveryEnabled(boolean recoveryEnabled)`
`void` | `setRecoverySleepTime(long recoverySleepTime)`
`void` | `setSoTimeout(int mcastSoTimeout)`
`void` | `setTtl(int mcastTTL)`
`void` | `start()` Start broadcasting and listening to membership pings
`void` | `start(int level)` Starts the membership service.
`void` | `stop(int svc)` Stop broadcasting and listening to membership pings

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.apache.catalina.tribes.MessageListener
`equals, hashCode`

Field Detail

### sm

    protected static final StringManager sm

  The string manager for this package.

### properties

    protected Properties properties

  The implementation specific properties

### impl

    protected McastServiceImpl impl

  A handle to the actual low level implementation

### listener

    protected MembershipListener listener

  A membership listener delegate (should be the cluster :)

### msglistener

    protected MessageListener msglistener

  A message listener delegate for broadcasts

### localMember

    protected MemberImpl localMember

  The local member

### payload

    protected byte[] payload

### domain

    protected byte[] domain

### EMPTY_MEMBERS

    protected static final Member[] EMPTY_MEMBERS

  Return all the members

Constructor Detail

### McastService

    public McastService()

  Create a membership service.

Method Detail

### getInfo

    public String getInfo()

  Return descriptive information about this implementation and the corresponding version number, in the format `<description>/<version>`.

### setProperties

    public void setProperties(Properties properties)

  Description copied from interface: `MembershipService`
  Sets the properties for the membership service. This must be called before the `start()` method is called. The properties are implementation specific.

  Specified by:
    `setProperties` in interface `MembershipService`
  Parameters:
    `properties` -
    All are required
    1. mcastPort - the port to listen to
    2. mcastAddress - the mcast group address
    4. bindAddress - the bind address if any - only one that can be null
    5. memberDropTime - the time a member is gone before it is considered gone.
    6. mcastFrequency - the frequency of sending messages
    7. tcpListenPort - the port this member listens to
    8. tcpListenHost - the bind address of this member
  Throws:
    `IllegalArgumentException` - if a property is missing.

### getProperties

    public Properties getProperties()

  Return the properties, see setProperties

  Specified by:
    `getProperties` in interface `MembershipService`

### getLocalMemberName

    public String getLocalMemberName()

  Return the local member name

### getLocalMember

    public Member getLocalMember(boolean alive)

  Return the local member

  Specified by:
    `getLocalMember` in interface `MembershipService`

### setLocalMemberProperties

    public void setLocalMemberProperties(String listenHost,
                                         int listenPort,
                                         int securePort,
                                         int udpPort)

  Sets the local member properties for broadcasting

  Specified by:
    `setLocalMemberProperties` in interface `MembershipService`

### setAddress

    public void setAddress(String addr)

### setMcastAddr

    @Deprecated
    public void setMcastAddr(String addr)

  Deprecated. use setAddress

  Parameters:
    `addr` - String

### getAddress

    public String getAddress()

### getMcastAddr

    @Deprecated
    public String getMcastAddr()

  Deprecated. use getAddress

  Returns:
    String

### setMcastBindAddress

    public void setMcastBindAddress(String bindaddr)

### setBind

    public void setBind(String bindaddr)

### getMcastBindAddress

    @Deprecated
    public String getMcastBindAddress()

  Deprecated. use getBind

  Returns:
    String

### getBind

    public String getBind()

### setMcastPort

    @Deprecated
    public void setMcastPort(int port)

  Deprecated. use setPort

  Parameters:
    `port` - int

### setPort

    public void setPort(int port)

### setRecoveryCounter

    public void setRecoveryCounter(int recoveryCounter)

### getRecoveryCounter

    public int getRecoveryCounter()

### setRecoveryEnabled

    public void setRecoveryEnabled(boolean recoveryEnabled)

### getRecoveryEnabled

    public boolean getRecoveryEnabled()

### setRecoverySleepTime

    public void setRecoverySleepTime(long recoverySleepTime)

### getRecoverySleepTime

    public long getRecoverySleepTime()

### setLocalLoopbackDisabled

    public void setLocalLoopbackDisabled(boolean localLoopbackDisabled)

### getLocalLoopbackDisabled

    public boolean getLocalLoopbackDisabled(boolean localLoopbackDisabled)

### getMcastPort

    @Deprecated
    public int getMcastPort()

  Deprecated. use getPort()

  Returns:
    int

### getPort

    public int getPort()

### setMcastFrequency

    @Deprecated
    public void setMcastFrequency(long time)

  Deprecated. use setFrequency

  Parameters:
    `time` - long

### setFrequency

    public void setFrequency(long time)

### getMcastFrequency

    @Deprecated
    public long getMcastFrequency()

  Deprecated. use getFrequency

  Returns:
    long

### getFrequency

    public long getFrequency()

### setMcastDropTime

    public void setMcastDropTime(long time)

### setDropTime

    public void setDropTime(long time)

### getMcastDropTime

    @Deprecated
    public long getMcastDropTime()

  Deprecated. use getDropTime

  Returns:
    long

### getDropTime

    public long getDropTime()

### hasProperty

    protected void hasProperty(Properties properties,
                               String name)

  Check if a required property is available.

  Parameters:
    `properties` - The set of properties
    `name` - The property to check for

### start

    public void start()
               throws Exception

  Start broadcasting and listening to membership pings

  Specified by:
    `start` in interface `MembershipService`
  Throws:
    `Exception` - if a IO error occurs

### start

    public void start(int level)
               throws Exception

  Description copied from interface: `MembershipService`
  Starts the membership service. If a membership listeners is added the listener will start to receive membership events.

  Specified by:
    `start` in interface `MembershipService`
  Parameters:
    `level` - - level MBR_RX starts listening for members, level MBR_TX starts broad casting the server
  Throws:
    `Exception` - if the service fails to start.
    `IllegalArgumentException` - if the level is incorrect.

### stop

    public void stop(int svc)

  Stop broadcasting and listening to membership pings

  Specified by:
    `stop` in interface `MembershipService`
  Parameters:
    `svc` - - level MBR_RX stops listening for members, level MBR_TX stops broad casting the server

### getMembersByName

    public String[] getMembersByName()

  Return all the members by name

  Specified by:
    `getMembersByName` in interface `MembershipService`

### findMemberByName

    public Member findMemberByName(String name)

  Return the member by name

  Specified by:
    `findMemberByName` in interface `MembershipService`

### hasMembers

    public boolean hasMembers()

  has members?

  Specified by:
    `hasMembers` in interface `MembershipService`
  Returns:
    true if the the group contains members

### getMember

    public Member getMember(Member mbr)

  Specified by:
    `getMember` in interface `MembershipService`
  Parameters:
    `mbr` - Member
  Returns:
    Member

### getMembers

    public Member[] getMembers()

  Description copied from interface: `MembershipService`
  Returns a list of all the members in the cluster.

  Specified by:
    `getMembers` in interface `MembershipService`

### setMembershipListener

    public void setMembershipListener(MembershipListener listener)

  Add a membership listener, this version only supports one listener per service, so calling this method twice will result in only the second listener being active.

  Specified by:
    `setMembershipListener` in interface `MembershipService`
  Parameters:
    `listener` - The listener

### setMessageListener

    public void setMessageListener(MessageListener listener)

### removeMessageListener

    public void removeMessageListener()

### removeMembershipListener

    public void removeMembershipListener()

  Remove the membership listener

  Specified by:
    `removeMembershipListener` in interface `MembershipService`

### memberAdded

    public void memberAdded(Member member)

  Description copied from interface: `MembershipListener`
  A member was added to the group

  Specified by:
    `memberAdded` in interface `MembershipListener`
  Parameters:
    `member` - Member - the member that was added

### memberDisappeared

    public void memberDisappeared(Member member)

  Callback from the impl when a new member has been received

  Specified by:
    `memberDisappeared` in interface `MembershipListener`
  Parameters:
    `member` - The member
  See Also:
    `Member.SHUTDOWN_PAYLOAD`

### messageReceived

    public void messageReceived(ChannelMessage msg)

  Description copied from interface: `MessageListener`
  Receive a message from the IO components in the Channel stack

  Specified by:
    `messageReceived` in interface `MessageListener`
  Parameters:
    `msg` - ChannelMessage

### accept

    public boolean accept(ChannelMessage msg)

  Specified by:
    `accept` in interface `MessageListener`

### broadcast

    public void broadcast(ChannelMessage message)
                   throws ChannelException

  Description copied from interface: `MembershipService`
  Broadcasts a message to all members

  Specified by:
    `broadcast` in interface `MembershipService`
  Throws:
    `ChannelException`

### getMcastSoTimeout

    @Deprecated
    public int getMcastSoTimeout()

  Deprecated. use getSoTimeout

  Returns:
    int

### getSoTimeout

    public int getSoTimeout()

### setMcastSoTimeout

    @Deprecated
    public void setMcastSoTimeout(int mcastSoTimeout)

  Deprecated. use setSoTimeout

  Parameters:
    `mcastSoTimeout` - int

### setSoTimeout

    public void setSoTimeout(int mcastSoTimeout)

### getMcastTTL

    @Deprecated
    public int getMcastTTL()

  Deprecated. use getTtl

  Returns:
    int

### getTtl

    public int getTtl()

### getPayload

    public byte[] getPayload()

### getDomain

    public byte[] getDomain()

### setMcastTTL

    @Deprecated
    public void setMcastTTL(int mcastTTL)

  Deprecated. use setTtl

  Parameters:
    `mcastTTL` - int

### setTtl

    public void setTtl(int mcastTTL)

### setPayload

    public void setPayload(byte[] payload)

  Description copied from interface: `MembershipService`
  Set a payload to be broadcasted with each membership broadcast.

  Specified by:
    `setPayload` in interface `MembershipService`
  Parameters:
    `payload` - byte[]

### setDomain

    public void setDomain(byte[] domain)

  Specified by:
    `setDomain` in interface `MembershipService`

### setDomain

    public void setDomain(String domain)

### main

    public static void main(String[] args)
                     throws Exception

  Simple test program

  Parameters:
    `args` - Command-line arguments
  Throws:
    `Exception` - If an error occurs

Overview | Package | Class | Tree | Deprecated | Index | Help
| Apache Tomcat 7.0.29
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.