Restart a data pipeline (Java SDK V2)

更新时间:
复制 MD 格式

Calls RestartDataPipeline through OSS Java SDK V2 to restart a data pipeline (DataPipeline) rule that is in the Paused state.

Prerequisites

  • OSS Java SDK V2 is installed. If you use Maven, add the com.aliyun:alibabacloud-oss-v2 dependency to your pom.xml.

  • Access credentials are configured by using environment variables. The example in this topic uses EnvironmentVariableCredentialsProvider to read credentials from the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables.

  • DataPipeline operations are forwarded by OSS to the underlying workflow service. Make sure that the source standard bucket and the destination vector bucket are located in the same region.

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.models.*;

public class RestartDataPipelineSample {
    public static void main(String[] args) throws Exception {
        CredentialsProvider provider = new EnvironmentVariableCredentialsProvider();
        try (OSSDataProcessClient client = OSSDataProcessClient.newBuilder()
                .region("cn-hangzhou")
                .credentialsProvider(provider)
                .build()) {

            RestartDataPipelineResult result = client.restartDataPipeline(
                    RestartDataPipelineRequest.newBuilder()
                            .dataPipelineName("my-data-pipeline")
                            .build());

            System.out.printf("Status code:%d, request id:%s%n",
                    result.statusCode(), result.requestId());

        } catch (Exception e) {
            System.out.printf("error:%n%s", e);
        }
    }
}

References