Search in sources :

Example 1 with CloudVmInstanceStatuses

use of com.sequenceiq.it.spark.spi.CloudVmInstanceStatuses in project cloudbreak by hortonworks.

the class ScalingMock method addSPIEndpoints.

public void addSPIEndpoints() {
    Service sparkService = getSparkService();
    Map<String, CloudVmMetaDataStatus> instanceMap = getInstanceMap();
    sparkService.post(MOCK_ROOT + "/cloud_metadata_statuses", new CloudMetaDataStatuses(instanceMap), gson()::toJson);
    sparkService.post(MOCK_ROOT + "/cloud_instance_statuses", new CloudVmInstanceStatuses(instanceMap), gson()::toJson);
    sparkService.post(MOCK_ROOT + "/terminate_instances", (request, response) -> {
        List<CloudInstance> cloudInstances = new Gson().fromJson(request.body(), new TypeToken<List<CloudInstance>>() {
        }.getType());
        cloudInstances.forEach(cloudInstance -> terminateInstance(instanceMap, cloudInstance.getInstanceId()));
        return null;
    }, gson()::toJson);
}
Also used : CloudVmInstanceStatuses(com.sequenceiq.it.spark.spi.CloudVmInstanceStatuses) CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus) TypeToken(com.google.common.reflect.TypeToken) CloudMetaDataStatuses(com.sequenceiq.it.spark.spi.CloudMetaDataStatuses) Service(spark.Service) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) Gson(com.google.gson.Gson)

Aggregations

TypeToken (com.google.common.reflect.TypeToken)1 Gson (com.google.gson.Gson)1 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)1 CloudVmMetaDataStatus (com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus)1 CloudMetaDataStatuses (com.sequenceiq.it.spark.spi.CloudMetaDataStatuses)1 CloudVmInstanceStatuses (com.sequenceiq.it.spark.spi.CloudVmInstanceStatuses)1 Service (spark.Service)1