loadBalance()
MilvusClient interface. This method moves segments from one query node to another to keep the load balanced.
notes
Milvus server has its internal machinery to keep the load balanced, sometimes the segments might be moved back.
R<RpcStatus> loadBalance(LoadBalanceParam requestParam);
LoadBalanceParam
Use the LoadBalanceParam.Builder
to construct a LoadBalanceParam
object.
import io.milvus.param.LoadBalanceParam;
LoadBalanceParam.Builder builder = LoadBalanceParam.newBuilder();
Methods of LoadBalanceParam.Builder
:
Method |
Description |
Parameters |
---|---|---|
withDatabaseName(String databaseName) |
Sets the database name. database name can be null for default database. |
databaseName: The database name. |
withSourceNodeID(Long srcNodeID) |
Set the ID of source query node in which the sealed segments were loaded. |
srcNodeID: The source query node ID. |
addDestinationNodeID(Long destNodeID) |
Add the ID of destination query node to which the sealed segments will be balanced. |
destNodeID: The destination query node ID. |
withDestinationNodeID(List<Long> destNodeIDs) |
Set an ID array of the destination query nodes to which the sealed segments will be balance. |
destNodeIDs: The destination query node ID array. |
addSegmentID(Long segmentID) |
Add a sealed segment ID which to be balanced. |
segmentID: A sealed segment ID. |
withSegmentIDs(List<Long> segmentIDs) |
Set an ID array of sealed segments which to be balanced. |
segmentIDs: The sealed segments ID array. |
build() |
Construct a LoadBalanceParam object. |
N/A |
The LoadBalanceParam.Builder.build()
can throw the following exceptions:
- ParamException: error if the parameter is invalid.
Returns
This method catches all the exceptions and returns an R<RpcStatus>
object.
If the API fails on the server side, it returns the error code and message from the server.
If the API fails by RPC exception, it returns
R.Status.Unknown
and error message of the exception.If the API succeeds, it returns
R.Status.Success
.
Example
import io.milvus.param.*;
LoadBalanceParam param = LoadBalanceParam.newBuilder()
.withSegmentIDs(segmentIDs)
.withDestinationNodeID(destNodeID)
.withSourceNodeID(srcNodeID)
.build();
R<RpcStatus> response = client.loadBalance(param);
if (response.getStatus() != R.Status.Success.getCode()) {
System.out.println(response.getMessage());
}