Skip to content

Commit 3d381cd

Browse files
authored
Merge branch 'main' into renovate/com.google.cloud-google-cloud-shared-config-1.x
2 parents d83400c + 1c6d909 commit 3d381cd

File tree

25 files changed

+587
-91
lines changed

25 files changed

+587
-91
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Changelog
22

3+
## [6.52.1](https://github.com/googleapis/java-spanner/compare/v6.52.0...v6.52.1) (2023-10-20)
4+
5+
6+
### Dependencies
7+
8+
* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.18.0 ([#2691](https://github.com/googleapis/java-spanner/issues/2691)) ([b425021](https://github.com/googleapis/java-spanner/commit/b4250218a500eb1540920ed0023454d06c54d621))
9+
10+
## [6.52.0](https://github.com/googleapis/java-spanner/compare/v6.51.0...v6.52.0) (2023-10-19)
11+
12+
13+
### Features
14+
15+
* Add support for Managed Autoscaler ([#2624](https://github.com/googleapis/java-spanner/issues/2624)) ([e5e6923](https://github.com/googleapis/java-spanner/commit/e5e6923a351670ab237c411bb4a549533dac1b6b))
16+
317
## [6.51.0](https://github.com/googleapis/java-spanner/compare/v6.50.1...v6.51.0) (2023-10-14)
418

519

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ implementation 'com.google.cloud:google-cloud-spanner'
5757
If you are using Gradle without BOM, add this to your dependencies:
5858

5959
```Groovy
60-
implementation 'com.google.cloud:google-cloud-spanner:6.51.0'
60+
implementation 'com.google.cloud:google-cloud-spanner:6.52.0'
6161
```
6262

6363
If you are using SBT, add this to your dependencies:
6464

6565
```Scala
66-
libraryDependencies += "com.google.cloud" % "google-cloud-spanner" % "6.51.0"
66+
libraryDependencies += "com.google.cloud" % "google-cloud-spanner" % "6.52.0"
6767
```
6868
<!-- {x-version-update-end} -->
6969

@@ -432,7 +432,7 @@ Java is a registered trademark of Oracle and/or its affiliates.
432432
[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-spanner/java11.html
433433
[stability-image]: https://img.shields.io/badge/stability-stable-green
434434
[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-spanner.svg
435-
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-spanner/6.51.0
435+
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-spanner/6.52.0
436436
[authentication]: https://github.com/googleapis/google-cloud-java#authentication
437437
[auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes
438438
[predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles

google-cloud-spanner-bom/pom.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.google.cloud</groupId>
55
<artifactId>google-cloud-spanner-bom</artifactId>
6-
<version>6.51.1-SNAPSHOT</version><!-- {x-version-update:google-cloud-spanner:current} -->
6+
<version>6.52.2-SNAPSHOT</version><!-- {x-version-update:google-cloud-spanner:current} -->
77
<packaging>pom</packaging>
88
<parent>
99
<groupId>com.google.cloud</groupId>
@@ -53,48 +53,48 @@
5353
<dependency>
5454
<groupId>com.google.cloud</groupId>
5555
<artifactId>google-cloud-spanner</artifactId>
56-
<version>6.51.1-SNAPSHOT</version><!-- {x-version-update:google-cloud-spanner:current} -->
56+
<version>6.52.2-SNAPSHOT</version><!-- {x-version-update:google-cloud-spanner:current} -->
5757
</dependency>
5858
<dependency>
5959
<groupId>com.google.cloud</groupId>
6060
<artifactId>google-cloud-spanner-executor</artifactId>
61-
<version>6.51.1-SNAPSHOT</version><!-- {x-version-update:google-cloud-spanner-executor:current} -->
61+
<version>6.52.2-SNAPSHOT</version><!-- {x-version-update:google-cloud-spanner-executor:current} -->
6262
</dependency>
6363
<dependency>
6464
<groupId>com.google.cloud</groupId>
6565
<artifactId>google-cloud-spanner</artifactId>
6666
<type>test-jar</type>
67-
<version>6.51.1-SNAPSHOT</version><!-- {x-version-update:google-cloud-spanner:current} -->
67+
<version>6.52.2-SNAPSHOT</version><!-- {x-version-update:google-cloud-spanner:current} -->
6868
</dependency>
6969
<dependency>
7070
<groupId>com.google.api.grpc</groupId>
7171
<artifactId>grpc-google-cloud-spanner-v1</artifactId>
72-
<version>6.51.1-SNAPSHOT</version><!-- {x-version-update:grpc-google-cloud-spanner-v1:current} -->
72+
<version>6.52.2-SNAPSHOT</version><!-- {x-version-update:grpc-google-cloud-spanner-v1:current} -->
7373
</dependency>
7474
<dependency>
7575
<groupId>com.google.api.grpc</groupId>
7676
<artifactId>grpc-google-cloud-spanner-admin-instance-v1</artifactId>
77-
<version>6.51.1-SNAPSHOT</version><!-- {x-version-update:grpc-google-cloud-spanner-admin-instance-v1:current} -->
77+
<version>6.52.2-SNAPSHOT</version><!-- {x-version-update:grpc-google-cloud-spanner-admin-instance-v1:current} -->
7878
</dependency>
7979
<dependency>
8080
<groupId>com.google.api.grpc</groupId>
8181
<artifactId>grpc-google-cloud-spanner-admin-database-v1</artifactId>
82-
<version>6.51.1-SNAPSHOT</version><!-- {x-version-update:grpc-google-cloud-spanner-admin-database-v1:current} -->
82+
<version>6.52.2-SNAPSHOT</version><!-- {x-version-update:grpc-google-cloud-spanner-admin-database-v1:current} -->
8383
</dependency>
8484
<dependency>
8585
<groupId>com.google.api.grpc</groupId>
8686
<artifactId>proto-google-cloud-spanner-admin-instance-v1</artifactId>
87-
<version>6.51.1-SNAPSHOT</version><!-- {x-version-update:proto-google-cloud-spanner-admin-instance-v1:current} -->
87+
<version>6.52.2-SNAPSHOT</version><!-- {x-version-update:proto-google-cloud-spanner-admin-instance-v1:current} -->
8888
</dependency>
8989
<dependency>
9090
<groupId>com.google.api.grpc</groupId>
9191
<artifactId>proto-google-cloud-spanner-v1</artifactId>
92-
<version>6.51.1-SNAPSHOT</version><!-- {x-version-update:proto-google-cloud-spanner-v1:current} -->
92+
<version>6.52.2-SNAPSHOT</version><!-- {x-version-update:proto-google-cloud-spanner-v1:current} -->
9393
</dependency>
9494
<dependency>
9595
<groupId>com.google.api.grpc</groupId>
9696
<artifactId>proto-google-cloud-spanner-admin-database-v1</artifactId>
97-
<version>6.51.1-SNAPSHOT</version><!-- {x-version-update:proto-google-cloud-spanner-admin-database-v1:current} -->
97+
<version>6.52.2-SNAPSHOT</version><!-- {x-version-update:proto-google-cloud-spanner-admin-database-v1:current} -->
9898
</dependency>
9999
</dependencies>
100100
</dependencyManagement>

google-cloud-spanner-executor/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>com.google.cloud</groupId>
77
<artifactId>google-cloud-spanner-executor</artifactId>
8-
<version>6.51.1-SNAPSHOT</version><!-- {x-version-update:google-cloud-spanner-executor:current} -->
8+
<version>6.52.2-SNAPSHOT</version><!-- {x-version-update:google-cloud-spanner-executor:current} -->
99
<packaging>jar</packaging>
1010
<name>Google Cloud Spanner Executor</name>
1111

1212
<parent>
1313
<groupId>com.google.cloud</groupId>
1414
<artifactId>google-cloud-spanner-parent</artifactId>
15-
<version>6.51.1-SNAPSHOT</version><!-- {x-version-update:google-cloud-spanner:current} -->
15+
<version>6.52.2-SNAPSHOT</version><!-- {x-version-update:google-cloud-spanner:current} -->
1616
</parent>
1717

1818
<properties>

google-cloud-spanner/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.google.cloud</groupId>
55
<artifactId>google-cloud-spanner</artifactId>
6-
<version>6.51.1-SNAPSHOT</version><!-- {x-version-update:google-cloud-spanner:current} -->
6+
<version>6.52.2-SNAPSHOT</version><!-- {x-version-update:google-cloud-spanner:current} -->
77
<packaging>jar</packaging>
88
<name>Google Cloud Spanner</name>
99
<url>https://github.com/googleapis/java-spanner</url>
1010
<description>Java idiomatic client for Google Cloud Spanner.</description>
1111
<parent>
1212
<groupId>com.google.cloud</groupId>
1313
<artifactId>google-cloud-spanner-parent</artifactId>
14-
<version>6.51.1-SNAPSHOT</version><!-- {x-version-update:google-cloud-spanner:current} -->
14+
<version>6.52.2-SNAPSHOT</version><!-- {x-version-update:google-cloud-spanner:current} -->
1515
</parent>
1616
<properties>
1717
<site.installationModule>google-cloud-spanner</site.installationModule>

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.google.cloud.spanner.Options.ListOption;
2424
import com.google.longrunning.Operation;
2525
import com.google.spanner.admin.database.v1.CreateDatabaseMetadata;
26+
import com.google.spanner.admin.instance.v1.AutoscalingConfig;
2627
import com.google.spanner.admin.instance.v1.UpdateInstanceMetadata;
2728
import java.util.Map;
2829

@@ -86,6 +87,12 @@ public Builder setProcessingUnits(int processingUnits) {
8687
return this;
8788
}
8889

90+
@Override
91+
public Builder setAutoscalingConfig(AutoscalingConfig autoscalingConfig) {
92+
infoBuilder.setAutoscalingConfig(autoscalingConfig);
93+
return this;
94+
}
95+
8996
@Override
9097
public Builder setState(State state) {
9198
infoBuilder.setState(state);
@@ -220,6 +227,7 @@ static Instance fromProto(
220227
.setNodeCount(proto.getNodeCount())
221228
.setCreateTime(Timestamp.fromProto(proto.getCreateTime()))
222229
.setUpdateTime(Timestamp.fromProto(proto.getUpdateTime()))
230+
.setAutoscalingConfig(proto.getAutoscalingConfig())
223231
.setProcessingUnits(proto.getProcessingUnits());
224232
State state;
225233
switch (proto.getState()) {

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,6 @@ public Operation fromProto(Operation proto) {
193193
@Override
194194
public OperationFuture<Instance, CreateInstanceMetadata> createInstance(InstanceInfo instance)
195195
throws SpannerException {
196-
Preconditions.checkArgument(
197-
instance.getNodeCount() == 0 || instance.getProcessingUnits() == 0,
198-
"Only one of nodeCount and processingUnits can be set when creating a new instance");
199196
String projectName = PROJECT_NAME_TEMPLATE.instantiate("project", projectId);
200197
OperationFuture<com.google.spanner.admin.instance.v1.Instance, CreateInstanceMetadata>
201198
rawOperationFuture =

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

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.google.common.base.MoreObjects;
2424
import com.google.common.collect.ImmutableMap;
2525
import com.google.protobuf.FieldMask;
26+
import com.google.spanner.admin.instance.v1.AutoscalingConfig;
2627
import java.util.HashMap;
2728
import java.util.Map;
2829
import java.util.Objects;
@@ -35,13 +36,16 @@ public enum InstanceField implements FieldSelector {
3536
DISPLAY_NAME("display_name"),
3637
NODE_COUNT("node_count"),
3738
PROCESSING_UNITS("processing_units"),
39+
AUTOSCALING_CONFIG("autoscaling_config"),
3840
LABELS("labels");
3941

4042
static InstanceField[] defaultFieldsToUpdate(InstanceInfo info) {
41-
if (info.getNodeCount() > 0) {
42-
return new InstanceField[] {DISPLAY_NAME, NODE_COUNT, LABELS};
43+
if (info.getAutoscalingConfig() != null) {
44+
return new InstanceField[] {DISPLAY_NAME, AUTOSCALING_CONFIG, LABELS};
45+
} else if (info.getNodeCount() > 0) {
46+
return new InstanceField[] {DISPLAY_NAME, AUTOSCALING_CONFIG, NODE_COUNT, LABELS};
4347
} else {
44-
return new InstanceField[] {DISPLAY_NAME, PROCESSING_UNITS, LABELS};
48+
return new InstanceField[] {DISPLAY_NAME, AUTOSCALING_CONFIG, PROCESSING_UNITS, LABELS};
4549
}
4650
}
4751

@@ -87,21 +91,31 @@ Builder setCreateTime(Timestamp createTime) {
8791
}
8892

8993
/**
90-
* Sets the number of nodes for the instance. Exactly one of processing units or node count must
91-
* be set when creating a new instance.
94+
* Sets the number of nodes for the instance. Exactly one of processing units, node count or
95+
* autoscaling config must be set when creating a new instance.
9296
*/
9397
public abstract Builder setNodeCount(int nodeCount);
9498

9599
/**
96-
* Sets the number of processing units for the instance. Exactly one of processing units or node
97-
* count must be set when creating a new instance. Processing units must be between 1 and 999
98-
* (inclusive) when creating a new instance with node count = 0. Processing units from 1000 and
99-
* up must always be a multiple of 1000 (that is equal to an integer number of nodes).
100+
* Sets the number of processing units for the instance. Exactly one of processing units, node
101+
* count, or autoscaling config must be set when creating a new instance. Processing units must
102+
* be between 1 and 999 (inclusive) when creating a new instance with node count = 0. Processing
103+
* units from 1000 and up must always be a multiple of 1000 (that is equal to an integer number
104+
* of nodes).
100105
*/
101106
public Builder setProcessingUnits(int processingUnits) {
102107
throw new UnsupportedOperationException("Unimplemented");
103108
}
104109

110+
/**
111+
* Sets the autoscaling config for the instance, which will enable the autoscaling for this
112+
* instance. Exactly one of processing units, node count, or autoscaling config must be set when
113+
* creating a new instance.
114+
*/
115+
public Builder setAutoscalingConfig(AutoscalingConfig autoscalingConfig) {
116+
throw new UnsupportedOperationException("Unimplemented");
117+
}
118+
105119
public abstract Builder setState(State state);
106120

107121
public abstract Builder addLabel(String key, String value);
@@ -117,6 +131,7 @@ static class BuilderImpl extends Builder {
117131
private String displayName;
118132
private int nodeCount;
119133
private int processingUnits;
134+
private AutoscalingConfig autoscalingConfig;
120135
private State state;
121136
private Map<String, String> labels;
122137
private Timestamp updateTime;
@@ -133,6 +148,7 @@ static class BuilderImpl extends Builder {
133148
this.displayName = instance.displayName;
134149
this.nodeCount = instance.nodeCount;
135150
this.processingUnits = instance.processingUnits;
151+
this.autoscalingConfig = instance.autoscalingConfig;
136152
this.state = instance.state;
137153
this.labels = new HashMap<>(instance.labels);
138154
this.updateTime = instance.updateTime;
@@ -175,6 +191,12 @@ public BuilderImpl setProcessingUnits(int processingUnits) {
175191
return this;
176192
}
177193

194+
@Override
195+
public BuilderImpl setAutoscalingConfig(AutoscalingConfig autoscalingConfig) {
196+
this.autoscalingConfig = autoscalingConfig;
197+
return this;
198+
}
199+
178200
@Override
179201
public BuilderImpl setState(State state) {
180202
this.state = state;
@@ -204,6 +226,7 @@ public InstanceInfo build() {
204226
private final String displayName;
205227
private final int nodeCount;
206228
private final int processingUnits;
229+
private final AutoscalingConfig autoscalingConfig;
207230
private final State state;
208231
private final ImmutableMap<String, String> labels;
209232
private final Timestamp updateTime;
@@ -215,6 +238,7 @@ public InstanceInfo build() {
215238
this.displayName = builder.displayName;
216239
this.nodeCount = builder.nodeCount;
217240
this.processingUnits = builder.processingUnits;
241+
this.autoscalingConfig = builder.autoscalingConfig;
218242
this.state = builder.state;
219243
this.labels = ImmutableMap.copyOf(builder.labels);
220244
this.updateTime = builder.updateTime;
@@ -254,6 +278,11 @@ public int getProcessingUnits() {
254278
return processingUnits;
255279
}
256280

281+
/** Returns the autoscaling config of the instance. */
282+
public AutoscalingConfig getAutoscalingConfig() {
283+
return autoscalingConfig;
284+
}
285+
257286
/** Returns the current state of the instance. */
258287
public State getState() {
259288
return state;
@@ -276,6 +305,7 @@ public String toString() {
276305
.add("displayName", displayName)
277306
.add("nodeCount", nodeCount)
278307
.add("processingUnits", processingUnits)
308+
.add("autoscaling_config", autoscalingConfig)
279309
.add("state", state)
280310
.add("labels", labels)
281311
.add("createTime", createTime)
@@ -297,6 +327,7 @@ public boolean equals(Object o) {
297327
&& Objects.equals(displayName, that.displayName)
298328
&& nodeCount == that.nodeCount
299329
&& processingUnits == that.processingUnits
330+
&& Objects.equals(autoscalingConfig, that.autoscalingConfig)
300331
&& state == that.state
301332
&& Objects.equals(labels, that.labels)
302333
&& Objects.equals(updateTime, that.updateTime)
@@ -311,6 +342,7 @@ public int hashCode() {
311342
displayName,
312343
nodeCount,
313344
processingUnits,
345+
autoscalingConfig,
314346
state,
315347
labels,
316348
updateTime,
@@ -330,6 +362,9 @@ com.google.spanner.admin.instance.v1.Instance toProto() {
330362
if (getInstanceConfigId() != null) {
331363
builder.setConfig(getInstanceConfigId().getName());
332364
}
365+
if (getAutoscalingConfig() != null) {
366+
builder.setAutoscalingConfig(getAutoscalingConfig());
367+
}
333368
return builder.build();
334369
}
335370

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.google.cloud.spanner;
1818

1919
import com.google.api.core.ApiFunction;
20+
import com.google.api.core.InternalApi;
2021
import com.google.api.gax.core.ExecutorProvider;
2122
import com.google.api.gax.grpc.GrpcCallContext;
2223
import com.google.api.gax.grpc.GrpcInterceptorProvider;
@@ -686,10 +687,10 @@ public static class Builder
686687
private final ImmutableSet<String> allowedClientLibTokens =
687688
ImmutableSet.of(
688689
ServiceOptions.getGoogApiClientLibName(),
689-
JDBC_API_CLIENT_LIB_TOKEN,
690-
HIBERNATE_API_CLIENT_LIB_TOKEN,
691-
LIQUIBASE_API_CLIENT_LIB_TOKEN,
692-
PG_ADAPTER_CLIENT_LIB_TOKEN);
690+
createCustomClientLibToken(JDBC_API_CLIENT_LIB_TOKEN),
691+
createCustomClientLibToken(HIBERNATE_API_CLIENT_LIB_TOKEN),
692+
createCustomClientLibToken(LIQUIBASE_API_CLIENT_LIB_TOKEN),
693+
createCustomClientLibToken(PG_ADAPTER_CLIENT_LIB_TOKEN));
693694
private TransportChannelProvider channelProvider;
694695

695696
@SuppressWarnings("rawtypes")
@@ -725,6 +726,10 @@ public static class Builder
725726
private String emulatorHost = System.getenv("SPANNER_EMULATOR_HOST");
726727
private boolean leaderAwareRoutingEnabled = true;
727728

729+
private static String createCustomClientLibToken(String token) {
730+
return token + " " + ServiceOptions.getGoogApiClientLibName();
731+
}
732+
728733
private Builder() {
729734
// Manually set retry and polling settings that work.
730735
OperationTimedPollAlgorithm longRunningPollingAlgorithm =
@@ -795,6 +800,13 @@ protected Set<String> getAllowedClientLibTokens() {
795800
return allowedClientLibTokens;
796801
}
797802

803+
@InternalApi
804+
@Override
805+
public SpannerOptions.Builder setClientLibToken(String clientLibToken) {
806+
return super.setClientLibToken(
807+
clientLibToken + " " + ServiceOptions.getGoogApiClientLibName());
808+
}
809+
798810
/**
799811
* Sets the {@code ChannelProvider}. {@link GapicSpannerRpc} would create a default one if none
800812
* is provided.

0 commit comments

Comments
 (0)