本文整理汇总了Java中com.google.appengine.api.taskqueue.TaskOptions.Method类的典型用法代码示例。如果您正苦于以下问题:Java Method类的具体用法?Java Method怎么用?Java Method使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Method类属于com.google.appengine.api.taskqueue.TaskOptions包,在下文中一共展示了Method类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scheduleNotificationBuild
import com.google.appengine.api.taskqueue.TaskOptions.Method; //导入依赖的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));
}
示例2: enqueueDomainResourceTask
import com.google.appengine.api.taskqueue.TaskOptions.Method; //导入依赖的package包/类
/**
* Enqueues a task in the LORDN queue representing a line of CSV for LORDN export.
*/
public static void enqueueDomainResourceTask(DomainResource domain) {
ofy().assertInTransaction();
// This method needs to use ofy transactionTime as the DomainResource's creationTime because
// CreationTime isn't yet populated when this method is called during the resource flow.
String tld = domain.getTld();
if (domain.getLaunchNotice() == null) {
getQueue(QUEUE_SUNRISE).add(TaskOptions.Builder
.withTag(tld)
.method(Method.PULL)
.payload(getCsvLineForSunriseDomain(domain, ofy().getTransactionTime())));
} else {
getQueue(QUEUE_CLAIMS).add(TaskOptions.Builder
.withTag(tld)
.method(Method.PULL)
.payload(getCsvLineForClaimsDomain(domain, ofy().getTransactionTime())));
}
}
示例3: enqueueAsyncDelete
import com.google.appengine.api.taskqueue.TaskOptions.Method; //导入依赖的package包/类
/** Enqueues a task to asynchronously delete a contact or host, by key. */
public void enqueueAsyncDelete(
EppResource resourceToDelete,
DateTime now,
String requestingClientId,
Trid trid,
boolean isSuperuser) {
Key<EppResource> resourceKey = Key.create(resourceToDelete);
logger.infofmt(
"Enqueuing async deletion of %s on behalf of registrar %s.",
resourceKey, requestingClientId);
TaskOptions task =
TaskOptions.Builder.withMethod(Method.PULL)
.countdownMillis(asyncDeleteDelay.getMillis())
.param(PARAM_RESOURCE_KEY, resourceKey.getString())
.param(PARAM_REQUESTING_CLIENT_ID, requestingClientId)
.param(PARAM_CLIENT_TRANSACTION_ID, trid.getClientTransactionId())
.param(PARAM_SERVER_TRANSACTION_ID, trid.getServerTransactionId())
.param(PARAM_IS_SUPERUSER, Boolean.toString(isSuperuser))
.param(PARAM_REQUESTED_TIME, now.toString());
addTaskToQueueWithRetry(asyncDeletePullQueue, task);
}
示例4: makeTaskOptions
import com.google.appengine.api.taskqueue.TaskOptions.Method; //导入依赖的package包/类
/**
* Generates the TaskOptions needed to trigger an AppEngine Datastore backup job.
*
* @see <a href="https://developers.google.com/appengine/articles/scheduled_backups">Scheduled Backups</a>
*/
private static TaskOptions makeTaskOptions(
String queue, String name, String gcsBucket, ImmutableSet<String> kinds) {
String hostname = modulesService.getVersionHostname("default", DATASTORE_ADMIN_VERSION_NAME);
TaskOptions options = TaskOptions.Builder.withUrl("/_ah/datastore_admin/backup.create")
.header("Host", hostname)
.method(Method.GET)
.param("name", name + "_") // Add underscore since the name will be used as a prefix.
.param("filesystem", "gs")
.param("gs_bucket_name", gcsBucket)
.param("queue", queue);
for (String kind : kinds) {
options.param("kind", kind);
}
return options;
}
示例5: testSuccess_enqueuePollTask_withChainedTask
import com.google.appengine.api.taskqueue.TaskOptions.Method; //导入依赖的package包/类
@Test
public void testSuccess_enqueuePollTask_withChainedTask() throws Exception {
TaskOptions chainedTask = TaskOptions.Builder
.withUrl("/_dr/something")
.method(Method.POST)
.header("X-Testing", "foo")
.param("testing", "bar");
new BigqueryPollJobEnqueuer(ENQUEUER).enqueuePollTask(
new JobReference().setProjectId(PROJECT_ID).setJobId(JOB_ID),
chainedTask,
getQueue(CHAINED_QUEUE_NAME));
assertTasksEnqueued(BigqueryPollJobAction.QUEUE, newPollJobTaskMatcher("POST"));
TaskStateInfo taskInfo = getOnlyElement(
TaskQueueHelper.getQueueInfo(BigqueryPollJobAction.QUEUE).getTaskInfo());
ByteArrayInputStream taskBodyBytes = new ByteArrayInputStream(taskInfo.getBodyAsBytes());
TaskOptions taskOptions = (TaskOptions) new ObjectInputStream(taskBodyBytes).readObject();
assertThat(taskOptions).isEqualTo(chainedTask);
}
示例6: queueToIndex
import com.google.appengine.api.taskqueue.TaskOptions.Method; //导入依赖的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);
}
示例7: reset
import com.google.appengine.api.taskqueue.TaskOptions.Method; //导入依赖的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);
}
示例8: doGet
import com.google.appengine.api.taskqueue.TaskOptions.Method; //导入依赖的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);
}
示例9: watchFolderChanges
import com.google.appengine.api.taskqueue.TaskOptions.Method; //导入依赖的package包/类
public Channel watchFolderChanges(Drive driveService, Project project) throws IOException {
Channel channel = new Channel();
channel.setId(java.util.UUID.randomUUID().toString());
channel.setToken(project.getKey());
channel.setType("web_hook");
channel.setAddress(API.getBaseUrl()+"/webhook/receiveFolderChanges");
long expirationMillis = 86400000; // 1day
channel.setExpiration( (new Date()).getTime() + expirationMillis);
// task for renewing watch channel
Queue queue = QueueFactory.getDefaultQueue();
TaskOptions task = TaskOptions.Builder
.withUrl(AppHelper.getTaskBaseUrl()+"/watchFolderChanges")
.countdownMillis(expirationMillis)
.param("project", project.getKey())
.param("user", project.getOwner().getKey().getString())
.method(Method.POST)
;
queue.add(task);
return driveService.files().watch(project.getFolder(),channel).execute();
}
示例10: spoonPollEndTask
import com.google.appengine.api.taskqueue.TaskOptions.Method; //导入依赖的package包/类
private void spoonPollEndTask(Meeting meeting) {
String taskName = "pollEnd_"+meeting.getKey();
this.removePollEndTask(meeting);
if (meeting.getPoll().getEndDate() != null && !meeting.getPoll().isEnded()) {
Queue queue = QueueFactory.getDefaultQueue();
TaskOptions task = TaskOptions.Builder
.withUrl(AppHelper.getTaskBaseUrl()+"/pollEnd")
.etaMillis(meeting.getPoll().getEndDate().getTime())
.param("meeting", meeting.getKey())
.method(Method.POST)
.taskName(taskName)
;
queue.add(task);
}
}
示例11: createBackupTaskOptions
import com.google.appengine.api.taskqueue.TaskOptions.Method; //导入依赖的package包/类
private TaskOptions createBackupTaskOptions(String backupName, List<String> kindsToExport, String bucketName, String queueName) {
TaskOptions t = TaskOptions.Builder.withUrl("/_ah/datastore_admin/backup.create");
t.param("name", backupName);
for (String kind : kindsToExport) {
t.param("kind", kind);
}
t.param("filesystem", "gs");
t.param("gs_bucket_name", bucketName);
t.param("queue", queueName);
t.method(Method.GET);
t.header("Host", BackendServiceFactory.getBackendService().getBackendAddress(AH_BUILTIN_PYTHON_BUNDLE));
return t;
}
示例12: enqueueAsyncDnsRefresh
import com.google.appengine.api.taskqueue.TaskOptions.Method; //导入依赖的package包/类
/** Enqueues a task to asynchronously refresh DNS for a renamed host. */
public void enqueueAsyncDnsRefresh(HostResource host, DateTime now) {
Key<HostResource> hostKey = Key.create(host);
logger.infofmt("Enqueuing async DNS refresh for renamed host %s.", hostKey);
addTaskToQueueWithRetry(
asyncDnsRefreshPullQueue,
TaskOptions.Builder.withMethod(Method.PULL)
.param(PARAM_HOST_KEY, hostKey.getString())
.param(PARAM_REQUESTED_TIME, now.toString()));
}
示例13: addToQueue
import com.google.appengine.api.taskqueue.TaskOptions.Method; //导入依赖的package包/类
/**
* Enqueues the given task type with the given target name to the DNS queue.
*/
private TaskHandle addToQueue(TargetType targetType, String targetName, String tld) {
logger.infofmt(
"Adding task type=%s, target=%s, tld=%s to pull queue %s (%d tasks currently on queue)",
targetType, targetName, tld, DNS_PULL_QUEUE_NAME, queue.fetchStatistics().getNumTasks());
return queue.add(TaskOptions.Builder
.withDefaults()
.method(Method.PULL)
.param(DNS_TARGET_TYPE_PARAM, targetType.toString())
.param(DNS_TARGET_NAME_PARAM, targetName)
.param(PARAM_TLD, tld));
}
示例14: enqueuePollTask
import com.google.appengine.api.taskqueue.TaskOptions.Method; //导入依赖的package包/类
/**
* Enqueue a task to poll for the success or failure of the referenced BigQuery job and to
* launch the provided task in the specified queue if the job succeeds.
*/
public TaskHandle enqueuePollTask(
JobReference jobRef, TaskOptions chainedTask, Queue chainedTaskQueue) throws IOException {
// Serialize the chainedTask into a byte array to put in the task payload.
ByteArrayOutputStream taskBytes = new ByteArrayOutputStream();
new ObjectOutputStream(taskBytes).writeObject(chainedTask);
return enqueuer.enqueue(
getQueue(QUEUE),
createCommonPollTask(jobRef)
.method(Method.POST)
.header(CHAINED_TASK_QUEUE_HEADER, chainedTaskQueue.getQueueName())
.payload(taskBytes.toByteArray()));
}
示例15: createViewUpdateTask
import com.google.appengine.api.taskqueue.TaskOptions.Method; //导入依赖的package包/类
/** Create a task for updating a snapshot view. */
static TaskOptions createViewUpdateTask(String datasetId, String tableId, String kindName) {
return TaskOptions.Builder.withUrl(PATH)
.method(Method.POST)
.param(UPDATE_SNAPSHOT_DATASET_ID_PARAM, datasetId)
.param(UPDATE_SNAPSHOT_TABLE_ID_PARAM, tableId)
.param(UPDATE_SNAPSHOT_KIND_PARAM, kindName);
}