Skip to content

Commit 44860e7

Browse files
committed
Propagate more session.getChannel() as well as comments for PR googleapis#3900
1 parent abe982f commit 44860e7

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

google-cloud-spanner/src/main/java/com/google/cloud/spanner/AbstractReadContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ void initTransaction() {
458458

459459
private void initTransactionInternal(BeginTransactionRequest request) {
460460
XGoogSpannerRequestId reqId =
461-
session.getRequestIdCreator().nextRequestId(1 /*TODO: retrieve channelId*/, 1);
461+
session.getRequestIdCreator().nextRequestId(session.getChannel(), 1);
462462
try {
463463
Transaction transaction =
464464
rpc.beginTransaction(

google-cloud-spanner/src/main/java/com/google/cloud/spanner/BatchClientImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ private List<Partition> partitionReadUsingIndex(
251251
builder.setPartitionOptions(pbuilder.build());
252252

253253
XGoogSpannerRequestId reqId =
254-
session.getRequestIdCreator().nextRequestId(1 /*TODO: retrieve channelId*/, 1);
254+
session.getRequestIdCreator().nextRequestId(session.getChannel(), 1);
255255
final PartitionReadRequest request = builder.build();
256256
try {
257257
PartitionResponse response = rpc.partitionRead(request, reqId.withOptions(options));
@@ -317,7 +317,7 @@ private List<Partition> partitionQuery(
317317
builder.setPartitionOptions(pbuilder.build());
318318

319319
XGoogSpannerRequestId reqId =
320-
session.getRequestIdCreator().nextRequestId(1 /*TODO: retrieve channelId*/, 1);
320+
session.getRequestIdCreator().nextRequestId(session.getChannel(), 1);
321321
final PartitionQueryRequest request = builder.build();
322322
try {
323323
PartitionResponse response = rpc.partitionQuery(request, reqId.withOptions(options));

google-cloud-spanner/src/main/java/com/google/cloud/spanner/Options.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ public boolean equals(Object o) {
11011101
if (this.reqId == null || other.reqId == null) {
11021102
return this.reqId == null && other.reqId == null;
11031103
}
1104-
return this.reqId.equals(other.reqId);
1104+
return Objects.equals(this.reqId, other.reqId);
11051105
}
11061106
}
11071107
}

google-cloud-spanner/src/main/java/com/google/cloud/spanner/PartitionedDmlTransaction.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ long executeStreamingPartitionedUpdate(
8282
Options options = Options.fromUpdateOptions(updateOptions);
8383
XGoogSpannerRequestId reqId = options.reqId();
8484
if (reqId == null) {
85-
reqId = session.getRequestIdCreator().nextRequestId(1 /*TODO: infer channelId*/, 0);
85+
reqId = session.getRequestIdCreator().nextRequestId(session.getChannel(), 0);
8686
}
8787

8888
try {
@@ -126,7 +126,7 @@ long executeStreamingPartitionedUpdate(
126126
updateCount = 0L;
127127
request = newTransactionRequestFrom(statement, options);
128128
// Create a new xGoogSpannerRequestId.
129-
reqId = session.getRequestIdCreator().nextRequestId(1 /*TODO: infer channelId*/, 0);
129+
reqId = session.getRequestIdCreator().nextRequestId(session.getChannel(), 0);
130130
} catch (SpannerException e) {
131131
e.setRequestId(reqId);
132132
throw e;
@@ -223,7 +223,7 @@ private ByteString initTransaction(final Options options) {
223223
.build();
224224
XGoogSpannerRequestId reqId = options.reqId();
225225
if (reqId == null) {
226-
reqId = session.getRequestIdCreator().nextRequestId(1 /*TODO: infer channelId*/, 1);
226+
reqId = session.getRequestIdCreator().nextRequestId(session.getChannel(), 1);
227227
}
228228
Transaction tx = rpc.beginTransaction(request, reqId.withOptions(session.getOptions()), true);
229229
if (tx.getId().isEmpty()) {

google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,15 +465,15 @@ public AsyncTransactionManagerImpl transactionManagerAsync(TransactionOption...
465465

466466
@Override
467467
public ApiFuture<Empty> asyncClose() {
468-
XGoogSpannerRequestId reqId = this.getRequestIdCreator().nextRequestId(this.getChannel(), 0);
468+
XGoogSpannerRequestId reqId = this.getRequestIdCreator().nextRequestId(this.getChannel(), 1);
469469
return spanner.getRpc().asyncDeleteSession(getName(), reqId.withOptions(getOptions()));
470470
}
471471

472472
@Override
473473
public void close() {
474474
ISpan span = tracer.spanBuilder(SpannerImpl.DELETE_SESSION);
475475
try (IScope s = tracer.withSpan(span)) {
476-
XGoogSpannerRequestId reqId = this.getRequestIdCreator().nextRequestId(this.getChannel(), 0);
476+
XGoogSpannerRequestId reqId = this.getRequestIdCreator().nextRequestId(this.getChannel(), 1);
477477
spanner.getRpc().deleteSession(getName(), reqId.withOptions(getOptions()));
478478
} catch (RuntimeException e) {
479479
span.setStatus(e);

google-cloud-spanner/src/main/java/com/google/cloud/spanner/TransactionRunnerImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ private final class CommitRunnable implements Runnable {
450450
@Override
451451
public void run() {
452452
XGoogSpannerRequestId reqId =
453-
session.getRequestIdCreator().nextRequestId(1 /*TODO: channelId */, 1);
453+
session.getRequestIdCreator().nextRequestId(session.getChannel(), 1);
454454
try {
455455
prev.get();
456456
if (transactionId == null && transactionIdFuture == null) {
@@ -930,7 +930,7 @@ private ResultSet internalExecuteUpdate(
930930
getExecuteSqlRequestBuilder(
931931
statement, queryMode, options, /* withTransactionSelector= */ true);
932932
XGoogSpannerRequestId reqId =
933-
session.getRequestIdCreator().nextRequestId(1 /*TODO: channelId */, 1);
933+
session.getRequestIdCreator().nextRequestId(session.getChannel(), 1);
934934
try {
935935
com.google.spanner.v1.ResultSet resultSet =
936936
rpc.executeQuery(
@@ -1066,7 +1066,7 @@ public long[] batchUpdate(Iterable<Statement> statements, UpdateOption... update
10661066
final ExecuteBatchDmlRequest.Builder builder =
10671067
getExecuteBatchDmlRequestBuilder(statements, options);
10681068
XGoogSpannerRequestId reqId =
1069-
session.getRequestIdCreator().nextRequestId(1 /*TODO: channelId */, 1);
1069+
session.getRequestIdCreator().nextRequestId(session.getChannel(), 1);
10701070
try {
10711071
com.google.spanner.v1.ExecuteBatchDmlResponse response =
10721072
rpc.executeBatchDml(builder.build(), reqId.withOptions(getTransactionChannelHint()));
@@ -1128,7 +1128,7 @@ public ApiFuture<long[]> batchUpdateAsync(
11281128
getExecuteBatchDmlRequestBuilder(statements, options);
11291129
ApiFuture<com.google.spanner.v1.ExecuteBatchDmlResponse> response;
11301130
XGoogSpannerRequestId reqId =
1131-
session.getRequestIdCreator().nextRequestId(1 /*TODO: channelId */, 1);
1131+
session.getRequestIdCreator().nextRequestId(session.getChannel(), 1);
11321132
try {
11331133
// Register the update as an async operation that must finish before the transaction may
11341134
// commit.

0 commit comments

Comments
 (0)