diff --git a/java/examples/src/main/java/PaddleServingClientExample.java b/java/examples/src/main/java/PaddleServingClientExample.java index 3505d8c584e5011df2c52c6203bcb5b24c0a8d85..a9334c2f7b903ae27be5a187b77996f2e0c2c1e9 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 ea891877a01722b8cae9d456b5674112c01a4537..b83fe858ea1666ed8278d2dc16458215f23b55fc 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;