feat(storage): add support for DirectPath over Interconnect - #13904
feat(storage): add support for DirectPath over Interconnect#13904nidhiii-27 wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for DirectPath xDS over Interconnect (on-premise xDS name resolution) across google-cloud-storage and gax-grpc. It adds the attemptDirectPathXdsOverInterconnect configuration, bypasses GCE environment checks when enabled, appends ?force-xds to the target URI, and updates endpoint validation to support custom URI schemes. Feedback on the changes includes restoring the accidentally removed getExecutor() method in InstantiatingGrpcChannelProvider, replacing fragile string equality checks for endpoint translation with a more robust replacement approach in GrpcStorageOptions, and simplifying redundant String.format calls in endpoint validation.
I am having trouble creating individual review comments. Click here to see my feedback.
sdk-platform-java/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java (268)
The getExecutor() method was accidentally removed from InstantiatingGrpcChannelProvider. Since this class implements TransportChannelProvider, removing this method will cause it to fallback to the interface's default implementation (which likely returns null), breaking the ability to retrieve the configured executor. Please restore this method.
@Nullable
@Override
public Executor getExecutor() {
return executor;
}java-storage/google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcStorageOptions.java (235-241)
The current string equality checks for endpoint are fragile. If the host is configured with a port (e.g., storage.googleapis.com:443), a trailing slash, or other variations, the translation to storage.direct.googleapis.com will be bypassed. Using String.replace is much more robust, simpler, and handles all these cases seamlessly.
if (attemptDirectPathXdsOverInterconnect && endpoint != null) {
endpoint = endpoint.replace("storage.googleapis.com", "storage.direct.googleapis.com");
}sdk-platform-java/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java (1494-1512)
The String.format calls with no format arguments are redundant and can be simplified to direct string literals for better performance and readability. Avoid adding defensive null checks for endpoint as it is guaranteed to be non-null by design.
if (endpoint.contains(":///")) {
try {
java.net.URI.create(endpoint);
return;
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("invalid endpoint URI: " + endpoint, e);
}
}
int colon = endpoint.lastIndexOf(':');
if (colon < 0) {
throw new IllegalArgumentException("invalid endpoint, expecting \"<host>:<port>\"");
}
try {
Integer.parseInt(endpoint.substring(colon + 1));
} catch (NumberFormatException e) {
throw new IllegalArgumentException("invalid endpoint, expecting \"<host>:<port>\"", e);
}References
- Avoid adding defensive null checks for values that are guaranteed to be non-null by design, as this can hide invariant breaks.
|
|


No description provided.