Search in sources :

Example 1 with FitComponent

use of com.netflix.titus.common.framework.fit.FitComponent in project titus-control-plane by Netflix.

the class DefaultFitComponent method getChild.

@Override
public FitComponent getChild(String id) {
    FitComponent child = children.get(id);
    Preconditions.checkArgument(child != null, "FitComponent %s not found", id);
    return child;
}
Also used : FitComponent(com.netflix.titus.common.framework.fit.FitComponent)

Example 2 with FitComponent

use of com.netflix.titus.common.framework.fit.FitComponent in project titus-control-plane by Netflix.

the class FitSpringResource method addAction.

@RequestMapping(method = RequestMethod.POST, path = "/actions", consumes = "application/json")
public Response addAction(@RequestBody Fit.AddAction request) {
    FitComponent fitComponent = FitUtil.getFitComponentOrFail(fitFramework, request.getComponentId());
    FitInjection fitInjection = FitUtil.getFitInjectionOrFail(request.getInjectionId(), fitComponent);
    Function<FitInjection, FitAction> fitActionFactory = fitFramework.getFitRegistry().newFitActionFactory(request.getActionKind(), request.getActionId(), request.getPropertiesMap());
    fitInjection.addAction(fitActionFactory.apply(fitInjection));
    return Response.noContent().build();
}
Also used : FitInjection(com.netflix.titus.common.framework.fit.FitInjection) FitComponent(com.netflix.titus.common.framework.fit.FitComponent) FitAction(com.netflix.titus.common.framework.fit.FitAction) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with FitComponent

use of com.netflix.titus.common.framework.fit.FitComponent in project titus-control-plane by Netflix.

the class FitResource method addAction.

@POST
@Path("/actions")
public Response addAction(Fit.AddAction request) {
    FitComponent fitComponent = FitUtil.getFitComponentOrFail(fitFramework, request.getComponentId());
    FitInjection fitInjection = FitUtil.getFitInjectionOrFail(request.getInjectionId(), fitComponent);
    Function<FitInjection, FitAction> fitActionFactory = fitFramework.getFitRegistry().newFitActionFactory(request.getActionKind(), request.getActionId(), request.getPropertiesMap());
    fitInjection.addAction(fitActionFactory.apply(fitInjection));
    return Response.noContent().build();
}
Also used : FitInjection(com.netflix.titus.common.framework.fit.FitInjection) FitComponent(com.netflix.titus.common.framework.fit.FitComponent) FitAction(com.netflix.titus.common.framework.fit.FitAction) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 4 with FitComponent

use of com.netflix.titus.common.framework.fit.FitComponent in project titus-control-plane by Netflix.

the class TitusRuntimeModule method getTitusRuntime.

@Provides
@Singleton
public TitusRuntime getTitusRuntime(Config config, SystemLogService systemLogService, SystemAbortListener systemAbortListener, Registry registry) {
    CodeInvariants codeInvariants = new CompositeCodeInvariants(LoggingCodeInvariants.getDefault(), new SpectatorCodeInvariants(registry.createId("titus.runtime.invariant.violations"), registry));
    DefaultTitusRuntime titusRuntime = new DefaultTitusRuntime(MyEnvironments.newArchaius(config), codeInvariants, systemLogService, systemExitOnFailure, systemAbortListener, registry);
    // Setup FIT component hierarchy
    FitFramework fitFramework = titusRuntime.getFitFramework();
    if (fitFramework.isActive()) {
        FitComponent root = fitFramework.getRootComponent();
        root.createChild(LeaderActivator.COMPONENT);
        root.createChild(V3JobOperations.COMPONENT);
        root.createChild(DirectKubeApiServerIntegrator.COMPONENT);
        // Add custom FIT actions
        FitRegistry fitRegistry = fitFramework.getFitRegistry();
        fitRegistry.registerActionKind(JobStoreFitAction.DESCRIPTOR, (id, properties) -> injection -> new JobStoreFitAction(id, properties, injection));
        fitRegistry.registerActionKind(KubeFitAction.DESCRIPTOR, (id, properties) -> injection -> new KubeFitAction(id, properties, injection));
    }
    return titusRuntime;
}
Also used : JobStoreFitAction(com.netflix.titus.api.jobmanager.store.JobStoreFitAction) FitComponent(com.netflix.titus.common.framework.fit.FitComponent) CodeInvariants(com.netflix.titus.common.util.code.CodeInvariants) SpectatorCodeInvariants(com.netflix.titus.common.util.code.SpectatorCodeInvariants) LoggingCodeInvariants(com.netflix.titus.common.util.code.LoggingCodeInvariants) CompositeCodeInvariants(com.netflix.titus.common.util.code.CompositeCodeInvariants) KubeFitAction(com.netflix.titus.master.kubernetes.client.KubeFitAction) SpectatorCodeInvariants(com.netflix.titus.common.util.code.SpectatorCodeInvariants) FitFramework(com.netflix.titus.common.framework.fit.FitFramework) CompositeCodeInvariants(com.netflix.titus.common.util.code.CompositeCodeInvariants) DefaultTitusRuntime(com.netflix.titus.common.runtime.internal.DefaultTitusRuntime) FitRegistry(com.netflix.titus.common.framework.fit.FitRegistry) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 5 with FitComponent

use of com.netflix.titus.common.framework.fit.FitComponent in project titus-control-plane by Netflix.

the class RelocationTitusRuntimeComponent method getTitusRuntime.

@Bean
public TitusRuntime getTitusRuntime() {
    FitFramework fitFramework = titusRuntime.getFitFramework();
    if (fitFramework.isActive()) {
        FitComponent root = fitFramework.getRootComponent();
        root.createChild(GrpcFitInterceptor.COMPONENT);
    }
    return titusRuntime;
}
Also used : FitComponent(com.netflix.titus.common.framework.fit.FitComponent) FitFramework(com.netflix.titus.common.framework.fit.FitFramework) Bean(org.springframework.context.annotation.Bean)

Aggregations

FitComponent (com.netflix.titus.common.framework.fit.FitComponent)5 FitAction (com.netflix.titus.common.framework.fit.FitAction)2 FitFramework (com.netflix.titus.common.framework.fit.FitFramework)2 FitInjection (com.netflix.titus.common.framework.fit.FitInjection)2 Provides (com.google.inject.Provides)1 JobStoreFitAction (com.netflix.titus.api.jobmanager.store.JobStoreFitAction)1 FitRegistry (com.netflix.titus.common.framework.fit.FitRegistry)1 DefaultTitusRuntime (com.netflix.titus.common.runtime.internal.DefaultTitusRuntime)1 CodeInvariants (com.netflix.titus.common.util.code.CodeInvariants)1 CompositeCodeInvariants (com.netflix.titus.common.util.code.CompositeCodeInvariants)1 LoggingCodeInvariants (com.netflix.titus.common.util.code.LoggingCodeInvariants)1 SpectatorCodeInvariants (com.netflix.titus.common.util.code.SpectatorCodeInvariants)1 KubeFitAction (com.netflix.titus.master.kubernetes.client.KubeFitAction)1 Singleton (javax.inject.Singleton)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Bean (org.springframework.context.annotation.Bean)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1