initial commit

This commit is contained in:
Mark Wolters 2024-03-28 13:37:45 -04:00 committed by Jonathan Shook
parent 52863ff38c
commit b744fe880f
2 changed files with 42 additions and 11 deletions

View File

@ -381,16 +381,6 @@ public class NBCLI implements Function<String[], Integer>, NBLabeledElement {
// reporters.start(10, options.getReportInterval());
// }
//
// for (
// final LoggerConfigData histoLogger : options.getHistoLoggerConfigs())
// ActivityMetrics.addHistoLogger(sessionName, histoLogger.pattern, histoLogger.file, histoLogger.interval);
// for (
// final LoggerConfigData statsLogger : options.getStatsLoggerConfigs())
// ActivityMetrics.addStatsLogger(sessionName, statsLogger.pattern, statsLogger.file, statsLogger.interval);
// for (
// final LoggerConfigData classicConfigs : options.getClassicHistoConfigs())
// ActivityMetrics.addClassicHistos(sessionName, classicConfigs.pattern, classicConfigs.file, classicConfigs.interval);
//
// if (options.getConsoleLogLevel().isGreaterOrEqualTo(NBLogLevel.WARN)) {
// options.setWantsStackTraces(true);
// NBCLI.logger.debug(() -> "enabling stack traces since log level is " + options.getConsoleLogLevel());
@ -446,7 +436,12 @@ public class NBCLI implements Function<String[], Integer>, NBLabeledElement {
}
session.create().pushReporter(uri, intervalMs, NBLabels.forKV());
});
for (
final NBCLIOptions.LoggerConfigData histoLogger : options.getHistoLoggerConfigs())
session.addHistoLogger(sessionName, histoLogger.pattern, histoLogger.file, histoLogger.millis);
for (
final NBCLIOptions.LoggerConfigData statsLogger : options.getStatsLoggerConfigs())
session.addStatsLogger(sessionName, statsLogger.pattern, statsLogger.file, statsLogger.millis);
ExecutionResult sessionResult = session.apply(options.getCommands());
logger.info(sessionResult);

View File

@ -20,7 +20,12 @@ import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBInvokableCommand;
import io.nosqlbench.nb.api.components.status.NBHeartbeatComponent;
import io.nosqlbench.nb.api.engine.activityimpl.ActivityDef;
import io.nosqlbench.nb.api.engine.metrics.ClassicHistoListener;
import io.nosqlbench.nb.api.engine.metrics.ClassicTimerListener;
import io.nosqlbench.nb.api.engine.metrics.HistoIntervalLogger;
import io.nosqlbench.nb.api.engine.metrics.HistoStatsLogger;
import io.nosqlbench.nb.api.engine.metrics.instruments.MetricCategory;
import io.nosqlbench.nb.api.engine.util.Unit;
import io.nosqlbench.nb.api.labels.NBLabeledElement;
import io.nosqlbench.nb.api.components.decorators.NBTokenWords;
import io.nosqlbench.engine.cmdstream.Cmd;
@ -31,9 +36,12 @@ import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBCommandResult;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.File;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.regex.Pattern;
/**
* A session represents a single execution of NoSQLBench, whether episodic or persistent under some service layer.
@ -127,5 +135,33 @@ public class NBSession extends NBHeartbeatComponent implements Function<List<Cmd
);
}
public void addHistoLogger(String sessionName, String pattern, String filename, long millis) {
if (filename.contains("_SESSION_")) {
filename = filename.replace("_SESSION_", sessionName);
}
Pattern compiledPattern = Pattern.compile(pattern);
File logfile = new File(filename);
HistoIntervalLogger histoIntervalLogger =
new HistoIntervalLogger(this, sessionName, logfile, compiledPattern, millis);
logger.debug(() -> "Adding " + histoIntervalLogger + " to session " + sessionName);
//get().addListener(histoIntervalLogger);
//metricsCloseables.add(histoIntervalLogger);
}
public void addStatsLogger(String sessionName, String pattern, String filename, long millis) {
if (filename.contains("_SESSION_")) {
filename = filename.replace("_SESSION_", sessionName);
}
Pattern compiledPattern = Pattern.compile(pattern);
File logfile = new File(filename);
HistoStatsLogger histoStatsLogger =
new HistoStatsLogger(this, sessionName, logfile, compiledPattern, millis, TimeUnit.NANOSECONDS);
logger.debug(() -> "Adding " + histoStatsLogger + " to session " + sessionName);
// get().addListener(histoStatsLogger);
// metricsCloseables.add(histoStatsLogger);
}
}