Search in sources :

Example 6 with EmptyAmbariResponse

use of com.sequenceiq.it.spark.ambari.EmptyAmbariResponse in project cloudbreak by hortonworks.

the class InstanceTerminationMock method addAmbariMappings.

public void addAmbariMappings(String clusterName) {
    Map<String, CloudVmMetaDataStatus> instanceMap = getInstanceMap();
    Service sparkService = getSparkService();
    int requestId = 100;
    sparkService.delete(AMBARI_API_ROOT + "/clusters/:cluster/hosts/:hostname", new EmptyAmbariResponse());
    sparkService.delete(AMBARI_API_ROOT + "/clusters/:cluster/hosts/:hostname/host_components/*", new EmptyAmbariResponse());
    sparkService.get(AMBARI_API_ROOT + "/clusters/:cluster/hosts/:hostname/host_components/*", new AmbariComponentStatusOnHostResponse());
    sparkService.post(AMBARI_API_ROOT + "/clusters/" + clusterName + "/requests", new AmbariRequestIdRespone(requestId));
    sparkService.get(AMBARI_API_ROOT + "/clusters/" + clusterName + "/requests/100", new AmbariRequestStatusResponse(requestId, 100));
    sparkService.put(AMBARI_API_ROOT + "/clusters/" + clusterName + "/requests/" + requestId, new EmptyAmbariClusterResponse());
    sparkService.put(AMBARI_API_ROOT + "/clusters/" + clusterName + "/host_components", new AmbariStrRequestIdRespone(requestId));
    sparkService.get(AMBARI_API_ROOT + "/clusters/:cluster/hosts", new AmbariHostComponentStateResponse(instanceMap));
    sparkService.get(AMBARI_API_ROOT + "/clusters/:cluster/hosts/:hostname", new AmbariHostResponse());
    sparkService.get(AMBARI_API_ROOT + "/clusters", new AmbariClusterResponse(instanceMap, clusterName));
    sparkService.get(AMBARI_API_ROOT + "/clusters/" + clusterName, new AmbariClustersHostsResponse(instanceMap, "SUCCESSFUL"));
    sparkService.post(AMBARI_API_ROOT + "/clusters/" + clusterName, new EmptyAmbariClusterResponse());
    sparkService.get(AMBARI_API_ROOT + "/clusters/:cluster/hosts/:hostname/host_components", new AmbariComponentStatusOnHostResponse());
    sparkService.get(AMBARI_API_ROOT + "/clusters/" + clusterName + "/configurations/service_config_versions", new AmbariServiceConfigResponse(getMockServerAddress(), getMockPort()), gson()::toJson);
    sparkService.get(AMBARI_API_ROOT + "/blueprints/:blueprintname", (request, response) -> {
        response.type("text/plain");
        return responseFromJsonFile("blueprint/" + request.params("blueprintname") + ".bp");
    });
}
Also used : AmbariHostResponse(com.sequenceiq.it.spark.ambari.v2.AmbariHostResponse) AmbariComponentStatusOnHostResponse(com.sequenceiq.it.spark.ambari.AmbariComponentStatusOnHostResponse) EmptyAmbariClusterResponse(com.sequenceiq.it.spark.ambari.EmptyAmbariClusterResponse) Service(spark.Service) AmbariRequestStatusResponse(com.sequenceiq.it.spark.ambari.v2.AmbariRequestStatusResponse) AmbariStrRequestIdRespone(com.sequenceiq.it.spark.ambari.v2.AmbariStrRequestIdRespone) AmbariRequestIdRespone(com.sequenceiq.it.spark.ambari.v2.AmbariRequestIdRespone) EmptyAmbariResponse(com.sequenceiq.it.spark.ambari.EmptyAmbariResponse) EmptyAmbariClusterResponse(com.sequenceiq.it.spark.ambari.EmptyAmbariClusterResponse) AmbariClusterResponse(com.sequenceiq.it.spark.ambari.AmbariClusterResponse) CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus) AmbariClustersHostsResponse(com.sequenceiq.it.spark.ambari.v2.AmbariClustersHostsResponse) AmbariServiceConfigResponse(com.sequenceiq.it.spark.ambari.AmbariServiceConfigResponse) AmbariHostComponentStateResponse(com.sequenceiq.it.spark.ambari.v2.AmbariHostComponentStateResponse)

Example 7 with EmptyAmbariResponse

use of com.sequenceiq.it.spark.ambari.EmptyAmbariResponse in project cloudbreak by hortonworks.

the class MockSparkServer method addAmbariMappings.

private static void addAmbariMappings(Map<String, CloudVmMetaDataStatus> instanceMap) {
    post(AMBARI_API_ROOT + "/views/:view/versions/1.0.0/instances/*", new EmptyAmbariResponse());
    get(AMBARI_API_ROOT + "/views/*", new AmbariViewResponse(MOCK_SERVER_ADDRESS));
    get(AMBARI_API_ROOT + "/clusters", new AmbariClusterResponse(instanceMap));
    get(AMBARI_API_ROOT + "/clusters/:cluster", (req, resp) -> {
        ITResponse itResp = CLUSTER_CREATED.contains(Integer.valueOf(req.params(":cluster"))) ? new AmbariClusterResponse(instanceMap) : new EmptyAmbariClusterResponse();
        return itResp.handle(req, resp);
    });
    get(AMBARI_API_ROOT + "/clusters/:cluster/hosts", new AmbariClustersHostsResponse(instanceMap, "SUCCESSFUL"));
    post(AMBARI_API_ROOT + "/clusters/:cluster/requests", new AmbariClusterRequestsResponse());
    get(AMBARI_API_ROOT + "/clusters/:cluster/requests/:request", new AmbariStatusResponse());
    post(AMBARI_API_ROOT + "/clusters/:cluster", (req, resp) -> {
        CLUSTER_CREATED.add(Integer.valueOf(req.params(":cluster")));
        return new EmptyAmbariResponse().handle(req, resp);
    }, GSON::toJson);
    get(AMBARI_API_ROOT + "/services/AMBARI/components/AMBARI_SERVER", new AmbariServicesComponentsResponse(), GSON::toJson);
    get(AMBARI_API_ROOT + "/hosts", new AmbariHostsResponse(instanceMap), GSON::toJson);
    get(AMBARI_API_ROOT + "/blueprints/:blueprintname", (request, response) -> {
        response.type("text/plain");
        return responseFromJsonFile("blueprint/" + request.params("blueprintname") + ".bp");
    });
    post(AMBARI_API_ROOT + "/blueprints/*", new EmptyAmbariResponse());
    put(AMBARI_API_ROOT + "/users/admin", new EmptyAmbariResponse());
    post(AMBARI_API_ROOT + "/users", new EmptyAmbariResponse());
    get(AMBARI_API_ROOT + "/check", new AmbariCheckResponse());
    put(AMBARI_API_ROOT + "/stacks/HDP/versions/:version/operating_systems/:os/repositories/:hdpversion", new EmptyAmbariResponse());
    get(AMBARI_API_ROOT + "/version_definitions", new AmbariVersionDefinitionResponse());
    post(AMBARI_API_ROOT + "/version_definitions", new EmptyAmbariResponse());
}
Also used : AmbariVersionDefinitionResponse(com.sequenceiq.it.spark.ambari.AmbariVersionDefinitionResponse) AmbariHostsResponse(com.sequenceiq.it.spark.ambari.AmbariHostsResponse) AmbariViewResponse(com.sequenceiq.it.spark.ambari.AmbariViewResponse) EmptyAmbariClusterResponse(com.sequenceiq.it.spark.ambari.EmptyAmbariClusterResponse) AmbariClusterRequestsResponse(com.sequenceiq.it.spark.ambari.AmbariClusterRequestsResponse) AmbariStatusResponse(com.sequenceiq.it.spark.ambari.AmbariStatusResponse) EmptyAmbariResponse(com.sequenceiq.it.spark.ambari.EmptyAmbariResponse) EmptyAmbariClusterResponse(com.sequenceiq.it.spark.ambari.EmptyAmbariClusterResponse) AmbariClusterResponse(com.sequenceiq.it.spark.ambari.AmbariClusterResponse) AmbariClustersHostsResponse(com.sequenceiq.it.spark.ambari.AmbariClustersHostsResponse) AmbariServicesComponentsResponse(com.sequenceiq.it.spark.ambari.AmbariServicesComponentsResponse) AmbariCheckResponse(com.sequenceiq.it.spark.ambari.AmbariCheckResponse)

Example 8 with EmptyAmbariResponse

use of com.sequenceiq.it.spark.ambari.EmptyAmbariResponse in project cloudbreak by hortonworks.

the class ScalingMock method addAmbariMappings.

public void addAmbariMappings(String clusterName) {
    Service sparkService = getSparkService();
    Map<String, CloudVmMetaDataStatus> instanceMap = getInstanceMap();
    sparkService.get(AMBARI_API_ROOT + "/check", new AmbariCheckResponse());
    sparkService.get(AMBARI_API_ROOT + "/clusters/:cluster/requests/:request", new AmbariStatusResponse());
    sparkService.get(AMBARI_API_ROOT + "/clusters", new AmbariClusterResponse(instanceMap, clusterName));
    sparkService.post(AMBARI_API_ROOT + "/clusters/:cluster/requests", new AmbariClusterRequestsResponse());
    sparkService.post(AMBARI_API_ROOT + "/clusters/:cluster", new EmptyAmbariResponse());
    sparkService.get(AMBARI_API_ROOT + "/clusters/:cluster", new AmbariClusterResponse(instanceMap, clusterName));
    sparkService.get(AMBARI_API_ROOT + "/hosts", new AmbariHostsResponse(instanceMap), gson()::toJson);
    sparkService.get(AMBARI_API_ROOT + "/clusters/:cluster/hosts", new AmbariClustersHostsResponse(instanceMap, "INSTALLED"));
    sparkService.put(AMBARI_API_ROOT + "/clusters/:cluster/services/*", new AmbariClusterRequestsResponse());
    sparkService.post(AMBARI_API_ROOT + "/clusters/:cluster/hosts", new AmbariClusterRequestsResponse());
    sparkService.get(AMBARI_API_ROOT + "/clusters/:cluster/hosts/:hostname/host_components/*", new AmbariComponentStatusOnHostResponse());
    sparkService.get(AMBARI_API_ROOT + "/clusters/" + clusterName + "/configurations/service_config_versions", new AmbariServiceConfigResponse(getMockServerAddress(), getMockPort()), gson()::toJson);
    sparkService.get(AMBARI_API_ROOT + "/blueprints/:blueprintname", (request, response) -> {
        response.type("text/plain");
        return responseFromJsonFile("blueprint/" + request.params("blueprintname") + ".bp");
    });
    sparkService.get(AMBARI_API_ROOT + "/clusters/:clusterName/hosts/:internalhostname", (request, response) -> {
        response.type("text/plain");
        ObjectNode rootNode = JsonNodeFactory.instance.objectNode();
        rootNode.putObject("Hosts").put("public_host_name", request.params("internalhostname")).put("host_status", "HEALTHY");
        return rootNode;
    });
    sparkService.get(AMBARI_API_ROOT + "/clusters/:clusterName/services/HDFS/components/NAMENODE", (request, response) -> {
        response.type("text/plain");
        ObjectNode rootNode = JsonNodeFactory.instance.objectNode();
        ObjectNode nameNode = rootNode.putObject("metrics").putObject("dfs").putObject("namenode");
        ObjectNode liveNodesRoot = JsonNodeFactory.instance.objectNode();
        for (CloudVmMetaDataStatus status : instanceMap.values()) {
            ObjectNode node = liveNodesRoot.putObject(HostNameUtil.generateHostNameByIp(status.getMetaData().getPrivateIp()));
            node.put("remaining", "10000000");
            node.put("usedSpace", Integer.toString(100000));
            node.put("adminState", "In Service");
        }
        nameNode.put("LiveNodes", liveNodesRoot.toString());
        nameNode.put("DecomNodes", "{}");
        return rootNode;
    });
    sparkService.put(AMBARI_API_ROOT + "/clusters/:cluster/host_components", new AmbariClusterRequestsResponse());
    sparkService.delete(AMBARI_API_ROOT + "/clusters/:cluster/hosts/:hostname/host_components/*", new EmptyAmbariResponse());
    sparkService.delete(AMBARI_API_ROOT + "/clusters/:cluster/hosts/:hostname", new AmbariClusterRequestsResponse());
    sparkService.post(AMBARI_API_ROOT + "/users", new EmptyAmbariResponse());
}
Also used : AmbariComponentStatusOnHostResponse(com.sequenceiq.it.spark.ambari.AmbariComponentStatusOnHostResponse) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) AmbariHostsResponse(com.sequenceiq.it.spark.ambari.AmbariHostsResponse) Service(spark.Service) AmbariClusterRequestsResponse(com.sequenceiq.it.spark.ambari.AmbariClusterRequestsResponse) AmbariStatusResponse(com.sequenceiq.it.spark.ambari.AmbariStatusResponse) EmptyAmbariResponse(com.sequenceiq.it.spark.ambari.EmptyAmbariResponse) AmbariClusterResponse(com.sequenceiq.it.spark.ambari.AmbariClusterResponse) CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus) AmbariClustersHostsResponse(com.sequenceiq.it.spark.ambari.AmbariClustersHostsResponse) AmbariServiceConfigResponse(com.sequenceiq.it.spark.ambari.AmbariServiceConfigResponse) AmbariCheckResponse(com.sequenceiq.it.spark.ambari.AmbariCheckResponse)

Aggregations

AmbariClusterResponse (com.sequenceiq.it.spark.ambari.AmbariClusterResponse)8 EmptyAmbariResponse (com.sequenceiq.it.spark.ambari.EmptyAmbariResponse)8 CloudVmMetaDataStatus (com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus)6 EmptyAmbariClusterResponse (com.sequenceiq.it.spark.ambari.EmptyAmbariClusterResponse)6 Service (spark.Service)6 AmbariComponentStatusOnHostResponse (com.sequenceiq.it.spark.ambari.AmbariComponentStatusOnHostResponse)5 AmbariServiceConfigResponse (com.sequenceiq.it.spark.ambari.AmbariServiceConfigResponse)5 AmbariCheckResponse (com.sequenceiq.it.spark.ambari.AmbariCheckResponse)4 AmbariClusterRequestsResponse (com.sequenceiq.it.spark.ambari.AmbariClusterRequestsResponse)4 AmbariClustersHostsResponse (com.sequenceiq.it.spark.ambari.AmbariClustersHostsResponse)4 AmbariHostsResponse (com.sequenceiq.it.spark.ambari.AmbariHostsResponse)4 AmbariStatusResponse (com.sequenceiq.it.spark.ambari.AmbariStatusResponse)4 AmbariClustersHostsResponse (com.sequenceiq.it.spark.ambari.v2.AmbariClustersHostsResponse)4 AmbariHostComponentStateResponse (com.sequenceiq.it.spark.ambari.v2.AmbariHostComponentStateResponse)4 AmbariHostResponse (com.sequenceiq.it.spark.ambari.v2.AmbariHostResponse)4 AmbariRequestIdRespone (com.sequenceiq.it.spark.ambari.v2.AmbariRequestIdRespone)4 AmbariRequestStatusResponse (com.sequenceiq.it.spark.ambari.v2.AmbariRequestStatusResponse)4 AmbariStrRequestIdRespone (com.sequenceiq.it.spark.ambari.v2.AmbariStrRequestIdRespone)4 AmbariServicesComponentsResponse (com.sequenceiq.it.spark.ambari.AmbariServicesComponentsResponse)3 AmbariVersionDefinitionResponse (com.sequenceiq.it.spark.ambari.AmbariVersionDefinitionResponse)2