-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(spanner): add manual affinity in grpc-gcp #3170
base: main
Are you sure you want to change the base?
Changes from 4 commits
3bc44dc
b35ce1a
e7338a2
945d420
c0b3bbb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,11 @@ | |
<groupId>io.grpc</groupId> | ||
<artifactId>grpc-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.cloud</groupId> | ||
<artifactId>grpc-gcp</artifactId> | ||
<version>1.6.1</version> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't we centralize the versions or create separate dependencyManagement? |
||
</dependency> | ||
<dependency> | ||
<groupId>io.grpc</groupId> | ||
<artifactId>grpc-netty-shaded</artifactId> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,6 +162,7 @@ | |
<dependency> | ||
<groupId>com.google.cloud</groupId> | ||
<artifactId>grpc-gcp</artifactId> | ||
<version>1.6.1</version> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
</dependency> | ||
<dependency> | ||
<groupId>io.grpc</groupId> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
handlers = java.util.logging.ConsoleHandler | ||
java.util.logging.ConsoleHandler.level = ALL | ||
com.google.cloud.grpc.GcpManagedChannel.level=FINEST |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,9 +42,15 @@ | |
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.google.cloud</groupId> | ||
<artifactId>grpc-gcp</artifactId> | ||
<version>1.6.1</version> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you have dependency management above |
||
</dependency> | ||
<dependency> | ||
<groupId>com.google.cloud</groupId> | ||
<artifactId>google-cloud-spanner</artifactId> | ||
<version>6.69.1-SNAPSHOT</version> | ||
</dependency> | ||
<!-- [END spanner_install_with_bom] --> | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.example.spanner; | ||
|
||
import com.google.cloud.spanner.DatabaseClient; | ||
import com.google.cloud.spanner.DatabaseId; | ||
import com.google.cloud.spanner.ResultSet; | ||
import com.google.cloud.spanner.Spanner; | ||
import com.google.cloud.spanner.SpannerOptions; | ||
import com.google.cloud.spanner.Statement; | ||
import java.math.BigDecimal; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
class Mux { | ||
public static void main(String[] args){ | ||
Logger.getLogger("com.google.cloud.grpc.GcpManagedChannel").setLevel(Level.FINEST); | ||
queryWithNumericParameter(); | ||
} | ||
|
||
static void queryWithNumericParameter() { | ||
// TODO(developer): Replace these variables before running the sample. | ||
String projectId = "span-cloud-testing"; | ||
String instanceId = "harsha-test-gcloud"; | ||
String databaseId = "database1"; | ||
|
||
try (Spanner spanner = | ||
SpannerOptions.newBuilder().setProjectId(projectId).enableGrpcGcpExtension().build().getService()) { | ||
DatabaseClient client = | ||
spanner.getDatabaseClient(DatabaseId.of(projectId, instanceId, databaseId)); | ||
queryWithNumericParameter(client); | ||
} | ||
} | ||
|
||
static void queryWithNumericParameter(DatabaseClient client) { | ||
Statement statement = | ||
Statement.newBuilder( | ||
"SELECT SingerId, FirstName, LastName FROM Singers") | ||
.build(); | ||
try (ResultSet resultSet = client.singleUse().executeQuery(statement)) { | ||
while (resultSet.next()) { | ||
System.out.printf( | ||
"%d %s %s %n", resultSet.getLong("SingerId"), resultSet.getString("FirstName"), resultSet.getString("LastName")); | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flushing (auto-flush on
\n
) with sysout in benchmark apps may add extra IO overhead.