зеркало из https://github.com/github/vitess-gh.git
add java client and grpc
1. define rules in the Maven build files to compile the data protos at build time. 2. define a new vtgate service interface that uses the proto3 data structures and defines an abstract service.
This commit is contained in:
Родитель
e0dbef79b0
Коммит
e99e9b761d
|
@ -0,0 +1,102 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.youtube.vitess</groupId>
|
||||
<artifactId>vitess-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<groupId>com.youtube.vitess</groupId>
|
||||
<artifactId>client</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
<artifactId>hadoop-client</artifactId>
|
||||
<version>2.5.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
<artifactId>hadoop-mapreduce-client-jobclient</artifactId>
|
||||
<version>2.5.1</version>
|
||||
<!-- Include the test jar to reuse Hadoop testing utils -->
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<releases>
|
||||
<updatePolicy>never</updatePolicy>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
<id>central</id>
|
||||
<name>Central Repository</name>
|
||||
<url>https://repo.maven.apache.org/maven2</url>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>protoc-plugin</id>
|
||||
<url>https://dl.bintray.com/sergei-ivanov/maven/</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<build>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>kr.motd.maven</groupId>
|
||||
<artifactId>os-maven-plugin</artifactId>
|
||||
<version>1.2.3.Final</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.3</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.17</version>
|
||||
<configuration>
|
||||
<argLine>${surefireArgLine}</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.google.protobuf.tools</groupId>
|
||||
<artifactId>maven-protoc-plugin</artifactId>
|
||||
<version>0.4.2</version>
|
||||
<configuration>
|
||||
<protocArtifact>com.google.protobuf:protoc:${protobuf.java.version}:exe:${os.detected.classifier}</protocArtifact>
|
||||
<protoSourceRoot>../../proto</protoSourceRoot>
|
||||
<includes>
|
||||
<include>query.proto</include>
|
||||
<include>topodata.proto</include>
|
||||
<include>vtgate.proto</include>
|
||||
<include>vtrpc.proto</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,15 @@
|
|||
package com.youtube.vitess.client;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* Context carries deadlines, cancelation signals and other request-scoped values across API
|
||||
* boundaries and between processes.
|
||||
*
|
||||
* TODO(shengzhe): implement Context.
|
||||
*/
|
||||
public class Context {
|
||||
public static Context withDeadline(DateTime deadline) { return new Context(); }
|
||||
|
||||
private Context() {}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package com.youtube.vitess.client;
|
||||
|
||||
import com.youtube.vitess.proto.Vtgate.BeginRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.BeginResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.CommitRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.CommitResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteBatchKeyspaceIdsRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteBatchKeyspaceIdsResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteBatchShardsRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteBatchShardsResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteKeyRangesRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteKeyRangesResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteKeyspaceIdsRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteKeyspaceIdsResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteShardsRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteShardsResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.GetSrvKeyspaceRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.GetSrvKeyspaceResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.RollbackRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.RollbackResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.StreamExecuteKeyRangesRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.StreamExecuteKeyRangesResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.StreamExecuteKeyspaceIdsRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.StreamExecuteKeyspaceIdsResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.StreamExecuteShardsRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.StreamExecuteShardsResponse;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* RpcClient defines a set of methods to communicate with VTGates.
|
||||
*/
|
||||
public interface RpcClient extends Closeable {
|
||||
// executeShard sends a single query to a set of shards.
|
||||
ExecuteShardsResponse executeShard(
|
||||
Context ctx, ExecuteShardsRequest request) throws VitessRpcException;
|
||||
|
||||
// executeKeyspaceIds sends a query with keyspace ids as bind variables.
|
||||
ExecuteKeyspaceIdsResponse executeKeyspaceIds(
|
||||
Context ctx, ExecuteKeyspaceIdsRequest request) throws VitessRpcException;
|
||||
|
||||
// executeKeyRanges sends a query with a set of key ranges.
|
||||
ExecuteKeyRangesResponse executeKeyRanges(
|
||||
Context ctx, ExecuteKeyRangesRequest request) throws VitessRpcException;
|
||||
|
||||
// executeBatchKeyspaceIds sends a list of queries with keyspace ids as bind variables.
|
||||
ExecuteBatchKeyspaceIdsResponse executeBatchKeyspaceIds(
|
||||
Context ctx, ExecuteBatchKeyspaceIdsRequest request) throws VitessRpcException;
|
||||
|
||||
// executeBatchShards sends a list of queries to a set of shards.
|
||||
ExecuteBatchShardsResponse executeBatchShards(
|
||||
Context ctx, ExecuteBatchShardsRequest request) throws VitessRpcException;
|
||||
|
||||
// streamExecuteShard starts stream queries with multiple shards.
|
||||
Iterator<StreamExecuteShardsResponse> streamExecuteShard(
|
||||
Context ctx, StreamExecuteShardsRequest request) throws VitessRpcException;
|
||||
|
||||
// streamExecuteKeyspaceIds starts a list of stream queries with keyspace ids as bind variables.
|
||||
Iterator<StreamExecuteKeyspaceIdsResponse> streamExecuteKeyspaceIds(
|
||||
Context ctx, StreamExecuteKeyspaceIdsRequest request) throws VitessRpcException;
|
||||
|
||||
// streamExecuteKeyRanges starts stream query with a set of key ranges.
|
||||
Iterator<StreamExecuteKeyRangesResponse> streamExecuteKeyRanges(
|
||||
Context ctx, StreamExecuteKeyRangesRequest request) throws VitessRpcException;
|
||||
|
||||
// begin starts a transaction.
|
||||
BeginResponse begin(Context ctx, BeginRequest request) throws VitessRpcException;
|
||||
|
||||
// commit commits a transaction.
|
||||
CommitResponse commit(Context ctx, CommitRequest request) throws VitessRpcException;
|
||||
|
||||
// rollback rollbacks a pending transaction.
|
||||
RollbackResponse rollback(Context ctx, RollbackRequest request) throws VitessRpcException;
|
||||
|
||||
// getSrvKeyspace returns a list of serving keyspaces.
|
||||
GetSrvKeyspaceResponse getSrvKeyspace(
|
||||
Context ctx, GetSrvKeyspaceRequest request) throws VitessRpcException;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.youtube.vitess.client;
|
||||
|
||||
import org.joda.time.Duration;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
/**
|
||||
* RpcClientFactory creates a concrete RpcClient.
|
||||
*/
|
||||
public interface RpcClientFactory {
|
||||
RpcClient create(InetAddress address, Duration deadline);
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
package com.youtube.vitess.client;
|
||||
|
||||
import com.youtube.vitess.proto.Vtgate.BeginRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.BeginResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteBatchKeyspaceIdsRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteBatchKeyspaceIdsResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteBatchShardsRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteBatchShardsResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteKeyRangesRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteKeyRangesResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteKeyspaceIdsRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteKeyspaceIdsResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteShardsRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteShardsResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.GetSrvKeyspaceRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.GetSrvKeyspaceResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.StreamExecuteKeyRangesRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.StreamExecuteKeyRangesResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.StreamExecuteKeyspaceIdsRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.StreamExecuteKeyspaceIdsResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.StreamExecuteShardsRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.StreamExecuteShardsResponse;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* VTGateConn manages a VTGate connection.
|
||||
* TODO(shengzhe): define VitessException for app-level error
|
||||
* <p>Usage:
|
||||
*
|
||||
* <code>
|
||||
* RpcClient client = RpcClientFactory.create(
|
||||
* InetAddresses.forUriString("${VTGATE_ADDR}", Duration.millis(500)));
|
||||
* VTGateConn conn = VTGateConn.WithRpcClient(client);
|
||||
* Context ctx = Context.withDeadline(DateTime.now().plusMillis(500));
|
||||
*
|
||||
* try {
|
||||
*
|
||||
* CallerID callerId = CallerID.newBuilder().setPrincipal("username").build();
|
||||
* BindVariable bindVars = BindVariable.newBuilder()
|
||||
* .setType(Type.TYPE_INT)
|
||||
* .setValueInt(12345)
|
||||
* .build();
|
||||
* BoundQuery.Builder queryBuilder = BoundQuery.newBuilder()
|
||||
* .setSql(ByteString.copyFrom("INSERT INTO test_table VALUES(1, 2, 3)", Charsets.UTF_8));
|
||||
* queryBuilder.getMutableBindVariables().put("keyspaceid_01", bindVars);
|
||||
* BoundQuery query = queryBuilder.build();
|
||||
* ExecuteKeyspaceIdsRequest.newBuilder()
|
||||
* .setCallerId(callerId)
|
||||
* .setQuery(query)
|
||||
* .setKeyspace("my_keyspace")
|
||||
* .setKeyspaceIds(0, ByteString.copyFrom("keyspaceid_01", Charsets.UTF_8))
|
||||
* .setTabletType(TabletType.MASTER)
|
||||
* .build();
|
||||
*
|
||||
* ExecuteKeyspaceIdsResponse response = conn.ExecuteKeyspaceIds(ctx, request);
|
||||
* if (response.hasError()) {
|
||||
* // handle error.
|
||||
* }
|
||||
* QueryResult result = response.getResult();
|
||||
* for (Row row : result.getRowsList()) {
|
||||
* // process each row.
|
||||
* }
|
||||
* } catch (VitessRpcException e) {
|
||||
* // ...
|
||||
* }
|
||||
* </code>
|
||||
* */
|
||||
public class VTGateConn implements Closeable {
|
||||
|
||||
private RpcClient client;
|
||||
|
||||
private VTGateConn(RpcClient client) { this.client = client; }
|
||||
|
||||
public static VTGateConn WithRpcClient(RpcClient client) {
|
||||
return new VTGateConn(client);
|
||||
}
|
||||
|
||||
public ExecuteShardsResponse ExecuteShard(Context ctx, ExecuteShardsRequest request)
|
||||
throws VitessRpcException {
|
||||
return this.client.executeShard(ctx, request);
|
||||
}
|
||||
|
||||
public ExecuteKeyspaceIdsResponse ExecuteKeyspaceIds(Context ctx, ExecuteKeyspaceIdsRequest request)
|
||||
throws VitessRpcException {
|
||||
return this.client.executeKeyspaceIds(ctx, request);
|
||||
}
|
||||
|
||||
public ExecuteKeyRangesResponse executeKeyRanges(Context ctx, ExecuteKeyRangesRequest request)
|
||||
throws VitessRpcException {
|
||||
return this.client.executeKeyRanges(ctx, request);
|
||||
}
|
||||
|
||||
public ExecuteBatchKeyspaceIdsResponse executeBatchKeyspaceIds(
|
||||
Context ctx, ExecuteBatchKeyspaceIdsRequest request) throws VitessRpcException {
|
||||
return this.client.executeBatchKeyspaceIds(ctx, request);
|
||||
}
|
||||
|
||||
public ExecuteBatchShardsResponse executeBatchShards(Context ctx, ExecuteBatchShardsRequest request)
|
||||
throws VitessRpcException {
|
||||
return this.client.executeBatchShards(ctx, request);
|
||||
}
|
||||
|
||||
public Iterator<StreamExecuteShardsResponse> streamExecuteShard(
|
||||
Context ctx, StreamExecuteShardsRequest request) throws VitessRpcException {
|
||||
return this.client.streamExecuteShard(ctx, request);
|
||||
}
|
||||
|
||||
public Iterator<StreamExecuteKeyspaceIdsResponse> streamExecuteKeyspaceIds(
|
||||
Context ctx, StreamExecuteKeyspaceIdsRequest request) throws VitessRpcException {
|
||||
return this.client.streamExecuteKeyspaceIds(ctx, request);
|
||||
}
|
||||
|
||||
public Iterator<StreamExecuteKeyRangesResponse> streamExecuteKeyRanges(
|
||||
Context ctx, StreamExecuteKeyRangesRequest request) throws VitessRpcException {
|
||||
return this.client.streamExecuteKeyRanges(ctx, request);
|
||||
}
|
||||
|
||||
public VTGateTx begin(Context ctx, BeginRequest request) throws VitessRpcException {
|
||||
BeginResponse response = this.client.begin(ctx, request);
|
||||
if (response.hasError()) {
|
||||
throw new VitessRpcException(response.getError().getMessage());
|
||||
}
|
||||
return VTGateTx.withRpcClientAndSession(this.client, response.getSession());
|
||||
}
|
||||
|
||||
public GetSrvKeyspaceResponse getSrvKeyspace(Context ctx, GetSrvKeyspaceRequest request)
|
||||
throws VitessRpcException {
|
||||
return this.client.getSrvKeyspace(ctx, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
this.client.close();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
package com.youtube.vitess.client;
|
||||
|
||||
import com.youtube.vitess.proto.Query.QueryResult;
|
||||
import com.youtube.vitess.proto.Vtgate.CommitRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.CommitResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteBatchKeyspaceIdsRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteBatchKeyspaceIdsResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteBatchShardsRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteBatchShardsResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteKeyRangesRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteKeyRangesResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteKeyspaceIdsRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteKeyspaceIdsResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteShardsRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.ExecuteShardsResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.RollbackRequest;
|
||||
import com.youtube.vitess.proto.Vtgate.RollbackResponse;
|
||||
import com.youtube.vitess.proto.Vtgate.Session;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* VTGateTx manages a pending transaction.
|
||||
*/
|
||||
public class VTGateTx {
|
||||
|
||||
private RpcClient client;
|
||||
private Session session;
|
||||
|
||||
private VTGateTx(RpcClient client, Session session) {
|
||||
this.client = client;
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
public static VTGateTx withRpcClientAndSession(RpcClient client, Session session) {
|
||||
return new VTGateTx(client, session);
|
||||
}
|
||||
|
||||
public QueryResult executeShard(Context ctx, ExecuteShardsRequest request)
|
||||
throws VitessRpcException, VitessNotInTransactionException {
|
||||
if (this.session == null) {
|
||||
throw new VitessNotInTransactionException("executeShard: not in transaction");
|
||||
}
|
||||
ExecuteShardsResponse response = this.client.executeShard(ctx, request);
|
||||
this.session = response.getSession();
|
||||
return response.getResult();
|
||||
}
|
||||
|
||||
public QueryResult executeKeyspaceIds(Context ctx, ExecuteKeyspaceIdsRequest request)
|
||||
throws VitessRpcException, VitessNotInTransactionException {
|
||||
if (this.session == null) {
|
||||
throw new VitessNotInTransactionException("executeKeyspaceIds: not in transaction");
|
||||
}
|
||||
ExecuteKeyspaceIdsResponse response = this.client.executeKeyspaceIds(ctx, request);
|
||||
this.session = response.getSession();
|
||||
return response.getResult();
|
||||
}
|
||||
|
||||
public QueryResult executeKeyRanges(Context ctx, ExecuteKeyRangesRequest request)
|
||||
throws VitessRpcException, VitessNotInTransactionException {
|
||||
if (this.session == null) {
|
||||
throw new VitessNotInTransactionException("executeKeyRanges: not in transaction");
|
||||
}
|
||||
ExecuteKeyRangesResponse response = this.client.executeKeyRanges(ctx, request);
|
||||
this.session = response.getSession();
|
||||
return response.getResult();
|
||||
}
|
||||
|
||||
public List<QueryResult> executeBatchKeyspaceIds(
|
||||
Context ctx, ExecuteBatchKeyspaceIdsRequest request)
|
||||
throws VitessRpcException, VitessNotInTransactionException {
|
||||
if (this.session == null) {
|
||||
throw new VitessNotInTransactionException("executeBatchKeyspaceIds: not in transaction");
|
||||
}
|
||||
ExecuteBatchKeyspaceIdsResponse response = this.client.executeBatchKeyspaceIds(ctx, request);
|
||||
this.session = response.getSession();
|
||||
return response.getResultsList();
|
||||
}
|
||||
|
||||
public List<QueryResult> executeBatchShards(Context ctx, ExecuteBatchShardsRequest request)
|
||||
throws VitessRpcException, VitessNotInTransactionException {
|
||||
if (this.session == null) {
|
||||
throw new VitessNotInTransactionException("executeBatchShards: not in transaction");
|
||||
}
|
||||
ExecuteBatchShardsResponse response = this.client.executeBatchShards(ctx, request);
|
||||
this.session = response.getSession();
|
||||
return response.getResultsList();
|
||||
}
|
||||
|
||||
|
||||
public CommitResponse commit(Context ctx, CommitRequest request)
|
||||
throws VitessRpcException, VitessNotInTransactionException {
|
||||
if (this.session == null) {
|
||||
throw new VitessNotInTransactionException("commit: not in transaction");
|
||||
}
|
||||
CommitResponse response = this.client.commit(
|
||||
ctx, CommitRequest.newBuilder().setSession(this.session).build());
|
||||
this.session = null;
|
||||
return response;
|
||||
}
|
||||
|
||||
public RollbackResponse rollback(Context ctx, RollbackRequest request)
|
||||
throws VitessRpcException, VitessNotInTransactionException {
|
||||
if (this.session == null) {
|
||||
throw new VitessNotInTransactionException("rollback: not in transaction");
|
||||
}
|
||||
RollbackResponse response = this.client.rollback(
|
||||
ctx, RollbackRequest.newBuilder().setSession(this.session).build());
|
||||
this.session = null;
|
||||
return response;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.youtube.vitess.client;
|
||||
|
||||
/**
|
||||
* VitessNotInTransactionException indicates a request is not wrapped in a transaction.
|
||||
*/
|
||||
public class VitessNotInTransactionException extends Exception {
|
||||
|
||||
public VitessNotInTransactionException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public VitessNotInTransactionException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public VitessNotInTransactionException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public VitessNotInTransactionException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.youtube.vitess.client;
|
||||
|
||||
/**
|
||||
* VitessRpcException indicates a rpc error between client and VTGate.
|
||||
*/
|
||||
public class VitessRpcException extends Exception {
|
||||
|
||||
public VitessRpcException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public VitessRpcException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public VitessRpcException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public VitessRpcException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.youtube.vitess</groupId>
|
||||
<artifactId>vitess-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<groupId>com.youtube.vitess.grpc</groupId>
|
||||
<artifactId>vitess-grpc</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.grpc</groupId>
|
||||
<artifactId>grpc-all</artifactId>
|
||||
<version>${grpc.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<releases>
|
||||
<updatePolicy>never</updatePolicy>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
<id>central</id>
|
||||
<name>Central Repository</name>
|
||||
<url>https://repo.maven.apache.org/maven2</url>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>protoc-plugin</id>
|
||||
<url>https://dl.bintray.com/sergei-ivanov/maven/</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
<build>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>kr.motd.maven</groupId>
|
||||
<artifactId>os-maven-plugin</artifactId>
|
||||
<version>1.2.3.Final</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>com.google.protobuf.tools</groupId>
|
||||
<artifactId>maven-protoc-plugin</artifactId>
|
||||
<version>0.4.2</version>
|
||||
<configuration>
|
||||
<protocArtifact>com.google.protobuf:protoc:${protobuf.java.version}:exe:${os.detected.classifier}</protocArtifact>
|
||||
<pluginId>grpc-java</pluginId>
|
||||
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
|
||||
<protoSourceRoot>../../proto</protoSourceRoot>
|
||||
<includes>
|
||||
<include>query.proto</include>
|
||||
<include>topodata.proto</include>
|
||||
<include>vtgate.proto</include>
|
||||
<include>vtrpc.proto</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
<goal>compile-custom</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
12
java/pom.xml
12
java/pom.xml
|
@ -11,7 +11,9 @@
|
|||
<description>Umbrella project for all Java activities for Vitess</description>
|
||||
<inceptionYear>2014</inceptionYear>
|
||||
<modules>
|
||||
<module>client</module>
|
||||
<module>gorpc</module>
|
||||
<module>grpc</module>
|
||||
<module>vtgate-client</module>
|
||||
</modules>
|
||||
|
||||
|
@ -58,13 +60,16 @@
|
|||
</mailingList>
|
||||
</mailingLists>
|
||||
|
||||
<!-- define dependency versions -->
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<grpc.version>0.7.1</grpc.version>
|
||||
<guava.version>18.0</guava.version>
|
||||
<junit.version>4.12</junit.version>
|
||||
<log4j.version>1.2.17</log4j.version>
|
||||
<protobuf.java.version>3.0.0-alpha-3.1</protobuf.java.version>
|
||||
</properties>
|
||||
|
||||
<!-- define dependency versions -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
|
@ -82,5 +87,10 @@
|
|||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<version>${protobuf.java.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -9,9 +9,7 @@
|
|||
</parent>
|
||||
<groupId>com.youtube.vitess</groupId>
|
||||
<artifactId>vtgate-client</artifactId>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.youtube.vitess</groupId>
|
||||
|
@ -42,7 +40,33 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<releases>
|
||||
<updatePolicy>never</updatePolicy>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
<id>central</id>
|
||||
<name>Central Repository</name>
|
||||
<url>https://repo.maven.apache.org/maven2</url>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>protoc-plugin</id>
|
||||
<url>https://dl.bintray.com/sergei-ivanov/maven/</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<build>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>kr.motd.maven</groupId>
|
||||
<artifactId>os-maven-plugin</artifactId>
|
||||
<version>1.2.3.Final</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
@ -97,6 +121,31 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.google.protobuf.tools</groupId>
|
||||
<artifactId>maven-protoc-plugin</artifactId>
|
||||
<version>0.4.2</version>
|
||||
<configuration>
|
||||
<protocArtifact>com.google.protobuf:protoc:${protobuf.java.version}:exe:${os.detected.classifier}</protocArtifact>
|
||||
<pluginId>grpc-java</pluginId>
|
||||
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
|
||||
<protoSourceRoot>../../proto</protoSourceRoot>
|
||||
<includes>
|
||||
<include>query.proto</include>
|
||||
<include>topodata.proto</include>
|
||||
<include>vtgate.proto</include>
|
||||
<include>vtrpc.proto</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
<goal>compile-custom</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -5,6 +5,8 @@ syntax = "proto3";
|
|||
|
||||
package query;
|
||||
|
||||
option java_package="com.youtube.vitess.proto";
|
||||
|
||||
import "topodata.proto";
|
||||
import "vtrpc.proto";
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package="com.youtube.vitess.proto";
|
||||
|
||||
package topodata;
|
||||
|
||||
// KeyRange describes a range of sharding keys, when range-based
|
||||
|
|
|
@ -4,6 +4,8 @@ syntax = "proto3";
|
|||
|
||||
package vtgate;
|
||||
|
||||
option java_package="com.youtube.vitess.proto";
|
||||
|
||||
import "query.proto";
|
||||
import "topodata.proto";
|
||||
import "vtrpc.proto";
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package="com.youtube.vitess.proto.grpc";
|
||||
|
||||
package vtgateservice;
|
||||
|
||||
import "vtgate.proto";
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package="com.youtube.vitess.proto";
|
||||
|
||||
package vtrpc;
|
||||
|
||||
// CallerID is passed along RPCs to identify the originating client
|
||||
|
|
Загрузка…
Ссылка в новой задаче