use of org.apache.ignite.loadtest.GridLoadTestStatistics in project ignite by apache.
the class SingleSplitsLoadTest method testLoad.
/**
* Load test grid.
*
* @throws Exception If task execution failed.
*/
public void testLoad() throws Exception {
final Ignite ignite = G.ignite(getTestIgniteInstanceName());
final long end = getTestDurationInMinutes() * 60 * 1000 + System.currentTimeMillis();
// Warm up.
ignite.compute().withTimeout(5000).execute(SingleSplitTestTask.class.getName(), 3);
info("Load test will be executed for '" + getTestDurationInMinutes() + "' mins.");
info("Thread count: " + getThreadCount());
final GridLoadTestStatistics stats = new GridLoadTestStatistics();
GridTestUtils.runMultiThreaded(new Runnable() {
/** {@inheritDoc} */
@Override
public void run() {
while (end - System.currentTimeMillis() > 0) {
long start = System.currentTimeMillis();
try {
int levels = 20;
ComputeTaskFuture<Integer> fut = ignite.compute().executeAsync(new SingleSplitTestTask(), levels);
int res = fut.get();
if (res != levels)
fail("Received wrong result [expected=" + levels + ", actual=" + res + ']');
long taskCnt = stats.onTaskCompleted(fut, levels, System.currentTimeMillis() - start);
if (taskCnt % 500 == 0)
info(stats.toString());
} catch (IgniteException e) {
error("Failed to execute grid task.", e);
fail();
}
}
}
}, getThreadCount(), "grid-notaop-load-test");
info("Final test statistics: " + stats);
}
use of org.apache.ignite.loadtest.GridLoadTestStatistics in project ignite by apache.
the class GridMultiSplitsLoadTest method testLoad.
/**
* Load test grid.
*
* @throws Exception If task execution failed.
*/
public void testLoad() throws Exception {
final Ignite ignite = G.ignite(getTestIgniteInstanceName());
final long end = getTestDurationInMinutes() * 60 * 1000 + System.currentTimeMillis();
// Warm up.
ignite.compute().withTimeout(5000).execute(GridLoadTestTask.class.getName(), 3);
info("Load test will be executed for '" + getTestDurationInMinutes() + "' mins.");
info("Thread count: " + getThreadCount());
final GridLoadTestStatistics stats = new GridLoadTestStatistics();
GridTestUtils.runMultiThreaded(new Runnable() {
/** {@inheritDoc} */
@Override
public void run() {
while (end - System.currentTimeMillis() > 0) {
int levels = 3;
int exp = factorial(levels);
long start = System.currentTimeMillis();
try {
ComputeTaskFuture<Integer> fut = ignite.compute().executeAsync(GridLoadTestTask.class, levels);
int res = fut.get();
if (res != exp)
fail("Received wrong result [expected=" + exp + ", actual=" + res + ']');
long taskCnt = stats.onTaskCompleted(fut, exp, System.currentTimeMillis() - start);
if (taskCnt % 500 == 0)
info(stats.toString());
} catch (IgniteException e) {
error("Failed to execute grid task.", e);
fail();
}
}
}
}, getThreadCount(), "grid-notaop-load-test");
info("Final test statistics: " + stats);
}
use of org.apache.ignite.loadtest.GridLoadTestStatistics in project ignite by apache.
the class GridSingleSplitsRedeployLoadTest method testLoad.
/**
* Load test grid.
*
* @throws Exception If task execution failed.
*/
public void testLoad() throws Exception {
final Ignite ignite = G.ignite(getTestIgniteInstanceName());
final long end = getTestDurationInMinutes() * 60 * 1000 + System.currentTimeMillis();
ignite.compute().localDeployTask(loadTaskClass(), loadTaskClass().getClassLoader());
info("Load test will be executed for '" + getTestDurationInMinutes() + "' mins.");
info("Thread count: " + getThreadCount());
final GridLoadTestStatistics stats = new GridLoadTestStatistics();
new Thread(new Runnable() {
/** {@inheritDoc} */
@SuppressWarnings("BusyWait")
@Override
public void run() {
try {
while (end - System.currentTimeMillis() > 0) {
Class<? extends ComputeTask<?, ?>> cls = loadTaskClass();
// info("Deploying class: " + cls);
ignite.compute().localDeployTask(cls, cls.getClassLoader());
Thread.sleep(1000);
}
} catch (Exception e) {
error("Failed to deploy grid task.", e);
fail();
}
}
}, "grid-notaop-deploy-load-test").start();
GridTestUtils.runMultiThreaded(new Runnable() {
/** {@inheritDoc} */
@Override
public void run() {
try {
int levels = 3;
while (end - System.currentTimeMillis() > 0) {
long start = System.currentTimeMillis();
// info("Executing task: " + TASK_NAME);
ComputeTaskFuture<Integer> fut = ignite.compute().execute(TASK_NAME, levels);
int res = fut.get();
if (res != levels)
fail("Received wrong result [expected=" + levels + ", actual=" + res + ']');
long taskCnt = stats.onTaskCompleted(fut, levels, System.currentTimeMillis() - start);
if (taskCnt % 500 == 0)
info(stats.toString());
}
} catch (IgniteException e) {
error("Failed to execute grid task.", e);
fail();
}
}
}, getThreadCount(), "grid-notaop-load-test");
info("Final test statistics: " + stats);
}
Aggregations