Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: move session lastUseTime parameter from PooledSession to SessionImpl class. Fix updation of the parameter for chained RPCs within one transaction. #2704

Merged
merged 32 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
edc5bbf
fix: prevent illegal negative timeout values into thread sleep() meth…
arpan14 Feb 6, 2023
49a85df
Merge pull request #1 from arpan14/retryerror
arpan14 Feb 8, 2023
4cd497b
Fixing lint issues.
arpan14 Feb 8, 2023
4a6aa8e
Merge branch 'googleapis:main' into main
arpan14 Mar 13, 2023
b2aa09d
Merge branch 'googleapis:main' into main
arpan14 Mar 15, 2023
8d6d71e
Merge branch 'googleapis:main' into main
arpan14 May 9, 2023
77e6e7d
Merge branch 'googleapis:main' into main
arpan14 Jul 17, 2023
e8b7fad
Merge branch 'googleapis:main' into main
arpan14 Jul 25, 2023
8aa84e1
Merge branch 'googleapis:main' into main
arpan14 Oct 10, 2023
922f324
refactor: move session lastUseTime parameter from PooledSession to Se…
arpan14 Oct 17, 2023
b544080
chore: add clock instances in callees of SessionImpl.
arpan14 Oct 19, 2023
9862265
chore: partially fix failing unit tests in SessionPoolTest and Sessio…
arpan14 Oct 26, 2023
5e5f769
chore: fix failing tests in SessionPoolStressTest.
arpan14 Oct 27, 2023
a385ceb
chore: update lastUseTime for methods in SessionPoolTransactionContex…
arpan14 Oct 27, 2023
fd3bb41
chore: lint errors.
arpan14 Oct 27, 2023
4864053
chore: fix tests in DatabaseClientImplTest by passing the mocked cloc…
arpan14 Oct 27, 2023
f5b82fa
fix: update session lastUseTime field for AbstractReadContext class. …
arpan14 Oct 28, 2023
73f0192
fix: failing tests in TransactionRunnerImplTest.
arpan14 Oct 29, 2023
ff32178
fix: failing test in SessionPoolMaintainerTest.
arpan14 Oct 29, 2023
1316579
refactor: move FakeClock to a new class.
arpan14 Oct 29, 2023
80dd971
refactor: move Clock to a new class.
arpan14 Oct 30, 2023
1acd645
chore: resolving PR comments.
arpan14 Oct 31, 2023
6af8187
chore: address review comments.
arpan14 Oct 31, 2023
999a39b
chore: updating lastUseTime state in TransactionRunnerImpl. Removing …
arpan14 Oct 31, 2023
ec80d6a
chore: remove redundant update statements from SessionPool class. Add…
arpan14 Nov 1, 2023
6cdef81
chore: add more tests for TransactionRunner.
arpan14 Nov 1, 2023
593a10b
chore: remove dead code from constructor of SessionPoolTransactionCon…
arpan14 Nov 1, 2023
ced1e06
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Nov 1, 2023
0485aee
Update google-cloud-spanner/src/main/java/com/google/cloud/spanner/Tr…
arpan14 Nov 2, 2023
c4163d8
Update google-cloud-spanner/src/main/java/com/google/cloud/spanner/Tr…
arpan14 Nov 2, 2023
b75b19f
Update google-cloud-spanner/src/main/java/com/google/cloud/spanner/Tr…
arpan14 Nov 2, 2023
86327e2
chore: fixing precondition errors due to null clock.
arpan14 Nov 2, 2023
File filter

Filter by extension

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
refactor: move FakeClock to a new class.
  • Loading branch information
arpan14 committed Oct 29, 2023
commit 13165792c8c80bc268a09ea2c0229657897bdacd
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.google.api.core.ApiFutures;
import com.google.cloud.grpc.GrpcTransportOptions.ExecutorFactory;
import com.google.cloud.spanner.Options.TransactionOption;
import com.google.cloud.spanner.SessionPool.Clock;
import com.google.cloud.spanner.spi.v1.SpannerRpc.Option;
import com.google.protobuf.Empty;
import java.util.HashMap;
Expand All @@ -37,7 +36,6 @@
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import org.threeten.bp.Instant;

abstract class BaseSessionPoolTest {
ScheduledExecutorService mockExecutor;
Expand Down Expand Up @@ -129,13 +127,4 @@ void runMaintenanceLoop(FakeClock clock, SessionPool pool, long numCycles) {
clock.currentTimeMillis += pool.poolMaintainer.loopFrequency;
}
}

static class FakeClock extends Clock {
volatile long currentTimeMillis;

@Override
public Instant instant() {
return Instant.ofEpochMilli(currentTimeMillis);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import com.google.cloud.spanner.Options.RpcPriority;
import com.google.cloud.spanner.Options.TransactionOption;
import com.google.cloud.spanner.ReadContext.QueryAnalyzeMode;
import com.google.cloud.spanner.SessionPool.Clock;
import com.google.cloud.spanner.SessionPool.PooledSessionFuture;
import com.google.cloud.spanner.SessionPoolOptions.ActionOnInactiveTransaction;
import com.google.cloud.spanner.SessionPoolOptions.InactiveTransactionRemovalOptions;
Expand Down Expand Up @@ -3693,13 +3692,4 @@ static void assertAsString(ImmutableList<String> expected, ResultSet resultSet,
expected.stream().collect(Collectors.joining(",", "[", "]")),
resultSet.getValue(col).getAsString());
}

static class FakeClock extends Clock {
volatile long currentTimeMillis;

@Override
public Instant instant() {
return Instant.ofEpochMilli(currentTimeMillis);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.cloud.spanner;

import com.google.cloud.spanner.SessionPool.Clock;
import org.threeten.bp.Instant;

/**
* Class which allows to mock {@link Clock} in unit tests and return custom time values within the
* tests.
*/
class FakeClock extends Clock {
volatile long currentTimeMillis;

@Override
public Instant instant() {
return Instant.ofEpochMilli(currentTimeMillis);
}
}