Class GroupChannel

    • Field Detail

      • heartbeat

        protected boolean heartbeat
        Flag to determine if the channel manages its own heartbeat If set to true, the channel will start a local thread for the heart beat.
      • heartbeatSleeptime

        protected long heartbeatSleeptime
        If heartbeat == true then how often do we want this heartbeat to run. The default value is 5000 milliseconds.
      • heartbeatFuture

        protected java.util.concurrent.ScheduledFuture<?> heartbeatFuture
        Internal heartbeat future
      • monitorFuture

        protected java.util.concurrent.ScheduledFuture<?> monitorFuture
      • coordinator

        protected final ChannelCoordinator coordinator
        The ChannelCoordinator coordinates the bottom layer components:
        - MembershipService
        - ChannelSender
        - ChannelReceiver
      • interceptors

        protected ChannelInterceptor interceptors
        The first interceptor in the interceptor stack. The interceptors are chained in a linked list, so we only need a reference to the first one
      • membershipListeners

        protected final java.util.List<MembershipListener> membershipListeners
        A list of membership listeners that subscribe to membership announcements
      • channelListeners

        protected final java.util.List<ChannelListener> channelListeners
        A list of channel listeners that subscribe to incoming messages
      • optionCheck

        protected boolean optionCheck
        If set to true, the GroupChannel will check to make sure that
      • name

        protected java.lang.String name
        the name of this channel.
      • utilityExecutor

        protected java.util.concurrent.ScheduledExecutorService utilityExecutor
        Executor service.
      • ownExecutor

        protected boolean ownExecutor
    • Constructor Detail

      • GroupChannel

        public GroupChannel()
        Creates a GroupChannel. This constructor will also add the first interceptor in the GroupChannel.
        The first interceptor is always the channel itself.
    • Method Detail

      • addInterceptor

        public void addInterceptor​(ChannelInterceptor interceptor)
        Adds an interceptor to the stack for message processing
        Interceptors are ordered in the way they are added.
        channel.addInterceptor(A);
        channel.addInterceptor(C);
        channel.addInterceptor(B);
        Will result in an interceptor stack like this:
        A -> C -> B
        The complete stack will look like this:
        Channel -> A -> C -> B -> ChannelCoordinator
        Specified by:
        addInterceptor in interface Channel
        Parameters:
        interceptor - ChannelInterceptorBase
      • send

        public UniqueId send​(Member[] destination,
                             java.io.Serializable msg,
                             int options)
                      throws ChannelException
        Send a message to the destinations specified
        Specified by:
        send in interface Channel
        Specified by:
        send in interface GroupChannelMBean
        Parameters:
        destination - Member[] - destination.length > 0
        msg - Serializable - the message to send
        options - sender options, options can trigger guarantee levels and different interceptors to react to the message see class documentation for the Channel object.
        Returns:
        UniqueId - the unique Id that was assigned to this message
        Throws:
        ChannelException - - if an error occurs processing the message
        See Also:
        Channel
      • send

        public UniqueId send​(Member[] destination,
                             java.io.Serializable msg,
                             int options,
                             ErrorHandler handler)
                      throws ChannelException
        Description copied from interface: Channel
        Send a message to one or more members in the cluster
        Specified by:
        send in interface Channel
        Specified by:
        send in interface GroupChannelMBean
        Parameters:
        destination - Member[] - destination.length > 0
        msg - Serializable - the message to send
        options - sender options, options can trigger guarantee levels and different interceptors to react to the message see class documentation for the Channel object.
        handler - - callback object for error handling and completion notification, used when a message is sent asynchronously using the Channel.SEND_OPTIONS_ASYNCHRONOUS flag enabled.
        Returns:
        UniqueId - the unique Id that was assigned to this message
        Throws:
        ChannelException - - if an error occurs processing the message
        See Also:
        Channel
      • messageReceived

        public void messageReceived​(ChannelMessage msg)
        Callback from the interceptor stack.
        When a message is received from a remote node, this method will be invoked by the previous interceptor.
        This method can also be used to send a message to other components within the same application, but its an extreme case, and you're probably better off doing that logic between the applications itself.
        Specified by:
        messageReceived in interface ChannelInterceptor
        Overrides:
        messageReceived in class ChannelInterceptorBase
        Parameters:
        msg - ChannelMessage
      • sendNoRpcChannelReply

        protected void sendNoRpcChannelReply​(RpcMessage msg,
                                             Member destination)
        Sends a NoRpcChannelReply message to a member
        This method gets invoked by the channel if an RPC message comes in and no channel listener accepts the message. This avoids timeout
        Parameters:
        msg - RpcMessage
        destination - Member - the destination for the reply
      • memberAdded

        public void memberAdded​(Member member)
        memberAdded gets invoked by the interceptor below the channel and the channel will broadcast it to the membership listeners
        Specified by:
        memberAdded in interface MembershipListener
        Overrides:
        memberAdded in class ChannelInterceptorBase
        Parameters:
        member - Member - the new member
      • setupDefaultStack

        protected void setupDefaultStack()
                                  throws ChannelException
        Sets up the default implementation interceptor stack if no interceptors have been added
        Throws:
        ChannelException - Cluster error
      • checkOptionFlags

        protected void checkOptionFlags()
                                 throws ChannelException
        Validates the option flags that each interceptor is using and reports an error if two interceptor share the same flag.
        Throws:
        ChannelException - Error with option flag
      • startHeartbeat

        protected void startHeartbeat()
      • getFirstInterceptor

        public ChannelInterceptor getFirstInterceptor()
        Returns the first interceptor of the stack. Useful for traversal.
        Returns:
        ChannelInterceptor
      • getUtilityExecutor

        public java.util.concurrent.ScheduledExecutorService getUtilityExecutor()
        Description copied from interface: Channel
        Return executor that can be used for utility tasks.
        Specified by:
        getUtilityExecutor in interface Channel
        Returns:
        the executor
      • setUtilityExecutor

        public void setUtilityExecutor​(java.util.concurrent.ScheduledExecutorService utilityExecutor)
        Description copied from interface: Channel
        Set the executor that can be used for utility tasks.
        Specified by:
        setUtilityExecutor in interface Channel
        Parameters:
        utilityExecutor - the executor
      • setOptionCheck

        public void setOptionCheck​(boolean optionCheck)
        Enables/disables the option check
        Setting this to true, will make the GroupChannel perform a conflict check on the interceptors. If two interceptors are using the same option flag and throw an error upon start.
        Parameters:
        optionCheck - boolean
      • setHeartbeatSleeptime

        public void setHeartbeatSleeptime​(long heartbeatSleeptime)
        Configure local heartbeat sleep time
        Only used when getHeartbeat()==true
        Parameters:
        heartbeatSleeptime - long - time in milliseconds to sleep between heartbeats
      • setHeartbeat

        public void setHeartbeat​(boolean heartbeat)
        Enables or disables local heartbeat. if setHeartbeat(true) is invoked then the channel will start an internal thread to invoke Channel.heartbeat() every getHeartbeatSleeptime milliseconds
        Specified by:
        setHeartbeat in interface Channel
        Parameters:
        heartbeat - boolean
        See Also:
        Channel.heartbeat()
      • getHeartbeatSleeptime

        public long getHeartbeatSleeptime()
        Returns the sleep time in milliseconds that the internal heartbeat will sleep in between invocations of Channel.heartbeat()
        Specified by:
        getHeartbeatSleeptime in interface GroupChannelMBean
        Returns:
        long
      • getName

        public java.lang.String getName()
        Description copied from interface: Channel
        Return the name of this channel.
        Specified by:
        getName in interface Channel
        Returns:
        channel name
      • setName

        public void setName​(java.lang.String name)
        Description copied from interface: Channel
        Set the name of this channel
        Specified by:
        setName in interface Channel
        Parameters:
        name - The new channel name
      • isJmxEnabled

        public boolean isJmxEnabled()
        Description copied from interface: JmxChannel
        If set to true, this channel is registered with jmx.
        Specified by:
        isJmxEnabled in interface JmxChannel
        Returns:
        true if this channel will be registered with jmx.
      • setJmxEnabled

        public void setJmxEnabled​(boolean jmxEnabled)
        Description copied from interface: JmxChannel
        If set to true, this channel is registered with jmx.
        Specified by:
        setJmxEnabled in interface JmxChannel
        Parameters:
        jmxEnabled - set to true if this channel should be registered with jmx.
      • getJmxDomain

        public java.lang.String getJmxDomain()
        Description copied from interface: JmxChannel
        Return the jmx domain which this channel is registered.
        Specified by:
        getJmxDomain in interface JmxChannel
        Returns:
        jmxDomain
      • setJmxDomain

        public void setJmxDomain​(java.lang.String jmxDomain)
        Description copied from interface: JmxChannel
        Set the jmx domain which this channel should be registered.
        Specified by:
        setJmxDomain in interface JmxChannel
        Parameters:
        jmxDomain - The jmx domain which this channel should be registered.
      • getJmxPrefix

        public java.lang.String getJmxPrefix()
        Description copied from interface: JmxChannel
        Return the jmx prefix which will be used with channel ObjectName.
        Specified by:
        getJmxPrefix in interface JmxChannel
        Returns:
        jmxPrefix
      • setJmxPrefix

        public void setJmxPrefix​(java.lang.String jmxPrefix)
        Description copied from interface: JmxChannel
        Set the jmx prefix which will be used with channel ObjectName.
        Specified by:
        setJmxPrefix in interface JmxChannel
        Parameters:
        jmxPrefix - The jmx prefix which will be used with channel ObjectName.
      • preRegister

        public javax.management.ObjectName preRegister​(javax.management.MBeanServer server,
                                                       javax.management.ObjectName name)
                                                throws java.lang.Exception
        Specified by:
        preRegister in interface javax.management.MBeanRegistration
        Throws:
        java.lang.Exception
      • postRegister

        public void postRegister​(java.lang.Boolean registrationDone)
        Specified by:
        postRegister in interface javax.management.MBeanRegistration
      • preDeregister

        public void preDeregister()
                           throws java.lang.Exception
        Specified by:
        preDeregister in interface javax.management.MBeanRegistration
        Throws:
        java.lang.Exception
      • postDeregister

        public void postDeregister()
        Specified by:
        postDeregister in interface javax.management.MBeanRegistration