Skip to content

Commit faaaee0

Browse files
author
Ajay Kannan
committed
---
yaml --- r: 6257 b: refs/heads/tswast-patch-1 c: eac140a h: refs/heads/master i: 6255: 3d1444c
1 parent 203e88f commit faaaee0

5 files changed

Lines changed: 30 additions & 122 deletions

File tree

[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: 89dafeafc8625058c697e03995c087831c8929fd
60+
refs/heads/tswast-patch-1: eac140ad429179cfef8d90a34cf6d429b7e80983
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

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

Lines changed: 1 addition & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import static java.nio.charset.StandardCharsets.UTF_8;
2323

2424
import com.google.api.client.extensions.appengine.http.UrlFetchTransport;
25-
import com.google.api.client.http.HttpRequest;
2625
import com.google.api.client.http.HttpRequestInitializer;
2726
import com.google.api.client.http.HttpTransport;
2827
import com.google.api.client.http.javanet.NetHttpTransport;
@@ -61,8 +60,6 @@ public abstract class ServiceOptions<
6160
private final AuthCredentials authCredentials;
6261
private final RetryParams retryParams;
6362
private final ServiceRpcFactory<ServiceRpcT, OptionsT> serviceRpcFactory;
64-
private final int connectTimeout;
65-
private final int readTimeout;
6663

6764
public interface HttpTransportFactory extends Serializable {
6865
HttpTransport create();
@@ -105,8 +102,6 @@ protected abstract static class Builder<
105102
private AuthCredentials authCredentials;
106103
private RetryParams retryParams;
107104
private ServiceRpcFactory<ServiceRpcT, OptionsT> serviceRpcFactory;
108-
private int connectTimeout = -1;
109-
private int readTimeout = -1;
110105

111106
protected Builder() {}
112107

@@ -126,89 +121,35 @@ protected B self() {
126121
return (B) this;
127122
}
128123

129-
/**
130-
* Sets project id.
131-
*
132-
* @return the builder.
133-
*/
134124
public B projectId(String projectId) {
135125
this.projectId = projectId;
136126
return self();
137127
}
138128

139-
/**
140-
* Sets service host.
141-
*
142-
* @return the builder.
143-
*/
144129
public B host(String host) {
145130
this.host = host;
146131
return self();
147132
}
148133

149-
/**
150-
* Sets the transport factory.
151-
*
152-
* @return the builder.
153-
*/
154134
public B httpTransportFactory(HttpTransportFactory httpTransportFactory) {
155135
this.httpTransportFactory = httpTransportFactory;
156136
return self();
157137
}
158138

159-
/**
160-
* Sets the service authentication credentials.
161-
*
162-
* @return the builder.
163-
*/
164139
public B authCredentials(AuthCredentials authCredentials) {
165140
this.authCredentials = authCredentials;
166141
return self();
167142
}
168143

169-
/**
170-
* Sets configuration parameters for request retries.
171-
*
172-
* @return the builder.
173-
*/
174144
public B retryParams(RetryParams retryParams) {
175145
this.retryParams = retryParams;
176146
return self();
177147
}
178148

179-
/**
180-
* Sets the factory for rpc services.
181-
*
182-
* @return the builder
183-
*/
184149
public B serviceRpcFactory(ServiceRpcFactory<ServiceRpcT, OptionsT> serviceRpcFactory) {
185150
this.serviceRpcFactory = serviceRpcFactory;
186151
return self();
187152
}
188-
189-
/**
190-
* Sets the timeout in milliseconds to establish a connection.
191-
*
192-
* @param connectTimeout connection timeout in milliseconds. 0 for an infinite timeout, a
193-
* negative number for the default value (20000).
194-
* @return the builder.
195-
*/
196-
public B connectTimeout(int connectTimeout) {
197-
this.connectTimeout = connectTimeout;
198-
return self();
199-
}
200-
201-
/**
202-
* Sets the timeout in milliseconds to read data from an established connection.
203-
*
204-
* @param readTimeout read timeout in milliseconds. 0 for an infinite timeout, a
205-
* negative number for the default value (20000).
206-
* @return the builder.
207-
*/
208-
public B readTimeout(int readTimeout) {
209-
this.readTimeout = readTimeout;
210-
return self();
211-
}
212153
}
213154

214155
protected ServiceOptions(Builder<ServiceRpcT, OptionsT, ?> builder) {
@@ -219,8 +160,6 @@ protected ServiceOptions(Builder<ServiceRpcT, OptionsT, ?> builder) {
219160
authCredentials = firstNonNull(builder.authCredentials, defaultAuthCredentials());
220161
retryParams = builder.retryParams;
221162
serviceRpcFactory = builder.serviceRpcFactory;
222-
connectTimeout = builder.connectTimeout;
223-
readTimeout = builder.readTimeout;
224163
}
225164

226165
private static AuthCredentials defaultAuthCredentials() {
@@ -338,84 +277,33 @@ protected static String getAppEngineProjectId() {
338277

339278
protected abstract Set<String> scopes();
340279

341-
/**
342-
* Returns the project id.
343-
*/
344280
public String projectId() {
345281
return projectId;
346282
}
347283

348-
/**
349-
* Returns the service host.
350-
*/
351284
public String host() {
352285
return host;
353286
}
354287

355-
/**
356-
* Returns the transport factory.
357-
*/
358288
public HttpTransportFactory httpTransportFactory() {
359289
return httpTransportFactory;
360290
}
361291

362-
/**
363-
* Returns the authentication credentials.
364-
*/
365292
public AuthCredentials authCredentials() {
366293
return authCredentials;
367294
}
368295

369-
/**
370-
* Returns configuration parameters for request retries.
371-
*/
372296
public RetryParams retryParams() {
373297
return retryParams != null ? retryParams : RetryParams.noRetries();
374298
}
375299

376-
/**
377-
* Returns the factory for rpc services.
378-
*/
379300
public ServiceRpcFactory<ServiceRpcT, OptionsT> serviceRpcFactory() {
380301
return serviceRpcFactory;
381302
}
382303

383-
/**
384-
* Returns a request initializer responsible for initializing requests according to service
385-
* options.
386-
*/
387304
public HttpRequestInitializer httpRequestInitializer() {
388305
HttpTransport httpTransport = httpTransportFactory.create();
389-
final HttpRequestInitializer baseRequestInitializer =
390-
authCredentials().httpRequestInitializer(httpTransport, scopes());
391-
return new HttpRequestInitializer() {
392-
@Override
393-
public void initialize(HttpRequest httpRequest) throws IOException {
394-
baseRequestInitializer.initialize(httpRequest);
395-
if (connectTimeout >= 0) {
396-
httpRequest.setConnectTimeout(connectTimeout);
397-
}
398-
if (readTimeout >= 0) {
399-
httpRequest.setReadTimeout(readTimeout);
400-
}
401-
}
402-
};
403-
}
404-
405-
/**
406-
* Returns the timeout in milliseconds to establish a connection. 0 is an infinite timeout, a
407-
* negative number is the default value (20000).
408-
*/
409-
public int connectTimeout() {
410-
return connectTimeout;
411-
}
412-
413-
/**
414-
* Returns the timeout in milliseconds to read from an established connection. 0 is an infinite
415-
* timeout, a negative number is the default value (20000).
416-
*/
417-
public int readTimeout() {
418-
return readTimeout;
306+
return authCredentials().httpRequestInitializer(httpTransport, scopes());
419307
}
420308

421309
protected int baseHashCode() {

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,33 @@ Add this to your pom.xml file
2020
</dependency>
2121
```
2222

23+
To run examples from your command line:
24+
25+
1. Login using gcloud SDK (`gcloud auth login` in command line)
26+
27+
2. Compile using Maven (`mvn compile` in command line from your base project directory)
28+
29+
3. Run an example using Maven from command line.
30+
31+
Here's an example run of `DatastoreExample`.
32+
33+
Note that you have to enable the Google Cloud Datastore API on the [Google Developers Console][developers-console] before running the following commands.
34+
```
35+
$mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DatastoreExample" -Dexec.args="[<project_id>] [user] add my\ comment"
36+
$mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DatastoreExample" -Dexec.args="[<project_id>] [user] display"
37+
$mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DatastoreExample" -Dexec.args="[<project_id>] [user] delete"
38+
```
39+
40+
Here's an example run of `StorageExample`.
41+
42+
Before running the example, go to the [Google Developers Console][developers-console] to ensure that Google Cloud Storage API is enabled and that you have a bucket. Also ensure that you have a test file (`test.txt` is chosen here) to upload to Cloud Storage stored locally on your machine.
43+
```
44+
$mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.StorageExample" -Dexec.args="<project_id> upload /path/to/test.txt <bucket_name>"
45+
$mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.StorageExample" -Dexec.args="<project_id> list <bucket_name>"
46+
$mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.StorageExample" -Dexec.args="<project_id> download <bucket_name> test.txt"
47+
$mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.StorageExample" -Dexec.args="<project_id> delete <bucket_name> test.txt"
48+
```
49+
2350
Contributing
2451
------------
2552

@@ -50,3 +77,4 @@ Apache 2.0 - See [LICENSE] for more information.
5077
[CONTRIBUTING]:https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/CONTRIBUTING.md
5178
[LICENSE]: https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/LICENSE
5279
[cloud-platform]: https://cloud.google.com/
80+
[developers-console]:https://console.developers.google.com/

branches/tswast-patch-1/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -632,15 +632,9 @@ public static Builder builder() {
632632
* is only valid within a certain time period.
633633
* This is particularly useful if you don't want publicly
634634
* accessible blobs, but don't want to require users to explicitly log in.
635-
* <p>
636-
* Example usage of creating a signed URL that is valid for 2 weeks:
637-
* <pre> {@code
638-
* service.signUrl(BlobInfo.of("bucket", "name"), TimeUnit.DAYS.toSeconds(14));
639-
* }</pre>
640635
*
641636
* @param blobInfo the blob associated with the signed url
642637
* @param expirationTimeInSeconds the signed URL expiration (using epoch time)
643-
* @param options optional URL signing options
644638
* @see <a href="https://cloud.google.com/storage/docs/access-control#Signed-URLs">Signed-URLs</a>
645639
*/
646640
URL signUrl(BlobInfo blobInfo, long expirationTimeInSeconds, SignUrlOption... options);

branches/tswast-patch-1/gcloud-java-storage/src/main/java/com/google/gcloud/storage/testing/RemoteGcsHelper.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ public static RemoteGcsHelper create(String projectId, String keyPath, Option...
133133
.totalRetryPeriodMillis(120000)
134134
.initialRetryDelayMillis(250)
135135
.build())
136-
.connectTimeout(60000)
137-
.readTimeout(60000)
138136
.build();
139137
return new RemoteGcsHelper(storageOptions);
140138
} catch (FileNotFoundException ex) {

0 commit comments

Comments
 (0)