Skip to content

Commit 8f263a2

Browse files
authored
Merge branch 'main' into cancel_race
2 parents 99c6f0c + e5e5f14 commit 8f263a2

47 files changed

Lines changed: 14575 additions & 7 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
/java-vertexai/ @googleapis/vertexai-team @googleapis/cloud-sdk-java-team
1010
/java-bigquerystorage/ @googleapis/bigquery-team @googleapis/cloud-sdk-java-team
1111
/java-bigquery/ @googleapis/bigquery-team @googleapis/cloud-sdk-java-team
12+
/grpc-gcp-java/ @googleapis/spanner-team @googleapis/cloud-sdk-java-team
1213
/java-spanner/ @googleapis/spanner-team @googleapis/cloud-sdk-java-team
1314
/java-spanner-jdbc/ @googleapis/spanner-team @googleapis/cloud-sdk-java-team
1415
/google-auth-library-java/ @googleapis/cloud-sdk-auth-team @googleapis/cloud-sdk-java-team @googleapis/aion-team

.github/workflows/ci.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ jobs:
3636
with:
3737
filters: |
3838
src:
39-
- '!(google-auth-library-java|java-bigquery|java-bigquerystorage|java-bigtable|java-datastore|java-firestore|java-logging|java-logging-logback|java-pubsub|java-spanner|java-storage)/**/*.java'
40-
- '!(google-auth-library-java|java-bigquery|java-bigquerystorage|java-bigtable|java-datastore|java-firestore|java-logging|java-logging-logback|java-pubsub|java-spanner|java-storage)/**/pom.xml'
39+
- '!(google-auth-library-java|grpc-gcp-java|java-bigquery|java-bigquerystorage|java-bigtable|java-datastore|java-firestore|java-logging|java-logging-logback|java-pubsub|java-spanner|java-storage)/**/*.java'
40+
- '!(google-auth-library-java|grpc-gcp-java|java-bigquery|java-bigquerystorage|java-bigtable|java-datastore|java-firestore|java-logging|java-logging-logback|java-pubsub|java-spanner|java-storage)/**/pom.xml'
4141
- 'pom.xml'
4242
ci:
4343
- '.github/workflows/ci.yaml'
@@ -123,6 +123,8 @@ jobs:
123123
filters: |
124124
google-auth-library-java:
125125
- 'google-auth-library-java/**'
126+
grpc-gcp-java:
127+
- 'grpc-gcp-java/**'
126128
java-bigquery:
127129
- 'java-bigquery/**'
128130
- 'google-auth-library-java/**/*.java'
@@ -160,6 +162,7 @@ jobs:
160162
- 'sdk-platform-java/gapic-generator-java-pom-parent/pom.xml'
161163
java-spanner:
162164
- 'java-spanner/**'
165+
- 'grpc-gcp-java/**'
163166
- 'google-auth-library-java/**/*.java'
164167
- 'google-auth-library-java/**/pom.xml'
165168
- 'sdk-platform-java/**/*.java'

generation/check_non_release_please_versions.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ for pomFile in $(find . -mindepth 2 -name pom.xml | sort ); do
1919
[[ "${pomFile}" =~ .*java-spanner.* ]] || \
2020
[[ "${pomFile}" =~ .*java-spanner-jdbc.* ]] || \
2121
[[ "${pomFile}" =~ .*google-auth-library-java.* ]] || \
22+
[[ "${pomFile}" =~ .*grpc-gcp.* ]] || \
2223
[[ "${pomFile}" =~ .*java-storage.* ]] || \
2324
[[ "${pomFile}" =~ .*java-storage-nio.* ]] || \
2425
[[ "${pomFile}" =~ .*java-pubsub.* ]] || \

grpc-gcp-java/.repo-metadata.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"api_shortname": "grpc-gcp",
3+
"name_pretty": "gRPC GCP Extension",
4+
"product_documentation": "https://github.com/GoogleCloudPlatform/grpc-gcp-java",
5+
"api_description": "gRPC extension library for Google Cloud Platform clients.",
6+
"client_documentation": "https://cloud.google.com/java/docs/reference/grpc-gcp/latest/overview",
7+
"release_level": "stable",
8+
"transport": "grpc",
9+
"language": "java",
10+
"repo": "googleapis/google-cloud-java",
11+
"repo_short": "google-cloud-java",
12+
"distribution_name": "com.google.cloud:grpc-gcp",
13+
"library_type": "OTHER",
14+
"codeowner_team": "@googleapis/cloud-sdk-java-team",
15+
"recommended_package": "com.google.cloud.grpc",
16+
"min_java_version": 8
17+
}

grpc-gcp-java/CHANGELOG.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Changelog
2+
3+
## 1.10.0 (2026-04-10)
4+
5+
### Fixes
6+
7+
* Use power-of-two random choices for channel selection to avoid thundering herd
8+
9+
10+
## 1.9.2 (2026-03-21)
11+
12+
### Fixes
13+
14+
* Use daemon threads for grpc-gcp background executors by default
15+
16+
### Features
17+
18+
* Support of Unbind manual affinity keys after terminal calls
19+
20+
21+
## 1.9.1 (2025-12-27)
22+
23+
### Fixes
24+
25+
* Fix race for metrics values (#228)
26+
27+
## 1.9.0 (2025-12-15)
28+
29+
### Features
30+
31+
* Set channelID in call options for downstream interceptors (#225)
32+
33+
## 1.8.0 (2025-12-12)
34+
35+
### Features
36+
37+
* End to end fallback (#221)
38+
* Migrate opencensus metrics to opentelemetry (#222)
39+
40+
## 1.7.0 (2025-09-23)
41+
42+
### Features
43+
44+
* Dynamic channel pool scaling (#194)
45+
46+
## 1.6.1 (2024-06-17)
47+
48+
### Features
49+
50+
* Log manual affinity and disabling affinity (#177)
51+
52+
## 1.6.0 (2024-05-09)
53+
54+
### Features
55+
56+
* Affinity keys cleanup. Allow setting keys lifetime (#174)
57+
* Manual affinity via call options or context (#175)
58+
59+
## 1.5.0 (2023-11-08)
60+
61+
### Features
62+
63+
* Add disable affinity feature (#167)
64+
65+
## 1.4.1 (2023-01-30)
66+
67+
### Fixes
68+
69+
- Support common labels for multi-endpoint metrics (#160)
70+
71+
## 1.4.0 (2023-01-27)
72+
73+
### Features
74+
75+
- MultiEndpoint metrics (#158)
76+
77+
## 1.3.2 (2022-12-02)
78+
79+
### Fixes
80+
81+
* Fix race condition when running and adding state change callbacks. (#155)
82+
83+
## 1.3.1 (2022-10-24)
84+
85+
### Fixes
86+
87+
* MultiEndpoint: allow specifying protocol in the endpoint. (#151)
88+
89+
## 1.3.0 (2022-10-12)
90+
91+
### Features
92+
93+
* Add switching delay to GcpMultiEndpointChannel. (#145)
94+
* Look for a multi-endpoint specified in gRPC context. (#149)
95+
96+
## 1.2.0 (2022-07-18)
97+
98+
### Features
99+
100+
* multi-endpoint (#135).
101+
* round-robin for bind calls (#127).
102+
* minSize of the channel pool (#134).
103+
* detailed logs (#133).
104+
* log metrics (#131).
105+
* map a key to current channel when bound call arrives but no mapping for the
106+
key exists (#132).
107+
* consolidate channel pool config in the GcpChannelPoolOptions (#109).
108+
109+
## 1.1.0 (2021-07-20)
110+
111+
### Features
112+
113+
* improve bind/unbind logic.
114+
* improve getChannelRef performance for calls without channel affinity.
115+
* more accurate affinity counts.
116+
* allow to rebind a key to another channel and adjust affinity counts accordingly.
117+
118+
## 1.0.0 (2021-06-11)
119+
120+
### Features
121+
122+
* gRPC channel pool with configurable channel affinity.
123+
* provide a channel with minimum active streams for a new call.
124+
* an optional fallback from non-ready channel to a ready channel.
125+
* an option to detect unresponsive channels.

grpc-gcp-java/README.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# gRPC-GCP for Java
2+
3+
grpc-gcp provides gRPC support for Google Cloud Clients.
4+
5+
This module is currently used by the Google Cloud Spanner client library to provide
6+
gRPC-GCP channel pooling and related transport behavior. It is published separately
7+
as `com.google.cloud:grpc-gcp` because Spanner exposes grpc-gcp types in its public
8+
API.
9+
10+
## Usage
11+
12+
Use Spanner API as an example.
13+
14+
First, Create a json file defining API configuration, with ChannelPoolConfig and MethodConfig.
15+
16+
```json
17+
{
18+
"channelPool": {
19+
"maxSize": 3,
20+
"maxConcurrentStreamsLowWatermark": 0
21+
},
22+
"method": [
23+
{
24+
"name": [ "google.spanner.v1.Spanner/CreateSession" ],
25+
"affinity": {
26+
"command": "BIND",
27+
"affinityKey": "name"
28+
}
29+
},
30+
{
31+
"name": [ "google.spanner.v1.Spanner/GetSession" ],
32+
"affinity": {
33+
"command": "BOUND",
34+
"affinityKey": "name"
35+
}
36+
},
37+
{
38+
"name": [ "google.spanner.v1.Spanner/DeleteSession" ],
39+
"affinity": {
40+
"command": "UNBIND",
41+
"affinityKey": "name"
42+
}
43+
}
44+
]
45+
}
46+
```
47+
48+
Initialize `GcpManagedChannel` based on this API config file.
49+
50+
```java
51+
String API_CONFIG_FILE = "api_config_file.json"
52+
String SPANNER_TARGET = "spanner.googleapis.com";
53+
...
54+
55+
ManagedChannelBuilder delegateChannelBuilder = ManagedChannelBuilder.forAddress(SPANNER_TARGET, 443);
56+
GcpManagedChannelBuilder gcpBuilder =
57+
GcpManagedChannelBuilder.forDelegateBuilder(delegateChannelBuilder)
58+
.withApiConfigJsonFile(jsonApiConfig);
59+
ManagedChannel gcpChannel = gcpBuilder.build();
60+
```
61+
62+
Create Cloud API stub using `GcpManagedChannel`.
63+
64+
```java
65+
GoogleCredentials creds = getCreds();
66+
SpannerBlockingStub stub =
67+
SpannerGrpc.newBlockingStub(gcpChannel)
68+
.withCallCredentials(MoreCallCredentials.from(creds));
69+
```
70+
71+
## Build from source
72+
73+
Download source.
74+
75+
```sh
76+
git clone https://github.com/googleapis/google-cloud-java.git && cd google-cloud-java/grpc-gcp-java
77+
```
78+
79+
Build project with unit tests.
80+
81+
```sh
82+
mvn verify
83+
```
84+
85+
Install the jar to your local Maven repository.
86+
87+
```sh
88+
mvn install
89+
```
90+
91+
## Test
92+
93+
Setup credentials. See [Getting Started With Authentication](https://cloud.google.com/docs/authentication/getting-started) for more details.
94+
95+
```sh
96+
export GOOGLE_APPLICATION_CREDENTIALS=path/to/key.json
97+
```
98+
99+
```sh
100+
export GCP_PROJECT_ID=project_id
101+
```
102+
103+
Run unit tests.
104+
105+
```sh
106+
mvn test
107+
```
108+
109+
Integration tests are kept as source references but are not wired into the default monorepo Maven lifecycle.
110+
111+
## Publish
112+
113+
This artifact is released by the `google-cloud-java` monorepo release pipeline.
114+
115+
## Code Format
116+
117+
Run google-java-format
118+
119+
```sh
120+
mvn fmt:format
121+
```

0 commit comments

Comments
 (0)