Search in sources :

Example 1 with NotFoundException

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

the class KodoInputStream method createStream.

@Override
protected InputStream createStream(long startPos, long endPos) throws IOException {
    IOException lastException = null;
    String errorMessage = String.format("Failed to open key: %s", mKey);
    while (mRetryPolicy.attempt()) {
        try {
            return mKodoclent.getObject(mKey, startPos, endPos, mContentLength);
        } catch (NotFoundException e) {
            errorMessage = String.format("Failed to open key: %s attempts: %s error: %s", mKey, mRetryPolicy.getAttemptCount(), e.getMessage());
            // Key does not exist
            lastException = e;
        }
    }
    // Failed after retrying key does not exist
    throw new IOException(errorMessage, lastException);
}
Also used : NotFoundException(alluxio.exception.status.NotFoundException) IOException(java.io.IOException)

Example 2 with NotFoundException

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

the class BlockInStream method create.

/**
 * Creates a {@link BlockInStream}.
 *
 * One of several read behaviors:
 *
 * 1. Domain socket - if the data source is the local worker and the local worker has a domain
 * socket server
 * 2. Short-Circuit - if the data source is the local worker
 * 3. Local Loopback Read - if the data source is the local worker and short circuit is disabled
 * 4. Read from remote worker - if the data source is a remote worker
 * 5. UFS Read from worker - if the data source is UFS, read from the UFS policy's designated
 * worker (ufs -> local or remote worker -> client)
 *
 * @param context the file system context
 * @param info the block info
 * @param dataSource the Alluxio worker which should read the data
 * @param dataSourceType the source location of the block
 * @param options the instream options
 * @return the {@link BlockInStream} object
 */
public static BlockInStream create(FileSystemContext context, BlockInfo info, WorkerNetAddress dataSource, BlockInStreamSource dataSourceType, InStreamOptions options) throws IOException {
    long blockId = info.getBlockId();
    long blockSize = info.getLength();
    if (dataSourceType == BlockInStreamSource.PROCESS_LOCAL) {
        // Interaction between the current client and the worker it embedded to should
        // go through worker internal communication directly without RPC involves
        LOG.debug("Creating worker process local input stream for block {} @ {}", blockId, dataSource);
        return createProcessLocalBlockInStream(context, dataSource, blockId, blockSize, options);
    }
    AlluxioConfiguration alluxioConf = context.getClusterConf();
    boolean shortCircuit = alluxioConf.getBoolean(PropertyKey.USER_SHORT_CIRCUIT_ENABLED);
    boolean shortCircuitPreferred = alluxioConf.getBoolean(PropertyKey.USER_SHORT_CIRCUIT_PREFERRED);
    boolean sourceSupportsDomainSocket = NettyUtils.isDomainSocketSupported(dataSource);
    boolean sourceIsLocal = dataSourceType == BlockInStreamSource.NODE_LOCAL;
    // OR alluxio.user.short.circuit.preferred is true
    if (sourceIsLocal && shortCircuit && (shortCircuitPreferred || !sourceSupportsDomainSocket)) {
        LOG.debug("Creating short circuit input stream for block {} @ {}", blockId, dataSource);
        try {
            return createLocalBlockInStream(context, dataSource, blockId, blockSize, options);
        } catch (NotFoundException e) {
            // Failed to do short circuit read because the block is not available in Alluxio.
            // We will try to read via gRPC. So this exception is ignored.
            LOG.warn("Failed to create short circuit input stream for block {} @ {}. Falling back to " + "network transfer", blockId, dataSource);
        }
    }
    // gRPC
    LOG.debug("Creating gRPC input stream for block {} @ {} from client {} reading through {} (" + "data locates in the local worker {}, shortCircuitEnabled {}, " + "shortCircuitPreferred {}, sourceSupportDomainSocket {})", blockId, dataSource, NetworkAddressUtils.getClientHostName(alluxioConf), dataSource, sourceIsLocal, shortCircuit, shortCircuitPreferred, sourceSupportsDomainSocket);
    return createGrpcBlockInStream(context, dataSource, dataSourceType, blockId, blockSize, options);
}
Also used : NotFoundException(alluxio.exception.status.NotFoundException) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration)

Example 3 with NotFoundException

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

the class SnapshotReplicationManager method sendSnapshotToLeader.

/**
 * Sends a snapshot to the leader.
 *
 * @throws IOException if error occurs while initializing the data stream
 */
public void sendSnapshotToLeader() throws IOException {
    if (mJournalSystem.isLeader()) {
        throw new IllegalStateException("Server is no longer a follower");
    }
    LOG.debug("Checking latest snapshot to send");
    SnapshotInfo snapshot = mStorage.getLatestSnapshot();
    if (snapshot == null) {
        throw new NotFoundException("No snapshot available");
    }
    StreamObserver<UploadSnapshotPResponse> responseObserver = SnapshotUploader.forFollower(mStorage, snapshot);
    try (RaftJournalServiceClient client = getJournalServiceClient()) {
        LOG.info("Sending stream request to {} for snapshot {}", client.getAddress(), snapshot.getTermIndex());
        StreamObserver<UploadSnapshotPRequest> requestObserver = client.uploadSnapshot(responseObserver);
        requestObserver.onNext(UploadSnapshotPRequest.newBuilder().setData(SnapshotData.newBuilder().setSnapshotTerm(snapshot.getTerm()).setSnapshotIndex(snapshot.getIndex()).setOffset(0)).build());
    }
}
Also used : SnapshotInfo(org.apache.ratis.statemachine.SnapshotInfo) SingleFileSnapshotInfo(org.apache.ratis.statemachine.impl.SingleFileSnapshotInfo) FileNotFoundException(java.io.FileNotFoundException) NotFoundException(alluxio.exception.status.NotFoundException) UploadSnapshotPRequest(alluxio.grpc.UploadSnapshotPRequest) UploadSnapshotPResponse(alluxio.grpc.UploadSnapshotPResponse)

Example 4 with NotFoundException

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

the class DefaultBlockMaster method workerRegister.

@Override
public void workerRegister(long workerId, List<String> storageTiers, Map<String, Long> totalBytesOnTiers, Map<String, Long> usedBytesOnTiers, Map<BlockLocation, List<Long>> currentBlocksOnLocation, Map<String, StorageList> lostStorage, RegisterWorkerPOptions options) throws NotFoundException {
    MasterWorkerInfo worker = mWorkers.getFirstByField(ID_INDEX, workerId);
    if (worker == null) {
        worker = findUnregisteredWorker(workerId);
    }
    if (worker == null) {
        throw new NotFoundException(ExceptionMessage.NO_WORKER_FOUND.getMessage(workerId));
    }
    // Gather all blocks on this worker.
    int totalSize = currentBlocksOnLocation.values().stream().mapToInt(List::size).sum();
    HashSet<Long> blocks = new HashSet<>(totalSize);
    for (List<Long> blockIds : currentBlocksOnLocation.values()) {
        blocks.addAll(blockIds);
    }
    // Lock all the locks
    try (LockResource r = worker.lockWorkerMeta(EnumSet.of(WorkerMetaLockSection.STATUS, WorkerMetaLockSection.USAGE, WorkerMetaLockSection.BLOCKS), false)) {
        // Detect any lost blocks on this worker.
        Set<Long> removedBlocks = worker.register(mGlobalStorageTierAssoc, storageTiers, totalBytesOnTiers, usedBytesOnTiers, blocks);
        processWorkerRemovedBlocks(worker, removedBlocks, false);
        processWorkerAddedBlocks(worker, currentBlocksOnLocation);
        processWorkerOrphanedBlocks(worker);
        worker.addLostStorage(lostStorage);
    }
    if (options.getConfigsCount() > 0) {
        for (BiConsumer<Address, List<ConfigProperty>> function : mWorkerRegisteredListeners) {
            WorkerNetAddress workerAddress = worker.getWorkerAddress();
            function.accept(new Address(workerAddress.getHost(), workerAddress.getRpcPort()), options.getConfigsList());
        }
    }
    recordWorkerRegistration(workerId);
    // Update the TS at the end of the process
    worker.updateLastUpdatedTimeMs();
    // Invalidate cache to trigger new build of worker info list
    mWorkerInfoCache.invalidate(WORKER_INFO_CACHE_KEY);
    LOG.info("registerWorker(): {}", worker);
}
Also used : Address(alluxio.wire.Address) WorkerNetAddress(alluxio.wire.WorkerNetAddress) NotFoundException(alluxio.exception.status.NotFoundException) LockResource(alluxio.resource.LockResource) WorkerNetAddress(alluxio.wire.WorkerNetAddress) MasterWorkerInfo(alluxio.master.block.meta.MasterWorkerInfo) ArrayList(java.util.ArrayList) StorageList(alluxio.grpc.StorageList) List(java.util.List) ConcurrentHashSet(alluxio.collections.ConcurrentHashSet) HashSet(java.util.HashSet)

Example 5 with NotFoundException

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

the class UfsFallbackBlockWriteHandler method transferToUfsBlock.

/**
 * Transfers data from block store to UFS.
 *
 * @param context context of this request
 * @param pos number of bytes in block store to write in the UFS block
 */
private void transferToUfsBlock(BlockWriteRequestContext context, long pos) throws Exception {
    OutputStream ufsOutputStream = context.getOutputStream();
    long sessionId = context.getRequest().getSessionId();
    long blockId = context.getRequest().getId();
    TempBlockMeta block = mWorker.getTempBlockMeta(sessionId, blockId);
    if (block == null) {
        throw new NotFoundException("block " + blockId + " not found");
    }
    Preconditions.checkState(Files.copy(Paths.get(block.getPath()), ufsOutputStream) == pos);
}
Also used : OutputStream(java.io.OutputStream) NotFoundException(alluxio.exception.status.NotFoundException) TempBlockMeta(alluxio.worker.block.meta.TempBlockMeta)

Aggregations

NotFoundException (alluxio.exception.status.NotFoundException)20 IOException (java.io.IOException)9 AlluxioURI (alluxio.AlluxioURI)6 UnavailableException (alluxio.exception.status.UnavailableException)6 WorkerNetAddress (alluxio.wire.WorkerNetAddress)5 List (java.util.List)4 BlockWorkerInfo (alluxio.client.block.BlockWorkerInfo)3 BlockWorkerClient (alluxio.client.block.stream.BlockWorkerClient)3 BlockInStream (alluxio.client.block.stream.BlockInStream)2 URIStatus (alluxio.client.file.URIStatus)2 InStreamOptions (alluxio.client.file.options.InStreamOptions)2 AlluxioConfiguration (alluxio.conf.AlluxioConfiguration)2 AlluxioException (alluxio.exception.AlluxioException)2 UfsInfo (alluxio.grpc.UfsInfo)2 ColumnStatisticsInfo (alluxio.grpc.table.ColumnStatisticsInfo)2 Layout (alluxio.grpc.table.Layout)2 PartitionInfo (alluxio.grpc.table.layout.hive.PartitionInfo)2 MasterWorkerInfo (alluxio.master.block.meta.MasterWorkerInfo)2 LockResource (alluxio.resource.LockResource)2 UdbPartition (alluxio.table.common.UdbPartition)2