This topic describes how to use Enterprise Distributed Application Service (EDAS) SDK for Java to terminate an update of an application deployed in an Elastic Compute Service (ECS) cluster by calling an API operation.
Prerequisites
- The application is being updated. For more information about how to update an application based on your business requirements, see the following topics:
- Optional:The ListRecentChangeOrder operation is called to obtain the value of the ChangeOrderId parameter. The value indicates the ID of the update. Example: 47e2b863-adc8-4a0e-ac23-8361b95a****.
If you have recorded the value of the ChangeOrderId parameter when you start an update, you do not need to call the ListRecentChangeOrder operation.
Terminate an update of an application
The following code provides an example on how to terminate an update for an application deployed in an ECS cluster in EDAS:
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.edas.model.v20170801.AbortChangeOrderRequest;
import com.aliyuncs.edas.model.v20170801.AbortChangeOrderResponse;
public class AbortChangeOrder {
public static void main(String[] args) {
// The AccessKey ID of your Alibaba Cloud account or a RAM user within the Alibaba Cloud account.
String aliyun_user_ak = "<yourAccessKeyId>";
// The AccessKey secret of your Alibaba Cloud account or a RAM user within the Alibaba Cloud account.
String aliyun_user_sk = "<yourAccessKeySecret>";
// The ID of the region where the application whose update is to be terminated resides.
String region_id = "cn-hangzhou";
DefaultProfile defaultProfile = DefaultProfile.getProfile(region_id, aliyun_user_ak, aliyun_user_sk);
DefaultAcsClient client = new DefaultAcsClient(defaultProfile);
// Create an API request and set the parameters.
AbortChangeOrderRequest request = new AbortChangeOrderRequest();
// The update ID of the application.
request.setChangeOrderId("47e2b863-adc8-4a0e-ac23-8361b95a****");
try {
AbortChangeOrderResponse response = client.getAcsResponse(request);
System.out.println("Message=" + response.getMessage() + "\nRequestId=" + response.getRequestId());
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
e.printStackTrace();
}
}
}
Message=success
RequestId=19C54DC3-C66C-40D0-AEED-8D5A1F00F3BA
Verify the result
After you terminate an update of the application, you can call the GetChangeOrderInfo operation to view the change details and obtain the change status of the application. For more information about the API operation, see GetChangeOrderInfo.
{
"Message": "success",
"RequestId": "CCC48EB3-E628-45B4-8DF3-ED8551119742",
"Code": 200,
"changeOrderInfo": {
"Status": 6,
"Desc": "create by edas pop api",
"PipelineInfoList": {
"PipelineInfo": [
{
......
// The sample response is incomplete and is only for reference.
- 0: ready
- 1: in progress
- 2: successful
- 3: failed
- 6: terminated
- 8: wait for manual confirmation to trigger the next phase during a manual phased release
- 9: wait to trigger the next phase during an automatic phased release
- 10: failed due to a system exception