Search in sources :

Example 1 with GridLoadTestStatistics

use of org.apache.ignite.loadtest.GridLoadTestStatistics in project ignite by apache.

the class GridifySingleSplitLoadTest method testGridifyLoad.

/**
     * Load test grid.
     *
     * @throws Exception If task execution failed.
     */
@SuppressWarnings("unchecked")
public void testGridifyLoad() throws Exception {
    Ignite ignite = G.ignite(getTestIgniteInstanceName());
    ignite.compute().localDeployTask(GridifyLoadTestTask.class, GridifyLoadTestTask.class.getClassLoader());
    final long end = getTestDurationInMinutes() * 60 * 1000 + System.currentTimeMillis();
    // Warm up.
    new GridifyLoadTestJobTarget().executeLoadTestJob(3);
    info("Load test will be executed for '" + getTestDurationInMinutes() + "' mins.");
    info("Thread count: " + getThreadCount());
    final GridLoadTestStatistics stats = new GridLoadTestStatistics();
    GridTestUtils.runMultiThreaded(new Runnable() {

        @Override
        public void run() {
            while (end - System.currentTimeMillis() > 0) {
                int levels = 3;
                int exp = factorial(levels);
                long start = System.currentTimeMillis();
                int res = new GridifyLoadTestJobTarget().executeLoadTestJob(exp);
                if (res != exp)
                    fail("Received wrong result [expected=" + exp + ", actual=" + res + ']');
                long taskCnt = stats.onTaskCompleted(null, exp, System.currentTimeMillis() - start);
                if (taskCnt % 500 == 0)
                    info(stats.toString());
            }
        }
    }, getThreadCount(), "grid-load-test-thread");
    info("Final test statistics: " + stats);
}
Also used : GridLoadTestStatistics(org.apache.ignite.loadtest.GridLoadTestStatistics) Ignite(org.apache.ignite.Ignite)

Example 2 with GridLoadTestStatistics

use of org.apache.ignite.loadtest.GridLoadTestStatistics in project ignite by apache.

the class GridStealingLoadTest method testStealingLoad.

/**
     * @throws Exception If failed.
     */
@SuppressWarnings("unchecked")
public void testStealingLoad() throws Exception {
    final Ignite ignite = grid(0);
    assert ignite != null;
    assert !ignite.cluster().forRemotes().nodes().isEmpty() : "Test requires at least 2 nodes.";
    final UUID stealingNodeId = ignite.cluster().forRemotes().nodes().iterator().next().id();
    info("Set stealing node id to: " + stealingNodeId);
    ignite.compute().localDeployTask(GridStealingLoadTestTask.class, GridStealingLoadTestTask.class.getClassLoader());
    final long end = 2 * 60 * 1000 + System.currentTimeMillis();
    info("Test timeout: " + getTestTimeout() + " ms.");
    info("Thread count: " + getThreadCount());
    final GridLoadTestStatistics stats = new GridLoadTestStatistics();
    final AtomicBoolean failed = new AtomicBoolean(false);
    final AtomicInteger stolen = new AtomicInteger(0);
    GridTestUtils.runMultiThreaded(new Runnable() {

        /** {@inheritDoc} */
        @Override
        public void run() {
            try {
                while (end - System.currentTimeMillis() > 0) {
                    long start = System.currentTimeMillis();
                    // Pass stealing node id.
                    ComputeTaskFuture<?> fut = ignite.compute().withTimeout(20000).execute(GridStealingLoadTestTask.class.getName(), stealingNodeId);
                    stolen.addAndGet((Integer) fut.get());
                    long taskCnt = stats.onTaskCompleted(fut, 1, System.currentTimeMillis() - start);
                    if (taskCnt % 500 == 0)
                        info("Stats [stats=" + stats.toString() + ", stolen=" + stolen + ']');
                }
            } catch (Throwable e) {
                error("Load test failed.", e);
                failed.set(true);
            }
        }
    }, getThreadCount(), "grid-load-test-thread");
    info("Final test statistics: " + stats);
    if (failed.get())
        fail();
    assert stolen.get() != 0 : "No jobs were stolen by stealing node.";
    info("Stolen jobs: " + stolen.get());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ComputeTaskFuture(org.apache.ignite.compute.ComputeTaskFuture) GridLoadTestStatistics(org.apache.ignite.loadtest.GridLoadTestStatistics) Ignite(org.apache.ignite.Ignite) UUID(java.util.UUID)

Example 3 with GridLoadTestStatistics

use of org.apache.ignite.loadtest.GridLoadTestStatistics in project ignite by apache.

the class GridMultiSplitsRedeployLoadTest method testLoad.

/**
     * Load test grid.
     *
     * @throws Exception If task execution failed.
     */
public void testLoad() throws Exception {
    final Ignite ignite = G.ignite(getTestIgniteInstanceName());
    deployTask(ignite);
    final long end = getTestDurationInMinutes() * 60 * 1000 + System.currentTimeMillis();
    // Warm up.
    ignite.compute().withTimeout(10000).execute(TASK_TYPE_ID, 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().withTimeout(10000).execute(TASK_TYPE_ID, 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 % 100 == 0) {
                        try {
                            deployTask(ignite);
                        } catch (Exception e) {
                            error("Failed to deploy grid task.", e);
                            fail();
                        }
                    }
                    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);
}
Also used : IgniteException(org.apache.ignite.IgniteException) ComputeTaskFuture(org.apache.ignite.compute.ComputeTaskFuture) GridLoadTestStatistics(org.apache.ignite.loadtest.GridLoadTestStatistics) Ignite(org.apache.ignite.Ignite) IgniteException(org.apache.ignite.IgniteException)

Example 4 with GridLoadTestStatistics

use of org.apache.ignite.loadtest.GridLoadTestStatistics in project ignite by apache.

the class GridSingleSplitsNewNodesAbstractLoadTest method testLoad.

/**
     * Load test grid.
     *
     * @throws Exception If task execution failed.
     */
public void testLoad() throws Exception {
    final Ignite ignite = startGrid(getTestIgniteInstanceName());
    try {
        final long end = getTestDurationInMinutes() * 60 * 1000 + System.currentTimeMillis();
        // Warm up.
        ignite.compute().execute(GridSingleSplitNewNodesTestTask.class.getName(), 3);
        info("Load test will be executed for '" + getTestDurationInMinutes() + "' mins.");
        info("Thread count: " + getThreadCount());
        final GridLoadTestStatistics stats = new GridLoadTestStatistics();
        final AtomicInteger gridIdx = new AtomicInteger(0);
        for (int i = 0; i < getNodeCount(); i++) {
            new Thread(new Runnable() {

                /** {@inheritDoc} */
                @SuppressWarnings("BusyWait")
                @Override
                public void run() {
                    try {
                        while (end - System.currentTimeMillis() > 0 && !Thread.currentThread().isInterrupted()) {
                            int idx = gridIdx.incrementAndGet();
                            startGrid(idx);
                            Thread.sleep(grid(idx).configuration().getMetricsUpdateFrequency() * 3);
                            stopGrid(idx);
                            Thread.sleep(grid(idx).configuration().getMetricsUpdateFrequency() * 3);
                        }
                    } catch (Throwable e) {
                        error("Failed to start new node.", e);
                        fail();
                    }
                }
            }, "grid-notaop-nodes-load-test").start();
        }
        GridTestUtils.runMultiThreaded(new Runnable() {

            /** {@inheritDoc} */
            @Override
            public void run() {
                while (end - System.currentTimeMillis() > 0 && !Thread.currentThread().isInterrupted()) {
                    long start = System.currentTimeMillis();
                    try {
                        int levels = 3;
                        ComputeTaskFuture<Integer> fut = ignite.compute().executeAsync(new GridSingleSplitNewNodesTestTask(), 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 (Throwable e) {
                        error("Failed to execute grid task.", e);
                        fail();
                    }
                }
            }
        }, getThreadCount(), "grid-notaop-load-test");
        info("Final test statistics: " + stats);
    } finally {
        G.stop(getTestIgniteInstanceName(), false);
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ComputeTaskFuture(org.apache.ignite.compute.ComputeTaskFuture) GridLoadTestStatistics(org.apache.ignite.loadtest.GridLoadTestStatistics) Ignite(org.apache.ignite.Ignite)

Example 5 with GridLoadTestStatistics

use of org.apache.ignite.loadtest.GridLoadTestStatistics in project ignite by apache.

the class GridSessionLoadTest method testSessionLoad.

/**
     * @throws Exception If failed.
     */
@SuppressWarnings("unchecked")
public void testSessionLoad() throws Exception {
    final Ignite ignite = G.ignite(getTestIgniteInstanceName());
    assert ignite != null;
    ignite.compute().localDeployTask(GridSessionLoadTestTask.class, GridSessionLoadTestTask.class.getClassLoader());
    final long end = getTestDurationInMinutes() * 60 * 1000 + System.currentTimeMillis();
    info("Load test will be executed for '" + getTestDurationInMinutes() + "' mins.");
    info("Thread count: " + getThreadCount());
    final GridLoadTestStatistics stats = new GridLoadTestStatistics();
    final AtomicBoolean failed = new AtomicBoolean(false);
    GridTestUtils.runMultiThreaded(new Runnable() {

        /** {@inheritDoc} */
        @Override
        public void run() {
            try {
                while (end - System.currentTimeMillis() > 0) {
                    long start = System.currentTimeMillis();
                    ComputeTaskFuture<?> fut = ignite.compute().withTimeout(10000).execute(GridSessionLoadTestTask.class.getName(), ignite.cluster().nodes().size());
                    Object res = fut.get();
                    assert (Boolean) res;
                    long taskCnt = stats.onTaskCompleted(fut, 1, System.currentTimeMillis() - start);
                    if (taskCnt % 500 == 0)
                        info(stats.toString());
                }
            } catch (Throwable e) {
                error("Load test failed.", e);
                failed.set(true);
            }
        }
    }, getThreadCount(), "grid-load-test-thread");
    info("Final test statistics: " + stats);
    if (failed.get())
        fail();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ComputeTaskFuture(org.apache.ignite.compute.ComputeTaskFuture) GridLoadTestStatistics(org.apache.ignite.loadtest.GridLoadTestStatistics) Ignite(org.apache.ignite.Ignite)

Aggregations

Ignite (org.apache.ignite.Ignite)8 GridLoadTestStatistics (org.apache.ignite.loadtest.GridLoadTestStatistics)8 ComputeTaskFuture (org.apache.ignite.compute.ComputeTaskFuture)7 IgniteException (org.apache.ignite.IgniteException)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 UUID (java.util.UUID)1