Search in sources :

Example 1 with Timer

use of org.apache.cassandra.stress.report.Timer in project cassandra by apache.

the class SampledOpDistributionFactory method get.

public OpDistribution get(boolean isWarmup, MeasurementSink sink) {
    PartitionGenerator generator = newGenerator();
    List<Pair<Operation, Double>> operations = new ArrayList<>();
    for (Map.Entry<T, Double> ratio : ratios.entrySet()) {
        List<? extends Operation> ops = get(new Timer(ratio.getKey().toString(), sink), generator, ratio.getKey(), isWarmup);
        for (Operation op : ops) operations.add(new Pair<>(op, ratio.getValue() / ops.size()));
    }
    return new SampledOpDistribution(new EnumeratedDistribution<>(operations), clustering.get());
}
Also used : PartitionGenerator(org.apache.cassandra.stress.generate.PartitionGenerator) ArrayList(java.util.ArrayList) Operation(org.apache.cassandra.stress.Operation) Timer(org.apache.cassandra.stress.report.Timer) Map(java.util.Map) Pair(org.apache.commons.math3.util.Pair)

Example 2 with Timer

use of org.apache.cassandra.stress.report.Timer 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)

Example 3 with Timer

use of org.apache.cassandra.stress.report.Timer in project cassandra by apache.

the class SettingsCommandUser method getFactory.

public OpDistributionFactory getFactory(final StressSettings settings) {
    final SeedManager seeds = new SeedManager(settings);
    final TokenRangeIterator tokenRangeIterator = profile.tokenRangeQueries.isEmpty() ? null : new TokenRangeIterator(settings, profile.maybeLoadTokenRanges(settings));
    return new SampledOpDistributionFactory<String>(ratios, clustering) {

        protected List<? extends Operation> get(Timer timer, PartitionGenerator generator, String key, boolean isWarmup) {
            if (key.equalsIgnoreCase("insert"))
                return Collections.singletonList(profile.getInsert(timer, generator, seeds, settings));
            if (key.equalsIgnoreCase("validate"))
                return profile.getValidate(timer, generator, seeds, settings);
            if (profile.tokenRangeQueries.containsKey(key))
                return Collections.singletonList(profile.getBulkReadQueries(key, timer, settings, tokenRangeIterator, isWarmup));
            return Collections.singletonList(profile.getQuery(key, timer, generator, seeds, settings, isWarmup));
        }

        protected PartitionGenerator newGenerator() {
            return profile.newGenerator(settings);
        }
    };
}
Also used : Timer(org.apache.cassandra.stress.report.Timer) PartitionGenerator(org.apache.cassandra.stress.generate.PartitionGenerator) TokenRangeIterator(org.apache.cassandra.stress.generate.TokenRangeIterator) SeedManager(org.apache.cassandra.stress.generate.SeedManager) SampledOpDistributionFactory(org.apache.cassandra.stress.operations.SampledOpDistributionFactory)

Aggregations

Timer (org.apache.cassandra.stress.report.Timer)3 PartitionGenerator (org.apache.cassandra.stress.generate.PartitionGenerator)2 SeedManager (org.apache.cassandra.stress.generate.SeedManager)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Operation (org.apache.cassandra.stress.Operation)1 MeasurementSink (org.apache.cassandra.stress.StressAction.MeasurementSink)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 Pair (org.apache.commons.math3.util.Pair)1