Skip to content

Conversation

@BenWhitehead
Copy link
Collaborator

Add new builder method to all setting attempt of direct path connection.

If enabled, the underlying gapic client will be configured to attempt connecting via direct path and using client side load balancing.

deps: add a direct dependency to io.grpc:grpc-googleapis

Rumour has it this dependency will be removed from gax, and we need to pull it up to our level to ensure it's there for storage direct path.

@BenWhitehead BenWhitehead requested review from a team as code owners October 3, 2022 19:31
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: storage Issues related to the googleapis/java-storage API. labels Oct 3, 2022
Add new builder method to all setting attempt of direct path connection.

If enabled, the underlying gapic client will be configured to attempt connecting via direct path and using client side load balancing.

deps: add a direct dependency to io.grpc:grpc-googleapis

Rumour has it this dependency will be removed from gax, and we need to pull it up to our level to ensure it's there for storage direct path.
@BenWhitehead BenWhitehead force-pushed the grpc/enable-directpath branch from 9d50191 to f1aa593 Compare October 5, 2022 19:26
@BenWhitehead BenWhitehead added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 5, 2022
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 5, 2022

@BetaApi
public boolean isAttemptDirectPath() {
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait shouldn't this be a class property?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is under GrpcStorageDefaults. And since it's the literal value of a boolean, doesn't need a constant to create a single instance.

*/
@BetaApi
public GrpcStorageOptions.Builder setAttemptDirectPath(boolean attemptDirectPath) {
this.attemptDirectPath = attemptDirectPath;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be enabled by default?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the latest version of gax-java an environment variable still needs to be set in order for direct path to actually be attempted. I think this type of thing we can change the default on in the future without there being an issue as long as there isn't any overhead to the attempt.

@BenWhitehead BenWhitehead merged commit b6649a6 into feat/grpc-storage Oct 6, 2022
@BenWhitehead BenWhitehead deleted the grpc/enable-directpath branch October 6, 2022 22:39
endpoint = String.format("%s:%s", uri.getHost(), port > 0 ? port : 80);
break;
case "https":
endpoint = String.format("%s:%s", uri.getHost(), port > 0 ? port : 443);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementer's choice, just looking at alternative syntax to avoid the implicit-fallthrough default case:

private String resolveEndpoint(String originalEndpoint) {
  URI uri = URI.create(originalEndpoint);

  int defaultPort = scheme.equals("http") ? 80 : 443;
  int explicitPort = uri.getPort();
  int port = explicitPort > 0 ? explicitPort : defaultPort;

  // Gax routes the endpoint into a method which can't handle schemes.
  // Unless for direct path, try and strip here if we can.
  return (schema.equals("http") || schema.equals("https"))
    ? String.format("%s:%s", uri.getHost(), port)
    : originalEndpoint;
}

@InternalApi
StorageSettings getStorageSettings() throws IOException {
  String endpoint = resolveEndpoint(getHost());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the googleapis/java-storage API. size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants