public static BlockLocation createRandom() { BlockLocation result = new BlockLocation(); Random random = new Random(); long workerId = random.nextLong(); WorkerNetAddress workerAddress = WorkerNetAddressTest.createRandom(); String tierAlias = CommonUtils.randomAlphaNumString(random.nextInt(10)); result.setWorkerId(workerId); result.setWorkerAddress(workerAddress); result.setTierAlias(tierAlias); return result; } }
/** * Converts a proto type to a wire type. * * @param blockPLocation the proto type to convert * @return the converted wire type */ public static BlockLocation fromProto(alluxio.grpc.BlockLocation blockPLocation) { BlockLocation blockLocation = new BlockLocation(); blockLocation.setWorkerId(blockPLocation.getWorkerId()); blockLocation.setWorkerAddress(fromProto(blockPLocation.getWorkerAddress())); blockLocation.setTierAlias(blockPLocation.getTierAlias()); return blockLocation; }
.setTierAlias(location.getTier()));
@Test public void getBlockInfo() throws Exception { // Create a worker with a block. long worker1 = mBlockMaster.getWorkerId(NET_ADDRESS_1); long blockId = 1L; long blockLength = 20L; mBlockMaster.workerRegister(worker1, Arrays.asList("MEM"), ImmutableMap.of("MEM", 100L), ImmutableMap.of("MEM", 0L), NO_BLOCKS_ON_TIERS, RegisterWorkerPOptions.getDefaultInstance()); mBlockMaster.commitBlock(worker1, 50L, "MEM", blockId, blockLength); BlockLocation blockLocation = new BlockLocation() .setTierAlias("MEM") .setWorkerAddress(NET_ADDRESS_1) .setWorkerId(worker1); BlockInfo expectedBlockInfo = new BlockInfo() .setBlockId(1L) .setLength(20L) .setLocations(ImmutableList.of(blockLocation)); assertEquals(expectedBlockInfo, mBlockMaster.getBlockInfo(blockId)); }
/** * Creates a new instance of {@link BlockLocation} from a thrift representation. * * @param blockLocation the thrift representation of a block location * @return the instance */ public static BlockLocation fromThrift(alluxio.thrift.BlockLocation blockLocation) { return new BlockLocation() .setWorkerId(blockLocation.getWorkerId()) .setWorkerAddress(WorkerNetAddress.fromThrift(blockLocation.getWorkerAddress())) .setTierAlias(blockLocation.getTierAlias()); }
.setTierAlias(masterBlockLocation.getTierAlias()));