Search in sources :

Example 1 with SeedManager

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));
        }
    };
}
Also used : StressProfile(org.apache.cassandra.stress.StressProfile) Timer(org.apache.cassandra.stress.report.Timer) PartitionGenerator(org.apache.cassandra.stress.generate.PartitionGenerator) Matcher(java.util.regex.Matcher) TokenRangeIterator(org.apache.cassandra.stress.generate.TokenRangeIterator) SeedManager(org.apache.cassandra.stress.generate.SeedManager) SampledOpDistributionFactory(org.apache.cassandra.stress.operations.SampledOpDistributionFactory) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with SeedManager

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);
        }
    };
}
Also used : Timer(org.apache.cassandra.stress.report.Timer) SeedManager(org.apache.cassandra.stress.generate.SeedManager) OpDistributionFactory(org.apache.cassandra.stress.operations.OpDistributionFactory) MeasurementSink(org.apache.cassandra.stress.StressAction.MeasurementSink) FixedOpDistribution(org.apache.cassandra.stress.operations.FixedOpDistribution)

Aggregations

SeedManager (org.apache.cassandra.stress.generate.SeedManager)2 Timer (org.apache.cassandra.stress.report.Timer)2 LinkedHashMap (java.util.LinkedHashMap)1 Matcher (java.util.regex.Matcher)1 MeasurementSink (org.apache.cassandra.stress.StressAction.MeasurementSink)1 StressProfile (org.apache.cassandra.stress.StressProfile)1 PartitionGenerator (org.apache.cassandra.stress.generate.PartitionGenerator)1 TokenRangeIterator (org.apache.cassandra.stress.generate.TokenRangeIterator)1 FixedOpDistribution (org.apache.cassandra.stress.operations.FixedOpDistribution)1 OpDistributionFactory (org.apache.cassandra.stress.operations.OpDistributionFactory)1 SampledOpDistributionFactory (org.apache.cassandra.stress.operations.SampledOpDistributionFactory)1