GetSmartCluster (OSS Java SDK V2)
Call GetSmartCluster with the OSS Java SDK V2 to retrieve details of a SmartCluster task.
Prerequisites
The OSS Java SDK V2 is installed. To use Maven, add the
com.aliyun:alibabacloud-oss-v2dependency to the pom.xml file.Configure your access credentials as environment variables. The example uses the
EnvironmentVariableCredentialsProviderto read credentials from theOSS_ACCESS_KEY_IDandOSS_ACCESS_KEY_SECRETenvironment variables.
Permissions
By default, an Alibaba Cloud account can access all resources. RAM users and RAM roles have no permissions by default. You must grant them permissions to call API operations.
API | Action | Description |
GetSmartCluster |
| Retrieves a SmartCluster task. |
Sample code
import com.aliyun.sdk.service.oss2.credentials.CredentialsProvider;
import com.aliyun.sdk.service.oss2.credentials.EnvironmentVariableCredentialsProvider;
import com.aliyun.sdk.service.oss2.dataprocess.OSSDataProcessClient;
import com.aliyun.sdk.service.oss2.dataprocess.OSSDataProcessClientBuilder;
import com.aliyun.sdk.service.oss2.dataprocess.models.*;
public class GetSmartClusterSample {
public static void main(String[] args) throws Exception {
String endpoint = null;
String region = "cn-hangzhou";
String bucket = "examplebucket";
String datasetName = "exampledataset";
String objectId = "exampleclusterid";
CredentialsProvider provider = new EnvironmentVariableCredentialsProvider();
OSSDataProcessClientBuilder clientBuilder = OSSDataProcessClient.newBuilder()
.credentialsProvider(provider)
.region(region);
if (endpoint != null) {
clientBuilder.endpoint(endpoint);
}
try (OSSDataProcessClient client = clientBuilder.build()) {
GetSmartClusterResult result = client.getSmartCluster(
GetSmartClusterRequest.newBuilder()
.bucket(bucket)
.datasetName(datasetName)
.objectId(objectId)
.build());
System.out.printf("Status code:%d, request id:%s%n",
result.statusCode(), result.requestId());
if (result.smartCluster() != null) {
SmartClusterInfo info = result.smartCluster();
System.out.printf("Object ID:%s%n", info.objectId());
System.out.printf("Name:%s%n", info.name());
System.out.printf("Cluster type:%s%n", info.clusterType());
System.out.printf("Description:%s%n", info.description());
System.out.printf("Create time:%s%n", info.createTime());
System.out.printf("Update time:%s%n", info.updateTime());
if (info.reason() != null) {
System.out.printf("Reason:%s%n", info.reason());
}
if (info.rules() != null) {
System.out.printf("Rules count:%d%n", info.rules().size());
}
}
} catch (Exception e) {
System.out.printf("error:%n%s", e);
}
}
}Related documentation
See GetSmartCluster.java for the synchronous sample code.
See GetSmartClusterAsync.java for the asynchronous sample code.