Use the Java SDK to manage data shipping jobs
Data shipping delivers data collected by Simple Log Service (SLS) to other Alibaba Cloud services for storage or consumption. You can manage data shipping jobs by using the SLS Java SDK.
The SLS SDK no longer receives updates for data shipping operations. We recommend that you use the Alibaba Cloud SDK to perform OSS data shipping operations.
On the CreateOSSExport API page in the Alibaba Cloud OpenAPI Portal, click the SDK Sample tab. In the language drop-down list, select Java to view the Java SDK sample code. You can click Debug to run the code or click Download Project to download the complete SDK project.
Prerequisites
Simple Log Service is activated.
Simple Log Service SDK for Python is initialized.
Simple Log Service SDK for Java is installed. For more information, see Install the Java SDK.
A project and a Standard logstore are created, and logs are collected. For more information, see Manage projects, Create a basic Logstore, and Data collection.
-
Obtain the MaxCompute endpoint for your region. For more information, see VPC Endpoint.
You must configure the MaxCompute endpoint when you create or update a MaxCompute data shipping job.
Precautions
In this example, the public Simple Log Service endpoint for the China (Hangzhou) region is used. Endpoint: https://cn-hangzhou.log.aliyuncs.com.
If you want to access Simple Log Service from other Alibaba Cloud services that reside in the same region as your project, you can use the internal Simple Log Service endpoint, which is https://cn-hangzhou-intranet.log.aliyuncs.com.
For more information about the supported regions and endpoints of Simple Log Service, see Endpoint.
Sample code
Query OSS or MaxCompute data shipping jobs
The following sample code in QuerySinkDemo.java queries the configurations of a data shipping job in a specific project.
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.openservices.log.Client;
import com.aliyun.openservices.log.common.*;
import com.aliyun.openservices.log.exception.LogException;
import com.aliyun.openservices.log.request.*;
import com.aliyun.openservices.log.response.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class QuerySinkDemo {
// The endpoint of Simple Log Service. This example uses the endpoint of the China (Hangzhou) region. Replace the value with the actual endpoint.
private static final String endpoint = "http://cn-hangzhou.log.aliyuncs.com";
// This example obtains the AccessKey ID and AccessKey Secret from environment variables.
private static final String accessKeyId = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
private static final String accessKeySecret = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
// The name of the project. Replace this with your actual project name.
private static final String project = "ali-test-project";
// The name of the data shipping job. You can view the job name in the job's basic information.
private static final String jobName = "ali-test-job";
// Create a Simple Log Service client.
private static final Client client = new Client(endpoint, accessKeyId, accessKeySecret);
private static String getSinkExportJob() throws LogException {
GetJobResponse getJobResponse = client.getJob(new GetJobRequest(project, jobName));
Job job = getJobResponse.getJob();
return JSONObject.toJSONString(job);
}
private static List<Export> listSinkExportJob() throws LogException {
ListExportResponse listExportResponse = client.listExport(new ListExportRequest(project));
return listExportResponse.getResults();
}
private static List<String> getOdpsSinkExportJob() throws LogException {
List<String> odpsSinkList = new ArrayList<>();
List<Export> listExports = listSinkExportJob();
for (Export job:listExports) {
DataSink type = job.getConfiguration().getSink();
Map<String, Object> map = JSONObject.parseObject(JSONArray.toJSONString(type));
Object sinkType = map.get("type");
if (sinkType.equals("AliyunODPS")) {
odpsSinkList.add(JSONArray.toJSONString(job));
}
}
return odpsSinkList;
}
private static List<String> getOssSinkExportJob() throws LogException {
List<String> ossSinkList = new ArrayList<>();
List<Export> listExports = listSinkExportJob();
for (Export job:listExports) {
DataSink type = job.getConfiguration().getSink();
Map<String, Object> map = JSONObject.parseObject(JSONArray.toJSONString(type));
Object sinkType = map.get("type");
if (sinkType.equals("AliyunOSS")) {
ossSinkList.add(JSONArray.toJSONString(job));
}
}
return ossSinkList;
}
public static void main(String[] args) throws LogException {
// View the specified data shipping job.
String jobConfig = getSinkExportJob();
System.out.println("**********View the configuration of the specified data shipping job**********");
System.out.println(jobConfig);
// View all data shipping jobs.
listSinkExportJob();
// View all MaxCompute data shipping jobs.
List<String> odpsSinkList = getOdpsSinkExportJob();
System.out.println("**********View the configurations of all MaxCompute data shipping jobs**********");
System.out.println(odpsSinkList);
// View all OSS data shipping jobs.
List<String> ossSinkList = getOssSinkExportJob();
System.out.println("**********View the configurations of all OSS data shipping jobs**********");
System.out.println(ossSinkList);
}
}
The following result is expected:
**********View the configuration of the specified data shipping job**********
{
"configuration": {
......
"fromTime": 1,
"instanceType": "Standard",
"logstore": "ali-test-logstore",
......
"state": "Enabled",
"status": "RUNNING",
"type": "Export"
}
**********View the configurations of all MaxCompute data shipping jobs**********
[{
"configuration": {
......
"status": "RUNNING",
"type": "Export"
}, {
"configuration": {
......
"state": "Enabled",
"status": "STOPPED",
"type": "Export"
}]
**********View the configurations of all OSS data shipping jobs**********
[{
"configuration": {
......
"fromTime": 0,
"instanceType": "Standard",
"logstore": "ali-test-logstore",
......
"state": "Enabled",
"status": "RUNNING",
"type": "Export"
}]
Create an OSS data shipping job
The following sample code in CreateOssSinkDemo.java creates an OSS data shipping job.
package demo;
import com.aliyun.openservices.log.Client;
import com.aliyun.openservices.log.common.*;
import com.aliyun.openservices.log.exception.LogException;
import com.aliyun.openservices.log.request.*;
public class CreateOssSinkDemo {
// The endpoint of Simple Log Service. This example uses the endpoint of the China (Hangzhou) region. Replace the value with the actual endpoint.
private static final String endpoint = "http://cn-hangzhou.log.aliyuncs.com";
// This example obtains the AccessKey ID and AccessKey Secret from environment variables.
private static final String accessKeyId = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
private static final String accessKeySecret = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
// The name of the project. Replace the value with your actual project name. You can obtain the project name from an existing project.
private static final String project = "ali-test-project";
// The name of the logstore. Replace the value with the name of a logstore in your project.
private static final String logStore = "ali-test-logstore";
// The RAM role ARN. Replace the value with the ARN of your RAM role. You can obtain the ARN from the RAM console.
private static final String roleArn = "acs:ram::111111";
// The name of the OSS bucket. Replace the value with the name of an existing OSS bucket.
private static final String bucket = "yourBucketName";
// The name of the job.
private static final String jobName = "ali-test-job-name";
// The display name of the data shipping job.
private static final String displayName = "ali-test-job-displayname";
// The description of the job.
private static final String description = "This is a OSS Shipper task.";
// The destination directory in the OSS bucket.
private static final String preffix = "test";
// The suffix of files in the OSS bucket.
private static final String suffix = "11111";
// The partition format for the OSS bucket. A directory is dynamically generated in the OSS bucket based on the shipping time.
private static final String pathFormat = "%Y/%m/%d/%H/%M";
// The buffer size for each shard. This value controls the size of an OSS object (uncompressed). Unit: MB.
private static final int bufferSize = 255;
// The buffer interval for each shard. Unit: seconds. Valid values: 300 to 900.
private static final int bufferInterval = 300;
// The format of files to be shipped to an OSS bucket. Valid values: csv, json, parquet, and orc.
private static final String contentType = "json";
// The start time for data shipping. A value of 1 indicates that shipping starts from the earliest historical data. You can also specify a different start time.
private static final int fromtime = 1;
// The end time for data shipping. A value of 0 indicates that data is continuously shipped. You can also specify an end time.
private static final int totime = 0;
private static void createOssExportJob(Client client) throws LogException {
Export export = new Export();
export.setName(jobName);
export.setDisplayName(displayName);
export.setDescription(description);
ExportConfiguration exportConfiguration = new ExportConfiguration();
AliyunOSSSink ossSink = new AliyunOSSSink();
ossSink.setRoleArn(roleArn);
ossSink.setBucket(bucket);
ossSink.setPrefix(preffix);
ossSink.setSuffix(suffix);
ossSink.setPathFormat(pathFormat);
ossSink.setBufferSize(bufferSize);
ossSink.setBufferInterval(bufferInterval);
ossSink.setContentType(contentType);
ExportContentJsonDetail jsonDetail = new ExportContentJsonDetail();
jsonDetail.setEnableTag(true);
ossSink.setContentDetail(jsonDetail);
exportConfiguration.setLogstore(logStore);
exportConfiguration.setRoleArn(roleArn);
exportConfiguration.setSink(ossSink);
exportConfiguration.setFromTime(fromtime);
exportConfiguration.setToTime(totime);
exportConfiguration.setVersion("v2.0");
export.setConfiguration(exportConfiguration);
client.createExport(new CreateExportRequest(project, export));
}
public static void main(String[] args) throws LogException {
Client client = new Client(endpoint, accessKeyId, accessKeySecret);
createOssExportJob(client);
}
}
Update an OSS data shipping job
The following sample code in UpdateOssSinkDemo.java updates an OSS data shipping job and restarts the job for the changes to take effect.
package demo;
import com.aliyun.openservices.log.Client;
import com.aliyun.openservices.log.common.*;
import com.aliyun.openservices.log.exception.LogException;
import com.aliyun.openservices.log.request.*;
import java.util.ArrayList;
public class UpdateOssSinkDemo {
// The endpoint of Simple Log Service. This example uses the endpoint of the China (Hangzhou) region. Replace the value with the actual endpoint.
private static final String endpoint = "http://cn-hangzhou.log.aliyuncs.com";
// This example obtains the AccessKey ID and AccessKey Secret from environment variables.
private static final String accessKeyId = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
private static final String accessKeySecret = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
// The name of the project. Replace the value with your actual project name. You can obtain the project name from an existing project.
private static final String project = "ali-test-project";
// The name of the logstore. Replace the value with the name of a logstore in your project.
private static final String logStore = "ali-test-logstore";
// The RAM role ARN. Replace the value with the ARN of your RAM role. You can obtain the ARN from the RAM console.
private static final String roleArn = "acs:ram::111111";
// The name of the OSS bucket. Replace the value with the name of an existing OSS bucket.
private static final String bucket = "yourBucketName";
// The name of the job that you want to modify.
private static final String jobName = "ali-test-job-name";
// The display name of the job.
private static final String displayName = "ali-test-job-displayname";
// The description of the job.
private static final String description = "This is a OSS Shipper task.";
// The destination directory in the OSS bucket.
private static final String preffix = "test";
// The suffix of files in the OSS bucket.
private static final String suffix = "11111";
// The partition format for the OSS bucket. A directory is dynamically generated in the OSS bucket based on the shipping time.
private static final String pathFormat = "%Y/%m/%d/%H/%M";
// The buffer size for each shard. This value controls the size of an OSS object (uncompressed). Unit: MB.
private static final int bufferSize = 255;
// The buffer interval for each shard. Unit: seconds. Valid values: 300 to 900.
private static final int bufferInterval = 300;
// The format of files to be shipped to an OSS bucket. Valid values: csv, json, parquet, and orc.
private static final String contentType = "csv";
// The start time for data shipping. A value of 1 indicates that shipping starts from the earliest historical data. You can also specify a different start time.
private static final int fromtime = 1;
// The end time for data shipping. A value of 0 indicates that data is continuously shipped. You can also specify an end time.
private static final int totime = 0;
private static final ArrayList<String> columns = new ArrayList<>();
private static void updateWithRestartOssSinkJob(Client client) throws LogException {
Export export = new Export();
export.setName(jobName);
export.setDisplayName(displayName);
export.setDescription(description);
ExportConfiguration exportConfiguration = new ExportConfiguration();
AliyunOSSSink ossSink = new AliyunOSSSink();
ossSink.setRoleArn(roleArn);
ossSink.setBucket(bucket);
ossSink.setPrefix(preffix);
ossSink.setSuffix(suffix);
ossSink.setPathFormat(pathFormat);
ossSink.setBufferSize(bufferSize);
ossSink.setBufferInterval(bufferInterval);
ossSink.setContentType(contentType);
ExportContentCsvDetail csvDetail = new ExportContentCsvDetail();
csvDetail.setNullIdentifier("");
csvDetail.setStorageColumns(columns);
ossSink.setContentDetail(csvDetail);
exportConfiguration.setLogstore(logStore);
exportConfiguration.setRoleArn(roleArn);
exportConfiguration.setSink(ossSink);
exportConfiguration.setFromTime(fromtime);
exportConfiguration.setToTime(totime);
exportConfiguration.setVersion("v2.0");
export.setConfiguration(exportConfiguration);
client.restartExport(new RestartExportRequest(project,export));
}
public static void main(String[] args) throws LogException {
Client client = new Client(endpoint, accessKeyId, accessKeySecret);
// Customize CSV columns.
columns.add("bucket");
columns.add("__topic__");
updateWithRestartOssSinkJob(client);
}
}
Create a MaxCompute data shipping job
The following sample code in CreateOdpsSinkDemo.java creates a MaxCompute data shipping job.
package demo;
import com.aliyun.openservices.log.Client;
import com.aliyun.openservices.log.common.*;
import com.aliyun.openservices.log.exception.LogException;
import com.aliyun.openservices.log.request.CreateExportRequest;
public class CreateOdpsSinkDemo {
// The endpoint of Simple Log Service. This example uses the endpoint of the China (Hangzhou) region. Replace the value with the actual endpoint.
private static final String endpoint = "http://cn-hangzhou.log.aliyuncs.com";
// This example obtains the AccessKey ID and AccessKey Secret from environment variables.
private static final String accessKeyId = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
private static final String accessKeySecret = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
// The RAM role ARN. Replace the value with the ARN of your RAM role. You can obtain the ARN from the RAM console.
private static final String roleArn = "acs:ram::111111";
// The name of the project. Replace the value with your actual project name. You can obtain the project name from an existing project.
private static final String projectName = "ali-test-project";
// The name of the logstore. Replace the value with the name of an existing logstore.
private static final String logstore = "ali-test-logstore";
// The display name of the data shipping job.
private static final String displayName = "ali-test-displayname";
// The name of the data shipping job.
private static final String jobName = "ali-test-yname";
// The description of the data shipping job.
private static final String description = "This is a MaxCompute Shipper task.";
// The start time for data shipping. A value of 1 indicates that shipping starts from the earliest historical data. You can also specify a different start time.
private static final int fromtime = 1;
// The end time for data shipping. A value of 0 indicates that data is continuously shipped. You can also specify an end time.
private static final int totime = 0;
// The shipping type. AliyunODPS indicates that data is shipped to MaxCompute.
private static final String type = "AliyunODPS";
// The name of the MaxCompute project. Replace the value with your actual project name. You can obtain the project name from the MaxCompute console.
private static final String odpsProject = "yourodpsProjectName";
// The name of the MaxCompute table. Replace the value with the name of an existing table. You can obtain the table name from the MaxCompute console.
private static final String odpsTable = "yourodpsTabletName";
// This example uses the endpoint of the China (Hangzhou) region. Replace the value with the actual endpoint. You can also find the MaxCompute endpoint on the MaxCompute data shipping configuration page in the Simple Log Service console or in the MaxCompute Help Center.
private static final String odpsEndpoint = "http://service.cn-hangzhou.maxcompute.aliyun-inc.com/api";
private static final String odpsTunnelEndpoint = "http://dt.cn-hangzhou.maxcompute.aliyun-inc.com";
// The format for time-based partitions.
private static final String partitionTimeFormat = "%Y_%m_%d_%H_%M";
private static final String timeZone = "+0800";
// Specifies whether to filter invalid fields.
private static final Boolean filterInvalid = true;
// The RAM role ARN. Replace the value with the ARN of your RAM role. You can obtain the ARN from the RAM console.
private static final String odpsRolearn = "acs:ram::111111";
// The names of log fields in Simple Log Service.
private static final String[] fields = {"11111","22222","33333"};
// The names of partition columns.
private static final String[] partitionColumn = {"__partition_time__"};
// The shipping mode. Valid values: stream and interval.
// stream: reads data from the logstore and ships it to MaxCompute in real time. interval: reads data generated 5 to 10 minutes earlier than the current time from the logstore and ships it to MaxCompute in batches.
private static final String mode = "stream";
private static void creatOdpsSinkJob(Client client) throws LogException {
Export export = new Export();
export.setDisplayName(displayName);
export.setDescription(description);
export.setName(jobName);
ExportConfiguration configuration = new ExportConfiguration();
configuration.setLogstore(logstore);
configuration.setVersion("v2.0");
configuration.setAccessKeyId(accessKeyId);
configuration.setAccessKeySecret(accessKeySecret);
configuration.setRoleArn(roleArn);
configuration.setFromTime(fromtime);
configuration.setToTime(totime);
ExportGeneralSink sink = new ExportGeneralSink();
sink.put("type", type);
sink.put("odpsProject", odpsProject);
sink.put("odpsTable", odpsTable);
sink.put("odpsEndpoint", odpsEndpoint);
sink.put("odpsTunnelEndpoint", odpsTunnelEndpoint);
sink.put("partitionTimeFormat", partitionTimeFormat);
sink.put("timeZone", timeZone);
sink.put("filterInvalid", filterInvalid);
sink.put("odpsRolearn", odpsRolearn);
sink.put("fields", fields);
sink.put("partitionColumn", partitionColumn);
sink.put("mode", mode);
configuration.setSink(sink);
export.setConfiguration(configuration);
JobSchedule jobSchedule = new JobSchedule();
jobSchedule.setType(JobScheduleType.RESIDENT);
export.setSchedule(jobSchedule);
CreateExportRequest createExportRequest = new CreateExportRequest(projectName, export);
client.createExport(createExportRequest);
}
public static void main(String[] args) throws LogException {
Client client = new Client(endpoint, accessKeyId, accessKeySecret);
creatOdpsSinkJob(client);
}
}
Update a MaxCompute data shipping job
The following sample code in UpdateOdpsSinkDemo.java updates a MaxCompute data shipping job and restarts the job for the changes to take effect.
package demo;
import com.aliyun.openservices.log.Client;
import com.aliyun.openservices.log.common.*;
import com.aliyun.openservices.log.exception.LogException;
import com.aliyun.openservices.log.request.RestartExportRequest;
public class UpdateOdpsSinkDemo {
// The endpoint of Simple Log Service. This example uses the endpoint of the China (Hangzhou) region. Replace the value with the actual endpoint.
private static final String endpoint = "http://cn-hangzhou.log.aliyuncs.com";
// This example obtains the AccessKey ID and AccessKey Secret from environment variables.
private static final String accessKeyId = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
private static final String accessKeySecret = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
// The RAM role ARN. Replace the value with the ARN of your RAM role. You can obtain the ARN from the RAM console.
private static final String roleArn = "acs:ram::111111";
// The name of the project. Replace the value with your actual project name. You can obtain the project name from an existing project.
private static final String projectName = "ali-test-project";
// The name of the logstore. Replace the value with the name of an existing logstore.
private static final String logstore = "ali-test-logstore";
// The display name of the data shipping job.
private static final String displayName = "ali-test-displayname";
// The name of the data shipping job.
private static final String jobName = "ali-test-job-name";
// The description of the data shipping job.
private static final String description = "This is a MaxCompute Shipper task.";
// The start time for data shipping. A value of 1 indicates that shipping starts from the earliest historical data. You can also specify a different start time.
private static final int fromtime = 1;
// The end time for data shipping. A value of 0 indicates that data is continuously shipped. You can also specify an end time.
private static final int totime = 0;
// The shipping type. AliyunODPS indicates that data is shipped to MaxCompute.
private static final String type = "AliyunODPS";
// The name of the MaxCompute project. Replace the value with your actual project name. You can obtain the project name from the MaxCompute console.
private static final String odpsProject = "yourodpsProjectName";
// The name of the MaxCompute table. Replace the value with the name of an existing table. You can obtain the table name from the MaxCompute console.
private static final String odpsTable = "yourodpsTableName";
// This example uses the endpoint of the China (Hangzhou) region. Replace the value with the actual endpoint. You can also find the MaxCompute endpoint on the MaxCompute data shipping configuration page in the Simple Log Service console.
private static final String odpsEndpoint = "http://service.cn-hangzhou.maxcompute.aliyun-inc.com/api";
private static final String odpsTunnelEndpoint = "http://dt.cn-hangzhou.maxcompute.aliyun-inc.com";
// The format for time-based partitions.
private static final String partitionTimeFormat = "%Y_%m_%d_%H_%M";
private static final String timeZone = "+0800";
// Specifies whether to filter invalid fields.
private static final Boolean filterInvalid = true;
// The RAM role ARN. Replace the value with the ARN of your RAM role. You can obtain the ARN from the RAM console.
private static final String odpsRolearn = "acs:ram::11111";
// The names of log fields in Simple Log Service.
private static final String[] fields = {"11111","22222","33333"};
// The names of partition columns.
private static final String[] partitionColumn = {"__partition_time__"};
// The shipping mode. Valid values: stream and interval.
// stream: reads data from the logstore and ships it to MaxCompute in real time. interval: reads data generated 5 to 10 minutes earlier than the current time from the logstore and ships it to MaxCompute in batches.
private static final String mode = "stream";
private static void updateWithRestartOdpsSinkJob(Client client) throws LogException {
Export export = new Export();
export.setDisplayName(displayName);
export.setDescription(description);
export.setName(jobName);
ExportConfiguration configuration = new ExportConfiguration();
configuration.setLogstore(logstore);
configuration.setVersion("v2.0");
configuration.setAccessKeyId(accessKeyId);
configuration.setAccessKeySecret(accessKeySecret);
configuration.setRoleArn(roleArn);
configuration.setFromTime(fromtime);
configuration.setToTime(totime);
ExportGeneralSink sink = new ExportGeneralSink();
sink.put("type", type);
sink.put("odpsProject", odpsProject);
sink.put("odpsTable", odpsTable);
sink.put("odpsEndpoint", odpsEndpoint);
sink.put("odpsTunnelEndpoint", odpsTunnelEndpoint);
sink.put("partitionTimeFormat", partitionTimeFormat);
sink.put("timeZone", timeZone);
sink.put("filterInvalid", filterInvalid);
sink.put("odpsRolearn", odpsRolearn);
sink.put("fields", fields);
sink.put("partitionColumn", partitionColumn);
sink.put("mode", mode);
configuration.setSink(sink);
export.setConfiguration(configuration);
JobSchedule jobSchedule = new JobSchedule();
jobSchedule.setType(JobScheduleType.RESIDENT);
export.setSchedule(jobSchedule);
RestartExportRequest restartExportRequest = new RestartExportRequest(projectName, export);
client.restartExport(restartExportRequest);
}
public static void main(String[] args) throws LogException {
Client client = new Client(endpoint, accessKeyId, accessKeySecret);
updateWithRestartOdpsSinkJob(client);
}
}
Delete an OSS or MaxCompute data shipping job
The following sample code in DeleteSinkDemo.java deletes an OSS or MaxCompute data shipping job.
package demo;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.openservices.log.Client;
import com.aliyun.openservices.log.exception.LogException;
import com.aliyun.openservices.log.request.*;
import com.aliyun.openservices.log.response.*;
public class DeleteSinkDemo {
// The endpoint of Simple Log Service. This example uses the endpoint of the China (Hangzhou) region. Replace the value with the actual endpoint.
private static final String endpoint = "http://cn-hangzhou.log.aliyuncs.com";
// This example obtains the AccessKey ID and AccessKey Secret from environment variables.
private static final String accessKeyId = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
private static final String accessKeySecret = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
// The name of the project. Replace the value with your actual project name. You can obtain the project name from an existing project.
private static final String project = "ali-test-project";
// The name of the data shipping job to delete.
private static final String jobName = "ali-test-job-name";
private static void deleteSinkExportJob(Client client) throws LogException {
DeleteExportResponse deleteExportResponse = client.deleteExport(new DeleteExportRequest(project, jobName));
System.out.println(JSONObject.toJSONString(deleteExportResponse));
}
public static void main(String[] args) throws LogException {
Client client = new Client(endpoint, accessKeyId, accessKeySecret);
deleteSinkExportJob(client);
}
}
References
In addition to its native SDK, SLS also supports the common Alibaba Cloud SDKs. For more information, see Log Service_SDKcenter-Alibaba CloudOpenAPIDeveloper Portal.
-
You can also use the console to create data shipping jobs, and view and manage them. For more information, see Create a data shipping job, Manage OSS data shipping jobs (New Version), and Manage MaxCompute data shipping jobs (New Version).