Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

Commit 12c448b

Browse files
authored
Merge branch 'main' into legacy-client-integration
2 parents 78ea90d + 07d3467 commit 12c448b

82 files changed

Lines changed: 3266 additions & 2626 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.

google-cloud-bigtable/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,11 @@
255255
</dependency>
256256

257257
<!-- Test dependencies -->
258+
<dependency>
259+
<groupId>com.google.api.grpc</groupId>
260+
<artifactId>grpc-google-cloud-monitoring-v3</artifactId>
261+
<scope>test</scope>
262+
</dependency>
258263
<dependency>
259264
<groupId>com.google.api</groupId>
260265
<artifactId>gax</artifactId>

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataClientFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package com.google.cloud.bigtable.data.v2;
1717

1818
import com.google.api.core.BetaApi;
19-
import com.google.bigtable.v2.InstanceName;
19+
import com.google.cloud.bigtable.data.v2.internal.api.InstanceName;
2020
import com.google.cloud.bigtable.data.v2.stub.BigtableClientContext;
2121
import com.google.cloud.bigtable.data.v2.stub.ClientOperationSettings;
2222
import com.google.cloud.bigtable.data.v2.stub.EnhancedBigtableStub;

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/RequestContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public abstract class RequestContext implements Serializable {
3636

3737
public static RequestContext create(ClientInfo clientInfo) {
3838
return create(
39-
clientInfo.getInstanceName().getProject(),
40-
clientInfo.getInstanceName().getInstance(),
39+
clientInfo.getInstanceName().getProjectId(),
40+
clientInfo.getInstanceName().getInstanceId(),
4141
clientInfo.getAppProfileId());
4242
}
4343

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.cloud.bigtable.data.v2.internal.api;
18+
19+
import com.google.auto.value.AutoValue;
20+
import com.google.common.base.Preconditions;
21+
import com.google.common.base.Splitter;
22+
import java.util.List;
23+
24+
@AutoValue
25+
public abstract class InstanceName {
26+
public abstract String getProjectId();
27+
28+
public abstract String getInstanceId();
29+
30+
@Override
31+
public final String toString() {
32+
return String.format("projects/%s/instances/%s", getProjectId(), getInstanceId());
33+
}
34+
35+
public static InstanceName of(String projectId, String instanceId) {
36+
return InstanceName.builder().setProjectId(projectId).setInstanceId(instanceId).build();
37+
}
38+
39+
public static Builder builder() {
40+
return new AutoValue_InstanceName.Builder();
41+
}
42+
43+
public static InstanceName parse(String name) {
44+
List<String> parts = Splitter.on('/').splitToList(name);
45+
Preconditions.checkArgument(parts.size() == 4, "Invalid instance name: %s", name);
46+
Preconditions.checkArgument(
47+
"projects".equals(parts.get(0)),
48+
"Invalid instance name: %s, must start with projects/",
49+
name);
50+
Preconditions.checkArgument(
51+
!parts.get(1).isEmpty(), "Invalid instance name %s, must have a project id", name);
52+
Preconditions.checkArgument(
53+
"instances".equals(parts.get(2)),
54+
"Invalid instance name: %s, must start with projects/$PROJECT_ID/instances/",
55+
name);
56+
Preconditions.checkArgument(
57+
!parts.get(3).isEmpty(), "Invalid instance name %s, must have an instance id", name);
58+
59+
return builder().setProjectId(parts.get(1)).setInstanceId(parts.get(3)).build();
60+
}
61+
62+
@AutoValue.Builder
63+
public abstract static class Builder {
64+
public abstract Builder setProjectId(String projectId);
65+
66+
public abstract Builder setInstanceId(String instanceId);
67+
68+
public abstract InstanceName build();
69+
}
70+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.cloud.bigtable.data.v2.internal.api;
18+
19+
import com.google.auto.value.AutoValue;
20+
import com.google.common.base.Preconditions;
21+
import com.google.common.base.Splitter;
22+
import java.util.List;
23+
24+
@AutoValue
25+
public abstract class TableName {
26+
public abstract String getProjectId();
27+
28+
public abstract String getInstanceId();
29+
30+
public abstract String getTableId();
31+
32+
public InstanceName getInstanceName() {
33+
return InstanceName.builder()
34+
.setProjectId(getProjectId())
35+
.setInstanceId(getInstanceId())
36+
.build();
37+
}
38+
39+
@Override
40+
public final String toString() {
41+
return String.format("%s/tables/%s", getInstanceName(), getTableId());
42+
}
43+
44+
public static Builder builder() {
45+
return new AutoValue_TableName.Builder();
46+
}
47+
48+
public static TableName parse(String name) {
49+
List<String> parts = Splitter.on('/').splitToList(name);
50+
Preconditions.checkArgument(parts.size() == 6, "Invalid table name: %s", name);
51+
Preconditions.checkArgument(
52+
"projects".equals(parts.get(0)), "Invalid table name: %s, must start with projects/", name);
53+
Preconditions.checkArgument(
54+
!parts.get(1).isEmpty(), "Invalid table name %s, must have a project id", name);
55+
Preconditions.checkArgument(
56+
"instances".equals(parts.get(2)),
57+
"Invalid table name: %s, must start with projects/$PROJECT_ID/instances/",
58+
name);
59+
Preconditions.checkArgument(
60+
!parts.get(3).isEmpty(), "Invalid table name %s, must have an instance id", name);
61+
Preconditions.checkArgument(
62+
"tables".equals(parts.get(4)),
63+
"Invalid table name: %s, must start with"
64+
+ " projects/$PROJECT_ID/instances/$INSTANCE_ID/tables",
65+
name);
66+
Preconditions.checkArgument(
67+
!parts.get(5).isEmpty(), "Invalid table name %s, must have table id", name);
68+
69+
return builder()
70+
.setProjectId(parts.get(1))
71+
.setInstanceId(parts.get(3))
72+
.setTableId(parts.get(5))
73+
.build();
74+
}
75+
76+
@AutoValue.Builder
77+
public abstract static class Builder {
78+
public abstract Builder setProjectId(String projectId);
79+
80+
public abstract Builder setInstanceId(String instanceId);
81+
82+
public abstract Builder setTableId(String tableId);
83+
84+
public abstract TableName build();
85+
}
86+
}

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/csm/MetricRegistry.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
* </ul>
5454
*/
5555
public class MetricRegistry {
56-
static final String METER_NAME = "bigtable.googleapis.com/internal/client/";
56+
public static final String METER_NAME = "bigtable.googleapis.com/internal/client/";
5757

5858
final TableOperationLatency operationLatencyMetric;
5959
final TableAttemptLatency attemptLatencyMetric;
@@ -165,7 +165,7 @@ List<String> getGrpcMetricNames() {
165165
return ImmutableList.copyOf(grpcMetricNames);
166166
}
167167

168-
MetricWrapper<?> getMetric(String name) {
168+
public MetricWrapper<?> getMetric(String name) {
169169
return metrics.get(name);
170170
}
171171

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2026 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.google.cloud.bigtable.data.v2.internal.csm;
17+
18+
import com.google.api.gax.tracing.ApiTracerFactory;
19+
import com.google.cloud.bigtable.data.v2.internal.csm.attributes.ClientInfo;
20+
import com.google.cloud.bigtable.data.v2.internal.csm.tracers.ChannelPoolMetricsTracer;
21+
import io.grpc.ManagedChannelBuilder;
22+
import java.io.Closeable;
23+
import java.io.IOException;
24+
import javax.annotation.Nullable;
25+
26+
public interface Metrics extends Closeable {
27+
ApiTracerFactory createTracerFactory(ClientInfo clientInfo) throws IOException;
28+
29+
<T extends ManagedChannelBuilder<?>> T configureGrpcChannel(T channelBuilder);
30+
31+
@Nullable
32+
ChannelPoolMetricsTracer getChannelPoolMetricsTracer();
33+
34+
void start();
35+
36+
@Override
37+
void close();
38+
}

0 commit comments

Comments
 (0)