From 87dca7e0c7ac29ffe4c33b2fc585a9ac81be254d Mon Sep 17 00:00:00 2001 From: lentitude2tk Date: Tue, 18 Nov 2025 11:29:21 +0800 Subject: [PATCH] Breaking change: Rename Stage to Volume Signed-off-by: lentitude2tk --- .../io/milvus/v2/StageManagerExample.java | 76 ---- ...ple.java => VolumeFileManagerExample.java} | 26 +- .../io/milvus/v2/VolumeManagerExample.java | 74 ++++ ...mple.java => BulkWriterVolumeExample.java} | 58 ++- .../io/milvus/bulkwriter/StageManager.java | 59 --- ...eBulkWriter.java => VolumeBulkWriter.java} | 36 +- ...rParam.java => VolumeBulkWriterParam.java} | 90 +++-- ...ileManager.java => VolumeFileManager.java} | 122 +++--- ...Param.java => VolumeFileManagerParam.java} | 65 +-- .../io/milvus/bulkwriter/VolumeManager.java | 59 +++ ...agerParam.java => VolumeManagerParam.java} | 41 +- .../bulkwriter/model/UploadFilesResult.java | 76 +++- .../request/import_/BaseImportRequest.java | 77 +++- .../request/import_/CloudImportRequest.java | 248 ++++++++++-- .../request/import_/MilvusImportRequest.java | 136 ++++++- .../request/import_/StageImportRequest.java | 79 ---- .../request/import_/VolumeImportRequest.java | 210 ++++++++++ .../request/stage/ApplyStageRequest.java | 34 -- .../request/stage/BaseStageRequest.java | 42 -- .../request/stage/CreateStageRequest.java | 35 -- .../request/stage/ListStagesRequest.java | 35 -- .../request/stage/UploadFilesRequest.java | 45 --- .../request/volume/ApplyVolumeRequest.java | 91 +++++ .../request/volume/BaseVolumeRequest.java | 98 +++++ .../request/volume/CreateVolumeRequest.java | 109 +++++ .../request/volume/DeleteVolumeRequest.java | 71 ++++ .../request/volume/ListVolumesRequest.java | 110 ++++++ .../request/volume/UploadFilesRequest.java | 101 +++++ .../response/ApplyStageResponse.java | 55 --- .../response/ApplyVolumeResponse.java | 373 ++++++++++++++++++ .../response/stage/ListStagesResponse.java | 42 -- .../response/volume/ListVolumesResponse.java | 130 ++++++ .../response/volume/VolumeInfo.java | 52 +++ ...taStageUtils.java => DataVolumeUtils.java} | 26 +- 34 files changed, 2215 insertions(+), 766 deletions(-) delete mode 100644 examples/src/main/java/io/milvus/v2/StageManagerExample.java rename examples/src/main/java/io/milvus/v2/{StageFileManagerExample.java => VolumeFileManagerExample.java} (68%) create mode 100644 examples/src/main/java/io/milvus/v2/VolumeManagerExample.java rename examples/src/main/java/io/milvus/v2/bulkwriter/{BulkWriterStageExample.java => BulkWriterVolumeExample.java} (93%) delete mode 100644 sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageManager.java rename sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/{StageBulkWriter.java => VolumeBulkWriter.java} (84%) rename sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/{StageBulkWriterParam.java => VolumeBulkWriterParam.java} (63%) rename sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/{StageFileManager.java => VolumeFileManager.java} (66%) rename sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/{StageFileManagerParam.java => VolumeFileManagerParam.java} (63%) create mode 100644 sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/VolumeManager.java rename sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/{StageManagerParam.java => VolumeManagerParam.java} (68%) delete mode 100644 sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/StageImportRequest.java create mode 100644 sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/VolumeImportRequest.java delete mode 100644 sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/ApplyStageRequest.java delete mode 100644 sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/BaseStageRequest.java delete mode 100644 sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/CreateStageRequest.java delete mode 100644 sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/ListStagesRequest.java delete mode 100644 sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/UploadFilesRequest.java create mode 100644 sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/ApplyVolumeRequest.java create mode 100644 sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/BaseVolumeRequest.java create mode 100644 sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/CreateVolumeRequest.java create mode 100644 sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/DeleteVolumeRequest.java create mode 100644 sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/ListVolumesRequest.java create mode 100644 sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/UploadFilesRequest.java delete mode 100644 sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/ApplyStageResponse.java create mode 100644 sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/ApplyVolumeResponse.java delete mode 100644 sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/stage/ListStagesResponse.java create mode 100644 sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/volume/ListVolumesResponse.java create mode 100644 sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/volume/VolumeInfo.java rename sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/restful/{DataStageUtils.java => DataVolumeUtils.java} (75%) diff --git a/examples/src/main/java/io/milvus/v2/StageManagerExample.java b/examples/src/main/java/io/milvus/v2/StageManagerExample.java deleted file mode 100644 index 70c10444b..000000000 --- a/examples/src/main/java/io/milvus/v2/StageManagerExample.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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.v2; - -import com.google.gson.Gson; -import io.milvus.bulkwriter.StageManager; -import io.milvus.bulkwriter.StageManagerParam; -import io.milvus.bulkwriter.request.stage.CreateStageRequest; -import io.milvus.bulkwriter.request.stage.DeleteStageRequest; -import io.milvus.bulkwriter.request.stage.ListStagesRequest; -import io.milvus.bulkwriter.response.stage.ListStagesResponse; - - -/** - * This is currently a private preview feature. If you need to use it, please submit a request and contact us. - */ -public class StageManagerExample { - private static final StageManager stageManager; - static { - StageManagerParam stageManagerParam = StageManagerParam.newBuilder() - .withCloudEndpoint("https://api.cloud.zilliz.com") - .withApiKey("_api_key_for_cluster_org_") - .build(); - stageManager = new StageManager(stageManagerParam); - } - - private static final String PROJECT_ID = "_id_for_project_"; - private static final String REGION_ID = "_id_for_region_"; - private static final String STAGE_NAME = "_stage_name_for_project_"; - - public static void main(String[] args) throws Exception { - createStage(); - listStages(); - deleteStage(); - } - - private static void createStage() { - CreateStageRequest request = CreateStageRequest.builder() - .projectId(PROJECT_ID).regionId(REGION_ID).stageName(STAGE_NAME) - .build(); - stageManager.createStage(request); - System.out.printf("\nStage %s created%n", STAGE_NAME); - } - - private static void listStages() { - ListStagesRequest request = ListStagesRequest.builder() - .projectId(PROJECT_ID).currentPage(1).pageSize(10) - .build(); - ListStagesResponse listStagesResponse = stageManager.listStages(request); - System.out.println("\nlistStages results: " + new Gson().toJson(listStagesResponse)); - } - - private static void deleteStage() { - DeleteStageRequest request = DeleteStageRequest.builder() - .stageName(STAGE_NAME) - .build(); - stageManager.deleteStage(request); - System.out.printf("\nStage %s deleted%n", STAGE_NAME); - } -} diff --git a/examples/src/main/java/io/milvus/v2/StageFileManagerExample.java b/examples/src/main/java/io/milvus/v2/VolumeFileManagerExample.java similarity index 68% rename from examples/src/main/java/io/milvus/v2/StageFileManagerExample.java rename to examples/src/main/java/io/milvus/v2/VolumeFileManagerExample.java index c554075fd..e466e1e5a 100644 --- a/examples/src/main/java/io/milvus/v2/StageFileManagerExample.java +++ b/examples/src/main/java/io/milvus/v2/VolumeFileManagerExample.java @@ -19,26 +19,24 @@ package io.milvus.v2; import com.google.gson.Gson; -import io.milvus.bulkwriter.StageFileManager; -import io.milvus.bulkwriter.StageFileManagerParam; +import io.milvus.bulkwriter.VolumeFileManager; +import io.milvus.bulkwriter.VolumeFileManagerParam; import io.milvus.bulkwriter.common.clientenum.ConnectType; import io.milvus.bulkwriter.model.UploadFilesResult; -import io.milvus.bulkwriter.request.stage.UploadFilesRequest; +import io.milvus.bulkwriter.request.volume.UploadFilesRequest; -/** - * This is currently a private preview feature. If you need to use it, please submit a request and contact us. - */ -public class StageFileManagerExample { - private static final StageFileManager stageFileManager; +public class VolumeFileManagerExample { + private static final VolumeFileManager volumeFileManager; + static { - StageFileManagerParam stageFileManagerParam = StageFileManagerParam.newBuilder() + VolumeFileManagerParam volumeFileManagerParam = VolumeFileManagerParam.newBuilder() .withCloudEndpoint("https://api.cloud.zilliz.com") .withApiKey("_api_key_for_cluster_org_") - .withStageName("_stage_name_for_project_") + .withVolumeName("_volume_name_for_project_") .withConnectType(ConnectType.AUTO) .build(); - stageFileManager = new StageFileManager(stageFileManagerParam); + volumeFileManager = new VolumeFileManager(volumeFileManagerParam); } public static void main(String[] args) throws Exception { @@ -49,13 +47,13 @@ public static void main(String[] args) throws Exception { private static void uploadFiles() throws Exception { UploadFilesRequest request = UploadFilesRequest.builder() .sourceFilePath("/Users/zilliz/data/") - .targetStagePath("data/") + .targetVolumePath("data/") .build(); - UploadFilesResult result = stageFileManager.uploadFilesAsync(request).get(); + UploadFilesResult result = volumeFileManager.uploadFilesAsync(request).get(); System.out.println("\nuploadFiles results: " + new Gson().toJson(result)); } private static void shutdown() { - stageFileManager.shutdownGracefully(); + volumeFileManager.shutdownGracefully(); } } diff --git a/examples/src/main/java/io/milvus/v2/VolumeManagerExample.java b/examples/src/main/java/io/milvus/v2/VolumeManagerExample.java new file mode 100644 index 000000000..309444efc --- /dev/null +++ b/examples/src/main/java/io/milvus/v2/VolumeManagerExample.java @@ -0,0 +1,74 @@ +/* + * 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.v2; + +import com.google.gson.Gson; +import io.milvus.bulkwriter.VolumeManager; +import io.milvus.bulkwriter.VolumeManagerParam; +import io.milvus.bulkwriter.request.volume.CreateVolumeRequest; +import io.milvus.bulkwriter.request.volume.DeleteVolumeRequest; +import io.milvus.bulkwriter.request.volume.ListVolumesRequest; +import io.milvus.bulkwriter.response.volume.ListVolumesResponse; + + +public class VolumeManagerExample { + private static final VolumeManager volumeManager; + + static { + VolumeManagerParam volumeManagerParam = VolumeManagerParam.newBuilder() + .withCloudEndpoint("https://api.cloud.zilliz.com") + .withApiKey("_api_key_for_cluster_org_") + .build(); + volumeManager = new VolumeManager(volumeManagerParam); + } + + private static final String PROJECT_ID = "_id_for_project_"; + private static final String REGION_ID = "_id_for_region_"; + private static final String VOLUME_NAME = "_volume_name_for_project_"; + + public static void main(String[] args) throws Exception { + createVolume(); + listVolumes(); + deleteVolume(); + } + + private static void createVolume() { + CreateVolumeRequest request = CreateVolumeRequest.builder() + .projectId(PROJECT_ID).regionId(REGION_ID).volumeName(VOLUME_NAME) + .build(); + volumeManager.createVolume(request); + System.out.printf("\nVolume %s created%n", VOLUME_NAME); + } + + private static void listVolumes() { + ListVolumesRequest request = ListVolumesRequest.builder() + .projectId(PROJECT_ID).currentPage(1).pageSize(10) + .build(); + ListVolumesResponse response = volumeManager.listVolumes(request); + System.out.println("\nlistVolumes results: " + new Gson().toJson(response)); + } + + private static void deleteVolume() { + DeleteVolumeRequest request = DeleteVolumeRequest.builder() + .volumeName(VOLUME_NAME) + .build(); + volumeManager.deleteVolume(request); + System.out.printf("\nVolume %s deleted%n", VOLUME_NAME); + } +} diff --git a/examples/src/main/java/io/milvus/v2/bulkwriter/BulkWriterStageExample.java b/examples/src/main/java/io/milvus/v2/bulkwriter/BulkWriterVolumeExample.java similarity index 93% rename from examples/src/main/java/io/milvus/v2/bulkwriter/BulkWriterStageExample.java rename to examples/src/main/java/io/milvus/v2/bulkwriter/BulkWriterVolumeExample.java index 7f6b5c213..d6d13c107 100644 --- a/examples/src/main/java/io/milvus/v2/bulkwriter/BulkWriterStageExample.java +++ b/examples/src/main/java/io/milvus/v2/bulkwriter/BulkWriterVolumeExample.java @@ -23,13 +23,13 @@ import com.google.gson.JsonElement; import com.google.gson.JsonNull; import com.google.gson.JsonObject; -import io.milvus.bulkwriter.StageBulkWriter; -import io.milvus.bulkwriter.StageBulkWriterParam; +import io.milvus.bulkwriter.VolumeBulkWriter; +import io.milvus.bulkwriter.VolumeBulkWriterParam; import io.milvus.bulkwriter.common.clientenum.BulkFileType; import io.milvus.bulkwriter.common.utils.GeneratorUtils; import io.milvus.bulkwriter.model.UploadFilesResult; import io.milvus.bulkwriter.request.describe.CloudDescribeImportRequest; -import io.milvus.bulkwriter.request.import_.StageImportRequest; +import io.milvus.bulkwriter.request.import_.VolumeImportRequest; import io.milvus.bulkwriter.request.list.CloudListImportJobsRequest; import io.milvus.bulkwriter.restful.BulkImportUtils; import io.milvus.v1.CommonUtils; @@ -59,7 +59,7 @@ import java.util.concurrent.TimeUnit; -public class BulkWriterStageExample { +public class BulkWriterVolumeExample { private static final Gson GSON_INSTANCE = new Gson(); // milvus @@ -76,11 +76,7 @@ public class BulkWriterStageExample { public static final String CLOUD_ENDPOINT = "https://api.cloud.zilliz.com"; public static final String API_KEY = "_api_key_for_cluster_org_"; - - /** - * This is currently a private preview feature. If you need to use it, please submit a request and contact us. - */ - public static final String STAGE_NAME = "_stage_name_for_project_"; + public static final String VOLUME_NAME = "_volume_name_for_project_"; public static final String CLUSTER_ID = "_your_cloud_cluster_id_"; // If db_name is not specified, use "" @@ -95,7 +91,7 @@ public class BulkWriterStageExample { public static void main(String[] args) throws Exception { createConnection(); - exampleCollectionRemoteStage(BulkFileType.PARQUET); + exampleCollectionRemoteVolume(BulkFileType.PARQUET); } private static void createConnection() { @@ -109,7 +105,7 @@ private static void createConnection() { System.out.println("\nConnected"); } - private static void exampleCollectionRemoteStage(BulkFileType fileType) throws Exception { + private static void exampleCollectionRemoteVolume(BulkFileType fileType) throws Exception { List> originalData = genOriginalData(5); List rows = genImportData(originalData, true); @@ -118,19 +114,19 @@ private static void exampleCollectionRemoteStage(BulkFileType fileType) throws E CreateCollectionReq.CollectionSchema collectionSchema = buildAllTypesSchema(); createCollection(COLLECTION_NAME, collectionSchema, false); - UploadFilesResult stageUploadResult = stageRemoteWriter(collectionSchema, fileType, rows); - callStageImport(stageUploadResult.getStageName(), stageUploadResult.getPath()); + UploadFilesResult uploadFilesResult = volumeRemoteWriter(collectionSchema, fileType, rows); + callVolumeImport(uploadFilesResult.getVolumeName(), uploadFilesResult.getPath()); verifyImportData(collectionSchema, originalData); } - private static void callStageImport(String stageName, String path) throws InterruptedException { + private static void callVolumeImport(String volumeName, String path) throws InterruptedException { List importDataPath = Lists.newArrayList(path); - StageImportRequest stageImportRequest = StageImportRequest.builder() + VolumeImportRequest volumeImportRequest = VolumeImportRequest.builder() .apiKey(API_KEY) - .stageName(stageName).dataPaths(Lists.newArrayList(Collections.singleton(importDataPath))) + .volumeName(volumeName).dataPaths(Lists.newArrayList(Collections.singleton(importDataPath))) .clusterId(CLUSTER_ID).dbName(DB_NAME).collectionName(COLLECTION_NAME).partitionName(PARTITION_NAME) .build(); - String bulkImportResult = BulkImportUtils.bulkImport(CLOUD_ENDPOINT, stageImportRequest); + String bulkImportResult = BulkImportUtils.bulkImport(CLOUD_ENDPOINT, volumeImportRequest); System.out.println(bulkImportResult); JsonObject bulkImportObject = convertJsonObject(bulkImportResult); @@ -284,30 +280,30 @@ private static List genImportData(List> original return data; } - private static UploadFilesResult stageRemoteWriter(CreateCollectionReq.CollectionSchema collectionSchema, - BulkFileType fileType, - List data) throws Exception { + private static UploadFilesResult volumeRemoteWriter(CreateCollectionReq.CollectionSchema collectionSchema, + BulkFileType fileType, + List data) throws Exception { System.out.printf("\n===================== all field types (%s) ====================%n", fileType.name()); - try (StageBulkWriter stageBulkWriter = buildStageBulkWriter(collectionSchema, fileType)) { + try (VolumeBulkWriter volumeBulkWriter = buildVolumeBulkWriter(collectionSchema, fileType)) { for (JsonObject rowObject : data) { - stageBulkWriter.appendRow(rowObject); + volumeBulkWriter.appendRow(rowObject); } - System.out.printf("%s rows appends%n", stageBulkWriter.getTotalRowCount()); + System.out.printf("%s rows appends%n", volumeBulkWriter.getTotalRowCount()); System.out.println("Generate data files..."); - stageBulkWriter.commit(false); + volumeBulkWriter.commit(false); - UploadFilesResult stageUploadResult = stageBulkWriter.getStageUploadResult(); - System.out.printf("Data files have been uploaded: %s%n", stageUploadResult); - return stageUploadResult; + UploadFilesResult uploadResult = volumeBulkWriter.getVolumeUploadResult(); + System.out.printf("Data files have been uploaded: %s%n", uploadResult); + return uploadResult; } catch (Exception e) { System.out.println("allTypesRemoteWriter catch exception: " + e); throw e; } } - private static StageBulkWriter buildStageBulkWriter(CreateCollectionReq.CollectionSchema collectionSchema, BulkFileType fileType) throws IOException { - StageBulkWriterParam bulkWriterParam = StageBulkWriterParam.newBuilder() + private static VolumeBulkWriter buildVolumeBulkWriter(CreateCollectionReq.CollectionSchema collectionSchema, BulkFileType fileType) throws IOException { + VolumeBulkWriterParam bulkWriterParam = VolumeBulkWriterParam.newBuilder() .withCollectionSchema(collectionSchema) .withRemotePath("bulk_data") .withFileType(fileType) @@ -315,9 +311,9 @@ private static StageBulkWriter buildStageBulkWriter(CreateCollectionReq.Collecti .withConfig("sep", "|") // only take effect for CSV file .withCloudEndpoint(CLOUD_ENDPOINT) .withApiKey(API_KEY) - .withStageName(STAGE_NAME) + .withVolumeName(VOLUME_NAME) .build(); - return new StageBulkWriter(bulkWriterParam); + return new VolumeBulkWriter(bulkWriterParam); } /** diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageManager.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageManager.java deleted file mode 100644 index afbeae951..000000000 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageManager.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.bulkwriter; - -import com.google.gson.Gson; -import io.milvus.bulkwriter.request.stage.CreateStageRequest; -import io.milvus.bulkwriter.request.stage.DeleteStageRequest; -import io.milvus.bulkwriter.request.stage.ListStagesRequest; -import io.milvus.bulkwriter.response.stage.ListStagesResponse; -import io.milvus.bulkwriter.restful.DataStageUtils; - -public class StageManager { - private final String cloudEndpoint; - private final String apiKey; - - public StageManager(StageManagerParam stageWriterParam) { - cloudEndpoint = stageWriterParam.getCloudEndpoint(); - apiKey = stageWriterParam.getApiKey(); - } - - /** - * Create a stage under the specified project and regionId. - */ - public void createStage(CreateStageRequest request) { - DataStageUtils.createStage(cloudEndpoint, apiKey, request); - } - - /** - * Delete a stage. - */ - public void deleteStage(DeleteStageRequest request) { - DataStageUtils.deleteStage(cloudEndpoint, apiKey, request); - } - - /** - * Paginated query of the stage list under a specified projectId. - */ - public ListStagesResponse listStages(ListStagesRequest request) { - String result = DataStageUtils.listStages(cloudEndpoint, apiKey, request); - return new Gson().fromJson(result, ListStagesResponse.class); - } -} \ No newline at end of file diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageBulkWriter.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/VolumeBulkWriter.java similarity index 84% rename from sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageBulkWriter.java rename to sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/VolumeBulkWriter.java index 3917bdceb..af716711f 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageBulkWriter.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/VolumeBulkWriter.java @@ -23,7 +23,7 @@ import com.google.gson.JsonObject; import io.milvus.bulkwriter.common.clientenum.ConnectType; import io.milvus.bulkwriter.model.UploadFilesResult; -import io.milvus.bulkwriter.request.stage.UploadFilesRequest; +import io.milvus.bulkwriter.request.volume.UploadFilesRequest; import io.milvus.common.utils.ExceptionUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,15 +36,15 @@ import java.util.ArrayList; import java.util.List; -public class StageBulkWriter extends LocalBulkWriter { - private static final Logger logger = LoggerFactory.getLogger(StageBulkWriter.class); +public class VolumeBulkWriter extends LocalBulkWriter { + private static final Logger logger = LoggerFactory.getLogger(VolumeBulkWriter.class); - private String remotePath; - private List> remoteFiles; - private StageFileManager stageFileManager; - private StageBulkWriterParam stageBulkWriterParam; + private final String remotePath; + private final List> remoteFiles; + private final VolumeFileManager volumeFileManager; + private final VolumeBulkWriterParam volumeBulkWriterParam; - public StageBulkWriter(StageBulkWriterParam bulkWriterParam) throws IOException { + public VolumeBulkWriter(VolumeBulkWriterParam bulkWriterParam) throws IOException { super(bulkWriterParam.getCollectionSchema(), bulkWriterParam.getChunkSize(), bulkWriterParam.getFileType(), @@ -53,20 +53,20 @@ public StageBulkWriter(StageBulkWriterParam bulkWriterParam) throws IOException Path path = Paths.get(bulkWriterParam.getRemotePath()); Path remoteDirPath = path.resolve(getUUID()); this.remotePath = remoteDirPath + "/"; - this.stageFileManager = initStageFileManagerParams(bulkWriterParam); - this.stageBulkWriterParam = bulkWriterParam; + this.volumeFileManager = initVolumeFileManagerParams(bulkWriterParam); + this.volumeBulkWriterParam = bulkWriterParam; this.remoteFiles = Lists.newArrayList(); logger.info("Remote buffer writer initialized, target path: {}", remotePath); } - private StageFileManager initStageFileManagerParams(StageBulkWriterParam bulkWriterParam) throws IOException { - StageFileManagerParam stageFileManagerParam = StageFileManagerParam.newBuilder() + private VolumeFileManager initVolumeFileManagerParams(VolumeBulkWriterParam bulkWriterParam) throws IOException { + VolumeFileManagerParam volumeFileManagerParam = VolumeFileManagerParam.newBuilder() .withCloudEndpoint(bulkWriterParam.getCloudEndpoint()).withApiKey(bulkWriterParam.getApiKey()) - .withStageName(bulkWriterParam.getStageName()).withConnectType(ConnectType.AUTO) + .withVolumeName(bulkWriterParam.getVolumeName()).withConnectType(ConnectType.AUTO) .build(); - return new StageFileManager(stageFileManagerParam); + return new VolumeFileManager(volumeFileManagerParam); } @Override @@ -89,9 +89,9 @@ public List> getBatchFiles() { return remoteFiles; } - public UploadFilesResult getStageUploadResult() { + public UploadFilesResult getVolumeUploadResult() { return UploadFilesResult.builder() - .stageName(stageBulkWriterParam.getStageName()) + .volumeName(volumeBulkWriterParam.getVolumeName()) .path(remotePath) .build(); } @@ -178,10 +178,10 @@ private void uploadObject(String filePath, String objectName) throws Exception { logger.info(String.format("Prepare to upload %s to %s", filePath, objectName)); UploadFilesRequest uploadFilesRequest = UploadFilesRequest.builder() - .sourceFilePath(filePath).targetStagePath(remotePath) + .sourceFilePath(filePath).targetVolumePath(remotePath) .build(); - stageFileManager.uploadFilesAsync(uploadFilesRequest).get(); + volumeFileManager.uploadFilesAsync(uploadFilesRequest).get(); logger.info(String.format("Upload file %s to %s", filePath, objectName)); } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageBulkWriterParam.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/VolumeBulkWriterParam.java similarity index 63% rename from sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageBulkWriterParam.java rename to sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/VolumeBulkWriterParam.java index 8425fda56..71521ed23 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageBulkWriterParam.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/VolumeBulkWriterParam.java @@ -25,20 +25,14 @@ import io.milvus.param.ParamUtils; import io.milvus.param.collection.CollectionSchemaParam; import io.milvus.v2.service.collection.request.CreateCollectionReq; -import lombok.Getter; -import lombok.NonNull; -import lombok.ToString; -import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.Map; /** - * Parameters for stageBulkWriter interface. + * Parameters for volumeBulkWriter interface. */ -@Getter -@ToString -public class StageBulkWriterParam { +public class VolumeBulkWriterParam { private final CreateCollectionReq.CollectionSchema collectionSchema; private final String remotePath; private final long chunkSize; @@ -47,9 +41,9 @@ public class StageBulkWriterParam { private final String cloudEndpoint; private final String apiKey; - private final String stageName; + private final String volumeName; - private StageBulkWriterParam(@NonNull Builder builder) { + private VolumeBulkWriterParam(Builder builder) { this.collectionSchema = builder.collectionSchema; this.remotePath = builder.remotePath; this.chunkSize = builder.chunkSize; @@ -58,7 +52,51 @@ private StageBulkWriterParam(@NonNull Builder builder) { this.cloudEndpoint = builder.cloudEndpoint; this.apiKey = builder.apiKey; - this.stageName = builder.stageName; + this.volumeName = builder.volumeName; + } + + public CreateCollectionReq.CollectionSchema getCollectionSchema() { + return collectionSchema; + } + + public String getRemotePath() { + return remotePath; + } + + public long getChunkSize() { + return chunkSize; + } + + public BulkFileType getFileType() { + return fileType; + } + + public Map getConfig() { + return config; + } + + public String getCloudEndpoint() { + return cloudEndpoint; + } + + public String getApiKey() { + return apiKey; + } + + public String getVolumeName() { + return volumeName; + } + + @Override + public String toString() { + return "VolumeBulkWriterParam{" + + "collectionSchema=" + collectionSchema + + ", remotePath='" + remotePath + '\'' + + ", chunkSize=" + chunkSize + + ", fileType=" + fileType + + ", cloudEndpoint='" + cloudEndpoint + '\'' + + ", volumeName='" + volumeName + '\'' + + '}'; } public static Builder newBuilder() { @@ -66,19 +104,19 @@ public static Builder newBuilder() { } /** - * Builder for {@link StageBulkWriterParam} class. + * Builder for {@link VolumeBulkWriterParam} class. */ public static final class Builder { private CreateCollectionReq.CollectionSchema collectionSchema; private String remotePath; private long chunkSize = 128 * 1024 * 1024; private BulkFileType fileType = BulkFileType.PARQUET; - private Map config = new HashMap<>(); + private final Map config = new HashMap<>(); private String cloudEndpoint; private String apiKey; - private String stageName; + private String volumeName; private Builder() { } @@ -89,7 +127,7 @@ private Builder() { * @param collectionSchema collection info * @return Builder */ - public Builder withCollectionSchema(@NonNull CollectionSchemaParam collectionSchema) { + public Builder withCollectionSchema(CollectionSchemaParam collectionSchema) { this.collectionSchema = V2AdapterUtils.convertV1Schema(collectionSchema); return this; } @@ -100,7 +138,7 @@ public Builder withCollectionSchema(@NonNull CollectionSchemaParam collectionSch * @param collectionSchema collection schema * @return Builder */ - public Builder withCollectionSchema(@NonNull CreateCollectionReq.CollectionSchema collectionSchema) { + public Builder withCollectionSchema(CreateCollectionReq.CollectionSchema collectionSchema) { this.collectionSchema = collectionSchema; return this; } @@ -111,7 +149,7 @@ public Builder withCollectionSchema(@NonNull CreateCollectionReq.CollectionSchem * @param remotePath remote path * @return Builder */ - public Builder withRemotePath(@NonNull String remotePath) { + public Builder withRemotePath(String remotePath) { this.remotePath = remotePath; return this; } @@ -121,7 +159,7 @@ public Builder withChunkSize(long chunkSize) { return this; } - public Builder withFileType(@NonNull BulkFileType fileType) { + public Builder withFileType(BulkFileType fileType) { this.fileType = fileType; return this; } @@ -131,34 +169,34 @@ public Builder withConfig(String key, Object val) { return this; } - public Builder withCloudEndpoint(@NotNull String cloudEndpoint) { + public Builder withCloudEndpoint(String cloudEndpoint) { this.cloudEndpoint = cloudEndpoint; return this; } - public Builder withApiKey(@NotNull String apiKey) { + public Builder withApiKey(String apiKey) { this.apiKey = apiKey; return this; } - public Builder withStageName(@NotNull String stageName) { - this.stageName = stageName; + public Builder withVolumeName(String volumeName) { + this.volumeName = volumeName; return this; } /** - * Verifies parameters and creates a new {@link StageBulkWriterParam} instance. + * Verifies parameters and creates a new {@link VolumeBulkWriterParam} instance. * - * @return {@link StageBulkWriterParam} + * @return {@link VolumeBulkWriterParam} */ - public StageBulkWriterParam build() throws ParamException { + public VolumeBulkWriterParam build() throws ParamException { ParamUtils.CheckNullEmptyString(remotePath, "localPath"); if (collectionSchema == null) { throw new ParamException("collectionSchema cannot be null"); } - return new StageBulkWriterParam(this); + return new VolumeBulkWriterParam(this); } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageFileManager.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/VolumeFileManager.java similarity index 66% rename from sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageFileManager.java rename to sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/VolumeFileManager.java index 19bb6aa08..61debb32d 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageFileManager.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/VolumeFileManager.java @@ -23,11 +23,11 @@ import io.milvus.bulkwriter.common.clientenum.ConnectType; import io.milvus.bulkwriter.common.utils.FileUtils; import io.milvus.bulkwriter.model.UploadFilesResult; -import io.milvus.bulkwriter.request.stage.ApplyStageRequest; -import io.milvus.bulkwriter.request.stage.UploadFilesRequest; +import io.milvus.bulkwriter.request.volume.ApplyVolumeRequest; +import io.milvus.bulkwriter.request.volume.UploadFilesRequest; import io.milvus.bulkwriter.resolver.EndpointResolver; -import io.milvus.bulkwriter.response.ApplyStageResponse; -import io.milvus.bulkwriter.restful.DataStageUtils; +import io.milvus.bulkwriter.response.ApplyVolumeResponse; +import io.milvus.bulkwriter.restful.DataVolumeUtils; import io.milvus.bulkwriter.storage.StorageClient; import io.milvus.bulkwriter.storage.client.MinioStorageClient; import io.milvus.exception.ParamException; @@ -51,30 +51,30 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; -public class StageFileManager { - private static final Logger logger = LoggerFactory.getLogger(StageFileManager.class); +public class VolumeFileManager { + private static final Logger logger = LoggerFactory.getLogger(VolumeFileManager.class); private final String cloudEndpoint; private final String apiKey; - private final String stageName; + private final String volumeName; private final ConnectType connectType; private final ExecutorService executor; private StorageClient storageClient; - private ApplyStageResponse applyStageResponse; + private ApplyVolumeResponse applyVolumeResponse; - public StageFileManager(StageFileManagerParam stageWriterParam) { - this.cloudEndpoint = stageWriterParam.getCloudEndpoint(); - this.apiKey = stageWriterParam.getApiKey(); - this.stageName = stageWriterParam.getStageName(); - this.connectType = stageWriterParam.getConnectType(); + public VolumeFileManager(VolumeFileManagerParam volumeFileManagerParam) { + this.cloudEndpoint = volumeFileManagerParam.getCloudEndpoint(); + this.apiKey = volumeFileManagerParam.getApiKey(); + this.volumeName = volumeFileManagerParam.getVolumeName(); + this.connectType = volumeFileManagerParam.getConnectType(); this.executor = Executors.newFixedThreadPool(10); } /** - * Asynchronously uploads a local file or directory to the specified path within the Stage. + * Asynchronously uploads a local file or directory to the specified path within the Volume. * * @param request the upload request containing the source local file or directory path - * and the target directory path in the Stage {@link UploadFilesRequest} + * and the target directory path in the Volume {@link UploadFilesRequest} * @return a {@link CompletableFuture} that completes with an {@link UploadFilesResult} * once all files have been uploaded successfully * @throws CompletionException if an error occurs during the upload process @@ -82,9 +82,9 @@ public StageFileManager(StageFileManagerParam stageWriterParam) { public CompletableFuture uploadFilesAsync(UploadFilesRequest request) { String localDirOrFilePath = request.getSourceFilePath(); Pair, Long> localPathPair = FileUtils.processLocalPath(localDirOrFilePath); - String stagePath = convertDirPath(request.getTargetStagePath()); + String volumePath = convertDirPath(request.getTargetVolumePath()); - refreshStageAndClient(stagePath); + refreshVolumeAndClient(volumePath); initValidator(localPathPair); AtomicInteger currentFileCount = new AtomicInteger(0); @@ -99,7 +99,7 @@ public CompletableFuture uploadFilesAsync(UploadFilesRequest long fileStartTime = System.currentTimeMillis(); try { - uploadLocalFileToStage(localFilePath, localDirOrFilePath, stagePath); + uploadLocalFileToVolume(localFilePath, localDirOrFilePath, volumePath); long bytes = processedBytes.addAndGet(file.length()); int completeCount = currentFileCount.incrementAndGet(); long elapsed = System.currentTimeMillis() - fileStartTime; @@ -115,11 +115,11 @@ public CompletableFuture uploadFilesAsync(UploadFilesRequest }) .thenApply(v -> { long totalElapsed = (System.currentTimeMillis() - startTime) / 1000; - logger.info("all files in {} has been async uploaded to stage, stageName:{}, stagePath:{}, totalFileCount:{}, totalFileSize:{}, cost times:{} s", - localDirOrFilePath, applyStageResponse.getStageName(), stagePath, localPathPair.getKey().size(), localPathPair.getValue(), totalElapsed); + logger.info("all files in {} has been async uploaded to volume, volumeName:{}, volumePath:{}, totalFileCount:{}, totalFileSize:{}, cost times:{} s", + localDirOrFilePath, applyVolumeResponse.getVolumeName(), volumePath, localPathPair.getKey().size(), localPathPair.getValue(), totalElapsed); return UploadFilesResult.builder() - .stageName(applyStageResponse.getStageName()) - .path(stagePath) + .volumeName(applyVolumeResponse.getVolumeName()) + .path(volumePath) .build(); }); } @@ -134,7 +134,7 @@ public CompletableFuture uploadFilesAsync(UploadFilesRequest * * Usage recommendation: *
    - *
  • Call this method when the StageFileManager is no longer needed.
  • + *
  • Call this method when the VolumeFileManager is no longer needed.
  • *
* * Thread interruption is respected, and the interrupt status is restored if interrupted during shutdown. @@ -154,33 +154,49 @@ public void shutdownGracefully() { } private void initValidator(Pair, Long> localPathPair) { - if (localPathPair.getValue() > applyStageResponse.getCondition().getMaxContentLength()) { - String msg = String.format("localFileTotalSize %s exceeds the maximum contentLength limit %s defined in the condition. If you want to upload larger files, please contact us to lift the restriction", localPathPair.getValue(), applyStageResponse.getCondition().getMaxContentLength()); + Long maxContentLength = applyVolumeResponse.getCondition().getMaxContentLength(); + Long uploadFileContentLength = localPathPair.getValue(); + if (uploadFileContentLength > maxContentLength) { + String msg = String.format("localFileTotalSize %s exceeds the maximum contentLength limit %s defined in the condition. If you are using the free tier, you may switch to the pay-as-you-go volume plan to support uploading larger files.", + uploadFileContentLength, maxContentLength); logger.error(msg); throw new ParamException(msg); } + + Long maxFileNumber = applyVolumeResponse.getCondition().getMaxFileNumber(); + int uploadFileNumber = localPathPair.getKey().size(); + if (maxFileNumber != null) { + if (uploadFileNumber > maxFileNumber) { + String msg = String.format( + "localFileTotalNumber %s exceeds the maximum fileNumber limit %s defined in the condition. If you are using the free tier, you may switch to the pay-as-you-go volume plan to support uploading more files.", + uploadFileNumber, maxFileNumber + ); + logger.error(msg); + throw new ParamException(msg); + } + } } - private void refreshStageAndClient(String path) { - logger.info("refreshing Stage info..."); - ApplyStageRequest applyStageRequest = ApplyStageRequest.builder() + private void refreshVolumeAndClient(String path) { + logger.info("refreshing Volume info..."); + ApplyVolumeRequest applyVolumeRequest = ApplyVolumeRequest.builder() .apiKey(apiKey) - .stageName(stageName) + .volumeName(volumeName) .path(path) .build(); - String result = DataStageUtils.applyStage(cloudEndpoint, applyStageRequest); - applyStageResponse = new Gson().fromJson(result, ApplyStageResponse.class); - logger.info("stage info refreshed"); + String result = DataVolumeUtils.applyVolume(cloudEndpoint, applyVolumeRequest); + applyVolumeResponse = new Gson().fromJson(result, ApplyVolumeResponse.class); + logger.info("volume info refreshed"); - String endpoint = EndpointResolver.resolveEndpoint(applyStageResponse.getEndpoint(), applyStageResponse.getCloud(), - applyStageResponse.getRegion(), connectType); + String endpoint = EndpointResolver.resolveEndpoint(applyVolumeResponse.getEndpoint(), applyVolumeResponse.getCloud(), + applyVolumeResponse.getRegion(), connectType); storageClient = MinioStorageClient.getStorageClient( - applyStageResponse.getCloud(), + applyVolumeResponse.getCloud(), endpoint, - applyStageResponse.getCredentials().getTmpAK(), - applyStageResponse.getCredentials().getTmpSK(), - applyStageResponse.getCredentials().getSessionToken(), - applyStageResponse.getRegion(), null); + applyVolumeResponse.getCredentials().getTmpAK(), + applyVolumeResponse.getCredentials().getTmpSK(), + applyVolumeResponse.getCredentials().getSessionToken(), + applyVolumeResponse.getRegion(), null); logger.info("storage client refreshed"); } @@ -194,7 +210,7 @@ private String convertDirPath(String inputPath) { return inputPath + "/"; } - private void uploadLocalFileToStage(String localFilePath, String rootPath, String stagePath) { + private void uploadLocalFileToVolume(String localFilePath, String rootPath, String volumePath) { File file = new File(localFilePath); Path filePath = file.toPath().toAbsolutePath(); Path root = Paths.get(rootPath).toAbsolutePath(); @@ -206,36 +222,36 @@ private void uploadLocalFileToStage(String localFilePath, String rootPath, Strin relativePath = root.relativize(filePath).toString().replace("\\", "/"); } - String remoteFilePath = applyStageResponse.getStagePrefix() + stagePath + relativePath; - putObjectWithRetry(file, remoteFilePath, stagePath); + String remoteFilePath = applyVolumeResponse.getVolumePrefix() + volumePath + relativePath; + putObjectWithRetry(file, remoteFilePath, volumePath); } - private void putObjectWithRetry(File file, String remoteFilePath, String stagePath) { - refreshIfExpire(stagePath); + private void putObjectWithRetry(File file, String remoteFilePath, String volumePath) { + refreshIfExpire(volumePath); String msg = "upload " + file.getAbsolutePath(); withRetry(msg, () -> { try { - storageClient.putObject(file, applyStageResponse.getBucketName(), remoteFilePath); + storageClient.putObject(file, applyVolumeResponse.getBucketName(), remoteFilePath); } catch (Exception e) { throw new RuntimeException(e); } - }, stagePath); + }, volumePath); } - private void refreshIfExpire(String stagePath) { - Instant instant = Instant.parse(applyStageResponse.getCredentials().getExpireTime()); + private void refreshIfExpire(String volumePath) { + Instant instant = Instant.parse(applyVolumeResponse.getCredentials().getExpireTime()); Date expireTime = Date.from(instant); if (new Date().after(expireTime)) { synchronized (this) { if (new Date().after(expireTime)) { - refreshStageAndClient(stagePath); + refreshVolumeAndClient(volumePath); } } } } - private T withRetry(String actionName, Callable callable, String stagePath) { + private T withRetry(String actionName, Callable callable, String volumePath) { final int maxRetries = 5; int attempt = 0; while (attempt < maxRetries) { @@ -245,7 +261,7 @@ private T withRetry(String actionName, Callable callable, String stagePat throw e; } catch (Exception e) { attempt++; - refreshStageAndClient(stagePath); + refreshVolumeAndClient(volumePath); logger.warn("Attempt {} failed to {}", attempt, actionName, e); if (attempt == maxRetries) { throw new RuntimeException(actionName + " failed after " + maxRetries + " attempts", e); @@ -259,11 +275,11 @@ private T withRetry(String actionName, Callable callable, String stagePat throw new RuntimeException(actionName + " failed unexpectedly."); } - private void withRetry(String actionName, Runnable runnable, String stagePath) { + private void withRetry(String actionName, Runnable runnable, String volumePath) { withRetry(actionName, () -> { runnable.run(); return null; - }, stagePath); + }, volumePath); } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageFileManagerParam.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/VolumeFileManagerParam.java similarity index 63% rename from sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageFileManagerParam.java rename to sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/VolumeFileManagerParam.java index 8cb0b623e..872129cc8 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageFileManagerParam.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/VolumeFileManagerParam.java @@ -22,42 +22,61 @@ import io.milvus.bulkwriter.common.clientenum.ConnectType; import io.milvus.exception.ParamException; import io.milvus.param.ParamUtils; -import lombok.Getter; -import lombok.NonNull; -import lombok.ToString; -import org.jetbrains.annotations.NotNull; /** - * Parameters for stageFileManager interface. + * Parameters for volumeFileManager interface. */ -@Getter -@ToString -public class StageFileManagerParam { +public class VolumeFileManagerParam { private final String cloudEndpoint; private final String apiKey; - private final String stageName; + private final String volumeName; private final ConnectType connectType; - private StageFileManagerParam(@NonNull Builder builder) { + private VolumeFileManagerParam(Builder builder) { this.cloudEndpoint = builder.cloudEndpoint; this.apiKey = builder.apiKey; - this.stageName = builder.stageName; + this.volumeName = builder.volumeName; this.connectType = builder.connectType; } + public String getCloudEndpoint() { + return cloudEndpoint; + } + + public String getApiKey() { + return apiKey; + } + + public String getVolumeName() { + return volumeName; + } + + public ConnectType getConnectType() { + return connectType; + } + + @Override + public String toString() { + return "VolumeFileManagerParam{" + + "cloudEndpoint='" + cloudEndpoint + '\'' + + ", volumeName='" + volumeName + '\'' + + ", connectType=" + connectType + + '}'; + } + public static Builder newBuilder() { return new Builder(); } /** - * Builder for {@link StageFileManagerParam} class. + * Builder for {@link VolumeFileManagerParam} class. */ public static final class Builder { private String cloudEndpoint; private String apiKey; - private String stageName; + private String volumeName; private ConnectType connectType = ConnectType.AUTO; @@ -69,18 +88,18 @@ private Builder() { * For overseas regions, it is: https://api.cloud.zilliz.com * For regions in China, it is: https://api.cloud.zilliz.com.cn */ - public Builder withCloudEndpoint(@NotNull String cloudEndpoint) { + public Builder withCloudEndpoint(String cloudEndpoint) { this.cloudEndpoint = cloudEndpoint; return this; } - public Builder withApiKey(@NotNull String apiKey) { + public Builder withApiKey(String apiKey) { this.apiKey = apiKey; return this; } - public Builder withStageName(@NotNull String stageName) { - this.stageName = stageName; + public Builder withVolumeName(String volumeName) { + this.volumeName = volumeName; return this; } @@ -90,22 +109,22 @@ public Builder withStageName(@NotNull String stageName) { * otherwise, the public endpoint will be used. * You can also force the use of either the internal or public endpoint. */ - public Builder withConnectType(@NotNull ConnectType connectType) { + public Builder withConnectType(ConnectType connectType) { this.connectType = connectType; return this; } /** - * Verifies parameters and creates a new {@link StageFileManagerParam} instance. + * Verifies parameters and creates a new {@link VolumeFileManagerParam} instance. * - * @return {@link StageFileManagerParam} + * @return {@link VolumeFileManagerParam} */ - public StageFileManagerParam build() throws ParamException { + public VolumeFileManagerParam build() throws ParamException { ParamUtils.CheckNullEmptyString(cloudEndpoint, "cloudEndpoint"); ParamUtils.CheckNullEmptyString(apiKey, "apiKey"); - ParamUtils.CheckNullEmptyString(stageName, "stageName"); + ParamUtils.CheckNullEmptyString(volumeName, "volumeName"); - return new StageFileManagerParam(this); + return new VolumeFileManagerParam(this); } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/VolumeManager.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/VolumeManager.java new file mode 100644 index 000000000..dec575b25 --- /dev/null +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/VolumeManager.java @@ -0,0 +1,59 @@ +/* + * 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.bulkwriter; + +import com.google.gson.Gson; +import io.milvus.bulkwriter.request.volume.CreateVolumeRequest; +import io.milvus.bulkwriter.request.volume.DeleteVolumeRequest; +import io.milvus.bulkwriter.request.volume.ListVolumesRequest; +import io.milvus.bulkwriter.response.volume.ListVolumesResponse; +import io.milvus.bulkwriter.restful.DataVolumeUtils; + +public class VolumeManager { + private final String cloudEndpoint; + private final String apiKey; + + public VolumeManager(VolumeManagerParam volumeManagerParam) { + cloudEndpoint = volumeManagerParam.getCloudEndpoint(); + apiKey = volumeManagerParam.getApiKey(); + } + + /** + * Create a volume under the specified project and regionId. + */ + public void createVolume(CreateVolumeRequest request) { + DataVolumeUtils.createVolume(cloudEndpoint, apiKey, request); + } + + /** + * Delete a volume. + */ + public void deleteVolume(DeleteVolumeRequest request) { + DataVolumeUtils.deleteVolume(cloudEndpoint, apiKey, request); + } + + /** + * Paginated query of the volume list under a specified projectId. + */ + public ListVolumesResponse listVolumes(ListVolumesRequest request) { + String result = DataVolumeUtils.listVolumes(cloudEndpoint, apiKey, request); + return new Gson().fromJson(result, ListVolumesResponse.class); + } +} \ No newline at end of file diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageManagerParam.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/VolumeManagerParam.java similarity index 68% rename from sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageManagerParam.java rename to sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/VolumeManagerParam.java index 0145499d7..a118cb782 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageManagerParam.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/VolumeManagerParam.java @@ -21,31 +21,40 @@ import io.milvus.exception.ParamException; import io.milvus.param.ParamUtils; -import lombok.Getter; -import lombok.NonNull; -import lombok.ToString; -import org.jetbrains.annotations.NotNull; /** - * Parameters for stageManager interface. + * Parameters for volumeManager interface. */ -@Getter -@ToString -public class StageManagerParam { +public class VolumeManagerParam { private final String cloudEndpoint; private final String apiKey; - private StageManagerParam(@NonNull Builder builder) { + private VolumeManagerParam(Builder builder) { this.cloudEndpoint = builder.cloudEndpoint; this.apiKey = builder.apiKey; } + public String getCloudEndpoint() { + return cloudEndpoint; + } + + public String getApiKey() { + return apiKey; + } + + @Override + public String toString() { + return "VolumeManagerParam{" + + "cloudEndpoint='" + cloudEndpoint + '\'' + + '}'; + } + public static Builder newBuilder() { return new Builder(); } /** - * Builder for {@link StageManagerParam} class. + * Builder for {@link VolumeManagerParam} class. */ public static final class Builder { private String cloudEndpoint; @@ -60,26 +69,26 @@ private Builder() { * For overseas regions, it is: https://api.cloud.zilliz.com * For regions in China, it is: https://api.cloud.zilliz.com.cn */ - public Builder withCloudEndpoint(@NotNull String cloudEndpoint) { + public Builder withCloudEndpoint(String cloudEndpoint) { this.cloudEndpoint = cloudEndpoint; return this; } - public Builder withApiKey(@NotNull String apiKey) { + public Builder withApiKey(String apiKey) { this.apiKey = apiKey; return this; } /** - * Verifies parameters and creates a new {@link StageManagerParam} instance. + * Verifies parameters and creates a new {@link VolumeManagerParam} instance. * - * @return {@link StageManagerParam} + * @return {@link VolumeManagerParam} */ - public StageManagerParam build() throws ParamException { + public VolumeManagerParam build() throws ParamException { ParamUtils.CheckNullEmptyString(cloudEndpoint, "cloudEndpoint"); ParamUtils.CheckNullEmptyString(apiKey, "apiKey"); - return new StageManagerParam(this); + return new VolumeManagerParam(this); } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/model/UploadFilesResult.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/model/UploadFilesResult.java index 43fe1de0f..4eac14bf6 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/model/UploadFilesResult.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/model/UploadFilesResult.java @@ -1,15 +1,71 @@ package io.milvus.bulkwriter.model; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor public class UploadFilesResult { - private String stageName; + private String volumeName; private String path; + + public UploadFilesResult() { + } + + public UploadFilesResult(String volumeName, String path) { + this.volumeName = volumeName; + this.path = path; + } + + private UploadFilesResult(UploadFilesResultBuilder builder) { + this.volumeName = builder.volumeName; + this.path = builder.path; + } + + public String getVolumeName() { + return volumeName; + } + + public void setVolumeName(String volumeName) { + this.volumeName = volumeName; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Override + public String toString() { + return "UploadFilesResult{" + + "volumeName='" + volumeName + '\'' + + ", path='" + path + '\'' + + '}'; + } + + public static UploadFilesResultBuilder builder() { + return new UploadFilesResultBuilder(); + } + + public static class UploadFilesResultBuilder { + private String volumeName; + private String path; + + private UploadFilesResultBuilder() { + this.volumeName = ""; + this.path = ""; + } + + public UploadFilesResultBuilder volumeName(String volumeName) { + this.volumeName = volumeName; + return this; + } + + public UploadFilesResultBuilder path(String path) { + this.path = path; + return this; + } + + public UploadFilesResult build() { + return new UploadFilesResult(this); + } + } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/BaseImportRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/BaseImportRequest.java index 99fd7e194..7a88c8a1f 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/BaseImportRequest.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/BaseImportRequest.java @@ -19,18 +19,10 @@ package io.milvus.bulkwriter.request.import_; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - import java.io.Serializable; +import java.util.HashMap; import java.util.Map; -@Data -@SuperBuilder(toBuilder = true) -@AllArgsConstructor -@NoArgsConstructor public class BaseImportRequest implements Serializable { private static final long serialVersionUID = 8192049841043084620L; /** @@ -40,4 +32,69 @@ public class BaseImportRequest implements Serializable { private String apiKey; private Map options; -} + + public BaseImportRequest() { + } + + public BaseImportRequest(String apiKey, Map options) { + this.apiKey = apiKey; + this.options = options; + } + + protected BaseImportRequest(BaseImportRequestBuilder builder) { + this.apiKey = builder.apiKey; + this.options = builder.options; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public Map getOptions() { + return options; + } + + public void setOptions(Map options) { + this.options = options; + } + + @Override + public String toString() { + return "BaseImportRequest{" + + "apiKey='" + apiKey + '\'' + + "options=" + options + + '}'; + } + + public static BaseImportRequestBuilder builder() { + return new BaseImportRequestBuilder<>(); + } + + public static class BaseImportRequestBuilder> { + private String apiKey = ""; + private Map options; + + protected BaseImportRequestBuilder() { + this.apiKey = ""; + this.options = new HashMap<>(); + } + + public T apiKey(String apiKey) { + this.apiKey = apiKey; + return (T) this; + } + + public T options(Map options) { + this.options = options; + return (T) this; + } + + public BaseImportRequest build() { + return new BaseImportRequest(this); + } + } +} \ No newline at end of file diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/CloudImportRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/CloudImportRequest.java index 0fd2819d6..54832cca4 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/CloudImportRequest.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/CloudImportRequest.java @@ -19,17 +19,9 @@ package io.milvus.bulkwriter.request.import_; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - +import java.util.ArrayList; import java.util.List; -@Data -@SuperBuilder -@AllArgsConstructor -@NoArgsConstructor /* If you want to import data into a Zilliz cloud instance and your data is stored in a storage bucket, you can use this method to import the data from the bucket. @@ -47,10 +39,10 @@ public class CloudImportRequest extends BaseImportRequest { /** * If the collection has partitionKey enabled: - * - The partitionName parameter cannot be specified for import. + * - The partitionName parameter cannot be specified for import. * If the collection does not have partitionKey enabled: - * - You may specify partitionName for the import. - * - Defaults to the "default" partition if not specified. + * - You may specify partitionName for the import. + * - Defaults to the "default" partition if not specified. */ private String partitionName; @@ -58,21 +50,21 @@ public class CloudImportRequest extends BaseImportRequest { * Data import can be configured in multiple ways using `objectUrls`: *

* 1. Multi-path import (multiple folders or files): - * "objectUrls": [ - * ["s3://bucket-name/parquet-folder-1/1.parquet"], - * ["s3://bucket-name/parquet-folder-2/1.parquet"], - * ["s3://bucket-name/parquet-folder-3/"] - * ] + * "objectUrls": [ + * ["s3://bucket-name/parquet-folder-1/1.parquet"], + * ["s3://bucket-name/parquet-folder-2/1.parquet"], + * ["s3://bucket-name/parquet-folder-3/"] + * ] *

* 2. Folder import: - * "objectUrls": [ - * ["s3://bucket-name/parquet-folder/"] - * ] + * "objectUrls": [ + * ["s3://bucket-name/parquet-folder/"] + * ] *

* 3. Single file import: - * "objectUrls": [ - * ["s3://bucket-name/parquet-folder/1.parquet"] - * ] + * "objectUrls": [ + * ["s3://bucket-name/parquet-folder/1.parquet"] + * ] */ private List> objectUrls; @@ -80,20 +72,218 @@ public class CloudImportRequest extends BaseImportRequest { * Use `objectUrls` instead for more flexible multi-path configuration. *

* Folder import: - * "objectUrl": "s3://bucket-name/parquet-folder/" + * "objectUrl": "s3://bucket-name/parquet-folder/" *

* File import: - * "objectUrl": "s3://bucket-name/parquet-folder/1.parquet" + * "objectUrl": "s3://bucket-name/parquet-folder/1.parquet" */ @Deprecated private String objectUrl; - /** Specify `accessKey` and `secretKey`; for short-term credentials, also include `token`. */ + /** + * Specify `accessKey` and `secretKey`; for short-term credentials, also include `token`. + */ private String accessKey; - /** Specify `accessKey` and `secretKey`; for short-term credentials, also include `token`. */ + /** + * Specify `accessKey` and `secretKey`; for short-term credentials, also include `token`. + */ private String secretKey; - /** Specify `accessKey` and `secretKey`; for short-term credentials, also include `token`. */ + /** + * Specify `accessKey` and `secretKey`; for short-term credentials, also include `token`. + */ private String token; -} + + public CloudImportRequest() { + } + + public CloudImportRequest(String clusterId, String dbName, String collectionName, String partitionName, + List> objectUrls, String accessKey, String secretKey, String token) { + this.clusterId = clusterId; + this.dbName = dbName; + this.collectionName = collectionName; + this.partitionName = partitionName; + this.objectUrls = objectUrls; + this.accessKey = accessKey; + this.secretKey = secretKey; + this.token = token; + } + + protected CloudImportRequest(CloudImportRequestBuilder builder) { + super(builder); + this.clusterId = builder.clusterId; + this.dbName = builder.dbName; + this.collectionName = builder.collectionName; + this.partitionName = builder.partitionName; + this.objectUrls = builder.objectUrls; + this.objectUrl = builder.objectUrl; + this.accessKey = builder.accessKey; + this.secretKey = builder.secretKey; + this.token = builder.token; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getDbName() { + return dbName; + } + + public void setDbName(String dbName) { + this.dbName = dbName; + } + + public String getCollectionName() { + return collectionName; + } + + public void setCollectionName(String collectionName) { + this.collectionName = collectionName; + } + + public String getPartitionName() { + return partitionName; + } + + public void setPartitionName(String partitionName) { + this.partitionName = partitionName; + } + + public List> getObjectUrls() { + return objectUrls; + } + + public void setObjectUrls(List> objectUrls) { + this.objectUrls = objectUrls; + } + + public String getObjectUrl() { + return objectUrl; + } + + public void setObjectUrl(String objectUrl) { + this.objectUrl = objectUrl; + } + + public String getAccessKey() { + return accessKey; + } + + public void setAccessKey(String accessKey) { + this.accessKey = accessKey; + } + + public String getSecretKey() { + return secretKey; + } + + public void setSecretKey(String secretKey) { + this.secretKey = secretKey; + } + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + + @Override + public String toString() { + return "CloudImportRequest{" + + "clusterId='" + clusterId + '\'' + + ", dbName='" + dbName + '\'' + + ", collectionName='" + collectionName + '\'' + + ", partitionName='" + partitionName + '\'' + + ", objectUrls=" + objectUrls + + ", objectUrl='" + objectUrl + '\'' + + ", accessKey='" + accessKey + '\'' + + ", secretKey='" + secretKey + '\'' + + ", token='" + token + '\'' + + '}'; + } + + public static CloudImportRequestBuilder builder() { + return new CloudImportRequestBuilder(); + } + + public static class CloudImportRequestBuilder extends BaseImportRequestBuilder { + private String clusterId; + private String dbName; + private String collectionName; + private String partitionName; + private List> objectUrls; + private String objectUrl; + private String accessKey; + private String secretKey; + private String token; + + private CloudImportRequestBuilder() { + this.clusterId = ""; + this.dbName = ""; + this.collectionName = ""; + this.partitionName = ""; + this.objectUrls = new ArrayList<>(); + this.objectUrl = ""; + this.accessKey = ""; + this.secretKey = ""; + this.token = ""; + } + + public CloudImportRequestBuilder clusterId(String clusterId) { + this.clusterId = clusterId; + return this; + } + + public CloudImportRequestBuilder dbName(String dbName) { + this.dbName = dbName; + return this; + } + + public CloudImportRequestBuilder collectionName(String collectionName) { + this.collectionName = collectionName; + return this; + } + + public CloudImportRequestBuilder partitionName(String partitionName) { + this.partitionName = partitionName; + return this; + } + + public CloudImportRequestBuilder objectUrls(List> objectUrls) { + this.objectUrls = objectUrls; + return this; + } + + public CloudImportRequestBuilder objectUrl(String objectUrl) { + this.objectUrl = objectUrl; + return this; + } + + public CloudImportRequestBuilder accessKey(String accessKey) { + this.accessKey = accessKey; + return this; + } + + public CloudImportRequestBuilder secretKey(String secretKey) { + this.secretKey = secretKey; + return this; + } + + public CloudImportRequestBuilder token(String token) { + this.token = token; + return this; + } + + public CloudImportRequest build() { + return new CloudImportRequest(this); + } + } +} \ No newline at end of file diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/MilvusImportRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/MilvusImportRequest.java index 7149fbfe5..628bc921f 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/MilvusImportRequest.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/MilvusImportRequest.java @@ -19,17 +19,9 @@ package io.milvus.bulkwriter.request.import_; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - +import java.util.ArrayList; import java.util.List; -@Data -@SuperBuilder -@AllArgsConstructor -@NoArgsConstructor /* If you want to import data into open-source Milvus, you can use this method to import the data files stored in the bucket where Milvus resides. @@ -45,10 +37,10 @@ public class MilvusImportRequest extends BaseImportRequest { /** * If the collection has partitionKey enabled: - * - The partitionName parameter cannot be specified for import. + * - The partitionName parameter cannot be specified for import. * If the collection does not have partitionKey enabled: - * - You may specify partitionName for the import. - * - Defaults to the "default" partition if not specified. + * - You may specify partitionName for the import. + * - Defaults to the "default" partition if not specified. */ private String partitionName; @@ -56,16 +48,118 @@ public class MilvusImportRequest extends BaseImportRequest { * Data import can be configured in multiple ways using `files`: *

* 1. Multi-path import (multiple files): - * "files": [ - * ["parquet-folder-1/1.parquet"], - * ["parquet-folder-2/1.parquet"], - * ["parquet-folder-3/1.parquet"] - * ] + * "files": [ + * ["parquet-folder-1/1.parquet"], + * ["parquet-folder-2/1.parquet"], + * ["parquet-folder-3/1.parquet"] + * ] *

* 2. Single file import: - * "files": [ - * ["parquet-folder/1.parquet"] - * ] + * "files": [ + * ["parquet-folder/1.parquet"] + * ] */ private List> files; -} + + public MilvusImportRequest() { + } + + public MilvusImportRequest(String dbName, String collectionName, String partitionName, List> files) { + this.dbName = dbName; + this.collectionName = collectionName; + this.partitionName = partitionName; + this.files = files; + } + + protected MilvusImportRequest(MilvusImportRequestBuilder builder) { + super(builder); + this.dbName = builder.dbName; + this.collectionName = builder.collectionName; + this.partitionName = builder.partitionName; + this.files = builder.files; + } + + public String getDbName() { + return dbName; + } + + public void setDbName(String dbName) { + this.dbName = dbName; + } + + public String getCollectionName() { + return collectionName; + } + + public void setCollectionName(String collectionName) { + this.collectionName = collectionName; + } + + public String getPartitionName() { + return partitionName; + } + + public void setPartitionName(String partitionName) { + this.partitionName = partitionName; + } + + public List> getFiles() { + return files; + } + + public void setFiles(List> files) { + this.files = files; + } + + @Override + public String toString() { + return "MilvusImportRequest{" + + "dbName='" + dbName + '\'' + + ", collectionName='" + collectionName + '\'' + + ", partitionName='" + partitionName + '\'' + + ", files=" + files + + '}'; + } + + public static MilvusImportRequestBuilder builder() { + return new MilvusImportRequestBuilder(); + } + + public static class MilvusImportRequestBuilder extends BaseImportRequestBuilder { + private String dbName; + private String collectionName; + private String partitionName; + private List> files; + + private MilvusImportRequestBuilder() { + this.dbName = ""; + this.collectionName = ""; + this.partitionName = ""; + this.files = new ArrayList<>(); + } + + public MilvusImportRequestBuilder dbName(String dbName) { + this.dbName = dbName; + return this; + } + + public MilvusImportRequestBuilder collectionName(String collectionName) { + this.collectionName = collectionName; + return this; + } + + public MilvusImportRequestBuilder partitionName(String partitionName) { + this.partitionName = partitionName; + return this; + } + + public MilvusImportRequestBuilder files(List> files) { + this.files = files; + return this; + } + + public MilvusImportRequest build() { + return new MilvusImportRequest(this); + } + } +} \ No newline at end of file diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/StageImportRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/StageImportRequest.java deleted file mode 100644 index 6a2215f52..000000000 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/StageImportRequest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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.bulkwriter.request.import_; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -import java.util.List; - -@Data -@SuperBuilder -@AllArgsConstructor -@NoArgsConstructor -/* - If you want to import data into a Zilliz cloud instance and your data is stored in a Zilliz stage, - you can use this method to import the data from the stage. - */ -public class StageImportRequest extends BaseImportRequest { - private String clusterId; - - /** - * For Free & Serverless deployments: specifying this parameter is not supported. - * For Dedicated deployments: this parameter can be specified; defaults to the "default" database. - */ - private String dbName; - private String collectionName; - - /** - * If the collection has partitionKey enabled: - * - The partitionName parameter cannot be specified for import. - * If the collection does not have partitionKey enabled: - * - You may specify partitionName for the import. - * - Defaults to the "default" partition if not specified. - */ - private String partitionName; - - private String stageName; - - /** - * Data import can be configured in multiple ways using `dataPaths`: - *

- * 1. Multi-path import (multiple folders or files): - * "dataPaths": [ - * ["parquet-folder-1/1.parquet"], - * ["parquet-folder-2/1.parquet"], - * ["parquet-folder-3/"] - * ] - *

- * 2. Folder import: - * "dataPaths": [ - * ["parquet-folder/"] - * ] - *

- * 3. Single file import: - * "dataPaths": [ - * ["parquet-folder/1.parquet"] - * ] - */ - private List> dataPaths; -} diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/VolumeImportRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/VolumeImportRequest.java new file mode 100644 index 000000000..2690945a4 --- /dev/null +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/VolumeImportRequest.java @@ -0,0 +1,210 @@ +/* + * 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.bulkwriter.request.import_; + +import java.util.ArrayList; +import java.util.List; + +/* + If you want to import data into a Zilliz cloud instance and your data is stored in a Zilliz volume, + you can use this method to import the data from the volume. + */ +public class VolumeImportRequest extends BaseImportRequest { + private String clusterId; + + /** + * For Free & Serverless deployments: specifying this parameter is not supported. + * For Dedicated deployments: this parameter can be specified; defaults to the "default" database. + */ + private String dbName; + private String collectionName; + + /** + * If the collection has partitionKey enabled: + * - The partitionName parameter cannot be specified for import. + * If the collection does not have partitionKey enabled: + * - You may specify partitionName for the import. + * - Defaults to the "default" partition if not specified. + */ + private String partitionName; + + private String volumeName; + + /** + * Data import can be configured in multiple ways using `dataPaths`: + *

+ * 1. Multi-path import (multiple folders or files): + * "dataPaths": [ + * ["parquet-folder-1/1.parquet"], + * ["parquet-folder-2/1.parquet"], + * ["parquet-folder-3/"] + * ] + *

+ * 2. Folder import: + * "dataPaths": [ + * ["parquet-folder/"] + * ] + *

+ * 3. Single file import: + * "dataPaths": [ + * ["parquet-folder/1.parquet"] + * ] + */ + private List> dataPaths; + + public VolumeImportRequest() { + } + + public VolumeImportRequest(String clusterId, String dbName, String collectionName, String partitionName, + String volumeName, List> dataPaths) { + this.clusterId = clusterId; + this.dbName = dbName; + this.collectionName = collectionName; + this.partitionName = partitionName; + this.volumeName = volumeName; + this.dataPaths = dataPaths; + } + + protected VolumeImportRequest(VolumeImportRequestBuilder builder) { + super(builder); + this.clusterId = builder.clusterId; + this.dbName = builder.dbName; + this.collectionName = builder.collectionName; + this.partitionName = builder.partitionName; + this.volumeName = builder.volumeName; + this.dataPaths = builder.dataPaths; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getDbName() { + return dbName; + } + + public void setDbName(String dbName) { + this.dbName = dbName; + } + + public String getCollectionName() { + return collectionName; + } + + public void setCollectionName(String collectionName) { + this.collectionName = collectionName; + } + + public String getPartitionName() { + return partitionName; + } + + public void setPartitionName(String partitionName) { + this.partitionName = partitionName; + } + + public String getVolumeName() { + return volumeName; + } + + public void setVolumeName(String volumeName) { + this.volumeName = volumeName; + } + + public List> getDataPaths() { + return dataPaths; + } + + public void setDataPaths(List> dataPaths) { + this.dataPaths = dataPaths; + } + + @Override + public String toString() { + return "VolumeImportRequest{" + + "clusterId='" + clusterId + '\'' + + ", dbName='" + dbName + '\'' + + ", collectionName='" + collectionName + '\'' + + ", partitionName='" + partitionName + '\'' + + ", volumeName='" + volumeName + '\'' + + ", dataPaths=" + dataPaths + + '}'; + } + + public static VolumeImportRequestBuilder builder() { + return new VolumeImportRequestBuilder(); + } + + public static class VolumeImportRequestBuilder extends BaseImportRequestBuilder { + private String clusterId; + private String dbName; + private String collectionName; + private String partitionName; + private String volumeName; + private List> dataPaths; + + private VolumeImportRequestBuilder() { + this.clusterId = ""; + this.dbName = ""; + this.collectionName = ""; + this.partitionName = ""; + this.volumeName = ""; + this.dataPaths = new ArrayList<>(); + } + + public VolumeImportRequestBuilder clusterId(String clusterId) { + this.clusterId = clusterId; + return this; + } + + public VolumeImportRequestBuilder dbName(String dbName) { + this.dbName = dbName; + return this; + } + + public VolumeImportRequestBuilder collectionName(String collectionName) { + this.collectionName = collectionName; + return this; + } + + public VolumeImportRequestBuilder partitionName(String partitionName) { + this.partitionName = partitionName; + return this; + } + + public VolumeImportRequestBuilder volumeName(String volumeName) { + this.volumeName = volumeName; + return this; + } + + public VolumeImportRequestBuilder dataPaths(List> dataPaths) { + this.dataPaths = dataPaths; + return this; + } + + public VolumeImportRequest build() { + return new VolumeImportRequest(this); + } + } +} diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/ApplyStageRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/ApplyStageRequest.java deleted file mode 100644 index 8ddeba45c..000000000 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/ApplyStageRequest.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.bulkwriter.request.stage; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -@Data -@SuperBuilder -@AllArgsConstructor -@NoArgsConstructor -public class ApplyStageRequest extends BaseStageRequest { - private String stageName; - private String path; -} diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/BaseStageRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/BaseStageRequest.java deleted file mode 100644 index a0f732eac..000000000 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/BaseStageRequest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.bulkwriter.request.stage; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -import java.io.Serializable; -import java.util.Map; - -@Data -@SuperBuilder(toBuilder = true) -@AllArgsConstructor -@NoArgsConstructor -public class BaseStageRequest implements Serializable { - private static final long serialVersionUID = 8192049841043084620L; - /** - * If you are calling the cloud API, this parameter needs to be filled in; otherwise, you can ignore it. - */ - private String apiKey; - - private Map options; -} diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/CreateStageRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/CreateStageRequest.java deleted file mode 100644 index 9420ea13b..000000000 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/CreateStageRequest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.bulkwriter.request.stage; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -@Data -@SuperBuilder -@AllArgsConstructor -@NoArgsConstructor -public class CreateStageRequest { - private String projectId; - private String regionId; - private String stageName; -} diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/ListStagesRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/ListStagesRequest.java deleted file mode 100644 index 6b24cd60e..000000000 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/ListStagesRequest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.bulkwriter.request.stage; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -@Data -@SuperBuilder -@AllArgsConstructor -@NoArgsConstructor -public class ListStagesRequest { - private String projectId; - private Integer pageSize; - private Integer currentPage; -} diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/UploadFilesRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/UploadFilesRequest.java deleted file mode 100644 index d749d12d4..000000000 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/UploadFilesRequest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.bulkwriter.request.stage; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -@Data -@SuperBuilder -@AllArgsConstructor -@NoArgsConstructor -public class UploadFilesRequest { - /** - * The full path of a local file or directory: - * If it is a file, please include the file name, e.g., /Users/zilliz/data/1.parquet - * If it is a directory, please end the path with a /, e.g., /Users/zilliz/data/ - */ - private String sourceFilePath; - - /** - * The target stage directory path: - * Leave it empty to upload to the root directory. - * To upload to a specific folder, end the path with a /, e.g., data/ - */ - private String targetStagePath; -} diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/ApplyVolumeRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/ApplyVolumeRequest.java new file mode 100644 index 000000000..296f05890 --- /dev/null +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/ApplyVolumeRequest.java @@ -0,0 +1,91 @@ +/* + * 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.bulkwriter.request.volume; + +public class ApplyVolumeRequest extends BaseVolumeRequest { + private String volumeName; + private String path; + + protected ApplyVolumeRequest() { + } + + protected ApplyVolumeRequest(String volumeName, String path) { + this.volumeName = volumeName; + this.path = path; + } + + protected ApplyVolumeRequest(ApplyVolumeRequestBuilder builder) { + super(builder); + this.volumeName = builder.volumeName; + this.path = builder.path; + } + + public String getVolumeName() { + return volumeName; + } + + public void setVolumeName(String volumeName) { + this.volumeName = volumeName; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Override + public String toString() { + return "ApplyVolumeRequest{" + + "volumeName='" + volumeName + '\'' + + ", path='" + path + '\'' + + '}'; + } + + public static ApplyVolumeRequestBuilder builder() { + return new ApplyVolumeRequestBuilder(); + } + + public static class ApplyVolumeRequestBuilder extends BaseVolumeRequestBuilder { + private String volumeName; + private String path; + + private ApplyVolumeRequestBuilder() { + this.volumeName = ""; + this.path = ""; + } + + public ApplyVolumeRequestBuilder volumeName(String volumeName) { + this.volumeName = volumeName; + return this; + } + + public ApplyVolumeRequestBuilder path(String path) { + this.path = path; + return this; + } + + public ApplyVolumeRequest build() { + return new ApplyVolumeRequest(this); + } + } +} diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/BaseVolumeRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/BaseVolumeRequest.java new file mode 100644 index 000000000..500626f28 --- /dev/null +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/BaseVolumeRequest.java @@ -0,0 +1,98 @@ +/* + * 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.bulkwriter.request.volume; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +public class BaseVolumeRequest implements Serializable { + private static final long serialVersionUID = 8192049841043084620L; + /** + * If you are calling the cloud API, this parameter needs to be filled in; otherwise, you can ignore it. + */ + private String apiKey; + private Map options; + + protected BaseVolumeRequest() { + } + + protected BaseVolumeRequest(String apiKey, Map options) { + this.apiKey = apiKey; + this.options = options; + } + + protected BaseVolumeRequest(BaseVolumeRequestBuilder builder) { + this.apiKey = builder.apiKey; + this.options = builder.options; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public Map getOptions() { + return options; + } + + public void setOptions(Map options) { + this.options = options; + } + + @Override + public String toString() { + return "BaseVolumeRequest{" + + "apiKey='" + apiKey + '\'' + + "options=" + options + + '}'; + } + + public static BaseVolumeRequestBuilder builder() { + return new BaseVolumeRequestBuilder<>(); + } + + public static class BaseVolumeRequestBuilder> { + private String apiKey; + private Map options; + + protected BaseVolumeRequestBuilder() { + this.apiKey = ""; + this.options = new HashMap<>(); + } + + public T apiKey(String apiKey) { + this.apiKey = apiKey; + return (T) this; + } + + public T options(Map options) { + this.options = options; + return (T) this; + } + + public BaseVolumeRequest build() { + return new BaseVolumeRequest(this); + } + } +} diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/CreateVolumeRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/CreateVolumeRequest.java new file mode 100644 index 000000000..03463d200 --- /dev/null +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/CreateVolumeRequest.java @@ -0,0 +1,109 @@ +/* + * 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.bulkwriter.request.volume; + +public class CreateVolumeRequest { + private String projectId; + private String regionId; + private String volumeName; + + public CreateVolumeRequest() { + } + + public CreateVolumeRequest(String projectId, String regionId, String volumeName) { + this.projectId = projectId; + this.regionId = regionId; + this.volumeName = volumeName; + } + + protected CreateVolumeRequest(CreateVolumeRequestBuilder builder) { + this.projectId = builder.projectId; + this.regionId = builder.regionId; + this.volumeName = builder.volumeName; + } + + public String getProjectId() { + return projectId; + } + + public void setProjectId(String projectId) { + this.projectId = projectId; + } + + public String getRegionId() { + return regionId; + } + + public void setRegionId(String regionId) { + this.regionId = regionId; + } + + public String getVolumeName() { + return volumeName; + } + + public void setVolumeName(String volumeName) { + this.volumeName = volumeName; + } + + @Override + public String toString() { + return "CreateVolumeRequest{" + + "projectId='" + projectId + '\'' + + ", regionId='" + regionId + '\'' + + ", volumeName='" + volumeName + '\'' + + '}'; + } + + public static CreateVolumeRequestBuilder builder() { + return new CreateVolumeRequestBuilder(); + } + + public static class CreateVolumeRequestBuilder { + private String projectId; + private String regionId; + private String volumeName; + + private CreateVolumeRequestBuilder() { + this.projectId = ""; + this.regionId = ""; + this.volumeName = ""; + } + + public CreateVolumeRequestBuilder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + public CreateVolumeRequestBuilder regionId(String regionId) { + this.regionId = regionId; + return this; + } + + public CreateVolumeRequestBuilder volumeName(String volumeName) { + this.volumeName = volumeName; + return this; + } + + public CreateVolumeRequest build() { + return new CreateVolumeRequest(this); + } + } +} diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/DeleteVolumeRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/DeleteVolumeRequest.java new file mode 100644 index 000000000..330ae60dc --- /dev/null +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/DeleteVolumeRequest.java @@ -0,0 +1,71 @@ +/* + * 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.bulkwriter.request.volume; + +public class DeleteVolumeRequest { + private String volumeName; + + public DeleteVolumeRequest() { + } + + public DeleteVolumeRequest(String volumeName) { + this.volumeName = volumeName; + } + + protected DeleteVolumeRequest(DeleteVolumeRequestBuilder builder) { + this.volumeName = builder.volumeName; + } + + public String getVolumeName() { + return volumeName; + } + + public void setVolumeName(String volumeName) { + this.volumeName = volumeName; + } + + @Override + public String toString() { + return "DeleteVolumeRequest{" + + "volumeName='" + volumeName + '\'' + + '}'; + } + + public static DeleteVolumeRequestBuilder builder() { + return new DeleteVolumeRequestBuilder(); + } + + public static class DeleteVolumeRequestBuilder { + private String volumeName; + + private DeleteVolumeRequestBuilder() { + this.volumeName = ""; + } + + public DeleteVolumeRequestBuilder volumeName(String volumeName) { + this.volumeName = volumeName; + return this; + } + + public DeleteVolumeRequest build() { + return new DeleteVolumeRequest(this); + } + } +} diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/ListVolumesRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/ListVolumesRequest.java new file mode 100644 index 000000000..a386bd848 --- /dev/null +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/ListVolumesRequest.java @@ -0,0 +1,110 @@ +/* + * 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.bulkwriter.request.volume; + + +public class ListVolumesRequest { + private String projectId; + private Integer pageSize; + private Integer currentPage; + + public ListVolumesRequest() { + } + + public ListVolumesRequest(String projectId, Integer pageSize, Integer currentPage) { + this.projectId = projectId; + this.pageSize = pageSize; + this.currentPage = currentPage; + } + + protected ListVolumesRequest(ListVolumesRequestBuilder builder) { + this.projectId = builder.projectId; + this.pageSize = builder.pageSize; + this.currentPage = builder.currentPage; + } + + public String getProjectId() { + return projectId; + } + + public void setProjectId(String projectId) { + this.projectId = projectId; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public Integer getCurrentPage() { + return currentPage; + } + + public void setCurrentPage(Integer currentPage) { + this.currentPage = currentPage; + } + + @Override + public String toString() { + return "ListVolumesRequest{" + + "projectId='" + projectId + '\'' + + ", pageSize=" + pageSize + + ", currentPage=" + currentPage + + '}'; + } + + public static ListVolumesRequestBuilder builder() { + return new ListVolumesRequestBuilder(); + } + + public static class ListVolumesRequestBuilder { + private String projectId; + private Integer pageSize; + private Integer currentPage; + + private ListVolumesRequestBuilder() { + this.projectId = ""; + this.pageSize = 0; + this.currentPage = 0; + } + + public ListVolumesRequestBuilder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + public ListVolumesRequestBuilder pageSize(Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + public ListVolumesRequestBuilder currentPage(Integer currentPage) { + this.currentPage = currentPage; + return this; + } + + public ListVolumesRequest build() { + return new ListVolumesRequest(this); + } + } +} diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/UploadFilesRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/UploadFilesRequest.java new file mode 100644 index 000000000..5b8348227 --- /dev/null +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/UploadFilesRequest.java @@ -0,0 +1,101 @@ +/* + * 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.bulkwriter.request.volume; + +public class UploadFilesRequest { + /** + * The full path of a local file or directory: + * If it is a file, please include the file name, e.g., /Users/zilliz/data/1.parquet + * If it is a directory, please end the path with a /, e.g., /Users/zilliz/data/ + */ + private String sourceFilePath; + + /** + * The target volume directory path: + * Leave it empty to upload to the root directory. + * To upload to a specific folder, end the path with a /, e.g., data/ + */ + private String targetVolumePath; + + public UploadFilesRequest() { + } + + public UploadFilesRequest(String sourceFilePath, String targetVolumePath) { + this.sourceFilePath = sourceFilePath; + this.targetVolumePath = targetVolumePath; + } + + protected UploadFilesRequest(UploadFilesRequestBuilder builder) { + this.sourceFilePath = builder.sourceFilePath; + this.targetVolumePath = builder.targetVolumePath; + } + + public String getSourceFilePath() { + return sourceFilePath; + } + + public void setSourceFilePath(String sourceFilePath) { + this.sourceFilePath = sourceFilePath; + } + + public String getTargetVolumePath() { + return targetVolumePath; + } + + public void setTargetVolumePath(String targetVolumePath) { + this.targetVolumePath = targetVolumePath; + } + + @Override + public String toString() { + return "UploadFilesRequest{" + + "sourceFilePath='" + sourceFilePath + '\'' + + ", targetVolumePath='" + targetVolumePath + '\'' + + '}'; + } + + public static UploadFilesRequestBuilder builder() { + return new UploadFilesRequestBuilder(); + } + + public static class UploadFilesRequestBuilder { + private String sourceFilePath; + private String targetVolumePath; + + private UploadFilesRequestBuilder() { + this.sourceFilePath = ""; + this.targetVolumePath = ""; + } + + public UploadFilesRequestBuilder sourceFilePath(String sourceFilePath) { + this.sourceFilePath = sourceFilePath; + return this; + } + + public UploadFilesRequestBuilder targetVolumePath(String targetVolumePath) { + this.targetVolumePath = targetVolumePath; + return this; + } + + public UploadFilesRequest build() { + return new UploadFilesRequest(this); + } + } +} diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/ApplyStageResponse.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/ApplyStageResponse.java deleted file mode 100644 index de13d981f..000000000 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/ApplyStageResponse.java +++ /dev/null @@ -1,55 +0,0 @@ -package io.milvus.bulkwriter.response; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -import java.io.Serializable; - - -@Data -@SuperBuilder -@AllArgsConstructor -@NoArgsConstructor -public class ApplyStageResponse implements Serializable { - private String endpoint; - - private String cloud; - - private String region; - - private String bucketName; - - private String uploadPath; - - private Credentials credentials; - - private Condition condition; - - private String stageName; - - private String stagePrefix; - - @AllArgsConstructor - @NoArgsConstructor - @Data - @Builder - public static class Credentials implements Serializable { - private static final long serialVersionUID = 623702599895113789L; - private String tmpAK; - private String tmpSK; - private String sessionToken; - private String expireTime; - } - - @AllArgsConstructor - @NoArgsConstructor - @Data - @Builder - public static class Condition implements Serializable { - private static final long serialVersionUID = -2613029991242322109L; - private Long maxContentLength; - } -} diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/ApplyVolumeResponse.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/ApplyVolumeResponse.java new file mode 100644 index 000000000..7e412a94a --- /dev/null +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/ApplyVolumeResponse.java @@ -0,0 +1,373 @@ +package io.milvus.bulkwriter.response; + +import java.io.Serializable; + + +public class ApplyVolumeResponse implements Serializable { + private String endpoint; + private String cloud; + private String region; + private String bucketName; + private String uploadPath; + private Credentials credentials; + private Condition condition; + private String volumeName; + private String volumePrefix; + + public ApplyVolumeResponse() { + } + + public ApplyVolumeResponse(String endpoint, String cloud, String region, String bucketName, String uploadPath, + Credentials credentials, Condition condition, String volumeName, String volumePrefix) { + this.endpoint = endpoint; + this.cloud = cloud; + this.region = region; + this.bucketName = bucketName; + this.uploadPath = uploadPath; + this.credentials = credentials; + this.condition = condition; + this.volumeName = volumeName; + this.volumePrefix = volumePrefix; + } + + private ApplyVolumeResponse(ApplyVolumeResponseBuilder builder) { + this.endpoint = builder.endpoint; + this.cloud = builder.cloud; + this.region = builder.region; + this.bucketName = builder.bucketName; + this.uploadPath = builder.uploadPath; + this.credentials = builder.credentials; + this.condition = builder.condition; + this.volumeName = builder.volumeName; + this.volumePrefix = builder.volumePrefix; + } + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public String getCloud() { + return cloud; + } + + public void setCloud(String cloud) { + this.cloud = cloud; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getBucketName() { + return bucketName; + } + + public void setBucketName(String bucketName) { + this.bucketName = bucketName; + } + + public String getUploadPath() { + return uploadPath; + } + + public void setUploadPath(String uploadPath) { + this.uploadPath = uploadPath; + } + + public Credentials getCredentials() { + return credentials; + } + + public void setCredentials(Credentials credentials) { + this.credentials = credentials; + } + + public Condition getCondition() { + return condition; + } + + public void setCondition(Condition condition) { + this.condition = condition; + } + + public String getVolumeName() { + return volumeName; + } + + public void setVolumeName(String volumeName) { + this.volumeName = volumeName; + } + + public String getVolumePrefix() { + return volumePrefix; + } + + public void setVolumePrefix(String volumePrefix) { + this.volumePrefix = volumePrefix; + } + + @Override + public String toString() { + return "ApplyVolumeResponse{" + + ", endpoint='" + endpoint + '\'' + + ", cloud='" + cloud + '\'' + + ", region='" + region + '\'' + + ", bucketName='" + bucketName + '\'' + + ", uploadPath='" + uploadPath + '\'' + + ", credentials=" + credentials + + ", condition=" + condition + + ", volumeName='" + volumeName + '\'' + + ", volumePrefix='" + volumePrefix + '\'' + + '}'; + } + + public static ApplyVolumeResponseBuilder builder() { + return new ApplyVolumeResponseBuilder(); + } + + public static class ApplyVolumeResponseBuilder { + private String endpoint; + private String cloud; + private String region; + private String bucketName; + private String uploadPath; + private Credentials credentials; + private Condition condition; + private String volumeName; + private String volumePrefix; + + private ApplyVolumeResponseBuilder() { + this.endpoint = ""; + this.cloud = ""; + this.region = ""; + this.bucketName = ""; + this.uploadPath = ""; + this.credentials = new Credentials(); + this.condition = new Condition(); + this.volumeName = ""; + this.volumePrefix = ""; + } + + public ApplyVolumeResponseBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + public ApplyVolumeResponseBuilder cloud(String cloud) { + this.cloud = cloud; + return this; + } + + public ApplyVolumeResponseBuilder region(String region) { + this.region = region; + return this; + } + + public ApplyVolumeResponseBuilder bucketName(String bucketName) { + this.bucketName = bucketName; + return this; + } + + public ApplyVolumeResponseBuilder uploadPath(String uploadPath) { + this.uploadPath = uploadPath; + return this; + } + + public ApplyVolumeResponseBuilder credentials(Credentials credentials) { + this.credentials = credentials; + return this; + } + + public ApplyVolumeResponseBuilder condition(Condition condition) { + this.condition = condition; + return this; + } + + public ApplyVolumeResponseBuilder volumeName(String volumeName) { + this.volumeName = volumeName; + return this; + } + + public ApplyVolumeResponseBuilder volumePrefix(String volumePrefix) { + this.volumePrefix = volumePrefix; + return this; + } + + public ApplyVolumeResponse build() { + return new ApplyVolumeResponse(this); + } + } + + public static class Credentials implements Serializable { + private static final long serialVersionUID = 623702599895113789L; + private String tmpAK; + private String tmpSK; + private String sessionToken; + private String expireTime; + + public Credentials() { + } + + public Credentials(String tmpAK, String tmpSK, String sessionToken, String expireTime) { + this.tmpAK = tmpAK; + this.tmpSK = tmpSK; + this.sessionToken = sessionToken; + this.expireTime = expireTime; + } + + private Credentials(CredentialsBuilder builder) { + this.tmpAK = builder.tmpAK; + this.tmpSK = builder.tmpSK; + this.sessionToken = builder.sessionToken; + this.expireTime = builder.expireTime; + } + + public String getTmpAK() { + return tmpAK; + } + + public void setTmpAK(String tmpAK) { + this.tmpAK = tmpAK; + } + + public String getTmpSK() { + return tmpSK; + } + + public void setTmpSK(String tmpSK) { + this.tmpSK = tmpSK; + } + + public String getSessionToken() { + return sessionToken; + } + + public void setSessionToken(String sessionToken) { + this.sessionToken = sessionToken; + } + + public String getExpireTime() { + return expireTime; + } + + public void setExpireTime(String expireTime) { + this.expireTime = expireTime; + } + + @Override + public String toString() { + return "Credentials{" + + ", tmpAK='" + tmpAK + '\'' + + ", expireTime='" + expireTime + '\'' + + '}'; + } + + public static CredentialsBuilder builder() { + return new CredentialsBuilder(); + } + + public static class CredentialsBuilder { + private String tmpAK; + private String tmpSK; + private String sessionToken; + private String expireTime; + + private CredentialsBuilder() { + this.tmpAK = ""; + this.tmpSK = ""; + this.sessionToken = ""; + this.expireTime = ""; + } + + public CredentialsBuilder tmpAK(String tmpAK) { + this.tmpAK = tmpAK; + return this; + } + + public CredentialsBuilder tmpSK(String tmpSK) { + this.tmpSK = tmpSK; + return this; + } + + public CredentialsBuilder sessionToken(String sessionToken) { + this.sessionToken = sessionToken; + return this; + } + + public CredentialsBuilder expireTime(String expireTime) { + this.expireTime = expireTime; + return this; + } + + public Credentials build() { + return new Credentials(this); + } + } + } + + public static class Condition implements Serializable { + private static final long serialVersionUID = -2613029991242322109L; + private Long maxContentLength; + private Long maxFileNumber; + + public Condition() { + } + + public Condition(Long maxContentLength) { + this.maxContentLength = maxContentLength; + } + + private Condition(ConditionBuilder builder) { + this.maxContentLength = builder.maxContentLength; + } + + public Long getMaxContentLength() { + return maxContentLength; + } + + public Long getMaxFileNumber() { + return maxFileNumber; + } + + public void setMaxContentLength(Long maxContentLength) { + this.maxContentLength = maxContentLength; + } + + @Override + public String toString() { + return "Condition{" + + ", maxContentLength=" + maxContentLength + + ", maxFileNumber=" + maxFileNumber + + '}'; + } + + public static ConditionBuilder builder() { + return new ConditionBuilder(); + } + + public static class ConditionBuilder { + private Long maxContentLength; + + private ConditionBuilder() { + this.maxContentLength = 0L; + } + + public ConditionBuilder maxContentLength(Long maxContentLength) { + this.maxContentLength = maxContentLength; + return this; + } + + public Condition build() { + return new Condition(this); + } + } + } +} diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/stage/ListStagesResponse.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/stage/ListStagesResponse.java deleted file mode 100644 index ca045ebb1..000000000 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/stage/ListStagesResponse.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.bulkwriter.response.stage; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.List; - -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class ListStagesResponse { - - private Integer count; - - private Integer currentPage; - - private Integer pageSize; - - private List stages; -} diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/volume/ListVolumesResponse.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/volume/ListVolumesResponse.java new file mode 100644 index 000000000..0eb11b673 --- /dev/null +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/volume/ListVolumesResponse.java @@ -0,0 +1,130 @@ +/* + * 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.bulkwriter.response.volume; + +import java.util.ArrayList; +import java.util.List; + +public class ListVolumesResponse { + private Integer count; + private Integer currentPage; + private Integer pageSize; + private List volumes; + + public ListVolumesResponse() { + } + + public ListVolumesResponse(Integer count, Integer currentPage, Integer pageSize, List volumes) { + this.count = count; + this.currentPage = currentPage; + this.pageSize = pageSize; + this.volumes = volumes; + } + + private ListVolumesResponse(ListVolumesResponseBuilder builder) { + this.count = builder.count; + this.currentPage = builder.currentPage; + this.pageSize = builder.pageSize; + this.volumes = builder.volumes; + } + + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public Integer getCurrentPage() { + return currentPage; + } + + public void setCurrentPage(Integer currentPage) { + this.currentPage = currentPage; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public List getVolumes() { + return volumes; + } + + public void setVolumes(List volumes) { + this.volumes = volumes; + } + + @Override + public String toString() { + return "ListVolumesResponse{" + + ", count=" + count + + ", currentPage=" + currentPage + + ", pageSize=" + pageSize + + '}'; + } + + public static ListVolumesResponseBuilder builder() { + return new ListVolumesResponseBuilder(); + } + + public static class ListVolumesResponseBuilder { + private Integer count; + private Integer currentPage; + private Integer pageSize; + private List volumes; + + private ListVolumesResponseBuilder() { + this.count = 0; + this.currentPage = 0; + this.pageSize = 0; + this.volumes = new ArrayList<>(); + } + + public ListVolumesResponseBuilder count(Integer count) { + this.count = count; + return this; + } + + public ListVolumesResponseBuilder currentPage(Integer currentPage) { + this.currentPage = currentPage; + return this; + } + + public ListVolumesResponseBuilder pageSize(Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + public ListVolumesResponseBuilder volumes(List volumes) { + this.volumes = volumes; + return this; + } + + public ListVolumesResponse build() { + return new ListVolumesResponse(this); + } + } +} diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/volume/VolumeInfo.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/volume/VolumeInfo.java new file mode 100644 index 000000000..9337b6795 --- /dev/null +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/volume/VolumeInfo.java @@ -0,0 +1,52 @@ +package io.milvus.bulkwriter.response.volume; + +public class VolumeInfo { + private String volumeName; + + public VolumeInfo() { + } + + public VolumeInfo(String volumeName) { + this.volumeName = volumeName; + } + + private VolumeInfo(VolumeInfoBuilder builder) { + this.volumeName = builder.volumeName; + } + + public String getVolumeName() { + return volumeName; + } + + public void setVolumeName(String volumeName) { + this.volumeName = volumeName; + } + + @Override + public String toString() { + return "VolumeInfo{" + + "volumeName='" + volumeName + '\'' + + '}'; + } + + public static VolumeInfoBuilder builder() { + return new VolumeInfoBuilder(); + } + + public static class VolumeInfoBuilder { + private String volumeName; + + private VolumeInfoBuilder() { + this.volumeName = ""; + } + + public VolumeInfoBuilder volumeName(String volumeName) { + this.volumeName = volumeName; + return this; + } + + public VolumeInfo build() { + return new VolumeInfo(this); + } + } +} diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/restful/DataStageUtils.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/restful/DataVolumeUtils.java similarity index 75% rename from sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/restful/DataStageUtils.java rename to sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/restful/DataVolumeUtils.java index fde3d67d7..bd846626d 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/restful/DataStageUtils.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/restful/DataVolumeUtils.java @@ -21,18 +21,18 @@ import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; -import io.milvus.bulkwriter.request.stage.BaseStageRequest; -import io.milvus.bulkwriter.request.stage.CreateStageRequest; -import io.milvus.bulkwriter.request.stage.DeleteStageRequest; -import io.milvus.bulkwriter.request.stage.ListStagesRequest; +import io.milvus.bulkwriter.request.volume.BaseVolumeRequest; +import io.milvus.bulkwriter.request.volume.CreateVolumeRequest; +import io.milvus.bulkwriter.request.volume.DeleteVolumeRequest; +import io.milvus.bulkwriter.request.volume.ListVolumesRequest; import io.milvus.bulkwriter.response.RestfulResponse; import io.milvus.common.utils.JsonUtils; import java.util.Map; -public class DataStageUtils extends BaseRestful { - public static String applyStage(String url, BaseStageRequest request) { - String requestURL = url + "/v2/stages/apply"; +public class DataVolumeUtils extends BaseRestful { + public static String applyVolume(String url, BaseVolumeRequest request) { + String requestURL = url + "/v2/volumes/apply"; Map params = JsonUtils.fromJson(JsonUtils.toJson(request), new TypeToken>() {}.getType()); String body = postRequest(requestURL, request.getApiKey(), params, 60 * 1000); @@ -41,8 +41,8 @@ public static String applyStage(String url, BaseStageRequest request) { return new Gson().toJson(response.getData()); } - public static String listStages(String url, String apiKey, ListStagesRequest request) { - String requestURL = url + "/v2/stages"; + public static String listVolumes(String url, String apiKey, ListVolumesRequest request) { + String requestURL = url + "/v2/volumes"; Map params = JsonUtils.fromJson(JsonUtils.toJson(request), new TypeToken>() {}.getType()); String body = getRequest(requestURL, apiKey, params, 60 * 1000); @@ -51,8 +51,8 @@ public static String listStages(String url, String apiKey, ListStagesRequest req return new Gson().toJson(response.getData()); } - public static void createStage(String url, String apiKey, CreateStageRequest request) { - String requestURL = url + "/v2/stages/create"; + public static void createVolume(String url, String apiKey, CreateVolumeRequest request) { + String requestURL = url + "/v2/volumes/create"; Map params = JsonUtils.fromJson(JsonUtils.toJson(request), new TypeToken>() {}.getType()); String body = postRequest(requestURL, apiKey, params, 60 * 1000); @@ -60,8 +60,8 @@ public static void createStage(String url, String apiKey, CreateStageRequest req handleResponse(requestURL, response); } - public static void deleteStage(String url, String apiKey, DeleteStageRequest request) { - String requestURL = url + "/v2/stages/" + request.getStageName(); + public static void deleteVolume(String url, String apiKey, DeleteVolumeRequest request) { + String requestURL = url + "/v2/volumes/" + request.getVolumeName(); Map params = JsonUtils.fromJson(JsonUtils.toJson(request), new TypeToken>() {}.getType()); String body = deleteRequest(requestURL, apiKey, params, 60 * 1000);