Feature flag the default max backoff interval.
This commit is contained in:
parent
c95f0fce6e
commit
93e9dd6425
4 changed files with 14 additions and 5 deletions
|
@ -7,6 +7,7 @@ import androidx.annotation.Nullable;
|
|||
import androidx.annotation.WorkerThread;
|
||||
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -340,7 +341,7 @@ public abstract class Job {
|
|||
}
|
||||
|
||||
Builder(@NonNull String id) {
|
||||
this(id, System.currentTimeMillis(), TimeUnit.SECONDS.toMillis(30), IMMORTAL, 1, UNLIMITED, UNLIMITED, null, new LinkedList<>(), null, false);
|
||||
this(id, System.currentTimeMillis(), TimeUnit.SECONDS.toMillis(FeatureFlags.getDefaultMaxBackoffSeconds()), IMMORTAL, 1, UNLIMITED, UNLIMITED, null, new LinkedList<>(), null, false);
|
||||
}
|
||||
|
||||
private Builder(@NonNull String id,
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.thoughtcrime.securesms.jobmanager.persistence.FullSpec;
|
|||
import org.thoughtcrime.securesms.jobmanager.persistence.JobSpec;
|
||||
import org.thoughtcrime.securesms.jobmanager.persistence.JobStorage;
|
||||
import org.thoughtcrime.securesms.util.Debouncer;
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
@ -25,6 +26,7 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Manages the queue of jobs. This is the only class that should write to {@link JobStorage} to
|
||||
|
@ -161,7 +163,7 @@ class JobController {
|
|||
@WorkerThread
|
||||
synchronized void onRetry(@NonNull Job job) {
|
||||
int nextRunAttempt = job.getRunAttempt() + 1;
|
||||
long nextRunAttemptTime = calculateNextRunAttemptTime(System.currentTimeMillis(), nextRunAttempt, job.getParameters().getMaxBackoff());
|
||||
long nextRunAttemptTime = calculateNextRunAttemptTime(System.currentTimeMillis(), nextRunAttempt, TimeUnit.SECONDS.toMillis(FeatureFlags.getDefaultMaxBackoffSeconds()));
|
||||
String serializedData = dataSerializer.serialize(job.serialize());
|
||||
|
||||
jobStorage.updateJobAfterRetry(job.getId(), false, nextRunAttempt, nextRunAttemptTime, serializedData);
|
||||
|
|
|
@ -37,7 +37,6 @@ public final class RegistrationPinV2MigrationJob extends BaseJob {
|
|||
.addConstraint(NetworkConstraint.KEY)
|
||||
.setLifespan(Job.Parameters.IMMORTAL)
|
||||
.setMaxAttempts(Job.Parameters.UNLIMITED)
|
||||
.setMaxBackoff(TimeUnit.HOURS.toMillis(2))
|
||||
.build());
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ public final class FeatureFlags {
|
|||
private static final String CUSTOM_VIDEO_MUXER = "android.customVideoMuxer";
|
||||
private static final String CDS_REFRESH_INTERVAL = "cds.syncInterval.seconds";
|
||||
private static final String AUTOMATIC_SESSION_RESET = "android.automaticSessionReset";
|
||||
private static final String DEFAULT_MAX_BACKOFF = "android.defaultMaxBackoff";
|
||||
|
||||
/**
|
||||
* We will only store remote values for flags in this set. If you want a flag to be controllable
|
||||
|
@ -92,7 +93,8 @@ public final class FeatureFlags {
|
|||
CUSTOM_VIDEO_MUXER,
|
||||
CDS_REFRESH_INTERVAL,
|
||||
GROUP_NAME_MAX_LENGTH,
|
||||
AUTOMATIC_SESSION_RESET
|
||||
AUTOMATIC_SESSION_RESET,
|
||||
DEFAULT_MAX_BACKOFF
|
||||
);
|
||||
|
||||
@VisibleForTesting
|
||||
|
@ -127,7 +129,8 @@ public final class FeatureFlags {
|
|||
CUSTOM_VIDEO_MUXER,
|
||||
CDS_REFRESH_INTERVAL,
|
||||
GROUP_NAME_MAX_LENGTH,
|
||||
AUTOMATIC_SESSION_RESET
|
||||
AUTOMATIC_SESSION_RESET,
|
||||
DEFAULT_MAX_BACKOFF
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -293,6 +296,10 @@ public final class FeatureFlags {
|
|||
return getBoolean(AUTOMATIC_SESSION_RESET, true);
|
||||
}
|
||||
|
||||
public static int getDefaultMaxBackoffSeconds() {
|
||||
return getInteger(DEFAULT_MAX_BACKOFF, 60);
|
||||
}
|
||||
|
||||
/** Only for rendering debug info. */
|
||||
public static synchronized @NonNull Map<String, Object> getMemoryValues() {
|
||||
return new TreeMap<>(REMOTE_VALUES);
|
||||
|
|
Loading…
Add table
Reference in a new issue