HDDS-1130. Make BenchMarkBlockManager multi-threaded. Contributed by Lokesh Jain.
This commit is contained in:
parent
51950f149e
commit
1d30fd94c6
|
@ -19,6 +19,7 @@
|
||||||
package org.apache.hadoop.ozone.genesis;
|
package org.apache.hadoop.ozone.genesis;
|
||||||
|
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
|
import org.apache.hadoop.fs.FileUtil;
|
||||||
import org.apache.hadoop.hdds.HddsConfigKeys;
|
import org.apache.hadoop.hdds.HddsConfigKeys;
|
||||||
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
|
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
|
||||||
import org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor;
|
import org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor;
|
||||||
|
@ -46,6 +47,7 @@ import java.io.IOException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
import static org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_DB_CACHE_SIZE_DEFAULT;
|
import static org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_DB_CACHE_SIZE_DEFAULT;
|
||||||
import static org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_DB_CACHE_SIZE_MB;
|
import static org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_DB_CACHE_SIZE_MB;
|
||||||
|
@ -59,9 +61,16 @@ import static org.apache.hadoop.ozone.OzoneConsts.SCM_PIPELINE_DB;
|
||||||
@State(Scope.Thread)
|
@State(Scope.Thread)
|
||||||
public class BenchMarkBlockManager {
|
public class BenchMarkBlockManager {
|
||||||
|
|
||||||
private StorageContainerManager scm;
|
private static String testDir;
|
||||||
private PipelineManager pipelineManager;
|
private static StorageContainerManager scm;
|
||||||
private BlockManager blockManager;
|
private static PipelineManager pipelineManager;
|
||||||
|
private static BlockManager blockManager;
|
||||||
|
private static ReentrantLock lock = new ReentrantLock();
|
||||||
|
|
||||||
|
@Param({"1", "10", "100", "1000", "10000", "100000"})
|
||||||
|
private static int numPipelines;
|
||||||
|
@Param({"3", "10", "100"})
|
||||||
|
private static int numContainersPerPipeline;
|
||||||
|
|
||||||
private static StorageContainerManager getScm(OzoneConfiguration conf,
|
private static StorageContainerManager getScm(OzoneConfiguration conf,
|
||||||
SCMConfigurator configurator) throws IOException,
|
SCMConfigurator configurator) throws IOException,
|
||||||
|
@ -80,25 +89,27 @@ public class BenchMarkBlockManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Setup(Level.Trial)
|
@Setup(Level.Trial)
|
||||||
public void initialize()
|
public static void initialize()
|
||||||
throws IOException, AuthenticationException, InterruptedException {
|
throws IOException, AuthenticationException, InterruptedException {
|
||||||
|
try {
|
||||||
|
lock.lock();
|
||||||
|
if (scm == null) {
|
||||||
OzoneConfiguration conf = new OzoneConfiguration();
|
OzoneConfiguration conf = new OzoneConfiguration();
|
||||||
conf.set(HddsConfigKeys.OZONE_METADATA_DIRS,
|
testDir = GenesisUtil.getTempPath()
|
||||||
GenesisUtil.getTempPath().resolve(RandomStringUtils.randomNumeric(7))
|
.resolve(RandomStringUtils.randomNumeric(7)).toString();
|
||||||
.toString());
|
conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, testDir);
|
||||||
conf.setInt(OZONE_SCM_PIPELINE_OWNER_CONTAINER_COUNT, 100);
|
conf.setInt(OZONE_SCM_PIPELINE_OWNER_CONTAINER_COUNT,
|
||||||
|
numContainersPerPipeline);
|
||||||
final File metaDir = ServerUtils.getScmDbDir(conf);
|
final File metaDir = ServerUtils.getScmDbDir(conf);
|
||||||
final File pipelineDBPath = new File(metaDir, SCM_PIPELINE_DB);
|
final File pipelineDBPath = new File(metaDir, SCM_PIPELINE_DB);
|
||||||
int cacheSize = conf.getInt(OZONE_SCM_DB_CACHE_SIZE_MB,
|
int cacheSize = conf.getInt(OZONE_SCM_DB_CACHE_SIZE_MB,
|
||||||
OZONE_SCM_DB_CACHE_SIZE_DEFAULT);
|
OZONE_SCM_DB_CACHE_SIZE_DEFAULT);
|
||||||
MetadataStore pipelineStore =
|
MetadataStore pipelineStore =
|
||||||
MetadataStoreBuilder.newBuilder()
|
MetadataStoreBuilder.newBuilder().setCreateIfMissing(true)
|
||||||
.setCreateIfMissing(true)
|
.setConf(conf).setDbFile(pipelineDBPath)
|
||||||
.setConf(conf)
|
.setCacheSize(cacheSize * OzoneConsts.MB).build();
|
||||||
.setDbFile(pipelineDBPath)
|
addPipelines(ReplicationFactor.THREE,
|
||||||
.setCacheSize(cacheSize * OzoneConsts.MB)
|
pipelineStore);
|
||||||
.build();
|
|
||||||
addPipelines(100, ReplicationFactor.THREE, pipelineStore);
|
|
||||||
pipelineStore.close();
|
pipelineStore.close();
|
||||||
scm = getScm(conf, new SCMConfigurator());
|
scm = getScm(conf, new SCMConfigurator());
|
||||||
pipelineManager = scm.getPipelineManager();
|
pipelineManager = scm.getPipelineManager();
|
||||||
|
@ -110,16 +121,21 @@ public class BenchMarkBlockManager {
|
||||||
scm.getEventQueue().fireEvent(SCMEvents.CHILL_MODE_STATUS, false);
|
scm.getEventQueue().fireEvent(SCMEvents.CHILL_MODE_STATUS, false);
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Setup(Level.Trial)
|
@Setup(Level.Trial)
|
||||||
public void tearDown() {
|
public static void tearDown() {
|
||||||
if (scm != null) {
|
if (scm != null) {
|
||||||
scm.stop();
|
scm.stop();
|
||||||
scm.join();
|
scm.join();
|
||||||
|
FileUtil.fullyDelete(new File(testDir));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPipelines(int numPipelines, ReplicationFactor factor,
|
private static void addPipelines(ReplicationFactor factor,
|
||||||
MetadataStore pipelineStore) throws IOException {
|
MetadataStore pipelineStore) throws IOException {
|
||||||
List<DatanodeDetails> nodes = new ArrayList<>();
|
List<DatanodeDetails> nodes = new ArrayList<>();
|
||||||
for (int i = 0; i < factor.getNumber(); i++) {
|
for (int i = 0; i < factor.getNumber(); i++) {
|
||||||
|
@ -140,6 +156,7 @@ public class BenchMarkBlockManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Threads(4)
|
||||||
@Benchmark
|
@Benchmark
|
||||||
public void allocateBlockBenchMark(BenchMarkBlockManager state,
|
public void allocateBlockBenchMark(BenchMarkBlockManager state,
|
||||||
Blackhole bh) throws IOException {
|
Blackhole bh) throws IOException {
|
||||||
|
|
Loading…
Reference in New Issue