|
@@ -23,7 +23,6 @@ import io.grpc.ConnectivityState;
|
|
|
import io.grpc.ManagedChannel;
|
|
|
import io.grpc.ManagedChannelBuilder;
|
|
|
import io.grpc.StatusRuntimeException;
|
|
|
-import io.milvus.grpc.PartitionParam;
|
|
|
import org.apache.commons.collections4.ListUtils;
|
|
|
|
|
|
import javax.annotation.Nonnull;
|
|
@@ -270,144 +269,6 @@ public class MilvusGrpcClient implements MilvusClient {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public Response createPartition(Partition partition) {
|
|
|
-
|
|
|
- if (!channelIsReadyOrIdle()) {
|
|
|
- logWarning("You are not connected to Milvus server");
|
|
|
- return new Response(Response.Status.CLIENT_NOT_CONNECTED);
|
|
|
- }
|
|
|
-
|
|
|
- io.milvus.grpc.PartitionParam request =
|
|
|
- io.milvus.grpc.PartitionParam.newBuilder()
|
|
|
- .setTableName(partition.getTableName())
|
|
|
- .setPartitionName(partition.getPartitionName())
|
|
|
- .setTag(partition.getTag())
|
|
|
- .build();
|
|
|
-
|
|
|
- io.milvus.grpc.Status response;
|
|
|
-
|
|
|
- try {
|
|
|
- response = blockingStub.createPartition(request);
|
|
|
-
|
|
|
- if (response.getErrorCode() == io.milvus.grpc.ErrorCode.SUCCESS) {
|
|
|
- logInfo("Created partition successfully!\n{0}", partition.toString());
|
|
|
- return new Response(Response.Status.SUCCESS);
|
|
|
- } else {
|
|
|
- logSevere("Create partition failed\n{0}\n{1}", partition.toString(), response.toString());
|
|
|
- return new Response(
|
|
|
- Response.Status.valueOf(response.getErrorCodeValue()), response.getReason());
|
|
|
- }
|
|
|
- } catch (StatusRuntimeException e) {
|
|
|
- logSevere("createPartition RPC failed:\n{0}", e.getStatus().toString());
|
|
|
- return new Response(Response.Status.RPC_ERROR, e.toString());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ShowPartitionsResponse showPartitions(String tableName) {
|
|
|
-
|
|
|
- if (!channelIsReadyOrIdle()) {
|
|
|
- logWarning("You are not connected to Milvus server");
|
|
|
- return new ShowPartitionsResponse(
|
|
|
- new Response(Response.Status.CLIENT_NOT_CONNECTED), new ArrayList<>());
|
|
|
- }
|
|
|
-
|
|
|
- io.milvus.grpc.TableName request =
|
|
|
- io.milvus.grpc.TableName.newBuilder().setTableName(tableName).build();
|
|
|
- io.milvus.grpc.PartitionList response;
|
|
|
-
|
|
|
- try {
|
|
|
- response = blockingStub.showPartitions(request);
|
|
|
-
|
|
|
- if (response.getStatus().getErrorCode() == io.milvus.grpc.ErrorCode.SUCCESS) {
|
|
|
- List<PartitionParam> partitionList = response.getPartitionArrayList();
|
|
|
- List<Partition> partitions = new ArrayList<>();
|
|
|
- for (PartitionParam partitionParam : partitionList) {
|
|
|
- partitions.add(
|
|
|
- new Partition.Builder(
|
|
|
- partitionParam.getTableName(),
|
|
|
- partitionParam.getPartitionName(),
|
|
|
- partitionParam.getTag())
|
|
|
- .build());
|
|
|
- }
|
|
|
- logInfo("Current partitions of table {0}: {1}", tableName, partitions.toString());
|
|
|
- return new ShowPartitionsResponse(new Response(Response.Status.SUCCESS), partitions);
|
|
|
- } else {
|
|
|
- logSevere("Show partitions failed:\n{0}", response.toString());
|
|
|
- return new ShowPartitionsResponse(
|
|
|
- new Response(
|
|
|
- Response.Status.valueOf(response.getStatus().getErrorCodeValue()),
|
|
|
- response.getStatus().getReason()),
|
|
|
- new ArrayList<>());
|
|
|
- }
|
|
|
- } catch (StatusRuntimeException e) {
|
|
|
- logSevere("showPartitions RPC failed:\n{0}", e.getStatus().toString());
|
|
|
- return new ShowPartitionsResponse(
|
|
|
- new Response(Response.Status.RPC_ERROR, e.toString()), new ArrayList<>());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Response dropPartition(String partitionName) {
|
|
|
-
|
|
|
- if (!channelIsReadyOrIdle()) {
|
|
|
- logWarning("You are not connected to Milvus server");
|
|
|
- return new Response(Response.Status.CLIENT_NOT_CONNECTED);
|
|
|
- }
|
|
|
-
|
|
|
- io.milvus.grpc.PartitionParam request =
|
|
|
- io.milvus.grpc.PartitionParam.newBuilder().setPartitionName(partitionName).build();
|
|
|
- io.milvus.grpc.Status response;
|
|
|
-
|
|
|
- try {
|
|
|
- response = blockingStub.dropPartition(request);
|
|
|
-
|
|
|
- if (response.getErrorCode() == io.milvus.grpc.ErrorCode.SUCCESS) {
|
|
|
- logInfo("Dropped partition `{0}` successfully!", partitionName);
|
|
|
- return new Response(Response.Status.SUCCESS);
|
|
|
- } else {
|
|
|
- logSevere("Drop partition `{0}` failed:\n{1}", partitionName, response.toString());
|
|
|
- return new Response(
|
|
|
- Response.Status.valueOf(response.getErrorCodeValue()), response.getReason());
|
|
|
- }
|
|
|
- } catch (StatusRuntimeException e) {
|
|
|
- logSevere("dropPartition RPC failed:\n{0}", e.getStatus().toString());
|
|
|
- return new Response(Response.Status.RPC_ERROR, e.toString());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Response dropPartition(String tableName, String tag) {
|
|
|
-
|
|
|
- if (!channelIsReadyOrIdle()) {
|
|
|
- logWarning("You are not connected to Milvus server");
|
|
|
- return new Response(Response.Status.CLIENT_NOT_CONNECTED);
|
|
|
- }
|
|
|
-
|
|
|
- io.milvus.grpc.PartitionParam request =
|
|
|
- io.milvus.grpc.PartitionParam.newBuilder().setTableName(tableName).setTag(tag).build();
|
|
|
- io.milvus.grpc.Status response;
|
|
|
-
|
|
|
- try {
|
|
|
- response = blockingStub.dropPartition(request);
|
|
|
-
|
|
|
- if (response.getErrorCode() == io.milvus.grpc.ErrorCode.SUCCESS) {
|
|
|
- logInfo("Dropped partition of table `{0}` and tag `{1}` successfully!", tableName, tag);
|
|
|
- return new Response(Response.Status.SUCCESS);
|
|
|
- } else {
|
|
|
- logSevere(
|
|
|
- "Drop partition of table `{0}` and tag `{1}` failed:\n{1}",
|
|
|
- tableName, tag, response.toString());
|
|
|
- return new Response(
|
|
|
- Response.Status.valueOf(response.getErrorCodeValue()), response.getReason());
|
|
|
- }
|
|
|
- } catch (StatusRuntimeException e) {
|
|
|
- logSevere("dropPartition RPC failed:\n{0}", e.getStatus().toString());
|
|
|
- return new Response(Response.Status.RPC_ERROR, e.toString());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public InsertResponse insert(@Nonnull InsertParam insertParam) {
|
|
|
|