Search in sources :

Example 16 with ChangeAction

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

the class DefaultReconciliationFrameworkTest method testMultiEngineChangeActionWithInvalidEngineId.

@Test
public void testMultiEngineChangeActionWithInvalidEngineId() {
    EntityHolder root1 = EntityHolder.newRoot("myRoot1", "myEntity1");
    framework.newEngine(root1).subscribe();
    testScheduler.triggerActions();
    Observable<Void> multiChangeObservable = framework.changeReferenceModel(// Keep anonymous class instead of lambda for readability
    new MultiEngineChangeAction() {

        @Override
        public Observable<Map<String, List<ModelActionHolder>>> apply() {
            return Observable.error(new IllegalStateException("invocation not expected"));
        }
    }, // Keep anonymous class instead of lambda for readability
    (id, modelUpdates) -> new ChangeAction() {

        @Override
        public Observable<List<ModelActionHolder>> apply() {
            return Observable.error(new IllegalStateException("invocation not expected"));
        }
    }, "myRoot1", "badRootId");
    ExtTestSubscriber<Void> multiChangeSubscriber = new ExtTestSubscriber<>();
    multiChangeObservable.subscribe(multiChangeSubscriber);
    assertThat(multiChangeSubscriber.isError()).isTrue();
    assertThat(multiChangeSubscriber.getError().getMessage()).contains("badRootId");
}
Also used : ChangeAction(com.netflix.titus.common.framework.reconciler.ChangeAction) MultiEngineChangeAction(com.netflix.titus.common.framework.reconciler.MultiEngineChangeAction) ExtTestSubscriber(com.netflix.titus.testkit.rx.ExtTestSubscriber) MultiEngineChangeAction(com.netflix.titus.common.framework.reconciler.MultiEngineChangeAction) EntityHolder(com.netflix.titus.common.framework.reconciler.EntityHolder) Observable(rx.Observable) List(java.util.List) ModelActionHolder(com.netflix.titus.common.framework.reconciler.ModelActionHolder) Test(org.junit.Test)

Example 17 with ChangeAction

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

the class DefaultReconciliationEngine method startReconcileAction.

private void startReconcileAction(List<ChangeAction> reconcileActions) {
    long transactionId = nextTransactionId.getAndIncrement();
    long nestedId = 0;
    long now = clock.wallTime();
    List<Transaction> transactions = new ArrayList<>();
    for (ChangeAction changeAction : reconcileActions) {
        String compositeTransactionId = reconcileActions.size() == 1 ? Long.toString(transactionId) : transactionId + "." + nestedId;
        nestedId++;
        emitEvent(eventFactory.newBeforeChangeEvent(this, changeAction, compositeTransactionId));
        transactions.add(new SingleTransaction<>(this, changeAction, now, Optional.empty(), compositeTransactionId, true));
    }
    pendingTransaction = transactions.size() == 1 ? transactions.get(0) : new CompositeTransaction(transactions);
}
Also used : ChangeAction(com.netflix.titus.common.framework.reconciler.ChangeAction) ArrayList(java.util.ArrayList)

Aggregations

ChangeAction (com.netflix.titus.common.framework.reconciler.ChangeAction)17 ArrayList (java.util.ArrayList)13 EntityHolder (com.netflix.titus.common.framework.reconciler.EntityHolder)12 TitusChangeAction (com.netflix.titus.master.jobmanager.service.common.action.TitusChangeAction)10 List (java.util.List)7 Task (com.netflix.titus.api.jobmanager.model.job.Task)5 ModelActionHolder (com.netflix.titus.common.framework.reconciler.ModelActionHolder)5 MultiEngineChangeAction (com.netflix.titus.common.framework.reconciler.MultiEngineChangeAction)5 Observable (rx.Observable)5 TaskState (com.netflix.titus.api.jobmanager.model.job.TaskState)4 ServiceJobExt (com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt)4 CallMetadata (com.netflix.titus.api.model.callmetadata.CallMetadata)4 ReconciliationEngine (com.netflix.titus.common.framework.reconciler.ReconciliationEngine)4 HashSet (java.util.HashSet)4 Optional (java.util.Optional)4 Set (java.util.Set)4 Job (com.netflix.titus.api.jobmanager.model.job.Job)3 JobFunctions (com.netflix.titus.api.jobmanager.model.job.JobFunctions)3 JobState (com.netflix.titus.api.jobmanager.model.job.JobState)3 TaskStatus (com.netflix.titus.api.jobmanager.model.job.TaskStatus)3