Search in sources :

Example 6 with Activator

use of com.netflix.titus.common.util.guice.annotation.Activator in project titus-control-plane by Netflix.

the class ManagementSubsystemInitializer method enterActiveMode.

@Activator
public Observable<Void> enterActiveMode() {
    logger.info("Entering active mode");
    try {
        ApplicationSLA defaultSLA = applicationSlaStore.findByName(ApplicationSlaManagementService.DEFAULT_APPLICATION).toBlocking().first();
        logger.info("Default application SLA configured as: {}", defaultSLA);
    } catch (NotFoundException e) {
        ApplicationSLA defaultSLA = buildDefaultApplicationSLA(configuration);
        applicationSlaStore.create(defaultSLA).toBlocking().firstOrDefault(null);
        logger.info("Default application SLA not defined; creating it according to the provided configuration: {}", defaultSLA);
    }
    return Observable.empty();
}
Also used : ApplicationSLA(com.netflix.titus.api.model.ApplicationSLA) NotFoundException(com.netflix.titus.api.store.v2.exception.NotFoundException) Activator(com.netflix.titus.common.util.guice.annotation.Activator)

Example 7 with Activator

use of com.netflix.titus.common.util.guice.annotation.Activator in project titus-control-plane by Netflix.

the class ArchivedTasksGc method enterActiveMode.

@Activator
public void enterActiveMode() {
    ScheduleDescriptor scheduleDescriptor = ScheduleDescriptor.newBuilder().withName("gcArchivedTasks").withDescription("GC oldest archived pasts once the criteria is met").withInitialDelay(Duration.ofMillis(configuration.getGcInitialDelayMs())).withInterval(Duration.ofMillis(configuration.getGcIntervalMs())).withTimeout(Duration.ofMillis(configuration.getGcTimeoutMs())).build();
    this.schedulerRef = titusRuntime.getLocalScheduler().schedule(scheduleDescriptor, e -> gc(), ExecutorsExt.namedSingleThreadExecutor(ArchivedTasksGc.class.getSimpleName()));
}
Also used : Completable(rx.Completable) Gauge(com.netflix.spectator.api.Gauge) Task(com.netflix.titus.api.jobmanager.model.job.Task) LoggerFactory(org.slf4j.LoggerFactory) Singleton(javax.inject.Singleton) ArrayList(java.util.ArrayList) ScheduleReference(com.netflix.titus.common.framework.scheduler.ScheduleReference) Observable(rx.Observable) Inject(javax.inject.Inject) PreDestroy(javax.annotation.PreDestroy) Pair(com.netflix.titus.common.util.tuple.Pair) Duration(java.time.Duration) JobStore(com.netflix.titus.api.jobmanager.store.JobStore) Deactivator(com.netflix.titus.common.util.guice.annotation.Deactivator) ExecutorsExt(com.netflix.titus.common.util.ExecutorsExt) Job(com.netflix.titus.api.jobmanager.model.job.Job) Logger(org.slf4j.Logger) JobFunctions(com.netflix.titus.api.jobmanager.model.job.JobFunctions) Collectors(java.util.stream.Collectors) TaskState(com.netflix.titus.api.jobmanager.model.job.TaskState) Activator(com.netflix.titus.common.util.guice.annotation.Activator) List(java.util.List) ExecutableStatus(com.netflix.titus.api.jobmanager.model.job.ExecutableStatus) V3JobOperations(com.netflix.titus.api.jobmanager.service.V3JobOperations) ScheduleDescriptor(com.netflix.titus.common.framework.scheduler.model.ScheduleDescriptor) Registry(com.netflix.spectator.api.Registry) METRIC_JOB_MANAGER(com.netflix.titus.master.MetricConstants.METRIC_JOB_MANAGER) VisibleForTesting(com.google.common.annotations.VisibleForTesting) TitusRuntime(com.netflix.titus.common.runtime.TitusRuntime) Comparator(java.util.Comparator) Evaluators(com.netflix.titus.common.util.Evaluators) Collections(java.util.Collections) ScheduleDescriptor(com.netflix.titus.common.framework.scheduler.model.ScheduleDescriptor) Activator(com.netflix.titus.common.util.guice.annotation.Activator)

Example 8 with Activator

use of com.netflix.titus.common.util.guice.annotation.Activator in project titus-control-plane by Netflix.

the class DefaultKubeJobManagementReconciler method enterActiveMode.

@Activator
public void enterActiveMode() {
    ScheduleDescriptor scheduleDescriptor = ScheduleDescriptor.newBuilder().withName("reconcileNodesAndPods").withDescription("Reconcile nodes and pods").withInitialDelay(Duration.ofMillis(backendConfiguration.getReconcilerInitialDelayMs())).withInterval(Duration.ofMillis(backendConfiguration.getReconcilerIntervalMs())).withTimeout(Duration.ofMinutes(5)).build();
    this.schedulerRef = titusRuntime.getLocalScheduler().schedule(scheduleDescriptor, e -> reconcile(), ExecutorsExt.namedSingleThreadExecutor(DefaultKubeJobManagementReconciler.class.getSimpleName()));
}
Also used : Gauge(com.netflix.spectator.api.Gauge) Task(com.netflix.titus.api.jobmanager.model.job.Task) FluxSink(reactor.core.publisher.FluxSink) StdKubeApiFacade(com.netflix.titus.runtime.connector.kubernetes.std.StdKubeApiFacade) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) MetricConstants(com.netflix.titus.master.MetricConstants) StringExt(com.netflix.titus.common.util.StringExt) V1Node(io.kubernetes.client.openapi.models.V1Node) Singleton(javax.inject.Singleton) ReactorExt(com.netflix.titus.common.util.rx.ReactorExt) KubeUtil(com.netflix.titus.master.kubernetes.KubeUtil) Function(java.util.function.Function) ArrayList(java.util.ArrayList) ScheduleReference(com.netflix.titus.common.framework.scheduler.ScheduleReference) Inject(javax.inject.Inject) PreDestroy(javax.annotation.PreDestroy) Duration(java.time.Duration) Map(java.util.Map) DirectKubeConfiguration(com.netflix.titus.master.kubernetes.client.DirectKubeConfiguration) Named(javax.inject.Named) Deactivator(com.netflix.titus.common.util.guice.annotation.Deactivator) PodEvent(com.netflix.titus.master.kubernetes.client.model.PodEvent) ExecutorsExt(com.netflix.titus.common.util.ExecutorsExt) Logger(org.slf4j.Logger) DirectProcessor(reactor.core.publisher.DirectProcessor) TaskStatus(com.netflix.titus.api.jobmanager.model.job.TaskStatus) Set(java.util.Set) Collectors(java.util.stream.Collectors) TaskState(com.netflix.titus.api.jobmanager.model.job.TaskState) PodNotFoundEvent(com.netflix.titus.master.kubernetes.client.model.PodNotFoundEvent) Activator(com.netflix.titus.common.util.guice.annotation.Activator) FixedIntervalTokenBucketConfiguration(com.netflix.titus.common.util.limiter.tokenbucket.FixedIntervalTokenBucketConfiguration) Flux(reactor.core.publisher.Flux) List(java.util.List) V3JobOperations(com.netflix.titus.api.jobmanager.service.V3JobOperations) Stream(java.util.stream.Stream) TaskAttributes(com.netflix.titus.api.jobmanager.TaskAttributes) ScheduleDescriptor(com.netflix.titus.common.framework.scheduler.model.ScheduleDescriptor) Registry(com.netflix.spectator.api.Registry) Optional(java.util.Optional) BackendConfiguration(com.netflix.titus.master.config.BackendConfiguration) TitusRuntime(com.netflix.titus.common.runtime.TitusRuntime) Evaluators(com.netflix.titus.common.util.Evaluators) Clock(com.netflix.titus.common.util.time.Clock) V1Pod(io.kubernetes.client.openapi.models.V1Pod) ScheduleDescriptor(com.netflix.titus.common.framework.scheduler.model.ScheduleDescriptor) Activator(com.netflix.titus.common.util.guice.annotation.Activator)

Example 9 with Activator

use of com.netflix.titus.common.util.guice.annotation.Activator in project titus-control-plane by Netflix.

the class BaseGcController method enterActiveMode.

@Activator
public void enterActiveMode() {
    ScheduleDescriptor gcScheduleDescriptor = ScheduleDescriptor.newBuilder().withName(name).withDescription(description).withInitialDelay(Duration.ofMillis(controllerConfiguration.getControllerInitialDelayMs())).withInterval(Duration.ofMillis(controllerConfiguration.getControllerIntervalMs())).withTimeout(Duration.ofMillis(controllerConfiguration.getControllerTimeoutMs())).build();
    executorService = ExecutorsExt.namedSingleThreadExecutor(name);
    schedulerRef = scheduler.schedule(gcScheduleDescriptor, e -> doGc(), executorService);
    tokenBucket = Limiters.createInstrumentedFixedIntervalTokenBucket(name + "TokenBucket", tokenBucketConfiguration, currentTokenBucket -> logger.info("Token bucket: {} configuration updated with: {}", name, currentTokenBucket), titusRuntime);
}
Also used : ExecutorsExt(com.netflix.titus.common.util.ExecutorsExt) Gauge(com.netflix.spectator.api.Gauge) Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) MetricConstants(com.netflix.titus.master.MetricConstants) ScheduleReference(com.netflix.titus.common.framework.scheduler.ScheduleReference) Activator(com.netflix.titus.common.util.guice.annotation.Activator) FixedIntervalTokenBucketConfiguration(com.netflix.titus.common.util.limiter.tokenbucket.FixedIntervalTokenBucketConfiguration) PreDestroy(javax.annotation.PreDestroy) List(java.util.List) ScheduleDescriptor(com.netflix.titus.common.framework.scheduler.model.ScheduleDescriptor) Duration(java.time.Duration) Limiters(com.netflix.titus.common.util.limiter.Limiters) Named(javax.inject.Named) TitusRuntime(com.netflix.titus.common.runtime.TitusRuntime) TokenBucket(com.netflix.titus.common.util.limiter.tokenbucket.TokenBucket) Evaluators(com.netflix.titus.common.util.Evaluators) Collections(java.util.Collections) Deactivator(com.netflix.titus.common.util.guice.annotation.Deactivator) ExecutorService(java.util.concurrent.ExecutorService) LocalScheduler(com.netflix.titus.common.framework.scheduler.LocalScheduler) ScheduleDescriptor(com.netflix.titus.common.framework.scheduler.model.ScheduleDescriptor) Activator(com.netflix.titus.common.util.guice.annotation.Activator)

Aggregations

Activator (com.netflix.titus.common.util.guice.annotation.Activator)9 TitusRuntime (com.netflix.titus.common.runtime.TitusRuntime)6 Evaluators (com.netflix.titus.common.util.Evaluators)6 Logger (org.slf4j.Logger)6 LoggerFactory (org.slf4j.LoggerFactory)6 ExecutorsExt (com.netflix.titus.common.util.ExecutorsExt)5 Duration (java.time.Duration)5 List (java.util.List)5 PreDestroy (javax.annotation.PreDestroy)5 Inject (javax.inject.Inject)5 Singleton (javax.inject.Singleton)5 Gauge (com.netflix.spectator.api.Gauge)4 Task (com.netflix.titus.api.jobmanager.model.job.Task)4 TaskState (com.netflix.titus.api.jobmanager.model.job.TaskState)4 V3JobOperations (com.netflix.titus.api.jobmanager.service.V3JobOperations)4 ScheduleDescriptor (com.netflix.titus.common.framework.scheduler.model.ScheduleDescriptor)4 Deactivator (com.netflix.titus.common.util.guice.annotation.Deactivator)4 ReactorExt (com.netflix.titus.common.util.rx.ReactorExt)4 MetricConstants (com.netflix.titus.master.MetricConstants)4 ArrayList (java.util.ArrayList)4