com.emc.mongoose.load.step.pipeline.PipelineLoadStepClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mongoose-load-step-pipeline Show documentation
Show all versions of mongoose-load-step-pipeline Show documentation
Mongoose is a high-load storage performance testing tool
package com.emc.mongoose.load.step.pipeline;
import com.emc.mongoose.env.Extension;
import com.emc.mongoose.exception.InterruptRunException;
import com.emc.mongoose.item.op.OpType;
import com.emc.mongoose.load.step.client.LoadStepClient;
import com.emc.mongoose.load.step.client.LoadStepClientBase;
import com.emc.mongoose.logging.LogUtil;
import com.emc.mongoose.metrics.MetricsManager;
import com.github.akurilov.commons.reflection.TypeUtil;
import com.github.akurilov.commons.system.SizeInBytes;
import com.github.akurilov.confuse.Config;
import com.github.akurilov.confuse.exceptions.InvalidValuePathException;
import com.github.akurilov.confuse.exceptions.InvalidValueTypeException;
import com.github.akurilov.confuse.impl.BasicConfig;
import org.apache.logging.log4j.Level;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import static com.github.akurilov.commons.collection.TreeUtil.reduceForest;
import static com.github.akurilov.confuse.Config.deepToMap;
public class PipelineLoadStepClient
extends LoadStepClientBase {
public PipelineLoadStepClient(
final Config config, final List extensions, final List ctxConfigs,
final MetricsManager metricsManager
) {
super(config, extensions, ctxConfigs, metricsManager);
}
@Override
@SuppressWarnings("unchecked")
protected T copyInstance(final Config config, final List ctxConfigs) {
return (T) new PipelineLoadStepClient(config, extensions, ctxConfigs, metricsMgr);
}
@Override
protected void init()
throws InterruptRunException, IllegalStateException {
final String autoStepId = "pipeline_" + LogUtil.getDateTimeStamp();
final Config stepConfig = config.configVal("load-step");
if(stepConfig.boolVal("idAutoGenerated")) {
stepConfig.val("id", autoStepId);
}
final int subStepCount = ctxConfigs.size();
for(int originIndex = 0; originIndex < subStepCount; originIndex++) {
final Map mergedConfigTree = reduceForest(
Arrays.asList(deepToMap(config), deepToMap(ctxConfigs.get(originIndex)))
);
final Config subConfig;
try {
subConfig = new BasicConfig(config.pathSep(), config.schema(), mergedConfigTree);
} catch(final InvalidValueTypeException | InvalidValuePathException e) {
LogUtil.exception(Level.FATAL, e, "Scenario syntax error");
throw new InterruptRunException(e);
}
final OpType opType = OpType.valueOf(subConfig.stringVal("load-op-type").toUpperCase());
final int concurrencyLimit = config.intVal("storage-driver-limit-concurrency");
final Config outputConfig = subConfig.configVal("output");
final Config metricsConfig = outputConfig.configVal("metrics");
final SizeInBytes itemDataSize;
final Object itemDataSizeRaw = config.val("item-data-size");
if(itemDataSizeRaw instanceof String) {
itemDataSize = new SizeInBytes((String) itemDataSizeRaw);
} else {
itemDataSize = new SizeInBytes(TypeUtil.typeConvert(itemDataSizeRaw, long.class));
}
final boolean colorFlag = outputConfig.boolVal("color");
initMetrics(originIndex, opType, concurrencyLimit, metricsConfig, itemDataSize, colorFlag);
}
}
@Override
public String getTypeName() {
return PipelineLoadStepExtension.TYPE;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy