use of org.apache.cassandra.stress.generate.SeedManager in project cassandra by apache.
the class SettingsCommandUser method getFactory.
public OpDistributionFactory getFactory(final StressSettings settings) {
final SeedManager seeds = new SeedManager(settings);
final Map<String, TokenRangeIterator> tokenRangeIterators = new LinkedHashMap<>();
profiles.forEach((k, v) -> tokenRangeIterators.put(k, (v.tokenRangeQueries.isEmpty() ? null : new TokenRangeIterator(settings, v.maybeLoadTokenRanges(settings)))));
return new SampledOpDistributionFactory<String>(ratios, clustering) {
protected List<? extends Operation> get(Timer timer, String key, boolean isWarmup) {
Matcher m = EXTRACT_SPEC_CMD.matcher(key);
final String profile_name;
final String sub_key;
if (m.matches()) {
profile_name = m.group(1);
sub_key = m.group(2);
} else {
profile_name = default_profile_name;
sub_key = key;
}
if (!profiles.containsKey(profile_name)) {
throw new IllegalArgumentException(String.format("Op name %s contains an invalid profile specname: %s", key, profile_name));
}
StressProfile profile = profiles.get(profile_name);
TokenRangeIterator tokenRangeIterator = tokenRangeIterators.get(profile_name);
PartitionGenerator generator = profile.newGenerator(settings);
if (sub_key.equalsIgnoreCase("insert"))
return Collections.singletonList(profile.getInsert(timer, generator, seeds, settings));
if (sub_key.equalsIgnoreCase("validate"))
return profile.getValidate(timer, generator, seeds, settings);
if (profile.tokenRangeQueries.containsKey(sub_key))
return Collections.singletonList(profile.getBulkReadQueries(sub_key, timer, settings, tokenRangeIterator, isWarmup));
return Collections.singletonList(profile.getQuery(sub_key, timer, generator, seeds, settings, isWarmup));
}
};
}
use of org.apache.cassandra.stress.generate.SeedManager in project cassandra by apache.
the class SettingsCommandPreDefined method getFactory.
public OpDistributionFactory getFactory(final StressSettings settings) {
final SeedManager seeds = new SeedManager(settings);
return new OpDistributionFactory() {
public OpDistribution get(boolean isWarmup, MeasurementSink sink) {
final Timer timer1 = new Timer(type.toString(), sink);
final Timer timer = timer1;
return new FixedOpDistribution(PredefinedOperation.operation(type, timer, newGenerator(settings), seeds, settings, add));
}
public String desc() {
return type.toString();
}
public Iterable<OpDistributionFactory> each() {
return Collections.<OpDistributionFactory>singleton(this);
}
};
}
Aggregations