本文整理匯總了Java中com.google.appengine.api.taskqueue.Queue.deleteTask方法的典型用法代碼示例。如果您正苦於以下問題:Java Queue.deleteTask方法的具體用法?Java Queue.deleteTask怎麽用?Java Queue.deleteTask使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.appengine.api.taskqueue.Queue
的用法示例。
在下文中一共展示了Queue.deleteTask方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: processTasks
import com.google.appengine.api.taskqueue.Queue; //導入方法依賴的package包/類
private static String processTasks(List<TaskHandle> tasks, Queue q) {
String payload;
int numberOfDeletedTasks = 0;
for (TaskHandle task : tasks) {
payload = new String(task.getPayload());
output = String.format("Processing: taskName='%s' payload='%s'", task.getName(), payload);
log.info(output);
output = String.format("Deleting taskName='%s'", task.getName());
log.info(output);
// [START delete_task]
q.deleteTask(task);
// [END delete_task]
numberOfDeletedTasks++;
}
if (numberOfDeletedTasks > 0) {
message = "Processed and deleted " + numberOfTasksToLease + " tasks from the "
+ " task queue.";
} else {
message = "Task Queue has no tasks available for lease.";
}
return message;
}
示例2: processTasks
import com.google.appengine.api.taskqueue.Queue; //導入方法依賴的package包/類
private static String processTasks(List<TaskHandle> tasks, Queue q) {
String payload;
int numberOfDeletedTasks = 0;
for (TaskHandle task : tasks) {
payload = new String(task.getPayload());
output =
String.format(
"Processing: taskName='%s' payload='%s'",
task.getName().toString(), payload.toString());
log.info(output.toString());
output = String.format("Deleting taskName='%s'", task.getName().toString());
log.info(output.toString());
// [START delete_task]
q.deleteTask(task);
// [END delete_task]
numberOfDeletedTasks++;
}
if (numberOfDeletedTasks > 0) {
message =
"Processed and deleted " + numberOfTasksToLease + " tasks from the " + " task queue.";
} else {
message = "Task Queue has no tasks available for lease.";
}
return message;
}
示例3: leaseAndDeleteTasks
import com.google.appengine.api.taskqueue.Queue; //導入方法依賴的package包/類
private void leaseAndDeleteTasks(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
int numTasks = Integer.parseInt(req.getParameter("numTasks"));
Double lease = Double.parseDouble(req.getParameter("lease"));
String queue = req.getParameter("queue");
Queue q = QueueFactory.getQueue(queue);
Boolean doDelete = Boolean.parseBoolean(req.getParameter("doDelete"));
List<TaskHandle> tasks = q.leaseTasks(lease.intValue() * 1000, TimeUnit.MILLISECONDS, numTasks);
for (TaskHandle task : tasks) {
if (doDelete) {
q.deleteTask(task.getName());
}
}
resp.getWriter().print(queue + "," + tasks.size());
}
示例4: testPullMultipleWithSameTag
import com.google.appengine.api.taskqueue.Queue; //導入方法依賴的package包/類
@Test
public void testPullMultipleWithSameTag() throws Exception {
final Queue queue = QueueFactory.getQueue("pull-queue");
TaskHandle th1 = queue.add(withMethod(PULL).tag("barfoo2").payload("foobar").etaMillis(15000));
TaskHandle th2 = queue.add(withMethod(PULL).tag("barfoo2").payload("foofoo").etaMillis(10000));
try {
List<TaskHandle> handles = waitOnFuture(queue.leaseTasksByTagAsync(30, TimeUnit.MINUTES, 100, "barfoo2"));
assertEquals(2, handles.size());
Set<String> expectedTasks = taskHandlesToNameSet(th1, th2);
Set<String> returnedTasks = taskHandleListToNameSet(handles);
assertEquals(expectedTasks, returnedTasks);
} finally {
queue.deleteTask(th1);
queue.deleteTask(th2);
}
}
示例5: testPullMultipleWithDiffTag
import com.google.appengine.api.taskqueue.Queue; //導入方法依賴的package包/類
@Test
public void testPullMultipleWithDiffTag() throws Exception {
final Queue queue = QueueFactory.getQueue("pull-queue");
TaskHandle th1 = queue.add(withMethod(PULL).tag("barfoo3").payload("foobar").etaMillis(15000));
TaskHandle th2 = queue.add(withMethod(PULL).tag("qwerty").payload("foofoo").etaMillis(10000));
TaskHandle th3 = queue.add(withMethod(PULL).tag("barfoo3").payload("foofoo").etaMillis(10000));
try {
List<TaskHandle> handles = waitOnFuture(queue.leaseTasksByTagAsync(30, TimeUnit.MINUTES, 100, "barfoo3"));
assertEquals(2, handles.size());
Set<String> expectedTasks = taskHandlesToNameSet(th1, th3);
Set<String> returnedTasks = taskHandleListToNameSet(handles);
assertEquals(expectedTasks, returnedTasks);
handles = queue.leaseTasksByTag(30, TimeUnit.MINUTES, 100, "qwerty");
assertEquals(1, handles.size());
Set<String> expectedTasks2 = taskHandlesToNameSet(th2);
Set<String> returnedTasks2 = taskHandleListToNameSet(handles);
assertEquals(expectedTasks2, returnedTasks2);
} finally {
queue.deleteTask(th1);
queue.deleteTask(th2);
queue.deleteTask(th3);
}
}
示例6: testBasics
import com.google.appengine.api.taskqueue.Queue; //導入方法依賴的package包/類
@Test
public void testBasics() throws Exception {
final Queue queue = QueueFactory.getQueue("pull-queue");
sync(2000L);
TaskHandle th = queue.add(TaskOptions.Builder.withMethod(TaskOptions.Method.PULL).param("foo", "bar".getBytes()));
try {
List<TaskHandle> handles = queue.leaseTasks(30, TimeUnit.MINUTES, 100);
Assert.assertFalse(handles.isEmpty());
Assert.assertEquals(1, handles.size());
TaskHandle lh = handles.get(0);
Assert.assertEquals(th.getName(), lh.getName());
sync(5000L);
} finally {
queue.deleteTask(th);
}
}
示例7: processLordnTasks
import com.google.appengine.api.taskqueue.Queue; //導入方法依賴的package包/類
private void processLordnTasks() throws IOException {
checkArgument(phase.equals(PARAM_LORDN_PHASE_SUNRISE)
|| phase.equals(PARAM_LORDN_PHASE_CLAIMS),
"Invalid phase specified to Nordn servlet: %s.", phase);
DateTime now = clock.nowUtc();
Queue queue = getQueue(
phase.equals(PARAM_LORDN_PHASE_SUNRISE) ? LordnTask.QUEUE_SUNRISE : LordnTask.QUEUE_CLAIMS);
String columns = phase.equals(PARAM_LORDN_PHASE_SUNRISE) ? COLUMNS_SUNRISE : COLUMNS_CLAIMS;
List<TaskHandle> tasks = LordnTask.loadAllTasks(queue, tld);
if (!tasks.isEmpty()) {
String csvData = convertTasksToCsv(tasks, now, columns);
uploadCsvToLordn(String.format("/LORDN/%s/%s", tld, phase), csvData);
queue.deleteTask(tasks);
}
}
示例8: deleteTask
import com.google.appengine.api.taskqueue.Queue; //導入方法依賴的package包/類
/**
* Delete the request task from the queue.
* @param req
* @return
*/
public static boolean deleteTask(HttpServletRequest req){
String queueName = req.getHeader(QUEUE_NAME);
String taskName = req.getHeader(TASK_NAME);
Queue queue = QueueFactory.getQueue(queueName);
return queue.deleteTask(taskName);
}
示例9: testPullParams
import com.google.appengine.api.taskqueue.Queue; //導入方法依賴的package包/類
@Test
public void testPullParams() throws Exception {
final Queue queue = QueueFactory.getQueue("pull-queue");
TaskHandle th = queue.add(withMethod(PULL).param("foo", "bar").etaMillis(15000));
try {
List<TaskHandle> handles = waitOnFuture(queue.leaseTasksAsync(30, TimeUnit.MINUTES, 100));
assertFalse(handles.isEmpty());
TaskHandle lh = handles.get(0);
assertEquals(th.getName(), lh.getName());
} finally {
queue.deleteTask(th);
}
}
示例10: testPullPayload
import com.google.appengine.api.taskqueue.Queue; //導入方法依賴的package包/類
@Test
public void testPullPayload() throws Exception {
final Queue queue = QueueFactory.getQueue("pull-queue");
TaskHandle th = queue.add(withMethod(PULL).payload("foobar").etaMillis(15000));
try {
List<TaskHandle> handles = waitOnFuture(queue.leaseTasksAsync(30, TimeUnit.MINUTES, 100));
assertFalse(handles.isEmpty());
TaskHandle lh = handles.get(0);
assertEquals(th.getName(), lh.getName());
} finally {
queue.deleteTask(th);
}
}
示例11: testPullWithTag
import com.google.appengine.api.taskqueue.Queue; //導入方法依賴的package包/類
@Test
public void testPullWithTag() throws Exception {
final Queue queue = QueueFactory.getQueue("pull-queue");
TaskHandle th = queue.add(withMethod(PULL).tag("barfoo1").etaMillis(15000));
try {
List<TaskHandle> handles = waitOnFuture(queue.leaseTasksByTagAsync(30, TimeUnit.MINUTES, 100, "barfoo1"));
assertFalse(handles.isEmpty());
TaskHandle lh = handles.get(0);
assertEquals(th.getName(), lh.getName());
} finally {
queue.deleteTask(th);
}
}
示例12: testPullWithGroupTag
import com.google.appengine.api.taskqueue.Queue; //導入方法依賴的package包/類
@Test
public void testPullWithGroupTag() throws Exception {
final Queue queue = QueueFactory.getQueue("pull-queue");
String tag = "testPullWithGroupTag" + "_" + System.currentTimeMillis();
long currentTime = System.currentTimeMillis();
TaskHandle th1 = queue.add(withMethod(PULL).tag(tag).payload("foobar").etaMillis(currentTime));
TaskHandle th2 = queue.add(withMethod(PULL).tag(tag + "qwerty").payload("foofoo").etaMillis(currentTime + 1000));
TaskHandle th3 = queue.add(withMethod(PULL).tag(tag).payload("foofoo").etaMillis(currentTime + 2000));
sync();
try {
LeaseOptions options = new LeaseOptions(LeaseOptions.Builder
.withLeasePeriod(1000L, TimeUnit.SECONDS))
.countLimit(100)
.groupByTag();
List<TaskHandle> handles = waitOnFuture(queue.leaseTasksAsync(options));
assertEquals(2, handles.size());
Set<String> expectedTasks = taskHandlesToNameSet(th1, th3);
Set<String> returnedTasks = taskHandleListToNameSet(handles);
assertEquals(expectedTasks, returnedTasks);
} finally {
queue.deleteTask(th1);
queue.deleteTask(th2);
queue.deleteTask(th3);
}
}
示例13: testLeaseTasksOnlyReturnsSpecifiedNumberOfTasks
import com.google.appengine.api.taskqueue.Queue; //導入方法依賴的package包/類
@Test
public void testLeaseTasksOnlyReturnsSpecifiedNumberOfTasks() {
Queue queue = QueueFactory.getQueue("pull-queue");
TaskHandle th1 = queue.add(withMethod(PULL));
TaskHandle th2 = queue.add(withMethod(PULL));
sync(2000);
try {
int countLimit = 1;
List<TaskHandle> handles = waitOnFuture(queue.leaseTasksAsync(10, TimeUnit.SECONDS, countLimit));
assertEquals(countLimit, handles.size());
} finally {
queue.deleteTask(th1);
queue.deleteTask(th2);
}
}
示例14: testPullParams
import com.google.appengine.api.taskqueue.Queue; //導入方法依賴的package包/類
@Test
public void testPullParams() throws Exception {
final Queue queue = QueueFactory.getQueue("pull-queue");
TaskHandle th = queue.add(withMethod(PULL).param("foo", "bar").etaMillis(15000));
sync();
try {
List<TaskHandle> handles = queue.leaseTasks(30, TimeUnit.MINUTES, 100);
assertFalse(handles.isEmpty());
TaskHandle lh = handles.get(0);
assertEquals(th.getName(), lh.getName());
} finally {
queue.deleteTask(th);
}
}
示例15: testPullPayload
import com.google.appengine.api.taskqueue.Queue; //導入方法依賴的package包/類
@Test
public void testPullPayload() throws Exception {
final Queue queue = QueueFactory.getQueue("pull-queue");
TaskHandle th = queue.add(withMethod(PULL).payload("foobar".getBytes()).etaMillis(15000));
sync();
try {
List<TaskHandle> handles = queue.leaseTasks(30, TimeUnit.MINUTES, 100);
assertFalse(handles.isEmpty());
TaskHandle lh = handles.get(0);
assertEquals(th.getName(), lh.getName());
} finally {
queue.deleteTask(th);
}
}