本文整理汇总了Java中com.facebook.thrift.TException类的典型用法代码示例。如果您正苦于以下问题:Java TException类的具体用法?Java TException怎么用?Java TException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TException类属于com.facebook.thrift包,在下文中一共展示了TException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: investigateAndPossiblyRethrowException
import com.facebook.thrift.TException; //导入依赖的package包/类
/**
* Logic that decides how to proceed after a failed Thrift RPC. If it appears to be a stale
* connection, this method will not throw as a signal to retry the RPC. Otherwise, it rethrows the
* exception that was passed in.
*/
private void investigateAndPossiblyRethrowException(TException originalException)
throws TException {
// Because we got a TException when making a Thrift call, we will dereference the current Thrift
// client such that getConnectedClient() will create a new one the next time it is called.
thriftClient = null;
Throwable e = originalException;
while (e != null && !(e instanceof LastErrorException)) {
e = e.getCause();
}
if (e != null) {
// e is a LastErrorException, so it's likely that it was a "Broken pipe" exception, which
// happens when the Eden server decides the Thrift client has been idle for too long and
// closes the connection.
LOG.info(e, "Suspected closed Thrift connection: will create a new one.");
} else {
throw originalException;
}
}
开发者ID:facebook,项目名称:buck,代码行数:26,代码来源:ReconnectingEdenClient.java
示例2: computeSha1ForOrdinaryFileUnderMount
import com.facebook.thrift.TException; //导入依赖的package包/类
@Test
public void computeSha1ForOrdinaryFileUnderMount() throws IOException, EdenError, TException {
FileSystem fs = Jimfs.newFileSystem(Configuration.unix());
Path root = fs.getPath(JIMFS_WORKING_DIRECTORY);
ProjectFilesystemDelegate delegate = new DefaultProjectFilesystemDelegate(root);
EdenMount mount = createMock(EdenMount.class);
Path path = fs.getPath("foo/bar");
expect(mount.getBindMounts()).andReturn(ImmutableList.of());
expect(mount.getPathRelativeToProjectRoot(root.resolve(path))).andReturn(Optional.of(path));
expect(mount.getSha1(path)).andReturn(DUMMY_SHA1);
replay(mount);
EdenProjectFilesystemDelegate edenDelegate = new EdenProjectFilesystemDelegate(mount, delegate);
assertEquals(DUMMY_SHA1, edenDelegate.computeSha1(path));
verify(mount);
}
开发者ID:facebook,项目名称:buck,代码行数:19,代码来源:EdenProjectFilesystemDelegateTest.java
示例3: run
import com.facebook.thrift.TException; //导入依赖的package包/类
@Override
public int run(EdenClientPool pool) throws EdenError, IOException, TException {
EdenClient client = pool.getClient();
List<MountInfo> mountInfos = client.listMounts();
System.out.printf("Number of mounts: %d\n", mountInfos.size());
for (MountInfo info : mountInfos) {
System.out.println(info.mountPoint);
EdenMount mount =
EdenMount.createEdenMountForProjectRoot(Paths.get(info.mountPoint), pool).get();
List<Path> bindMounts = mount.getBindMounts();
System.out.printf(" Number of bind mounts: %d\n", bindMounts.size());
for (Path bindMount : bindMounts) {
System.out.printf(" %s\n", bindMount);
}
}
return 0;
}
开发者ID:facebook,项目名称:buck,代码行数:19,代码来源:MountsCommand.java
示例4: getSha1DelegatesToThriftClient
import com.facebook.thrift.TException; //导入依赖的package包/类
@Test
public void getSha1DelegatesToThriftClient() throws EdenError, IOException, TException {
final EdenClient thriftClient = createMock(EdenClient.class);
FileSystem fs = Jimfs.newFileSystem(Configuration.unix());
Path entry = fs.getPath("LICENSE");
HashCode hash = HashCode.fromString("2b8b815229aa8a61e483fb4ba0588b8b6c491890");
SHA1Result sha1Result = new SHA1Result();
sha1Result.setSha1(hash.asBytes());
expect(thriftClient.getSHA1("/home/mbolin/src/buck", ImmutableList.of("LICENSE")))
.andReturn(ImmutableList.of(sha1Result));
replay(thriftClient);
EdenClientPool pool = new EdenClientPool(thriftClient);
Path pathToBuck = fs.getPath("/home/mbolin/src/buck");
Files.createDirectories(pathToBuck.resolve(".eden"));
Files.createSymbolicLink(pathToBuck.resolve(".eden").resolve("root"), pathToBuck);
Optional<EdenMount> mount = EdenMount.createEdenMountForProjectRoot(pathToBuck, pool);
assertTrue("Should find mount for path.", mount.isPresent());
assertEquals(Sha1HashCode.fromHashCode(hash), mount.get().getSha1(entry));
verify(thriftClient);
}
开发者ID:facebook,项目名称:buck,代码行数:24,代码来源:EdenMountTest.java
示例5: getSHA1
import com.facebook.thrift.TException; //导入依赖的package包/类
@Override
public List<SHA1Result> getSHA1(String mountPoint, List<String> paths)
throws EdenError, IOException, TException {
try {
return attemptGetSHA1(mountPoint, paths);
} catch (TException e) {
investigateAndPossiblyRethrowException(e);
}
return attemptGetSHA1(mountPoint, paths);
}
开发者ID:facebook,项目名称:buck,代码行数:12,代码来源:ReconnectingEdenClient.java
示例6: getBindMounts
import com.facebook.thrift.TException; //导入依赖的package包/类
@Override
public List<String> getBindMounts(String mountPoint) throws EdenError, IOException, TException {
try {
return attemptGetBindMounts(mountPoint);
} catch (TException e) {
investigateAndPossiblyRethrowException(e);
}
return attemptGetBindMounts(mountPoint);
}
开发者ID:facebook,项目名称:buck,代码行数:11,代码来源:ReconnectingEdenClient.java
示例7: listMounts
import com.facebook.thrift.TException; //导入依赖的package包/类
@Override
public List<MountInfo> listMounts() throws EdenError, IOException, TException {
try {
return attemptListMounts();
} catch (TException e) {
investigateAndPossiblyRethrowException(e);
}
return attemptListMounts();
}
开发者ID:facebook,项目名称:buck,代码行数:11,代码来源:ReconnectingEdenClient.java
示例8: getSha1
import com.facebook.thrift.TException; //导入依赖的package包/类
/** @param entry is a path that is relative to {@link #getProjectRoot()}. */
public Sha1HashCode getSha1(Path entry) throws EdenError, IOException, TException {
List<SHA1Result> results =
pool.getClient().getSHA1(mountPoint, ImmutableList.of(normalizePathArg(entry)));
SHA1Result result = Iterables.getOnlyElement(results);
if (result.getSetField() == SHA1Result.SHA1) {
return Sha1HashCode.fromBytes(result.getSha1());
} else {
throw result.getError();
}
}
开发者ID:facebook,项目名称:buck,代码行数:12,代码来源:EdenMount.java
示例9: getBindMounts
import com.facebook.thrift.TException; //导入依赖的package包/类
public ImmutableList<Path> getBindMounts() {
List<String> bindMounts;
try {
bindMounts = pool.getClient().getBindMounts(mountPoint);
} catch (EdenError | IOException | TException e) {
throw new RuntimeException(e);
}
return bindMounts.stream().map(Paths::get).collect(ImmutableList.toImmutableList());
}
开发者ID:facebook,项目名称:buck,代码行数:11,代码来源:EdenMount.java
示例10: newInstanceFromSocket
import com.facebook.thrift.TException; //导入依赖的package包/类
public static Optional<EdenClientPool> newInstanceFromSocket(final Path socketFile) {
// We forcibly try to create an EdenClient as a way of verifying that `socketFile` is a
// valid UNIX domain socket for talking to Eden. If this is not the case, then we should not
// return a new EdenClientPool.
ReconnectingEdenClient edenClient = new ReconnectingEdenClient(socketFile, clock);
try {
edenClient.listMounts();
} catch (EdenError | IOException | TException e) {
return Optional.empty();
}
return Optional.of(new EdenClientPool(socketFile));
}
开发者ID:facebook,项目名称:buck,代码行数:13,代码来源:EdenClientPool.java
示例11: getMountInfosDelegatesToThriftClient
import com.facebook.thrift.TException; //导入依赖的package包/类
@Test
public void getMountInfosDelegatesToThriftClient() throws EdenError, IOException, TException {
List<MountInfo> mountInfos =
ImmutableList.of(
new MountInfo("/home/mbolin/src/buck", /* edenClientPath */ ""),
new MountInfo("/home/mbolin/src/eden", /* edenClientPath */ ""));
expect(thriftClient.listMounts()).andReturn(mountInfos);
replay(thriftClient);
assertEquals(mountInfos, pool.getClient().listMounts());
verify(thriftClient);
}
开发者ID:facebook,项目名称:buck,代码行数:12,代码来源:EdenClientTest.java
示例12: getMountForMatchesProjectRootEqualToMount
import com.facebook.thrift.TException; //导入依赖的package包/类
@Test
public void getMountForMatchesProjectRootEqualToMount()
throws EdenError, IOException, TException {
Path projectRoot = fs.getPath("/home/mbolin/src/eden");
Files.createDirectories(projectRoot.resolve(".eden"));
Files.createSymbolicLink(projectRoot.resolve(".eden").resolve("root"), projectRoot);
Optional<EdenMount> mount = EdenMount.createEdenMountForProjectRoot(projectRoot, pool);
assertTrue("Should find mount for path.", mount.isPresent());
assertEquals(fs.getPath("/home/mbolin/src/eden"), mount.get().getProjectRoot());
assertEquals(fs.getPath(""), mount.get().getPrefix());
}
开发者ID:facebook,项目名称:buck,代码行数:13,代码来源:EdenClientTest.java
示例13: getMountForMatchesProjectRootUnderMount
import com.facebook.thrift.TException; //导入依赖的package包/类
@Test
public void getMountForMatchesProjectRootUnderMount() throws EdenError, IOException, TException {
Path edenMountRoot = fs.getPath("/home/mbolin/src/eden");
Path projectRoot = fs.getPath("/home/mbolin/src/eden/deep/project");
Files.createDirectories(projectRoot.resolve(".eden"));
Files.createSymbolicLink(projectRoot.resolve(".eden").resolve("root"), edenMountRoot);
Optional<EdenMount> mount = EdenMount.createEdenMountForProjectRoot(projectRoot, pool);
assertTrue("Should find mount for path.", mount.isPresent());
assertEquals(projectRoot, mount.get().getProjectRoot());
assertEquals(fs.getPath("deep/project"), mount.get().getPrefix());
}
开发者ID:facebook,项目名称:buck,代码行数:13,代码来源:EdenClientTest.java
示例14: getMountForReturnsNullWhenMissingMountPoint
import com.facebook.thrift.TException; //导入依赖的package包/类
@Test
public void getMountForReturnsNullWhenMissingMountPoint()
throws EdenError, IOException, TException {
Path projectRoot = Paths.get("/home/mbolin/src/other_project");
Optional<EdenMount> mount = EdenMount.createEdenMountForProjectRoot(projectRoot, pool);
assertFalse(mount.isPresent());
}
开发者ID:facebook,项目名称:buck,代码行数:8,代码来源:EdenClientTest.java
示例15: computeSha1ForOrdinaryFileUnderMountButBehindBindMount
import com.facebook.thrift.TException; //导入依赖的package包/类
@Test
public void computeSha1ForOrdinaryFileUnderMountButBehindBindMount()
throws IOException, EdenError, TException {
FileSystem fs = Jimfs.newFileSystem(Configuration.unix());
Path root = fs.getPath(JIMFS_WORKING_DIRECTORY);
ProjectFilesystemDelegate delegate = new DefaultProjectFilesystemDelegate(root);
EdenMount mount = createMock(EdenMount.class);
Path path = fs.getPath("buck-out/gen/some-output");
Files.createDirectories(path.getParent());
Files.createFile(path);
byte[] bytes = new byte[] {66, 85, 67, 75};
Files.write(path, bytes);
expect(mount.getBindMounts()).andReturn(ImmutableList.of(fs.getPath("buck-out")));
expect(mount.getPathRelativeToProjectRoot(root.resolve(path))).andReturn(Optional.of(path));
replay(mount);
EdenProjectFilesystemDelegate edenDelegate = new EdenProjectFilesystemDelegate(mount, delegate);
assertEquals(
"EdenProjectFilesystemDelegate.computeSha1() should compute the SHA-1 directly via "
+ "DefaultProjectFilesystemDelegate because the path is behind a bind mount.",
Sha1HashCode.fromHashCode(Hashing.sha1().hashBytes(bytes)),
edenDelegate.computeSha1(path));
verify(mount);
}
开发者ID:facebook,项目名称:buck,代码行数:28,代码来源:EdenProjectFilesystemDelegateTest.java
示例16: computeSha1ForSymlinkUnderMountThatPointsToFileUnderMount
import com.facebook.thrift.TException; //导入依赖的package包/类
@Test
public void computeSha1ForSymlinkUnderMountThatPointsToFileUnderMount()
throws EdenError, TException, IOException {
FileSystem fs = Jimfs.newFileSystem(Configuration.unix());
Path root = fs.getPath(JIMFS_WORKING_DIRECTORY);
ProjectFilesystemDelegate delegate = new DefaultProjectFilesystemDelegate(root);
// Create a symlink within the project root.
Path link = fs.getPath("/work/link");
Path target = fs.getPath("/work/target");
Files.createFile(target);
Files.createSymbolicLink(link, target);
// Eden will throw when the SHA-1 for the link is requested, but return a SHA-1 when the target
// is requested.
EdenMount mount = createMock(EdenMount.class);
expect(mount.getBindMounts()).andReturn(ImmutableList.of());
expect(mount.getPathRelativeToProjectRoot(link)).andReturn(Optional.of(fs.getPath("link")));
expect(mount.getPathRelativeToProjectRoot(target)).andReturn(Optional.of(fs.getPath("target")));
expect(mount.getSha1(fs.getPath("link"))).andThrow(new EdenError());
expect(mount.getSha1(fs.getPath("target"))).andReturn(DUMMY_SHA1);
replay(mount);
EdenProjectFilesystemDelegate edenDelegate = new EdenProjectFilesystemDelegate(mount, delegate);
assertEquals(DUMMY_SHA1, edenDelegate.computeSha1(link));
verify(mount);
}
开发者ID:facebook,项目名称:buck,代码行数:29,代码来源:EdenProjectFilesystemDelegateTest.java
示例17: computeSha1ForSymlinkUnderMountThatPointsToFileOutsideMount
import com.facebook.thrift.TException; //导入依赖的package包/类
@Test
public void computeSha1ForSymlinkUnderMountThatPointsToFileOutsideMount()
throws IOException, EdenError, TException {
FileSystem fs = Jimfs.newFileSystem(Configuration.unix());
Path root = fs.getPath(JIMFS_WORKING_DIRECTORY);
ProjectFilesystemDelegate delegate = new DefaultProjectFilesystemDelegate(root);
// Create a symlink within the project root.
Path link = fs.getPath("/work/link");
Path target = fs.getPath("/example");
Files.createFile(target);
byte[] bytes = new byte[] {66, 85, 67, 75};
Files.write(target, bytes);
Files.createSymbolicLink(link, target);
// Eden will throw when the SHA-1 for the link is requested, but return a SHA-1 when the target
// is requested.
EdenMount mount = createMock(EdenMount.class);
expect(mount.getBindMounts()).andReturn(ImmutableList.of());
expect(mount.getPathRelativeToProjectRoot(link)).andReturn(Optional.of(fs.getPath("link")));
expect(mount.getPathRelativeToProjectRoot(target)).andReturn(Optional.empty());
expect(mount.getSha1(fs.getPath("link"))).andThrow(new EdenError());
replay(mount);
EdenProjectFilesystemDelegate edenDelegate = new EdenProjectFilesystemDelegate(mount, delegate);
assertEquals(
"EdenProjectFilesystemDelegate.computeSha1() should return the SHA-1 of the target of "
+ "the symlink even though the target is outside of the EdenFS root.",
Sha1HashCode.fromHashCode(Hashing.sha1().hashBytes(bytes)),
edenDelegate.computeSha1(link));
verify(mount);
}
开发者ID:facebook,项目名称:buck,代码行数:34,代码来源:EdenProjectFilesystemDelegateTest.java
示例18: run
import com.facebook.thrift.TException; //导入依赖的package包/类
@Override
public int run(EdenClientPool pool) throws EdenError, IOException, TException {
Path mountPoint = Paths.get(this.mountPoint);
EdenMount mount = EdenMount.createEdenMountForProjectRoot(mountPoint, pool).get();
for (String path : paths) {
Path entry = mountPoint.relativize(Paths.get(path));
Sha1HashCode sha1 = mount.getSha1(entry);
System.out.printf("%s %s\n", entry, sha1);
}
return 0;
}
开发者ID:facebook,项目名称:buck,代码行数:14,代码来源:Sha1Command.java
示例19: attemptGetSHA1
import com.facebook.thrift.TException; //导入依赖的package包/类
private List<SHA1Result> attemptGetSHA1(String mountPoint, List<String> paths)
throws EdenError, IOException, TException {
List<SHA1Result> sha1s = getConnectedClient().getSHA1(mountPoint, paths);
lastSuccessfulRequest = clock.currentTimeMillis();
return sha1s;
}
开发者ID:facebook,项目名称:buck,代码行数:7,代码来源:ReconnectingEdenClient.java
示例20: attemptGetBindMounts
import com.facebook.thrift.TException; //导入依赖的package包/类
private List<String> attemptGetBindMounts(String mountPoint)
throws EdenError, IOException, TException {
List<String> bindMounts = getConnectedClient().getBindMounts(mountPoint);
lastSuccessfulRequest = clock.currentTimeMillis();
return bindMounts;
}
开发者ID:facebook,项目名称:buck,代码行数:7,代码来源:ReconnectingEdenClient.java
注:本文中的com.facebook.thrift.TException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论