Search in sources :

Example 51 with UnavailableException

use of alluxio.exception.status.UnavailableException in project alluxio by Alluxio.

the class PollingMasterInquireClient method getAddress.

@Nullable
private InetSocketAddress getAddress() {
    // Iterate over the masters and try to connect to each of their RPC ports.
    List<InetSocketAddress> addresses;
    if (mConfiguration.getBoolean(PropertyKey.USER_RPC_SHUFFLE_MASTERS_ENABLED)) {
        addresses = Lists.newArrayList(mConnectDetails.getAddresses());
        Collections.shuffle(addresses);
    } else {
        addresses = mConnectDetails.getAddresses();
    }
    for (InetSocketAddress address : addresses) {
        try {
            LOG.debug("Checking whether {} is listening for RPCs", address);
            pingMetaService(address);
            LOG.debug("Successfully connected to {}", address);
            return address;
        } catch (UnavailableException e) {
            LOG.debug("Failed to connect to {}", address);
            continue;
        } catch (DeadlineExceededException e) {
            LOG.debug("Timeout while connecting to {}", address);
            continue;
        } catch (CancelledException e) {
            LOG.debug("Cancelled while connecting to {}", address);
            continue;
        } catch (AlluxioStatusException e) {
            LOG.error("Error while connecting to {}. {}", address, e);
            // Breaking the loop on non filtered error.
            break;
        }
    }
    return null;
}
Also used : InetSocketAddress(java.net.InetSocketAddress) CancelledException(alluxio.exception.status.CancelledException) UnavailableException(alluxio.exception.status.UnavailableException) DeadlineExceededException(alluxio.exception.status.DeadlineExceededException) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) Nullable(javax.annotation.Nullable)

Example 52 with UnavailableException

use of alluxio.exception.status.UnavailableException in project alluxio by Alluxio.

the class AuthenticatedChannelClientDriver method waitUntilChannelAuthenticated.

private void waitUntilChannelAuthenticated(long timeoutMs) throws AlluxioStatusException {
    try {
        // Wait until authentication status changes.
        mChannelAuthenticatedFuture.get(timeoutMs, TimeUnit.MILLISECONDS);
        mChannelAuthenticated = true;
    } catch (InterruptedException ie) {
        Thread.currentThread().interrupt();
        throw AlluxioStatusException.fromThrowable(ie);
    } catch (ExecutionException e) {
        AlluxioStatusException statExc = AlluxioStatusException.fromThrowable(e.getCause());
        // Unimplemented is returned if server doesn't provide authentication service.
        if (statExc.getStatusCode() == Status.Code.UNIMPLEMENTED) {
            throw new UnauthenticatedException("Authentication is disabled on target server.");
        }
        throw statExc;
    } catch (TimeoutException e) {
        throw new UnavailableException(e);
    }
}
Also used : UnauthenticatedException(alluxio.exception.status.UnauthenticatedException) UnavailableException(alluxio.exception.status.UnavailableException) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException)

Example 53 with UnavailableException

use of alluxio.exception.status.UnavailableException in project alluxio by Alluxio.

the class DefaultAsyncPersistHandler method getWorkerStoringFile.

/**
 * Gets a worker where the given file is stored.
 *
 * @param path the path to the file
 * @return the id of the storing worker
 * @throws FileDoesNotExistException when the file does not exist on any worker
 * @throws AccessControlException if permission checking fails
 */
// TODO(calvin): Propagate the exceptions in certain cases
private long getWorkerStoringFile(AlluxioURI path) throws FileDoesNotExistException, AccessControlException, UnavailableException {
    long fileId = mFileSystemMasterView.getFileId(path);
    try {
        if (mFileSystemMasterView.getFileInfo(fileId).getLength() == 0) {
            // if file is empty, return any worker
            List<WorkerInfo> workerInfoList = mFileSystemMasterView.getWorkerInfoList();
            if (workerInfoList.isEmpty()) {
                LOG.error("No worker is available");
                return IdUtils.INVALID_WORKER_ID;
            }
            // randomly pick a worker
            int index = new Random().nextInt(workerInfoList.size());
            return workerInfoList.get(index).getId();
        }
    } catch (UnavailableException e) {
        return IdUtils.INVALID_WORKER_ID;
    }
    Map<Long, Integer> workerBlockCounts = new HashMap<>();
    List<FileBlockInfo> blockInfoList;
    try {
        blockInfoList = mFileSystemMasterView.getFileBlockInfoList(path);
        for (FileBlockInfo fileBlockInfo : blockInfoList) {
            for (BlockLocation blockLocation : fileBlockInfo.getBlockInfo().getLocations()) {
                if (workerBlockCounts.containsKey(blockLocation.getWorkerId())) {
                    workerBlockCounts.put(blockLocation.getWorkerId(), workerBlockCounts.get(blockLocation.getWorkerId()) + 1);
                } else {
                    workerBlockCounts.put(blockLocation.getWorkerId(), 1);
                }
                // all the blocks of a file must be stored on the same worker
                if (workerBlockCounts.get(blockLocation.getWorkerId()) == blockInfoList.size()) {
                    return blockLocation.getWorkerId();
                }
            }
        }
    } catch (FileDoesNotExistException e) {
        LOG.error("The file {} to persist does not exist", path);
        return IdUtils.INVALID_WORKER_ID;
    } catch (InvalidPathException e) {
        LOG.error("The file {} to persist is invalid", path);
        return IdUtils.INVALID_WORKER_ID;
    } catch (UnavailableException e) {
        return IdUtils.INVALID_WORKER_ID;
    }
    if (workerBlockCounts.size() == 0) {
        LOG.error("The file " + path + " does not exist on any worker");
        return IdUtils.INVALID_WORKER_ID;
    }
    LOG.error("Not all the blocks of file {} stored on the same worker", path);
    return IdUtils.INVALID_WORKER_ID;
}
Also used : FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) HashMap(java.util.HashMap) UnavailableException(alluxio.exception.status.UnavailableException) WorkerInfo(alluxio.wire.WorkerInfo) FileBlockInfo(alluxio.wire.FileBlockInfo) BlockLocation(alluxio.wire.BlockLocation) InvalidPathException(alluxio.exception.InvalidPathException) Random(java.util.Random)

Example 54 with UnavailableException

use of alluxio.exception.status.UnavailableException in project alluxio by Alluxio.

the class MountTable method resolve.

/**
 * Resolves the given Alluxio path. If the given Alluxio path is nested under a mount point, the
 * resolution maps the Alluxio path to the corresponding UFS path. Otherwise, the resolution is a
 * no-op.
 *
 * @param uri an Alluxio path URI
 * @return the {@link Resolution} representing the UFS path
 * @throws InvalidPathException if an invalid path is encountered
 */
public Resolution resolve(AlluxioURI uri) throws InvalidPathException {
    try (LockResource r = new LockResource(mReadLock)) {
        String path = uri.getPath();
        LOG.debug("Resolving {}", path);
        PathUtils.validatePath(uri.getPath());
        // This will re-acquire the read lock, but that is allowed.
        String mountPoint = getMountPoint(uri);
        if (mountPoint != null) {
            MountInfo info = mState.getMountTable().get(mountPoint);
            AlluxioURI ufsUri = info.getUfsUri();
            UfsManager.UfsClient ufsClient;
            AlluxioURI resolvedUri;
            try {
                ufsClient = mUfsManager.get(info.getMountId());
                try (CloseableResource<UnderFileSystem> ufsResource = ufsClient.acquireUfsResource()) {
                    UnderFileSystem ufs = ufsResource.get();
                    resolvedUri = ufs.resolveUri(ufsUri, path.substring(mountPoint.length()));
                }
            } catch (NotFoundException | UnavailableException e) {
                throw new RuntimeException(String.format("No UFS information for %s for mount Id %d, we should never reach here", uri, info.getMountId()), e);
            }
            return new Resolution(resolvedUri, ufsClient, info.getOptions().getShared(), info.getMountId());
        }
        // TODO(binfan): throw exception as we should never reach here
        return new Resolution(uri, null, false, IdUtils.INVALID_MOUNT_ID);
    }
}
Also used : UfsManager(alluxio.underfs.UfsManager) UnavailableException(alluxio.exception.status.UnavailableException) NotFoundException(alluxio.exception.status.NotFoundException) MountInfo(alluxio.master.file.meta.options.MountInfo) LockResource(alluxio.resource.LockResource) UnderFileSystem(alluxio.underfs.UnderFileSystem) AlluxioURI(alluxio.AlluxioURI)

Example 55 with UnavailableException

use of alluxio.exception.status.UnavailableException in project alluxio by Alluxio.

the class WorkerUfsManager method get.

/**
 * {@inheritDoc}.
 *
 * If this mount id is new to this worker, this method will query master to get the
 * corresponding ufs info.
 */
@Override
public UfsClient get(long mountId) throws NotFoundException, UnavailableException {
    try {
        return super.get(mountId);
    } catch (NotFoundException e) {
    // Not cached locally, let's query master
    }
    UfsInfo info;
    try {
        info = mMasterClient.getUfsInfo(mountId);
    } catch (IOException e) {
        throw new UnavailableException(String.format("Failed to create UFS info for mount point with id %d", mountId), e);
    }
    Preconditions.checkState((info.hasUri() && info.hasProperties()), "unknown mountId");
    super.addMount(mountId, new AlluxioURI(info.getUri()), UnderFileSystemConfiguration.defaults(ServerConfiguration.global()).setReadOnly(info.getProperties().getReadOnly()).setShared(info.getProperties().getShared()).createMountSpecificConf(info.getProperties().getPropertiesMap()));
    UfsClient ufsClient = super.get(mountId);
    return ufsClient;
}
Also used : UfsInfo(alluxio.grpc.UfsInfo) UnavailableException(alluxio.exception.status.UnavailableException) NotFoundException(alluxio.exception.status.NotFoundException) IOException(java.io.IOException) AlluxioURI(alluxio.AlluxioURI)

Aggregations

UnavailableException (alluxio.exception.status.UnavailableException)58 IOException (java.io.IOException)25 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)10 AlluxioURI (alluxio.AlluxioURI)9 AlluxioStatusException (alluxio.exception.status.AlluxioStatusException)9 NotFoundException (alluxio.exception.status.NotFoundException)9 InetSocketAddress (java.net.InetSocketAddress)9 BlockInfo (alluxio.wire.BlockInfo)8 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)7 WorkerNetAddress (alluxio.wire.WorkerNetAddress)7 WorkerInfo (alluxio.wire.WorkerInfo)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 Set (java.util.Set)6 RetryPolicy (alluxio.retry.RetryPolicy)5 TimeoutException (java.util.concurrent.TimeoutException)5 BlockInfoException (alluxio.exception.BlockInfoException)4 ExceptionMessage (alluxio.exception.ExceptionMessage)4 InodeFile (alluxio.master.file.meta.InodeFile)4