Search in sources :

Example 16 with ModelActionHolder

use of com.netflix.titus.common.framework.reconciler.ModelActionHolder in project titus-control-plane by Netflix.

the class CreateOrReplaceServiceTaskActions method createNewTaskModelAction.

private static List<ModelActionHolder> createNewTaskModelAction(TitusChangeAction.Builder changeActionBuilder, ServiceJobTask newTask, Optional<ServiceJobTask> replacementOf, Retryer newRetryer) {
    List<ModelActionHolder> actions = new ArrayList<>();
    String summary = "Creating new task entity holder";
    TitusModelAction.Builder modelBuilder = TitusModelAction.newModelUpdate(changeActionBuilder).summary(summary);
    EntityHolder taskHolder = EntityHolder.newRoot(newTask.getId(), newTask).addTag(TaskRetryers.ATTR_TASK_RETRY, newRetryer);
    if (replacementOf.isPresent()) {
        taskHolder = taskHolder.addTag(ATTR_REPLACEMENT_OF, replacementOf.get());
    }
    actions.add(ModelActionHolder.reference(modelBuilder.addTaskHolder(taskHolder)));
    actions.add(ModelActionHolder.store(modelBuilder.taskUpdate(newTask)));
    return actions;
}
Also used : TitusModelAction(com.netflix.titus.master.jobmanager.service.common.action.TitusModelAction) ArrayList(java.util.ArrayList) EntityHolder(com.netflix.titus.common.framework.reconciler.EntityHolder) ModelActionHolder(com.netflix.titus.common.framework.reconciler.ModelActionHolder)

Example 17 with ModelActionHolder

use of com.netflix.titus.common.framework.reconciler.ModelActionHolder in project titus-control-plane by Netflix.

the class CreateOrReplaceServiceTaskActions method createTaskResubmitModelActions.

private static List<ModelActionHolder> createTaskResubmitModelActions(TitusChangeAction.Builder changeActionBuilder, ServiceJobTask oldTask, ServiceJobTask newTask, Retryer nextTaskRetryer) {
    List<ModelActionHolder> actions = new ArrayList<>();
    TitusModelAction removeTaskAction = TitusModelAction.newModelUpdate(changeActionBuilder).summary("Removing replaced task").removeTask(oldTask);
    actions.addAll(ModelActionHolder.allModels(removeTaskAction));
    actions.addAll(createNewTaskModelAction(changeActionBuilder, newTask, Optional.of(oldTask), nextTaskRetryer));
    return actions;
}
Also used : TitusModelAction(com.netflix.titus.master.jobmanager.service.common.action.TitusModelAction) ArrayList(java.util.ArrayList) ModelActionHolder(com.netflix.titus.common.framework.reconciler.ModelActionHolder)

Aggregations

ModelActionHolder (com.netflix.titus.common.framework.reconciler.ModelActionHolder)17 EntityHolder (com.netflix.titus.common.framework.reconciler.EntityHolder)11 TitusModelAction (com.netflix.titus.master.jobmanager.service.common.action.TitusModelAction)11 ArrayList (java.util.ArrayList)10 Task (com.netflix.titus.api.jobmanager.model.job.Task)4 ChangeAction (com.netflix.titus.common.framework.reconciler.ChangeAction)4 List (java.util.List)4 Test (org.junit.Test)4 Observable (rx.Observable)4 MultiEngineChangeAction (com.netflix.titus.common.framework.reconciler.MultiEngineChangeAction)3 Optional (java.util.Optional)3 Job (com.netflix.titus.api.jobmanager.model.job.Job)2 JobState (com.netflix.titus.api.jobmanager.model.job.JobState)2 JobStatus (com.netflix.titus.api.jobmanager.model.job.JobStatus)2 TaskStatus (com.netflix.titus.api.jobmanager.model.job.TaskStatus)2 CallMetadata (com.netflix.titus.api.model.callmetadata.CallMetadata)2 ReconciliationEngine (com.netflix.titus.common.framework.reconciler.ReconciliationEngine)2 TitusChangeAction (com.netflix.titus.master.jobmanager.service.common.action.TitusChangeAction)2 JobManagerReconcilerEvent (com.netflix.titus.master.jobmanager.service.event.JobManagerReconcilerEvent)2 ExtTestSubscriber (com.netflix.titus.testkit.rx.ExtTestSubscriber)2