Class SimpleQueuedProvisioningAdapter

  • All Implemented Interfaces:
    ProvisioningAdapter
    Direct Known Subclasses:
    DnsProvisioningAdapter, PuppetProvisioningAdapter, RancidProvisioningAdapter, ReverseDnsProvisioningAdapter, SimplerQueuedProvisioningAdapter

    public abstract class SimpleQueuedProvisioningAdapter
    extends java.lang.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 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
    • Constructor Detail

      • SimpleQueuedProvisioningAdapter

        protected SimpleQueuedProvisioningAdapter()

        Constructor for SimpleQueuedProvisioningAdapter.

    • Method Detail

      • getName

        public abstract java.lang.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 SimpleQueuedProvisioningAdapter.AdapterOperation object.
        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 SimpleQueuedProvisioningAdapter.AdapterOperation object.
        Throws:
        ProvisioningAdapterException - if any.
      • addNode

        public final java.util.concurrent.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 java.util.concurrent.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 java.util.concurrent.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 java.util.concurrent.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.