當前位置: 首頁>>代碼示例>>Java>>正文


Java Queue類代碼示例

本文整理匯總了Java中com.google.appengine.api.taskqueue.Queue的典型用法代碼示例。如果您正苦於以下問題:Java Queue類的具體用法?Java Queue怎麽用?Java Queue使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Queue類屬於com.google.appengine.api.taskqueue包,在下文中一共展示了Queue類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: scheduleNotificationBuild

import com.google.appengine.api.taskqueue.Queue; //導入依賴的package包/類
public static void scheduleNotificationBuild(String objectType, Long id,
		String action) {
	if (objectType == null || objectType.isEmpty()) {
		throw new IllegalArgumentException("No Specified Object Type");
	}

	if (id == null) {
		throw new IllegalArgumentException("No Specified Object Id");
	}

	if (action == null || action.isEmpty()) {
		throw new IllegalArgumentException("No Action Specified");
	}

	// Execute the servlet to pull from the queue
	Queue executionQueue = QueueFactory.getQueue("notification-building");
	executionQueue.add(TaskOptions.Builder
			.withUrl("/notifications/builder/").method(Method.GET)
			.param("objectType", objectType)
			.param("id", String.valueOf(id.longValue()))
			.param("action", action));

}
 
開發者ID:pschuette22,項目名稱:Zeppa-AppEngine,代碼行數:24,代碼來源:NotificationUtility.java

示例2: UserInviteService

import com.google.appengine.api.taskqueue.Queue; //導入依賴的package包/類
public UserInviteService(UserInviteLinkRepository userInviteLinkRepository,
                         LoginIdentifierService loginIdentifierService,
                         AppUserService userService,
                         Router router,
                         Queue queue,
                         Mailer mailer,
                         String host,
                         String mailerSenderEmail) {
    this.userInviteLinkRepository = userInviteLinkRepository;
    this.loginIdentifierService = loginIdentifierService;
    this.userService = userService;
    this.router = router;
    this.queue = queue;
    this.mailer = mailer;
    this.host = host;
    this.mailerSenderEmail = mailerSenderEmail;
}
 
開發者ID:3wks,項目名稱:generator-thundr-gae-react,代碼行數:18,代碼來源:UserInviteService.java

示例3: MagicLinkService

import com.google.appengine.api.taskqueue.Queue; //導入依賴的package包/類
public MagicLinkService(MagicLinkRepository magicLinkRepository,
    AppUserService userService,
    Router router,
    Queue queue,
    Mailer mailer,
    String host,
    String mailerSenderEmail,
    String magicLinkExpiryInMinutes) {
    this.magicLinkRepository = magicLinkRepository;
    this.userService = userService;
    this.router = router;
    this.queue = queue;
    this.mailer = mailer;
    this.host = host;
    this.mailerSenderEmail = mailerSenderEmail;
    setMagicNumberExpiry(magicLinkExpiryInMinutes);
}
 
開發者ID:3wks,項目名稱:generator-thundr-gae-react,代碼行數:18,代碼來源:MagicLinkService.java

示例4: configure

import com.google.appengine.api.taskqueue.Queue; //導入依賴的package包/類
@Override protected void configure() {
  StoreModuleHelper.makeBasicBindingsAndExposures(binder(), ConvStore.class);
  StoreModuleHelper.bindEntityKinds(binder(), ROOT_ENTITY_KIND);

  bind(SlobModel.class).to(WaveObjectStoreModel.class);
  bind(AccessChecker.class).to(ConvAccessChecker.class);
  bind(PermissionSource.class).to(ConvPermissionSource.class);

  Multibinder<PreCommitAction> preCommitActions =
      Multibinder.newSetBinder(binder(), PreCommitAction.class);
  preCommitActions.addBinding().to(IndexTask.ConvPreCommit.class);

  Multibinder<PostCommitAction> postCommitActions =
      Multibinder.newSetBinder(binder(), PostCommitAction.class);
  postCommitActions.addBinding().to(IndexTask.Conv.class);

  bind(Queue.class).annotatedWith(PostCommitActionQueue.class).toInstance(
      QueueFactory.getQueue("post-commit-conv"));
}
 
開發者ID:ArloJamesBarnes,項目名稱:walkaround,代碼行數:20,代碼來源:ConvStoreModule.java

示例5: PostCommitActionScheduler

import com.google.appengine.api.taskqueue.Queue; //導入依賴的package包/類
@Inject
public PostCommitActionScheduler(Set<PostCommitAction> actions,
    @PostCommitActionQueue Queue postCommitActionQueue,
    @PostCommitActionIntervalMillis int postCommitActionIntervalMillis,
    MemcacheTable.Factory memcacheFactory,
    @SlobRootEntityKind String rootEntityKind,
    @SlobSynchronizationEntityKind String syncEntityKind,
    @PostCommitTaskUrl String taskUrl,
    Random random,
    SlobStoreImpl.InternalPostCommitAction internalPostCommit,
    CheckedDatastore datastore) {
  this.actions = actions;
  this.postCommitActionQueue = postCommitActionQueue;
  this.postCommitActionIntervalMillis = postCommitActionIntervalMillis;
  this.postCommitActionPending = memcacheFactory.create(MEMCACHE_TAG_PREFIX + rootEntityKind);
  this.rootEntityKind = rootEntityKind;
  this.syncEntityKind = syncEntityKind;
  this.taskUrl = taskUrl;
  this.random = random;
  this.internalPostCommit = internalPostCommit;
  this.datastore = datastore;
}
 
開發者ID:ArloJamesBarnes,項目名稱:walkaround,代碼行數:23,代碼來源:PostCommitActionScheduler.java

示例6: doGet

import com.google.appengine.api.taskqueue.Queue; //導入依賴的package包/類
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) {
    Enumeration e = req.getHeaderNames();
    while(e.hasMoreElements()) {
        String param = (String)e.nextElement();
        log.info("header:" + param + req.getHeader(param));
    }

    String cronHeader = req.getHeader("X-Appengine-Cron");
    if(cronHeader == null || !cronHeader.trim().equals("true")) {
        resp.setStatus(403);
        return;
    }

    Queue queue = QueueFactory.getQueue("reaper");
    queue.add(TaskOptions.Builder.withUrl("/reaper"));

}
 
開發者ID:saucenet,項目名稱:sync,代碼行數:19,代碼來源:ReaperCronServlet.java

示例7: loadAllTasks

import com.google.appengine.api.taskqueue.Queue; //導入依賴的package包/類
/** Leases and returns all tasks from the queue with the specified tag tld, in batches. */
public static List<TaskHandle> loadAllTasks(Queue queue, String tld) {
  ImmutableList.Builder<TaskHandle> allTasks = new ImmutableList.Builder<>();
  int numErrors = 0;
  long backOff = backOffMillis;
  while (true) {
    try {
      List<TaskHandle> tasks = queue.leaseTasks(LeaseOptions.Builder
          .withTag(tld)
          .leasePeriod(LEASE_PERIOD.getMillis(), TimeUnit.MILLISECONDS)
          .countLimit(BATCH_SIZE));
      allTasks.addAll(tasks);
      if (tasks.isEmpty()) {
        return allTasks.build();
      }
    } catch (TransientFailureException | DeadlineExceededException e) {
      if (++numErrors >= 3) {
        throw new RuntimeException("Error leasing tasks", e);
      }
      Uninterruptibles.sleepUninterruptibly(backOff, TimeUnit.MILLISECONDS);
      backOff *= 2;
    }
  }
}
 
開發者ID:google,項目名稱:nomulus,代碼行數:25,代碼來源:LordnTask.java

示例8: deleteTasksWithRetry

import com.google.appengine.api.taskqueue.Queue; //導入依賴的package包/類
/** Deletes a list of tasks from the given queue using a retrier. */
private static void deleteTasksWithRetry(
    final List<DnsRefreshRequest> refreshRequests,
    final Queue queue,
    AsyncFlowMetrics asyncFlowMetrics,
    Retrier retrier,
    OperationResult result) {
  if (refreshRequests.isEmpty()) {
    return;
  }
  final List<TaskHandle> tasks =
      refreshRequests.stream().map(DnsRefreshRequest::task).collect(toImmutableList());
  retrier.callWithRetry(() -> queue.deleteTask(tasks), TransientFailureException.class);
  refreshRequests.forEach(
      r -> asyncFlowMetrics.recordAsyncFlowResult(DNS_REFRESH, result, r.requestedTime()));
}
 
開發者ID:google,項目名稱:nomulus,代碼行數:17,代碼來源:RefreshDnsOnHostRenameAction.java

示例9: 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;
}
 
開發者ID:GoogleCloudPlatform,項目名稱:java-docs-samples,代碼行數:23,代碼來源:TaskqueueServlet.java

示例10: 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;
}
 
開發者ID:GoogleCloudPlatform,項目名稱:java-docs-samples,代碼行數:26,代碼來源:TaskqueueServlet.java

示例11: queueToIndex

import com.google.appengine.api.taskqueue.Queue; //導入依賴的package包/類
/**
 * @param name
 * @param id
 */
public static void queueToIndex (String name, Long id) {
	Queue queue = QueueFactory.getDefaultQueue();

	TaskOptions options = TaskOptions.Builder.withMethod(Method.POST)
			.url(INDEX_SEARCH_URL).param(ENTITY_NAME_KEY, name)
			.param(ENTITY_ID_KEY, id.toString());

	int retry = RETRY_COUNT;
	do {
		try {
			queue.add(options);

			// success no need to retry
			retry = 0;
		} catch (TransientFailureException ex) {
			retry--;
		}
	} while (retry > 0);
}
 
開發者ID:billy1380,項目名稱:blogwt,代碼行數:24,代碼來源:SearchHelper.java

示例12: reset

import com.google.appengine.api.taskqueue.Queue; //導入依賴的package包/類
/**
 * Reset reservations in datastore to match those in RTDB. Reservations in RTDB are used
 * as the source of truth, corresponding reservations in datastore are updated to match
 * those in RTDB. Reservations in RTDB that do not exist in datastore are added to datastore.
 * Reservations that exist in datastore and do not exist in RTDB are updated in datastore
 * with status DELETED.
 *
 * Use of this endpoint should be followed by a user data sync.
 *
 * @param user User making request (injected by Endpoints)
 */
@ApiMethod(name = "reset", path = "reset")
public void reset(User user)
    throws UnauthorizedException {
  if (user == null) {
    throw new UnauthorizedException("Invalid credentials");
  }

  // Add Sync Reservations worker to queue.
  Queue queue = QueueFactory.getQueue("SyncReservationsQueue");

  TaskOptions taskOptions = TaskOptions.Builder
      .withUrl("/queue/syncres")
      .method(Method.GET);
  queue.add(taskOptions);
}
 
開發者ID:google,項目名稱:iosched,代碼行數:27,代碼來源:ReservationsEndpoint.java

示例13: enqueueTask

import com.google.appengine.api.taskqueue.Queue; //導入依賴的package包/類
@Override
public void enqueueTask(String taskName, Map<String, String[]> paramMap) {

  checkNotNull(taskName);

  final Queue queue = QueueFactory.getDefaultQueue();
  final TaskOptions options = TaskOptions.Builder.withUrl(String.format(PATH_ADMIN_TASK, taskName));

  for (Map.Entry<String, String[]> param : paramMap.entrySet()) {
    for (String value : param.getValue()) {
      options.param(param.getKey(), value);
    }
  }

  try {
    queue.add(options);
    LOGGER.info("Added admin task to queue {}", taskName);
  } catch (TransientFailureException tfe) {
    LOGGER.error("Run admin task fail {} ", tfe.getMessage());
  }

}
 
開發者ID:Wadpam,項目名稱:guja,代碼行數:23,代碼來源:GAEAdminTaskQueue.java

示例14: doGet

import com.google.appengine.api.taskqueue.Queue; //導入依賴的package包/類
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
  String channelKey = getChannelKey();
  String filterText = req.getParameter("filterText");
  filterText = (filterText == null) ? "" : filterText;
  String tag = req.getParameter("tag");
  String requestId = req.getParameter("reqId");
  String userId = userService.getCurrentUser().getUserId();

  Queue queue = QueueFactory.getDefaultQueue();
  TaskOptions taskOptions = withUrl("/fetch")
      .param("displayStyle", req.getParameter("displayStyle"))
      .param("filterText", filterText)
      .param("key", channelKey)
      .param("networkCode", req.getParameter("networkCode"))
      .param("userId", userId)
      .param("tag", tag)
      .param("reqId", requestId)
      .param("typeOverride", req.getParameter("typeOverride"));

  queue.add(taskOptions.method(Method.GET));
  resp.getWriter().print(channelKey);
}
 
開發者ID:googleads,項目名稱:googleads-dfp-java-dfp-playground,代碼行數:24,代碼來源:TaskDispatchServlet.java

示例15: addToQueue

import com.google.appengine.api.taskqueue.Queue; //導入依賴的package包/類
List<TaskHandle> addToQueue(final Collection<Task> tasks) {
  List<TaskHandle> handles = new ArrayList<>();
  Map<String, List<TaskOptions>> queueNameToTaskOptions = new HashMap<>();
  for (Task task : tasks) {
    logger.finest("Enqueueing: " + task);
    String queueName = task.getQueueSettings().getOnQueue();
    TaskOptions taskOptions = toTaskOptions(task);
    List<TaskOptions> taskOptionsList = queueNameToTaskOptions.get(queueName);
    if (taskOptionsList == null) {
      taskOptionsList = new ArrayList<>();
      queueNameToTaskOptions.put(queueName, taskOptionsList);
    }
    taskOptionsList.add(taskOptions);
  }
  for (Map.Entry<String, List<TaskOptions>> entry : queueNameToTaskOptions.entrySet()) {
    Queue queue = getQueue(entry.getKey());
    handles.addAll(addToQueue(queue, entry.getValue()));
  }
  return handles;
}
 
開發者ID:GoogleCloudPlatform,項目名稱:appengine-pipelines,代碼行數:21,代碼來源:AppEngineTaskQueue.java


注:本文中的com.google.appengine.api.taskqueue.Queue類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。