Skip to content

Commit 93d90ad

Browse files
SNOW-1991221 retries draft
1 parent 5f9a1a1 commit 93d90ad

File tree

10 files changed

+2379
-2262
lines changed

10 files changed

+2379
-2262
lines changed

src/main/java/net/snowflake/client/core/HttpExecutingContext.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ public class HttpExecutingContext {
4343
int injectSocketTimeout;
4444
boolean retryHTTP403;
4545
boolean shouldRetry;
46+
boolean skipRetriesBecauseOf200; //todo create skip retry reason enum
4647
boolean withoutCookies;
4748
boolean includeRetryParameters;
4849
boolean includeRequestGuid;
50+
boolean unpackResponse;
4951
AtomicBoolean canceling;
5052

5153
public HttpExecutingContext(String requestIdStr, String requestInfoScrubbed) {
@@ -183,7 +185,6 @@ public void resetRetryCount() {
183185
}
184186

185187
public void incrementRetryCount() {
186-
System.out.println("before INCREMENTED " + retryCount);
187188
this.retryCount++;
188189
}
189190

@@ -228,11 +229,6 @@ public void increaseElapsedMilliForTransientIssues(long elapsedMilliForLastCall)
228229
}
229230

230231
public boolean elapsedTimeExceeded() {
231-
System.out.println(
232-
"elapsedTimeExceeded:"
233-
+ (elapsedMilliForTransientIssues > getRetryTimeoutInMilliseconds()));
234-
System.out.println("elapsedTimeExceeded:" + elapsedMilliForTransientIssues);
235-
System.out.println("elapsedTimeExceeded:" + getRetryTimeoutInMilliseconds());
236232
return elapsedMilliForTransientIssues > getRetryTimeoutInMilliseconds();
237233
}
238234

@@ -241,9 +237,6 @@ public boolean moreThanMinRetries() {
241237
}
242238

243239
public boolean maxRetriesExceeded() {
244-
System.out.println("Exceeded maxRetries: " + (maxRetries > 0 && retryCount > maxRetries));
245-
System.out.println("Exceeded maxRetries: " + retryCount);
246-
System.out.println("Exceeded maxRetries: " + maxRetries);
247240
return maxRetries > 0 && retryCount >= maxRetries;
248241
}
249242

@@ -293,7 +286,23 @@ public boolean isIncludeRetryParameters() {
293286
return includeRetryParameters;
294287
}
295288

289+
public boolean isUnpackResponse() {
290+
return unpackResponse;
291+
}
292+
293+
public void setUnpackResponse(boolean unpackResponse) {
294+
this.unpackResponse = unpackResponse;
295+
}
296+
296297
public void setIncludeRetryParameters(boolean includeRetryParameters) {
297298
this.includeRetryParameters = includeRetryParameters;
298299
}
300+
301+
public boolean isSkipRetriesBecauseOf200() {
302+
return skipRetriesBecauseOf200;
303+
}
304+
305+
public void setSkipRetriesBecauseOf200(boolean skipRetriesBecauseOf200) {
306+
this.skipRetriesBecauseOf200 = skipRetriesBecauseOf200;
307+
}
299308
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package net.snowflake.client.core;
2+
3+
import org.apache.http.client.methods.CloseableHttpResponse;
4+
5+
public class HttpResponseContextDto {
6+
7+
private CloseableHttpResponse httpResponse;
8+
private String unpackedCloseableHttpResponse;
9+
private Exception savedEx;
10+
11+
// Constructors
12+
public HttpResponseContextDto() {}
13+
14+
public HttpResponseContextDto(CloseableHttpResponse httpResponse, String unpackedCloseableHttpResponse) {
15+
this.httpResponse = httpResponse;
16+
this.unpackedCloseableHttpResponse = unpackedCloseableHttpResponse;
17+
}
18+
19+
public CloseableHttpResponse getHttpResponse() {
20+
return httpResponse;
21+
}
22+
23+
public void setHttpResponse(CloseableHttpResponse httpResponse) {
24+
this.httpResponse = httpResponse;
25+
}
26+
27+
public String getUnpackedCloseableHttpResponse() {
28+
return unpackedCloseableHttpResponse;
29+
}
30+
31+
public void setUnpackedCloseableHttpResponse(String unpackedCloseableHttpResponse) {
32+
this.unpackedCloseableHttpResponse = unpackedCloseableHttpResponse;
33+
}
34+
35+
public Exception getSavedEx() {
36+
return savedEx;
37+
}
38+
39+
public void setSavedEx(Exception savedEx) {
40+
this.savedEx = savedEx;
41+
}
42+
43+
@Override
44+
public String toString() {
45+
return "CloseableHttpResponseContextDto{" +
46+
"httpResponse=" + httpResponse +
47+
", unpackedCloseableHttpResponse=" + unpackedCloseableHttpResponse +
48+
'}';
49+
}
50+
}

0 commit comments

Comments
 (0)