伸缩组接口
更新时间:2024-06-13
查询伸缩组列表
查询所有伸缩组的详细信息
public static void listAsGroup(AsGroupClient asGroupClient, String groupName, String marker, int maxKeys) {
ListAsGroupRequest listAsGroupRequest = new ListAsGroupRequest();
// 可选,伸缩组名称
listAsGroupRequest.setGroupName(groupName);
// 可选,批量获取列表的查询的起始位置,是一个由系统生成的字符串
listAsGroupRequest.setMarker(marker);
// 可选,每页包含的最大数量,最大数量通常不超过1000。缺省值为1000
listAsGroupRequest.setMaxKeys(maxKeys);
ListAsGroupResponse listAsGroupResponse = asGroupClient.listAsGroup(listAsGroupRequest);
}
查询伸缩组详情
查询单个伸缩组的详细信息
public static void getAsGroup(AsGroupClient asGroupClient, String groupId) {
GetAsGroupRequest getAsGroupRequest = new GetAsGroupRequest();
// 必填,待查询的伸缩组ID
getAsGroupRequest.setGroupId(groupId);
GetAsGroupResponse asGroup = asGroupClient.getAsGroup(getAsGroupRequest);
}
伸缩组扩容
在指定伸缩组下添加节点
public static void increaseAsGroup(AsGroupClient asGroupClient, String groupId, int nodeCount) {
IncreaseAsGroupRequest increaseAsGroupRequest = new IncreaseAsGroupRequest();
// 待添加节点的伸缩组ID
increaseAsGroupRequest.setGroupId(groupId);
// 新增节点数量
increaseAsGroupRequest.setNodeCount(nodeCount);
IncreaseAsGroupResponse increaseAsGroupResponse = asGroupClient.increaseAsGroup(increaseAsGroupRequest);
}
伸缩组缩容
用于伸缩组下节点的缩容
public static void decreaseAsGroup(AsGroupClient asGroupClient, String groupId, int actionNum) {
DecreaseAsGroupRequest decreaseAsGroupRequest = new DecreaseAsGroupRequest();
// 待执行缩容行为的伸缩组ID
decreaseAsGroupRequest.setGroupId(groupId);
// 减少节点数量
decreaseAsGroupRequest.setActionNum(actionNum);
DecreaseAsGroupResponse decreaseAsGroupResponse = asGroupClient.decreaseAsGroup(decreaseAsGroupRequest);
}
- 当前伸缩组处于运行中状态,触发成功并返回TaskId
- 当前伸缩组不处于运行中状态,触发失败并返回失败信息
伸缩组节点数量调
用于伸缩组下节点的数量调整
public static void adjustAsGroup(AsGroupClient asGroupClient, String groupId, int actionNum) {
AdjustAsGroupRequest adjustAsGroupRequest = new AdjustAsGroupRequest();
// 待执行调整行为的伸缩组ID
adjustAsGroupRequest.setGroupId(groupId);
// 节点数量调整为
adjustAsGroupRequest.setActionNum(actionNum);
AdjustAsGroupResponse adjustAsGroupResponse = asGroupClient.adjustAsGroup(adjustAsGroupRequest);
}
- 当前伸缩组处于运行中状态,触发成功并返回TaskId
- 当前伸缩组不处于运行中状态,触发失败并返回失败信息
查询伸缩组下节点列表
查询指定伸缩组下节点的详细信息
public static void listAsNode(AsGroupClient asGroupClient, String groupId, String marker, int maxKeys) {
ListAsNodeRequest listAsNodeRequest = new ListAsNodeRequest();
// 必填,伸缩组ID
listAsNodeRequest.setGroupId(groupId);
// 选填,批量获取列表的查询的起始位置,是一个由系统生成的字符串
listAsNodeRequest.setMarker(marker);
// 选填,每页包含的最大数量,最大数量通常不超过1000。缺省值为1000
listAsNodeRequest.setMaxKeys(maxKeys);
ListAsNodeResponse listAsNodeResponse = asGroupClient.listAsNode(listAsNodeRequest);
}