本文整理了Java中com.twitter.util.Future.get()
方法的一些代码示例,展示了Future.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Future.get()
方法的具体详情如下:
包路径:com.twitter.util.Future
类名称:Future
方法名:get
暂无
代码示例来源:origin: pinterest/pinlater
private void createQueue(PinLater.ServiceIface iface) {
Preconditions.checkNotNull(queueName, "Queue was not specified.");
iface.createQueue(REQUEST_CONTEXT, queueName).get();
LOG.info("Created queue: " + queueName);
}
代码示例来源:origin: pinterest/pinlater
private void getQueueNames(PinLater.ServiceIface iface) {
Set<String> queueNames = iface.getQueueNames(REQUEST_CONTEXT).get();
LOG.info("Queues: " + queueNames);
}
代码示例来源:origin: com.twitter/finagle-memcached_2.9.2
public static void testClient(Client client) {
client.delete("foo").get();
client.set("foo", "bar").get();
assert(client.get("foo").get().toString(Charset.defaultCharset()) == "bar");
ResultWithCAS res = client.gets("foo").get();
assert(client.cas("foo", "baz", res.casUnique).get());
assert(client.get("foo").get().toString(Charset.defaultCharset()) == "baz");
client.delete("foo").get();
System.err.println("passed.");
client.release();
}
}
代码示例来源:origin: pinterest/pinlater
private void lookupJobs(PinLater.ServiceIface iface) {
Preconditions.checkNotNull(queueName, "Queue was not specified.");
Preconditions.checkArgument(
!jobDescriptor.isEmpty(), "No job descriptor specified to lookup");
PinLaterLookupJobRequest lookupJobRequest = new PinLaterLookupJobRequest();
lookupJobRequest.setIncludeBody(true);
lookupJobRequest.addToJobDescriptors(jobDescriptor);
LOG.info("Job: " + iface.lookupJobs(REQUEST_CONTEXT, lookupJobRequest).get());
}
代码示例来源:origin: pinterest/pinlater
private void checkDequeue(PinLater.ServiceIface iface) {
Preconditions.checkNotNull(queueName, "Queue was not specified.");
PinLaterDequeueRequest getOneJobRequest = new PinLaterDequeueRequest(queueName, 1);
getOneJobRequest.setDryRun(true);
boolean jobsAvailable =
iface.dequeueJobs(REQUEST_CONTEXT, getOneJobRequest).get().getJobsSize() != 0;
LOG.info("Jobs available for dequeue: " + jobsAvailable);
}
代码示例来源:origin: com.twitter.common/net-http-handlers-pprof
@Override
protected final void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
final int profileDurationSecs = HttpServletRequestParams.getInt(req, "seconds", 10);
final int profilePollRate = HttpServletRequestParams.getInt(req, "hz", 100);
LOG.info("Collecting CPU profile for " + profileDurationSecs + " seconds at "
+ profilePollRate + " Hz");
Duration sampleDuration = Duration.fromTimeUnit(profileDurationSecs, TimeUnit.SECONDS);
CpuProfile profile =
CpuProfile.recordInThread(sampleDuration, profilePollRate, stateToProfile).get();
resp.setHeader("Content-Type", "pprof/raw");
resp.setStatus(HttpServletResponse.SC_OK);
OutputStream responseBody = resp.getOutputStream();
try {
profile.writeGoogleProfile(responseBody);
} finally {
Closeables.close(responseBody, /* swallowIOException */ true);
}
}
}
代码示例来源:origin: pinterest/pinlater
private void getJobCount(PinLater.ServiceIface iface) {
Preconditions.checkNotNull(queueName, "Queue was not specified.");
Preconditions.checkNotNull(
PinLaterJobState.findByValue(jobState), "Invalid job state specified.");
PinLaterGetJobCountRequest getJobCountRequest = new PinLaterGetJobCountRequest();
getJobCountRequest.setQueueName(queueName);
getJobCountRequest.setJobState(PinLaterJobState.findByValue(jobState));
if (cmdLine.hasOption("priority")) {
getJobCountRequest.setPriority(priority);
}
getJobCountRequest.setCountFutureJobs(countFutureJobs);
LOG.info("# jobs: " + iface.getJobCount(REQUEST_CONTEXT, getJobCountRequest).get());
}
代码示例来源:origin: eirslett/thrift-zookeeper
Foo foo = client.giveMeSomeFoo(i).get();
System.out.println("Got "+foo.getBazz());
内容来源于网络,如有侵权,请联系作者删除!