Skip to content

Commit 8eed797

Browse files
vkediagarrettjonesgoogle
authored andcommitted
---
yaml --- r: 7827 b: refs/heads/tswast-patch-1 c: cad6b05 h: refs/heads/master i: 7825: 7c73a40 7823: e7ad16f
1 parent 19e1077 commit 8eed797

112 files changed

Lines changed: 24406 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: 0df82a932c8092a3cb821701e10e73522d4fb91d
60+
refs/heads/tswast-patch-1: cad6b057400466c3b3fb47a070c18417756eb70d
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ This client supports the following Google Cloud Platform services at a [Beta](#v
1818
- [Stackdriver Logging] (#stackdriver-logging-beta) (Beta - Not working on App Engine Standard)
1919
- [Google Cloud Datastore] (#google-cloud-datastore-beta) (Beta)
2020
- [Google Cloud Storage] (#google-cloud-storage-beta) (Beta)
21+
- [Cloud Spanner] (#cloud-spanner-beta) (Beta)
2122

2223
This client supports the following Google Cloud Platform services at an [Alpha](#versioning) quality level:
2324

@@ -400,6 +401,45 @@ if (blob != null) {
400401
channel.close();
401402
}
402403
```
404+
Cloud Spanner (Beta)
405+
--------------------
406+
407+
- [API Documentation][cloud-spanner-api]
408+
- [Official Documentation][cloud-spanner-docs]
409+
410+
#### Preview
411+
412+
Here is a code snippet showing a simple usage example from within Compute/App Engine Flex. Note that you
413+
must [supply credentials](#authentication) and a project ID if running this snippet elsewhere.
414+
415+
```java
416+
import com.google.cloud.spanner.DatabaseClient;
417+
import com.google.cloud.spanner.DatabaseId;
418+
import com.google.cloud.spanner.ResultSet;
419+
import com.google.cloud.spanner.Spanner;
420+
import com.google.cloud.spanner.SpannerOptions;
421+
import com.google.cloud.spanner.Statement;
422+
423+
// Instantiates a client
424+
SpannerOptions options = SpannerOptions.newBuilder().build();
425+
Spanner spanner = options.getService();
426+
String instance = "my-instance";
427+
String database = "my-database";
428+
try {
429+
// Creates a database client
430+
DatabaseClient dbClient = spanner.getDatabaseClient(
431+
DatabaseId.of(options.getProjectId(), instance, database));
432+
// Queries the database
433+
ResultSet resultSet = dbClient.singleUse().executeQuery(Statement.of("SELECT 1"));
434+
// Prints the results
435+
while (resultSet.next()) {
436+
System.out.printf("%d\n", resultSet.getLong(0));
437+
}
438+
} finally {
439+
// Closes the client which will free up the resources used
440+
spanner.closeAsync().get();
441+
}
442+
```
403443
404444
Google Cloud Compute (Alpha)
405445
----------------------
@@ -727,3 +767,7 @@ Apache 2.0 - See [LICENSE] for more information.
727767
728768
[translate-docs]: https://cloud.google.com/translate/docs/
729769
[translate-api]: https://googlecloudplatform.github.io/google-cloud-java/apidocs/index.html?com/google/cloud/translate/package-summary.html
770+
771+
[cloud-spanner]: https://cloud.google.com/spanner/
772+
[cloud-spanner-docs]: https://cloud.google.com/spanner/docs/
773+
[cloud-spanner-api]: https://googlecloudplatform.github.io/google-cloud-java/apidocs/index.html?com/google/cloud/spanner/package-summary.html

branches/tswast-patch-1/TESTING.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This library provides tools to help write tests for code that uses the following
1010
- [PubSub] (#testing-code-that-uses-pubsub)
1111
- [Resource Manager] (#testing-code-that-uses-resource-manager)
1212
- [Storage] (#testing-code-that-uses-storage)
13+
- [Spanner] (#testing-code-that-uses-cloud-spanner)
1314

1415
### Testing code that uses BigQuery
1516

@@ -260,5 +261,35 @@ that uses the `RemoteTranslateHelper` to list supported languages.
260261

261262
4. Run your tests.
262263

264+
### Testing code that uses Cloud Spanner
265+
266+
Currently, there isn't an emulator for Cloud Spanner, so an alternative is to create a test project. `RemoteSpannerHelper` contains convenience methods to make setting up and cleaning up the test project easier. To use this class, follow the steps below:
267+
268+
1. Create a test Google Cloud project.
269+
270+
2. Download a JSON service account credentials file from the Google Developer's Console. See more about this on the [Google Cloud Platform Storage Authentication page][cloud-platform-storage-authentication].
271+
272+
3. Create or use an existing Cloud Spanner Instance.
273+
274+
4. Create a `RemoteSpannerHelper` object using your instance ID and
275+
`SpannerOptions` pointing to the credentials file.
276+
Here is an example that uses the `RemoteSpannerHelper` to create a database.
277+
```java
278+
SpannerOptions options = SpannerOptions.newBuilder()
279+
.setCredentials(GoogleCredentials.fromStream(new FileInputStream("/path/to/my/JSON/key.json")))
280+
.build()
281+
RemoteSpannerHelper helper =
282+
RemoteSpannerHelper.create(options, InstanceId.of(options.getProjectId(), INSTANCE_ID),
283+
new FileInputStream("/path/to/my/JSON/key.json"));
284+
Database db = RemoteSpannerHelper.createTestDatabase("my ddl statements"...);
285+
DatabaseClient client = RemoteSpannerHelper.getDatabaseClient(db);
286+
```
287+
288+
5. Run your tests.
289+
290+
6. Clean up the test project by using `cleanUp` to clear any databases created.
291+
```java
292+
RemoteSpannerHelper.cleanUp();
293+
263294
[cloud-platform-storage-authentication]:https://cloud.google.com/storage/docs/authentication?hl=en#service_accounts
264295
[create-service-account]:https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Google Cloud Java Client for Spanner
2+
3+
Java idiomatic client for [Cloud
4+
Spanner](https://cloud.google.com/spanner).
5+
6+
[![Build
7+
Status](https://travis-ci.org/GoogleCloudPlatform/google-cloud-java.svg?branch=master)](https://travis-ci.org/GoogleCloudPlatform/google-cloud-java)
8+
[![Coverage
9+
Status](https://coveralls.io/repos/GoogleCloudPlatform/google-cloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/google-cloud-java?branch=master)
10+
[![Maven](https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-spanner.svg)](https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-spanner.svg)
11+
[![Codacy
12+
Badge](https://api.codacy.com/project/badge/grade/9da006ad7c3a4fe1abd142e77c003917)](https://www.codacy.com/app/mziccard/google-cloud-java)
13+
[![Dependency
14+
Status](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969/badge.svg?style=flat)](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969)
15+
16+
- [Homepage](https://googlecloudplatform.github.io/google-cloud-java/)
17+
- [API
18+
Documentation](https://googlecloudplatform.github.io/google-cloud-java/apidocs/index.html?com/google/cloud/spanner/package-summary.html)
19+
20+
> Note: This client is a work-in-progress, and may occasionally make
21+
> backwards-incompatible changes.
22+
23+
## Quickstart
24+
25+
If you are using Maven, add this to your pom.xml file `xml <dependency>
26+
<groupId>com.google.cloud</groupId>
27+
<artifactId>google-cloud-spanner</artifactId> <version>0.8.2-beta</version>
28+
</dependency>` If you are using Gradle, add this to your dependencies `Groovy
29+
compile 'com.google.cloud:google-cloud-spanner:0.8.2-beta'` If you are using
30+
SBT, add this to your dependencies `Scala libraryDependencies +=
31+
"com.google.cloud" % "google-cloud-spanner" % "0.8.2-beta"`
32+
33+
## Authentication
34+
35+
See the
36+
[Authentication](https://github.com/GoogleCloudPlatform/google-cloud-java#authentication)
37+
section in the base directory's README.
38+
39+
## About Cloud Spanner
40+
41+
[Cloud Spanner][cloud-spanner] is a fully managed, mission-critical relational database service
42+
built from the ground up and battle tested for transactional consistency, high
43+
availability, and global scale. With traditional relational semantics (schemas,
44+
ACID transactions, SQL) and automatic, synchronous replication for high
45+
availability, Cloud Spanner is the only database service of its kind on the
46+
market.
47+
48+
Be sure to activate the Cloud Spanner API on the Developer's Console to
49+
use Cloud Spanner from your project.
50+
51+
See the `google-cloud` API [spanner documentation][spanner-api] to learn how to
52+
interact with Cloud Spanner using this Client Library.
53+
54+
## Getting Started
55+
56+
Please refer to the [getting
57+
started](https://cloud.google.com/spanner/docs/getting-started/java/) guide.
58+
59+
## Troubleshooting
60+
61+
To get help, follow the instructions in the [shared Troubleshooting
62+
document](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/troubleshooting/readme.md#troubleshooting).
63+
64+
## Java Versions
65+
66+
Java 7 or above is required for using this client.
67+
68+
## Testing
69+
70+
This library has tools to help make tests for code using Cloud Spanner.
71+
72+
See [TESTING] to read more about testing.
73+
74+
## Versioning
75+
76+
This library follows [Semantic Versioning](http://semver.org/).
77+
78+
It is currently in major version zero (`0.y.z`), which means that anything may
79+
change at any time and the public API should not be considered stable.
80+
81+
## Contributing
82+
83+
Contributions to this library are always welcome and highly encouraged.
84+
85+
See [CONTRIBUTING] for more information on how to get started.
86+
87+
## License
88+
89+
Apache 2.0 - See [LICENSE] for more information.
90+
91+
[CONTRIBUTING]:https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/CONTRIBUTING.md
92+
[LICENSE]: https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/LICENSE
93+
[TESTING]: https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/TESTING.md#testing-code-that-uses-cloud-spanner
94+
[cloud-platform]: https://cloud.google.com/
95+
[cloud-spanner]: https://cloud.google.com/spanner/
96+
[spanner-api]: https://googlecloudplatform.github.io/google-cloud-java/apidocs/index.html?com/google/cloud/spanner/package-summary.html

0 commit comments

Comments
 (0)