Class DataSender

  • All Implemented Interfaces:
    Fiber

    public class DataSender
    extends java.lang.Object
    implements Fiber
    The DataSender is responsible to send data out to 'listeners' When the RTCManager's timers go off, the DataSender is prompted to send data, which it does by maintaining a 'SendRequest' runnable queue so as to not block the RTCManager.
    Author:
    Sowmya Nataraj, Brian Weaver, OpenNMS.org
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getName()
      Returns a name/ID for this fiber
      int getStatus()
      Returns the current status
      void handleRtcSubscribe​(IEvent event)
      Inform the data sender of the new listener
      void handleRtcUnsubscribe​(IEvent event)
      Inform the data sender of the listener unsubscribing
      void notifyToSend()
      Notify the DataSender to send data - create a new 'SendRequest' to send the data and queue to the consumer
      void sendData()
      Loop through the categories and send out data for all categories that have changed
      void start()
      Start the data sender thread pool
      void stop()
      Shutdown the data sender thread pool
      void subscribe​(java.lang.String url, java.lang.String catlabel, java.lang.String user, java.lang.String passwd)
      Subscribe - Add the received URL and related info to the category->URLs map so the sendData() can send out to appropriate URLs for each category.
      void unsubscribe​(java.lang.String urlStr)
      Unsubscribe - remove the received URL and related info from the category->URLs map so the sendData() will know when it sends data out
      • Methods inherited from class java.lang.Object

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

      • DataSender

        public DataSender​(AvailabilityService dataMgr,
                          RTCConfigFactory configFactory)
        The constructor for this object
        Parameters:
        categories - The category map.
        numSenders - The number of senders.
    • Method Detail

      • start

        public void start()
        Start the data sender thread pool
        Specified by:
        start in interface Fiber
      • stop

        public void stop()

        Shutdown the data sender thread pool

        Specified by:
        stop in interface Fiber
      • getName

        public java.lang.String getName()
        Returns a name/ID for this fiber
        Specified by:
        getName in interface Fiber
        Returns:
        a String object.
      • getStatus

        public int getStatus()
        Returns the current status
        Specified by:
        getStatus in interface Fiber
        Returns:
        a int.
      • subscribe

        public void subscribe​(java.lang.String url,
                              java.lang.String catlabel,
                              java.lang.String user,
                              java.lang.String passwd)
        Subscribe - Add the received URL and related info to the category->URLs map so the sendData() can send out to appropriate URLs for each category. Also send the latest info for the category
        Parameters:
        url - a String object.
        catlabel - a String object.
        user - a String object.
        passwd - a String object.
      • unsubscribe

        public void unsubscribe​(java.lang.String urlStr)
        Unsubscribe - remove the received URL and related info from the category->URLs map so the sendData() will know when it sends data out
        Parameters:
        urlStr - a String object.
      • sendData

        public void sendData()
        Loop through the categories and send out data for all categories that have changed
      • notifyToSend

        public void notifyToSend()
        Notify the DataSender to send data - create a new 'SendRequest' to send the data and queue to the consumer
      • handleRtcSubscribe

        public void handleRtcSubscribe​(IEvent event)
        Inform the data sender of the new listener
      • handleRtcUnsubscribe

        public void handleRtcUnsubscribe​(IEvent event)
        Inform the data sender of the listener unsubscribing