diff --git a/dynamometer-blockgen/src/main/java/com/linkedin/dynamometer/blockgenerator/XMLParser.java b/dynamometer-blockgen/src/main/java/com/linkedin/dynamometer/blockgenerator/XMLParser.java index 3b915c23b2..8b5f069782 100644 --- a/dynamometer-blockgen/src/main/java/com/linkedin/dynamometer/blockgenerator/XMLParser.java +++ b/dynamometer-blockgen/src/main/java/com/linkedin/dynamometer/blockgenerator/XMLParser.java @@ -38,8 +38,9 @@ */ class XMLParser { + // Legacy block id can be negative private static final Pattern BLOCK_PATTERN = - Pattern.compile("(\\d+)(\\d+)(\\d+)"); + Pattern.compile("(-?\\d+)(\\d+)(\\d+)"); private State currentState = State.DEFAULT; private short currentReplication; diff --git a/dynamometer-infra/src/main/java/com/linkedin/dynamometer/SimulatedMultiStorageFSDataset.java b/dynamometer-infra/src/main/java/com/linkedin/dynamometer/SimulatedMultiStorageFSDataset.java index 54cc38bf86..8d565b100f 100644 --- a/dynamometer-infra/src/main/java/com/linkedin/dynamometer/SimulatedMultiStorageFSDataset.java +++ b/dynamometer-infra/src/main/java/com/linkedin/dynamometer/SimulatedMultiStorageFSDataset.java @@ -581,14 +581,26 @@ public synchronized void injectBlocks(String bpid, for (Block b: injectBlocks) { BInfo binfo = new BInfo(bpid, b, false); - blockMaps.get((int) (b.getBlockId() % storages.size())).put(binfo.theBlock, binfo); + long indexOfBlock; + if (b.getBlockId() < 0) { + indexOfBlock = (b.getBlockId() * (-1)) % storages.size(); + } else { + indexOfBlock = b.getBlockId() % storages.size(); + } + blockMaps.get((int) indexOfBlock).put(binfo.theBlock, binfo); } } } /** Get the storage that a given block lives within. */ private SimulatedStorage getStorage(Block b) { - return storages.get((int) (b.getBlockId() % storages.size())); + long indexOfBlock; + if (b.getBlockId() < 0) { + indexOfBlock = (b.getBlockId() * (-1)) % storages.size(); + } else { + indexOfBlock = b.getBlockId() % storages.size(); + } + return storages.get((int) indexOfBlock); } /**