Skip to content

Conversation

@rahul2393
Copy link
Contributor

No description provided.

@rahul2393 rahul2393 requested a review from a team as a code owner September 22, 2022 07:07
@product-auto-label product-auto-label bot added size: s Pull request size is small. api: spanner Issues related to the googleapis/java-spanner API. labels Sep 22, 2022
@rahul2393 rahul2393 requested a review from a team as a code owner September 22, 2022 07:19
@rahul2393 rahul2393 added the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 22, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 22, 2022
* determines the access permissions that a connection has. This can for example be used to create
* connections that are only permitted to access certain tables.
*/
String getDatabaseRole();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
String getDatabaseRole();
default String getDatabaseRole() {
throw new UnsupportedOperationException("method should be overwritten");
}

I think we should provide a default implementation for this method in the interface, so that it isn't a breaking change.


private final SessionPoolOptions options;
private final SettableFuture<Dialect> dialect = SettableFuture.create();

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove extra newline.

Clock clock) {
return createPool(
poolOptions,
"",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we pass in null here?

Suggested change
"",
null,

}
}

String getDatabaseRole() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
String getDatabaseRole() {
public String getDatabaseRole() {

Clock clock, MetricRegistry metricRegistry, List<LabelValue> labelValues) {
return SessionPool.createPool(
options,
"",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"",
null,

try (ResultSet rs =
dbClient.singleUse().executeQuery(Statement.of("SELECT COUNT(*) as cnt FROM T"))) {
assertTrue(rs.next());
assertThat(dbClient.getDatabaseRole()).isEqualTo(dbRoleParent);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
assertThat(dbClient.getDatabaseRole()).isEqualTo(dbRoleParent);
assertEquals(dbClient.getDatabaseRole(), dbRoleParent);

nit: change to assertEquals.

@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Sep 22, 2022
@rahul2393 rahul2393 added the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 22, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 22, 2022
@rajatbhatta
Copy link
Contributor

@rahul2393 rahul2393 added the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 22, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 22, 2022
@rahul2393 rahul2393 force-pushed the add-database-role-getter branch from cc008d9 to c3c9e81 Compare September 22, 2022 12:49
import static com.google.cloud.spanner.MetricRegistryConstants.NUM_WRITE_SESSIONS;
import static com.google.cloud.spanner.MetricRegistryConstants.SPANNER_LABEL_KEYS;
import static com.google.cloud.spanner.MetricRegistryConstants.SPANNER_LABEL_KEYS_WITH_TYPE;
import static com.google.cloud.spanner.MetricRegistryConstants.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import static com.google.cloud.spanner.MetricRegistryConstants.*;
import static com.google.cloud.spanner.MetricRegistryConstants.NUM_IN_USE_SESSIONS;
import static com.google.cloud.spanner.MetricRegistryConstants.NUM_READ_SESSIONS;
import static com.google.cloud.spanner.MetricRegistryConstants.NUM_SESSIONS_BEING_PREPARED;
import static com.google.cloud.spanner.MetricRegistryConstants.NUM_WRITE_SESSIONS;
import static com.google.cloud.spanner.MetricRegistryConstants.SPANNER_LABEL_KEYS;
import static com.google.cloud.spanner.MetricRegistryConstants.SPANNER_LABEL_KEYS_WITH_TYPE;

Google style requires us to never use wildcard imports: https://google.github.io/styleguide/javaguide.html

}

@Test
public void testDatabaseRole() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public void testDatabaseRole() throws Exception {
public void testGetDatabaseRole() throws Exception {

@rahul2393 rahul2393 force-pushed the add-database-role-getter branch from 26e1438 to ee9b14b Compare September 22, 2022 17:11
@rajatbhatta rajatbhatta added the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 22, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 22, 2022
@rajatbhatta rajatbhatta added the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 22, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 22, 2022
@rajatbhatta rajatbhatta self-requested a review September 22, 2022 20:53
Copy link
Contributor

@rajatbhatta rajatbhatta left a comment

Choose a reason for hiding this comment

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

LGTM.
@olavloite: Can you please take a look at this PR once? Thanks!

@rajatbhatta rajatbhatta added the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 23, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 23, 2022
Copy link
Collaborator

@olavloite olavloite left a comment

Choose a reason for hiding this comment

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

LGTM (with a tiny nit on the Javadoc)

BatchReadOnlyTransaction batchReadOnlyTransaction(BatchTransactionId batchTransactionId);

/**
* Returns the {@link DatabaseRole} used by the client connection. The database role that is used
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: replace the {@link DatabaseRole} with just database role. DatabaseRole is not a valid class name, so it cannot be linked.

}

/**
* Returns the {@link DatabaseRole} used by the client connection. The database role that is used
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above

@ansh0l ansh0l merged commit c2363e3 into googleapis:main Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants