## Class SimpleQueuedProvisioningAdapter

  * 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 cannot 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)

Version:
    $Id: $
Author:
    David Hustace



  *     * ### Nested Class Summary

Nested Classes Modifier and Type | Class and Description  
---|---  
`static class ` | `SimpleQueuedProvisioningAdapter.AdapterOperationQueue`  
`static interface ` | `SimpleQueuedProvisioningAdapter.AdapterOperationQueueListener`  
    * ### Constructor Summary

Constructors Modifier | Constructor and Description  
---|---  
`protected ` | `SimpleQueuedProvisioningAdapter()` Constructor for SimpleQueuedProvisioningAdapter.  
`protected ` | `SimpleQueuedProvisioningAdapter(PausibleScheduledThreadPoolExecutor executorService)` Constructor for SimpleQueuedProvisioningAdapter.  
    * ### Method Summary

All Methods Modifier and Type | Method and Description  
---|---  
`ScheduledFuture<?>` | `addNode(int nodeId)` This method is called by the Provisioner when a new node is provisioned.  
`ScheduledFuture<?>` | `deleteNode(int nodeId)` This method is called by the Provisioner when a node is deleted through provisioning.  
`abstract String` | `getName()` getName  
`SimpleQueuedProvisioningAdapter.AdapterOperationQueue` | `getOperationQueue()`  
`void` | `init()` (non-Javadoc)  
`abstract boolean` | `isNodeReady(org.opennms.netmgt.provision.SimpleQueuedProvisioningAdapter.AdapterOperation op)` Adapters extending this class must implement this method.  
`ScheduledFuture<?>` | `nodeConfigChanged(int nodeId)` This method is called when a configuration change event has occurred from any source.  
`protected 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.  
`ScheduledFuture<?>` | `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)

Constructor for SimpleQueuedProvisioningAdapter.

Parameters:
    `executorService` \- a `PausibleScheduledThreadPoolExecutor` object.
      * #### SimpleQueuedProvisioningAdapter
            
            protected SimpleQueuedProvisioningAdapter()

Constructor for SimpleQueuedProvisioningAdapter.

    * ### Method Detail

      * #### getName
            
            public abstract String getName()

getName

Specified by:
    `getName` in interface `ProvisioningAdapter`
Returns:
    a `String` object.
      * #### 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` \- a  object.`SimpleQueuedProvisioningAdapter.AdapterOperation`
Returns:
    a boolean representing the state of readiness from the underlying system integrated by the implementing adapter.
      * #### processPendingOperationForNode
            
            protected 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 derive the its behavior.

Parameters:
    `op` \- a  object.`SimpleQueuedProvisioningAdapter.AdapterOperation`
Throws:
    `ProvisioningAdapterException` \- if any.
      * #### addNode
            
            public final ScheduledFuture<?> addNode(int nodeId)

This method is called by the Provisioner when a new node is provisioned.

Specified by:
    `addNode` in interface `ProvisioningAdapter`
Parameters:
    `nodeId` \- a int.
Returns:
      * #### updateNode
            
            public final ScheduledFuture<?> updateNode(int nodeId)

This method is called by the Provisioner when a node is updated through provisioning.

Specified by:
    `updateNode` in interface `ProvisioningAdapter`
Parameters:
    `nodeId` \- a int.
      * #### deleteNode
            
            public final ScheduledFuture<?> deleteNode(int nodeId)

This method is called by the Provisioner when a node is deleted through provisioning.

Specified by:
    `deleteNode` in interface `ProvisioningAdapter`
Parameters:
    `nodeId` \- a int.
      * #### nodeConfigChanged
            
            public final ScheduledFuture<?> nodeConfigChanged(int nodeId)

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`
Parameters:
    `nodeId` \- a int.
      * #### init
            
            public void init()

(non-Javadoc)

Specified by:
    `init` in interface `ProvisioningAdapter`
See Also:
    `Override this implementation if needed.`
      * #### getOperationQueue
            
            public SimpleQueuedProvisioningAdapter.AdapterOperationQueue getOperationQueue()