7
7
import com .squareup .okhttp .Call ;
8
8
import io .kubernetes .client .ApiClient ;
9
9
import io .kubernetes .client .ApiException ;
10
- import io .kubernetes .client .ProgressRequestBody ;
11
- import io .kubernetes .client .ProgressResponseBody ;
12
10
import io .kubernetes .client .apis .BatchV1Api ;
13
11
import io .kubernetes .client .apis .CoreV1Api ;
14
12
import io .kubernetes .client .models .V1ConfigMap ;
@@ -33,6 +31,8 @@ public class WatchBuilder {
33
31
/** Ignored for watches. */
34
32
private static final String START_LIST = null ;
35
33
34
+ private static final int ADDITIONAL_TIMEOUT_FOR_SOCKET = 60 ;
35
+
36
36
private static WatchFactory FACTORY = new WatchFactoryImpl ();
37
37
38
38
private CallParamsImpl callParams = new CallParamsImpl ();
@@ -92,7 +92,7 @@ private class ListNamespacedServiceCall implements BiFunction<ApiClient, CallPar
92
92
@ Override
93
93
public Call apply (ApiClient client , CallParams callParams ) {
94
94
// Ensure that client doesn't time out before call or watch
95
- client .getHttpClient ().setReadTimeout (callParams . getTimeoutSeconds ( ), TimeUnit .SECONDS );
95
+ client .getHttpClient ().setReadTimeout (getSocketTimeout ( callParams ), TimeUnit .SECONDS );
96
96
97
97
try {
98
98
return new CoreV1Api (client )
@@ -137,7 +137,7 @@ private class ListPodCall implements BiFunction<ApiClient, CallParams, Call> {
137
137
@ Override
138
138
public Call apply (ApiClient client , CallParams callParams ) {
139
139
// Ensure that client doesn't time out before call or watch
140
- client .getHttpClient ().setReadTimeout (callParams . getTimeoutSeconds ( ), TimeUnit .SECONDS );
140
+ client .getHttpClient ().setReadTimeout (getSocketTimeout ( callParams ), TimeUnit .SECONDS );
141
141
142
142
try {
143
143
return new CoreV1Api (client )
@@ -182,7 +182,7 @@ private class ListJobCall implements BiFunction<ApiClient, CallParams, Call> {
182
182
@ Override
183
183
public Call apply (ApiClient client , CallParams callParams ) {
184
184
// Ensure that client doesn't time out before call or watch
185
- client .getHttpClient ().setReadTimeout (callParams . getTimeoutSeconds ( ), TimeUnit .SECONDS );
185
+ client .getHttpClient ().setReadTimeout (getSocketTimeout ( callParams ), TimeUnit .SECONDS );
186
186
187
187
try {
188
188
return new BatchV1Api (client )
@@ -227,7 +227,7 @@ private class ListEventCall implements BiFunction<ApiClient, CallParams, Call> {
227
227
@ Override
228
228
public Call apply (ApiClient client , CallParams callParams ) {
229
229
// Ensure that client doesn't time out before call or watch
230
- client .getHttpClient ().setReadTimeout (callParams . getTimeoutSeconds ( ), TimeUnit .SECONDS );
230
+ client .getHttpClient ().setReadTimeout (getSocketTimeout ( callParams ), TimeUnit .SECONDS );
231
231
232
232
try {
233
233
return new CoreV1Api (client )
@@ -272,7 +272,7 @@ private class ListDomainsCall implements BiFunction<ApiClient, CallParams, Call>
272
272
@ Override
273
273
public Call apply (ApiClient client , CallParams callParams ) {
274
274
// Ensure that client doesn't time out before call or watch
275
- client .getHttpClient ().setReadTimeout (callParams . getTimeoutSeconds ( ), TimeUnit .SECONDS );
275
+ client .getHttpClient ().setReadTimeout (getSocketTimeout ( callParams ), TimeUnit .SECONDS );
276
276
277
277
try {
278
278
return new WeblogicApi (client )
@@ -320,7 +320,7 @@ private class ListNamespacedConfigMapCall implements BiFunction<ApiClient, CallP
320
320
@ Override
321
321
public Call apply (ApiClient client , CallParams callParams ) {
322
322
// Ensure that client doesn't time out before call or watch
323
- client .getHttpClient ().setReadTimeout (callParams . getTimeoutSeconds ( ), TimeUnit .SECONDS );
323
+ client .getHttpClient ().setReadTimeout (getSocketTimeout ( callParams ), TimeUnit .SECONDS );
324
324
325
325
try {
326
326
return new CoreV1Api (client )
@@ -343,6 +343,10 @@ public Call apply(ApiClient client, CallParams callParams) {
343
343
}
344
344
}
345
345
346
+ private Integer getSocketTimeout (CallParams callParams ) {
347
+ return callParams .getTimeoutSeconds () + ADDITIONAL_TIMEOUT_FOR_SOCKET ;
348
+ }
349
+
346
350
/**
347
351
* Sets a value for the fieldSelector parameter for the call that will set up this watch. Defaults
348
352
* to null.
@@ -355,7 +359,8 @@ public WatchBuilder withFieldSelector(String fieldSelector) {
355
359
return this ;
356
360
}
357
361
358
- public WatchBuilder withIncludeUninitialized (Boolean includeUninitialized ) {
362
+ @ SuppressWarnings ("SameParameterValue" )
363
+ WatchBuilder withIncludeUninitialized (Boolean includeUninitialized ) {
359
364
callParams .setIncludeUninitialized (includeUninitialized );
360
365
return this ;
361
366
}
@@ -370,16 +375,12 @@ public WatchBuilder withLabelSelectors(String... labelSelectors) {
370
375
return this ;
371
376
}
372
377
373
- public WatchBuilder withLimit (Integer limit ) {
378
+ @ SuppressWarnings ("SameParameterValue" )
379
+ WatchBuilder withLimit (Integer limit ) {
374
380
callParams .setLimit (limit );
375
381
return this ;
376
382
}
377
383
378
- public WatchBuilder withPrettyPrinting () {
379
- callParams .setPretty ("true" );
380
- return this ;
381
- }
382
-
383
384
public WatchBuilder withResourceVersion (String resourceVersion ) {
384
385
callParams .setResourceVersion (resourceVersion );
385
386
return this ;
@@ -390,17 +391,6 @@ public WatchBuilder withTimeoutSeconds(Integer timeoutSeconds) {
390
391
return this ;
391
392
}
392
393
393
- public WatchBuilder withProgressListener (ProgressResponseBody .ProgressListener progressListener ) {
394
- callParams .setProgressListener (progressListener );
395
- return this ;
396
- }
397
-
398
- public WatchBuilder withProgressRequestListener (
399
- ProgressRequestBody .ProgressRequestListener progressRequestListener ) {
400
- callParams .setProgressRequestListener (progressRequestListener );
401
- return this ;
402
- }
403
-
404
394
static class WatchFactoryImpl implements WatchFactory {
405
395
@ Override
406
396
public <T > WatchI <T > createWatch (
@@ -411,7 +401,7 @@ public <T> WatchI<T> createWatch(
411
401
throws ApiException {
412
402
ApiClient client = pool .take ();
413
403
try {
414
- return new WatchImpl <T >(
404
+ return new WatchImpl <>(
415
405
pool ,
416
406
client ,
417
407
Watch .createWatch (
0 commit comments