use of alluxio.stress.rpc.TierAlias in project alluxio by Alluxio.
the class BlockWorkerRegisterStreamIntegrationTest method prepareBlocksOnWorker.
private void prepareBlocksOnWorker(String tierConfig) throws Exception {
List<String> tierAliases = getTierAliases(parseTierConfig(tierConfig));
// Generate block IDs heuristically
Map<TierAlias, List<Integer>> tierConfigMap = parseTierConfig(tierConfig);
Map<BlockStoreLocation, List<Long>> blockMap = RpcBenchPreparationUtils.generateBlockIdOnTiers(tierConfigMap);
for (Map.Entry<BlockStoreLocation, List<Long>> entry : blockMap.entrySet()) {
BlockStoreLocation loc = entry.getKey();
int tierIndex = mTierToIndex.get(loc.tierAlias());
for (long blockId : entry.getValue()) {
mBlockWorker.createBlock(1L, blockId, tierIndex, loc.tierAlias(), 1);
mBlockWorker.commitBlock(1L, blockId, false);
}
}
}
use of alluxio.stress.rpc.TierAlias in project alluxio by Alluxio.
the class RegisterStreamTestUtils method generateRegisterStreamForWorker.
public static List<RegisterWorkerPRequest> generateRegisterStreamForWorker(long workerId) {
List<String> tierAliases = getTierAliases(parseTierConfig(TIER_CONFIG));
// Generate block IDs heuristically
Map<TierAlias, List<Integer>> tierConfigMap = parseTierConfig(TIER_CONFIG);
Map<BlockStoreLocation, List<Long>> blockMap = RpcBenchPreparationUtils.generateBlockIdOnTiers(tierConfigMap);
// We just use the RegisterStreamer to generate the batch of requests
RegisterStreamer registerStreamer = new RegisterStreamer(null, workerId, tierAliases, CAPACITY_MAP, USAGE_MAP, blockMap, LOST_STORAGE, EMPTY_CONFIG);
// Get chunks from the RegisterStreamer
List<RegisterWorkerPRequest> requestChunks = ImmutableList.copyOf(registerStreamer);
int expectedBatchCount = (int) Math.ceil((TIER_BLOCK_TOTAL) / (double) BATCH_SIZE);
assertEquals(expectedBatchCount, requestChunks.size());
return requestChunks;
}
use of alluxio.stress.rpc.TierAlias in project alluxio by Alluxio.
the class RpcBenchPreparationUtils method generateBlockIdOnTiers.
/**
* Generates block IDs according to the storage tier/dir setup.
* In order to avoid block ID colliding with existing blocks, this will generate IDs
* decreasingly from the {@link Long#MAX_VALUE}.
*
* @param tiersConfig the tier/dir block counts
* @return a map of location to generated block lists
*/
public static Map<BlockStoreLocation, List<Long>> generateBlockIdOnTiers(Map<TierAlias, List<Integer>> tiersConfig) {
Map<BlockStoreLocation, List<Long>> blockMap = new HashMap<>();
long blockIdStart = Long.MAX_VALUE;
for (Map.Entry<TierAlias, List<Integer>> tierConfig : tiersConfig.entrySet()) {
List<Integer> dirConfigs = tierConfig.getValue();
for (int i = 0; i < dirConfigs.size(); i++) {
int dirNumBlocks = dirConfigs.get(i);
LOG.info("Found dir on tier {} with {} blocks", tierConfig.getKey(), dirNumBlocks);
BlockStoreLocation loc = new BlockStoreLocation(tierConfig.getKey().toString(), i);
List<Long> blockIds = generateDecreasingNumbers(blockIdStart, dirNumBlocks);
blockMap.put(loc, blockIds);
blockIdStart -= dirNumBlocks;
}
}
return blockMap;
}
Aggregations