Search in sources :

Example 1 with OpDistributionFactory

use of org.apache.cassandra.stress.operations.OpDistributionFactory in project cassandra by apache.

the class StressAction method warmup.

// type provided separately to support recursive call for mixed command with each command type it is performing
// warmupOutput doesn't need closing
@SuppressWarnings("resource")
private void warmup(OpDistributionFactory operations) {
    // do 25% of iterations as warmup but no more than 50k (by default hotspot compiles methods after 10k invocations)
    int iterations = (settings.command.count > 0 ? Math.min(50000, (int) (settings.command.count * 0.25)) : 50000) * settings.node.nodes.size();
    int threads = 100;
    if (settings.rate.maxThreads > 0)
        threads = Math.min(threads, settings.rate.maxThreads);
    if (settings.rate.threadCount > 0)
        threads = Math.min(threads, settings.rate.threadCount);
    for (OpDistributionFactory single : operations.each()) {
        // we need to warm up all the nodes in the cluster ideally, but we may not be the only stress instance;
        // so warm up all the nodes we're speaking to only.
        output.println(String.format("Warming up %s with %d iterations...", single.desc(), iterations));
        boolean success = null != run(single, threads, iterations, 0, null, null, ResultLogger.NOOP, true);
        if (!success)
            throw new RuntimeException("Failed to execute warmup");
    }
}
Also used : OpDistributionFactory(org.apache.cassandra.stress.operations.OpDistributionFactory)

Example 2 with OpDistributionFactory

use of org.apache.cassandra.stress.operations.OpDistributionFactory 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

OpDistributionFactory (org.apache.cassandra.stress.operations.OpDistributionFactory)2 MeasurementSink (org.apache.cassandra.stress.StressAction.MeasurementSink)1 SeedManager (org.apache.cassandra.stress.generate.SeedManager)1 FixedOpDistribution (org.apache.cassandra.stress.operations.FixedOpDistribution)1 Timer (org.apache.cassandra.stress.report.Timer)1