Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions examples/src/main/java/io/milvus/v2/VolumeManagerExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
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.DescribeVolumeRequest;
import io.milvus.bulkwriter.request.volume.ListVolumesRequest;
import io.milvus.bulkwriter.response.volume.ListVolumesResponse;
import io.milvus.bulkwriter.response.volume.VolumeInfo;


public class VolumeManagerExample {
Expand All @@ -44,6 +46,8 @@ public class VolumeManagerExample {

public static void main(String[] args) throws Exception {
createVolume();
// createExternalVolume();
describeVolume();
listVolumes();
deleteVolume();
}
Expand All @@ -56,12 +60,39 @@ private static void createVolume() {
System.out.printf("\nVolume %s created%n", VOLUME_NAME);
}

private static void createExternalVolume() {
CreateVolumeRequest request = CreateVolumeRequest.builder()
.projectId(PROJECT_ID).regionId(REGION_ID).volumeName("ext-volume")
.type("EXTERNAL")
.storageIntegrationId("integ-xxxx")
.path("import_data/")
.build();
volumeManager.createVolume(request);
System.out.printf("\nExternal volume %s created%n", "ext-volume");
}

private static void describeVolume() {
DescribeVolumeRequest request = DescribeVolumeRequest.builder()
.volumeName(VOLUME_NAME)
.build();
VolumeInfo volumeInfo = volumeManager.describeVolume(request);
System.out.println("\ndescribeVolume result: " + new Gson().toJson(volumeInfo));
}

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));

// List volumes filtered by type
ListVolumesRequest filteredRequest = ListVolumesRequest.builder()
.projectId(PROJECT_ID).currentPage(1).pageSize(10)
.type("EXTERNAL")
.build();
ListVolumesResponse filteredResponse = volumeManager.listVolumes(filteredRequest);
System.out.println("\nlistVolumes (EXTERNAL) results: " + new Gson().toJson(filteredResponse));
}

private static void deleteVolume() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
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.DescribeVolumeRequest;
import io.milvus.bulkwriter.request.volume.ListVolumesRequest;
import io.milvus.bulkwriter.response.volume.ListVolumesResponse;
import io.milvus.bulkwriter.response.volume.VolumeInfo;
import io.milvus.bulkwriter.restful.DataVolumeUtils;

public class VolumeManager {
Expand All @@ -42,6 +44,14 @@ public void createVolume(CreateVolumeRequest request) {
DataVolumeUtils.createVolume(cloudEndpoint, apiKey, request);
}

/**
* Get detailed information about a specific volume.
*/
public VolumeInfo describeVolume(DescribeVolumeRequest request) {
String result = DataVolumeUtils.describeVolume(cloudEndpoint, apiKey, request);
return new Gson().fromJson(result, VolumeInfo.class);
}

/**
* Delete a volume.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public class CreateVolumeRequest {
private String projectId;
private String regionId;
private String volumeName;
private String type;
private String storageIntegrationId;
private String path;

public CreateVolumeRequest() {
}
Expand All @@ -37,6 +40,9 @@ protected CreateVolumeRequest(CreateVolumeRequestBuilder builder) {
this.projectId = builder.projectId;
this.regionId = builder.regionId;
this.volumeName = builder.volumeName;
this.type = builder.type;
this.storageIntegrationId = builder.storageIntegrationId;
this.path = builder.path;
}

public String getProjectId() {
Expand All @@ -63,12 +69,39 @@ public void setVolumeName(String volumeName) {
this.volumeName = volumeName;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getStorageIntegrationId() {
return storageIntegrationId;
}

public void setStorageIntegrationId(String storageIntegrationId) {
this.storageIntegrationId = storageIntegrationId;
}

public String getPath() {
return path;
}

public void setPath(String path) {
this.path = path;
}

@Override
public String toString() {
return "CreateVolumeRequest{" +
"projectId='" + projectId + '\'' +
", regionId='" + regionId + '\'' +
", volumeName='" + volumeName + '\'' +
", type='" + type + '\'' +
", storageIntegrationId='" + storageIntegrationId + '\'' +
", path='" + path + '\'' +
'}';
}

Expand All @@ -80,6 +113,9 @@ public static class CreateVolumeRequestBuilder {
private String projectId;
private String regionId;
private String volumeName;
private String type;
private String storageIntegrationId;
private String path;

private CreateVolumeRequestBuilder() {
this.projectId = "";
Expand All @@ -102,6 +138,21 @@ public CreateVolumeRequestBuilder volumeName(String volumeName) {
return this;
}

public CreateVolumeRequestBuilder type(String type) {
this.type = type;
return this;
}

public CreateVolumeRequestBuilder storageIntegrationId(String storageIntegrationId) {
this.storageIntegrationId = storageIntegrationId;
return this;
}

public CreateVolumeRequestBuilder path(String path) {
this.path = path;
return this;
}

public CreateVolumeRequest build() {
return new CreateVolumeRequest(this);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 DescribeVolumeRequest {
private String volumeName;

public DescribeVolumeRequest() {
}

public DescribeVolumeRequest(String volumeName) {
this.volumeName = volumeName;
}

protected DescribeVolumeRequest(DescribeVolumeRequestBuilder builder) {
this.volumeName = builder.volumeName;
}

public String getVolumeName() {
return volumeName;
}

public void setVolumeName(String volumeName) {
this.volumeName = volumeName;
}

@Override
public String toString() {
return "DescribeVolumeRequest{" +
"volumeName='" + volumeName + '\'' +
'}';
}

public static DescribeVolumeRequestBuilder builder() {
return new DescribeVolumeRequestBuilder();
}

public static class DescribeVolumeRequestBuilder {
private String volumeName;

private DescribeVolumeRequestBuilder() {
this.volumeName = "";
}

public DescribeVolumeRequestBuilder volumeName(String volumeName) {
this.volumeName = volumeName;
return this;
}

public DescribeVolumeRequest build() {
return new DescribeVolumeRequest(this);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class ListVolumesRequest {
private String projectId;
private Integer pageSize;
private Integer currentPage;
private String type;

public ListVolumesRequest() {
}
Expand All @@ -38,6 +39,7 @@ protected ListVolumesRequest(ListVolumesRequestBuilder builder) {
this.projectId = builder.projectId;
this.pageSize = builder.pageSize;
this.currentPage = builder.currentPage;
this.type = builder.type;
}

public String getProjectId() {
Expand All @@ -64,12 +66,21 @@ public void setCurrentPage(Integer currentPage) {
this.currentPage = currentPage;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

@Override
public String toString() {
return "ListVolumesRequest{" +
"projectId='" + projectId + '\'' +
", pageSize=" + pageSize +
", currentPage=" + currentPage +
", type='" + type + '\'' +
'}';
}

Expand All @@ -81,6 +92,7 @@ public static class ListVolumesRequestBuilder {
private String projectId;
private Integer pageSize;
private Integer currentPage;
private String type;

private ListVolumesRequestBuilder() {
this.projectId = "";
Expand All @@ -103,6 +115,11 @@ public ListVolumesRequestBuilder currentPage(Integer currentPage) {
return this;
}

public ListVolumesRequestBuilder type(String type) {
this.type = type;
return this;
}

public ListVolumesRequest build() {
return new ListVolumesRequest(this);
}
Expand Down
Loading
Loading