Unified Http server configuration 29/92529/4
authorEliezio Oliveira <eliezio.oliveira@est.tech>
Thu, 1 Aug 2019 11:52:49 +0000 (12:52 +0100)
committerDan Timoney <dtimoney@att.com>
Fri, 9 Aug 2019 18:41:17 +0000 (18:41 +0000)
To allow UA tests with both servers listening on random TCP ports.

Change-Id: I9f125b8f2568797b8f7a747b7d8b7bd9a163d30e
Issue-ID: CCSDK-1568
Signed-off-by: Eliezio Oliveira <eliezio.oliveira@est.tech>
ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintGRPCServer.java
ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintHttpServer.java [moved from ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/cds/blueprintsprocessor/HttpServerWhenGrpcDisable.java with 77% similarity]
ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/cds/blueprintsprocessor/HttpServerWhenGrpcEnable.java [deleted file]

index 6bb6a26..5ad6ee2 100644 (file)
@@ -59,7 +59,6 @@ public class BlueprintGRPCServer implements ApplicationListener<ContextRefreshed
 
             server.start();
             log.info("Blueprint Processor GRPC server started and ready to serve on port({})...", server.getPort());
-            server.awaitTermination();
         } catch (Exception e) {
             log.error("*** Error ***", e);
         }
 package org.onap.ccsdk.cds.blueprintsprocessor;
 
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory;
 import org.springframework.boot.web.server.WebServerFactoryCustomizer;
 import org.springframework.stereotype.Component;
 
-// When GRPC disable, no need to create the netty server
-@ConditionalOnProperty(name = "blueprintsprocessor.grpcEnable", havingValue = "false")
 @Component
-public class HttpServerWhenGrpcDisable implements WebServerFactoryCustomizer<NettyReactiveWebServerFactory> {
+public class BlueprintHttpServer implements WebServerFactoryCustomizer<NettyReactiveWebServerFactory> {
 
     @Value("${blueprintsprocessor.httpPort}")
     private Integer httpPort;
diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/cds/blueprintsprocessor/HttpServerWhenGrpcEnable.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/cds/blueprintsprocessor/HttpServerWhenGrpcEnable.java
deleted file mode 100644 (file)
index e769b93..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright © 2019 Bell Canada.
- *
- * 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.
- */
-package org.onap.ccsdk.cds.blueprintsprocessor;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory;
-import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
-import org.springframework.boot.web.server.WebServer;
-import org.springframework.http.server.reactive.HttpHandler;
-import org.springframework.stereotype.Component;
-
-// When GRPC enable, we need to manually create the netty server
-@ConditionalOnProperty(name = "blueprintsprocessor.grpcEnable", havingValue = "true")
-@Component
-public class HttpServerWhenGrpcEnable {
-
-    @Value("${blueprintsprocessor.httpPort}")
-    private Integer httpPort;
-
-    private final HttpHandler httpHandler;
-    private WebServer http;
-
-    @Autowired
-    public HttpServerWhenGrpcEnable(HttpHandler httpHandler) {
-        this.httpHandler = httpHandler;
-    }
-
-    @PostConstruct
-    public void start() {
-        ReactiveWebServerFactory factory = new NettyReactiveWebServerFactory(httpPort);
-        this.http = factory.getWebServer(this.httpHandler);
-        this.http.start();
-    }
-
-    @PreDestroy
-    public void stop() {
-        this.http.stop();
-    }
-}
\ No newline at end of file