Search in sources :

Example 1 with JobDisruptionBudget

use of com.netflix.titus.grpc.protogen.JobDisruptionBudget in project titus-control-plane by Netflix.

the class JobManagementSpringResourceTest method testSetJobDisruptionBudget.

@Test
public void testSetJobDisruptionBudget() throws Exception {
    JobDisruptionBudget restRequest = toGrpcDisruptionBudget(DisruptionBudgetGenerator.budgetSelfManagedBasic());
    JobDisruptionBudgetUpdate forwardedRequest = JobDisruptionBudgetUpdate.newBuilder().setJobId(JOB_ID_1).setDisruptionBudget(restRequest).build();
    when(jobServiceGatewayMock.updateJobDisruptionBudget(forwardedRequest, JUNIT_REST_CALL_METADATA)).thenReturn(Mono.empty());
    SpringMockMvcUtil.doPut(mockMvc, String.format("/api/v3/jobs/%s/disruptionBudget", JOB_ID_1), restRequest);
    verify(jobServiceGatewayMock, times(1)).updateJobDisruptionBudget(forwardedRequest, JUNIT_REST_CALL_METADATA);
}
Also used : JobDisruptionBudget(com.netflix.titus.grpc.protogen.JobDisruptionBudget) JobDisruptionBudgetUpdate(com.netflix.titus.grpc.protogen.JobDisruptionBudgetUpdate) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest) Test(org.junit.Test)

Example 2 with JobDisruptionBudget

use of com.netflix.titus.grpc.protogen.JobDisruptionBudget in project titus-control-plane by Netflix.

the class DefaultJobManagementServiceGrpc method validateAndConvertJobDisruptionBudgetToCoreModel.

private Optional<DisruptionBudget> validateAndConvertJobDisruptionBudgetToCoreModel(com.netflix.titus.api.jobmanager.model.job.Job<?> coreJob, JobDisruptionBudget grpcDisruptionBudget, StreamObserver<Empty> responseObserver) {
    DisruptionBudget coreDisruptionBudget;
    try {
        coreDisruptionBudget = GrpcJobManagementModelConverters.toCoreDisruptionBudget(grpcDisruptionBudget);
    } catch (Exception e) {
        safeOnError(logger, TitusServiceException.invalidArgument("Error when converting GRPC disruption budget to the internal model: " + e.getMessage()), responseObserver);
        return Optional.empty();
    }
    DisruptionBudget sanitizedCoreDisruptionBudget = entitySanitizer.sanitize(coreDisruptionBudget).orElse(coreDisruptionBudget);
    Set<ValidationError> violations = entitySanitizer.validate(sanitizedCoreDisruptionBudget);
    if (!violations.isEmpty()) {
        safeOnError(logger, TitusServiceException.invalidArgument(violations), responseObserver);
        return Optional.empty();
    }
    return Optional.of(sanitizedCoreDisruptionBudget);
}
Also used : DisruptionBudget(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudget) JobDisruptionBudget(com.netflix.titus.grpc.protogen.JobDisruptionBudget) ValidationError(com.netflix.titus.common.model.sanitizer.ValidationError) StatusRuntimeException(io.grpc.StatusRuntimeException) TitusServiceException(com.netflix.titus.api.service.TitusServiceException) JobManagerException(com.netflix.titus.api.jobmanager.service.JobManagerException)

Aggregations

JobDisruptionBudget (com.netflix.titus.grpc.protogen.JobDisruptionBudget)2 DisruptionBudget (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudget)1 JobManagerException (com.netflix.titus.api.jobmanager.service.JobManagerException)1 TitusServiceException (com.netflix.titus.api.service.TitusServiceException)1 ValidationError (com.netflix.titus.common.model.sanitizer.ValidationError)1 JobDisruptionBudgetUpdate (com.netflix.titus.grpc.protogen.JobDisruptionBudgetUpdate)1 StatusRuntimeException (io.grpc.StatusRuntimeException)1 Test (org.junit.Test)1 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)1