use of com.netflix.titus.grpc.protogen.ServiceJobSpec in project titus-control-plane by Netflix.
the class JobTemplateCommand method createServiceJobDescriptor.
private JobDescriptor createServiceJobDescriptor() {
Container container = createContainer().addAllEntryPoint(asList("sleep", "30")).build();
ServiceJobSpec jobSpec = ServiceJobSpec.newBuilder().setCapacity(Capacity.newBuilder().setMin(1).setDesired(5).setMax(10).build()).setEnabled(true).setRetryPolicy(RetryPolicy.newBuilder().setDelayed(RetryPolicy.Delayed.newBuilder().setDelayMs(1000).setRetries(3))).build();
return JobDescriptor.newBuilder().setApplicationName("myServiceApp").setOwner(createUser()).setCapacityGroup("service_workloads").setContainer(container).putAllAttributes(createLabels()).setJobGroupInfo(createJobGroupInfo()).setService(jobSpec).build();
}
use of com.netflix.titus.grpc.protogen.ServiceJobSpec in project titus-control-plane by Netflix.
the class DefaultAppAutoScalingCallbackService method getScalableTargetResourceInfo.
@Override
public Observable<ScalableTargetResourceInfo> getScalableTargetResourceInfo(String jobId, CallMetadata callMetadata) {
TaskQuery taskQuery = TaskQuery.newBuilder().putFilteringCriteria("jobIds", jobId).putFilteringCriteria("taskStates", "Started").setPage(Page.newBuilder().setPageSize(1).build()).build();
return jobServiceGateway.findTasks(taskQuery, callMetadata).map(taskQueryResult -> taskQueryResult.getPagination().getTotalItems()).flatMap(numStartedTasks -> jobServiceGateway.findJob(jobId, callMetadata).map(job -> Pair.of(job, numStartedTasks))).flatMap(jobTasksPair -> {
Job job = jobTasksPair.getLeft();
Integer numRunningTasks = jobTasksPair.getRight();
if (!job.getJobDescriptor().hasService()) {
return Observable.error(JobManagerException.notServiceJob(jobId));
}
ServiceJobSpec jobSpec = job.getJobDescriptor().getService();
ScalableTargetResourceInfo.Builder scalableTargetResourceInfoBuilder = ScalableTargetResourceInfo.newBuilder().actualCapacity(jobTasksPair.getRight()).desiredCapacity(jobSpec.getCapacity().getDesired()).dimensionName(DIMENSION_NAME).resourceName(jobId).scalableTargetDimensionId(jobId).version(buildVersion(job));
if (jobSpec.getCapacity().getDesired() != numRunningTasks) {
scalableTargetResourceInfoBuilder.scalingStatus(ScalingStatus.InProgress.name());
} else {
scalableTargetResourceInfoBuilder.scalingStatus(ScalingStatus.Successful.name());
}
return Observable.just(scalableTargetResourceInfoBuilder.build());
});
}
Aggregations