Search in sources :

Example 11 with BlockWorker

use of alluxio.worker.block.BlockWorker in project alluxio by Alluxio.

the class BlockMasterIntegrityIntegrationTest method deleteOrphanedBlocks.

@Test
public void deleteOrphanedBlocks() throws Exception {
    AlluxioURI uri = new AlluxioURI("/test");
    int len = 10;
    FileSystem fs = mCluster.getClient();
    BlockWorker worker = mCluster.getWorkerProcess().getWorker(BlockWorker.class);
    FileSystemTestUtils.createByteFile(fs, uri, WritePType.MUST_CACHE, len);
    Assert.assertEquals(1, worker.getStoreMetaFull().getNumberOfBlocks());
    mCluster.stopWorkers();
    fs.delete(uri);
    mCluster.restartMasters();
    // creates a new worker, so need to get the new BlockWorker
    mCluster.startWorkers();
    BlockWorker newWorker = mCluster.getWorkerProcess().getWorker(BlockWorker.class);
    CommonUtils.waitFor("orphan blocks to be deleted", () -> newWorker.getStoreMetaFull().getNumberOfBlocks() == 0, WaitForOptions.defaults().setTimeoutMs(2000));
}
Also used : FileSystem(alluxio.client.file.FileSystem) AlluxioURI(alluxio.AlluxioURI) BlockWorker(alluxio.worker.block.BlockWorker) Test(org.junit.Test)

Example 12 with BlockWorker

use of alluxio.worker.block.BlockWorker in project alluxio by Alluxio.

the class BlockMasterIntegrityIntegrationTest method deleteInvalidBlocksPeriodically.

@Test
@LocalAlluxioClusterResource.Config(confParams = { PropertyKey.Name.MASTER_PERIODIC_BLOCK_INTEGRITY_CHECK_INTERVAL, "1sec", PropertyKey.Name.MASTER_PERIODIC_BLOCK_INTEGRITY_CHECK_REPAIR, "true" })
public void deleteInvalidBlocksPeriodically() throws Exception {
    AlluxioURI uri = new AlluxioURI("/test");
    int len = 10;
    FileSystem fs = mCluster.getClient();
    BlockWorker worker = mCluster.getWorkerProcess().getWorker(BlockWorker.class);
    FileSystemTestUtils.createByteFile(fs, uri, WritePType.MUST_CACHE, len);
    Assert.assertEquals(1, worker.getStoreMetaFull().getNumberOfBlocks());
    removeFileMetadata(uri);
    CommonUtils.waitFor("invalid blocks to be deleted", () -> worker.getStoreMetaFull().getNumberOfBlocks() == 0, WaitForOptions.defaults().setTimeoutMs(2000));
}
Also used : FileSystem(alluxio.client.file.FileSystem) AlluxioURI(alluxio.AlluxioURI) BlockWorker(alluxio.worker.block.BlockWorker) Test(org.junit.Test)

Aggregations

BlockWorker (alluxio.worker.block.BlockWorker)12 Test (org.junit.Test)10 AlluxioURI (alluxio.AlluxioURI)5 BlockInfo (alluxio.wire.BlockInfo)5 FileSystem (alluxio.client.file.FileSystem)4 URIStatus (alluxio.client.file.URIStatus)4 TieredIdentityFactory (alluxio.network.TieredIdentityFactory)3 WorkerNetAddress (alluxio.wire.WorkerNetAddress)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 BlockInStream (alluxio.client.block.stream.BlockInStream)2 FileOutStream (alluxio.client.file.FileOutStream)2 InStreamOptions (alluxio.client.file.options.InStreamOptions)2 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)2 BlockMaster (alluxio.master.block.BlockMaster)2 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)2 FileBlockInfo (alluxio.wire.FileBlockInfo)2 FileInfo (alluxio.wire.FileInfo)2 AlluxioConfiguration (alluxio.conf.AlluxioConfiguration)1 BlockAlreadyExistsException (alluxio.exception.BlockAlreadyExistsException)1 BlockDoesNotExistException (alluxio.exception.BlockDoesNotExistException)1