HDDS-1388. Add a shell script to run MiniOzoneChaosCluster using mvn exec. Contributed by Mukul Kumar Singh. (#709)
This commit is contained in:
parent
cfec455c45
commit
312d4d4cc5
@ -189,6 +189,8 @@ public AllocatedBlock allocateBlock(final long size, ReplicationType type,
|
|||||||
// factors are handled by pipeline creator
|
// factors are handled by pipeline creator
|
||||||
pipeline = pipelineManager.createPipeline(type, factor);
|
pipeline = pipelineManager.createPipeline(type, factor);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
LOG.error("pipeline creation failed type:{} factor:{}", type,
|
||||||
|
factor, e);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
35
hadoop-ozone/integration-test/src/test/bin/start-chaos.sh
Executable file
35
hadoop-ozone/integration-test/src/test/bin/start-chaos.sh
Executable file
@ -0,0 +1,35 @@
|
|||||||
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
|
# this work for additional information regarding copyright ownership.
|
||||||
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
# (the "License"); you may not use this file except in compliance with
|
||||||
|
# the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
date=`date +"%m-%d-%y-%T"`
|
||||||
|
fileformat=".MiniOzoneChaosCluster.log"
|
||||||
|
heapformat=".dump"
|
||||||
|
current="/tmp/"
|
||||||
|
filename=$current$date$fileformat
|
||||||
|
heapdumpfile=$current$date$heapformat
|
||||||
|
|
||||||
|
export MAVEN_OPTS="-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath={$heapdumpfile}"
|
||||||
|
|
||||||
|
echo "logging to" ${filename}
|
||||||
|
echo "heapdump to" ${heapdumpfile}
|
||||||
|
|
||||||
|
echo "Starting MiniOzoneChaosCluster"
|
||||||
|
mvn clean install -DskipTests > ${filename} 2>&1
|
||||||
|
mvn exec:java \
|
||||||
|
-Dexec.mainClass="org.apache.hadoop.ozone.TestMiniChaosOzoneCluster" \
|
||||||
|
-Dexec.classpathScope=test \
|
||||||
|
-Dexec.args="$*" >> ${filename} 2>&1
|
@ -66,6 +66,7 @@ public MiniOzoneChaosCluster(OzoneConfiguration conf,
|
|||||||
|
|
||||||
this.executorService = Executors.newSingleThreadScheduledExecutor();
|
this.executorService = Executors.newSingleThreadScheduledExecutor();
|
||||||
this.numDatanodes = getHddsDatanodes().size();
|
this.numDatanodes = getHddsDatanodes().size();
|
||||||
|
LOG.info("Starting MiniOzoneChaosCluster with:{} datanodes" + numDatanodes);
|
||||||
LogUtils.setLogLevel(GrpcClientProtocolClient.LOG, Level.WARN);
|
LogUtils.setLogLevel(GrpcClientProtocolClient.LOG, Level.WARN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,14 +118,17 @@ private void fail() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void startChaos(long initialDelay, long period, TimeUnit timeUnit) {
|
void startChaos(long initialDelay, long period, TimeUnit timeUnit) {
|
||||||
|
LOG.info("Starting Chaos with failure period:{} unit:{}", period, timeUnit);
|
||||||
scheduledFuture = executorService.scheduleAtFixedRate(this::fail,
|
scheduledFuture = executorService.scheduleAtFixedRate(this::fail,
|
||||||
initialDelay, period, timeUnit);
|
initialDelay, period, timeUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void stopChaos() throws Exception {
|
void stopChaos() throws Exception {
|
||||||
|
if (scheduledFuture != null) {
|
||||||
scheduledFuture.cancel(false);
|
scheduledFuture.cancel(false);
|
||||||
scheduledFuture.get();
|
scheduledFuture.get();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
super.shutdown();
|
super.shutdown();
|
||||||
@ -192,6 +196,7 @@ void initializeConfiguration() throws IOException {
|
|||||||
1, TimeUnit.SECONDS);
|
1, TimeUnit.SECONDS);
|
||||||
conf.setTimeDuration(HddsConfigKeys.HDDS_HEARTBEAT_INTERVAL, 1,
|
conf.setTimeDuration(HddsConfigKeys.HDDS_HEARTBEAT_INTERVAL, 1,
|
||||||
TimeUnit.SECONDS);
|
TimeUnit.SECONDS);
|
||||||
|
conf.setInt(OzoneConfigKeys.OZONE_CONTAINER_CACHE_SIZE, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -81,7 +81,8 @@ public class MiniOzoneLoadGenerator {
|
|||||||
|
|
||||||
// Start IO load on an Ozone bucket.
|
// Start IO load on an Ozone bucket.
|
||||||
private void load(long runTimeMillis) {
|
private void load(long runTimeMillis) {
|
||||||
LOG.info("Started IO Thread" + Thread.currentThread().getId());
|
long threadID = Thread.currentThread().getId();
|
||||||
|
LOG.info("Started IO Thread:{}.", threadID);
|
||||||
String threadName = Thread.currentThread().getName();
|
String threadName = Thread.currentThread().getName();
|
||||||
long startTime = Time.monotonicNow();
|
long startTime = Time.monotonicNow();
|
||||||
|
|
||||||
@ -98,8 +99,11 @@ private void load(long runTimeMillis) {
|
|||||||
new HashMap<>())) {
|
new HashMap<>())) {
|
||||||
stream.write(buffer.array());
|
stream.write(buffer.array());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("LOADGEN: Create key:{} failed with exception", keyName, e);
|
LOG.error("LOADGEN: Create key:{} failed with exception, skipping",
|
||||||
break;
|
keyName, e);
|
||||||
|
continue;
|
||||||
|
// TODO: HDDS-1403.A key write can fail after multiple block writes
|
||||||
|
// to closed container. add a break here once that is fixed.
|
||||||
}
|
}
|
||||||
|
|
||||||
try (OzoneInputStream stream = ozoneBucket.readKey(keyName)) {
|
try (OzoneInputStream stream = ozoneBucket.readKey(keyName)) {
|
||||||
@ -119,17 +123,20 @@ private void load(long runTimeMillis) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("Read key:{} failed with exception", keyName, e);
|
LOG.error("LOADGEN: Read key:{} failed with exception", keyName, e);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// This will terminate other threads too.
|
// This will terminate other threads too.
|
||||||
isWriteThreadRunning.set(false);
|
isWriteThreadRunning.set(false);
|
||||||
|
LOG.info("Terminating IO thread:{}.", threadID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startIO(long time, TimeUnit timeUnit) {
|
public void startIO(long time, TimeUnit timeUnit) {
|
||||||
List<CompletableFuture<Void>> writeFutures = new ArrayList<>();
|
List<CompletableFuture<Void>> writeFutures = new ArrayList<>();
|
||||||
|
LOG.info("Starting MiniOzoneLoadGenerator for time {}:{} with {} buffers " +
|
||||||
|
"and {} threads", time, timeUnit, numBuffers, numWriteThreads);
|
||||||
if (isWriteThreadRunning.compareAndSet(false, true)) {
|
if (isWriteThreadRunning.compareAndSet(false, true)) {
|
||||||
// Start the IO thread
|
// Start the IO thread
|
||||||
for (int i = 0; i < numWriteThreads; i++) {
|
for (int i = 0; i < numWriteThreads; i++) {
|
||||||
|
@ -96,7 +96,7 @@ public static void shutdown() {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
init();
|
init();
|
||||||
cluster.startChaos(5, failureInterval, TimeUnit.SECONDS);
|
cluster.startChaos(failureInterval, failureInterval, TimeUnit.SECONDS);
|
||||||
loadGenerator.startIO(numMinutes, TimeUnit.MINUTES);
|
loadGenerator.startIO(numMinutes, TimeUnit.MINUTES);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
} finally {
|
} finally {
|
||||||
@ -109,8 +109,8 @@ public static void main(String... args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReadWriteWithChaosCluster() throws Exception {
|
public void testReadWriteWithChaosCluster() {
|
||||||
cluster.startChaos(5, 1, TimeUnit.SECONDS);
|
cluster.startChaos(5, 10, TimeUnit.SECONDS);
|
||||||
loadGenerator.startIO(1, TimeUnit.MINUTES);
|
loadGenerator.startIO(1, TimeUnit.MINUTES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user