use of com.netflix.titus.common.util.guice.annotation.Activator in project titus-control-plane by Netflix.
the class DefaultEvictionOperations method enterActiveMode.
@Activator
public void enterActiveMode() {
this.quotEventEmitter = new QuotaEventEmitter(configuration, jobOperations, quotaManager, titusRuntime);
this.taskTerminationExecutor = new TaskTerminationExecutor(configuration, jobOperations, quotaManager, titusRuntime, scheduler);
}
use of com.netflix.titus.common.util.guice.annotation.Activator in project titus-control-plane by Netflix.
the class KubeAndJobServiceSyncStatusWatcher method enterActiveMode.
@Activator
public Observable<Void> enterActiveMode() {
try {
kubeApiFacade.getPodInformer().addEventHandler(new ResourceEventHandler<V1Pod>() {
@Override
public void onAdd(V1Pod obj) {
capturedState.put(obj.getMetadata().getName(), new TaskHolder(obj, false));
}
@Override
public void onUpdate(V1Pod oldObj, V1Pod newObj) {
capturedState.put(newObj.getMetadata().getName(), new TaskHolder(newObj, false));
}
@Override
public void onDelete(V1Pod obj, boolean deletedFinalStateUnknown) {
capturedState.put(obj.getMetadata().getName(), new TaskHolder(obj, true));
}
});
ScheduleDescriptor scheduleDescriptor = ScheduleDescriptor.newBuilder().withName(KubeAndJobServiceSyncStatusWatcher.class.getSimpleName()).withDescription("Compare Kube pod state with Titus job service").withInitialDelay(Duration.ofSeconds(60)).withInterval(Duration.ofSeconds(10)).withTimeout(Duration.ofSeconds((60))).build();
this.schedulerRef = titusRuntime.getLocalScheduler().schedule(scheduleDescriptor, this::process, ExecutorsExt.namedSingleThreadExecutor(KubeAndJobServiceSyncStatusWatcher.class.getSimpleName()));
} catch (Exception e) {
return Observable.error(e);
}
return Observable.empty();
}
use of com.netflix.titus.common.util.guice.annotation.Activator in project titus-control-plane by Netflix.
the class DefaultV3JobOperations method enterActiveMode.
@Activator
public void enterActiveMode() {
this.reconciliationFramework = jobReconciliationFrameworkFactory.newInstance();
// BUG: event stream breaks permanently, and cannot be retried.
// As we cannot fix the underlying issue yet, we have to be able to discover when it happens.
AtomicLong eventStreamLastError = new AtomicLong();
Clock clock = titusRuntime.getClock();
this.transactionLoggerSubscription = JobTransactionLogger.logEvents(reconciliationFramework, eventStreamLastError, clock);
PolledMeter.using(titusRuntime.getRegistry()).withName(METRIC_EVENT_STREAM_LAST_ERROR).monitorValue(eventStreamLastError, value -> value.get() <= 0 ? 0 : clock.wallTime() - value.get());
// Remove finished jobs from the reconciliation framework.
Observable<JobManagerReconcilerEvent> reconciliationEventsObservable = reconciliationFramework.events().onBackpressureBuffer(OBSERVE_JOBS_BACKPRESSURE_BUFFER_SIZE, () -> logger.warn("Overflowed the buffer size: " + OBSERVE_JOBS_BACKPRESSURE_BUFFER_SIZE), BackpressureOverflow.ON_OVERFLOW_ERROR).doOnSubscribe(() -> {
List<EntityHolder> entityHolders = reconciliationFramework.orderedView(IndexKind.StatusCreationTime);
for (EntityHolder entityHolder : entityHolders) {
handleJobCompletedEvent(entityHolder);
}
});
this.reconcilerEventSubscription = titusRuntime.persistentStream(reconciliationEventsObservable).subscribe(event -> {
if (event instanceof JobModelUpdateReconcilerEvent) {
JobModelUpdateReconcilerEvent jobUpdateEvent = (JobModelUpdateReconcilerEvent) event;
handleJobCompletedEvent(jobUpdateEvent.getChangedEntityHolder());
}
}, e -> logger.error("Event stream terminated with an error", e), () -> logger.info("Event stream completed"));
reconciliationFramework.start();
}
use of com.netflix.titus.common.util.guice.annotation.Activator in project titus-control-plane by Netflix.
the class KubeNotificationProcessor method enterActiveMode.
@Activator
public void enterActiveMode() {
this.scheduler = initializeNotificationScheduler();
AtomicLong pendingCounter = new AtomicLong();
this.subscription = kubeApiServerIntegrator.events().mergeWith(kubeJobManagementReconciler.getPodEventSource()).subscribeOn(scheduler).publishOn(scheduler).doOnError(error -> logger.warn("Kube integration event stream terminated with an error (retrying soon)", error)).retryWhen(Retry.backoff(Long.MAX_VALUE, Duration.ofSeconds(1))).subscribe(event -> {
Stopwatch stopwatch = Stopwatch.createStarted();
pendingCounter.getAndIncrement();
metricsRunning.set(pendingCounter.get());
metricsLag.set(PodEvent.nextSequence() - event.getSequenceNumber());
logger.info("New event [pending={}, lag={}]: {}", pendingCounter.get(), PodEvent.nextSequence() - event.getSequenceNumber(), event);
processEvent(event).doAfterTerminate(() -> {
pendingCounter.decrementAndGet();
long elapsed = stopwatch.elapsed(TimeUnit.MILLISECONDS);
metricsProcessed.record(elapsed, TimeUnit.MILLISECONDS);
metricsRunning.set(pendingCounter.get());
logger.info("Event processed [pending={}]: event={}, elapsed={}", pendingCounter.get(), event, elapsed);
}).subscribe(next -> {
// nothing
}, error -> {
logger.info("Kube notification event state update error: event={}, error={}", event, error.getMessage());
logger.debug("Stack trace", error);
}, () -> {
// nothing
});
}, e -> logger.error("Event stream terminated"), () -> logger.info("Event stream completed"));
}
use of com.netflix.titus.common.util.guice.annotation.Activator in project titus-control-plane by Netflix.
the class DefaultFabric8IOConnector method enterActiveMode.
@Activator
public void enterActiveMode() {
logger.info("Kube api connector entering active mode");
this.scheduler = initializeNotificationScheduler();
AtomicLong pendingCounter = new AtomicLong();
this.subscription = this.events().subscribeOn(scheduler).publishOn(scheduler).doOnError(error -> logger.warn("Kube integration event stream terminated with an error (retrying soon)", error)).retryWhen(Retry.backoff(Long.MAX_VALUE, Duration.ofSeconds(1))).subscribe(event -> {
Stopwatch stopwatch = Stopwatch.createStarted();
pendingCounter.getAndIncrement();
logger.info("New event [pending={}, lag={}]: {}", pendingCounter.get(), PodEvent.nextSequence() - event.getSequenceNumber(), event);
processEvent(event).doAfterTerminate(() -> {
pendingCounter.decrementAndGet();
long elapsed = stopwatch.elapsed(TimeUnit.MILLISECONDS);
logger.info("Event processed [pending={}]: event={}, elapsed={}", pendingCounter.get(), event, elapsed);
}).subscribe(next -> {
// nothing
}, error -> {
logger.info("Kube api connector event state update error: event={}, error={}", event, error.getMessage());
logger.debug("Stack trace", error);
}, () -> {
// nothing
});
}, e -> logger.error("Event stream terminated"), () -> logger.info("Event stream completed"));
}
Aggregations