Skip to content

Commit 51d7a64

Browse files
committed
---
yaml --- r: 2977 b: refs/heads/dns-alpha-batch c: 9b6929b h: refs/heads/master i: 2975: 074e28f
1 parent 912bdc0 commit 51d7a64

7 files changed

Lines changed: 24 additions & 927 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ refs/tags/v0.0.11: ffbfba48a6426ff63c08ff2117e58681f251fbf2
1212
refs/tags/v0.0.12: 2fd8066e891fb3dfea69b65f6bf6461db79342b9
1313
refs/heads/compute-alpha: b1274b5bdf4eea955f3588b56378a5ae4ba59cef
1414
refs/heads/dns-alpha: 2f90e7e338349287ace33375896907af0f032ca1
15-
refs/heads/dns-alpha-batch: 44b19985a2e375d4a433e8dc31f309d1d51fa4ff
15+
refs/heads/dns-alpha-batch: 9b6929bbfdc9dc376fd52464f1df0cda4b5da7e3

branches/dns-alpha-batch/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ static String selector(ProjectField... fields) {
6868
* The fields of a zone.
6969
*
7070
* <p>These values can be used to specify the fields to include in a partial response when calling
71-
* {@link Dns#getZone(String, ZoneOption...)}. The name is always returned, even if not
72-
* specified.
71+
* {@link Dns#getZone(String, ZoneOption...)}. The name is always returned, even if not specified.
7372
*/
7473
enum ZoneField {
7574
CREATION_TIME("creationTime"),
@@ -104,8 +103,8 @@ static String selector(ZoneField... fields) {
104103
* The fields of a DNS record.
105104
*
106105
* <p>These values can be used to specify the fields to include in a partial response when calling
107-
* {@link Dns#listDnsRecords(String, DnsRecordListOption...)}. The name and type are always
108-
* returned even if not selected.
106+
* {@link Dns#listDnsRecords(String, DnsRecordListOption...)}. The name is always returned even if
107+
* not selected.
109108
*/
110109
enum DnsRecordField {
111110
DNS_RECORDS("rrdatas"),
@@ -126,7 +125,6 @@ String selector() {
126125
static String selector(DnsRecordField... fields) {
127126
Set<String> fieldStrings = Sets.newHashSetWithExpectedSize(fields.length + 1);
128127
fieldStrings.add(NAME.selector());
129-
fieldStrings.add(TYPE.selector());
130128
for (DnsRecordField field : fields) {
131129
fieldStrings.add(field.selector());
132130
}
@@ -200,7 +198,7 @@ class DnsRecordListOption extends AbstractOption implements Serializable {
200198
*/
201199
public static DnsRecordListOption fields(DnsRecordField... fields) {
202200
StringBuilder builder = new StringBuilder();
203-
builder.append("nextPageToken,rrsets(").append(DnsRecordField.selector(fields)).append(')');
201+
builder.append("rrsets(").append(DnsRecordField.selector(fields)).append(')');
204202
return new DnsRecordListOption(DnsRpc.Option.FIELDS, builder.toString());
205203
}
206204

@@ -236,7 +234,7 @@ public static DnsRecordListOption dnsName(String dnsName) {
236234
* Dns.DnsRecordListOption#dnsName(String)} must also be present.
237235
*/
238236
public static DnsRecordListOption type(DnsRecord.Type type) {
239-
return new DnsRecordListOption(DnsRpc.Option.DNS_TYPE, type.name());
237+
return new DnsRecordListOption(DnsRpc.Option.DNS_TYPE, type);
240238
}
241239
}
242240

@@ -283,7 +281,7 @@ class ZoneListOption extends AbstractOption implements Serializable {
283281
*/
284282
public static ZoneListOption fields(ZoneField... fields) {
285283
StringBuilder builder = new StringBuilder();
286-
builder.append("nextPageToken,managedZones(").append(ZoneField.selector(fields)).append(')');
284+
builder.append("managedZones(").append(ZoneField.selector(fields)).append(')');
287285
return new ZoneListOption(DnsRpc.Option.FIELDS, builder.toString());
288286
}
289287

@@ -390,8 +388,7 @@ class ChangeRequestListOption extends AbstractOption implements Serializable {
390388
*/
391389
public static ChangeRequestListOption fields(ChangeRequestField... fields) {
392390
StringBuilder builder = new StringBuilder();
393-
builder.append("nextPageToken,changes(").append(ChangeRequestField.selector(fields))
394-
.append(')');
391+
builder.append("changes(").append(ChangeRequestField.selector(fields)).append(')');
395392
return new ChangeRequestListOption(DnsRpc.Option.FIELDS, builder.toString());
396393
}
397394

branches/dns-alpha-batch/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,39 @@
1616

1717
package com.google.gcloud.dns;
1818

19+
import com.google.common.collect.ImmutableSet;
1920
import com.google.gcloud.BaseServiceException;
2021
import com.google.gcloud.RetryHelper.RetryHelperException;
2122
import com.google.gcloud.RetryHelper.RetryInterruptedException;
2223

2324
import java.io.IOException;
25+
import java.util.Set;
2426

2527
/**
2628
* DNS service exception.
2729
*/
2830
public class DnsException extends BaseServiceException {
2931

32+
// see: https://cloud.google.com/dns/troubleshooting
33+
private static final Set<Error> RETRYABLE_ERRORS = ImmutableSet.of(
34+
new Error(500, null),
35+
new Error(502, null),
36+
new Error(503, null));
3037
private static final long serialVersionUID = 490302380416260252L;
3138

3239
public DnsException(IOException exception) {
3340
super(exception, true);
3441
}
3542

36-
public DnsException(int code, String message) {
43+
private DnsException(int code, String message) {
3744
super(code, message, null, true);
3845
}
3946

47+
@Override
48+
protected Set<Error> retryableErrors() {
49+
return RETRYABLE_ERRORS;
50+
}
51+
4052
/**
4153
* Translate RetryHelperException to the DnsException that caused the error. This method will
4254
* always throw an exception.
@@ -48,6 +60,4 @@ static DnsException translateAndThrow(RetryHelperException ex) {
4860
BaseServiceException.translateAndPropagateIfPossible(ex);
4961
throw new DnsException(UNKNOWN_CODE, ex.getMessage());
5062
}
51-
52-
//TODO(mderka) Add translation and retry functionality. Created issue #593.
5363
}

branches/dns-alpha-batch/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,7 @@ public Change getChangeRequest(String zoneName, String changeRequestId, Map<Opti
162162
} catch (IOException ex) {
163163
DnsException serviceException = translate(ex);
164164
if (serviceException.code() == HTTP_NOT_FOUND) {
165-
if ("entity.parameters.changeId".equals(serviceException.location())
166-
|| (serviceException.getMessage() != null
167-
&& serviceException.getMessage().contains("parameters.changeId"))) {
165+
if (serviceException.location().equals("entity.parameters.changeId")) {
168166
// the change id was not found, but the zone exists
169167
return null;
170168
}

branches/dns-alpha-batch/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ public void testListDnsRecordsWithOptions() {
368368
assertTrue(selector.contains(Dns.DnsRecordField.TTL.selector()));
369369
selector = (String) capturedOptions.getValue().get(DNS_RECORD_LIST_OPTIONS[3].rpcOption());
370370
assertEquals(DNS_RECORD_LIST_OPTIONS[3].value(), selector);
371-
String type = (String) capturedOptions.getValue().get(DNS_RECORD_LIST_OPTIONS[4]
371+
DnsRecord.Type type = (DnsRecord.Type) capturedOptions.getValue().get(DNS_RECORD_LIST_OPTIONS[4]
372372
.rpcOption());
373373
assertEquals(DNS_RECORD_LIST_OPTIONS[4].value(), type);
374374
}

branches/dns-alpha-batch/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void testDnsRecordListOption() {
4747
// record type
4848
DnsRecord.Type recordType = DnsRecord.Type.AAAA;
4949
dnsRecordListOption = Dns.DnsRecordListOption.type(recordType);
50-
assertEquals(recordType.name(), dnsRecordListOption.value());
50+
assertEquals(recordType, dnsRecordListOption.value());
5151
assertEquals(DnsRpc.Option.DNS_TYPE, dnsRecordListOption.rpcOption());
5252
// fields
5353
dnsRecordListOption = Dns.DnsRecordListOption.fields(Dns.DnsRecordField.NAME,

0 commit comments

Comments
 (0)