Skip to content

Commit 75fc580

Browse files
committed
Merge branch 'transactional-connection-state' into enable-transactional-connection-state
2 parents b74abca + 5f51a2a commit 75fc580

File tree

32 files changed

+13667
-9045
lines changed

32 files changed

+13667
-9045
lines changed

.github/.OwlBot-hermetic.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
15-
docker:
16-
image: "gcr.io/cloud-devrel-public-resources/owlbot-java:latest"
17-
1814
deep-remove-regex:
1915
- "/grpc-google-.*/src"
2016
- "/proto-google-.*/src"

.github/workflows/hermetic_library_generation.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ on:
1919

2020
env:
2121
HEAD_REF: ${{ github.head_ref }}
22+
REPO_FULL_NAME: ${{ github.event.pull_request.head.repo.full_name }}
23+
GITHUB_REPOSITORY: ${{ github.repository }}
24+
2225
jobs:
2326
library_generation:
24-
# skip pull requests coming from a forked repository
25-
if: github.event.pull_request.head.repo.full_name == github.repository
2627
runs-on: ubuntu-latest
2728
steps:
2829
- uses: actions/checkout@v4
@@ -33,6 +34,10 @@ jobs:
3334
shell: bash
3435
run: |
3536
set -ex
37+
if [[ "${GITHUB_REPOSITORY}" != "${REPO_FULL_NAME}" ]]; then
38+
echo "This PR comes from a fork. Generation will be skipped"
39+
exit 0
40+
fi
3641
[ -z "$(git config user.email)" ] && git config --global user.email "[email protected]"
3742
[ -z "$(git config user.name)" ] && git config --global user.name "cloud-java-bot"
3843
bash .github/scripts/hermetic_library_generation.sh \

.github/workflows/unmanaged_dependency_check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ jobs:
1717
# repository
1818
.kokoro/build.sh
1919
- name: Unmanaged dependency check
20-
uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v3.34.0
20+
uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v3.35.0
2121
with:
2222
bom-path: google-cloud-spanner-bom/pom.xml

.kokoro/presubmit/graalvm-native-17.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Configure the docker image for kokoro-trampoline.
44
env_vars: {
55
key: "TRAMPOLINE_IMAGE"
6-
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:3.34.0"
6+
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:3.35.0"
77
}
88

99
env_vars: {

.kokoro/presubmit/graalvm-native.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Configure the docker image for kokoro-trampoline.
44
env_vars: {
55
key: "TRAMPOLINE_IMAGE"
6-
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.34.0"
6+
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.35.0"
77
}
88

99
env_vars: {

benchmarks/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
<dependency>
9393
<groupId>com.google.cloud</groupId>
9494
<artifactId>google-cloud-spanner</artifactId>
95-
<version>6.72.0</version>
95+
<version>6.74.0</version>
9696
</dependency>
9797
<dependency>
9898
<groupId>commons-cli</groupId>

google-cloud-spanner-bom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>com.google.cloud</groupId>
1010
<artifactId>sdk-platform-java-config</artifactId>
11-
<version>3.34.0</version>
11+
<version>3.35.0</version>
1212
</parent>
1313

1414
<name>Google Cloud Spanner BOM</name>

google-cloud-spanner-executor/assembly-descriptor.xml

Lines changed: 0 additions & 27 deletions
This file was deleted.

google-cloud-spanner-executor/pom.xml

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -160,30 +160,61 @@
160160

161161
</dependencies>
162162
<build>
163-
<finalName>google-spanner-cloud-executor</finalName>
164163
<plugins>
165164
<plugin>
166-
<artifactId>maven-assembly-plugin</artifactId>
167-
<version>3.7.1</version>
165+
<artifactId>maven-resources-plugin</artifactId>
166+
<executions>
167+
<execution>
168+
<id>copy-resources</id>
169+
<phase>validate</phase>
170+
<goals>
171+
<goal>copy-resources</goal>
172+
</goals>
173+
<configuration>
174+
<outputDirectory>${project.build.directory}/spanner-executor</outputDirectory>
175+
<resources>
176+
<resource>
177+
<directory>resources</directory>
178+
<filtering>true</filtering>
179+
</resource>
180+
</resources>
181+
</configuration>
182+
</execution>
183+
</executions>
184+
</plugin>
185+
<plugin>
186+
<groupId>org.apache.maven.plugins</groupId>
187+
<artifactId>maven-dependency-plugin</artifactId>
188+
<executions>
189+
<execution>
190+
<id>copy-dependencies</id>
191+
<phase>prepare-package</phase>
192+
<goals>
193+
<goal>copy-dependencies</goal>
194+
</goals>
195+
<configuration>
196+
<outputDirectory>${project.build.directory}/spanner-executor/lib</outputDirectory>
197+
<overWriteReleases>false</overWriteReleases>
198+
<overWriteSnapshots>false</overWriteSnapshots>
199+
<overWriteIfNewer>true</overWriteIfNewer>
200+
</configuration>
201+
</execution>
202+
</executions>
203+
</plugin>
204+
<plugin>
205+
<groupId>org.apache.maven.plugins</groupId>
206+
<artifactId>maven-jar-plugin</artifactId>
168207
<configuration>
169-
<descriptors>
170-
<descriptor>assembly-descriptor.xml</descriptor>
171-
</descriptors>
208+
<finalName>spanner-executor/google-spanner-cloud-executor</finalName>
172209
<archive>
210+
<index>false</index>
173211
<manifest>
174212
<mainClass>com.google.cloud.executor.spanner.WorkerProxy</mainClass>
213+
<addClasspath>true</addClasspath>
214+
<classpathPrefix>lib/</classpathPrefix>
175215
</manifest>
176216
</archive>
177217
</configuration>
178-
<executions>
179-
<execution>
180-
<id>make-assembly</id>
181-
<phase>package</phase>
182-
<goals>
183-
<goal>single</goal>
184-
</goals>
185-
</execution>
186-
</executions>
187218
</plugin>
188219
<plugin>
189220
<groupId>org.apache.maven.plugins</groupId>

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ public class SessionPoolOptions {
7373

7474
private final boolean useMultiplexedSession;
7575

76+
private final boolean useMultiplexedSessionForRW;
77+
7678
// TODO: Change to use java.time.Duration.
7779
private final Duration multiplexedSessionMaintenanceDuration;
7880

@@ -108,6 +110,13 @@ private SessionPoolOptions(Builder builder) {
108110
(useMultiplexedSessionFromEnvVariable != null)
109111
? useMultiplexedSessionFromEnvVariable
110112
: builder.useMultiplexedSession;
113+
// useMultiplexedSessionForRW priority => Environment var > private setter > client default
114+
Boolean useMultiplexedSessionForRWFromEnvVariable =
115+
getUseMultiplexedSessionForRWFromEnvVariable();
116+
this.useMultiplexedSessionForRW =
117+
(useMultiplexedSessionForRWFromEnvVariable != null)
118+
? useMultiplexedSessionForRWFromEnvVariable
119+
: builder.useMultiplexedSessionForRW;
111120
this.multiplexedSessionMaintenanceDuration = builder.multiplexedSessionMaintenanceDuration;
112121
}
113122

@@ -144,6 +153,7 @@ public boolean equals(Object o) {
144153
this.inactiveTransactionRemovalOptions, other.inactiveTransactionRemovalOptions)
145154
&& Objects.equals(this.poolMaintainerClock, other.poolMaintainerClock)
146155
&& Objects.equals(this.useMultiplexedSession, other.useMultiplexedSession)
156+
&& Objects.equals(this.useMultiplexedSessionForRW, other.useMultiplexedSessionForRW)
147157
&& Objects.equals(
148158
this.multiplexedSessionMaintenanceDuration,
149159
other.multiplexedSessionMaintenanceDuration);
@@ -174,6 +184,7 @@ public int hashCode() {
174184
this.inactiveTransactionRemovalOptions,
175185
this.poolMaintainerClock,
176186
this.useMultiplexedSession,
187+
this.useMultiplexedSessionForRW,
177188
this.multiplexedSessionMaintenanceDuration);
178189
}
179190

@@ -307,6 +318,14 @@ public boolean getUseMultiplexedSession() {
307318
return useMultiplexedSession;
308319
}
309320

321+
@VisibleForTesting
322+
@InternalApi
323+
public boolean getUseMultiplexedSessionForRW() {
324+
// Multiplexed sessions for R/W are enabled only if both global multiplexed sessions and
325+
// read-write multiplexed session flags are set to true.
326+
return getUseMultiplexedSession() && useMultiplexedSessionForRW;
327+
}
328+
310329
private static Boolean getUseMultiplexedSessionFromEnvVariable() {
311330
String useMultiplexedSessionFromEnvVariable =
312331
System.getenv("GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS");
@@ -323,6 +342,12 @@ private static Boolean getUseMultiplexedSessionFromEnvVariable() {
323342
return null;
324343
}
325344

345+
private static Boolean getUseMultiplexedSessionForRWFromEnvVariable() {
346+
// Checks the value of env, GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS_FOR_RW
347+
// This returns null until RW is supported.
348+
return null;
349+
}
350+
326351
Duration getMultiplexedSessionMaintenanceDuration() {
327352
return multiplexedSessionMaintenanceDuration;
328353
}
@@ -529,6 +554,12 @@ public static class Builder {
529554
// Set useMultiplexedSession to true to make multiplexed session the default.
530555
private boolean useMultiplexedSession = false;
531556

557+
// This field controls the default behavior of session management for RW operations in Java
558+
// client.
559+
// Set useMultiplexedSessionForRW to true to make multiplexed session for RW operations the
560+
// default.
561+
private boolean useMultiplexedSessionForRW = false;
562+
532563
private Duration multiplexedSessionMaintenanceDuration = Duration.ofDays(7);
533564
private Clock poolMaintainerClock = Clock.INSTANCE;
534565

@@ -570,6 +601,7 @@ private Builder(SessionPoolOptions options) {
570601
this.randomizePositionQPSThreshold = options.randomizePositionQPSThreshold;
571602
this.inactiveTransactionRemovalOptions = options.inactiveTransactionRemovalOptions;
572603
this.useMultiplexedSession = options.useMultiplexedSession;
604+
this.useMultiplexedSessionForRW = options.useMultiplexedSessionForRW;
573605
this.multiplexedSessionMaintenanceDuration = options.multiplexedSessionMaintenanceDuration;
574606
this.poolMaintainerClock = options.poolMaintainerClock;
575607
}
@@ -757,6 +789,15 @@ Builder setUseMultiplexedSession(boolean useMultiplexedSession) {
757789
return this;
758790
}
759791

792+
/**
793+
* Sets whether the client should use multiplexed session for R/W operations or not. This method
794+
* is intentionally package-private and intended for internal use.
795+
*/
796+
Builder setUseMultiplexedSessionForRW(boolean useMultiplexedSessionForRW) {
797+
this.useMultiplexedSessionForRW = useMultiplexedSessionForRW;
798+
return this;
799+
}
800+
760801
@VisibleForTesting
761802
Builder setMultiplexedSessionMaintenanceDuration(
762803
Duration multiplexedSessionMaintenanceDuration) {

0 commit comments

Comments
 (0)