Search in sources :

Example 16 with ScalingPolicyResult

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

the class DefaultAutoScalingServiceGrpc method getScalingPolicy.

@Override
public void getScalingPolicy(com.netflix.titus.grpc.protogen.ScalingPolicyID request, io.grpc.stub.StreamObserver<com.netflix.titus.grpc.protogen.GetPolicyResult> responseObserver) {
    // FIXME: make NOT_FOUND an explicit error condition
    // appScaleManager.getScalingPolicy(id) will return an empty Observable when the id is not found, which makes
    // the gRPC handler throw an exception (INTERNAL: Completed without a response). This error should be an
    // explicit condition of the API, and mapped to Status.NOT_FOUND
    appScaleManager.getScalingPolicy(request.getId()).subscribe(autoScalingPolicyInternal -> {
        ScalingPolicyResult scalingPolicyResult = GrpcModelConverters.toScalingPolicyResult(autoScalingPolicyInternal);
        responseObserver.onNext(GetPolicyResult.newBuilder().addItems(scalingPolicyResult).build());
    }, e -> safeOnError(logger, e, responseObserver), responseObserver::onCompleted);
}
Also used : ScalingPolicyResult(com.netflix.titus.grpc.protogen.ScalingPolicyResult)

Example 17 with ScalingPolicyResult

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

the class DefaultAutoScalingServiceGrpc method completePolicyList.

private void completePolicyList(Observable<AutoScalingPolicy> policyObservable, io.grpc.stub.StreamObserver<com.netflix.titus.grpc.protogen.GetPolicyResult> responseObserver) {
    List<ScalingPolicyResult> scalingPolicyResultList = new ArrayList<>();
    policyObservable.subscribe(autoScalingPolicyInternal -> {
        ScalingPolicyResult scalingPolicyResult = GrpcModelConverters.toScalingPolicyResult(autoScalingPolicyInternal);
        scalingPolicyResultList.add(scalingPolicyResult);
    }, e -> safeOnError(logger, e, responseObserver), () -> {
        responseObserver.onNext(GetPolicyResult.newBuilder().addAllItems(scalingPolicyResultList).build());
        responseObserver.onCompleted();
    });
}
Also used : ScalingPolicyResult(com.netflix.titus.grpc.protogen.ScalingPolicyResult) ArrayList(java.util.ArrayList)

Aggregations

ScalingPolicyResult (com.netflix.titus.grpc.protogen.ScalingPolicyResult)17 ScalingPolicyID (com.netflix.titus.grpc.protogen.ScalingPolicyID)13 Test (org.junit.Test)13 GetPolicyResult (com.netflix.titus.grpc.protogen.GetPolicyResult)12 AutoScalingResource (com.netflix.titus.runtime.endpoint.v3.rest.AutoScalingResource)6 UpdatePolicyRequest (com.netflix.titus.grpc.protogen.UpdatePolicyRequest)2 Response (javax.ws.rs.core.Response)2 DoubleValue (com.google.protobuf.DoubleValue)1 DeletePolicyRequest (com.netflix.titus.grpc.protogen.DeletePolicyRequest)1 JobId (com.netflix.titus.grpc.protogen.JobId)1 ScalingPolicy (com.netflix.titus.grpc.protogen.ScalingPolicy)1 TestStreamObserver (com.netflix.titus.testkit.grpc.TestStreamObserver)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1