X Tutup
Skip to content

Exists method added#3769

Merged
igorbernstein2 merged 12 commits intogoogleapis:masterfrom
elisheva-qlogic:exist_method
Oct 23, 2018
Merged

Exists method added#3769
igorbernstein2 merged 12 commits intogoogleapis:masterfrom
elisheva-qlogic:exist_method

Conversation

@elisheva-qlogic
Copy link
Copy Markdown
Contributor

@elisheva-qlogic elisheva-qlogic commented Oct 4, 2018

exists method added in BigtableTableAdminClient to check if table exists #3636

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 4, 2018
@chingor13 chingor13 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 4, 2018
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 4, 2018
* }</pre>
*/
public boolean exists(String tableId) {
List<TableName> tableNames = this.listTables();

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

String table = tableName.toString();
String separator = "/";
int index = table.lastIndexOf(separator);
String name = table.substring(index + separator.length());

This comment was marked as spam.

boolean found = adminClient.exists(TABLE_NAME.getTable());

// Verify
Assert.assertTrue(found);

This comment was marked as spam.

@elisheva-qlogic elisheva-qlogic requested a review from a team October 11, 2018 16:26
return ApiFutures.transform(listTablesAsync(), new ApiFunction<List<TableName>, Boolean>() {
@Override public Boolean apply(List<TableName> tableNames) {
for(TableName tableName : tableNames) {
if(tableName.getTable().equalsIgnoreCase(tableId)) {

This comment was marked as spam.

return listTablesAsync(com.google.bigtable.admin.v2.Table.View.NAME_ONLY);
}

public ApiFuture<List<TableName>> listTablesAsync(com.google.bigtable.admin.v2.Table.View view) {

This comment was marked as spam.

}

public ApiFuture<Boolean> existsAsync(final String tableId) {
return ApiFutures.transform(listTablesAsync(), new ApiFunction<List<TableName>, Boolean>() {

This comment was marked as spam.

@sduskis sduskis added the api: bigtable Issues related to the Bigtable API. label Oct 12, 2018
Copy link
Copy Markdown
Contributor

@igorbernstein2 igorbernstein2 left a comment

Choose a reason for hiding this comment

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

This looks pretty good, just needs some stylistic fixes

.setName(TABLE_NAME.toString())
.build();

Mockito.when(mockGetTableCallable.futureCall(Matchers.any(GetTableRequest.class))).thenReturn(ApiFutures.immediateFuture(expectedResponse));

This comment was marked as spam.

import com.google.bigtable.admin.v2.GetTableRequest;
import com.google.bigtable.admin.v2.InstanceName;
import com.google.bigtable.admin.v2.ListTablesRequest;
import com.google.bigtable.admin.v2.*;

This comment was marked as spam.

// Setup
GetTableRequest expectedRequest = GetTableRequest.newBuilder()
.setName(TABLE_NAME.toString())
.setView(com.google.bigtable.admin.v2.Table.View.SCHEMA_VIEW)

This comment was marked as spam.

Copy link
Copy Markdown
Contributor

@igorbernstein2 igorbernstein2 left a comment

Choose a reason for hiding this comment

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

One last nit about sample code, but this LGTM

* found,
* new ApiFutureCallback<Boolean>() {
* public void onSuccess(Boolean found) {
* System.out.println("Table exists");

This comment was marked as spam.

@igorbernstein2 igorbernstein2 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 23, 2018
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 23, 2018
new NotFoundException("fake error", null, GrpcStatusCode.of(Status.Code.NOT_FOUND), false);

Mockito.when(mockGetTableCallable.futureCall(Matchers.any(GetTableRequest.class)))
.thenReturn(ApiFutures.immediateFailedFuture(exception));

This comment was marked as spam.

@igorbernstein2 igorbernstein2 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 23, 2018
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 23, 2018
@sduskis
Copy link
Copy Markdown
Contributor

sduskis commented Oct 23, 2018

@elisheva-qlogic, there's a compilation failure:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project google-cloud-bigtable-admin: Compilation failure
[ERROR] /tmpfs/src/github/google-cloud-java/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClient.java:[339,12] cannot find symbol
[ERROR] symbol: method awaitFuture(com.google.api.core.ApiFuture<java.lang.Boolean>)
[ERROR] location: class com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient

It looks like a merge conflict with PR #3809

@igorbernstein2 igorbernstein2 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 23, 2018
@igorbernstein2
Copy link
Copy Markdown
Contributor

I think I fixed the issue

@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 23, 2018
@igorbernstein2 igorbernstein2 merged commit 0e1bc68 into googleapis:master Oct 23, 2018
@JesseLovelace JesseLovelace mentioned this pull request Oct 25, 2018
@elisheva-qlogic elisheva-qlogic deleted the exist_method branch November 8, 2018 14:30
chingor13 pushed a commit that referenced this pull request Mar 24, 2026
….1 to 3.3.3 in /java-shared-dependencies/unmanaged-dependency-check (#3769)

Bumps
[org.apache.maven.shared:maven-shared-utils](https://github.com/apache/maven-shared-utils)
from 3.2.1 to 3.3.3.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/apache/maven-shared-utils/commit/cc010396156386d95e2acbc28f7aba32590243a2"><code>cc01039</code></a>
[maven-release-plugin] prepare release maven-shared-utils-3.3.3</li>
<li><a
href="https://github.com/apache/maven-shared-utils/commit/abdc90ccc36326dc6ee61ac497d2005e9e6637ef"><code>abdc90c</code></a>
[maven-release-plugin] prepare for next development iteration</li>
<li><a
href="https://github.com/apache/maven-shared-utils/commit/5460b13f6f4230d5ddce3fe8ffb241ab42254346"><code>5460b13</code></a>
[maven-release-plugin] prepare release maven-shared-utils-3.3.2</li>
<li><a
href="https://github.com/apache/maven-shared-utils/commit/60d005240b324e08661471fe6b0db981e2a0bd58"><code>60d0052</code></a>
[maven-release-plugin] prepare for next development iteration</li>
<li><a
href="https://github.com/apache/maven-shared-utils/commit/b3f78c16715d237b2d915d5cb963eef18b0d9fd2"><code>b3f78c1</code></a>
[maven-release-plugin] prepare release maven-shared-utils-3.3.1</li>
<li><a
href="https://github.com/apache/maven-shared-utils/commit/d1acca0bfaa7eda578f522f8d7851af074dbaa1c"><code>d1acca0</code></a>
Bump version to 3.3.1 in preparation for release.</li>
<li><a
href="https://github.com/apache/maven-shared-utils/commit/5ff997cac035ac7d2ab84bbd2c695c6e60798400"><code>5ff997c</code></a>
[MSHARED-848] deprecate XmlStreamReader (<a
href="https://redirect.github.com/apache/maven-shared-utils/issues/59">#59</a>)</li>
<li><a
href="https://github.com/apache/maven-shared-utils/commit/914d9755b157f337dfb76e90f6b0331f834096d6"><code>914d975</code></a>
remove call to deprecated method (<a
href="https://redirect.github.com/apache/maven-shared-utils/issues/58">#58</a>)</li>
<li><a
href="https://github.com/apache/maven-shared-utils/commit/dda9e1480f4f51120f619dfd302ed0d10807dfa5"><code>dda9e14</code></a>
[MSHARED-904] update test dependencies for Maven 3.1 (<a
href="https://redirect.github.com/apache/maven-shared-utils/issues/57">#57</a>)</li>
<li><a
href="https://github.com/apache/maven-shared-utils/commit/6798f3033c3c5144e52c5aa8e1be584ea97527d2"><code>6798f30</code></a>
[MSHARED-297] - Minor code cleanup</li>
<li>Additional commits viewable in <a
href="https://github.com/apache/maven-shared-utils/compare/maven-shared-utils-3.2.1...maven-shared-utils-3.3.3">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=org.apache.maven.shared:maven-shared-utils&package-manager=maven&previous-version=3.2.1&new-version=3.3.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/googleapis/sdk-platform-java/network/alerts).

</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Min Zhu <zhumin@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigtable Issues related to the Bigtable API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

X Tutup