- 1.3 EMR简介
- 1.3.1 基本概念
- 1.3.2 配额说明和申请
- 1.3.3 创建集群
- 1.3.4 管理集群
- 1.3.5 FDS/SDS支持
- 1.3.6 缩容
- 1.3.7 服务
- 1.3.7.1 HDFS
- 1.3.7.2 Yarn
- 1.3.7.3 Hive
- 1.3.7.4 Impala
- 1.3.7.5 Spark
- 1.3.7.6 Storm
- 1.3.8 工具
- 1.4 FAQ
- 1.5 EMR API
- 1.5.1 create
- 1.5.2 describeCluster
- 1.5.3 describeInstanceGroup
- 1.5.4 listClusters
- 1.5.5 listClustersWithPrefix
- 1.5.6 terminateCluster
- 1.5.7 modifyInstanceGroup
- 1.5.8 deleteCluster
- 1.5.9 getQuota
- 1.5.10 getEMRBasicConfig
- 1.5.11 getSoftwareConfig
- 1.5.12 getHardwareConfig
- 1.5.13 getSSHPublicKeys
- 1.5.14 addSSHPublicKeys
- 1.5.15 deleteSSHPublicKeys
- 1.6 JavaScript SDK
文章来源于网络收集而来,版权归原创者所有,如有侵权请及时联系!
1.6 JavaScript SDK
Example
<!DOCTYPE html>
<!--
-->
<html lang="en">
<head>
<meta charset="utf-8">
<title>EMR jQuery Client Test</title>
</head>
<body>
<input type="button" id="runTest" value="Test EMR Server API" >
<table style="width:600px">
<tr>
<td>API</td>
<td>Result</td>
</tr>
<tr>
<td>getServerVersion</td>
<td id="getServerVersion">NA</td>
</tr>
<tr>
<td>createCluster</td>
<td id="createCluster">NA</td>
</tr>
<tr>
<td>listClusters</td>
<td id="listClusters">NA</td>
</tr>
<tr>
<td>terminateCluster</td>
<td id="terminateCluster">NA</td>
</tr>
</table>
<script src="../../src/jquery.js"></script>
<script src="../../src/rpc/thrift.js"></script>
<script src="../../src/rpc/Common_types.js"></script>
<script src="../../src/rpc/Errors_types.js"></script>
<script src="../../src/rpc/BaseService.js"></script>
<script src="../../src/emr/EMRService_types.js"></script>
<script src="../../src/emr/EMRSchedulerService.js"></script>
<script>
(function() {
var transport = new Thrift.TXHRTransport("http://emr.api.xiaomi.com/v1/api/scheduler");
var protocol = new Thrift.TJSONProtocol(transport);
var client = new EMRSchedulerServiceClient(protocol);
var serverVersionElement = document.getElementById("getServerVersion");
var createClusterElement = document.getElementById("createCluster");
var listClustersElement = document.getElementById("listClusters");
var terminateClusterElment = document.getElementById("terminateCluster");
document.getElementById("runTest")
.addEventListener("click", function() {
client.getServerVersion(function(ver) {
serverVersionElement.innerHTML = "Server Version: " + ver.major +
"." + ver.minor + "." + ver.revision;
});
// createCluster
var createClusterRequest = new CreateClusterRequest();
createClusterRequest.name = "CreateClusterTest";
createClusterRequest.region="ec2.cn-norht-1";
createClusterRequest.purpose="emr";
createClusterRequest.addInstanceGroupRequests = [
new AddInstanceGroupRequest({
name: "master",
role: InstanceGroupRole.MASTER,
instanceType: "master.test",
requestedInstanceCount: 1}),
new AddInstanceGroupRequest({
name: "control",
role: InstanceGroupRole.CONTROL,
instanceType: "control.test",
requestedInstanceCount: 3}),
new AddInstanceGroupRequest({
name: "core",
role: InstanceGroupRole.CORE,
instanceType: "core.test",
requestedInstanceCount: 1}),
];
// send request to server
var clusterId = null;
client.createCluster(createClusterRequest, function(createClusterResponse) {
clusterId = createClusterResponse.cluserId;
createClusterElement.innerHTML = "CreateClusterResponse: " + createClusterResponse;
}).error(function(xhr, status, e) {
createClusterElement.innerHTML = "Error code " + e.errorCode + ": " + e.errorMessage;
});
client.listClusters(0, 0x7FFFFFFF, function(clusterList){
for (var idx in clusterList) {
listClusterElement.innerHTML = listClusterElement.innerHTML +
"[id:" + clusterList[idx].clusterId + ",name:" + clusterList[idx].name + "]<br>";
}
}).error(function(xhr, status, e) {
listClustersElement.innerHTML = "Error code " + e.errorCode + ": " + e.errorMessage;
});
if (clusterId != null) {
client.terminateCluster(new TerminateClusterRequest({clusterId: clusterId}), function(response) {
terminateClusterElment.innerHTML = "terminate cluster " + clusterId + " " + response;
}).error(function(xhr, status, e) {
terminateClusterElment.innerHTML = "Error code " + e.errorCode + ": " + e.errorMessage;
});
}
});
})();
</script>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论