恢复批量加载任务 - Amazon Timestream
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

从2025年6月20日起,亚马逊Timestream版 LiveAnalytics 将不再向新客户开放。如果您想使用亚马逊 Timestream LiveAnalytics,请在该日期之前注册。现有客户可以继续照常使用该服务。有关更多信息,请参阅 Amazon Timestream 以了解 LiveAnalytics 可用性变更。

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

恢复批量加载任务

您可以使用以下代码片段来恢复批量加载任务。

Java
public void resumeBatchLoadTask(String taskId) { try { amazonTimestreamWrite .resumeBatchLoadTask(ResumeBatchLoadTaskRequest.builder() .taskId(taskId) .build()); System.out.println("Successfully resumed batch load task."); } catch (ValidationException validationException) { System.out.println(validationException.getMessage()); } }
Go
package main import ( "fmt" "context" "log" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/service/timestreamwrite" ) func main() { customResolver := aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (aws.Endpoint, error) { if service == timestreamwrite.ServiceID && region == "us-west-2" { return aws.Endpoint{ PartitionID: "aws", URL: <URL>, SigningRegion: "us-west-2", }, nil } return aws.Endpoint{}, &aws.EndpointNotFoundError{} }) cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithEndpointResolverWithOptions(customResolver), config.WithRegion("us-west-2")) if err != nil { log.Fatalf("failed to load configuration, %v", err) } client := timestreamwrite.NewFromConfig(cfg) response, err := client.ResumeBatchLoadTask(context.TODO(), &timestreamwrite.ResumeBatchLoadTaskInput{ TaskId: aws.String("TaskId"), }) if err != nil { fmt.Println("Error:") fmt.Println(err) } else { fmt.Println("Resume batch load task is successful") fmt.Println(response) } }
Python
import boto3 from botocore.config import Config INGEST_ENDPOINT="<url>" REGION="us-west-2" HT_TTL_HOURS = 24 CT_TTL_DAYS = 7 TASK_ID = "<TaskId>" def resume_batch_load_task(client, task_id): try: result = client.resume_batch_load_task(TaskId=task_id) print("Successfully resumed batch load task: ", result) except Exception as err: print("Resume batch load task failed:", err) if __name__ == '__main__': session = boto3.Session() write_client = session.client('timestream-write', \ endpoint_url=INGEST_ENDPOINT, region_name=REGION, \ config=Config(read_timeout=20, max_pool_connections = 5000, retries={'max_attempts': 10})) resume_batch_load_task(write_client, TASK_ID)
Node.js

以下代码段使用 Amazon 适用于 JavaScript v3 的 SDK。有关如何安装客户端和用法的更多信息,请参阅 Timestream Write Client- Amazon 适用于 JavaScript v3 的 SDK

有关 API 的详细信息,请参阅类 CreateBatchLoadCommandCreateBatchLoadTask

import { TimestreamWriteClient, ResumeBatchLoadTaskCommand } from "@aws-sdk/client-timestream-write"; const writeClient = new TimestreamWriteClient({ region: "<region>", endpoint: "<endpoint>" }); const params = { TaskId: "<TaskId>" }; const command = new ResumeBatchLoadTaskCommand(params); try { const data = await writeClient.send(command); console.log("Resumed batch load task"); } catch (error) { console.log("Resume batch load task failed.", error); throw error; }
.NET
using System; using System.IO; using System.Collections.Generic; using Amazon.TimestreamWrite; using Amazon.TimestreamWrite.Model; using System.Threading.Tasks; namespace TimestreamDotNetSample { public class ResumeBatchLoadTaskExample { private readonly AmazonTimestreamWriteClient writeClient; public ResumeBatchLoadTaskExample(AmazonTimestreamWriteClient writeClient) { this.writeClient = writeClient; } public async Task ResumeBatchLoadTask(String taskId) { try { var resumeBatchLoadTaskRequest = new ResumeBatchLoadTaskRequest { TaskId = taskId }; ResumeBatchLoadTaskResponse response = await writeClient.ResumeBatchLoadTaskAsync(resumeBatchLoadTaskRequest); Console.WriteLine("Successfully resumed batch load task."); } catch (ResourceNotFoundException) { Console.WriteLine("Batch load task does not exist."); } catch (Exception e) { Console.WriteLine("Resume batch load task failed: " + e.ToString()); } } } }