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 4e8a1aa9c44..0a9bb1a8bbc 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 0473c532591..92980dc1d5c 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 fac2453b3b1..55923f3a4f9 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 @@ private void writeRequest(String serviceMethod, Object args) throws GoRpcExcepti 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 1d60ca297e2..8e35006f03b 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 BSONObject readObject(InputStream in) throws IOException { 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 09cdf4d6fcc..9ee67bf01ae 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 void testUnsignedLongs() throws Exception { 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 ae664a5d28d..dfd9be5f48e 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 void run() { 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 2ac420e98a5..b16fd49ec2e 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 55f6c5f8c02..714b5bd82ab 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