Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3872199
feat!: add support for CommitStats
olavloite Oct 24, 2020
def8768
fix: add clirr ignored differences
olavloite Oct 24, 2020
5372dae
Merge branch 'master' into commit-stats2
olavloite Oct 31, 2020
34fbda6
fix: error message should start with getCommitResponse
olavloite Oct 31, 2020
8f61c2a
Merge branch 'master' into commit-stats2
olavloite Nov 6, 2020
041b34d
Merge branch 'master' into commit-stats2
olavloite Dec 5, 2020
8299054
fix: remove overload delay
olavloite Dec 10, 2020
9b710a7
Merge branch 'master' into commit-stats2
olavloite Dec 10, 2020
8c15641
Merge branch 'master' into commit-stats2
olavloite Jan 23, 2021
919cf02
chore: cleanup after merge
olavloite Jan 23, 2021
97ec917
fix: update copyright years of new files
olavloite Jan 23, 2021
afeb0fd
test: fix flaky test
olavloite Jan 23, 2021
8524526
test: skip commit stats tests on emulator
olavloite Jan 23, 2021
06b3e22
test: missed one commit stats tests against emulator
olavloite Jan 23, 2021
1c17d16
test: skip another emulator test
olavloite Jan 23, 2021
664b87d
test: add missing test cases
olavloite Jan 23, 2021
6573a0f
fix: address review comments
olavloite Jan 30, 2021
0b448c3
Merge branch 'master' into commit-stats2
olavloite Feb 1, 2021
83039fb
Merge branch 'master' into commit-stats2
olavloite Feb 3, 2021
57ea714
chore: use junit assertion instead of truth
olavloite Feb 3, 2021
66c5f88
chore: replace truth asserts with junit asserts
olavloite Feb 4, 2021
1d17973
chore: replace truth assertions with junit
olavloite Feb 5, 2021
48ef21b
chore: cleanup test and variable names
olavloite Feb 8, 2021
1f33c42
fix: rename test method and variables
olavloite Feb 9, 2021
7d45ace
fix: address review comments
olavloite Feb 16, 2021
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'master' into commit-stats2
  • Loading branch information
olavloite committed Jan 23, 2021
commit 8c15641f07c55dea211aa714f45d9f7da8201aaa
50 changes: 49 additions & 1 deletion google-cloud-spanner/clirr-ignored-differences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,55 @@
<method>java.lang.Object initialize()</method>
</difference>

<!-- TransactionOptions and UpdateOptions -->
<difference>
<differenceType>7004</differenceType>
<className>com/google/cloud/spanner/DatabaseClient</className>
<method>long executePartitionedUpdate(com.google.cloud.spanner.Statement)</method>
</difference>
<difference>
<differenceType>7004</differenceType>
<className>com/google/cloud/spanner/DatabaseClient</className>
<method>com.google.cloud.spanner.TransactionRunner readWriteTransaction()</method>
</difference>
<difference>
<differenceType>7004</differenceType>
<className>com/google/cloud/spanner/DatabaseClient</className>
<method>com.google.cloud.spanner.AsyncRunner runAsync()</method>
</difference>
<difference>
<differenceType>7004</differenceType>
<className>com/google/cloud/spanner/DatabaseClient</className>
<method>com.google.cloud.spanner.TransactionManager transactionManager()</method>
</difference>
<difference>
<differenceType>7004</differenceType>
<className>com/google/cloud/spanner/DatabaseClient</className>
<method>com.google.cloud.spanner.AsyncTransactionManager transactionManagerAsync()</method>
</difference>
<difference>
<differenceType>7004</differenceType>
<className>com/google/cloud/spanner/TransactionContext</className>
<method>long[] batchUpdate(java.lang.Iterable)</method>
</difference>
<difference>
<differenceType>7004</differenceType>
<className>com/google/cloud/spanner/TransactionContext</className>
<method>com.google.api.core.ApiFuture batchUpdateAsync(java.lang.Iterable)</method>
</difference>
<difference>
<differenceType>7004</differenceType>
<className>com/google/cloud/spanner/TransactionContext</className>
<method>long executeUpdate(com.google.cloud.spanner.Statement)</method>
</difference>
<difference>
<differenceType>7004</differenceType>
<className>com/google/cloud/spanner/TransactionContext</className>
<method>com.google.api.core.ApiFuture executeUpdateAsync(com.google.cloud.spanner.Statement)</method>
</difference>

<!-- Support for CommitStats added -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another one where a major version bump is required

<!--
<difference>
<differenceType>7005</differenceType>
<className>com/google/cloud/spanner/CommitResponse</className>
Expand Down Expand Up @@ -463,5 +511,5 @@
<method>com.google.cloud.spanner.AsyncTransactionManager transactionManagerAsync()</method>
<to>com.google.cloud.spanner.AsyncTransactionManager transactionManagerAsync(com.google.cloud.spanner.TransactionOption[])</to>
</difference>

-->
</differences>
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ final class AsyncTransactionManagerImpl
private TransactionState txnState;
private final SettableApiFuture<CommitResponse> commitResponse = SettableApiFuture.create();

AsyncTransactionManagerImpl(SessionImpl session, Span span, Options options) {
AsyncTransactionManagerImpl(SessionImpl session, Span span, TransactionOption... options) {
this.session = session;
this.span = span;
this.options = options;
this.options = Options.fromTransactionOptions(options);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ public Void run(TransactionContext ctx) {
return null;
}
});
<<<<<<< HEAD
return runner.getCommitResponse();
=======
return new CommitResponse(runner.getCommitTimestamp());
>>>>>>> master
}

@Override
Expand All @@ -157,7 +161,11 @@ public Timestamp writeAtLeastOnce(Iterable<Mutation> mutations) throws SpannerEx

@Override
public CommitResponse writeAtLeastOnceWithOptions(
<<<<<<< HEAD
final Iterable<Mutation> mutations, final TransactionOption... options)
=======
Iterable<Mutation> mutations, TransactionOption... transactionOptions)
>>>>>>> master
throws SpannerException {
setActive(null);
List<com.google.spanner.v1.Mutation> mutationsProto = new ArrayList<>();
Expand All @@ -175,7 +183,12 @@ public CommitResponse writeAtLeastOnceWithOptions(
try (Scope s = tracer.withSpan(span)) {
com.google.spanner.v1.CommitResponse response =
spanner.getRpc().commit(request, this.options);
<<<<<<< HEAD
return new CommitResponse(response);
=======
Timestamp t = Timestamp.fromProto(response.getCommitTimestamp());
return new CommitResponse(t);
>>>>>>> master
} catch (IllegalArgumentException e) {
TraceUtil.setWithFailure(span, e);
throw newSpannerException(ErrorCode.INTERNAL, "Could not parse commit response", e);
Expand Down Expand Up @@ -246,24 +259,44 @@ public ReadOnlyTransaction readOnlyTransaction(TimestampBound bound) {

@Override
public TransactionRunner readWriteTransaction(TransactionOption... options) {
<<<<<<< HEAD
return setActive(new TransactionRunnerImpl(this, Options.fromTransactionOptions(options)));
=======
return setActive(
new TransactionRunnerImpl(
this, spanner.getRpc(), spanner.getDefaultPrefetchChunks(), options));
>>>>>>> master
}

@Override
public AsyncRunner runAsync(TransactionOption... options) {
return new AsyncRunnerImpl(
<<<<<<< HEAD
setActive(new TransactionRunnerImpl(this, Options.fromTransactionOptions(options))));
=======
setActive(
new TransactionRunnerImpl(
this, spanner.getRpc(), spanner.getDefaultPrefetchChunks(), options)));
>>>>>>> master
}

@Override
public TransactionManager transactionManager(TransactionOption... options) {
<<<<<<< HEAD
return new TransactionManagerImpl(this, currentSpan, Options.fromTransactionOptions(options));
=======
return new TransactionManagerImpl(this, currentSpan, options);
>>>>>>> master
}

@Override
public AsyncTransactionManagerImpl transactionManagerAsync(TransactionOption... options) {
<<<<<<< HEAD
return new AsyncTransactionManagerImpl(
this, currentSpan, Options.fromTransactionOptions(options));
=======
return new AsyncTransactionManagerImpl(this, currentSpan, options);
>>>>>>> master
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1394,17 +1394,6 @@ public CommitResponse writeAtLeastOnceWithOptions(
}
}

@Override
public CommitResponse writeAtLeastOnceWithOptions(
Iterable<Mutation> mutations, TransactionOption... options) throws SpannerException {
try {
markUsed();
return delegate.writeAtLeastOnceWithOptions(mutations, options);
} catch (SpannerException e) {
throw lastException = e;
}
}

@Override
public long executePartitionedUpdate(Statement stmt, UpdateOption... options)
throws SpannerException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SessionPoolAsyncTransactionManager
private boolean restartedAfterSessionNotFound;

SessionPoolAsyncTransactionManager(
SessionPool pool, PooledSessionFuture session, final TransactionOption... options) {
SessionPool pool, PooledSessionFuture session, TransactionOption... options) {
this.pool = Preconditions.checkNotNull(pool);
this.options = options;
createTransaction(session);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ final class TransactionManagerImpl implements TransactionManager, SessionTransac
private TransactionRunnerImpl.TransactionContextImpl txn;
private TransactionState txnState;

TransactionManagerImpl(SessionImpl session, Span span, Options options) {
TransactionManagerImpl(SessionImpl session, Span span, TransactionOption... options) {
this.session = session;
this.span = span;
this.options = options;
this.options = Options.fromTransactionOptions(options);
}

Span getSpan() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.google.cloud.spanner.Options.TransactionOption;
import com.google.cloud.spanner.Options.UpdateOption;
import com.google.cloud.spanner.SessionImpl.SessionTransaction;
import com.google.cloud.spanner.spi.v1.SpannerRpc;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
Expand Down Expand Up @@ -75,7 +76,8 @@ class TransactionRunnerImpl implements SessionTransaction, TransactionRunner {
static class TransactionContextImpl extends AbstractReadContext implements TransactionContext {
static class Builder extends AbstractReadContext.Builder<Builder, TransactionContextImpl> {
private ByteString transactionId;
private Options options = Options.fromTransactionOptions();
private Options options;
private boolean trackTransactionStarter;

private Builder() {}

Expand All @@ -85,7 +87,12 @@ Builder setTransactionId(ByteString transactionId) {
}

Builder setOptions(Options options) {
this.options = options;
this.options = Preconditions.checkNotNull(options);
return self();
}

Builder setTrackTransactionStarter(boolean trackTransactionStarter) {
this.trackTransactionStarter = trackTransactionStarter;
return self();
}

Expand Down Expand Up @@ -176,13 +183,13 @@ public void removeListener(Runnable listener) {

volatile ByteString transactionId;

private final Options options;
private CommitResponse commitResponse;

private TransactionContextImpl(Builder builder) {
super(builder);
this.transactionId = builder.transactionId;
this.options = Preconditions.checkNotNull(builder.options);
this.trackTransactionStarter = builder.trackTransactionStarter;
this.options = builder.options;
this.finishedAsyncOperations.set(null);
}

Expand Down Expand Up @@ -808,7 +815,6 @@ public ListenableAsyncResultSet executeQueryAsync(
private final SessionImpl session;
private final Options options;
private Span span;
private final Options options;
private TransactionContextImpl txn;
private volatile boolean isValid = true;

Expand All @@ -818,10 +824,14 @@ public TransactionRunner allowNestedTransaction() {
return this;
}

TransactionRunnerImpl(SessionImpl session, Options options) {
TransactionRunnerImpl(
SessionImpl session,
SpannerRpc rpc,
int defaultPrefetchChunks,
TransactionOption... options) {
this.session = session;
this.options = options;
this.txn = session.newTransaction(options);
this.options = Options.fromTransactionOptions(options);
this.txn = session.newTransaction(this.options);
}

@Override
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.