org.licas.autonomic

## Class AutonomicManagerDefault

- java.lang.Object
- - java.lang.Thread
  - - org.licas.module.LicasModule
    - - org.licas.module.FrameworkModule
      - - org.licas.module.ServiceModule
        - - org.licas.ServiceWrapper
          - - org.licas.autonomic.AutonomicManager
            - - org.licas.autonomic.AutonomicManagerDefault

- All Implemented Interfaces:
    java.lang.Runnable, ServiceDef, ServiceWrapperDef

      public class AutonomicManagerDefault
      extends AutonomicManager

  This class is a default implementation of an autonomic manager. It is a service wrapper that can also be used to manage an `Auto` service's data history. This default implementation does not implement any of the monitoring modules. It does however implement a message queueing system that can be used to control the messages that are submitted to the service (controlled element). The monitoring modules should extend the base `AM_Module` class and can be either to monitor, analyze, plan or execute. Descriptions of the monitoring process can be found in related papers. These modules should be added using the pre-defined default keyword names of either `Const`.`MONITOR`, `ANALYZE`, `PLAN`, or `EXECUTE` to identify each one. The MAPE loop is synchronised, but any resulting action or effector list is not.
  Author:
    Kieran Greer

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class java.lang.Thread

      `java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler`

  - ### Field Summary

    - ### Fields inherited from class org.licas.autonomic.AutonomicManager

      `analyzer, autoEngine, CONVERSATIONEXISTS, executor, isConfigured, messageQueue, monitor, NEWCONVERSATION, planner, quarantineQueue`

    - ### Fields inherited from class org.licas.ServiceWrapper

      `metrics, setStructures`

    - ### Fields inherited from class org.licas.module.ServiceModule

      `shutDown`

    - ### Fields inherited from class org.licas.module.FrameworkModule

      `passwordHandler, service, serviceType`

    - ### Fields inherited from class org.licas.module.LicasModule

      `jarFile, uuid`

    - ### Fields inherited from class java.lang.Thread

      `MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AutonomicManagerDefault(Auto theService)` Creates a new instance of AutonomicManagerDefault.
    `AutonomicManagerDefault(Auto theService, org.licas_xml.abs.Element adminXml)` Creates a new instance of AutonomicManagerDefault.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addManagerModule(java.lang.String moduleType, java.lang.String moduleClass, java.util.ArrayList<java.lang.Object> params, java.util.ArrayList<java.lang.String> theJarUris)` Add a new module to the manager - monitor, analyze, plan or execute.
    `void` | `addPolicy(java.lang.String policyType, org.licas_xml.abs.Element document)` Add a new policy to the auto manager.
    `void` | `monitor(MessageInfo theMessage, java.lang.String theAdminKey)` Monitor a conversation message and add if a new conversation.
    `protected void` | `monitorMessage(MessageInfo theMessage, java.lang.String theAdminKey)` Monitor a message using a MAPE control loop.
    `void` | `run()` This is the default method to start the service thread.

    - ### Methods inherited from class org.licas.autonomic.AutonomicManager

      `addMessage, checkCommID, getClientURI, getMessageQueue, getNextMessage, getQuarantineMessageQueue, interrupt, isAuto, isService, removeCommID, returnLastMessage, setConfigured, storesLegacy`

    - ### Methods inherited from class org.licas.ServiceWrapper

      `addCommunicationID, addMetrics, canAccess, canAccess, canAccess, canAccessTemp, copyFromService, copyToService, execute, getDescription, getFullPath, getMetrics, getObjClass, getObjService, getPassword, getPassword, getPassword, getService, getService, getServiceGrade, getWorkInfo, interrupt, invokeObj, reflectionMethods, setObjService, setParent, setServerPassword, setServiceGrade, threadAliveState`

    - ### Methods inherited from class org.licas.module.ServiceModule

      `getShutDown, setShutDown, setShutDown`

    - ### Methods inherited from class org.licas.module.FrameworkModule

      `getPasswordHandler, getPasswordHandler, getServerPassword, getServicePassword, getServiceType, isAdminKey, setServiceDetails, setServiceType`

    - ### Methods inherited from class org.licas.module.LicasModule

      `getJarFile, getUUID, loadObject, setJarFile, setUUID`

    - ### Methods inherited from class java.lang.Thread

      `activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.licas.def.ServiceDef

      `getServiceType, getUUID, isAdminKey, setJarFile, setServiceType, setUUID`

- - ### Constructor Detail

    - #### AutonomicManagerDefault

          public AutonomicManagerDefault(Auto theService)
                                  throws java.lang.Exception

      Creates a new instance of AutonomicManagerDefault.
      Parameters:
        `theService` - the service to monitor.
      Throws:
        `java.lang.Exception` - any error.

    - #### AutonomicManagerDefault

          public AutonomicManagerDefault(Auto theService,
                                         org.licas_xml.abs.Element adminXml)
                                  throws java.lang.Exception

      Creates a new instance of AutonomicManagerDefault.
      Parameters:
        `theService` - the service to monitor.
        `adminXml` - the admin document describing the auto manager.
      Throws:
        `java.lang.Exception` - any error.

  - ### Method Detail

    - #### run

          public void run()

      This is the default method to start the service thread. This default process periodically executes and evaluates a behaviour.
      Specified by:
        `run` in interface `java.lang.Runnable`
      Overrides:
        `run` in class `ServiceWrapper`

    - #### monitor

          public void monitor(MessageInfo theMessage,
                              java.lang.String theAdminKey)
                       throws PasswordException,
                              LicasException,
                              java.lang.Exception

      Monitor a conversation message and add if a new conversation. The autonomous loops can repeat a request to monitor something, and so this method does not throw an exception if the comm ID is not new. It is up to the user to check the comm ID. If the communication ID is `null` then the message is ignored and not checked.
      Specified by:
        `monitor` in class `AutonomicManager`
      Parameters:
        `theMessage` - the message that the service has produced / received.
        `theAdminKey` - the admin key for the parent service.
      Throws:
        `PasswordException` - if the admin key is incorrect.
        `LicasException` - if the communication ID is not part of a current conversation.
        `java.lang.Exception` - any error.

    - #### monitorMessage

          protected void monitorMessage(MessageInfo theMessage,
                                        java.lang.String theAdminKey)
                                 throws java.lang.Exception

      Monitor a message using a MAPE control loop. This occurs after the message has been added to the queue and retrieved for processing. In this case, the message must be recognised as part of an existing conversation, from its comm ID. If the comm ID is `null`, then an exception is thrown. If it new, then the message is added to a quarantine list and an exception is thrown. The MAPE loop is synchronised, but any resulting action or effector list is not.
      Specified by:
        `monitorMessage` in class `AutonomicManager`
      Parameters:
        `theMessage` - the message that the service has produced / received.
        `theAdminKey` - the admin key for the parent service.
      Throws:
        `java.lang.Exception` - any error.
        `PasswordException` - if the admin key is incorrect.
        `LicasException` - if the communication ID is not part of a current conversation.

    - #### addManagerModule

          public void addManagerModule(java.lang.String moduleType,
                                       java.lang.String moduleClass,
                                       java.util.ArrayList<java.lang.Object> params,
                                       java.util.ArrayList<java.lang.String> theJarUris)
                                throws java.lang.Exception

      Add a new module to the manager - monitor, analyze, plan or execute.
      Specified by:
        `addManagerModule` in class `AutonomicManager`
      Parameters:
        `moduleType` - the type of module. This is pre-defined and should be either `Const`.`MONITOR`, `ANALYZE`, `PLAN`, or `EXECUTE` to identify each particular module.
        `moduleClass` - the class name of the module to be loaded.
        `params` - initialisation parameters.
        `theJarUris` - uris from which the remote object can be loaded, only if needed.
      Throws:
        `java.lang.Exception` - any error.

    - #### addPolicy

          public void addPolicy(java.lang.String policyType,
                                org.licas_xml.abs.Element document)
                         throws java.lang.Exception

      Add a new policy to the auto manager.
      Specified by:
        `addPolicy` in class `AutonomicManager`
      Parameters:
        `policyType` - the type of policy. To add to a monitoring module, use one of the pre-defined keywords - `Const`.`MONITOR`, `ANALYZE`, `PLAN`, or `EXECUTE`.
        `document` - the policy document.
      Throws:
        `java.lang.Exception` - any error.