Search in sources :

Example 1 with AlluxioBlockStore

use of alluxio.client.block.AlluxioBlockStore in project alluxio by Alluxio.

the class GetUsedBytesCommand method run.

@Override
public void run(CommandLine cl) throws IOException {
    AlluxioBlockStore blockStore = AlluxioBlockStore.create();
    long usedBytes = blockStore.getUsedBytes();
    System.out.println("Used Bytes: " + usedBytes);
}
Also used : AlluxioBlockStore(alluxio.client.block.AlluxioBlockStore)

Example 2 with AlluxioBlockStore

use of alluxio.client.block.AlluxioBlockStore in project alluxio by Alluxio.

the class LocationCommand method runCommand.

@Override
protected void runCommand(AlluxioURI path, CommandLine cl) throws AlluxioException, IOException {
    URIStatus status = mFileSystem.getStatus(path);
    System.out.println(path + " with file id " + status.getFileId() + " is on nodes: ");
    AlluxioBlockStore blockStore = AlluxioBlockStore.create();
    for (long blockId : status.getBlockIds()) {
        for (BlockLocation location : blockStore.getInfo(blockId).getLocations()) {
            System.out.println(location.getWorkerAddress().getHost());
        }
    }
}
Also used : URIStatus(alluxio.client.file.URIStatus) AlluxioBlockStore(alluxio.client.block.AlluxioBlockStore) BlockLocation(alluxio.wire.BlockLocation)

Example 3 with AlluxioBlockStore

use of alluxio.client.block.AlluxioBlockStore in project alluxio by Alluxio.

the class RemoteBlockInStreamIntegrationTest method readTest4.

/**
   * Tests {@link RemoteBlockInStream#read()}. Read from remote data server.
   */
@Test
public void readTest4() 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);
        long blockId = mFileSystem.getStatus(uri).getBlockIds().get(0);
        AlluxioBlockStore blockStore = AlluxioBlockStore.create();
        BlockInfo info = blockStore.getInfo(blockId);
        WorkerNetAddress workerAddr = info.getLocations().get(0).getWorkerAddress();
        RemoteBlockInStream is = RemoteBlockInStream.create(info.getBlockId(), info.getLength(), workerAddr, FileSystemContext.INSTANCE, InStreamOptions.defaults());
        byte[] ret = new byte[k];
        int value = is.read();
        int cnt = 0;
        while (value != -1) {
            Assert.assertTrue(value >= 0);
            Assert.assertTrue(value < 256);
            ret[cnt++] = (byte) value;
            value = is.read();
        }
        Assert.assertEquals(cnt, k);
        Assert.assertTrue(BufferUtils.equalIncreasingByteArray(k, ret));
        is.close();
        Assert.assertTrue(mFileSystem.getStatus(uri).getInMemoryPercentage() == 100);
    }
}
Also used : BlockInfo(alluxio.wire.BlockInfo) WorkerNetAddress(alluxio.wire.WorkerNetAddress) AlluxioBlockStore(alluxio.client.block.AlluxioBlockStore) RemoteBlockInStream(alluxio.client.block.RemoteBlockInStream) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 4 with AlluxioBlockStore

use of alluxio.client.block.AlluxioBlockStore in project alluxio by Alluxio.

the class GetCapacityBytesCommand method run.

@Override
public void run(CommandLine cl) throws IOException {
    AlluxioBlockStore alluxioBlockStore = AlluxioBlockStore.create();
    long capacityBytes = alluxioBlockStore.getCapacityBytes();
    System.out.println("Capacity Bytes: " + capacityBytes);
}
Also used : AlluxioBlockStore(alluxio.client.block.AlluxioBlockStore)

Example 5 with AlluxioBlockStore

use of alluxio.client.block.AlluxioBlockStore in project alluxio by Alluxio.

the class StatCommand method runCommand.

@Override
protected void runCommand(AlluxioURI path, CommandLine cl) throws AlluxioException, IOException {
    URIStatus status = mFileSystem.getStatus(path);
    if (status.isFolder()) {
        System.out.println(path + " is a directory path.");
        System.out.println(status);
    } else {
        System.out.println(path + " is a file path.");
        System.out.println(status);
        System.out.println("Containing the following blocks: ");
        AlluxioBlockStore blockStore = AlluxioBlockStore.create();
        for (long blockId : status.getBlockIds()) {
            System.out.println(blockStore.getInfo(blockId));
        }
    }
}
Also used : URIStatus(alluxio.client.file.URIStatus) AlluxioBlockStore(alluxio.client.block.AlluxioBlockStore)

Aggregations

AlluxioBlockStore (alluxio.client.block.AlluxioBlockStore)6 URIStatus (alluxio.client.file.URIStatus)2 Test (org.junit.Test)2 AlluxioURI (alluxio.AlluxioURI)1 RemoteBlockInStream (alluxio.client.block.RemoteBlockInStream)1 BlockInfo (alluxio.wire.BlockInfo)1 BlockLocation (alluxio.wire.BlockLocation)1 WorkerNetAddress (alluxio.wire.WorkerNetAddress)1