org.opennms.netmgt.provision
Class SimpleQueuedProvisioningAdapter

java.lang.Object
  extended by org.opennms.netmgt.provision.SimpleQueuedProvisioningAdapter
All Implemented Interfaces:
ProvisioningAdapter

public abstract class SimpleQueuedProvisioningAdapter
extends Object
implements ProvisioningAdapter

This class takes the work out of scheduling and queuing calls from the provisioner. Each provisioning adapter can extend this class for this functionality. The ProvisioningAdapter Interface API methods are final so that the child class can not implement them and override the queuing... for what would be the point. To use this class, have your provisioning adapter extend this abstract class. You see that you must implement abstract methods. To change the schedule, override the createScheduleForNode method and return a schedule suitable for the node. In this base class, the same schedule is used for all nodes. This class throws away duplicate node/operation tuples. This way you are guaranteed to only receive one node/operation from the queue, until it is removed from the queue that is. This is the purpose of the initial delay. It is suspected that the add/update/delete operations will not have any delay. Since there is only one thread per adapter, you will get these in the order they're scheduled. Be sure that adds/updates/deletes use the same schedule to insure the proper order. TODO: Add logging TODO: Verify correct Exception handling TODO: Write tests (especially the equals method of the NodeOperation for proper queue handling)

Author:
David Hustace

Constructor Summary
protected SimpleQueuedProvisioningAdapter()
           
protected SimpleQueuedProvisioningAdapter(PausibleScheduledThreadPoolExecutor executorService)
           
 
Method Summary
 void addNode(int nodeId)
          This method is called by the Provisioner when a new node is provisioned.
 void deleteNode(int nodeId)
          This method is called by the Provisioner when a node is deleted through provisioning.
abstract  String getName()
           
abstract  boolean isNodeReady(org.opennms.netmgt.provision.SimpleQueuedProvisioningAdapter.AdapterOperation op)
          Adapters extending this class must implement this method.
 void nodeConfigChanged(int nodeId)
          This method is called when a configuration change event has occurred from any source.
abstract  void processPendingOperationForNode(org.opennms.netmgt.provision.SimpleQueuedProvisioningAdapter.AdapterOperation op)
          The class implements the API and therefore the concrete class implements this method to handle dequeued operations.
 void updateNode(int nodeId)
          This method is called by the Provisioner when a node is updated through provisioning.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleQueuedProvisioningAdapter

protected SimpleQueuedProvisioningAdapter(PausibleScheduledThreadPoolExecutor executorService)

SimpleQueuedProvisioningAdapter

protected SimpleQueuedProvisioningAdapter()
Method Detail

getName

public abstract String getName()
Specified by:
getName in interface ProvisioningAdapter

isNodeReady

public abstract boolean isNodeReady(org.opennms.netmgt.provision.SimpleQueuedProvisioningAdapter.AdapterOperation op)
Adapters extending this class must implement this method. This method is called in the run method of an operation to insure that the adapter is ready for the operation to run for the associated node. The adapter is responsible for setting the schedule, however, something could have altered the state of readiness for the provisioning system in the meantime. If this method returns false, the operation is rescheduled with the and the attempts remaining on the operation are not decremented.

Parameters:
op -
Returns:
a boolean representing the state of readiness from the underlying system integrated by the implementing adapter.

processPendingOperationForNode

public abstract void processPendingOperationForNode(org.opennms.netmgt.provision.SimpleQueuedProvisioningAdapter.AdapterOperation op)
                                             throws ProvisioningAdapterException
The class implements the API and therefore the concrete class implements this method to handle dequeued operations. The concrete implementation should check the operation type to derrive the its behavior.

Parameters:
op -
Throws:
ProvisioningAdapterException

addNode

public final void addNode(int nodeId)
Description copied from interface: ProvisioningAdapter
This method is called by the Provisioner when a new node is provisioned.

Specified by:
addNode in interface ProvisioningAdapter

updateNode

public final void updateNode(int nodeId)
Description copied from interface: ProvisioningAdapter
This method is called by the Provisioner when a node is updated through provisioning.

Specified by:
updateNode in interface ProvisioningAdapter

deleteNode

public final void deleteNode(int nodeId)
Description copied from interface: ProvisioningAdapter
This method is called by the Provisioner when a node is deleted through provisioning.

Specified by:
deleteNode in interface ProvisioningAdapter

nodeConfigChanged

public final void nodeConfigChanged(int nodeId)
Description copied from interface: ProvisioningAdapter
This method is called when a configuration change event has occurred from any source. Typically, Traps sent from a device are converted to an event and that event is then identified for translation and translated into a generic configuration changed event.

Specified by:
nodeConfigChanged in interface ProvisioningAdapter


Copyright © 2009. All Rights Reserved.