/// <summary> /// 扩容指定集群实例的节点数量 /// </summary> public AddShardingNodeResponse AddShardingNode(AddShardingNodeRequest addShardingNodeRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add("instance_id", addShardingNodeRequest.InstanceId.ToString()); string urlPath = HttpUtils.AddUrlPath("/v3/{project_id}/instances/{instance_id}/enlarge", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, "application/json", addShardingNodeRequest); SdkResponse response = DoHttpRequest("POST", request); return(JsonUtils.DeSerialize <AddShardingNodeResponse>(response)); }
/// <summary> /// 扩容集群实例的节点数量 /// </summary> public static void EnlargeShardingNode(DdsClient client) { var req = new AddShardingNodeRequest() { InstanceId = "a25de644d3b74b86b4b3010a68897e85in02", Body = new AddShardingNodeRequestBody() { Type = AddShardingNodeRequestBody.TypeEnum.MONGOS, SpecCode = "dds.mongodb.s6.medium.4.mongos", Num = 2, Volume = new AddShardingNodeVolumeOption() { Size = 20 } } }; try { var resp = client.AddShardingNode(req); Console.WriteLine(resp.JobId); Console.WriteLine("Enlarge Instance Success!"); } catch (RequestTimeoutException requestTimeoutException) { Console.WriteLine(requestTimeoutException.ErrorMessage); } catch (ServiceResponseException clientRequestException) { Console.WriteLine(clientRequestException.HttpStatusCode); Console.WriteLine(clientRequestException.ErrorCode); Console.WriteLine(clientRequestException.ErrorMsg); } catch (ConnectionException connectionException) { Console.WriteLine(connectionException.ErrorMessage); } }