Class HeartbeatListener

    • Field Detail

      • HEARTBEAT_FILENAME_PROPERTY

        public static final java.lang.String HEARTBEAT_FILENAME_PROPERTY
        Configurable property for heartbeat fully qualified directory+filename.
        See Also:
        Constant Field Values
      • DEFAULT_HEARTBEAT_FILENAME

        public static final java.lang.String DEFAULT_HEARTBEAT_FILENAME
        Default heartbeat directory.
        See Also:
        Constant Field Values
      • DEFAULT_STORAGE_TIMEOUT

        public static final java.lang.String DEFAULT_STORAGE_TIMEOUT
        Default timeout for HeartbeatStatus key/value pairs. Zero = disabled
        See Also:
        Constant Field Values
      • DEFAULT_CLEANUP_INTERVAL

        public static final java.lang.String DEFAULT_CLEANUP_INTERVAL
        Default schedule interval for HeartbeatStatus key/value pairs cleanup. 30 minutes
        See Also:
        Constant Field Values
      • HEARTBEAT_TIMEOUT_PROPERTY

        public static final java.lang.String HEARTBEAT_TIMEOUT_PROPERTY
        Configurable property for heartbeat key/value expiration
        See Also:
        Constant Field Values
    • Constructor Detail

      • HeartbeatListener

        public HeartbeatListener()
                          throws java.lang.Exception
        Create a new HeartbeatListener. Sets up the includeTypes list to contain "heartbeat".
        Throws:
        java.lang.Exception - if error occurs
    • Method Detail

      • getHeartbeats

        protected static java.util.Map<java.lang.String,​HeartbeatStatus> getHeartbeats()
        Returns:
        map of component and heartbeat status.
      • onProduct

        public void onProduct​(Product product)
                       throws java.lang.Exception
        heartbeat onProduct processing writes to heartbeat file
        Overrides:
        onProduct in class DefaultNotificationListener
        Parameters:
        product - a product whose notification was accepted.
        Throws:
        java.lang.Exception - if error occurs
      • sendHeartbeatMessage

        public static void sendHeartbeatMessage​(java.lang.String component,
                                                java.lang.String key,
                                                java.lang.String value)
        Send heartbeat data to heartbeat listener
        Parameters:
        component - String component
        key - Heartbeat key
        value - Heartbeat value
      • writeHeartbeat

        public boolean writeHeartbeat()
                               throws java.io.IOException
        Write heartbeat data for all components to the heartbeat file
        Returns:
        true
        Throws:
        java.io.IOException - if IO error occurs
      • configure

        public void configure​(Config config)
                       throws java.lang.Exception
        Self-configure HeartbeatListener object
        Specified by:
        configure in interface Configurable
        Overrides:
        configure in class DefaultNotificationListener
        Parameters:
        config - the Config object with settings.
        Throws:
        java.lang.Exception - if configuration exceptions occur.
      • formatHeartbeatOutput

        public java.lang.String formatHeartbeatOutput()
        Returns:
        JSON-formatted output from the map of components and their values
      • cleanup

        public void cleanup()
                     throws java.lang.Exception
        purge heartbeat key/values older than storageTimeout, also purging empty heartbeats
        Overrides:
        cleanup in class DefaultNotificationListener
        Throws:
        java.lang.Exception
      • getHeartbeatFile

        public java.io.File getHeartbeatFile()
        Returns:
        heartbeatFile
      • setHeartbeatFile

        public void setHeartbeatFile​(java.io.File heartbeatFile)
        Parameters:
        heartbeatFile - to set
      • getStorageTimeout

        public long getStorageTimeout()
        Returns:
        storageTimeout
      • setStorageTimeout

        public void setStorageTimeout​(long storageTimeout)
        Parameters:
        storageTimeout - to set