Skip to content

Commit 31f5ed1

Browse files
authored
Merge branch 'main' into release-please--branches--main
2 parents c69ec93 + e1e4059 commit 31f5ed1

15 files changed

Lines changed: 318 additions & 57 deletions

File tree

.github/workflows/librarian_generation_check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
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-
name: Librarian generate diff check on pull requests
14+
name: Librarian - Generate diff check on pull requests
1515
on:
1616
pull_request:
1717

.github/workflows/showcase-version-check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
name: Showcase Version Check
15+
name: Librarian - Showcase Version Check
1616

1717
on:
1818
schedule:

.github/workflows/update_librarian_googleapis.yaml

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
name: Update librarian googleapis commitish
15+
name: Librarian - Update googleapis commitish and generate all
1616
on:
1717
schedule:
1818
- cron: '0 3 * * *' # Run once a day at 3:00 AM UTC
@@ -85,6 +85,7 @@ jobs:
8585
echo "has_changes=true" >> $GITHUB_OUTPUT
8686
fi
8787
- name: Install protoc
88+
if: steps.detect_librarian.outputs.has_changes == 'true'
8889
run: |
8990
set -e
9091
VERSION="33.2"
@@ -93,42 +94,37 @@ jobs:
9394
sudo unzip -o /tmp/protoc.zip
9495
protoc --version
9596
- uses: actions/setup-java@v4
97+
if: steps.detect_librarian.outputs.has_changes == 'true'
9698
with:
9799
java-version: "17"
98100
distribution: "temurin"
99101
cache: "maven"
100102
- name: Verify Java and Maven installation
103+
if: steps.detect_librarian.outputs.has_changes == 'true'
101104
run: |
102105
java -version
103106
if ! command -v mvn &> /dev/null; then
104107
sudo apt-get update && sudo apt-get install -y maven
105108
fi
106109
mvn -version
107110
- uses: actions/setup-python@v5
111+
if: steps.detect_librarian.outputs.has_changes == 'true'
108112
with:
109113
python-version: "3.12"
110114
cache: 'pip'
111115
- name: Run librarian install
116+
if: steps.detect_librarian.outputs.has_changes == 'true'
112117
run: |
113118
go run github.com/googleapis/librarian/cmd/librarian@latest install
114119
echo "$HOME/java_tools/bin" >> $GITHUB_PATH
115120
env:
116121
PYTHONPATH: ${{ github.workspace }}/sdk-platform-java/hermetic_build/library_generation/owlbot
117122
- name: Generate Libraries
118123
if: steps.detect_librarian.outputs.has_changes == 'true'
119-
id: generate
120124
run: |
121125
go run github.com/googleapis/librarian/cmd/librarian@latest generate --all
122-
git add .
123-
changed_files=$(git diff --cached --name-only)
124-
if [[ "${changed_files}" == "" ]]; then
125-
echo "has_changes=false" >> $GITHUB_OUTPUT
126-
echo "No changes in libraries"
127-
else
128-
echo "has_changes=true" >> $GITHUB_OUTPUT
129-
fi
130126
- name: Commit and Create PR
131-
if: steps.detect_librarian.outputs.has_changes == 'true' || steps.generate.outputs.has_changes == 'true'
127+
if: steps.detect_librarian.outputs.has_changes == 'true'
132128
env:
133129
GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_GITHUB_TOKEN }}
134130
PR_TITLE: "chore: update googleapis commitish to ${{ steps.commit.outputs.short_commit }}"
@@ -139,7 +135,7 @@ jobs:
139135
if [ "${{ github.event_name }}" = "pull_request" ]; then
140136
echo "=== PR Test: DRY RUN MODE ACTIVE ==="
141137
echo "Would have checked out branch: update-librarian-googleapis-main"
142-
echo "Would have committed with title: $PR_TITLE"
138+
echo "Would have committed configs with title: $PR_TITLE"
143139
echo "Would have pushed branch and created PR."
144140
exit 0
145141
fi
@@ -153,8 +149,22 @@ jobs:
153149
# Create and switch to the branch (force checkout -B to discard any local state on this branch name if it existed)
154150
git checkout -B "${current_branch}"
155151
156-
# Commit the changes (they are already staged by the Detect Changes step!)
157-
git commit -m "${PR_TITLE}"
152+
# 1. Commit Config Changes
153+
# Ensure they are staged
154+
git add librarian.yaml generation_config.yaml
155+
if ! git diff --cached --quiet; then
156+
git commit -m "${PR_TITLE}"
157+
else
158+
echo "No config changes to commit"
159+
fi
160+
161+
# 2. Commit Generated Code
162+
git add .
163+
if ! git diff --cached --quiet; then
164+
git commit -m "chore: generate libraries"
165+
else
166+
echo "No generated code changes to commit"
167+
fi
158168
159169
# Push to remote (force push to overwrite any stale branch on remote)
160170
git remote add remote_repo https://cloud-java-bot:"${GH_TOKEN}@github.com/${{ github.repository }}.git" || git remote set-url remote_repo https://cloud-java-bot:"${GH_TOKEN}@github.com/${{ github.repository }}.git"

generation_config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1442,7 +1442,7 @@ libraries:
14421442
GAPICs:
14431443
- proto_path: google/iam/admin/v1
14441444
- api_shortname: iam-policy
1445-
name_pretty: IAM
1445+
name_pretty: Cloud IAM Policy
14461446
product_documentation: n/a
14471447
api_description: n/a
14481448
release_level: stable

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-datastore/datastore-v1-proto-client/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@
107107
</exclusion>
108108
</exclusions>
109109
</dependency>
110+
<dependency>
111+
<groupId>com.google.api</groupId>
112+
<artifactId>gax</artifactId>
113+
<scope>test</scope>
114+
</dependency>
110115
</dependencies>
111116

112117
<build>

0 commit comments

Comments
 (0)