Move the JobDatabase to a separate physical database.

Also removes maxInstancesPerFactory from DB, which was only used during job submission and had no need to be persisted.
This commit is contained in:
Greyson Parrelli
2021-01-06 10:56:05 -05:00
committed by Alan Evans
parent 198281aa47
commit 01152ead61
13 changed files with 205 additions and 100 deletions

View File

@@ -355,7 +355,6 @@ class JobController {
job.getParameters().getMaxAttempts(),
job.getParameters().getMaxBackoff(),
job.getParameters().getLifespan(),
job.getParameters().getMaxInstancesForFactory(),
dataSerializer.serialize(job.serialize()),
null,
false,
@@ -469,7 +468,6 @@ class JobController {
jobSpec.getMaxAttempts(),
jobSpec.getMaxBackoff(),
jobSpec.getLifespan(),
jobSpec.getMaxInstancesForFactory(),
jobSpec.getSerializedData(),
dataSerializer.serialize(inputData),
jobSpec.isRunning(),

View File

@@ -71,7 +71,6 @@ public class JobMigrator {
jobSpec.getMaxAttempts(),
jobSpec.getMaxBackoff(),
jobSpec.getLifespan(),
jobSpec.getMaxInstancesForFactory(),
dataSerializer.serialize(updatedJobData.getData()),
jobSpec.getSerializedInputData(),
jobSpec.isRunning(),

View File

@@ -18,7 +18,6 @@ public final class JobSpec {
private final int maxAttempts;
private final long maxBackoff;
private final long lifespan;
private final int maxInstances;
private final String serializedData;
private final String serializedInputData;
private final boolean isRunning;
@@ -33,7 +32,6 @@ public final class JobSpec {
int maxAttempts,
long maxBackoff,
long lifespan,
int maxInstances,
@NonNull String serializedData,
@Nullable String serializedInputData,
boolean isRunning,
@@ -48,7 +46,6 @@ public final class JobSpec {
this.runAttempt = runAttempt;
this.maxAttempts = maxAttempts;
this.lifespan = lifespan;
this.maxInstances = maxInstances;
this.serializedData = serializedData;
this.serializedInputData = serializedInputData;
this.isRunning = isRunning;
@@ -87,10 +84,6 @@ public final class JobSpec {
return maxBackoff;
}
public int getMaxInstancesForFactory() {
return maxInstances;
}
public long getLifespan() {
return lifespan;
}
@@ -122,7 +115,6 @@ public final class JobSpec {
maxAttempts == jobSpec.maxAttempts &&
maxBackoff == jobSpec.maxBackoff &&
lifespan == jobSpec.lifespan &&
maxInstances == jobSpec.maxInstances &&
isRunning == jobSpec.isRunning &&
memoryOnly == jobSpec.memoryOnly &&
Objects.equals(id, jobSpec.id) &&
@@ -134,13 +126,13 @@ public final class JobSpec {
@Override
public int hashCode() {
return Objects.hash(id, factoryKey, queueKey, createTime, nextRunAttemptTime, runAttempt, maxAttempts, maxBackoff, lifespan, maxInstances, serializedData, serializedInputData, isRunning, memoryOnly);
return Objects.hash(id, factoryKey, queueKey, createTime, nextRunAttemptTime, runAttempt, maxAttempts, maxBackoff, lifespan, serializedData, serializedInputData, isRunning, memoryOnly);
}
@SuppressLint("DefaultLocale")
@Override
public @NonNull String toString() {
return String.format("id: JOB::%s | factoryKey: %s | queueKey: %s | createTime: %d | nextRunAttemptTime: %d | runAttempt: %d | maxAttempts: %d | maxBackoff: %d | maxInstances: %d | lifespan: %d | isRunning: %b | memoryOnly: %b",
id, factoryKey, queueKey, createTime, nextRunAttemptTime, runAttempt, maxAttempts, maxBackoff, maxInstances, lifespan, isRunning, memoryOnly);
return String.format("id: JOB::%s | factoryKey: %s | queueKey: %s | createTime: %d | nextRunAttemptTime: %d | runAttempt: %d | maxAttempts: %d | maxBackoff: %d | lifespan: %d | isRunning: %b | memoryOnly: %b",
id, factoryKey, queueKey, createTime, nextRunAttemptTime, runAttempt, maxAttempts, maxBackoff, lifespan, isRunning, memoryOnly);
}
}

View File

@@ -67,7 +67,6 @@ final class WorkManagerDatabase extends SQLiteOpenHelper {
Job.Parameters.UNLIMITED,
TimeUnit.SECONDS.toMillis(30),
TimeUnit.DAYS.toMillis(1),
Job.Parameters.UNLIMITED,
dataSerializer.serialize(DataMigrator.convert(data)),
null,
false,