modify logger calls for computable messages via closures

This commit is contained in:
Jonathan Shook
2022-12-21 19:37:36 -06:00
parent a06cf565ee
commit 6731937c96
114 changed files with 317 additions and 313 deletions

View File

@@ -110,7 +110,7 @@ public abstract class Cqld4BaseOpDispenser extends BaseOpDispenser<Cqld4CqlOp, C
private Statement showstmt(Statement stmt, boolean input) {
String query = cqlFor(stmt, new StringBuilder());
logger.info("CQL(SIMPLE): " + query);
logger.info(() -> "CQL(SIMPLE): " + query);
return stmt;
}

View File

@@ -66,7 +66,7 @@ public class Cqld4CoreOpMapper implements OpMapper<Op> {
TypeAndTarget<CqlD4OpType, String> target = op.getTypeAndTarget(CqlD4OpType.class, String.class, "type", "stmt");
logger.info("Using " + target.enumId + " statement form for '" + op.getName());
logger.info(() -> "Using " + target.enumId + " statement form for '" + op.getName());
return switch (target.enumId) {
case raw -> new CqlD4RawStmtMapper(adapter, sessionFunc, target.targetFunction).apply(op);

View File

@@ -103,7 +103,7 @@ public class Cqld4FluentGraphOpMapper implements OpMapper<Op> {
try {
loader.loadClass(candidateName);
classNames.add(candidateName);
logger.debug("added import " + candidateName);
logger.debug(() -> "added import " + candidateName);
} catch (Exception e) {
throw new RuntimeException("Class '" + candidateName + "' was not found for fluent imports.");
}

View File

@@ -32,7 +32,7 @@ public class RingAnalyzer implements BundledApp {
CommandLine cli = new CommandLine(cfg);
CommandLine.ParseResult cl = cli.parseArgs(args);
logger.info("filename: " + cfg.filename);
logger.info(() -> "filename: " + cfg.filename);
return 0;
}
}

View File

@@ -117,7 +117,7 @@ public class BindingsAccumulator {
accumulated.forEach((k,v) -> {
inverted.computeIfAbsent(v,def -> new HashSet<>()).add(k);
});
logger.info("computed " + accumulated.size() + " raw bindings, consisting of " + inverted.size() + " unique definitions.");
logger.info(() -> "computed " + accumulated.size() + " raw bindings, consisting of " + inverted.size() + " unique definitions.");
return accumulated;
}
}

View File

@@ -74,7 +74,7 @@ public class CGTextTransformers implements Consumer<List<Map<String, ?>>>, Suppl
Object cfgvalues = cfgmap.get("config");
if (cfgvalues != null) {
configurable.accept((cfgvalues));
logger.info("configured transformer with " + cfgvalues);
logger.info(() -> "configured transformer with " + cfgvalues);
}
}

View File

@@ -92,7 +92,7 @@ public class CGWorkloadExporter implements BundledApp {
@Override
public int applyAsInt(String[] args) {
logger.info("running CQL workload exporter with args:" + Arrays.toString(args));
logger.info(() -> "running CQL workload exporter with args:" + Arrays.toString(args));
if (args.length == 0) {
throw new RuntimeException("Usage example: PROG filepath.cql filepath.yaml");
@@ -195,7 +195,7 @@ public class CGWorkloadExporter implements BundledApp {
private String loadFile(Path path) {
try {
String ddl = Files.readString(path);
logger.info("read " + ddl.length() + " character DDL file");
logger.info(() -> "read " + ddl.length() + " character DDL file");
return ddl;
} catch (IOException e) {
throw new RuntimeException(e);
@@ -348,7 +348,7 @@ public class CGWorkloadExporter implements BundledApp {
blockdata.put("ops", ops);
for (CqlTable table : model.getTableDefs()) {
if (table.getClusteringColumns().size() == 0) {
logger.debug("skipping table " + table.getFullName() + " for scan since there are no clustering columns");
logger.debug(() -> "skipping table " + table.getFullName() + " for scan since there are no clustering columns");
}
ops.put(
namer.nameFor(table, "optype", "scan", "blockname", blockname),

View File

@@ -75,18 +75,18 @@ public class CqlModel {
CqlKeyspaceDef ksdef = getKeyspace(statsKeyspacename);
if (ksdef !=null) {
logger.debug("setting keyspace stats for '" + statsKeyspacename + "'");
logger.debug(() -> "setting keyspace stats for '" + statsKeyspacename + "'");
ksdef.setStats(keyspaceStats);
keyspaceStats.getKeyspaceTables().forEach((tbname, tbstats) -> {
CqlTable table = ksdef.getTable(tbname);
if (table != null) {
table.setStats(tbstats);
} else {
logger.debug(" skipping table '" + statsKeyspacename + "." + tbname + ", since it was not found in the model.");
logger.debug(() -> " skipping table '" + statsKeyspacename + "." + tbname + ", since it was not found in the model.");
}
});
} else {
logger.debug(" skipping keyspace stats for '" + statsKeyspacename + "'");
logger.debug(() -> " skipping keyspace stats for '" + statsKeyspacename + "'");
}
}

View File

@@ -49,7 +49,7 @@ public class CqlModelBuilder extends CqlParserBaseListener {
@Override
public void exitEveryRule(ParserRuleContext ctx) {
if ((counted++ & 0b11111111111111) == 0b10000000000000) {
logger.trace("parsed " + counted + " elements...");
logger.trace(() -> "parsed " + counted + " elements...");
}
}
@@ -59,7 +59,7 @@ public class CqlModelBuilder extends CqlParserBaseListener {
ParseTree parent = node.getParent();
String errorNodeType = parent.getClass().getSimpleName();
logger.info("PARSE ERROR: " + errorNodeType + "\n" + node.getSourceInterval());
logger.info(() -> "PARSE ERROR: " + errorNodeType + "\n" + node.getSourceInterval());
super.visitErrorNode(node);
}

View File

@@ -42,9 +42,9 @@ public class CqlModelParser {
public static CqlModel parse(Path path) {
try {
String ddl = Files.readString(path);
logger.info("read " + ddl.length() + " character DDL file, parsing");
logger.info(() -> "read " + ddl.length() + " character DDL file, parsing");
CqlModel parsed = parse(ddl, null);
logger.info("parsed cql model: " + parsed.getSummaryLine());
logger.info(() -> "parsed cql model: " + parsed.getSummaryLine());
return parsed;
} catch (IOException e) {
@@ -85,7 +85,7 @@ public class CqlModelParser {
}
} catch (Exception e) {
logger.warn("Error while parsing flow:" + e.getMessage());
logger.warn(() -> "Error while parsing flow:" + e.getMessage());
throw e;
// return new ParseResult(e);
}

View File

@@ -59,7 +59,7 @@ public class CGGenStatsInjector implements CGModelTransformer, CGTransformerConf
String histogramPath = config.get("path").toString();
if (histogramPath != null) {
if (!Files.exists(Path.of(histogramPath))) {
logger.info("No tablestats file was found. at '" + histogramPath + "'.");
logger.info(() -> "No tablestats file was found. at '" + histogramPath + "'.");
Object onmissing = config.get("onmissing");
if (onmissing==null || !String.valueOf(onmissing).toLowerCase(Locale.ROOT).equals("skip")) {
logger.error("Unable to load tablestats file from '" + histogramPath + "' because it doesn't exists, and onmissing!=skip.");

View File

@@ -61,10 +61,10 @@ public class CGKeyspaceFilter implements CGModelTransformer, CGTransformerConfig
action = pattern.apply(keyspace);
switch (action) {
case add:
logger.debug("including all definitions in " + keyspace + " with inclusion pattern " + pattern);
logger.debug(() -> "including all definitions in " + keyspace + " with inclusion pattern " + pattern);
break;
case remove:
logger.info("removing all definitions in " + keyspace + " with exclusion pattern " + pattern);
logger.info(() -> "removing all definitions in " + keyspace + " with exclusion pattern " + pattern);
model.removeKeyspaceDef(keyspace);
case inderminate:
}

View File

@@ -93,7 +93,7 @@ public class CGModelTransformers implements
Object cfgvalues = cfgmap.get("config");
if (cfgvalues !=null ) {
configurable.accept((cfgvalues));
logger.info("configured transformer with " + cfgvalues);
logger.info(() -> "configured transformer with " + cfgvalues);
}
}

View File

@@ -108,7 +108,7 @@ public class CGRegexReplacer implements CGTextTransformer, CGTransformerConfigur
while (matcher.find()) {
matcher.appendReplacement(sb, replacement);
// if (matcher.end() - matcher.start() > 10000) {
// logger.info("whoops");
// logger.info(()-> "whoops");
// }
// logger.info("matcher:[" + matcher.group(0) + "][" + matcher.group(1) + "][" + matcher.group(2) + "][" + matcher.group(3));
// logger.info(String.format("\tat %2.2f%%", (float) ((float) matcher.start() / (float) s.length())));

View File

@@ -52,7 +52,7 @@ public class CGUdtReplacer implements CGModelTransformer {
String[] words = typedef.split("\\W+");
for (String word : words) {
if (word.toLowerCase(Locale.ROOT).equals(searchFor.toLowerCase(Locale.ROOT))) {
logger.info("replacing '" + typedef + "' with blob");
logger.info(() -> "replacing '" + typedef + "' with blob");
coldef.setTypeDef("blob");
break;
}

View File

@@ -45,7 +45,7 @@ public class UnusedTableRemover implements CGModelTransformer, CGTransformerConf
String weightedOpsSpec = table.getTableAttributes().getAttribute("weighted_ops");
double weightedOps = Double.parseDouble(weightedOpsSpec);
if (weightedOps < minimumThreshold) {
logger.info(String.format(
logger.info(() -> String.format(
"removing table " + table.getKeyspace().getName() + "." + table.getName() + " with minimum weighted_ops of %1.5f under %1.5f",
weightedOps, minimumThreshold)
);

View File

@@ -72,7 +72,7 @@ public class NameCache {
if (this.path.equals(path)) {
logger.debug("mapfile unchanged '" + path + "'");
} else {
logger.info("mapfile changed from '" + this.path + "' to '" + path + "'");
logger.info(() -> "mapfile changed from '" + this.path + "' to '" + path + "'");
this.path = path;
}
}