core activity impl now handles alias defaults

This commit is contained in:
Jonathan Shook 2020-12-02 14:18:26 -06:00
parent 3d2ff55f1c
commit 40897879ec
3 changed files with 15 additions and 10 deletions

View File

@ -34,11 +34,6 @@ public class CqlActivityType implements ActivityType<CqlActivity> {
throw new RuntimeException("Currently, the cql activity type requires yaml/workload activity parameter.");
}
// allow shortcut: yaml parameter provide the default alias name
if (activityDef.getAlias().equals(ActivityDef.DEFAULT_ALIAS)) {
activityDef.getParams().set("alias",yaml.get());
}
return new CqlActivity(activityDef);
}

View File

@ -27,11 +27,6 @@ public class StdoutActivityType implements ActivityType<StdoutActivity> {
".");
}
// allow shortcut: yaml parameter provide the default alias name
if (activityDef.getAlias().equals(ActivityDef.DEFAULT_ALIAS)) {
activityDef.getParams().set("alias",yaml.get());
}
return new StdoutActivity(activityDef);
}

View File

@ -27,6 +27,7 @@ import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Supplier;
@ -52,9 +53,23 @@ public class SimpleActivity implements Activity, ProgressCapable {
private ActivityInstrumentation activityInstrumentation;
private PrintWriter console;
private long startedAtMillis;
private int nameEnumerator = 0;
public SimpleActivity(ActivityDef activityDef) {
this.activityDef = activityDef;
if (activityDef.getAlias().equals(ActivityDef.DEFAULT_ALIAS)) {
Optional<String> workloadOpt = activityDef.getParams().getOptionalString(
"workload",
"yaml"
);
if (workloadOpt.isPresent()) {
activityDef.getParams().set("alias", workloadOpt.get());
} else {
activityDef.getParams().set("alias",
activityDef.getActivityType().toUpperCase(Locale.ROOT)
+ String.valueOf(nameEnumerator++));
}
}
}
public SimpleActivity(String activityDefString) {