Merge "Test env documentation and new features"
authorHenrik Andersson <henrik.b.andersson@est.tech>
Thu, 4 Jun 2020 06:57:50 +0000 (06:57 +0000)
committerGerrit Code Review <gerrit@o-ran-sc.org>
Thu, 4 Jun 2020 06:57:50 +0000 (06:57 +0000)
21 files changed:
.gitignore
LICENSE.txt
docker-compose/README.md [new file with mode: 0644]
docker-compose/data/fill_data.sh [new file with mode: 0755]
docker-compose/data/testdata/OSC/policy_type.json [new file with mode: 0644]
docker-compose/data/testdata/policy.json [new file with mode: 0644]
docker-compose/data/testdata/service.json [new file with mode: 0644]
docker-compose/nosdnc/config/application.yaml [new file with mode: 0755]
docker-compose/nosdnc/config/application_configuration.json [new file with mode: 0644]
docker-compose/nosdnc/docker-compose.yml [new file with mode: 0644]
docker-compose/sdnc/config/application.yaml [new file with mode: 0755]
docker-compose/sdnc/config/application_configuration.json [new file with mode: 0644]
docker-compose/sdnc/docker-compose.yml [new file with mode: 0644]
policy-agent/Dockerfile
policy-agent/config/application.yaml
policy-agent/config/application_configuration.json [moved from policy-agent/config/application_configuration.json_example with 100% similarity]
policy-agent/src/main/java/org/oransc/policyagent/clients/AsyncRestClient.java
policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyController.java
policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageHandler.java
policy-agent/src/main/java/org/oransc/policyagent/repository/Lock.java
sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/main/java/org/o_ran_sc/nonrtric/sdnc_a1/northbound/restadapter/RestAdapterImpl.java

index f459dca..6136fcb 100644 (file)
@@ -9,4 +9,5 @@ docs/_build/
 .sts4-cache
 .project
 .settings
-.pydevproject
\ No newline at end of file
+.pydevproject
+infer-out/
\ No newline at end of file
index f49a4e1..96589bf 100644 (file)
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
-   limitations under the License.
\ No newline at end of file
+   limitations under the License. 
diff --git a/docker-compose/README.md b/docker-compose/README.md
new file mode 100644 (file)
index 0000000..7573398
--- /dev/null
@@ -0,0 +1,54 @@
+# O-RAN-SC docker-compose files
+
+The docker-compose.yml file will create an entire nonrtric system with one command:
+docker-compose up
+
+Two docker-compose files are provided in this folder:
+
+nosdnc/docker-compose.yml
+This file is to create nonrtric system without sdnc a1-controller
+
+sdnc/docker-compose.yml
+This file is to create nonrtric system with sdnc a1-controller
+
+Howto:
+cd nosdnc/
+docker-compose up
+
+or
+
+cd sdnc/
+docker-compose up
+
+The scripts in data/ will generate some dummy data in the running system.
+It will create:
+one policy type in a1-sim-OSC
+one service in policy agent
+one policy in a1-sim-OSC
+one policy in a1-sim-STD
+
+Run command:
+cd data/
+./fill_data.sh [policy-agent-port] [a1-sim-OSC-port] [a1-sim-STD-port] [http/https]
+
+Open link:
+http://localhost:[control-panel-port]/
+
+All the generated data is shown on the web page
+
+## License
+
+Copyright (C) 2020 Nordix Foundation.
+Licensed under the Apache License, Version 2.0 (the "License")
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+For more information about license please see the [LICENSE](LICENSE.txt) file for details.
diff --git a/docker-compose/data/fill_data.sh b/docker-compose/data/fill_data.sh
new file mode 100755 (executable)
index 0000000..7b8f665
--- /dev/null
@@ -0,0 +1,97 @@
+#!/bin/bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+# The scripts in data/ will generate some dummy data in the running system.
+# It will create:
+# one policy type in a1-sim-OSC
+# one service in policy agent
+# one policy in a1-sim-OSC
+# one policy in a1-sim-STD
+
+# Run command:
+# ./fill_data.sh [policy-agent port] [a1-sim-OSC port] [a1-sim-STD port] [http/https]
+
+policy_agent_port=${1:-8081}
+a1_sim_OSC_port=${2:-30001}
+a1_sim_STD_port=${3:-30003}
+httpx=${4:-"http"}
+
+echo "using policy_agent port: "$policy_agent_port
+echo "using a1-sim-OSC port: "$a1_sim_OSC_port
+echo "using a1-sim-STD port: "$a1_sim_STD_port
+echo "using protocol: "$httpx
+echo -e "\n"
+
+echo "policy agent status:"
+curl -skw " %{http_code}" $httpx://localhost:$policy_agent_port/status
+echo -e "\n"
+
+echo "ric1 version:"
+curl -skw " %{http_code}" $httpx://localhost:$a1_sim_OSC_port/counter/interface
+echo -e "\n"
+
+echo "ric2 version:"
+curl -skw " %{http_code}" $httpx://localhost:$a1_sim_STD_port/counter/interface
+echo -e "\n"
+
+echo "create policy type 1 to ric1:"
+curl -X PUT -skw " %{http_code}" $httpx://localhost:$a1_sim_OSC_port/policytype?id=1 -H Content-Type:application/json --data-binary @testdata/OSC/policy_type.json
+echo -e "\n"
+
+for i in {1..12}; do
+       echo "policy types from policy agent:"
+    curlString="curl -skw %{http_code} $httpx://localhost:$policy_agent_port/policy_types"
+    res=$($curlString)
+    echo "$res"
+    expect="[\"\",\"1\"]200"
+    if [ "$res" == "$expect" ]; then
+        echo -e "\n"
+        break;
+    else
+        sleep $i
+    fi
+done
+
+echo "create service 1 to policy agent:"
+curl -k -X PUT -sw " %{http_code}" -H accept:application/json -H Content-Type:application/json "$httpx://localhost:$policy_agent_port/service" --data-binary @testdata/service.json
+echo -e "\n"
+
+echo "create policy 2000 to ric1 with type1 and service1 via policy agent:"
+curl -k -X PUT -sw " %{http_code}" -H accept:application/json -H Content-Type:application/json "$httpx://localhost:$policy_agent_port/policy?id=2000&ric=ric1&service=service1&type=1" --data-binary @testdata/policy.json
+echo -e "\n"
+
+echo "policy numbers from ric1:"
+curl -skw " %{http_code}" $httpx://localhost:$a1_sim_OSC_port/counter/num_instances
+echo -e "\n"
+
+echo "create policy 2100 to ric2 with service1 via policy agent, no type:"
+curl -k -X PUT -sw " %{http_code}" -H accept:application/json -H Content-Type:application/json "$httpx://localhost:$policy_agent_port/policy?id=2100&ric=ric2&service=service1" --data-binary @testdata/policy.json
+echo -e "\n"
+
+echo "policy numbers from ric2:"
+curl -skw " %{http_code}" $httpx://localhost:$a1_sim_STD_port/counter/num_instances
+echo -e "\n"
+
+echo "policy id 2000 from policy agent:"
+curl -k -X GET -sw " %{http_code}" $httpx://localhost:$policy_agent_port/policy?id=2000
+echo -e "\n"
+
+echo "policy id 2100 from policy agent:"
+curl -k -X GET -sw " %{http_code}" $httpx://localhost:$policy_agent_port/policy?id=2100
+echo -e "\n"
\ No newline at end of file
diff --git a/docker-compose/data/testdata/OSC/policy_type.json b/docker-compose/data/testdata/OSC/policy_type.json
new file mode 100644 (file)
index 0000000..537d86f
--- /dev/null
@@ -0,0 +1,45 @@
+{
+  "name": "pt1",
+  "description": "pt1 policy type",
+  "policy_type_id": 1,
+  "create_schema": {
+    "$schema": "http://json-schema.org/draft-07/schema#",
+    "title": "OSC_Type1_1.0.0",
+    "description": "Type 1 policy type",
+    "type": "object",
+    "properties": {
+      "scope": {
+        "type": "object",
+        "properties": {
+          "ueId": {
+            "type": "string"
+          },
+          "qosId": {
+            "type": "string"
+          }
+        },
+        "additionalProperties": false,
+        "required": [
+          "ueId",
+          "qosId"
+        ]
+      },
+      "qosObjective": {
+        "type": "object",
+        "properties": {
+          "priorityLevel": {
+            "type": "number"
+          }
+        },
+        "additionalProperties": false,
+        "required": [
+          "priorityLevel"
+        ]
+      }
+    },
+    "additionalProperties": false,
+    "required": [
+      "scope", "qosObjective"
+    ]
+  }
+}
diff --git a/docker-compose/data/testdata/policy.json b/docker-compose/data/testdata/policy.json
new file mode 100644 (file)
index 0000000..119ba8b
--- /dev/null
@@ -0,0 +1,9 @@
+{
+  "scope": {
+    "ueId": "ue3100",
+    "qosId": "qos3100"
+  },
+  "qosObjective": {
+    "priorityLevel": 3100
+  }
+}
diff --git a/docker-compose/data/testdata/service.json b/docker-compose/data/testdata/service.json
new file mode 100644 (file)
index 0000000..1b973fc
--- /dev/null
@@ -0,0 +1 @@
+{"callbackUrl": "http://callback-receiver:8090/callbacks/1","keepAliveIntervalSeconds": "3600","serviceName": "service1"}
diff --git a/docker-compose/nosdnc/config/application.yaml b/docker-compose/nosdnc/config/application.yaml
new file mode 100755 (executable)
index 0000000..c0ddfb5
--- /dev/null
@@ -0,0 +1,37 @@
+spring:
+  profiles:
+    active: prod
+  main:
+    allow-bean-definition-overriding: true
+  aop:
+    auto: false
+management:
+  endpoints:
+    web:
+      exposure:
+        include: "loggers,logfile,health,info,metrics,threaddump,heapdump"
+
+logging:
+  level:
+    ROOT: ERROR
+    org.springframework: ERROR
+    org.springframework.data: ERROR
+    org.springframework.web.reactive.function.client.ExchangeFunctions: ERROR
+    org.oransc.policyagent: INFO
+  file: /var/log/policy-agent/application.log
+server:
+   port : 8433
+   http-port: 8081
+   ssl:
+      key-store-type: JKS
+      key-store-password: policy_agent
+      key-store: classpath:keystore.jks
+      key-password: policy_agent
+      key-alias: policy_agent
+app:
+  filepath: /opt/app/policy-agent/config/application_configuration.json
+  webclient:
+    trust-store-used: false
+    trust-store-password: policy_agent
+    trust-store: classpath:keystore.jks
+
diff --git a/docker-compose/nosdnc/config/application_configuration.json b/docker-compose/nosdnc/config/application_configuration.json
new file mode 100644 (file)
index 0000000..3a10acd
--- /dev/null
@@ -0,0 +1,23 @@
+{
+   "config": {
+      "//description": "Application configuration",
+      "ric": [
+         {
+            "name": "ric1",
+            "baseUrl": "http://a1-sim-OSC:8085/",
+            "managedElementIds": [
+               "kista_1",
+               "kista_2"
+            ]
+         },
+         {
+            "name":"ric2",
+            "baseUrl":"http://a1-sim-STD:8085/",
+            "managedElementIds": [
+               "kista_1",
+               "kista_2"
+            ]
+         }
+      ]
+   }
+}
\ No newline at end of file
diff --git a/docker-compose/nosdnc/docker-compose.yml b/docker-compose/nosdnc/docker-compose.yml
new file mode 100644 (file)
index 0000000..8c58e34
--- /dev/null
@@ -0,0 +1,64 @@
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+version: '3.0'
+services:
+  policy-agent:
+    image: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-policy-agent:1.0.0
+    container_name: policy-agent
+    networks:
+      default:
+        aliases:
+          - policy-agent-container
+    ports:
+      - 8081:8081
+      - 8433:8433
+    volumes:
+      - ./config:/opt/app/policy-agent/config:ro
+
+  a1-sim-OSC:
+    image: nexus3.o-ran-sc.org:10004/o-ran-sc/a1-simulator:1.0.1
+    container_name: a1-sim-OSC
+    networks:
+      - default
+    ports:
+      - 30001:8085
+      - 30002:8185
+    environment:
+      - A1_VERSION=OSC_2.1.0
+      - REMOTE_HOSTS_LOGGING=1
+      - ALLOW_HTTP=true
+
+  a1-sim-STD:
+    image: nexus3.o-ran-sc.org:10004/o-ran-sc/a1-simulator:1.0.1
+    container_name: a1-sim-STD
+    networks:
+      - default
+    ports:
+      - 30003:8085
+      - 30004:8185
+    environment:
+      - A1_VERSION=STD_1.1.3
+      - REMOTE_HOSTS_LOGGING=1
+      - ALLOW_HTTP=true
+
+  policy-control-panel:
+    image: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-controlpanel:1.0.0
+    container_name: policy-control-panel
+    networks:
+      - default
+    ports:
+      - 8080:8080
+      - 8082:8082
diff --git a/docker-compose/sdnc/config/application.yaml b/docker-compose/sdnc/config/application.yaml
new file mode 100755 (executable)
index 0000000..c0ddfb5
--- /dev/null
@@ -0,0 +1,37 @@
+spring:
+  profiles:
+    active: prod
+  main:
+    allow-bean-definition-overriding: true
+  aop:
+    auto: false
+management:
+  endpoints:
+    web:
+      exposure:
+        include: "loggers,logfile,health,info,metrics,threaddump,heapdump"
+
+logging:
+  level:
+    ROOT: ERROR
+    org.springframework: ERROR
+    org.springframework.data: ERROR
+    org.springframework.web.reactive.function.client.ExchangeFunctions: ERROR
+    org.oransc.policyagent: INFO
+  file: /var/log/policy-agent/application.log
+server:
+   port : 8433
+   http-port: 8081
+   ssl:
+      key-store-type: JKS
+      key-store-password: policy_agent
+      key-store: classpath:keystore.jks
+      key-password: policy_agent
+      key-alias: policy_agent
+app:
+  filepath: /opt/app/policy-agent/config/application_configuration.json
+  webclient:
+    trust-store-used: false
+    trust-store-password: policy_agent
+    trust-store: classpath:keystore.jks
+
diff --git a/docker-compose/sdnc/config/application_configuration.json b/docker-compose/sdnc/config/application_configuration.json
new file mode 100644 (file)
index 0000000..31ec633
--- /dev/null
@@ -0,0 +1,33 @@
+{
+   "config": {
+      "//description": "Application configuration",
+      "controller": [
+         {
+            "name": "a1-controller",
+            "baseUrl": "http://a1-controller:8181",
+            "userName": "admin",
+            "password": "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"
+         }
+      ],
+      "ric": [
+         {
+            "name": "ric1",
+            "baseUrl": "http://a1-sim-OSC:8085/",
+            "controller": "a1-controller",
+            "managedElementIds": [
+               "kista_1",
+               "kista_2"
+            ]
+         },
+         {
+            "name":"ric2",
+            "baseUrl":"http://a1-sim-STD:8085/",
+            "controller": "a1-controller",
+            "managedElementIds":[
+               "kista_1",
+               "kista_2"
+            ]
+         }
+      ]
+   }
+}
\ No newline at end of file
diff --git a/docker-compose/sdnc/docker-compose.yml b/docker-compose/sdnc/docker-compose.yml
new file mode 100644 (file)
index 0000000..edbe0bc
--- /dev/null
@@ -0,0 +1,104 @@
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+version: '3.0'
+services:
+  policy-agent:
+    image: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-policy-agent:1.0.0
+    container_name: policy-agent
+    networks:
+      default:
+        aliases:
+          - policy-agent-container
+    ports:
+      - 8081:8081
+      - 8433:8433
+    volumes:
+      - ./config:/opt/app/policy-agent/config:ro
+
+  a1-sim-OSC:
+    image: nexus3.o-ran-sc.org:10004/o-ran-sc/a1-simulator:1.0.1
+    container_name: a1-sim-OSC
+    networks:
+      - default
+    ports:
+      - 30001:8085
+      - 30002:8185
+    environment:
+      - A1_VERSION=OSC_2.1.0
+      - REMOTE_HOSTS_LOGGING=1
+      - ALLOW_HTTP=true
+
+  a1-sim-STD:
+    image: nexus3.o-ran-sc.org:10004/o-ran-sc/a1-simulator:1.0.1
+    container_name: a1-sim-STD
+    networks:
+      - default
+    ports:
+      - 30003:8085
+      - 30004:8185
+    environment:
+      - A1_VERSION=STD_1.1.3
+      - REMOTE_HOSTS_LOGGING=1
+      - ALLOW_HTTP=true
+
+  policy-control-panel:
+    image: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-controlpanel:1.0.0
+    container_name: policy-control-panel
+    networks:
+      - default
+    ports:
+      - 8080:8080
+      - 8082:8082
+
+  db:
+    image: mysql/mysql-server:5.6
+    container_name: sdnc-db
+    networks:
+      - default
+    ports:
+      - "3306"
+    environment:
+      - MYSQL_ROOT_PASSWORD=openECOMP1.0
+      - MYSQL_ROOT_HOST=%
+    logging:
+      driver:   "json-file"
+      options:
+        max-size: "30m"
+        max-file: "5"
+
+  a1-controller:
+    image: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-a1-controller:1.7.5
+    depends_on :
+      - db
+    container_name: a1-controller
+    networks:
+      - default
+    entrypoint: ["/opt/onap/sdnc/bin/startODL.sh"]
+    ports:
+      - 8282:8181
+      - 8443:8443
+    links:
+      - db:dbhost
+      - db:sdnctldb01
+      - db:sdnctldb02
+    environment:
+      - MYSQL_ROOT_PASSWORD=openECOMP1.0
+      - SDNC_CONFIG_DIR=/opt/onap/sdnc/data/properties
+    logging:
+      driver:   "json-file"
+      options:
+        max-size: "30m"
+        max-file: "5"
index da9fd44..15f0502 100644 (file)
@@ -27,7 +27,8 @@ RUN mkdir -p /opt/app/policy-agent/etc/cert/
 
 EXPOSE 8081 8433
 
-ADD /config/* /opt/app/policy-agent/config/
+ADD /config/application.yaml /opt/app/policy-agent/config/application.yaml
+ADD /config/application_configuration.json /opt/app/policy-agent/data/application_configuration.json_example
 ADD target/${JAR} /opt/app/policy-agent/policy-agent.jar
 
 
index c0ddfb5..aac4393 100644 (file)
@@ -29,7 +29,7 @@ server:
       key-password: policy_agent
       key-alias: policy_agent
 app:
-  filepath: /opt/app/policy-agent/config/application_configuration.json
+  filepath: /opt/app/policy-agent/data/application_configuration.json
   webclient:
     trust-store-used: false
     trust-store-password: policy_agent
index 4ba58c7..b292c51 100644 (file)
@@ -196,7 +196,7 @@ public class AsyncRestClient {
             logger.debug("{} HTTP error status = '{}', body '{}'", traceTag, exception.getStatusCode(),
                 exception.getResponseBodyAsString());
         } else {
-            logger.debug("{} HTTP error: {}", traceTag, t.getMessage());
+            logger.debug("{} HTTP error", traceTag, t);
         }
     }
 
index 49d7702..832bbe9 100644 (file)
@@ -269,6 +269,7 @@ public class PolicyController {
             RejectionException e = new RejectionException("Policy cannot change RIC, policyId: " + current.id() + //
                 ", RIC name: " + current.ric().name() + //
                 ", new name: " + policy.ric().name(), HttpStatus.CONFLICT);
+            logger.debug("Request rejected, {}", e);
             return Mono.error(e);
         }
         return Mono.just("OK");
@@ -276,6 +277,7 @@ public class PolicyController {
 
     private Mono<Object> checkSupportedType(Ric ric, PolicyType type) {
         if (!ric.isSupportingType(type.name())) {
+            logger.debug("Request rejected, type not supported, RIC: {}", ric);
             RejectionException e = new RejectionException(
                 "Type: " + type.name() + " not supported by RIC: " + ric.name(), HttpStatus.NOT_FOUND);
             return Mono.error(e);
@@ -287,6 +289,7 @@ public class PolicyController {
         if (ric.getState() == Ric.RicState.AVAILABLE) {
             return Mono.just("OK");
         } else {
+            logger.debug("Request rejected RIC not IDLE, ric: {}", ric);
             RejectionException e = new RejectionException(
                 "Ric is not operational, RIC name: " + ric.name() + ", state: " + ric.getState(), HttpStatus.LOCKED);
             return Mono.error(e);
index c50a46f..19d1564 100644 (file)
@@ -35,6 +35,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
+import org.springframework.web.reactive.function.client.WebClientException;
 import org.springframework.web.reactive.function.client.WebClientResponseException;
 import reactor.core.publisher.Mono;
 
@@ -81,7 +82,7 @@ public class DmaapMessageHandler {
     private Mono<ResponseEntity<String>> handleAgentCallError(Throwable t, String originalMessage,
         DmaapRequestMessage dmaapRequestMessage) {
         logger.debug("Agent call failed: {}", t.getMessage());
-        HttpStatus status = HttpStatus.NOT_FOUND;
+        HttpStatus status = HttpStatus.INTERNAL_SERVER_ERROR;
         String errorMessage = t.getMessage();
         if (t instanceof WebClientResponseException) {
             WebClientResponseException exception = (WebClientResponseException) t;
@@ -90,7 +91,8 @@ public class DmaapMessageHandler {
         } else if (t instanceof ServiceException) {
             status = HttpStatus.BAD_REQUEST;
             errorMessage = prepareBadOperationErrorMessage(t, originalMessage);
-
+        } else if (!(t instanceof WebClientException)) {
+            logger.warn("Unexpected exception ", t);
         }
         return sendDmaapResponse(errorMessage, dmaapRequestMessage, status) //
             .flatMap(notUsed -> Mono.empty());
@@ -119,7 +121,6 @@ public class DmaapMessageHandler {
         } else {
             return Mono.error(new ServiceException("Not implemented operation: " + operation));
         }
-
     }
 
     private String payload(DmaapRequestMessage message) {
index ed94492..716148f 100644 (file)
@@ -44,48 +44,6 @@ public class Lock {
     private final List<LockRequest> lockRequestQueue = new LinkedList<>();
     private static AsynchCallbackExecutor callbackProcessor = new AsynchCallbackExecutor();
 
-    private static class AsynchCallbackExecutor implements Runnable {
-        private List<LockRequest> lockRequestQueue = new LinkedList<>();
-
-        public AsynchCallbackExecutor() {
-            Thread thread = new Thread(this);
-            thread.start();
-        }
-
-        public synchronized void addAll(List<LockRequest> requests) {
-            this.lockRequestQueue.addAll(requests);
-            this.notifyAll();
-        }
-
-        @Override
-        public void run() {
-            try {
-                while (true) {
-                    for (LockRequest request : consume()) {
-                        request.callback.success(request.lock);
-                    }
-                    waitForNewEntries();
-                }
-            } catch (InterruptedException e) {
-                Thread.currentThread().interrupt();
-                logger.error("Interrupted {}", e.getMessage());
-            }
-        }
-
-        private synchronized List<LockRequest> consume() {
-            List<LockRequest> q = this.lockRequestQueue;
-            this.lockRequestQueue = new LinkedList<>();
-            return q;
-        }
-
-        @SuppressWarnings("java:S2274")
-        private synchronized void waitForNewEntries() throws InterruptedException {
-            if (this.lockRequestQueue.isEmpty()) {
-                this.wait();
-            }
-        }
-    }
-
     public enum LockType {
         EXCLUSIVE, SHARED
     }
@@ -113,23 +71,21 @@ public class Lock {
         });
     }
 
-    public void unlockBlocking() {
-        synchronized (this) {
-            if (lockCounter <= 0) {
-                lockCounter = -1; // Might as well stop, to make it easier to find the problem
-                logger.error("Number of unlocks must match the number of locks");
-            }
-            this.lockCounter--;
-            if (lockCounter == 0) {
-                isExclusive = false;
-            }
-            this.notifyAll();
+    public synchronized void unlockBlocking() {
+        if (lockCounter <= 0) {
+            lockCounter = -1; // Might as well stop, to make it easier to find the problem
+            logger.error("Number of unlocks must match the number of locks");
+        }
+        this.lockCounter--;
+        if (lockCounter == 0) {
+            isExclusive = false;
         }
+        this.notifyAll();
         this.processQueuedEntries();
     }
 
     @Override
-    public String toString() {
+    public synchronized String toString() {
         return "Lock cnt: " + this.lockCounter + " exclusive: " + this.isExclusive + " queued: "
             + this.lockRequestQueue.size();
     }
@@ -141,32 +97,19 @@ public class Lock {
 
     private void processQueuedEntries() {
         List<LockRequest> granted = new ArrayList<>();
-        synchronized (this) {
-            for (Iterator<LockRequest> i = lockRequestQueue.iterator(); i.hasNext();) {
-                LockRequest request = i.next();
-                if (tryLock(request.lockType)) {
-                    i.remove();
-                    granted.add(request);
-                }
+        for (Iterator<LockRequest> i = lockRequestQueue.iterator(); i.hasNext();) {
+            LockRequest request = i.next();
+            if (tryLock(request.lockType)) {
+                i.remove();
+                granted.add(request);
             }
         }
         callbackProcessor.addAll(granted);
     }
 
-    private static class LockRequest {
-        final MonoSink<Lock> callback;
-        final LockType lockType;
-        final Lock lock;
-
-        LockRequest(MonoSink<Lock> callback, LockType lockType, Lock lock) {
-            this.callback = callback;
-            this.lockType = lockType;
-            this.lock = lock;
-        }
-    }
-
     private synchronized void addToQueue(MonoSink<Lock> callback, LockType lockType) {
         lockRequestQueue.add(new LockRequest(callback, lockType, this));
+        processQueuedEntries();
     }
 
     @SuppressWarnings("java:S2274") // Always invoke wait() and await() methods inside a loop
@@ -191,4 +134,64 @@ public class Lock {
         return true;
     }
 
+    /**
+     * Represents a queued lock request
+     */
+    private static class LockRequest {
+        final MonoSink<Lock> callback;
+        final LockType lockType;
+        final Lock lock;
+
+        LockRequest(MonoSink<Lock> callback, LockType lockType, Lock lock) {
+            this.callback = callback;
+            this.lockType = lockType;
+            this.lock = lock;
+        }
+    }
+
+    /**
+     * A separate thread that calls a MonoSink to continue. This is done after a
+     * queued lock is granted.
+     */
+    private static class AsynchCallbackExecutor implements Runnable {
+        private List<LockRequest> lockRequestQueue = new LinkedList<>();
+
+        public AsynchCallbackExecutor() {
+            Thread thread = new Thread(this);
+            thread.start();
+        }
+
+        public synchronized void addAll(List<LockRequest> requests) {
+            this.lockRequestQueue.addAll(requests);
+            this.notifyAll();
+        }
+
+        @Override
+        public void run() {
+            try {
+                while (true) {
+                    for (LockRequest request : consume()) {
+                        request.callback.success(request.lock);
+                    }
+                    waitForNewEntries();
+                }
+            } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
+                logger.error("Interrupted {}", e.getMessage());
+            }
+        }
+
+        private synchronized List<LockRequest> consume() {
+            List<LockRequest> q = this.lockRequestQueue;
+            this.lockRequestQueue = new LinkedList<>();
+            return q;
+        }
+
+        @SuppressWarnings("java:S2274")
+        private synchronized void waitForNewEntries() throws InterruptedException {
+            if (this.lockRequestQueue.isEmpty()) {
+                this.wait();
+            }
+        }
+    }
 }
index d317e56..928b65f 100644 (file)
@@ -34,7 +34,7 @@ import java.util.Properties;
 import org.apache.http.client.HttpClient;
 import org.apache.http.conn.ssl.NoopHostnameVerifier;
 import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
+import org.apache.http.conn.ssl.TrustAllStrategy;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.http.ssl.SSLContexts;
 import org.slf4j.Logger;
@@ -87,7 +87,7 @@ public class RestAdapterImpl implements RestAdapter {
                   SSLContexts.custom()
                              .loadKeyMaterial(ResourceUtils.getFile(properties.getProperty("key-store")),
                                      keystorePassword.toCharArray(), keystorePassword.toCharArray())
-                             .loadTrustMaterial(null, new TrustSelfSignedStrategy())
+                             .loadTrustMaterial(null, new TrustAllStrategy())
                              .build(),
                   NoopHostnameVerifier.INSTANCE);
           HttpClient client = HttpClients.custom().setSSLSocketFactory(scsf).build();