Skip to content

Commit 8de444b

Browse files
peterzellerbieniusa
authored andcommitted
Update protocol buffer definition (#6)
* new proto * Fixed compiler errors * set transaction properties, which are mandatory now * update versions for travis
1 parent 6580d42 commit 8de444b

File tree

11 files changed

+80
-60
lines changed

11 files changed

+80
-60
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ target/
33
Antidote.iml
44
.gradle/
55
build/
6-
gen/
6+
gen/
7+
out/

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ services:
33
- docker
44
language: java
55
jdk:
6-
- oraclejdk8
6+
- oraclejdk11
77
before_install:
8-
- docker run -d --name antidote -p "8087:8087" antidotedb/antidote:0.2.0
8+
- docker run -d --name antidote -p "8087:8087" antidotedb/antidote:0.2.1

src/main/java/eu/antidotedb/client/AntidoteClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ public static ByteString getConnectionDescriptor(InetSocketAddress managerNode)
245245
AntidotePB.ApbGetConnectionDescriptor apbGetConnectionDescriptor = AntidotePB.ApbGetConnectionDescriptor.newBuilder()
246246
.build();
247247
SocketSender socketSender = new SocketSender(s);
248-
AntidotePB.ApbGetConnectionDescriptorResponse connectionDescriptor = socketSender.handle(apbGetConnectionDescriptor).accept(new AntidoteResponse.MsgGetConnectionDescriptorResponse.Extractor());
248+
AntidotePB.ApbGetConnectionDescriptorResp connectionDescriptor = socketSender.handle(apbGetConnectionDescriptor).accept(new AntidoteResponse.MsgGetConnectionDescriptorResponse.Extractor());
249249
if (connectionDescriptor.getSuccess()) {
250-
return connectionDescriptor.getConDesc();
250+
return connectionDescriptor.getD();
251251
} else {
252252
throw new IOException("Error getting connection descriptor of node: Error code " + connectionDescriptor.getErrorcode());
253253
}
@@ -257,7 +257,7 @@ public static ByteString getConnectionDescriptor(InetSocketAddress managerNode)
257257
public static boolean connectToDCs(InetSocketAddress managerNode, List<ByteString> descriptors) throws IOException {
258258
try (Socket s = new Socket()) {
259259
s.connect(managerNode);
260-
AntidotePB.ApbConnectToDcs apbConnectToDcs = AntidotePB.ApbConnectToDcs.newBuilder()
260+
AntidotePB.ApbConnectToDCs apbConnectToDcs = AntidotePB.ApbConnectToDCs.newBuilder()
261261
.addAllDescriptors(descriptors)
262262
.build();
263263
SocketSender socketSender = new SocketSender(s);

src/main/java/eu/antidotedb/client/AntidoteStaticTransaction.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package eu.antidotedb.client;
22

3+
import eu.antidotedb.antidotepb.AntidotePB;
34
import eu.antidotedb.antidotepb.AntidotePB.ApbCommitResp;
45
import eu.antidotedb.antidotepb.AntidotePB.ApbStartTransaction;
56
import eu.antidotedb.antidotepb.AntidotePB.ApbStaticUpdateObjects;
@@ -66,10 +67,7 @@ public CommitInfo commitTransaction() {
6667
*/
6768
protected ApbStaticUpdateObjects createUpdateStaticObject() {
6869
ApbStaticUpdateObjects.Builder updateMessage = ApbStaticUpdateObjects.newBuilder(); // Message which will be sent to antidote
69-
ApbStartTransaction.Builder startTransaction = ApbStartTransaction.newBuilder();
70-
if (timestamp != null) {
71-
startTransaction.setTimestamp(timestamp.getCommitTime());
72-
}
70+
ApbStartTransaction.Builder startTransaction = newStartTransaction(timestamp);
7371
updateMessage.setTransaction(startTransaction);
7472
// TODO could optimize this by combining updates on same key
7573
for (ApbUpdateOp.Builder updateInstruction : transactionUpdateList) {
@@ -78,6 +76,15 @@ protected ApbStaticUpdateObjects createUpdateStaticObject() {
7876
return updateMessage.build();
7977
}
8078

79+
protected static ApbStartTransaction.Builder newStartTransaction(CommitInfo timestamp) {
80+
ApbStartTransaction.Builder startTransaction = ApbStartTransaction.newBuilder();
81+
startTransaction.setProperties(AntidotePB.ApbTxnProperties.newBuilder());
82+
if (timestamp != null) {
83+
startTransaction.setTimestamp(timestamp.getCommitTime());
84+
}
85+
return startTransaction;
86+
}
87+
8188

8289
@Override
8390
void performUpdate(ApbUpdateOp.Builder updateInstruction) {

src/main/java/eu/antidotedb/client/ApbCoder.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static AntidoteRequest<?> decodeRequest(InputStream stream) throws IOExce
6161
AntidotePB.ApbCreateDC apbCreateDC = AntidotePB.ApbCreateDC.parseFrom(data);
6262
return AntidoteRequest.of(apbCreateDC);
6363
case ApbConnectToDCs:
64-
AntidotePB.ApbConnectToDcs apbConnectToDcs = AntidotePB.ApbConnectToDcs.parseFrom(data);
64+
AntidotePB.ApbConnectToDCs apbConnectToDcs = AntidotePB.ApbConnectToDCs.parseFrom(data);
6565
return AntidoteRequest.of(apbConnectToDcs);
6666
case ApbGetConnectionDescriptor:
6767
AntidotePB.ApbGetConnectionDescriptor apbGetConnectionDescriptor = AntidotePB.ApbGetConnectionDescriptor.parseFrom(data);
@@ -109,7 +109,7 @@ public static AntidoteResponse decodeResponse(InputStream stream) throws IOExcep
109109
AntidotePB.ApbStaticReadObjectsResp apbStaticReadObjectsResp = AntidotePB.ApbStaticReadObjectsResp.parseFrom(data);
110110
return AntidoteResponse.of(apbStaticReadObjectsResp);
111111
case ApbGetConnectionDescriptorResponse:
112-
AntidotePB.ApbGetConnectionDescriptorResponse apbGetConnectionDescriptorResponse = AntidotePB.ApbGetConnectionDescriptorResponse.parseFrom(data);
112+
AntidotePB.ApbGetConnectionDescriptorResp apbGetConnectionDescriptorResponse = AntidotePB.ApbGetConnectionDescriptorResp.parseFrom(data);
113113
return AntidoteResponse.of(apbGetConnectionDescriptorResponse);
114114
default:
115115
throw new RuntimeException("Unexpected message code: " + msgCode);
@@ -159,7 +159,7 @@ public static void encodeRequest(AntidotePB.ApbCreateDC op, OutputStream stream)
159159
encode(ApbCreateDC, op, stream);
160160
}
161161

162-
public static void encodeRequest(AntidotePB.ApbConnectToDcs op, OutputStream stream) {
162+
public static void encodeRequest(AntidotePB.ApbConnectToDCs op, OutputStream stream) {
163163
encode(ApbConnectToDCs, op, stream);
164164
}
165165

@@ -188,7 +188,7 @@ public static void encodeResponse(AntidotePB.ApbStaticReadObjectsResp op, Output
188188
encode(128, op, stream);
189189
}
190190

191-
public static void encodeResponse(AntidotePB.ApbGetConnectionDescriptorResponse op, OutputStream stream) {
191+
public static void encodeResponse(AntidotePB.ApbGetConnectionDescriptorResp op, OutputStream stream) {
192192
encode(ApbGetConnectionDescriptorResponse, op, stream);
193193
}
194194

@@ -260,7 +260,7 @@ public Void handle(AntidotePB.ApbCreateDC op) {
260260
}
261261

262262
@Override
263-
public Void handle(AntidotePB.ApbConnectToDcs op) {
263+
public Void handle(AntidotePB.ApbConnectToDCs op) {
264264
encodeRequest(op, stream);
265265
return null;
266266
}

src/main/java/eu/antidotedb/client/InteractiveTransaction.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,9 @@ public InteractiveTransaction(AntidoteClient antidoteClient, CommitInfo timestam
5757
}
5858

5959
private void startTransaction(CommitInfo timestamp) {
60-
ApbTxnProperties.Builder transactionProperties = ApbTxnProperties.newBuilder();
6160

62-
ApbStartTransaction.Builder readwriteTransaction = ApbStartTransaction.newBuilder();
63-
readwriteTransaction.setProperties(transactionProperties);
64-
if (timestamp != null) {
65-
readwriteTransaction.setTimestamp(timestamp.getCommitTime());
66-
}
61+
ApbStartTransaction.Builder readwriteTransaction = AntidoteStaticTransaction.newStartTransaction(timestamp);
62+
6763

6864
ApbStartTransaction startTransactionMessage = readwriteTransaction.build();
6965
AntidotePB.ApbStartTransactionResp transactionResponse = getClient().sendMessage(AntidoteRequest.of(startTransactionMessage), connection);

src/main/java/eu/antidotedb/client/NoTransaction.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ void performUpdate(AntidotePB.ApbUpdateOp.Builder updateInstruction) {
3434
@Override
3535
void performUpdates(Collection<AntidotePB.ApbUpdateOp.Builder> updateInstructions) {
3636
AntidotePB.ApbStaticUpdateObjects.Builder updateMessage = AntidotePB.ApbStaticUpdateObjects.newBuilder(); // Message which will be sent to antidote
37-
AntidotePB.ApbStartTransaction.Builder startTransaction = AntidotePB.ApbStartTransaction.newBuilder();
38-
if (timestamp != null) {
39-
startTransaction.setTimestamp(timestamp.getCommitTime());
40-
}
37+
AntidotePB.ApbStartTransaction.Builder startTransaction = AntidoteStaticTransaction.newStartTransaction(timestamp);
4138
updateMessage.setTransaction(startTransaction);
4239
for (AntidotePB.ApbUpdateOp.Builder updateInstruction : updateInstructions) {
4340
updateMessage.addUpdates(updateInstruction);
@@ -55,7 +52,7 @@ AntidotePB.ApbReadObjectsResp readHelper(ByteString bucket, ByteString key, Anti
5552
.setType(type)
5653
.setKey(key);
5754
readMessage.addObjects(obj);
58-
AntidotePB.ApbStartTransaction.Builder startTransaction = AntidotePB.ApbStartTransaction.newBuilder();
55+
AntidotePB.ApbStartTransaction.Builder startTransaction = AntidoteStaticTransaction.newStartTransaction(timestamp);
5956
readMessage.setTransaction(startTransaction);
6057

6158
AntidotePB.ApbStaticReadObjectsResp resp =
@@ -70,7 +67,7 @@ void batchReadHelper(List<BatchReadResultImpl> requests) {
7067
for (BatchReadResultImpl request : requests) {
7168
readObject.addObjects(request.getObject());
7269
}
73-
readObject.setTransaction(AntidotePB.ApbStartTransaction.newBuilder().build());
70+
readObject.setTransaction(AntidoteStaticTransaction.newStartTransaction(timestamp));
7471

7572
AntidotePB.ApbStaticReadObjects readObjectsMessage = readObject.build();
7673
Connection connection = client.getPoolManager().getConnection();

src/main/java/eu/antidotedb/client/SocketSender.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public AntidoteResponse handle(AntidotePB.ApbCreateDC op) {
104104
}
105105

106106
@Override
107-
public AntidoteResponse handle(AntidotePB.ApbConnectToDcs op) {
107+
public AntidoteResponse handle(AntidotePB.ApbConnectToDCs op) {
108108
try {
109109
ApbCoder.encodeRequest(op, socket.getOutputStream());
110110
return ApbCoder.decodeResponse(socket.getInputStream());

src/main/java/eu/antidotedb/client/messages/AntidoteRequest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ default V handle(AntidotePB.ApbCreateDC op) {
5454
throw new ExtractionError("Unexpected message: " + op);
5555
}
5656

57-
default V handle(AntidotePB.ApbConnectToDcs op) {
57+
default V handle(AntidotePB.ApbConnectToDCs op) {
5858
throw new ExtractionError("Unexpected message: " + op);
5959
}
6060

@@ -110,7 +110,7 @@ public static MsgCreateDC of(AntidotePB.ApbCreateDC op) {
110110
return new MsgCreateDC(op);
111111
}
112112

113-
public static MsgConnectToDCs of(AntidotePB.ApbConnectToDcs op) {
113+
public static MsgConnectToDCs of(AntidotePB.ApbConnectToDCs op) {
114114
return new MsgConnectToDCs(op);
115115
}
116116

@@ -404,18 +404,18 @@ public String toString() {
404404
}
405405

406406
private static class MsgConnectToDCs extends AntidoteRequest<AntidotePB.ApbOperationResp> {
407-
private final AntidotePB.ApbConnectToDcs op;
407+
private final AntidotePB.ApbConnectToDCs op;
408408

409-
public static class Extractor implements Handler<AntidotePB.ApbConnectToDcs> {
409+
public static class Extractor implements Handler<AntidotePB.ApbConnectToDCs> {
410410

411411

412412
@Override
413-
public AntidotePB.ApbConnectToDcs handle(AntidotePB.ApbConnectToDcs op) {
413+
public AntidotePB.ApbConnectToDCs handle(AntidotePB.ApbConnectToDCs op) {
414414
return op;
415415
}
416416
}
417417

418-
private MsgConnectToDCs(AntidotePB.ApbConnectToDcs apbConnectToDcs) {
418+
private MsgConnectToDCs(AntidotePB.ApbConnectToDCs apbConnectToDcs) {
419419
this.op = apbConnectToDcs;
420420
}
421421

@@ -430,7 +430,7 @@ public AntidoteResponse.Handler<AntidotePB.ApbOperationResp> readResponseExtract
430430
}
431431
}
432432

433-
private static class MsgGetConnectionDescriptor extends AntidoteRequest<AntidotePB.ApbGetConnectionDescriptorResponse> {
433+
private static class MsgGetConnectionDescriptor extends AntidoteRequest<AntidotePB.ApbGetConnectionDescriptorResp> {
434434
private final AntidotePB.ApbGetConnectionDescriptor op;
435435

436436
public static class Extractor implements Handler<AntidotePB.ApbGetConnectionDescriptor> {
@@ -452,7 +452,7 @@ public <V> V accept(Handler<V> handler) {
452452
}
453453

454454
@Override
455-
public AntidoteResponse.Handler<AntidotePB.ApbGetConnectionDescriptorResponse> readResponseExtractor() {
455+
public AntidoteResponse.Handler<AntidotePB.ApbGetConnectionDescriptorResp> readResponseExtractor() {
456456
return new AntidoteResponse.MsgGetConnectionDescriptorResponse.Extractor();
457457
}
458458
}

src/main/java/eu/antidotedb/client/messages/AntidoteResponse.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ default V handle(AntidotePB.ApbStaticReadObjectsResp op) {
4646
throw new ExtractionError(this.getClass() + " - Unexpected message: " + op);
4747
}
4848

49-
default V handle(AntidotePB.ApbGetConnectionDescriptorResponse op) {
49+
default V handle(AntidotePB.ApbGetConnectionDescriptorResp op) {
5050
throw new ExtractionError(this.getClass() + " - Unexpected message: " + op);
5151
}
5252

@@ -92,7 +92,7 @@ public static AntidoteResponse of(AntidotePB.ApbStaticReadObjectsResp op) {
9292
return new MsgStaticReadObjectsResp(op);
9393
}
9494

95-
public static AntidoteResponse of(AntidotePB.ApbGetConnectionDescriptorResponse op) {
95+
public static AntidoteResponse of(AntidotePB.ApbGetConnectionDescriptorResp op) {
9696
return new MsgGetConnectionDescriptorResponse(op);
9797
}
9898

@@ -326,16 +326,16 @@ public String toString() {
326326
}
327327

328328
public static class MsgGetConnectionDescriptorResponse extends AntidoteResponse {
329-
private AntidotePB.ApbGetConnectionDescriptorResponse op;
329+
private AntidotePB.ApbGetConnectionDescriptorResp op;
330330

331-
public static class Extractor implements Handler<AntidotePB.ApbGetConnectionDescriptorResponse> {
331+
public static class Extractor implements Handler<AntidotePB.ApbGetConnectionDescriptorResp> {
332332
@Override
333-
public AntidotePB.ApbGetConnectionDescriptorResponse handle(AntidotePB.ApbGetConnectionDescriptorResponse op) {
333+
public AntidotePB.ApbGetConnectionDescriptorResp handle(AntidotePB.ApbGetConnectionDescriptorResp op) {
334334
return op;
335335
}
336336
}
337337

338-
private MsgGetConnectionDescriptorResponse(AntidotePB.ApbGetConnectionDescriptorResponse op) {
338+
private MsgGetConnectionDescriptorResponse(AntidotePB.ApbGetConnectionDescriptorResp op) {
339339
this.op = op;
340340
}
341341

0 commit comments

Comments
 (0)