Skip to content

Commit 81d12c5

Browse files
authored
Merge branch 'main' into fix-testbench-localhost-hang
2 parents e679b7d + 0d1d8f6 commit 81d12c5

44 files changed

Lines changed: 5233 additions & 1514 deletions

File tree

Some content is hidden

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

.github/workflows/update_generation_config.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
# downstream client libraries before they are released.
1616
name: Update generation configuration
1717
on:
18-
schedule:
19-
- cron: '0 2 * * *'
2018
workflow_dispatch:
2119
jobs:
2220
update-generation-config:

README.md

Lines changed: 64 additions & 32 deletions
Large diffs are not rendered by default.

generate-readme.py

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from typing import List, Optional
1818
from glob import glob
1919
import json
20-
import requests
2120

2221
class CloudClient:
2322
repo: str = None
@@ -41,6 +40,8 @@ def __init__(self, repo: dict):
4140
# For sorting, we want to sort by release level, then API pretty_name
4241
def __lt__(self, other):
4342
if self.release_level == other.release_level:
43+
if self.title == other.title:
44+
return (self.artifact_id or "") < (other.artifact_id or "")
4445
return self.title < other.title
4546

4647
return other.release_level < self.release_level
@@ -88,16 +89,6 @@ def generate_table_contents(clients: List[CloudClient]) -> List[str]:
8889
return content_rows + [client_row(client) for client in clients]
8990

9091

91-
REPO_METADATA_URL_FORMAT = "https://raw.githubusercontent.com/{repo_slug}/main/.repo-metadata.json"
92-
93-
def client_for_repo(repo_slug) -> Optional[CloudClient]:
94-
url = REPO_METADATA_URL_FORMAT.format(repo_slug=repo_slug)
95-
response = requests.get(url)
96-
if response.status_code != requests.codes.ok:
97-
return
98-
99-
return CloudClient(response.json())
100-
10192
def client_for_module(module) -> Optional[CloudClient]:
10293
with open ('%s/.repo-metadata.json' % module, "r") as metadata_file:
10394
data = json.load(metadata_file)
@@ -117,39 +108,21 @@ def client_for_module(module) -> Optional[CloudClient]:
117108
'java-shared-config',
118109
'java-shared-dependencies',
119110
'java-samples',
111+
'java-showcase',
120112
'java-vertexai'
121113
]
122114

123115
LIBRARIES_IN_MONOREPO = glob("java-*")
124116

125-
def allowed_remote_repo(repo) -> bool:
126-
return (repo['language'].lower() == 'java'
127-
and repo['full_name'].startswith('googleapis/java-')
128-
and repo['full_name'] not in
129-
[ 'googleapis/%s' % repo for repo in (REPO_EXCLUSION + LIBRARIES_IN_MONOREPO)])
130-
131-
def _fetch_repo_list(page):
132-
url = "https://api.github.com/search/repositories"
133-
response = requests.get(url, params = {
134-
'q': 'org:googleapis is:public archived:false language:java',
135-
'per_page': 100,
136-
'page': page,
137-
})
138-
return response.json()['items']
139-
140117
def all_clients() -> List[CloudClient]:
141-
page = 1
142118
clients = []
143-
while (True):
144-
repos = _fetch_repo_list(page)
145-
if not repos:
146-
break
147-
clients.extend([client_for_repo(repo['full_name']) for repo in repos if allowed_remote_repo(repo)])
148-
page += 1
149-
clients.extend([client_for_module(module) for module in LIBRARIES_IN_MONOREPO if
150-
module not in REPO_EXCLUSION])
151-
152-
return [client for client in clients if client]
119+
for module in sorted(LIBRARIES_IN_MONOREPO):
120+
if module not in REPO_EXCLUSION:
121+
client = client_for_module(module)
122+
if client:
123+
clients.append(client)
124+
125+
return clients
153126

154127

155128
clients = sorted(all_clients())

generation_config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
googleapis_commitish: 0db4dc67dd805d20294c6dc34068c37f546d71da
1+
googleapis_commitish: ff15be54722218705740b9fc6223d264c4cdb6dd
22
libraries_bom_version: 26.83.0
33
is_monorepo: true
44
libraries:

java-bigtable/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminClient.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
public final class BigtableInstanceAdminClient implements AutoCloseable {
126126
private final String projectId;
127127
private final BigtableInstanceAdminStub stub;
128-
private final BaseBigtableInstanceAdminClient baseClient;
128+
private final BigtableInstanceAdminClientV2 v2Client;
129129

130130
/** Constructs an instance of BigtableInstanceAdminClient with the given project ID. */
131131
public static BigtableInstanceAdminClient create(@Nonnull String projectId) throws IOException {
@@ -148,7 +148,7 @@ private BigtableInstanceAdminClient(
148148
@Nonnull String projectId, @Nonnull BigtableInstanceAdminStub stub) {
149149
this.projectId = projectId;
150150
this.stub = stub;
151-
this.baseClient = BaseBigtableInstanceAdminClient.create(stub);
151+
this.v2Client = new BigtableInstanceAdminClientV2(stub);
152152
}
153153

154154
/** Gets the project ID this client is associated with. */
@@ -157,11 +157,11 @@ public String getProjectId() {
157157
}
158158

159159
/**
160-
* Returns the modern autogenerated client. This provides access to the newest features and
161-
* proto-based methods.
160+
* Returns the modern V2 client. This provides access to the newest features and proto-based
161+
* methods.
162162
*/
163-
public BaseBigtableInstanceAdminClient getBaseClient() {
164-
return baseClient;
163+
public BigtableInstanceAdminClientV2 getBaseClient() {
164+
return v2Client;
165165
}
166166

167167
/** Closes the client and frees all resources associated with it (like thread pools). */

java-bigtable/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClient.java

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
import java.util.List;
9090
import java.util.Map;
9191
import java.util.concurrent.ExecutionException;
92+
import java.util.concurrent.ScheduledExecutorService;
9293
import javax.annotation.Nonnull;
9394

9495
/**
@@ -169,7 +170,7 @@ public final class BigtableTableAdminClient implements AutoCloseable {
169170
private final EnhancedBigtableTableAdminStub stub;
170171
private final String projectId;
171172
private final String instanceId;
172-
private final BaseBigtableTableAdminClient baseClient;
173+
private BigtableTableAdminClientV2 v2Client;
173174

174175
/** Constructs an instance of BigtableTableAdminClient with the given project and instance IDs. */
175176
public static BigtableTableAdminClient create(
@@ -209,7 +210,6 @@ private BigtableTableAdminClient(
209210
this.projectId = projectId;
210211
this.instanceId = instanceId;
211212
this.stub = stub;
212-
this.baseClient = BaseBigtableTableAdminClient.create(stub);
213213
}
214214

215215
/** Gets the project ID of the instance whose tables this client manages. */
@@ -223,11 +223,29 @@ public String getInstanceId() {
223223
}
224224

225225
/**
226-
* Returns the modern autogenerated client. This provides access to the newest features and
227-
* proto-based methods.
228-
*/
229-
public BaseBigtableTableAdminClient getBaseClient() {
230-
return baseClient;
226+
* Returns the modern V2 client. This provides access to the newest features and proto-based
227+
* methods.
228+
*/
229+
public synchronized BigtableTableAdminClientV2 getBaseClient() {
230+
if (v2Client == null) {
231+
ScheduledExecutorService backgroundExecutor =
232+
stub.getSettings().getBackgroundExecutorProvider().getExecutor();
233+
boolean shouldAutoClose =
234+
stub.getSettings().getBackgroundExecutorProvider().shouldAutoClose();
235+
236+
try {
237+
v2Client =
238+
BigtableTableAdminClientV2.create(
239+
stub,
240+
stub.getSettings(),
241+
stub.getClientContext().getClock(),
242+
backgroundExecutor,
243+
shouldAutoClose);
244+
} catch (IOException e) {
245+
throw new IllegalStateException("Failed to initialize modern V2 table admin client", e);
246+
}
247+
}
248+
return v2Client;
231249
}
232250

233251
@Override

java-bigtable/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClientV2.java

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ public static final BigtableTableAdminClientV2 create(BaseBigtableTableAdminSett
108108

109109
OperationCallable<Void, Empty, OptimizeRestoredTableMetadata>
110110
optimizeRestoredTableOperationBaseCallable =
111-
createOptimizeRestoredTableOperationBaseCallable(stub, settings, backgroundExecutor);
111+
createOptimizeRestoredTableOperationBaseCallable(
112+
stub, settings.getStubSettings().getClock(), backgroundExecutor);
112113

113114
return new BigtableTableAdminClientV2(
114115
stub,
@@ -118,6 +119,34 @@ public static final BigtableTableAdminClientV2 create(BaseBigtableTableAdminSett
118119
optimizeRestoredTableOperationBaseCallable);
119120
}
120121

122+
/**
123+
* Package-private factory method to construct an instance of {@link BigtableTableAdminClientV2}
124+
* by reusing an existing stub, settings, clock, and background executor.
125+
*
126+
* <p>This is used by the legacy {@code BigtableTableAdminClient}'s escape hatch ({@code
127+
* getBaseClient()}) to wrap the legacy client's active stub, ensuring the underlying gRPC channel
128+
* and resources are shared rather than recreated.
129+
*/
130+
static BigtableTableAdminClientV2 create(
131+
GrpcBigtableTableAdminStub stub,
132+
BigtableTableAdminStubSettings settings,
133+
ApiClock clock,
134+
ScheduledExecutorService backgroundExecutor,
135+
boolean shouldAutoClose)
136+
throws IOException {
137+
AwaitConsistencyCallableV2 awaitConsistencyCallable =
138+
createAwaitConsistencyCallable(stub, settings, clock, backgroundExecutor);
139+
OperationCallable<Void, Empty, OptimizeRestoredTableMetadata>
140+
optimizeRestoredTableOperationBaseCallable =
141+
createOptimizeRestoredTableOperationBaseCallable(stub, clock, backgroundExecutor);
142+
return new BigtableTableAdminClientV2(
143+
stub,
144+
backgroundExecutor,
145+
shouldAutoClose,
146+
awaitConsistencyCallable,
147+
optimizeRestoredTableOperationBaseCallable);
148+
}
149+
121150
protected BigtableTableAdminClientV2(
122151
GrpcBigtableTableAdminStub stub,
123152
@Nullable ScheduledExecutorService backgroundExecutor,
@@ -156,7 +185,7 @@ private static AwaitConsistencyCallableV2 createAwaitConsistencyCallable(
156185
private static OperationCallable<Void, Empty, OptimizeRestoredTableMetadata>
157186
createOptimizeRestoredTableOperationBaseCallable(
158187
GrpcBigtableTableAdminStub stub,
159-
BaseBigtableTableAdminSettings settings,
188+
ApiClock clock,
160189
ScheduledExecutorService backgroundExecutor)
161190
throws IOException {
162191

@@ -229,7 +258,7 @@ public Empty apply(OperationSnapshot input) {
229258
// (including channels, credentials, and headers) for executing the polling RPCs.
230259
ClientContext clientContext =
231260
ClientContext.newBuilder()
232-
.setClock(settings.getStubSettings().getClock())
261+
.setClock(clock)
233262
.setExecutor(backgroundExecutor)
234263
.setDefaultCallContext(GrpcCallContext.createDefault())
235264
.build();

java-bigtable/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/EnhancedBigtableTableAdminStub.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,4 +245,12 @@ public UnaryCallable<ConsistencyRequest, Void> awaitConsistencyCallable() {
245245
awaitOptimizeRestoredTableCallable() {
246246
return optimizeRestoredTableOperationBaseCallable;
247247
}
248+
249+
public BigtableTableAdminStubSettings getSettings() {
250+
return settings;
251+
}
252+
253+
public ClientContext getClientContext() {
254+
return clientContext;
255+
}
248256
}

java-bigtable/grpc-google-cloud-bigtable-v2/src/main/java/com/google/bigtable/v2/BigtableGrpc.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,8 @@ default void readRows(
772772
* delimit contiguous sections of the table of approximately equal size,
773773
* which can be used to break up the data for distributed tasks like
774774
* mapreduces.
775+
* If a `row_range` is provided in the request, the returned samples will be
776+
* restricted to the specified range.
775777
* </pre>
776778
*/
777779
default void sampleRowKeys(
@@ -1045,6 +1047,8 @@ public void readRows(
10451047
* delimit contiguous sections of the table of approximately equal size,
10461048
* which can be used to break up the data for distributed tasks like
10471049
* mapreduces.
1050+
* If a `row_range` is provided in the request, the returned samples will be
1051+
* restricted to the specified range.
10481052
* </pre>
10491053
*/
10501054
public void sampleRowKeys(
@@ -1326,6 +1330,8 @@ public io.grpc.stub.BlockingClientCall<?, com.google.bigtable.v2.ReadRowsRespons
13261330
* delimit contiguous sections of the table of approximately equal size,
13271331
* which can be used to break up the data for distributed tasks like
13281332
* mapreduces.
1333+
* If a `row_range` is provided in the request, the returned samples will be
1334+
* restricted to the specified range.
13291335
* </pre>
13301336
*/
13311337
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/10918")
@@ -1586,6 +1592,8 @@ public java.util.Iterator<com.google.bigtable.v2.ReadRowsResponse> readRows(
15861592
* delimit contiguous sections of the table of approximately equal size,
15871593
* which can be used to break up the data for distributed tasks like
15881594
* mapreduces.
1595+
* If a `row_range` is provided in the request, the returned samples will be
1596+
* restricted to the specified range.
15891597
* </pre>
15901598
*/
15911599
public java.util.Iterator<com.google.bigtable.v2.SampleRowKeysResponse> sampleRowKeys(

0 commit comments

Comments
 (0)