指派任務優先順序 - Amazon Simple Storage Service

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

指派任務優先順序

您可以為每個任務指定數值優先順序,可以是任何正整數。S3 批次作業會根據指定的優先順序,排列任務的優先順序。優先順序較高的任務 (或優先順序參數較高的數值) 會先進行評估。優先順序會依遞減順序決定。例如,優先順序值為 10 的任務佇列的排程優先順序會高於優先順序值為 1 的任務佇列。

您可以在任務執行時變更任務的優先順序。如果您在任務執行時提交較高優先順序的新任務,則系統會暫停較低優先順序的任務,以允許優先順序較高之任務的執行。

變更任務優先順序不會影響任務處理速度。

注意

S3 批次作業會盡力遵循任務優先順序。雖然優先順序較高的任務一般會優先於優先順序較低的任務,但 Amazon S3 不保證任務的嚴格排序。

如何在AWS Management Console中更新任務優先順序
  1. 登入 AWS Management Console,並開啟位於 https://console.aws.amazon.com/s3/ 的 Amazon S3 主控台。

  2. 在左側導覽窗格中,選擇 Batch Operations (批次操作)。

  3. 選擇您要管理的特定任務。

  4. 選擇 Action (動作)。在下拉式清單中選擇 Update priority (更新優先順序)。

下列範例會使用 AWS CLI 更新任務優先順序。數字越高表示執行優先順序越高。

aws s3control update-job-priority \ --region us-west-2 \ --account-id acct-id \ --priority 98 \ --job-id 00e123a4-c0d8-41f4-a0eb-b46f9ba5b07c

下列範例使用 AWS SDK for Java 更新 S3 批次操作任務的優先順序。

如需任務優先順序的詳細資訊,請參閱 指派任務優先順序

package aws.example.s3control; import com.amazonaws.AmazonServiceException; import com.amazonaws.SdkClientException; import com.amazonaws.auth.profile.ProfileCredentialsProvider; import com.amazonaws.services.s3control.AWSS3Control; import com.amazonaws.services.s3control.AWSS3ControlClient; import com.amazonaws.services.s3control.model.UpdateJobPriorityRequest; import static com.amazonaws.regions.Regions.US_WEST_2; public class UpdateJobPriority { public static void main(String[] args) { String accountId = "Account ID"; String jobId = "00e123a4-c0d8-41f4-a0eb-b46f9ba5b07c"; try { AWSS3Control s3ControlClient = AWSS3ControlClient.builder() .withCredentials(new ProfileCredentialsProvider()) .withRegion(US_WEST_2) .build(); s3ControlClient.updateJobPriority(new UpdateJobPriorityRequest() .withAccountId(accountId) .withJobId(jobId) .withPriority(98)); } catch (AmazonServiceException e) { // The call was transmitted successfully, but Amazon S3 couldn't process // it and returned an error response. e.printStackTrace(); } catch (SdkClientException e) { // Amazon S3 couldn't be contacted for a response, or the client // couldn't parse the response from Amazon S3. e.printStackTrace(); } } }