Class McastService

    • Field Detail

      • sm

        protected static final StringManager sm
        The string manager for this package.
      • properties

        protected java.util.Properties properties
        The implementation specific properties
      • impl

        protected McastServiceImpl impl
        A handle to the actual low level implementation
      • listener

        protected volatile 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

        protected static final Member[] EMPTY_MEMBERS
        Return all the members
    • Constructor Detail

      • McastService

        public McastService()
        Create a membership service.
    • Method Detail

      • setProperties

        public void setProperties​(java.util.Properties properties)
        Sets the properties for the membership service.
        Specified by:
        setProperties in interface MembershipService
        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
        java.lang.IllegalArgumentException - if a property is missing.
      • getLocalMember

        public Member getLocalMember​(boolean alive)
        Description copied from interface: MembershipService
        Get the local member.
        Specified by:
        getLocalMember in interface MembershipService
        alive - true to set the alive time on the local member
        the member object that defines this member
      • setLocalMemberProperties

        public void setLocalMemberProperties​(java.lang.String listenHost,
                                             int listenPort,
                                             int securePort,
                                             int udpPort)
        Description copied from interface: MembershipService
        Sets the local member properties for broadcasting.
        Specified by:
        setLocalMemberProperties in interface MembershipService
        listenHost - Listen to host
        listenPort - Listen to port
        securePort - Use a secure port
        udpPort - Use UDP
      • setAddress

        public void setAddress​(java.lang.String addr)
      • setMcastBindAddress

        public void setMcastBindAddress​(java.lang.String bindaddr)
      • setBind

        public void setBind​(java.lang.String bindaddr)
      • setPort

        public void setPort​(int port)
      • setRecoveryCounter

        public void setRecoveryCounter​(int recoveryCounter)
      • setRecoveryEnabled

        public void setRecoveryEnabled​(boolean recoveryEnabled)
      • setRecoverySleepTime

        public void setRecoverySleepTime​(long recoverySleepTime)
      • setLocalLoopbackDisabled

        public void setLocalLoopbackDisabled​(boolean localLoopbackDisabled)
      • setFrequency

        public void setFrequency​(long time)
      • setMcastDropTime

        public void setMcastDropTime​(long time)
      • setDropTime

        public void setDropTime​(long time)
      • hasProperty

        protected void hasProperty​(java.util.Properties properties,
                                   java.lang.String name)
        Check if a required property is available.
        properties - The set of properties
        name - The property to check for
      • start

        public void start()
                   throws java.lang.Exception
        Start broadcasting and listening to membership pings
        Specified by:
        start in interface MembershipService
        java.lang.Exception - if a IO error occurs
      • start

        public void start​(int level)
                   throws java.lang.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
        level - - level MBR_RX starts listening for members, level MBR_TX starts broad casting the server
        java.lang.Exception - if the service fails to start.
        java.lang.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
        svc - - level MBR_RX stops listening for members, level MBR_TX stops broad casting the server
      • getMember

        public Member getMember​(Member mbr)
        Description copied from interface: MembershipService
        Retrieve the specified member from the membership.
        Specified by:
        getMember in interface MembershipService
        mbr - The member to retrieve
        the member
      • 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
        listener - The listener
      • setMessageListener

        public void setMessageListener​(MessageListener listener)
      • removeMessageListener

        public void removeMessageListener()
      • setSoTimeout

        public void setSoTimeout​(int mcastSoTimeout)
      • getPayload

        public byte[] getPayload()
      • 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
        payload - byte[]
      • setDomain

        public void setDomain​(java.lang.String domain)
      • setChannel

        public void setChannel​(Channel channel)
        Description copied from interface: MembershipService
        Set the channel that is related to this MembershipService
        Specified by:
        setChannel in interface MembershipService
        channel - The channel
      • setDefaults

        protected void setDefaults​(java.util.Properties properties)
      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.Exception
        Simple test program
        args - Command-line arguments
        java.lang.Exception - If an error occurs