public Builder mergeFrom(com.google.spanner.v1.CommitResponse other) { if (other == com.google.spanner.v1.CommitResponse.getDefaultInstance()) return this; if (other.hasCommitTimestamp()) { mergeCommitTimestamp(other.getCommitTimestamp()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
@java.lang.Override public com.google.spanner.v1.CommitResponse buildPartial() { com.google.spanner.v1.CommitResponse result = new com.google.spanner.v1.CommitResponse(this); if (commitTimestampBuilder_ == null) { result.commitTimestamp_ = commitTimestamp_; } else { result.commitTimestamp_ = commitTimestampBuilder_.build(); } onBuilt(); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (hasCommitTimestamp()) { hash = (37 * hash) + COMMIT_TIMESTAMP_FIELD_NUMBER; hash = (53 * hash) + getCommitTimestamp().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.spanner.v1.CommitResponse)) { return super.equals(obj); } com.google.spanner.v1.CommitResponse other = (com.google.spanner.v1.CommitResponse) obj; boolean result = true; result = result && (hasCommitTimestamp() == other.hasCommitTimestamp()); if (hasCommitTimestamp()) { result = result && getCommitTimestamp().equals(other.getCommitTimestamp()); } result = result && unknownFields.equals(other.unknownFields); return result; }
/** * * * <pre> * The Cloud Spanner timestamp at which the transaction committed. * </pre> * * <code>.google.protobuf.Timestamp commit_timestamp = 1;</code> */ public com.google.protobuf.TimestampOrBuilder getCommitTimestampOrBuilder() { return getCommitTimestamp(); }
@java.lang.Override public com.google.spanner.v1.CommitResponse getDefaultInstanceForType() { return com.google.spanner.v1.CommitResponse.getDefaultInstance(); }
if (!parseUnknownFieldProto3(input, unknownFields, extensionRegistry, tag)) { done = true; } finally { this.unknownFields = unknownFields.build(); makeExtensionsImmutable();
public static Builder newBuilder() { return DEFAULT_INSTANCE.toBuilder(); }
@java.lang.Override public com.google.spanner.v1.CommitResponse build() { com.google.spanner.v1.CommitResponse result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }
if (!commitResponse.hasCommitTimestamp()) { throw newSpannerException( ErrorCode.INTERNAL, "Missing commitTimestamp:\n" + session.getName()); commitTimestamp = Timestamp.fromProto(commitResponse.getCommitTimestamp()); opSpan.end(); } catch (RuntimeException e) {
@java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (commitTimestamp_ != null) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getCommitTimestamp()); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
.setResponseMarshaller( io.grpc.protobuf.ProtoUtils.marshaller( com.google.spanner.v1.CommitResponse.getDefaultInstance())) .setSchemaDescriptor(new SpannerMethodDescriptorSupplier("Commit")) .build();
public static Builder newBuilder(com.google.spanner.v1.CommitResponse prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); }
if (!commitResponse.hasCommitTimestamp()) { throw newSpannerException( ErrorCode.INTERNAL, "Missing commitTimestamp:\n" + session.getName()); commitTimestamp = Timestamp.fromProto(commitResponse.getCommitTimestamp()); opSpan.end(); } catch (RuntimeException e) {
@java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (commitTimestamp_ != null) { output.writeMessage(1, getCommitTimestamp()); } unknownFields.writeTo(output); }
@Test public void writeClosesOldSingleUseContext() throws ParseException { ReadContext ctx = session.singleUse(TimestampBound.strong()); Mockito.when(rpc.commit(Mockito.<CommitRequest>any(), Mockito.eq(options))) .thenReturn( CommitResponse.newBuilder() .setCommitTimestamp(Timestamps.parse("2015-10-01T10:54:20.021Z")) .build()); session.writeAtLeastOnce(Arrays.<Mutation>asList()); expectedException.expect(IllegalStateException.class); expectedException.expectMessage("invalidated"); ctx.read("Dummy", KeySet.all(), Arrays.asList("C")); }
.setResponseMarshaller( io.grpc.protobuf.ProtoUtils.marshaller( com.google.spanner.v1.CommitResponse.getDefaultInstance())) .setSchemaDescriptor(new SpannerMethodDescriptorSupplier("Commit")) .build();
Timestamp t = Timestamp.fromProto(response.getCommitTimestamp()); span.end(); return t;
@Test public void writeAtLeastOnce() throws ParseException { String timestampString = "2015-10-01T10:54:20.021Z"; ArgumentCaptor<CommitRequest> commit = ArgumentCaptor.forClass(CommitRequest.class); CommitResponse response = CommitResponse.newBuilder().setCommitTimestamp(Timestamps.parse(timestampString)).build(); Mockito.when(rpc.commit(commit.capture(), Mockito.eq(options))).thenReturn(response); Timestamp timestamp = session.writeAtLeastOnce( Arrays.asList(Mutation.newInsertBuilder("T").set("C").to("x").build())); assertThat(timestamp.getSeconds()) .isEqualTo(utcTimeSeconds(2015, Calendar.OCTOBER, 1, 10, 54, 20)); assertThat(timestamp.getNanos()).isEqualTo(TimeUnit.MILLISECONDS.toNanos(21)); CommitRequest request = commit.getValue(); assertThat(request.getSingleUseTransaction()).isNotNull(); assertThat(request.getSingleUseTransaction().getReadWrite()).isNotNull(); com.google.spanner.v1.Mutation mutation = com.google.spanner.v1.Mutation.newBuilder() .setInsert( Write.newBuilder() .setTable("T") .addColumns("C") .addValues( ListValue.newBuilder() .addValues(com.google.protobuf.Value.newBuilder().setStringValue("x")))) .build(); assertThat(request.getMutationsList()).containsExactly(mutation); }