Skip to content

Commit 2a95aa1

Browse files
committed
fix rrio optionals
1 parent 528aafc commit 2a95aa1

File tree

2 files changed

+13
-33
lines changed

2 files changed

+13
-33
lines changed

sdks/java/io/rrio/src/main/java/org/apache/beam/io/requestresponse/Call.java

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,14 @@ private void backoffIfNeeded(BackOff backOff, Sleeper sleeper) {
362362
abstract static class Configuration<RequestT, ResponseT> implements Serializable {
363363

364364
static <RequestT, ResponseT> Builder<RequestT, ResponseT> builder() {
365-
return new AutoValue_Call_Configuration.Builder<RequestT, ResponseT>();
365+
return new AutoValue_Call_Configuration.Builder<RequestT, ResponseT>()
366+
.setShouldRepeat(false)
367+
.setTimeout(RequestResponseIO.DEFAULT_TIMEOUT)
368+
.setCallShouldBackoff(new NoopCallShouldBackoff<>())
369+
.setSleeperSupplier((SerializableSupplier<Sleeper>) () -> Sleeper.DEFAULT)
370+
.setBackOffSupplier(new DefaultSerializableBackoffSupplier())
371+
.setMonitoringConfiguration(Monitoring.builder().build())
372+
.setSetupTeardown(new NoopSetupTeardown());
366373
}
367374

368375
/** The user custom code that converts a {@link RequestT} into a {@link ResponseT}. */
@@ -438,7 +445,7 @@ abstract static class Builder<RequestT, ResponseT> {
438445
/** See {@link Configuration#getTimeout}. */
439446
abstract Builder<RequestT, ResponseT> setTimeout(Duration value);
440447

441-
abstract Optional<Duration> getTimeout();
448+
abstract Duration getTimeout();
442449

443450
/** See {@link Configuration#getShouldRepeat}. */
444451
abstract Builder<RequestT, ResponseT> setShouldRepeat(boolean value);
@@ -449,49 +456,25 @@ abstract static class Builder<RequestT, ResponseT> {
449456
abstract Builder<RequestT, ResponseT> setCallShouldBackoff(
450457
CallShouldBackoff<ResponseT> value);
451458

452-
abstract Optional<CallShouldBackoff<ResponseT>> getCallShouldBackoff();
459+
abstract CallShouldBackoff<ResponseT> getCallShouldBackoff();
453460

454461
/** See {@link Configuration#getSleeperSupplier}. */
455462
abstract Builder<RequestT, ResponseT> setSleeperSupplier(SerializableSupplier<Sleeper> value);
456463

457-
abstract Optional<SerializableSupplier<Sleeper>> getSleeperSupplier();
464+
abstract SerializableSupplier<Sleeper> getSleeperSupplier();
458465

459466
/** See {@link Configuration#getBackOffSupplier}. */
460467
abstract Builder<RequestT, ResponseT> setBackOffSupplier(SerializableSupplier<BackOff> value);
461468

462-
abstract Optional<SerializableSupplier<BackOff>> getBackOffSupplier();
469+
abstract SerializableSupplier<BackOff> getBackOffSupplier();
463470

464471
abstract Builder<RequestT, ResponseT> setMonitoringConfiguration(Monitoring value);
465472

466-
abstract Optional<Monitoring> getMonitoringConfiguration();
473+
abstract Monitoring getMonitoringConfiguration();
467474

468475
abstract Configuration<RequestT, ResponseT> autoBuild();
469476

470477
final Configuration<RequestT, ResponseT> build() {
471-
if (!getSetupTeardown().isPresent()) {
472-
setSetupTeardown(new NoopSetupTeardown());
473-
}
474-
475-
if (!getTimeout().isPresent()) {
476-
setTimeout(RequestResponseIO.DEFAULT_TIMEOUT);
477-
}
478-
479-
if (!getCallShouldBackoff().isPresent()) {
480-
setCallShouldBackoff(new NoopCallShouldBackoff<>());
481-
}
482-
483-
if (!getSleeperSupplier().isPresent()) {
484-
setSleeperSupplier((SerializableSupplier<Sleeper>) () -> Sleeper.DEFAULT);
485-
}
486-
487-
if (!getBackOffSupplier().isPresent()) {
488-
setBackOffSupplier(new DefaultSerializableBackoffSupplier());
489-
}
490-
491-
if (!getMonitoringConfiguration().isPresent()) {
492-
setMonitoringConfiguration(Monitoring.builder().build());
493-
}
494-
495478
return autoBuild();
496479
}
497480
}

sdks/java/io/rrio/src/main/java/org/apache/beam/io/requestresponse/Monitoring.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import com.google.auto.value.AutoValue;
2121
import java.io.Serializable;
2222
import java.util.Arrays;
23-
import java.util.Optional;
2423
import org.apache.beam.sdk.metrics.Counter;
2524
import org.apache.beam.sdk.metrics.Metric;
2625
import org.apache.beam.sdk.transforms.DoFn;
@@ -288,8 +287,6 @@ public abstract static class Builder {
288287

289288
public abstract Builder setCountCacheWriteFailures(boolean value);
290289

291-
abstract Optional<Boolean> getCountRequests();
292-
293290
public abstract Monitoring build();
294291
}
295292
}

0 commit comments

Comments
 (0)