Search in sources :

Example 1 with BenchmarkProbePoint

use of org.yardstickframework.BenchmarkProbePoint in project ignite by apache.

the class CacheEntryEventProbe method start.

/** {@inheritDoc} */
@Override
public void start(BenchmarkDriver drv, BenchmarkConfiguration cfg) throws Exception {
    this.cfg = cfg;
    if (drv instanceof IgniteCacheAbstractBenchmark) {
        IgniteCacheAbstractBenchmark drv0 = (IgniteCacheAbstractBenchmark) drv;
        if (drv0.cache() != null) {
            ContinuousQuery<Integer, Integer> qry = new ContinuousQuery<>();
            final AtomicLong cnt = new AtomicLong();
            qry.setLocalListener(localListener(cnt));
            qryCur = drv0.cache().query(qry);
            buildingService = Executors.newSingleThreadExecutor();
            buildingService.execute(new Runnable() {

                @Override
                public void run() {
                    try {
                        while (!Thread.currentThread().isInterrupted()) {
                            Thread.sleep(1000);
                            long evts = cnt.getAndSet(0);
                            BenchmarkProbePoint pnt = new BenchmarkProbePoint(TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()), new double[] { evts });
                            collectPoint(pnt);
                        }
                    } catch (InterruptedException e) {
                    // No-op.
                    }
                }
            });
            println(cfg, getClass().getSimpleName() + " probe is started.");
        }
    }
    if (qryCur == null)
        errorHelp(cfg, "Can not start " + getClass().getSimpleName() + " probe. Probably, the driver doesn't provide \"cache()\" method.");
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) ContinuousQuery(org.apache.ignite.cache.query.ContinuousQuery) BenchmarkProbePoint(org.yardstickframework.BenchmarkProbePoint)

Aggregations

AtomicLong (java.util.concurrent.atomic.AtomicLong)1 ContinuousQuery (org.apache.ignite.cache.query.ContinuousQuery)1 BenchmarkProbePoint (org.yardstickframework.BenchmarkProbePoint)1