Search in sources :

Example 6 with DeletePolicyRequest

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

the class AggregatingAutoScalingService method deleteAutoScalingPolicy.

@Override
public Completable deleteAutoScalingPolicy(DeletePolicyRequest request, CallMetadata callMetadata) {
    ScalingPolicyID policyId = request.getId();
    Observable<Empty> observable = getScalingPolicyInAllCells(policyId, callMetadata).flatMap(response -> singleCellCall(response.getCell(), (client, responseObserver) -> client.deleteAutoScalingPolicy(request, responseObserver), callMetadata));
    return observable.toCompletable();
}
Also used : Completable(rx.Completable) UpdatePolicyRequest(com.netflix.titus.grpc.protogen.UpdatePolicyRequest) Cell(com.netflix.titus.api.federation.model.Cell) DeletePolicyRequest(com.netflix.titus.grpc.protogen.DeletePolicyRequest) GrpcUtil.createWrappedStub(com.netflix.titus.runtime.endpoint.common.grpc.GrpcUtil.createWrappedStub) Singleton(javax.inject.Singleton) AutoScalingServiceStub(com.netflix.titus.grpc.protogen.AutoScalingServiceGrpc.AutoScalingServiceStub) PutPolicyRequest(com.netflix.titus.grpc.protogen.PutPolicyRequest) Observable(rx.Observable) Inject(javax.inject.Inject) Empty(com.google.protobuf.Empty) GetPolicyResult(com.netflix.titus.grpc.protogen.GetPolicyResult) CellConnectorUtil.callToCell(com.netflix.titus.federation.service.CellConnectorUtil.callToCell) StreamObserver(io.grpc.stub.StreamObserver) GrpcConfiguration(com.netflix.titus.federation.startup.GrpcConfiguration) ScalingPolicyID(com.netflix.titus.grpc.protogen.ScalingPolicyID) AbstractStub(io.grpc.stub.AbstractStub) AutoScalingServiceGrpc(com.netflix.titus.grpc.protogen.AutoScalingServiceGrpc) AutoScalingService(com.netflix.titus.runtime.service.AutoScalingService) BiConsumer(java.util.function.BiConsumer) CallMetadata(com.netflix.titus.api.model.callmetadata.CallMetadata) JobId(com.netflix.titus.grpc.protogen.JobId) Empty(com.google.protobuf.Empty) ScalingPolicyID(com.netflix.titus.grpc.protogen.ScalingPolicyID)

Example 7 with DeletePolicyRequest

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

the class AutoScalingGrpcTest method testDeletePolicyById.

/**
 * Test that a policy can be deleted.
 *
 * @throws Exception
 */
@Test(timeout = TEST_TIMEOUT_MS)
public void testDeletePolicyById() throws Exception {
    // Put a policy
    String jobId = "Titus-1";
    PutPolicyRequest putPolicyRequest = AutoScalingTestUtils.generatePutPolicyRequest(jobId, PolicyType.StepScaling);
    TestStreamObserver<ScalingPolicyID> putResponse = new TestStreamObserver<>();
    client.setAutoScalingPolicy(putPolicyRequest, putResponse);
    ScalingPolicyID scalingPolicyID = putResponse.takeNext(TIMEOUT_MS, TimeUnit.MILLISECONDS);
    assertThat(!scalingPolicyID.getId().isEmpty());
    // Delete the policy
    TestStreamObserver<Empty> deletePolicyResult = new TestStreamObserver<>();
    DeletePolicyRequest deletePolicyRequest = DeletePolicyRequest.newBuilder().setId(scalingPolicyID).build();
    client.deleteAutoScalingPolicy(deletePolicyRequest, deletePolicyResult);
    deletePolicyResult.awaitDone();
    assertThat(deletePolicyResult.hasError()).isFalse();
    // Make sure it's set to Deleting or Deleted state
    TestStreamObserver<GetPolicyResult> getResponse = new TestStreamObserver<>();
    client.getScalingPolicy(scalingPolicyID, getResponse);
    GetPolicyResult getPolicyResult = getResponse.takeNext(TIMEOUT_MS, TimeUnit.MILLISECONDS);
    log.info("Got result {}", getPolicyResult);
    assertThat(getPolicyResult.getItemsCount()).isEqualTo(1);
    assertThat(isDeletingState(getPolicyResult.getItems(0).getPolicyState()));
}
Also used : DeletePolicyRequest(com.netflix.titus.grpc.protogen.DeletePolicyRequest) PutPolicyRequest(com.netflix.titus.grpc.protogen.PutPolicyRequest) Empty(com.google.protobuf.Empty) ScalingPolicyID(com.netflix.titus.grpc.protogen.ScalingPolicyID) TestStreamObserver(com.netflix.titus.testkit.grpc.TestStreamObserver) GetPolicyResult(com.netflix.titus.grpc.protogen.GetPolicyResult) BaseIntegrationTest(com.netflix.titus.master.integration.BaseIntegrationTest) IntegrationTest(com.netflix.titus.testkit.junit.category.IntegrationTest) Test(org.junit.Test)

Aggregations

DeletePolicyRequest (com.netflix.titus.grpc.protogen.DeletePolicyRequest)7 ScalingPolicyID (com.netflix.titus.grpc.protogen.ScalingPolicyID)6 GetPolicyResult (com.netflix.titus.grpc.protogen.GetPolicyResult)4 Test (org.junit.Test)4 Empty (com.google.protobuf.Empty)3 PutPolicyRequest (com.netflix.titus.grpc.protogen.PutPolicyRequest)2 TestStreamObserver (com.netflix.titus.testkit.grpc.TestStreamObserver)2 ApiOperation (io.swagger.annotations.ApiOperation)2 Cell (com.netflix.titus.api.federation.model.Cell)1 CallMetadata (com.netflix.titus.api.model.callmetadata.CallMetadata)1 CellConnectorUtil.callToCell (com.netflix.titus.federation.service.CellConnectorUtil.callToCell)1 GrpcConfiguration (com.netflix.titus.federation.startup.GrpcConfiguration)1 AutoScalingServiceGrpc (com.netflix.titus.grpc.protogen.AutoScalingServiceGrpc)1 AutoScalingServiceStub (com.netflix.titus.grpc.protogen.AutoScalingServiceGrpc.AutoScalingServiceStub)1 JobId (com.netflix.titus.grpc.protogen.JobId)1 ScalingPolicyResult (com.netflix.titus.grpc.protogen.ScalingPolicyResult)1 UpdatePolicyRequest (com.netflix.titus.grpc.protogen.UpdatePolicyRequest)1 BaseIntegrationTest (com.netflix.titus.master.integration.BaseIntegrationTest)1 GrpcUtil.createWrappedStub (com.netflix.titus.runtime.endpoint.common.grpc.GrpcUtil.createWrappedStub)1 AutoScalingService (com.netflix.titus.runtime.service.AutoScalingService)1