Skip to content

Commit

Permalink
Use an ImmutableMap instead of a HashMap for retry times.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 545652311
Change-Id: I37f455adfe5e29e2e0109856c004b7575a99fc05
  • Loading branch information
meisterT authored and copybara-github committed Jul 5, 2023
1 parent d426b3d commit 2bba03b
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -69,8 +70,9 @@ public static SpawnMetrics forLocalExecution(int wallTimeInMs) {
private final int executionWallTimeInMs;
private final int processOutputsTimeInMs;
private final int networkTimeInMs;

// error code to duration in ms
private final Map<Integer, Integer> retryTimeInMs;
private final ImmutableMap<Integer, Integer> retryTimeInMs;
private final long inputBytes;
private final long inputFiles;
private final long memoryEstimateBytes;
Expand All @@ -91,7 +93,7 @@ private SpawnMetrics(Builder builder) {
this.setupTimeInMs = builder.setupTimeInMs;
this.uploadTimeInMs = builder.uploadTimeInMs;
this.executionWallTimeInMs = builder.executionWallTimeInMs;
this.retryTimeInMs = builder.retryTimeInMs;
this.retryTimeInMs = ImmutableMap.copyOf(builder.retryTimeInMs);
this.processOutputsTimeInMs = builder.processOutputsTimeInMs;
this.inputBytes = builder.inputBytes;
this.inputFiles = builder.inputFiles;
Expand Down Expand Up @@ -436,8 +438,8 @@ public Builder addRetryTimeInMs(int errorCode, int retryTimeInMs) {
}

@CanIgnoreReturnValue
public Builder setRetryTimeInMs(Map<Integer, Integer> retryTimeInMs) {
this.retryTimeInMs = new HashMap<>(retryTimeInMs);
public Builder setRetryTimeInMs(ImmutableMap<Integer, Integer> retryTimeInMs) {
this.retryTimeInMs = retryTimeInMs;
return this;
}

Expand Down

0 comments on commit 2bba03b

Please sign in to comment.