Class HeartBeatManager

  • All Implemented Interfaces:
    IHeartBeatManager

    public final class HeartBeatManager
    extends AbstractLogger
    implements IHeartBeatManager
    The Java ExecutorService is a construct that allows you to pass a task to be executed by a thread asynchronously. The executor service creates and maintains a reusable pool of threads for executing submitted tasks. This class helps you create and manage your HeartBeats. See: AbstractHeartBeat
    Author:
    kong
    See Also:
    IHeartBeatManager
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Destroy all heart-beats and clear all references.
      boolean contains​(java.lang.String id)
      Check if a heart-beat is existed or not.
      void create​(java.lang.String id, AbstractHeartBeat heartbeat)
      Create a new heart-beat.
      void dispose​(java.lang.String id)
      Dispose a heart-beat.
      void initialize​(int maxHeartbeat)
      The number of maximum heart-beats that the server can handle.
      void initialize​(BaseConfiguration configuration)
      The number of maximum heart-beats that the server can handle.
      void sendMessage​(java.lang.String id, TObject message)
      Send a message to a particular heart-beat with no delay time
      void sendMessage​(java.lang.String id, TObject message, double delayTime)
      Send a message to a particular heart-beat with a delay time
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HeartBeatManager

        public HeartBeatManager()
    • Method Detail

      • initialize

        public void initialize​(int maxHeartbeat)
        Description copied from interface: IHeartBeatManager
        The number of maximum heart-beats that the server can handle.
        Specified by:
        initialize in interface IHeartBeatManager
        Parameters:
        maxHeartbeat - the number of maximum heart-beats that the server can handle
      • dispose

        public void dispose​(java.lang.String id)
        Description copied from interface: IHeartBeatManager
        Dispose a heart-beat.
        Specified by:
        dispose in interface IHeartBeatManager
        Parameters:
        id - the unique id
      • contains

        public boolean contains​(java.lang.String id)
        Description copied from interface: IHeartBeatManager
        Check if a heart-beat is existed or not.
        Specified by:
        contains in interface IHeartBeatManager
        Parameters:
        id - the unique id
        Returns:
        true if the corresponding heart-beat has existed
      • sendMessage

        public void sendMessage​(java.lang.String id,
                                TObject message,
                                double delayTime)
        Description copied from interface: IHeartBeatManager
        Send a message to a particular heart-beat with a delay time
        Specified by:
        sendMessage in interface IHeartBeatManager
        Parameters:
        id - the unique id
        message - the message content, see TObject
        delayTime - the delay time in seconds
      • sendMessage

        public void sendMessage​(java.lang.String id,
                                TObject message)
        Description copied from interface: IHeartBeatManager
        Send a message to a particular heart-beat with no delay time
        Specified by:
        sendMessage in interface IHeartBeatManager
        Parameters:
        id - the unique id
        message - the message content, see TObject