From 982e1e2acf9008f06446229e1601c6e593116785 Mon Sep 17 00:00:00 2001 From: Shengzhe Yao Date: Tue, 28 Jul 2015 14:10:59 -0700 Subject: [PATCH] refactor java client pom structure 1. move common dependencies into parent pom. 2. upgrade com.google.guava to 18.0. 3. rename java build target to java_client_test. 4. fix makefile so java client test will run tests from each sub package. --- Makefile | 4 +- java/gorpc/pom.xml | 50 +++---------------- .../java/com/youtube/vitess/gorpc/Client.java | 2 +- .../gorpc/codecs/bson/GoRpcBsonDecoder.java | 2 +- .../com/youtube/vitess/gorpc/ClientIT.java | 2 +- .../youtube/vitess/gorpc/FakeGoServer.java | 3 +- java/pom.xml | 30 ++++++++++- java/vtgate-client/pom.xml | 36 +++---------- 8 files changed, 49 insertions(+), 80 deletions(-) diff --git a/Makefile b/Makefile index 4e8a1aa9c4..0a9bb1a8bb 100644 --- a/Makefile +++ b/Makefile @@ -44,7 +44,7 @@ site_test: unit_test site_integration_test clean: go clean -i ./go/... - rm -rf java/vtocc-client/target java/vtocc-jdbc-driver/target third_party/acolyte + rm -rf third_party/acolyte unit_test: godep go test $(VT_GO_PARALLEL) ./go/... @@ -194,7 +194,7 @@ site_integration_test: $(call run_integration_tests, $(site_integration_test_files)) java_vtgate_client_test: - mvn -f java/vtgate-client/pom.xml clean verify + mvn -f java/pom.xml clean verify v3_test: cd test && ./vtgatev3_test.py diff --git a/java/gorpc/pom.xml b/java/gorpc/pom.xml index 0473c53259..92980dc1d5 100644 --- a/java/gorpc/pom.xml +++ b/java/gorpc/pom.xml @@ -1,26 +1,15 @@ 4.0.0 + + com.youtube.vitess + vitess-parent + 1.0-SNAPSHOT + ../pom.xml + com.youtube.vitess gorpc-client - 0.0.1-SNAPSHOT - - - repo - https://github.com/youtube/mvn-repo/raw/master/releases - - - snapshot-repo - https://github.com/youtube/mvn-repo/raw/master/snapshots - - - - junit - junit - 4.11 - test - org.mongodb bson @@ -36,21 +25,11 @@ gson 2.3.1 - - log4j - log4j - 1.2.17 - org.mongodb mongo-java-driver 2.12.3 - - com.google.guava - guava - 11.0.2 - @@ -68,24 +47,9 @@ 2.17 ${surefireArgLine} + true - - org.apache.maven.plugins - maven-failsafe-plugin - 2.13 - - ${failsafeArgLine} - - - - - integration-test - verify - - - - diff --git a/java/gorpc/src/main/java/com/youtube/vitess/gorpc/Client.java b/java/gorpc/src/main/java/com/youtube/vitess/gorpc/Client.java index fac2453b3b..55923f3a4f 100644 --- a/java/gorpc/src/main/java/com/youtube/vitess/gorpc/Client.java +++ b/java/gorpc/src/main/java/com/youtube/vitess/gorpc/Client.java @@ -99,7 +99,7 @@ public class Client { if (isStreaming) { throw new GoRpcException("request not allowed as client is in the middle of streaming"); } - seq = seq.add(UnsignedLong.ONE); + seq = seq.plus(UnsignedLong.ONE); Request request = new Request(serviceMethod, seq); try { codec.WriteRequest(request, args); diff --git a/java/gorpc/src/main/java/com/youtube/vitess/gorpc/codecs/bson/GoRpcBsonDecoder.java b/java/gorpc/src/main/java/com/youtube/vitess/gorpc/codecs/bson/GoRpcBsonDecoder.java index 1d60ca297e..8e35006f03 100644 --- a/java/gorpc/src/main/java/com/youtube/vitess/gorpc/codecs/bson/GoRpcBsonDecoder.java +++ b/java/gorpc/src/main/java/com/youtube/vitess/gorpc/codecs/bson/GoRpcBsonDecoder.java @@ -51,7 +51,7 @@ public class GoRpcBsonDecoder extends ExtendableBsonDecoder { public static class GoRpcBSONCallBack extends BasicBSONCallback { public void gotULong(final String name, final long v) { - final UnsignedLong ulv = UnsignedLong.asUnsigned(v); + final UnsignedLong ulv = UnsignedLong.fromLongBits(v); _put(name, ulv); } } diff --git a/java/gorpc/src/test/java/com/youtube/vitess/gorpc/ClientIT.java b/java/gorpc/src/test/java/com/youtube/vitess/gorpc/ClientIT.java index 09cdf4d6fc..9ee67bf01a 100644 --- a/java/gorpc/src/test/java/com/youtube/vitess/gorpc/ClientIT.java +++ b/java/gorpc/src/test/java/com/youtube/vitess/gorpc/ClientIT.java @@ -118,7 +118,7 @@ public class ClientIT extends ClientTest { BSONObject mArgs = new BasicBSONObject(); mArgs.put("Num", a); Response response = client.call("Arith.Increment", mArgs); - Assert.assertEquals(a.add(UnsignedLong.ONE), (UnsignedLong) response.getReply()); + Assert.assertEquals(a.plus(UnsignedLong.ONE), (UnsignedLong) response.getReply()); client.close(); } } diff --git a/java/gorpc/src/test/java/com/youtube/vitess/gorpc/FakeGoServer.java b/java/gorpc/src/test/java/com/youtube/vitess/gorpc/FakeGoServer.java index ae664a5d28..dfd9be5f48 100644 --- a/java/gorpc/src/test/java/com/youtube/vitess/gorpc/FakeGoServer.java +++ b/java/gorpc/src/test/java/com/youtube/vitess/gorpc/FakeGoServer.java @@ -37,8 +37,9 @@ public class FakeGoServer extends Thread { new ArithThread(clientSocket).start(); } } catch (SocketException e) { + throw new RuntimeException(e); } catch (IOException e) { - e.printStackTrace(); + throw new RuntimeException(e); } } diff --git a/java/pom.xml b/java/pom.xml index 2ac420e98a..b16fd49ec2 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -3,10 +3,10 @@ xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.github.youtube.vitess + com.youtube.vitess vitess-parent - pom 1.0-SNAPSHOT + pom https://github.com/youtube/vitess/ Umbrella project for all Java activities for Vitess 2014 @@ -57,4 +57,30 @@ https://groups.google.com/forum/#!forum/vitess + + + + 18.0 + 4.12 + 1.2.17 + + + + + com.google.guava + guava + ${guava.version} + + + log4j + log4j + ${log4j.version} + + + junit + junit + ${junit.version} + test + + diff --git a/java/vtgate-client/pom.xml b/java/vtgate-client/pom.xml index 55f6c5f8c0..714b5bd82a 100644 --- a/java/vtgate-client/pom.xml +++ b/java/vtgate-client/pom.xml @@ -1,44 +1,22 @@ 4.0.0 + + com.youtube.vitess + vitess-parent + 1.0-SNAPSHOT + ../pom.xml + com.youtube.vitess vtgate-client - 0.0.1-SNAPSHOT UTF-8 - - - repo - https://github.com/youtube/mvn-repo/raw/master/releases - - - snapshot-repo - https://github.com/youtube/mvn-repo/raw/master/snapshots - - - - - youtube-snapshots - https://github.com/youtube/mvn-repo/raw/master/snapshots - - - - junit - junit - 4.11 - test - com.youtube.vitess gorpc-client - 0.0.1-SNAPSHOT - - - log4j - log4j - 1.2.17 + ${project.version} commons-codec