use of com.netflix.titus.common.framework.fit.FitInjection in project titus-control-plane by Netflix.
the class GrpcFitInterceptor method interceptCall.
@Override
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> call, Metadata headers, ServerCallHandler<ReqT, RespT> next) {
if (!fitRequestHandler.isPresent()) {
return next.startCall(call, headers);
}
FitInjection fitInjection = fitRequestHandler.get();
String injectionPoint = call.getMethodDescriptor().getFullMethodName();
// Request failure
try {
fitInjection.beforeImmediate(injectionPoint);
} catch (Exception e) {
call.close(Status.UNAVAILABLE.withDescription("FIT server failure"), new Metadata());
return new ServerCall.Listener<ReqT>() {
};
}
// Increased latency.
return fitInjection.findAction(FitLatencyAction.ACTION_ID).map(action -> {
int latencyMs = ExceptionExt.doTry(() -> Integer.parseInt(action.getProperties().get("latency"))).orElse(100);
return new LatencyHandler<>(call, headers, next, latencyMs).getLatencyListener();
}).orElse(next.startCall(call, headers));
}
use of com.netflix.titus.common.framework.fit.FitInjection in project titus-control-plane by Netflix.
the class FitSpringResource method deleteAction.
@RequestMapping(method = RequestMethod.DELETE, path = "/actions/{actionId}")
public Response deleteAction(@PathVariable("actionId") String actionId, @RequestParam("componentId") String componentId, @RequestParam("injectionId") String injectionId) {
FitInjection fitInjection = FitUtil.getFitInjectionOrFail(injectionId, FitUtil.getFitComponentOrFail(fitFramework, componentId));
fitInjection.removeAction(FitUtil.getFitActionOrFail(actionId, fitInjection).getId());
return Response.noContent().build();
}
use of com.netflix.titus.common.framework.fit.FitInjection 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();
}
use of com.netflix.titus.common.framework.fit.FitInjection in project titus-control-plane by Netflix.
the class FitResource method deleteAction.
@DELETE
@Path("/actions/{actionId}")
public Response deleteAction(@PathParam("actionId") String actionId, @QueryParam("componentId") String componentId, @QueryParam("injectionId") String injectionId) {
FitInjection fitInjection = FitUtil.getFitInjectionOrFail(injectionId, FitUtil.getFitComponentOrFail(fitFramework, componentId));
fitInjection.removeAction(FitUtil.getFitActionOrFail(actionId, fitInjection).getId());
return Response.noContent().build();
}
use of com.netflix.titus.common.framework.fit.FitInjection 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();
}
Aggregations