App Engine Java SDK version 1.7.0
[gae.git] / java / src / main / com / google / appengine / api / taskqueue / QueueConstants.java
blobaebc8c575bd87836aefa32e1419f6a1b073de467
1 // Copyright 2010 Google Inc. All rights reserved.
2 package com.google.appengine.api.taskqueue;
4 import java.util.concurrent.TimeUnit;
5 import java.util.regex.Pattern;
7 /**
8 * Describes various taskqueue limits.
11 public final class QueueConstants {
13 private static final int MAX_QUEUE_NAME_LENGTH = 100;
14 private static final int MAX_TASK_NAME_LENGTH = 500;
15 private static final int MAX_TASK_TAG_LENGTH = 500;
16 private static final int MAX_PUSH_TASK_SIZE_BYTES = 100 * (1 << 10);
17 private static final int MAX_PULL_TASK_SIZE_BYTES = (1 << 20);
18 private static final int MAX_TRANSACTIONAL_REQUEST_SIZE_BYTES = (1 << 20);
19 private static final int MAX_TASKS_PER_ADD = 100;
20 private static final int MAX_URL_LENGTH = 2083;
21 private static final long MAX_ETA_DELTA_MILLIS = 30L * 24 * 60 * 60 * 1000;
23 private static final long MAX_LEASE_MILLIS = 3600L * 24 * 7 * 1000;
24 private static final long MAX_TASKS_PER_LEASE = 1000;
26 private static final int MAX_TASKS_PER_DELETE = 1000;
28 /**
29 * Regular expression that matches all valid task names.
31 public static final String TASK_NAME_REGEX = "[a-zA-Z\\d_-]{1," + maxTaskNameLength() + "}";
32 public static final Pattern TASK_NAME_PATTERN = Pattern.compile(TASK_NAME_REGEX);
33 /**
34 * Regular expression that matches all valid queue names.
36 public static final String QUEUE_NAME_REGEX = "[a-zA-Z\\d-]{1," + maxQueueNameLength() + "}";
37 public static final Pattern QUEUE_NAME_PATTERN = Pattern.compile(QUEUE_NAME_REGEX);
39 /**
40 * Returns the maximum length of period to lease a task.
42 public static long maxLease(TimeUnit unit) {
43 return unit.convert(MAX_LEASE_MILLIS, TimeUnit.MILLISECONDS);
46 /**
47 * Returns the maximum number of tasks to lease in one call.
49 public static long maxLeaseCount() {
50 return MAX_TASKS_PER_LEASE;
53 /**
54 * Returns the maximum length of a queue name.
56 public static int maxQueueNameLength() {
57 return MAX_QUEUE_NAME_LENGTH;
60 /**
61 * Returns the maximum length of a task name.
63 public static int maxTaskNameLength() {
64 return MAX_TASK_NAME_LENGTH;
67 /**
68 * Returns the maximum length of a task tag.
70 public static int maxTaskTagLength() {
71 return MAX_TASK_TAG_LENGTH;
74 /**
75 * Returns the maximum push task size.
76 * @deprecated Use {@link #maxPushTaskSizeBytes()}
78 @Deprecated
79 public static int maxTaskSizeBytes() {
80 return maxPushTaskSizeBytes();
83 /**
84 * Returns the maximum push task size.
86 public static int maxPushTaskSizeBytes() {
87 return MAX_PUSH_TASK_SIZE_BYTES;
90 /**
91 * Returns the maximum pull task size.
93 public static int maxPullTaskSizeBytes() {
94 return MAX_PULL_TASK_SIZE_BYTES;
97 static int maxTransactionalRequestSizeBytes() {
98 return MAX_TRANSACTIONAL_REQUEST_SIZE_BYTES;
102 * Returns the maximum number of tasks that may be passed to a single add
103 * call.
105 public static int maxTasksPerAdd() {
106 return MAX_TASKS_PER_ADD;
110 * Returns the maximum URL length.
112 public static int maxUrlLength() {
113 return MAX_URL_LENGTH;
117 * Returns the maximum time into the future that a task may be scheduled.
119 public static long getMaxEtaDeltaMillis() {
120 return MAX_ETA_DELTA_MILLIS;
123 private QueueConstants() {