Skip to content

Commit 1e075c8

Browse files
authored
retry validateOutputFilePrefixSupported for tempLocation (#35574)
* retry validateOutputFilePrefixSupported for tempLocation * fixed tempLocation * fix gcs util
1 parent aeb09c5 commit 1e075c8

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

  • sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/util

sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/util/GcsUtil.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,19 @@ public static GcsUtil create(
207207

208208
private static final FluentBackoff BACKOFF_FACTORY =
209209
FluentBackoff.DEFAULT.withMaxRetries(10).withInitialBackoff(Duration.standardSeconds(1));
210+
private static final RetryDeterminer<IOException> RETRY_DETERMINER =
211+
new RetryDeterminer<IOException>() {
212+
@Override
213+
public boolean shouldRetry(IOException e) {
214+
if (e instanceof GoogleJsonResponseException) {
215+
int statusCode = ((GoogleJsonResponseException) e).getStatusCode();
216+
return statusCode == 408 // Request Timeout
217+
|| statusCode == 429 // Too many requests
218+
|| (statusCode >= 500 && statusCode < 600); // Server errors
219+
}
220+
return RetryDeterminer.SOCKET_ERRORS.shouldRetry(e);
221+
}
222+
};
210223

211224
/////////////////////////////////////////////////////////////////////////////
212225

@@ -863,7 +876,7 @@ public boolean shouldRetry(IOException e) {
863876
if (errorExtractor.itemNotFound(e) || errorExtractor.accessDenied(e)) {
864877
return false;
865878
}
866-
return RetryDeterminer.SOCKET_ERRORS.shouldRetry(e);
879+
return RETRY_DETERMINER.shouldRetry(e);
867880
}
868881
},
869882
IOException.class,
@@ -902,7 +915,7 @@ public boolean shouldRetry(IOException e) {
902915
if (errorExtractor.itemAlreadyExists(e) || errorExtractor.accessDenied(e)) {
903916
return false;
904917
}
905-
return RetryDeterminer.SOCKET_ERRORS.shouldRetry(e);
918+
return RETRY_DETERMINER.shouldRetry(e);
906919
}
907920
},
908921
IOException.class,
@@ -940,7 +953,7 @@ public boolean shouldRetry(IOException e) {
940953
if (errorExtractor.itemNotFound(e) || errorExtractor.accessDenied(e)) {
941954
return false;
942955
}
943-
return RetryDeterminer.SOCKET_ERRORS.shouldRetry(e);
956+
return RETRY_DETERMINER.shouldRetry(e);
944957
}
945958
},
946959
IOException.class,

0 commit comments

Comments
 (0)