From fd00a6849e072eb429e7ed7181588389f39bbdff Mon Sep 17 00:00:00 2001 From: HuabingZhao Date: Wed, 21 Mar 2018 09:14:25 +0800 Subject: Support healthy check for registered services Issue-ID: MSB-180 Change-Id: I352dfe32d3fbc1c7736ffbbb7b72718e6bbb5e01 Signed-off-by: HuabingZhao --- .../sdk/example/client/AnimalServiceClient.java | 4 +- .../onap/msb/sdk/example/client/ExampleClient.java | 4 +- .../onap/msb/sdk/example/server/ExampleApp.java | 4 +- .../org/onap/msb/sdk/example/server/MsbHelper.java | 55 +++++++++++----------- 4 files changed, 33 insertions(+), 34 deletions(-) (limited to 'example/src') diff --git a/example/src/main/java/org/onap/msb/sdk/example/client/AnimalServiceClient.java b/example/src/main/java/org/onap/msb/sdk/example/client/AnimalServiceClient.java index cd9ebbb..aa6b9e3 100644 --- a/example/src/main/java/org/onap/msb/sdk/example/client/AnimalServiceClient.java +++ b/example/src/main/java/org/onap/msb/sdk/example/client/AnimalServiceClient.java @@ -23,6 +23,6 @@ import retrofit2.http.Path; @ServiceHttpEndPoint(serviceName = "animals", serviceVersion = "v1") public interface AnimalServiceClient { - @GET("animals/{name}") - Call queryAnimal(@Path("name") String name); + @GET("animals/{name}") + Call queryAnimal(@Path("name") String name); } diff --git a/example/src/main/java/org/onap/msb/sdk/example/client/ExampleClient.java b/example/src/main/java/org/onap/msb/sdk/example/client/ExampleClient.java index 4184b02..968621f 100644 --- a/example/src/main/java/org/onap/msb/sdk/example/client/ExampleClient.java +++ b/example/src/main/java/org/onap/msb/sdk/example/client/ExampleClient.java @@ -29,8 +29,8 @@ public class ExampleClient { public static void main(String[] args) throws IOException { // For real use case, MSB discovery IP and Port should come from configuration file instead // of hard code here - String msb_discovery_ip = "127.0.0.1"; - int msb_discovery_port = 10081; + String msb_discovery_ip = "10.96.33.44"; + int msb_discovery_port = 30080; MSBServiceClient msbClient = new MSBServiceClient(msb_discovery_ip, msb_discovery_port); diff --git a/example/src/main/java/org/onap/msb/sdk/example/server/ExampleApp.java b/example/src/main/java/org/onap/msb/sdk/example/server/ExampleApp.java index 7e74ed2..002a358 100644 --- a/example/src/main/java/org/onap/msb/sdk/example/server/ExampleApp.java +++ b/example/src/main/java/org/onap/msb/sdk/example/server/ExampleApp.java @@ -40,8 +40,8 @@ public class ExampleApp extends Application { public void run(Config configuration, Environment environment) throws Exception { // For real use case, MSB discovery IP and Port should come from configuration file instead // of hard code here - String msb_discovery_ip = "127.0.0.1"; - int msb_discovery_port = 10081; + String msb_discovery_ip = "10.96.33.44"; + int msb_discovery_port = 30081; environment.jersey().register(new AnimalResource()); diff --git a/example/src/main/java/org/onap/msb/sdk/example/server/MsbHelper.java b/example/src/main/java/org/onap/msb/sdk/example/server/MsbHelper.java index bd49a9b..c3cab67 100644 --- a/example/src/main/java/org/onap/msb/sdk/example/server/MsbHelper.java +++ b/example/src/main/java/org/onap/msb/sdk/example/server/MsbHelper.java @@ -24,32 +24,31 @@ import org.onap.msb.sdk.httpclient.msb.MSBServiceClient; public class MsbHelper { - private MSBServiceClient msbClient; - - public MsbHelper(MSBServiceClient msbClient) { - super(); - this.msbClient = msbClient; - } - - - - public void registerMsb() throws Exception { - - - MicroServiceInfo msinfo = new MicroServiceInfo(); - - msinfo.setServiceName("animals"); - msinfo.setVersion("v1"); - msinfo.setUrl("/api/rpc/v1"); - msinfo.setProtocol("REST"); - msinfo.setVisualRange("0|1"); - - Set nodes = new HashSet<>(); - Node node1 = new Node(); - node1.setIp(InetAddress.getLocalHost().getHostAddress()); - node1.setPort("9090"); - nodes.add(node1); - msinfo.setNodes(nodes); - msbClient.registerMicroServiceInfo(msinfo, false); - } + private MSBServiceClient msbClient; + + public MsbHelper(MSBServiceClient msbClient) { + super(); + this.msbClient = msbClient; + } + + + + public void registerMsb() throws Exception { + MicroServiceInfo msinfo = new MicroServiceInfo(); + msinfo.setServiceName("animals"); + msinfo.setVersion("v1"); + msinfo.setUrl("/api/rpc/v1"); + msinfo.setProtocol("REST"); + msinfo.setVisualRange("0|1"); + + Set nodes = new HashSet<>(); + Node node1 = new Node(); + node1.setIp(InetAddress.getLocalHost().getHostAddress()); + node1.setPort("9090"); + node1.setCheckType("HTTP"); + node1.setCheckUrl("http://10.74.57.151:9090/api/rpc/v1/animals/panda"); + nodes.add(node1); + msinfo.setNodes(nodes); + msbClient.registerMicroServiceInfo(msinfo, false); + } } -- cgit 1.2.3-korg