Search in sources :

Example 11 with NotFoundException

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

the class AbstractUfsManager method getRoot.

@Override
public UfsClient getRoot() {
    synchronized (this) {
        if (mRootUfsClient == null) {
            String rootUri = ServerConfiguration.getString(PropertyKey.MASTER_MOUNT_TABLE_ROOT_UFS);
            boolean rootReadOnly = ServerConfiguration.getBoolean(PropertyKey.MASTER_MOUNT_TABLE_ROOT_READONLY);
            boolean rootShared = ServerConfiguration.getBoolean(PropertyKey.MASTER_MOUNT_TABLE_ROOT_SHARED);
            Map<String, Object> rootConf = ServerConfiguration.getNestedProperties(PropertyKey.MASTER_MOUNT_TABLE_ROOT_OPTION);
            addMount(IdUtils.ROOT_MOUNT_ID, new AlluxioURI(rootUri), UnderFileSystemConfiguration.defaults(ServerConfiguration.global()).setReadOnly(rootReadOnly).setShared(rootShared).createMountSpecificConf(rootConf));
            try {
                mRootUfsClient = get(IdUtils.ROOT_MOUNT_ID);
            } catch (NotFoundException | UnavailableException e) {
                throw new RuntimeException("We should never reach here", e);
            }
        }
        return mRootUfsClient;
    }
}
Also used : UnavailableException(alluxio.exception.status.UnavailableException) NotFoundException(alluxio.exception.status.NotFoundException) AlluxioURI(alluxio.AlluxioURI)

Example 12 with NotFoundException

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

the class MoveDefinition method runTask.

/**
 * {@inheritDoc}
 *
 * This task will move the given block.
 */
@Override
public SerializableVoid runTask(MoveConfig config, SerializableVoid args, RunTaskContext context) throws Exception {
    long blockId = config.getBlockId();
    String localHostName = NetworkAddressUtils.getConnectHost(ServiceType.WORKER_RPC, ServerConfiguration.global());
    List<BlockWorkerInfo> workerInfoList = context.getFsContext().getCachedWorkers();
    WorkerNetAddress localNetAddress = null;
    for (BlockWorkerInfo workerInfo : workerInfoList) {
        if (workerInfo.getNetAddress().getHost().equals(localHostName)) {
            localNetAddress = workerInfo.getNetAddress();
            break;
        }
    }
    if (localNetAddress == null) {
        String message = String.format("Cannot find a local block worker to move block %d", blockId);
        throw new NotFoundException(message);
    }
    MoveBlockRequest request = MoveBlockRequest.newBuilder().setBlockId(blockId).setMediumType(config.getMediumType()).build();
    try (CloseableResource<BlockWorkerClient> blockWorker = context.getFsContext().acquireBlockWorkerClient(localNetAddress)) {
        blockWorker.get().moveBlock(request);
    }
    return null;
}
Also used : WorkerNetAddress(alluxio.wire.WorkerNetAddress) BlockWorkerInfo(alluxio.client.block.BlockWorkerInfo) MoveBlockRequest(alluxio.grpc.MoveBlockRequest) NotFoundException(alluxio.exception.status.NotFoundException) BlockWorkerClient(alluxio.client.block.stream.BlockWorkerClient)

Example 13 with NotFoundException

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

the class RemoteReadIntegrationTest method remoteReadLock.

/**
 * Tests remote reads lock blocks correctly.
 */
@Test
public void remoteReadLock() throws Exception {
    String uniqPath = PathUtils.uniqPath();
    for (int k = MIN_LEN + DELTA; k <= MAX_LEN; k += DELTA) {
        AlluxioURI uri = new AlluxioURI(uniqPath + "/file_" + k);
        FileSystemTestUtils.createByteFile(mFileSystem, uri, mWriteAlluxio, k);
        URIStatus status = mFileSystem.getStatus(uri);
        InStreamOptions options = new InStreamOptions(status, ServerConfiguration.global());
        long blockId = status.getBlockIds().get(0);
        BlockInfo info = AlluxioBlockStore.create(FileSystemContext.create(ServerConfiguration.global())).getInfo(blockId);
        WorkerNetAddress workerAddr = info.getLocations().get(0).getWorkerAddress();
        BlockInStream is = BlockInStream.create(mFsContext, options.getBlockInfo(blockId), workerAddr, BlockInStreamSource.REMOTE, options);
        Assert.assertEquals(0, is.read());
        mFileSystem.delete(uri);
        // The file has been deleted.
        Assert.assertFalse(mFileSystem.exists(uri));
        // Look! We can still read the deleted file since we have a lock!
        byte[] ret = new byte[k / 2];
        Assert.assertTrue(is.read(ret, 0, k / 2) > 0);
        is.close();
        Assert.assertFalse(mFileSystem.exists(uri));
        // Try to create an in stream again, and it should fail.
        BlockInStream is2 = null;
        try {
            is2 = BlockInStream.create(mFsContext, options.getBlockInfo(blockId), workerAddr, BlockInStreamSource.REMOTE, options);
        } catch (NotFoundException e) {
        // Expected since the file has been deleted.
        } finally {
            if (is2 != null) {
                is2.close();
            }
        }
    }
}
Also used : BlockInStream(alluxio.client.block.stream.BlockInStream) BlockInfo(alluxio.wire.BlockInfo) WorkerNetAddress(alluxio.wire.WorkerNetAddress) NotFoundException(alluxio.exception.status.NotFoundException) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) InStreamOptions(alluxio.client.file.options.InStreamOptions) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 14 with NotFoundException

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

the class DefaultBlockMaster method commitBlock.

// TODO(binfan): check the logic is correct or not when commitBlock is a retry
@Override
public void commitBlock(long workerId, long usedBytesOnTier, String tierAlias, String mediumType, long blockId, long length) throws NotFoundException, UnavailableException {
    LOG.debug("Commit block from workerId: {}, usedBytesOnTier: {}, blockId: {}, length: {}", workerId, usedBytesOnTier, blockId, length);
    MasterWorkerInfo worker = mWorkers.getFirstByField(ID_INDEX, workerId);
    // TODO(peis): Check lost workers as well.
    if (worker == null) {
        throw new NotFoundException(ExceptionMessage.NO_WORKER_FOUND.getMessage(workerId));
    }
    try (JournalContext journalContext = createJournalContext()) {
        // The worker metadata must be locked before the blocks
        try (LockResource lr = worker.lockWorkerMeta(EnumSet.of(WorkerMetaLockSection.USAGE, WorkerMetaLockSection.BLOCKS), false)) {
            try (LockResource r = lockBlock(blockId)) {
                Optional<BlockMeta> block = mBlockStore.getBlock(blockId);
                if (!block.isPresent() || block.get().getLength() != length) {
                    if (block.isPresent() && block.get().getLength() != Constants.UNKNOWN_SIZE) {
                        LOG.warn("Rejecting attempt to change block length from {} to {}", block.get().getLength(), length);
                    } else {
                        mBlockStore.putBlock(blockId, BlockMeta.newBuilder().setLength(length).build());
                        BlockInfoEntry blockInfo = BlockInfoEntry.newBuilder().setBlockId(blockId).setLength(length).build();
                        journalContext.append(JournalEntry.newBuilder().setBlockInfo(blockInfo).build());
                    }
                }
                // Update the block metadata with the new worker location.
                mBlockStore.addLocation(blockId, BlockLocation.newBuilder().setWorkerId(workerId).setTier(tierAlias).setMediumType(mediumType).build());
                // This worker has this block, so it is no longer lost.
                mLostBlocks.remove(blockId);
                // Update the worker information for this new block.
                // TODO(binfan): when retry commitBlock on master is expected, make sure metrics are not
                // double counted.
                worker.addBlock(blockId);
                worker.updateUsedBytes(tierAlias, usedBytesOnTier);
            }
        }
        worker.updateLastUpdatedTimeMs();
    }
}
Also used : LockResource(alluxio.resource.LockResource) JournalContext(alluxio.master.journal.JournalContext) MasterWorkerInfo(alluxio.master.block.meta.MasterWorkerInfo) NotFoundException(alluxio.exception.status.NotFoundException) BlockMeta(alluxio.proto.meta.Block.BlockMeta) BlockInfoEntry(alluxio.proto.journal.Block.BlockInfoEntry)

Example 15 with NotFoundException

use of alluxio.exception.status.NotFoundException 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

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