org.opennms.bb.dp.poller.scheduler
Class PollerScheduler

java.lang.Object
  |
  +--org.opennms.bb.dp.poller.scheduler.PollerScheduler

public class PollerScheduler
extends Object

This class is responsible for reading the information from the poller.xml and the packages.xml in order to schedule and run the service monitors for all interfaces dictated by the package information for the poller.

Version:
$Revision: 1.7 $
Author:
Jason Johns, OpenNMS

Field Summary
private static int INITIAL_POOL_SIZE
          The initial size of the consumer thread pool
private  String m_activeService
          A list of services this scheduler should look for and schedule
private  List m_consumerThreadPool
          A list of consumer threads that process the m_inQueue
private  boolean m_doneScheduling
          A blooean indicating that the scheduler should shutdown
private  PCQueue m_inQueue
          Queue holding NetworkInterface runnables that have been scheduled
private  List m_interfaceErrorList
           
private  Map m_modelMap
          A list of full model information for all packages
private  ModelsParser m_modelParser
          The parser responsible for getting the model information
private  PCQueue m_outQueue
          Queue holding NetworkInterfaces that have completeted polling
private  List m_packageInterfaces
          A list of interface lists that need to be scheduled
private  List m_packageList
          A list of full package information for all packages belonging with this poller
private  PackageParser m_packageParser
          The parser responsible for getting the package information
private  DiscPollersParser m_pollerParser
          The parser responsible for getting the poller information from poller.xml
private  Map m_scheduleMaster
          A final list of the interfaces to schedule
private  ServiceMonitor m_serviceMonitor
           
 
Constructor Summary
PollerScheduler(String anIpAddr, String aService)
          Constructor, intializes the queues and thread pool, parses the poller.xml and package.xml and builds the list of interfaces ready to be scheduled.
 
Method Summary
private  void assignModelsToPackages(Map aModelMap, List aPackageList, String aServiceName)
           
private  Map buildServiceMaster(String aService, List aPackageInterfacesList, ServiceMonitor aMonitor)
           
private  List getInterfacesToSchedule(List aPackageList, String aService)
          This method builds the interface ip lists for each service that requires scheduling.
 List getPackages()
          This method returns the list of package information this poller has
static void main(String[] args)
          A main method to allow a scheduler to be invoked from a command line.
private  void rescheduleInterface(Map aMaster, Integer newInterval, PollerTask aTask)
           
 void start()
          This method builds the NetworkInterface runnables and places them on the m_inQueue.
 void updateSchedule(Map aSchedule, Integer anInterval, PollerTask aTask)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

m_pollerParser

private DiscPollersParser m_pollerParser
The parser responsible for getting the poller information from poller.xml

m_packageParser

private PackageParser m_packageParser
The parser responsible for getting the package information

m_modelParser

private ModelsParser m_modelParser
The parser responsible for getting the model information

m_activeService

private String m_activeService
A list of services this scheduler should look for and schedule

m_packageList

private List m_packageList
A list of full package information for all packages belonging with this poller

m_modelMap

private Map m_modelMap
A list of full model information for all packages

m_packageInterfaces

private List m_packageInterfaces
A list of interface lists that need to be scheduled

m_inQueue

private PCQueue m_inQueue
Queue holding NetworkInterface runnables that have been scheduled

m_outQueue

private PCQueue m_outQueue
Queue holding NetworkInterfaces that have completeted polling

m_consumerThreadPool

private List m_consumerThreadPool
A list of consumer threads that process the m_inQueue

m_scheduleMaster

private Map m_scheduleMaster
A final list of the interfaces to schedule

m_serviceMonitor

private ServiceMonitor m_serviceMonitor

m_doneScheduling

private boolean m_doneScheduling
A blooean indicating that the scheduler should shutdown

m_interfaceErrorList

private List m_interfaceErrorList

INITIAL_POOL_SIZE

private static final int INITIAL_POOL_SIZE
The initial size of the consumer thread pool
Constructor Detail

PollerScheduler

public PollerScheduler(String anIpAddr,
                       String aService)
                throws IOException
Constructor, intializes the queues and thread pool, parses the poller.xml and package.xml and builds the list of interfaces ready to be scheduled.
Parameters:
String - anIpAddr, the ip address of the poller
List - aServiceList, the list of services that should be scheduled
Method Detail

assignModelsToPackages

private void assignModelsToPackages(Map aModelMap,
                                    List aPackageList,
                                    String aServiceName)

buildServiceMaster

private Map buildServiceMaster(String aService,
                               List aPackageInterfacesList,
                               ServiceMonitor aMonitor)

updateSchedule

public void updateSchedule(Map aSchedule,
                           Integer anInterval,
                           PollerTask aTask)

start

public void start()
This method builds the NetworkInterface runnables and places them on the m_inQueue. The consumer threads process the runnables and place them onto m_outQueue where they are removed and evaluated for status and rescheduled accordingly.

rescheduleInterface

private void rescheduleInterface(Map aMaster,
                                 Integer newInterval,
                                 PollerTask aTask)

getInterfacesToSchedule

private List getInterfacesToSchedule(List aPackageList,
                                     String aService)
This method builds the interface ip lists for each service that requires scheduling. To be eligible for scheduling an interface address must be included in the filter expression of the package, be in the valid range (member of specific, or not in the exclude range and in the inlcude range) and be associated with one of the services the scheduler was told to schedule. The structure that is build is a list of lists, where each inner list contains interface ip addresses conforming to the above conditions.
Parameters:
List, - the list of package names
Returns:
List, a list containing lists of interfaces to be scheduled

getPackages

public List getPackages()
This method returns the list of package information this poller has
Returns:
List, the list of packages

main

public static void main(String[] args)
A main method to allow a scheduler to be invoked from a command line. The arguments include: -ipaddr, ip address of the poller -service, list of service name strings the scheduler should look for -packages, print the list of packages this poller has