Search in sources :

Example 1 with UfsInfo

use of alluxio.grpc.UfsInfo in project alluxio by Alluxio.

the class JobUfsManager method get.

@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);
    try (CloseableResource<UnderFileSystem> ufsResource = ufsClient.acquireUfsResource()) {
        UnderFileSystem ufs = ufsResource.get();
        ufs.connectFromWorker(NetworkAddressUtils.getConnectHost(NetworkAddressUtils.ServiceType.WORKER_RPC, ServerConfiguration.global()));
    } catch (IOException e) {
        removeMount(mountId);
        throw new UnavailableException(String.format("Failed to connect to UFS %s with id %d", info.getUri(), mountId), e);
    }
    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)

Example 2 with UfsInfo

use of alluxio.grpc.UfsInfo 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

AlluxioURI (alluxio.AlluxioURI)2 NotFoundException (alluxio.exception.status.NotFoundException)2 UnavailableException (alluxio.exception.status.UnavailableException)2 UfsInfo (alluxio.grpc.UfsInfo)2 IOException (java.io.IOException)2