Search in sources :

Example 1 with TierAlias

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);
        }
    }
}
Also used : TierAlias(alluxio.stress.rpc.TierAlias) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) StorageList(alluxio.grpc.StorageList) BlockStoreLocation(alluxio.worker.block.BlockStoreLocation) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 2 with TierAlias

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;
}
Also used : TierAlias(alluxio.stress.rpc.TierAlias) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) RegisterWorkerPRequest(alluxio.grpc.RegisterWorkerPRequest) BlockStoreLocation(alluxio.worker.block.BlockStoreLocation) RegisterStreamer(alluxio.worker.block.RegisterStreamer)

Example 3 with TierAlias

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;
}
Also used : HashMap(java.util.HashMap) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) TierAlias(alluxio.stress.rpc.TierAlias) BlockStoreLocation(alluxio.worker.block.BlockStoreLocation) HashMap(java.util.HashMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

TierAlias (alluxio.stress.rpc.TierAlias)3 BlockStoreLocation (alluxio.worker.block.BlockStoreLocation)3 ImmutableList (com.google.common.collect.ImmutableList)3 List (java.util.List)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 Map (java.util.Map)2 RegisterWorkerPRequest (alluxio.grpc.RegisterWorkerPRequest)1 StorageList (alluxio.grpc.StorageList)1 RegisterStreamer (alluxio.worker.block.RegisterStreamer)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1