Skip to content

Commit

Permalink
fix: resource group example
Browse files Browse the repository at this point in the history
Signed-off-by: chyezh <[email protected]>
  • Loading branch information
chyezh committed Apr 15, 2024
1 parent e836ded commit e333af1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 11 additions & 1 deletion examples/main/java/io/milvus/ResourceGroupExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class ResourceGroupExample {
manager = new ResourceGroupManagement(new MilvusServiceClient(connectParam));
}

private static void printResourceGroupInfo() {
private static void printResourceGroupInfo() throws Exception {
manager.listResourceGroups().forEach((name, rg) -> {
System.out.println(name);
System.out.println(gson.toJson(rg));
Expand Down Expand Up @@ -61,5 +61,15 @@ public static void main(String[] args) throws Exception {
manager.scaleResourceGroupTo(ResourceGroupManagement.DEFAULT_RG, 1);
// default_rg: 1, rg1: 1, rg2: 2, recycle_rg: 1
printResourceGroupInfo();

manager.scaleResourceGroupTo(ResourceGroupManagement.DEFAULT_RG, 5);
manager.scaleResourceGroupTo(rgName1, 1);
manager.scaleResourceGroupTo(rgName2, 3);
// keep 8 query node in cluster.
printResourceGroupInfo();

// if there are replicas in other rg, transfer them to default together.
manager.transferDataBaseToResourceGroup("default", ResourceGroupManagement.DEFAULT_RG);
printResourceGroupInfo();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public Map<String, ResourceGroupInfo> listResourceGroups() throws Exception {

resourceGroupInfo.getResourceGroup().getNodesList().forEach(node -> {
builder.addAvailableNode(NodeInfo.newBuilder()
.withNodeId(node.getNodeID())
.withNodeId(node.getNodeId())
.withAddress(node.getAddress())
.withHostname(node.getHostname())
.build());
Expand All @@ -94,7 +94,9 @@ public Map<String, ResourceGroupInfo> listResourceGroups() throws Exception {
Set<String> resourceGroupNames = new HashSet<>();
for (String collection : showCollectionResponse.getCollectionNamesList()) {
String resourceGroupName = getCollectionResourceGroupName(dbName, collection);
resourceGroupNames.add(resourceGroupName);
if (resourceGroupName != null) {
resourceGroupNames.add(resourceGroupName);
}
}

if (resourceGroupNames.size() == 0) {
Expand Down

0 comments on commit e333af1

Please sign in to comment.