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");
}
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);
}
Aggregations