Use task builder instead of creating persistent tasks directly.
This commit is contained in:
parent
abd9ae399c
commit
4771965931
|
@ -499,7 +499,6 @@ public final class PersistentTasksCustomMetaData extends AbstractNamedDiffable<M
|
|||
return lastAllocationId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.field("last_allocation_id", lastAllocationId);
|
||||
|
@ -524,10 +523,10 @@ public final class PersistentTasksCustomMetaData extends AbstractNamedDiffable<M
|
|||
private long lastAllocationId;
|
||||
private boolean changed;
|
||||
|
||||
public Builder() {
|
||||
private Builder() {
|
||||
}
|
||||
|
||||
public Builder(PersistentTasksCustomMetaData tasksInProgress) {
|
||||
private Builder(PersistentTasksCustomMetaData tasksInProgress) {
|
||||
if (tasksInProgress != null) {
|
||||
tasks.putAll(tasksInProgress.tasks);
|
||||
lastAllocationId = tasksInProgress.lastAllocationId;
|
||||
|
@ -536,6 +535,10 @@ public final class PersistentTasksCustomMetaData extends AbstractNamedDiffable<M
|
|||
}
|
||||
}
|
||||
|
||||
public long getLastAllocationId() {
|
||||
return lastAllocationId;
|
||||
}
|
||||
|
||||
private Builder setLastAllocationId(long currentId) {
|
||||
this.lastAllocationId = currentId;
|
||||
return this;
|
||||
|
|
|
@ -87,7 +87,7 @@ public class PersistentTasksCustomMetaDataTests extends AbstractDiffableSerializ
|
|||
|
||||
@Override
|
||||
protected Custom makeTestChanges(Custom testInstance) {
|
||||
Builder builder = new Builder((PersistentTasksCustomMetaData) testInstance);
|
||||
Builder builder = PersistentTasksCustomMetaData.builder((PersistentTasksCustomMetaData) testInstance);
|
||||
switch (randomInt(3)) {
|
||||
case 0:
|
||||
addRandomTask(builder);
|
||||
|
@ -209,9 +209,9 @@ public class PersistentTasksCustomMetaDataTests extends AbstractDiffableSerializ
|
|||
for (int i = 0; i < randomIntBetween(10, 100); i++) {
|
||||
final Builder builder;
|
||||
if (randomBoolean()) {
|
||||
builder = new Builder();
|
||||
builder = PersistentTasksCustomMetaData.builder();
|
||||
} else {
|
||||
builder = new Builder(persistentTasks);
|
||||
builder = PersistentTasksCustomMetaData.builder(persistentTasks);
|
||||
}
|
||||
boolean changed = false;
|
||||
for (int j = 0; j < randomIntBetween(1, 10); j++) {
|
||||
|
|
Loading…
Reference in New Issue