本文整理汇总了Java中com.twitter.util.TimeoutException类的典型用法代码示例。如果您正苦于以下问题:Java TimeoutException类的具体用法?Java TimeoutException怎么用?Java TimeoutException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TimeoutException类属于com.twitter.util包,在下文中一共展示了TimeoutException类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createLog
import com.twitter.util.TimeoutException; //导入依赖的package包/类
public static void createLog(Settings settings, String indexName, String indexUUID, int shardId, String localNodeId) throws IOException {
int retryNum = 0;
while (true) {
try {
String tmpLogName = getLogName(indexName, indexUUID, shardId);
DistributedLogNamespace logNamespace = DLNamespace.getNamespace(settings, localNodeId);
boolean isLogExist = logNamespace.logExists(tmpLogName);
if (!isLogExist) {
logNamespace.createLog(tmpLogName);
continue;
}
return;
} catch (Throwable t) {
++ retryNum;
if ((t instanceof TimeoutException || t.getCause() instanceof TimeoutException) && retryNum <= 5) {
continue;
} else {
throw t;
}
}
}
}
示例2: unlock
import com.twitter.util.TimeoutException; //导入依赖的package包/类
@Override
public void unlock() {
Future<BoxedUnit> unlockResult = asyncUnlock();
try {
Await.result(unlockResult, Duration.fromMilliseconds(lockOpTimeout));
} catch (TimeoutException toe) {
// This shouldn't happen unless we lose a watch, and may result in a leaked lock.
LOG.error("Timeout unlocking {} owned by {} : ", new Object[] { lockPath, lockId, toe });
} catch (Exception e) {
LOG.warn("{} failed to unlock {} : ", new Object[] { lockId, lockPath, e });
}
}
示例3: testLockStreamSameSubscriber
import com.twitter.util.TimeoutException; //导入依赖的package包/类
@Test(timeout = 60000)
public void testLockStreamSameSubscriber() throws Exception {
String streamName = runtime.getMethodName();
BKDistributedLogManager bkdlm = createNewDLM(conf, streamName);
DLMTestUtil.generateLogSegmentNonPartitioned(bkdlm, 0, 5, 1);
BKLogReadHandler readHandler = bkdlm.createReadHandler();
Await.result(readHandler.lockStream());
// same subscrbiers couldn't lock stream in parallel
BKDistributedLogManager bkdlm10 = createNewDLM(conf, streamName);
BKLogReadHandler s10Handler =
bkdlm10.createReadHandler(Optional.of("s1"));
Await.result(s10Handler.lockStream());
BKDistributedLogManager bkdlm11 = createNewDLM(conf, streamName);
BKLogReadHandler s11Handler =
bkdlm11.createReadHandler(Optional.of("s1"));
try {
Await.result(s11Handler.lockStream(), Duration.apply(10000, TimeUnit.MILLISECONDS));
fail("Should fail lock stream using same subscriber id");
} catch (OwnershipAcquireFailedException oafe) {
// expected
} catch (TimeoutException te) {
// expected.
}
readHandler.asyncClose();
bkdlm.close();
s10Handler.asyncClose();
bkdlm10.close();
s11Handler.asyncClose();
bkdlm11.close();
}
示例4: main
import com.twitter.util.TimeoutException; //导入依赖的package包/类
public static void main(String[] args) throws TimeoutException, InterruptedException {
HelloService.FutureIface impl = new HelloImpl();
ListeningServer server = Thrift.server().serveIface("localhost:9097", impl);
Await.ready(server);
}