Running Dmaap consumer in a seprate thread

Fixed some potential threading problems

Enabled spring boot actuator for REST API
to control traces, diagnostics etc.

API documentation updates

Added GET policy_status in the agent NBI

Change-Id: Ied170bb1e8f350f17b385a0ef1def87cc6ec8750
Issue-ID: NONRTRIC-107
Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
diff --git a/policy-agent/docs/api.yaml b/policy-agent/docs/api.yaml
new file mode 100644
index 0000000..1416298
--- /dev/null
+++ b/policy-agent/docs/api.yaml
@@ -0,0 +1,863 @@
+swagger: '2.0'
+info:
+  description: This page lists all the rest apis for Policy server.
+  version: '1.0'
+  title: Policy server
+host: 'localhost:8081'
+basePath: /
+tags:
+  - name: operation-handler
+    description: Operation Handler
+  - name: policy-controller
+    description: Policy Controller
+  - name: ric-repository-controller
+    description: Ric Repository Controller
+  - name: service-controller
+    description: Service Controller
+  - name: status-controller
+    description: Status Controller
+  - name: web-mvc-links-handler
+    description: Web Mvc Links Handler
+paths:
+  /actuator:
+    get:
+      tags:
+        - web-mvc-links-handler
+      summary: links
+      operationId: linksUsingGET
+      produces:
+        - application/vnd.spring-boot.actuator.v3+json
+        - application/json
+        - application/vnd.spring-boot.actuator.v2+json
+      responses:
+        '200':
+          description: OK
+          schema:
+            type: object
+            additionalProperties:
+              type: object
+              additionalProperties:
+                $ref: '#/definitions/Link'
+        '401':
+          description: Unauthorized
+        '403':
+          description: Forbidden
+        '404':
+          description: Not Found
+      deprecated: false
+  /actuator/health:
+    get:
+      tags:
+        - operation-handler
+      summary: handle
+      operationId: handleUsingGET_1
+      produces:
+        - application/vnd.spring-boot.actuator.v3+json
+        - application/json
+        - application/vnd.spring-boot.actuator.v2+json
+      parameters:
+        - in: body
+          name: body
+          description: body
+          required: false
+          schema:
+            type: object
+            additionalProperties:
+              type: string
+      responses:
+        '200':
+          description: OK
+          schema:
+            type: object
+        '401':
+          description: Unauthorized
+        '403':
+          description: Forbidden
+        '404':
+          description: Not Found
+      deprecated: false
+  /actuator/health/**:
+    get:
+      tags:
+        - operation-handler
+      summary: handle
+      operationId: handleUsingGET
+      produces:
+        - application/vnd.spring-boot.actuator.v3+json
+        - application/json
+        - application/vnd.spring-boot.actuator.v2+json
+      parameters:
+        - in: body
+          name: body
+          description: body
+          required: false
+          schema:
+            type: object
+            additionalProperties:
+              type: string
+      responses:
+        '200':
+          description: OK
+          schema:
+            type: object
+        '401':
+          description: Unauthorized
+        '403':
+          description: Forbidden
+        '404':
+          description: Not Found
+      deprecated: false
+  /actuator/info:
+    get:
+      tags:
+        - operation-handler
+      summary: handle
+      operationId: handleUsingGET_2
+      produces:
+        - application/vnd.spring-boot.actuator.v3+json
+        - application/json
+        - application/vnd.spring-boot.actuator.v2+json
+      parameters:
+        - in: body
+          name: body
+          description: body
+          required: false
+          schema:
+            type: object
+            additionalProperties:
+              type: string
+      responses:
+        '200':
+          description: OK
+          schema:
+            type: object
+        '401':
+          description: Unauthorized
+        '403':
+          description: Forbidden
+        '404':
+          description: Not Found
+      deprecated: false
+  /actuator/logfile:
+    get:
+      tags:
+        - operation-handler
+      summary: handle
+      operationId: handleUsingGET_3
+      produces:
+        - text/plain;charset=UTF-8
+      parameters:
+        - in: body
+          name: body
+          description: body
+          required: false
+          schema:
+            type: object
+            additionalProperties:
+              type: string
+      responses:
+        '200':
+          description: OK
+          schema:
+            type: object
+        '401':
+          description: Unauthorized
+        '403':
+          description: Forbidden
+        '404':
+          description: Not Found
+      deprecated: false
+  /actuator/loggers:
+    get:
+      tags:
+        - operation-handler
+      summary: handle
+      operationId: handleUsingGET_5
+      produces:
+        - application/vnd.spring-boot.actuator.v3+json
+        - application/json
+        - application/vnd.spring-boot.actuator.v2+json
+      parameters:
+        - in: body
+          name: body
+          description: body
+          required: false
+          schema:
+            type: object
+            additionalProperties:
+              type: string
+      responses:
+        '200':
+          description: OK
+          schema:
+            type: object
+        '401':
+          description: Unauthorized
+        '403':
+          description: Forbidden
+        '404':
+          description: Not Found
+      deprecated: false
+  '/actuator/loggers/{name}':
+    get:
+      tags:
+        - operation-handler
+      summary: handle
+      operationId: handleUsingGET_4
+      produces:
+        - application/vnd.spring-boot.actuator.v3+json
+        - application/json
+        - application/vnd.spring-boot.actuator.v2+json
+      parameters:
+        - in: body
+          name: body
+          description: body
+          required: false
+          schema:
+            type: object
+            additionalProperties:
+              type: string
+      responses:
+        '200':
+          description: OK
+          schema:
+            type: object
+        '401':
+          description: Unauthorized
+        '403':
+          description: Forbidden
+        '404':
+          description: Not Found
+      deprecated: false
+    post:
+      tags:
+        - operation-handler
+      summary: handle
+      operationId: handleUsingPOST
+      consumes:
+        - application/vnd.spring-boot.actuator.v3+json
+        - application/json
+        - application/vnd.spring-boot.actuator.v2+json
+      produces:
+        - '*/*'
+      parameters:
+        - in: body
+          name: body
+          description: body
+          required: false
+          schema:
+            type: object
+            additionalProperties:
+              type: string
+      responses:
+        '200':
+          description: OK
+          schema:
+            type: object
+        '201':
+          description: Created
+        '401':
+          description: Unauthorized
+        '403':
+          description: Forbidden
+        '404':
+          description: Not Found
+      deprecated: false
+  /actuator/metrics:
+    get:
+      tags:
+        - operation-handler
+      summary: handle
+      operationId: handleUsingGET_7
+      produces:
+        - application/vnd.spring-boot.actuator.v3+json
+        - application/json
+        - application/vnd.spring-boot.actuator.v2+json
+      parameters:
+        - in: body
+          name: body
+          description: body
+          required: false
+          schema:
+            type: object
+            additionalProperties:
+              type: string
+      responses:
+        '200':
+          description: OK
+          schema:
+            type: object
+        '401':
+          description: Unauthorized
+        '403':
+          description: Forbidden
+        '404':
+          description: Not Found
+      deprecated: false
+  '/actuator/metrics/{requiredMetricName}':
+    get:
+      tags:
+        - operation-handler
+      summary: handle
+      operationId: handleUsingGET_6
+      produces:
+        - application/vnd.spring-boot.actuator.v3+json
+        - application/json
+        - application/vnd.spring-boot.actuator.v2+json
+      parameters:
+        - in: body
+          name: body
+          description: body
+          required: false
+          schema:
+            type: object
+            additionalProperties:
+              type: string
+      responses:
+        '200':
+          description: OK
+          schema:
+            type: object
+        '401':
+          description: Unauthorized
+        '403':
+          description: Forbidden
+        '404':
+          description: Not Found
+      deprecated: false
+  /policies:
+    get:
+      tags:
+        - policy-controller
+      summary: Query policies
+      operationId: getPoliciesUsingGET
+      produces:
+        - '*/*'
+      parameters:
+        - name: ric
+          in: query
+          description: ric
+          required: false
+          type: string
+        - name: service
+          in: query
+          description: service
+          required: false
+          type: string
+        - name: type
+          in: query
+          description: type
+          required: false
+          type: string
+      responses:
+        '200':
+          description: Policies
+          schema:
+            type: array
+            items:
+              $ref: '#/definitions/PolicyInfo'
+        '401':
+          description: Unauthorized
+        '403':
+          description: Forbidden
+        '404':
+          description: Not Found
+      deprecated: false
+  /policy:
+    get:
+      tags:
+        - policy-controller
+      summary: Returns a policy configuration
+      operationId: getPolicyUsingGET
+      produces:
+        - '*/*'
+      parameters:
+        - name: instance
+          in: query
+          description: instance
+          required: true
+          type: string
+      responses:
+        '200':
+          description: Policy found
+          schema:
+            type: object
+        '204':
+          description: Policy is not found
+          schema:
+            type: string
+        '401':
+          description: Unauthorized
+        '403':
+          description: Forbidden
+        '404':
+          description: Not Found
+      deprecated: false
+    put:
+      tags:
+        - policy-controller
+      summary: Put a policy
+      operationId: putPolicyUsingPUT
+      consumes:
+        - application/json
+      produces:
+        - '*/*'
+      parameters:
+        - name: instance
+          in: query
+          description: instance
+          required: true
+          type: string
+        - in: body
+          name: jsonBody
+          description: jsonBody
+          required: true
+          schema:
+            type: object
+        - name: ric
+          in: query
+          description: ric
+          required: true
+          type: string
+        - name: service
+          in: query
+          description: service
+          required: true
+          type: string
+        - name: type
+          in: query
+          description: type
+          required: true
+          type: string
+      responses:
+        '200':
+          description: Policy created or updated
+          schema:
+            type: string
+        '201':
+          description: Created
+        '401':
+          description: Unauthorized
+        '403':
+          description: Forbidden
+        '404':
+          description: Not Found
+      deprecated: false
+    delete:
+      tags:
+        - policy-controller
+      summary: Delete a policy
+      operationId: deletePolicyUsingDELETE
+      produces:
+        - '*/*'
+      parameters:
+        - name: instance
+          in: query
+          description: instance
+          required: true
+          type: string
+      responses:
+        '200':
+          description: OK
+          schema:
+            type: object
+        '204':
+          description: Policy deleted
+          schema:
+            type: object
+        '401':
+          description: Unauthorized
+        '403':
+          description: Forbidden
+      deprecated: false
+  /policy_schema:
+    get:
+      tags:
+        - policy-controller
+      summary: Returns one policy type schema definition
+      operationId: getPolicySchemaUsingGET
+      produces:
+        - '*/*'
+      parameters:
+        - name: id
+          in: query
+          description: id
+          required: true
+          type: string
+      responses:
+        '200':
+          description: Policy schema
+          schema:
+            type: object
+        '401':
+          description: Unauthorized
+        '403':
+          description: Forbidden
+        '404':
+          description: Not Found
+      deprecated: false
+  /policy_schemas:
+    get:
+      tags:
+        - policy-controller
+      summary: Returns policy type schema definitions
+      operationId: getPolicySchemasUsingGET
+      produces:
+        - '*/*'
+      parameters:
+        - name: ric
+          in: query
+          description: ric
+          required: false
+          type: string
+      responses:
+        '200':
+          description: Policy schemas
+          schema:
+            type: array
+            items:
+              type: string
+        '401':
+          description: Unauthorized
+        '403':
+          description: Forbidden
+        '404':
+          description: Not Found
+      deprecated: false
+  /policy_status:
+    get:
+      tags:
+        - policy-controller
+      summary: Returns a policy status
+      operationId: getPolicyStatusUsingGET
+      produces:
+        - '*/*'
+      parameters:
+        - name: instance
+          in: query
+          description: instance
+          required: true
+          type: string
+      responses:
+        '200':
+          description: Policy status
+          schema:
+            type: object
+        '204':
+          description: Policy is not found
+          schema:
+            type: string
+        '401':
+          description: Unauthorized
+        '403':
+          description: Forbidden
+        '404':
+          description: Not Found
+      deprecated: false
+  /policy_types:
+    get:
+      tags:
+        - policy-controller
+      summary: Query policy type names
+      operationId: getPolicyTypesUsingGET
+      produces:
+        - '*/*'
+      parameters:
+        - name: ric
+          in: query
+          description: ric
+          required: false
+          type: string
+      responses:
+        '200':
+          description: Policy type names
+          schema:
+            type: array
+            items:
+              type: string
+        '401':
+          description: Unauthorized
+        '403':
+          description: Forbidden
+        '404':
+          description: Not Found
+      deprecated: false
+  /ric:
+    get:
+      tags:
+        - ric-repository-controller
+      summary: Returns the name of a RIC managing one Mananged Element
+      operationId: getRicUsingGET
+      produces:
+        - '*/*'
+      parameters:
+        - name: managedElementId
+          in: query
+          description: managedElementId
+          required: false
+          type: string
+      responses:
+        '200':
+          description: RIC is fond
+          schema:
+            type: string
+        '401':
+          description: Unauthorized
+        '403':
+          description: Forbidden
+        '404':
+          description: RIC is not fond
+          schema:
+            type: string
+      deprecated: false
+  /rics:
+    get:
+      tags:
+        - ric-repository-controller
+      summary: Query NearRT RIC information
+      operationId: getRicsUsingGET
+      produces:
+        - '*/*'
+      parameters:
+        - name: policyType
+          in: query
+          description: policyType
+          required: false
+          type: string
+      responses:
+        '200':
+          description: OK
+          schema:
+            type: array
+            items:
+              $ref: '#/definitions/RicInfo'
+        '401':
+          description: Unauthorized
+        '403':
+          description: Forbidden
+        '404':
+          description: Not Found
+      deprecated: false
+  /service:
+    put:
+      tags:
+        - service-controller
+      summary: Register a service
+      operationId: putServiceUsingPUT
+      consumes:
+        - application/json
+      produces:
+        - '*/*'
+      parameters:
+        - in: body
+          name: registrationInfo
+          description: registrationInfo
+          required: true
+          schema:
+            $ref: '#/definitions/ServiceRegistrationInfo'
+      responses:
+        '200':
+          description: OK
+          schema:
+            type: string
+        '201':
+          description: Created
+        '401':
+          description: Unauthorized
+        '403':
+          description: Forbidden
+        '404':
+          description: Not Found
+      deprecated: false
+  /services:
+    get:
+      tags:
+        - service-controller
+      summary: Returns service information
+      operationId: getServicesUsingGET
+      produces:
+        - '*/*'
+      parameters:
+        - name: name
+          in: query
+          description: name
+          required: false
+          type: string
+      responses:
+        '200':
+          description: OK
+          schema:
+            type: array
+            items:
+              $ref: '#/definitions/ServiceStatus'
+        '401':
+          description: Unauthorized
+        '403':
+          description: Forbidden
+        '404':
+          description: Not Found
+      deprecated: false
+    delete:
+      tags:
+        - service-controller
+      summary: Delete a service
+      operationId: deleteServiceUsingDELETE
+      produces:
+        - '*/*'
+      parameters:
+        - name: name
+          in: query
+          description: name
+          required: true
+          type: string
+      responses:
+        '200':
+          description: OK
+          schema:
+            type: string
+        '204':
+          description: No Content
+        '401':
+          description: Unauthorized
+        '403':
+          description: Forbidden
+      deprecated: false
+  /services/keepalive:
+    post:
+      tags:
+        - service-controller
+      summary: Keep the poilicies alive for a service
+      operationId: keepAliveServiceUsingPOST
+      consumes:
+        - application/json
+      produces:
+        - '*/*'
+      parameters:
+        - name: name
+          in: query
+          description: name
+          required: true
+          type: string
+      responses:
+        '200':
+          description: Policies timeout supervision refreshed
+          schema:
+            type: string
+        '201':
+          description: Created
+        '401':
+          description: Unauthorized
+        '403':
+          description: Forbidden
+        '404':
+          description: 'The service is not found, needs re-registration'
+      deprecated: false
+  /status:
+    get:
+      tags:
+        - status-controller
+      summary: Returns status and statistics of the service
+      operationId: getStatusUsingGET
+      produces:
+        - '*/*'
+      responses:
+        '200':
+          description: Service is living
+          schema:
+            type: string
+        '401':
+          description: Unauthorized
+        '403':
+          description: Forbidden
+        '404':
+          description: Not Found
+      deprecated: false
+definitions:
+  Link:
+    type: object
+    properties:
+      href:
+        type: string
+      templated:
+        type: boolean
+    title: Link
+  'Map«string,Link»':
+    type: object
+    title: 'Map«string,Link»'
+    additionalProperties:
+      $ref: '#/definitions/Link'
+  Mono«ResponseEntity«Void»»:
+    type: object
+    title: Mono«ResponseEntity«Void»»
+  Mono«ResponseEntity«string»»:
+    type: object
+    title: Mono«ResponseEntity«string»»
+  PolicyInfo:
+    type: object
+    properties:
+      id:
+        type: string
+        description: identity of the policy
+      json:
+        type: string
+        description: the configuration of the policy
+      lastModified:
+        type: string
+        description: 'timestamp, last modification time'
+      ric:
+        type: string
+        description: identity the target NearRT RIC
+      service:
+        type: string
+        description: the name of the service owning the policy
+      type:
+        type: string
+        description: name of the policy type
+    title: PolicyInfo
+  RicInfo:
+    type: object
+    properties:
+      managedElementIds:
+        type: array
+        description: O1 identities for managed entities
+        items:
+          type: string
+      name:
+        type: string
+        description: identity of the ric
+      policyTypes:
+        type: array
+        description: supported policy types
+        items:
+          type: string
+    title: RicInfo
+  ServiceRegistrationInfo:
+    type: object
+    properties:
+      callbackUrl:
+        type: string
+        description: callback for notifying of RIC recovery
+      keepAliveIntervalSeconds:
+        type: integer
+        format: int64
+        description: keep alive interval for policies owned by the service. 0 means no timeout supervision. Polcies that are not refreshed within this time are removed
+      name:
+        type: string
+        description: identity of the service
+    title: ServiceRegistrationInfo
+  ServiceStatus:
+    type: object
+    properties:
+      keepAliveIntervalSeconds:
+        type: integer
+        format: int64
+        description: policy keep alive timeout
+      name:
+        type: string
+        description: identity of the service
+      timeSincePingSeconds:
+        type: integer
+        format: int64
+        description: time since last invocation by the service
+    title: ServiceStatus
+