Skip to content

Commit 326479a

Browse files
author
Ajay Kannan
committed
---
yaml --- r: 6313 b: refs/heads/tswast-patch-1 c: 33ddb90 h: refs/heads/master i: 6311: 0008d41
1 parent 32014fe commit 326479a

42 files changed

Lines changed: 507 additions & 1380 deletions

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: b0c8874085d36949d8707159839173f91df2d9e0
60+
refs/heads/tswast-patch-1: 33ddb90dec5aa31e527a2dc9af949cd6189857ec
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/README.md

Lines changed: 48 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@ Java idiomatic client for [Google Cloud Platform][cloud-platform] services.
99

1010
- [Homepage] (https://googlecloudplatform.github.io/gcloud-java/)
1111
- [API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs)
12+
- [Examples] (http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/examples/package-summary.html)
1213

1314
This client supports the following Google Cloud Platform services:
1415

1516
- [Google Cloud Datastore] (#google-cloud-datastore)
1617
- [Google Cloud Storage] (#google-cloud-storage)
1718

19+
<!---
20+
- [Google Cloud Storage] (https://cloud.google.com/storage/)
21+
--->
22+
1823
> Note: This client is a work-in-progress, and may occasionally
1924
> make backwards-incompatible changes.
2025
@@ -25,39 +30,32 @@ Add this to your pom.xml file
2530
<dependency>
2631
<groupId>com.google.gcloud</groupId>
2732
<artifactId>gcloud-java</artifactId>
28-
<version>0.0.10</version>
33+
<version>0.0.9</version>
2934
</dependency>
3035
```
3136

37+
<!---
3238
Example Applications
3339
--------------------
3440
35-
- [`DatastoreExample`](https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/gcloud-java-examples/src/main/java/com/google/gcloud/examples/DatastoreExample.java) - A simple command line interface for the Cloud Datastore
36-
- Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/DatastoreExample.html).
37-
- [`StorageExample`](https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/gcloud-java-examples/src/main/java/com/google/gcloud/examples/StorageExample.java) - A simple command line interface providing some of Cloud Storage's functionality
38-
- Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/StorageExample.html).
39-
40-
Authentication
41-
--------------
42-
43-
There are multiple ways to authenticate to use Google Cloud services.
44-
45-
1. When using `gcloud-java` libraries from within Compute/App Engine, no additional authentication steps are necessary.
46-
2. When using `gcloud-java` libraries elsewhere, there are two options:
47-
* [Generate a JSON service account key](https://cloud.google.com/storage/docs/authentication?hl=en#service_accounts). Supply a path to the downloaded JSON credentials file when building the options supplied to datastore/storage constructor.
48-
* If running locally for development/testing, you can use use [Google Cloud SDK](https://cloud.google.com/sdk/?hl=en). To use the SDK authentication, [download the SDK](https://cloud.google.com/sdk/?hl=en) if you haven't already. Then login using the SDK (`gcloud auth login` in command line), and set your current project using `gcloud config set project PROJECT_ID`.
41+
- `java-datastore-sample`_ - A sample using Cloud Datastore
42+
.. _java-datastore-sample: https://github.com/GoogleCloudPlatform/java-datastore-sample
43+
--->
4944

5045
Google Cloud Datastore
5146
----------------------
5247

53-
- [API Documentation][datastore-api]
54-
- [Official Documentation][cloud-datastore-docs]
55-
56-
*Follow the [activation instructions][cloud-datastore-activation] to use the Google Cloud Datastore API with your project.*
48+
[Google Cloud Datastore][cloud-datastore] is a fully managed, schemaless database for
49+
storing non-relational data. Cloud Datastore automatically scales with
50+
your users and supports ACID transactions, high availability of reads and
51+
writes, strong consistency for reads and ancestor queries, and eventual
52+
consistency for all other queries.
5753

58-
#### Preview
54+
See the [Google Cloud Datastore docs][cloud-datastore-activation] for more details on how to activate
55+
Cloud Datastore for your project.
5956

60-
Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must [supply credentials](#authentication) and a project ID if running this snippet elsewhere.
57+
See the ``gcloud-java`` API [datastore documentation][datastore-api] to learn how to interact
58+
with the Cloud Datastore using this Client Library.
6159

6260
```java
6361
import com.google.gcloud.datastore.Datastore;
@@ -68,7 +66,8 @@ import com.google.gcloud.datastore.Entity;
6866
import com.google.gcloud.datastore.Key;
6967
import com.google.gcloud.datastore.KeyFactory;
7068

71-
Datastore datastore = DatastoreFactory.instance().get(DatastoreOptions.getDefaultInstance());
69+
DatastoreOptions options = DatastoreOptions.builder().projectId(PROJECT_ID).build();
70+
Datastore datastore = DatastoreFactory.instance().get(options);
7271
KeyFactory keyFactory = datastore.newKeyFactory().kind(KIND);
7372
Key key = keyFactory.newKey(keyName);
7473
Entity entity = datastore.get(key);
@@ -91,36 +90,35 @@ if (entity == null) {
9190
Google Cloud Storage
9291
----------------------
9392

94-
- [API Documentation][storage-api]
95-
- [Official Documentation][cloud-storage-docs]
93+
[Google Cloud Storage][cloud-storage] is a durable and highly available
94+
object storage service. Google Cloud Storage is almost infinitely scalable
95+
and guarantees consistency: when a write succeeds, the latest copy of the
96+
object will be returned to any GET, globally.
9697

97-
*Follow the [activation instructions][cloud-storage-activation] to use the Google Cloud Storage API with your project.*
98+
See the [Google Cloud Storage docs][cloud-storage-activation] for more details on how to activate
99+
Cloud Storage for your project.
98100

99-
#### Preview
100-
101-
Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must [supply credentials](#authentication) and a project ID if running this snippet elsewhere.
101+
See the ``gcloud-java`` API [storage documentation][storage-api] to learn how to interact
102+
with the Cloud Storage using this Client Library.
102103

103104
```java
104105
import static java.nio.charset.StandardCharsets.UTF_8;
105106

106107
import com.google.gcloud.storage.Blob;
107-
import com.google.gcloud.storage.BlobId;
108108
import com.google.gcloud.storage.Storage;
109109
import com.google.gcloud.storage.StorageFactory;
110110
import com.google.gcloud.storage.StorageOptions;
111111

112112
import java.nio.ByteBuffer;
113113
import java.nio.channels.WritableByteChannel;
114114

115-
StorageOptions options = StorageOptions.builder().projectId("project").build();
115+
StorageOptions options = StorageOptions.builder().projectId(PROJECT_ID).build();
116116
Storage storage = StorageFactory.instance().get(options);
117-
BlobId blobId = BlobId.of("bucket", "blob_name");
118-
Blob blob = Blob.load(storage, blobId);
119-
if (blob == null) {
120-
BlobInfo blobInfo = BlobInfo.builder(blobId).contentType("text/plain").build();
121-
storage.create(blobInfo, "Hello, Cloud Storage!".getBytes(UTF_8));
117+
Blob blob = new Blob(storage, "bucket", "blob_name");
118+
if (!blob.exists()) {
119+
storage2.create(blob.info(), "Hello, Cloud Storage!".getBytes(UTF_8));
122120
} else {
123-
System.out.println("Updating content for " + blobId.name());
121+
System.out.println("Updating content for " + blob.info().name());
124122
byte[] prevContent = blob.content();
125123
System.out.println(new String(prevContent, UTF_8));
126124
WritableByteChannel channel = blob.writer();
@@ -129,27 +127,13 @@ if (blob == null) {
129127
}
130128
```
131129

132-
Java Versions
133-
-------------
134-
135-
Java 7 or above is required for using this client.
136-
137130
Testing
138131
-------
139132

140133
This library provides tools to help write tests for code that uses gcloud-java services.
141134

142135
See [TESTING] to read more about using our testing helpers.
143136

144-
Versioning
145-
----------
146-
147-
This library follows [Semantic Versioning] (http://semver.org/).
148-
149-
It is currently in major version zero (``0.y.z``), which means that anything
150-
may change at any time and the public API should not be considered
151-
stable.
152-
153137
Contributing
154138
------------
155139

@@ -159,6 +143,20 @@ See [CONTRIBUTING] for more information on how to get started.
159143

160144
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See [Code of Conduct][code-of-conduct] for more information.
161145

146+
Java Versions
147+
-------------
148+
149+
Java 7 or above is required for using this client.
150+
151+
Versioning
152+
----------
153+
154+
This library follows [Semantic Versioning] (http://semver.org/).
155+
156+
It is currently in major version zero (``0.y.z``), which means that anything
157+
may change at any time and the public API should not be considered
158+
stable.
159+
162160
License
163161
-------
164162

branches/tswast-patch-1/gcloud-java-core/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ This module provides common functionality required by service-specific modules o
55

66
[![Build Status](https://travis-ci.org/GoogleCloudPlatform/gcloud-java.svg?branch=master)](https://travis-ci.org/GoogleCloudPlatform/gcloud-java)
77
[![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master)
8-
[![Maven](https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-core.svg)](https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-core.svg)
98

109
- [Homepage] (https://googlecloudplatform.github.io/gcloud-java/)
1110
- [API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/package-summary.html)
11+
- [Examples] (http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/examples/package-summary.html)
1212

1313
Quickstart
1414
----------
@@ -17,22 +17,22 @@ Add this to your pom.xml file
1717
<dependency>
1818
<groupId>com.google.gcloud</groupId>
1919
<artifactId>gcloud-java-core</artifactId>
20-
<version>0.0.10</version>
20+
<version>0.0.9</version>
2121
</dependency>
2222
```
2323

24-
Java Versions
25-
-------------
26-
27-
Java 7 or above is required for using this client.
28-
2924
Contributing
3025
------------
3126

3227
Contributions to this library are always welcome and highly encouraged.
3328

3429
See [CONTRIBUTING] for more information on how to get started.
3530

31+
Java Versions
32+
-------------
33+
34+
Java 7 or above is required for using this client.
35+
3636
Versioning
3737
----------
3838

branches/tswast-patch-1/gcloud-java-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<parent>
1212
<groupId>com.google.gcloud</groupId>
1313
<artifactId>gcloud-java-pom</artifactId>
14-
<version>0.0.11-SNAPSHOT</version>
14+
<version>0.0.10-SNAPSHOT</version>
1515
</parent>
1616
<dependencies>
1717
<dependency>

branches/tswast-patch-1/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java

Lines changed: 2 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import java.io.IOException;
3535
import java.io.InputStream;
3636
import java.io.InputStreamReader;
37-
import java.io.ObjectStreamException;
3837
import java.io.Serializable;
3938
import java.lang.reflect.Method;
4039
import java.net.HttpURLConnection;
@@ -63,7 +62,6 @@ public abstract class ServiceOptions<
6362
private final ServiceRpcFactory<ServiceRpcT, OptionsT> serviceRpcFactory;
6463
private final int connectTimeout;
6564
private final int readTimeout;
66-
private final Clock clock;
6765

6866
public interface HttpTransportFactory extends Serializable {
6967
HttpTransport create();
@@ -93,44 +91,7 @@ public HttpTransport create() {
9391
}
9492
}
9593

96-
/**
97-
* A class providing access to the current time in milliseconds. This class is mainly used for
98-
* testing and will be replaced by Java8's {@code java.time.Clock}.
99-
*
100-
* Implementations should implement {@code Serializable} wherever possible and must document
101-
* whether or not they do support serialization.
102-
*/
103-
public static abstract class Clock {
10494

105-
private static ServiceOptions.Clock DEFAULT_TIME_SOURCE = new DefaultClock();
106-
107-
/**
108-
* Returns current time in milliseconds according to this clock.
109-
*/
110-
public abstract long millis();
111-
112-
/**
113-
* Returns the default clock. Default clock uses {@link System#currentTimeMillis()} to get time
114-
* in milliseconds.
115-
*/
116-
public static ServiceOptions.Clock defaultClock() {
117-
return DEFAULT_TIME_SOURCE;
118-
}
119-
120-
private static class DefaultClock extends ServiceOptions.Clock implements Serializable {
121-
122-
private static final long serialVersionUID = -5077300394286703864L;
123-
124-
@Override
125-
public long millis() {
126-
return System.currentTimeMillis();
127-
}
128-
129-
private Object readResolve() throws ObjectStreamException {
130-
return DEFAULT_TIME_SOURCE;
131-
}
132-
}
133-
}
13495

13596
protected abstract static class Builder<
13697
ServiceRpcT,
@@ -145,7 +106,6 @@ protected abstract static class Builder<
145106
private ServiceRpcFactory<ServiceRpcT, OptionsT> serviceRpcFactory;
146107
private int connectTimeout = -1;
147108
private int readTimeout = -1;
148-
private Clock clock;
149109

150110
protected Builder() {}
151111

@@ -165,18 +125,6 @@ protected B self() {
165125
return (B) this;
166126
}
167127

168-
/**
169-
* Sets the service's clock. The clock is mainly used for testing purpose. {@link Clock} will be
170-
* replaced by Java8's {@code java.time.Clock}.
171-
*
172-
* @param clock the clock to set
173-
* @return the builder.
174-
*/
175-
public B clock(Clock clock) {
176-
this.clock = clock;
177-
return self();
178-
}
179-
180128
/**
181129
* Sets project id.
182130
*
@@ -273,7 +221,6 @@ protected ServiceOptions(Builder<ServiceRpcT, OptionsT, ?> builder) {
273221
serviceRpcFactory = builder.serviceRpcFactory;
274222
connectTimeout = builder.connectTimeout;
275223
readTimeout = builder.readTimeout;
276-
clock = firstNonNull(builder.clock, Clock.defaultClock());
277224
}
278225

279226
private static AuthCredentials defaultAuthCredentials() {
@@ -472,17 +419,9 @@ public int readTimeout() {
472419
return readTimeout;
473420
}
474421

475-
/**
476-
* Returns the service's clock. Default time source uses {@link System#currentTimeMillis()} to
477-
* get current time.
478-
*/
479-
public Clock clock() {
480-
return clock;
481-
}
482-
483422
protected int baseHashCode() {
484423
return Objects.hash(projectId, host, httpTransportFactory, authCredentials, retryParams,
485-
serviceRpcFactory, connectTimeout, readTimeout, clock);
424+
serviceRpcFactory);
486425
}
487426

488427
protected boolean baseEquals(ServiceOptions<?, ?> other) {
@@ -491,10 +430,7 @@ protected boolean baseEquals(ServiceOptions<?, ?> other) {
491430
&& Objects.equals(httpTransportFactory, other.httpTransportFactory)
492431
&& Objects.equals(authCredentials, other.authCredentials)
493432
&& Objects.equals(retryParams, other.retryParams)
494-
&& Objects.equals(serviceRpcFactory, other.serviceRpcFactory)
495-
&& Objects.equals(connectTimeout, other.connectTimeout)
496-
&& Objects.equals(readTimeout, other.readTimeout)
497-
&& Objects.equals(clock, clock);
433+
&& Objects.equals(serviceRpcFactory, other.serviceRpcFactory);
498434
}
499435

500436
public abstract Builder<ServiceRpcT, OptionsT, ?> toBuilder();

0 commit comments

Comments
 (0)