Search in sources :

Example 1 with JobCapacityUpdateWithOptionalAttributes

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

the class JobManagementSpringResourceTest method testSetCapacityWithOptionalAttributes.

@Test
public void testSetCapacityWithOptionalAttributes() throws Exception {
    JobCapacityWithOptionalAttributes restRequest = JobCapacityWithOptionalAttributes.newBuilder().setMin(UInt32Value.newBuilder().setValue(1).build()).setDesired(UInt32Value.newBuilder().setValue(2).build()).setMax(UInt32Value.newBuilder().setValue(3).build()).build();
    JobCapacityUpdateWithOptionalAttributes forwardedRequest = JobCapacityUpdateWithOptionalAttributes.newBuilder().setJobId(JOB_ID_1).setJobCapacityWithOptionalAttributes(restRequest).build();
    when(jobServiceGatewayMock.updateJobCapacityWithOptionalAttributes(forwardedRequest, JUNIT_REST_CALL_METADATA)).thenReturn(Completable.complete());
    SpringMockMvcUtil.doPut(mockMvc, String.format("/api/v3/jobs/%s/capacityAttributes", JOB_ID_1), restRequest);
    verify(jobServiceGatewayMock, times(1)).updateJobCapacityWithOptionalAttributes(forwardedRequest, JUNIT_REST_CALL_METADATA);
}
Also used : JobCapacityUpdateWithOptionalAttributes(com.netflix.titus.grpc.protogen.JobCapacityUpdateWithOptionalAttributes) JobCapacityWithOptionalAttributes(com.netflix.titus.grpc.protogen.JobCapacityWithOptionalAttributes) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest) Test(org.junit.Test)

Example 2 with JobCapacityUpdateWithOptionalAttributes

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

the class DefaultAppAutoScalingCallbackService method setScalableTargetResourceInfo.

@Override
public Observable<ScalableTargetResourceInfo> setScalableTargetResourceInfo(String jobId, ScalableTargetResourceInfo scalableTargetResourceInfo, CallMetadata callMetadata) {
    logger.info("(BEFORE setting job instances) for jobId {} :: {}", jobId, scalableTargetResourceInfo);
    JobCapacityWithOptionalAttributes jobCapacityWithOptionalAttributes = JobCapacityWithOptionalAttributes.newBuilder().setDesired(UInt32Value.newBuilder().setValue(scalableTargetResourceInfo.getDesiredCapacity()).build()).build();
    JobCapacityUpdateWithOptionalAttributes jobCapacityRequest = JobCapacityUpdateWithOptionalAttributes.newBuilder().setJobId(jobId).setJobCapacityWithOptionalAttributes(jobCapacityWithOptionalAttributes).build();
    return jobServiceGateway.updateJobCapacityWithOptionalAttributes(jobCapacityRequest, callMetadata).andThen(getScalableTargetResourceInfo(jobId, callMetadata).map(scalableTargetResourceInfoReturned -> {
        scalableTargetResourceInfoReturned.setScalingStatus(ScalingStatus.Pending.name());
        logger.info("(set job instances) Returning value Instances for jobId {} :: {}", jobId, scalableTargetResourceInfo);
        return scalableTargetResourceInfoReturned;
    }));
}
Also used : JobCapacityUpdateWithOptionalAttributes(com.netflix.titus.grpc.protogen.JobCapacityUpdateWithOptionalAttributes) Logger(org.slf4j.Logger) ServiceJobSpec(com.netflix.titus.grpc.protogen.ServiceJobSpec) UInt32Value(com.google.protobuf.UInt32Value) JobStatus(com.netflix.titus.grpc.protogen.JobStatus) LoggerFactory(org.slf4j.LoggerFactory) Job(com.netflix.titus.grpc.protogen.Job) Singleton(javax.inject.Singleton) ArrayList(java.util.ArrayList) Page(com.netflix.titus.grpc.protogen.Page) Observable(rx.Observable) Inject(javax.inject.Inject) List(java.util.List) Pair(com.netflix.titus.common.util.tuple.Pair) Optional(java.util.Optional) JobManagerException(com.netflix.titus.api.jobmanager.service.JobManagerException) JobServiceGateway(com.netflix.titus.runtime.jobmanager.gateway.JobServiceGateway) JobCapacityWithOptionalAttributes(com.netflix.titus.grpc.protogen.JobCapacityWithOptionalAttributes) TaskQuery(com.netflix.titus.grpc.protogen.TaskQuery) CallMetadata(com.netflix.titus.api.model.callmetadata.CallMetadata) JobCapacityUpdateWithOptionalAttributes(com.netflix.titus.grpc.protogen.JobCapacityUpdateWithOptionalAttributes) JobCapacityWithOptionalAttributes(com.netflix.titus.grpc.protogen.JobCapacityWithOptionalAttributes)

Aggregations

JobCapacityUpdateWithOptionalAttributes (com.netflix.titus.grpc.protogen.JobCapacityUpdateWithOptionalAttributes)2 JobCapacityWithOptionalAttributes (com.netflix.titus.grpc.protogen.JobCapacityWithOptionalAttributes)2 UInt32Value (com.google.protobuf.UInt32Value)1 JobManagerException (com.netflix.titus.api.jobmanager.service.JobManagerException)1 CallMetadata (com.netflix.titus.api.model.callmetadata.CallMetadata)1 Pair (com.netflix.titus.common.util.tuple.Pair)1 Job (com.netflix.titus.grpc.protogen.Job)1 JobStatus (com.netflix.titus.grpc.protogen.JobStatus)1 Page (com.netflix.titus.grpc.protogen.Page)1 ServiceJobSpec (com.netflix.titus.grpc.protogen.ServiceJobSpec)1 TaskQuery (com.netflix.titus.grpc.protogen.TaskQuery)1 JobServiceGateway (com.netflix.titus.runtime.jobmanager.gateway.JobServiceGateway)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Optional (java.util.Optional)1 Inject (javax.inject.Inject)1 Singleton (javax.inject.Singleton)1 Test (org.junit.Test)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1