Skip to content

Commit

Permalink
Remove usages of ThriftIOException
Browse files Browse the repository at this point in the history
  • Loading branch information
aaudiber committed Apr 15, 2017
1 parent 8df17bf commit 8bc0101
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 77 deletions.
Expand Up @@ -22,14 +22,14 @@
import alluxio.exception.ExceptionMessage;
import alluxio.exception.UfsBlockAccessTokenUnavailableException;
import alluxio.exception.WorkerOutOfSpaceException;
import alluxio.exception.status.UnavailableException;
import alluxio.metrics.MetricsSystem;
import alluxio.retry.CountingRetry;
import alluxio.retry.ExponentialBackoffRetry;
import alluxio.retry.RetryPolicy;
import alluxio.retry.TimeoutRetry;
import alluxio.thrift.AlluxioTException;
import alluxio.thrift.BlockWorkerClientService;
import alluxio.thrift.ThriftIOException;
import alluxio.util.ThreadFactoryUtils;
import alluxio.util.network.NetworkAddressUtils;
import alluxio.wire.LockBlockResult;
Expand Down Expand Up @@ -352,7 +352,7 @@ public void sessionHeartbeat(RetryPolicy retryPolicy) throws IOException, Interr
AlluxioException ae = AlluxioException.fromThrift(e);
LOG.warn(ae.getMessage());
throw new IOException(ae);
} catch (ThriftIOException e) {
} catch (UnavailableException e) {
LOG.warn(e.getMessage());
throw new IOException(e);
} catch (TException e) {
Expand Down
6 changes: 3 additions & 3 deletions core/common/src/main/java/alluxio/AbstractClient.java
Expand Up @@ -15,12 +15,12 @@
import alluxio.exception.ConnectionFailedException;
import alluxio.exception.ExceptionMessage;
import alluxio.exception.PreconditionMessage;
import alluxio.exception.status.UnavailableException;
import alluxio.retry.ExponentialBackoffRetry;
import alluxio.retry.RetryPolicy;
import alluxio.security.authentication.TransportProvider;
import alluxio.thrift.AlluxioService;
import alluxio.thrift.AlluxioTException;
import alluxio.thrift.ThriftIOException;

import com.google.common.base.Preconditions;
import org.apache.thrift.TException;
Expand Down Expand Up @@ -320,7 +320,7 @@ protected synchronized <V> V retryRPC(RpcCallable<V> rpc) throws IOException,
connect();
try {
return rpc.call();
} catch (ThriftIOException e) {
} catch (UnavailableException e) {
throw new IOException(e);
} catch (AlluxioTException e) {
throw new RuntimeException(AlluxioException.fromThrift(e));
Expand Down Expand Up @@ -357,7 +357,7 @@ protected synchronized <V> V retryRPC(RpcCallableThrowsAlluxioTException<V> rpc)
return rpc.call();
} catch (AlluxioTException e) {
throw AlluxioException.fromThrift(e);
} catch (ThriftIOException e) {
} catch (UnavailableException e) {
throw new IOException(e);
} catch (TException e) {
LOG.error(e.getMessage(), e);
Expand Down
6 changes: 3 additions & 3 deletions core/common/src/main/java/alluxio/AbstractThriftClient.java
Expand Up @@ -12,12 +12,12 @@
package alluxio;

import alluxio.exception.AlluxioException;
import alluxio.exception.status.UnavailableException;
import alluxio.network.connection.ThriftClientPool;
import alluxio.retry.ExponentialBackoffRetry;
import alluxio.retry.RetryPolicy;
import alluxio.thrift.AlluxioService;
import alluxio.thrift.AlluxioTException;
import alluxio.thrift.ThriftIOException;

import com.google.common.base.Preconditions;
import org.apache.thrift.TException;
Expand Down Expand Up @@ -106,7 +106,7 @@ protected <V> V retryRPC(RpcCallable<V, C> rpc) throws IOException {
C client = acquireClient();
try {
return rpc.call(client);
} catch (ThriftIOException e) {
} catch (UnavailableException e) {
throw new IOException(e);
} catch (AlluxioTException e) {
AlluxioException ae = AlluxioException.fromThrift(e);
Expand Down Expand Up @@ -154,7 +154,7 @@ protected <V> V retryRPC(RpcCallableThrowsAlluxioTException<V, C> rpc)
AlluxioException ae = AlluxioException.fromThrift(e);
processException(client, ae);
exception = new TException(ae);
} catch (ThriftIOException e) {
} catch (UnavailableException e) {
throw new IOException(e);
} catch (TException e) {
LOG.error(e.getMessage(), e);
Expand Down
14 changes: 6 additions & 8 deletions core/server/common/src/main/java/alluxio/RpcUtils.java
Expand Up @@ -13,8 +13,8 @@

import alluxio.exception.AlluxioException;
import alluxio.exception.UnexpectedAlluxioException;
import alluxio.exception.status.UnavailableException;
import alluxio.thrift.AlluxioTException;
import alluxio.thrift.ThriftIOException;

import org.slf4j.Logger;

Expand Down Expand Up @@ -52,11 +52,10 @@ public static <T> T call(Logger logger, RpcCallable<T> callable) throws AlluxioT
* @param callable the callable to call
* @param <T> the return type of the callable
* @return the return value from calling the callable
* @throws AlluxioTException if the callable throws an Alluxio or runtime exception
* @throws ThriftIOException if the callable throws an IOException
* @throws AlluxioTException if the callable throws an exception
*/
public static <T> T call(Logger logger, RpcCallableThrowsIOException<T> callable)
throws AlluxioTException, ThriftIOException {
throws AlluxioTException {
try {
return callable.call();
} catch (AlluxioException e) {
Expand All @@ -65,7 +64,7 @@ public static <T> T call(Logger logger, RpcCallableThrowsIOException<T> callable
} catch (IOException e) {
logger.warn("{}, Error={}", callable, e.getMessage());
logger.debug("{}", callable, e);
throw new ThriftIOException(e.getMessage());
throw new UnavailableException(e.getMessage());
} catch (Exception e) {
logger.error("{}", callable, e);
throw new UnexpectedAlluxioException(e).toThrift();
Expand Down Expand Up @@ -106,16 +105,15 @@ public static <T> T callAndLog(Logger logger, RpcCallable<T> callable) throws Al
* @param <T> the return type of the callable
* @return the return value from calling the callable
* @throws AlluxioTException if the callable throws an Alluxio or runtime exception
* @throws ThriftIOException if the callable throws an IOException
*/
public static <T> T callAndLog(Logger logger, RpcCallableThrowsIOException<T> callable)
throws AlluxioTException, ThriftIOException {
throws AlluxioTException {
logger.debug("Enter: {}", callable);
try {
T ret = call(logger, callable);
logger.debug("Exit (OK): {}", callable);
return ret;
} catch (AlluxioTException | ThriftIOException e) {
} catch (AlluxioTException e) {
logger.debug("Exit (Error): {}, Error={}", callable, e.getMessage());
throw e;
}
Expand Down
Expand Up @@ -41,7 +41,6 @@
import alluxio.thrift.ListStatusTOptions;
import alluxio.thrift.MountTOptions;
import alluxio.thrift.SetAttributeTOptions;
import alluxio.thrift.ThriftIOException;
import alluxio.wire.ThriftUtils;

import com.google.common.base.Preconditions;
Expand Down Expand Up @@ -81,7 +80,7 @@ public long getServiceVersion() {

@Override
public List<String> checkConsistency(final String path, final CheckConsistencyTOptions options)
throws AlluxioTException, ThriftIOException {
throws AlluxioTException {
return RpcUtils.callAndLog(LOG, new RpcCallableThrowsIOException<List<String>>() {
@Override
public List<String> call() throws AlluxioException, IOException {
Expand Down Expand Up @@ -120,7 +119,7 @@ public String toString() {

@Override
public void createDirectory(final String path, final CreateDirectoryTOptions options)
throws AlluxioTException, ThriftIOException {
throws AlluxioTException {
RpcUtils.callAndLog(LOG, new RpcCallableThrowsIOException<Void>() {
@Override
public Void call() throws AlluxioException, IOException {
Expand All @@ -138,7 +137,7 @@ public String toString() {

@Override
public void createFile(final String path, final CreateFileTOptions options)
throws AlluxioTException, ThriftIOException {
throws AlluxioTException {
RpcUtils.callAndLog(LOG, new RpcCallableThrowsIOException<Void>() {
@Override
public Void call() throws AlluxioException, IOException {
Expand Down Expand Up @@ -306,7 +305,7 @@ public String toString() {
@Override
@Deprecated
public long loadMetadata(final String alluxioPath, final boolean recursive)
throws AlluxioTException, ThriftIOException {
throws AlluxioTException {
return RpcUtils.callAndLog(LOG, new RpcCallableThrowsIOException<Long>() {
@Override
public Long call() throws AlluxioException, IOException {
Expand All @@ -323,7 +322,7 @@ public String toString() {

@Override
public void mount(final String alluxioPath, final String ufsPath, final MountTOptions options)
throws AlluxioTException, ThriftIOException {
throws AlluxioTException {
RpcUtils.callAndLog(LOG, new RpcCallableThrowsIOException<Void>() {
@Override
public Void call() throws AlluxioException, IOException {
Expand All @@ -342,7 +341,7 @@ public String toString() {

@Override
public void remove(final String path, final boolean recursive, final DeleteTOptions options)
throws AlluxioTException, ThriftIOException {
throws AlluxioTException {
RpcUtils.callAndLog(LOG, new RpcCallableThrowsIOException<Void>() {
@Override
public Void call() throws AlluxioException, IOException {
Expand All @@ -367,7 +366,7 @@ public String toString() {

@Override
public void rename(final String srcPath, final String dstPath)
throws AlluxioTException, ThriftIOException {
throws AlluxioTException {
RpcUtils.callAndLog(LOG, new RpcCallableThrowsIOException<Void>() {
@Override
public Void call() throws AlluxioException, IOException {
Expand Down Expand Up @@ -418,7 +417,7 @@ public String toString() {
}

@Override
public void unmount(final String alluxioPath) throws AlluxioTException, ThriftIOException {
public void unmount(final String alluxioPath) throws AlluxioTException {
RpcUtils.callAndLog(LOG, new RpcCallableThrowsIOException<Void>() {
@Override
public Void call() throws AlluxioException, IOException {
Expand Down
Expand Up @@ -23,7 +23,6 @@
import alluxio.thrift.CommandLineJobInfo;
import alluxio.thrift.LineageInfo;
import alluxio.thrift.LineageMasterClientService;
import alluxio.thrift.ThriftIOException;
import alluxio.thrift.TTtlAction;
import alluxio.wire.ThriftUtils;

Expand Down Expand Up @@ -64,7 +63,7 @@ public long getServiceVersion() {

@Override
public long createLineage(final List<String> inputFiles, final List<String> outputFiles,
final CommandLineJobInfo jobInfo) throws AlluxioTException, ThriftIOException {
final CommandLineJobInfo jobInfo) throws AlluxioTException {
return RpcUtils.call(LOG, new RpcCallableThrowsIOException<Long>() {
@Override
public Long call() throws AlluxioException, IOException {
Expand Down
Expand Up @@ -27,7 +27,6 @@
import alluxio.thrift.LockBlockResult;
import alluxio.thrift.LockBlockStatus;
import alluxio.thrift.LockBlockTOptions;
import alluxio.thrift.ThriftIOException;
import alluxio.worker.block.options.OpenUfsBlockOptions;

import org.slf4j.Logger;
Expand Down Expand Up @@ -95,12 +94,11 @@ public String toString() {
*
* @param sessionId the id of the client requesting the commit
* @param blockId the id of the block to commit
* @throws AlluxioTException if an Alluxio error occurs
* @throws ThriftIOException if an I/O error occurs
* @throws AlluxioTException if an error occurs
*/
@Override
public void cacheBlock(final long sessionId, final long blockId)
throws AlluxioTException, ThriftIOException {
throws AlluxioTException {
RpcUtils.callAndLog(LOG, new RpcCallableThrowsIOException<Void>() {
@Override
public Void call() throws AlluxioException, IOException {
Expand All @@ -121,12 +119,11 @@ public String toString() {
*
* @param sessionId the id of the client requesting the abort
* @param blockId the id of the block to be aborted
* @throws AlluxioTException if an Alluxio error occurs
* @throws ThriftIOException if an I/O error occurs
* @throws AlluxioTException if an error occurs
*/
@Override
public void cancelBlock(final long sessionId, final long blockId)
throws AlluxioTException, ThriftIOException {
throws AlluxioTException {
RpcUtils.callAndLog(LOG, new RpcCallableThrowsIOException<Void>() {
@Override
public Void call() throws AlluxioException, IOException {
Expand All @@ -147,7 +144,7 @@ public String toString() {
* @param blockId the id of the block to be locked
* @param sessionId the id of the session
* @return the path of the block file locked
* @throws AlluxioTException if an Alluxio error occurs
* @throws AlluxioTException if an error occurs
*/
@Override
public LockBlockResult lockBlock(final long blockId, final long sessionId,
Expand Down Expand Up @@ -193,12 +190,11 @@ public String toString() {
*
* @param blockId the id of the block to move to the top layer
* @return true if the block is successfully promoted, otherwise false
* @throws AlluxioTException if an Alluxio error occurs
* @throws ThriftIOException if an I/O error occurs
* @throws AlluxioTException if an error occurs
*/
// TODO(calvin): This may be better as void.
@Override
public boolean promoteBlock(final long blockId) throws AlluxioTException, ThriftIOException {
public boolean promoteBlock(final long blockId) throws AlluxioTException {
return RpcUtils.callAndLog(LOG, new RpcCallableThrowsIOException<Boolean>() {
@Override
public Boolean call() throws AlluxioException, IOException {
Expand All @@ -219,11 +215,10 @@ public String toString() {
* reclaim space allocated to the block.
*
* @param blockId the id of the block to be removed
* @throws AlluxioTException if an Alluxio error occurs
* @throws ThriftIOException if an I/O error occurs
* @throws AlluxioTException if an error occurs
*/
@Override
public void removeBlock(final long blockId) throws AlluxioTException, ThriftIOException {
public void removeBlock(final long blockId) throws AlluxioTException {
RpcUtils.callAndLog(LOG, new RpcCallableThrowsIOException<Void>() {
@Override
public Void call() throws AlluxioException, IOException {
Expand All @@ -250,12 +245,11 @@ public String toString() {
* @param initialBytes the initial number of bytes to allocate for this block
* @param writeTier policy used to choose tier for this block
* @return the temporary file path of the block file
* @throws AlluxioTException if an Alluxio error occurs
* @throws ThriftIOException if an I/O error occurs
* @throws AlluxioTException if an error occurs
*/
@Override
public String requestBlockLocation(final long sessionId, final long blockId,
final long initialBytes, final int writeTier) throws AlluxioTException, ThriftIOException {
final long initialBytes, final int writeTier) throws AlluxioTException {
return RpcUtils.callAndLog(LOG, new RpcCallableThrowsIOException<String>() {
@Override
public String call() throws AlluxioException, IOException {
Expand All @@ -279,12 +273,11 @@ public String toString() {
* @param requestBytes the amount of bytes to add to the block
* @return true if the worker successfully allocates space for the block on block’s location,
* false if there is not enough space
* @throws AlluxioTException if an Alluxio error occurs
* @throws ThriftIOException if an I/O error occurs
* @throws AlluxioTException if an error occurs
*/
@Override
public boolean requestSpace(final long sessionId, final long blockId, final long requestBytes)
throws AlluxioTException, ThriftIOException {
throws AlluxioTException {
return RpcUtils.callAndLog(LOG, new RpcCallable<Boolean>() {
@Override
public Boolean call() throws AlluxioException {
Expand Down Expand Up @@ -322,12 +315,11 @@ public String toString() {
* @param sessionId the id of the client requesting the unlock
* @return true if successfully unlock the block, return false if the block is not
* found or failed to delete the block
* @throws AlluxioTException if an Alluxio error occurs
* @throws AlluxioTException if an error occurs
*/
// TODO(andrew): This should return void
@Override
public boolean unlockBlock(final long blockId, final long sessionId)
throws AlluxioTException, ThriftIOException {
throws AlluxioTException {
return RpcUtils.callAndLog(LOG, new RpcCallableThrowsIOException<Boolean>() {
@Override
public Boolean call() throws AlluxioException, IOException {
Expand Down

0 comments on commit 8bc0101

Please sign in to comment.