Skip to content

Commit

Permalink
ResourceGroup interfaces for V2
Browse files Browse the repository at this point in the history
Signed-off-by: yhmo <[email protected]>
  • Loading branch information
yhmo committed Dec 26, 2024
1 parent 25ec12e commit 8810317
Show file tree
Hide file tree
Showing 16 changed files with 570 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package io.milvus.common.resourcegroup;

import lombok.Data;
import lombok.experimental.SuperBuilder;

@Data
@SuperBuilder
public class NodeInfo {
private Long nodeId;
private String address;
private String hostname;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package io.milvus.common.resourcegroup;

import java.util.stream.Collectors;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
package io.milvus.common.resourcegroup;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.jetbrains.annotations.NotNull;
package io.milvus.common.resourcegroup;

import lombok.Getter;
import lombok.NonNull;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package io.milvus.common.resourcegroup;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Expand All @@ -22,7 +42,7 @@ public static Builder newBuilder() {
}

public static final class Builder {
private Map<String, String> nodeLabels;
private Map<String, String> nodeLabels = new HashMap<>();
private Builder() {
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package io.milvus.common.resourcegroup;

import lombok.Getter;
Expand Down
90 changes: 82 additions & 8 deletions sdk-core/src/main/java/io/milvus/v2/client/MilvusClientV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
import io.grpc.ManagedChannel;
import io.grpc.Status;
import io.grpc.StatusRuntimeException;
import io.milvus.grpc.ClientInfo;
import io.milvus.grpc.ConnectRequest;
import io.milvus.grpc.ConnectResponse;
import io.milvus.grpc.MilvusServiceGrpc;
import io.milvus.grpc.*;
import io.milvus.orm.iterator.QueryIterator;
import io.milvus.orm.iterator.SearchIterator;

Expand All @@ -46,6 +43,9 @@
import io.milvus.v2.service.rbac.RBACService;
import io.milvus.v2.service.rbac.request.*;
import io.milvus.v2.service.rbac.response.*;
import io.milvus.v2.service.resourcegroup.ResourceGroupService;
import io.milvus.v2.service.resourcegroup.request.*;
import io.milvus.v2.service.resourcegroup.response.*;
import io.milvus.v2.service.utility.UtilityService;
import io.milvus.v2.service.utility.request.*;
import io.milvus.v2.service.utility.response.*;
Expand Down Expand Up @@ -74,6 +74,7 @@ public class MilvusClientV2 {
private final VectorService vectorService = new VectorService();
private final PartitionService partitionService = new PartitionService();
private final RBACService rbacService = new RBACService();
private final ResourceGroupService rgroupService = new ResourceGroupService();
private final UtilityService utilityService = new UtilityService();
private ConnectConfig connectConfig;
private RetryConfig retryConfig = RetryConfig.builder().build();
Expand Down Expand Up @@ -267,6 +268,9 @@ private <T> T retry(Callable<T> callable) {
return null;
}

/////////////////////////////////////////////////////////////////////////////////////////////
// Database Operations
/////////////////////////////////////////////////////////////////////////////////////////////
/**
* use Database
* @param dbName databaseName
Expand Down Expand Up @@ -341,7 +345,9 @@ public DescribeDatabaseResp describeDatabase(DescribeDatabaseReq request) {
return retry(()-> databaseService.describeDatabase(this.getRpcStub(), request));
}

//Collection Operations
/////////////////////////////////////////////////////////////////////////////////////////////
// Collection Operations
/////////////////////////////////////////////////////////////////////////////////////////////
/**
* Creates a collection in Milvus.
* @param request create collection request
Expand Down Expand Up @@ -481,7 +487,9 @@ public Boolean getLoadState(GetLoadStateReq request) {
return retry(()->collectionService.getLoadState(this.getRpcStub(), request));
}

//Index Operations
/////////////////////////////////////////////////////////////////////////////////////////////
// Index Operations
/////////////////////////////////////////////////////////////////////////////////////////////
/**
* Creates an index for a specified field in a collection in Milvus.
*
Expand Down Expand Up @@ -547,7 +555,9 @@ public List<String> listIndexes(ListIndexesReq request) {
return retry(()->indexService.listIndexes(this.getRpcStub(), request));
}

/////////////////////////////////////////////////////////////////////////////////////////////
// Vector Operations
/////////////////////////////////////////////////////////////////////////////////////////////
/**
* Inserts vectors into a collection in Milvus.
*
Expand Down Expand Up @@ -634,7 +644,9 @@ public SearchIterator searchIterator(SearchIteratorReq request) {
return retry(()->vectorService.searchIterator(this.getRpcStub(), request));
}

/////////////////////////////////////////////////////////////////////////////////////////////
// Partition Operations
/////////////////////////////////////////////////////////////////////////////////////////////
/**
* Creates a partition in a collection in Milvus.
*
Expand Down Expand Up @@ -700,7 +712,9 @@ public void releasePartitions(ReleasePartitionsReq request) {
retry(()->partitionService.releasePartitions(this.getRpcStub(), request));
}

// RBAC operations
/////////////////////////////////////////////////////////////////////////////////////////////
// RBAC Operations
/////////////////////////////////////////////////////////////////////////////////////////////
/**
* list users
*
Expand Down Expand Up @@ -837,8 +851,68 @@ public void revokePrivilegeV2(RevokePrivilegeReqV2 request) {
retry(()->rbacService.revokePrivilegeV2(this.getRpcStub(), request));
}

// Utility Operations
/////////////////////////////////////////////////////////////////////////////////////////////
// Resource group Operations
/////////////////////////////////////////////////////////////////////////////////////////////
/**
* Create a resource group.
*
* @param request {@link CreateResourceGroupReq}
*/
public void createResourceGroup(CreateResourceGroupReq request){
retry(()->rgroupService.createResourceGroup(this.getRpcStub(), request));
}

/**
* Update resource groups.
*
* @param request {@link UpdateResourceGroupsReq}
*/
public void updateResourceGroups(UpdateResourceGroupsReq request) {
retry(()->rgroupService.updateResourceGroups(this.getRpcStub(), request));
}

/**
* Drop a resource group.
*
* @param request {@link DropResourceGroupReq}
*/
public void dropResourceGroup(DropResourceGroupReq request) {
retry(()->rgroupService.dropResourceGroup(this.getRpcStub(), request));
}

/**
* List resource groups.
*
* @param request {@link ListResourceGroupsReq}
* @return ListResourceGroupsResp
*/
ListResourceGroupsResp listResourceGroups(ListResourceGroupsReq request) {
return retry(()->rgroupService.listResourceGroups(this.getRpcStub(), request));
}

/**
* Describe a resource group.
*
* @param request {@link DescribeResourceGroupReq}
* @return DescribeResourceGroupResp
*/
DescribeResourceGroupResp describeResourceGroup(DescribeResourceGroupReq request) {
return retry(()->rgroupService.describeResourceGroup(this.getRpcStub(), request));
}

/**
* Transfer a replica from source resource group to target resource_group.
*
* @param request {@link TransferReplicaReq}
*/
public void transferReplica(TransferReplicaReq request) {
retry(()->rgroupService.transferReplica(this.getRpcStub(), request));
}

/////////////////////////////////////////////////////////////////////////////////////////////
// Utility Operations
/////////////////////////////////////////////////////////////////////////////////////////////
/**
* create aliases
*
Expand Down
Loading

0 comments on commit 8810317

Please sign in to comment.