Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a35a59e
feat: enable experimental grpc support (#1419)
kolea2 May 2, 2024
c524d9c
chore: update version numbers (#1425)
kolea2 May 3, 2024
8a7a425
fix: make removeScheme case insensitive (#1423)
kolea2 May 3, 2024
ef741e8
chore: sync with main, update version numbers (#1465)
kolea2 May 29, 2024
37256a4
feat: add some docs, use only setCredentials in DatastoreOptions (#1467)
kolea2 May 30, 2024
2306cfa
test: Add GRPC DatastoreTest and parameterize DatastoreTest for both …
cindy-peng Jun 6, 2024
782c4cb
refactor: Pull latest changes from main to Gapic update (#1620)
cindy-peng Oct 18, 2024
1154c29
Refactor: merge changes from main branch (#1660)
cindy-peng Nov 14, 2024
c772f3e
Refactor: refactor code changes from maincopy (#1676)
cindy-peng Dec 3, 2024
4a18ad2
Refactor: refactor grpc query splitter logic (#1674)
cindy-peng Dec 23, 2024
7ba4531
feat: Improve upon the default gRPC Connection Pool size (#1706)
cindy-peng Feb 6, 2025
f2c7c29
deps: bump org.easymock:easymock from 5.4.0 to 5.5.0 (#1749)
dependabot[bot] Feb 25, 2025
111d68f
Resolve merge conficts from main
cindy-peng Feb 25, 2025
9552e63
resolve conflicts in dependabot
cindy-peng Feb 26, 2025
c78e207
Merge branch 'main' into grpc-experimental-main-1
cindy-peng Apr 24, 2025
8fa7c2f
chore: generate libraries at Thu Apr 24 00:49:57 UTC 2025
cloud-java-bot Apr 24, 2025
a3497e6
fix version
cindy-peng Apr 24, 2025
4293bbd
fix version to 2.27.2-SNAPSHOT
cindy-peng Apr 24, 2025
f61fb82
fix version to 2.27.2-SNAPSHOT
cindy-peng Apr 24, 2025
757845b
pull latest change from main
cindy-peng Apr 29, 2025
48df8a0
chore: generate libraries at Tue Apr 29 16:59:41 UTC 2025
cloud-java-bot Apr 29, 2025
36af98a
update version to 2.27.3
cindy-peng Apr 29, 2025
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/.OwlBot-hermetic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ deep-copy-regex:
dest: "/owl-bot-staging/$1/proto-google-cloud-datastore-$1/src"
- source: "/google/datastore/admin/(v.*)/.*-java/proto-google-.*/src"
dest: "/owl-bot-staging/$1/proto-google-cloud-datastore-admin-$1/src"
- source: "/google/datastore/(v.*)/.*-java/grpc-google-.*/src"
dest: "/owl-bot-staging/$1/grpc-google-cloud-datastore-$1/src"
- source: "/google/datastore/admin/(v.*)/.*-java/grpc-google-.*/src"
dest: "/owl-bot-staging/$1/grpc-google-cloud-datastore-admin-$1/src"
# Admin & Data APIs share the same wrapper library.
- source: "/google/datastore/(v.*)/.*-java/gapic-google-.*/src"
dest: "/owl-bot-staging/$1/google-cloud-datastore/src"
- source: "/google/datastore/admin/(v.*)/.*-java/gapic-google-.*/src"
dest: "/owl-bot-staging/$1/google-cloud-datastore/src"
3 changes: 1 addition & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ updates:
# If a security vulnerability comes in, we will be notified about
# it via template in the synthtool repository.
ignore:
- dependency-name: "*"

- dependency-name: "*"
# rules for the `grpc-experimental` branch
- package-ecosystem: maven
directory: "/"
Expand Down
16 changes: 0 additions & 16 deletions .github/sync-repo-settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,22 +156,6 @@ branchProtectionRules:
- 'Kokoro - Test: Java GraalVM Native Image'
- 'Kokoro - Test: Java 17 GraalVM Native Image'
- javadoc
- pattern: grpc-experimental
isAdminEnforced: true
requiredApprovingReviewCount: 1
requiresCodeOwnerReviews: true
requiresStrictStatusChecks: false
requiredStatusCheckContexts:
- dependencies (17)
- lint
- clirr
- units (8)
- units (11)
- 'Kokoro - Test: Integration'
- cla/google
- 'Kokoro - Test: Java GraalVM Native Image'
- 'Kokoro - Test: Java 17 GraalVM Native Image'
- javadoc
- pattern: 2.19.x
isAdminEnforced: true
requiredApprovingReviewCount: 1
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ target/
*.iml
__pycache__/

.flattened-pom.xml
.flattened-pom.xml
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>26.56.0</version>
<version>26.59.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -41,7 +41,7 @@ If you are using Maven without the BOM, add this to your dependencies:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-datastore</artifactId>
<version>2.26.4</version>
<version>2.27.0</version>
</dependency>

```
Expand Down
111 changes: 111 additions & 0 deletions google-cloud-datastore-utils/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?xml version='1.0' encoding='UTF-8'?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-datastore-utils</artifactId>
<version>2.27.2-SNAPSHOT</version><!-- {x-version-update:google-cloud-datastore:current} -->
<packaging>jar</packaging>
<name>Google Cloud Datastore Utilities</name>
<url>https://github.com/googleapis/java-datastore</url>
<description>
Java datastore client utility library.
</description>
<parent>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-datastore-parent</artifactId>
<version>2.27.2-SNAPSHOT</version><!-- {x-version-update:google-cloud-datastore:current} -->
</parent>
<properties>
<site.installationModule>google-cloud-datastore-utils</site.installationModule>
</properties>
<dependencies>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-protobuf</artifactId>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-gson</artifactId>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-cloud-datastore-v1</artifactId>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>api-common</artifactId>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-common-protos</artifactId>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson2</artifactId>
</dependency>
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<version>1.4.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Xmx2048m</argLine>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>native</id>
<properties>
<!-- skip native tests for this module, it will be tested in google-cloud-datastore-->
<skipTests>true</skipTests>
</properties>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.datastore.utils;

import com.google.datastore.v1.*;
import com.google.rpc.Code;
import java.io.IOException;
import java.io.InputStream;

/**
* Provides access to Cloud Datastore.
*
* <p>This class is thread-safe.
*/
public class Datastore {

final RemoteRpc remoteRpc;

Datastore(RemoteRpc remoteRpc) {
this.remoteRpc = remoteRpc;
}

/** Reset the RPC count. */
public void resetRpcCount() {
remoteRpc.resetRpcCount();
}

/**
* Returns the number of RPC calls made since the client was created or {@link #resetRpcCount} was
* called.
*/
public int getRpcCount() {
return remoteRpc.getRpcCount();
}

private com.google.datastore.utils.DatastoreException invalidResponseException(
String method, IOException exception) {
return RemoteRpc.makeException(
remoteRpc.getUrl(), method, Code.UNAVAILABLE, "Invalid response", exception);
}

public AllocateIdsResponse allocateIds(AllocateIdsRequest request)
throws com.google.datastore.utils.DatastoreException {
try (InputStream is =
remoteRpc.call("allocateIds", request, request.getProjectId(), request.getDatabaseId())) {
return AllocateIdsResponse.parseFrom(is);
} catch (IOException exception) {
throw invalidResponseException("allocateIds", exception);
}
}

public BeginTransactionResponse beginTransaction(BeginTransactionRequest request)
throws com.google.datastore.utils.DatastoreException {
try (InputStream is =
remoteRpc.call(
"beginTransaction", request, request.getProjectId(), request.getDatabaseId())) {
return BeginTransactionResponse.parseFrom(is);
} catch (IOException exception) {
throw invalidResponseException("beginTransaction", exception);
}
}

public CommitResponse commit(CommitRequest request)
throws com.google.datastore.utils.DatastoreException {
try (InputStream is =
remoteRpc.call("commit", request, request.getProjectId(), request.getDatabaseId())) {
return CommitResponse.parseFrom(is);
} catch (IOException exception) {
throw invalidResponseException("commit", exception);
}
}

public LookupResponse lookup(LookupRequest request)
throws com.google.datastore.utils.DatastoreException {
try (InputStream is =
remoteRpc.call("lookup", request, request.getProjectId(), request.getDatabaseId())) {
return LookupResponse.parseFrom(is);
} catch (IOException exception) {
throw invalidResponseException("lookup", exception);
}
}

public ReserveIdsResponse reserveIds(ReserveIdsRequest request)
throws com.google.datastore.utils.DatastoreException {
try (InputStream is =
remoteRpc.call("reserveIds", request, request.getProjectId(), request.getDatabaseId())) {
return ReserveIdsResponse.parseFrom(is);
} catch (IOException exception) {
throw invalidResponseException("reserveIds", exception);
}
}

public RollbackResponse rollback(RollbackRequest request)
throws com.google.datastore.utils.DatastoreException {
try (InputStream is =
remoteRpc.call("rollback", request, request.getProjectId(), request.getDatabaseId())) {
return RollbackResponse.parseFrom(is);
} catch (IOException exception) {
throw invalidResponseException("rollback", exception);
}
}

public RunQueryResponse runQuery(RunQueryRequest request)
throws com.google.datastore.utils.DatastoreException {
try (InputStream is =
remoteRpc.call("runQuery", request, request.getProjectId(), request.getDatabaseId())) {
return RunQueryResponse.parseFrom(is);
} catch (IOException exception) {
throw invalidResponseException("runQuery", exception);
}
}

public RunAggregationQueryResponse runAggregationQuery(RunAggregationQueryRequest request)
throws DatastoreException {
try (InputStream is =
remoteRpc.call(
"runAggregationQuery", request, request.getProjectId(), request.getDatabaseId())) {
return RunAggregationQueryResponse.parseFrom(is);
} catch (IOException exception) {
throw invalidResponseException("runAggregationQuery", exception);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.datastore.utils;

import com.google.rpc.Code;

/** Indicates an error in a {@link Datastore} call. */
public class DatastoreException extends Exception {
private final String methodName;
private final Code code;

public DatastoreException(String methodName, Code code, String message, Throwable cause) {
super(message, cause);
this.methodName = methodName;
this.code = code;
}

/** @return the canonical error code */
public Code getCode() {
return code;
}

/** @return the datastore method name */
public String getMethodName() {
return methodName;
}

@Override
public String toString() {
return String.format("%s, code=%s", super.toString(), code);
}
}
Loading