From 2eeaa754fcf4837121051ef51f2b751b216cd78e Mon Sep 17 00:00:00 2001 From: barrierye Date: Thu, 16 Jul 2020 15:43:15 +0800 Subject: [PATCH] change param endpoints in connect function to target --- .../main/java/PaddleServingClientExample.java | 28 ++++++++++--------- .../java/io/paddle/serving/client/Client.java | 11 ++++---- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/java/examples/src/main/java/PaddleServingClientExample.java b/java/examples/src/main/java/PaddleServingClientExample.java index 3505d8c5..a9334c2f 100644 --- a/java/examples/src/main/java/PaddleServingClientExample.java +++ b/java/examples/src/main/java/PaddleServingClientExample.java @@ -17,8 +17,8 @@ public class PaddleServingClientExample { List fetch = Arrays.asList("price"); Client client = new Client(); - List endpoints = Arrays.asList("localhost:9393"); - boolean succ = client.connect(endpoints); + String target = "localhost:9393"; + boolean succ = client.connect(target); if (succ != true) { System.out.println("connect failed."); return false; @@ -52,8 +52,8 @@ public class PaddleServingClientExample { List fetch = Arrays.asList("price"); Client client = new Client(); - List endpoints = Arrays.asList("localhost:9393"); - boolean succ = client.connect(endpoints); + String target = "localhost:9393"; + boolean succ = client.connect(target); if (succ != true) { System.out.println("connect failed."); return false; @@ -82,8 +82,8 @@ public class PaddleServingClientExample { List fetch = Arrays.asList("price"); Client client = new Client(); - List endpoints = Arrays.asList("localhost:9393"); - boolean succ = client.connect(endpoints); + String target = "localhost:9393"; + boolean succ = client.connect(target); if (succ != true) { System.out.println("connect failed."); return false; @@ -112,8 +112,8 @@ public class PaddleServingClientExample { List fetch = Arrays.asList("prediction"); Client client = new Client(); - List endpoints = Arrays.asList("localhost:9393"); - boolean succ = client.connect(endpoints); + String target = "localhost:9393"; + boolean succ = client.connect(target); if (succ != true) { System.out.println("connect failed."); return false; @@ -150,8 +150,8 @@ public class PaddleServingClientExample { List fetch = Arrays.asList("pooled_output"); Client client = new Client(); - List endpoints = Arrays.asList("localhost:9393"); - boolean succ = client.connect(endpoints); + String target = "localhost:9393"; + boolean succ = client.connect(target); if (succ != true) { System.out.println("connect failed."); return false; @@ -231,8 +231,8 @@ public class PaddleServingClientExample { List fetch = Arrays.asList("prob"); Client client = new Client(); - List endpoints = Arrays.asList("localhost:9292"); - boolean succ = client.connect(endpoints); + String target = "localhost:9393"; + boolean succ = client.connect(target); if (succ != true) { System.out.println("connect failed."); return false; @@ -269,9 +269,11 @@ public class PaddleServingClientExample { succ = e.batch_predict(); } else if ("cube_local".equals(arg)) { succ = e.cube_local(); + } else if ("cube_quant".equals(arg)) { + succ = e.cube_local(); } else { System.out.format("%s not match: java -cp PaddleServingClientExample .\n", arg); - System.out.println(": fit_a_line bert model_ensemble asyn_predict batch_predict cube_local."); + System.out.println(": fit_a_line bert model_ensemble asyn_predict batch_predict cube_local cube_quant."); } } diff --git a/java/src/main/java/io/paddle/serving/client/Client.java b/java/src/main/java/io/paddle/serving/client/Client.java index ea891877..b83fe858 100644 --- a/java/src/main/java/io/paddle/serving/client/Client.java +++ b/java/src/main/java/io/paddle/serving/client/Client.java @@ -109,10 +109,9 @@ public class Client { return resp.getErrCode() == 0; } - public boolean connect(List endpoints) { - // TODO - //String target = "ipv4:" + String.join(",", endpoints); - String target = endpoints.get(0); + public boolean connect(String target) { + // TODO: target must be NameResolver-compliant URI + // https://grpc.github.io/grpc-java/javadoc/io/grpc/ManagedChannelBuilder.html try { channel_ = ManagedChannelBuilder.forTarget(target) .defaultLoadBalancingPolicy("round_robin") @@ -484,8 +483,8 @@ public class Client { List fetch = Arrays.asList("price"); Client client = new Client(); - List endpoints = Arrays.asList("localhost:9393"); - boolean succ = client.connect(endpoints); + String endpoint = "localhost:9393"; + boolean succ = client.connect(endpoint); if (succ != true) { System.out.println("connect failed."); return; -- GitLab