use of com.sequenceiq.it.spark.ambari.AmbariComponentStatusOnHostResponse in project cloudbreak by hortonworks.
the class InstanceTerminationReplicationErrorMock 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");
});
}
use of com.sequenceiq.it.spark.ambari.AmbariComponentStatusOnHostResponse in project cloudbreak by hortonworks.
the class InstanceTerminationReplicationMock 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");
});
}
use of com.sequenceiq.it.spark.ambari.AmbariComponentStatusOnHostResponse in project cloudbreak by hortonworks.
the class InstanceTerminationUnknownMock 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(AmbariHostResponse.UNKNOWN));
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");
});
}
use of com.sequenceiq.it.spark.ambari.AmbariComponentStatusOnHostResponse 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");
});
}
use of com.sequenceiq.it.spark.ambari.AmbariComponentStatusOnHostResponse 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());
}
Aggregations