如何通过Java SDK描述Partition

18 阅读1分钟

本文介绍如何通过Java SDK获取Collection中一个已存在的Partition的状态。

前提条件

接口定义

Java

// class DashVectorCollection

public Response<Status> describePartition(String name);

使用示例

**说明

  1. 需要使用您的api-key替换示例中的YOUR_API_KEY、您的Cluster Endpoint替换示例中的YOUR_CLUSTER_ENDPOINT,代码才能正常运行。
  2. 本示例需要参考新建Collection提前创建好名称为quickstart的Collection。
  3. 本示例需要参考新建Partition提前创建好名称为shoes的Partition。

Java

import com.aliyun.dashvector.DashVectorClient;
import com.aliyun.dashvector.DashVectorCollection;
import com.aliyun.dashvector.common.DashVectorException;
import com.aliyun.dashvector.models.responses.Response;

public class Main {
    public static void main(String[] args) throws DashVectorException {
      	DashVectorClient client = new DashVectorClient("YOUR_API_KEY", "YOUR_CLUSTER_ENDPOINT");
      	DashVectorCollection collection = client.get("quickstart");
      	
      	// 描述Partition
        Response<Status> response = collection.describePartition("shoes");

        System.out.println(response);
        // example output:
        // {"code":0,"message":"","requestId":"f554cde8-6147-42b5-b794-8cb9c0ae57da","output":"SERVING"}
    }
}

入参描述

参数类型必填默认值描述
nameString-Partition名称