http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/direct/multisplit/GridLoadTestJob.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/direct/multisplit/GridLoadTestJob.java b/modules/core/src/test/java/org/gridgain/loadtests/direct/multisplit/GridLoadTestJob.java deleted file mode 100644 index dfe783f..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/direct/multisplit/GridLoadTestJob.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.gridgain.loadtests.direct.multisplit; - -import org.apache.ignite.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.resources.*; -import org.gridgain.grid.*; - -import java.io.*; - -/** - * Load test job. - */ -public class GridLoadTestJob extends ComputeJobAdapter { - /** */ - @IgniteInstanceResource - private Ignite ignite; - - /** - * Constructor. - * @param arg Argument. - */ - public GridLoadTestJob(Integer arg) { - super(arg); - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override public Serializable execute() throws IgniteCheckedException { - Integer i = this.<Integer>argument(0); - - assert i != null && i > 0; - - if (i == 1) - return new GridLoadTestJobTarget().executeLoadTestJob(1); - - assert ignite != null; - - ignite.compute().localDeployTask(GridLoadTestTask.class, GridLoadTestTask.class.getClassLoader()); - - return (Integer) ignite.compute().execute(GridLoadTestTask.class.getName(), i); - } -}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/direct/multisplit/GridLoadTestJobTarget.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/direct/multisplit/GridLoadTestJobTarget.java b/modules/core/src/test/java/org/gridgain/loadtests/direct/multisplit/GridLoadTestJobTarget.java deleted file mode 100644 index db3e640..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/direct/multisplit/GridLoadTestJobTarget.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.gridgain.loadtests.direct.multisplit; - -/** - * Load test job target. - */ -public class GridLoadTestJobTarget { - /** - * @param level Level. - * @return Always return {@code 1}. - */ - public int executeLoadTestJob(int level) { - assert level > 0; - - return 1; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/direct/multisplit/GridLoadTestTask.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/direct/multisplit/GridLoadTestTask.java b/modules/core/src/test/java/org/gridgain/loadtests/direct/multisplit/GridLoadTestTask.java deleted file mode 100644 index fd4e07a..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/direct/multisplit/GridLoadTestTask.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.gridgain.loadtests.direct.multisplit; - -import org.apache.ignite.*; -import org.apache.ignite.cluster.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.resources.*; -import org.gridgain.grid.*; - -import java.util.*; - -/** - * Load test task. - */ -public class GridLoadTestTask extends ComputeTaskAdapter<Integer, Integer> { - /** Injected job context. */ - @IgniteTaskSessionResource - private ComputeTaskSession ctx; - - /** */ - @SuppressWarnings("unused") - @IgniteInstanceResource - private Ignite ignite; - - /** {@inheritDoc} */ - @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, Integer arg) throws IgniteCheckedException { - assert arg != null; - assert arg > 1; - - Map<GridLoadTestJob, ClusterNode> map = new HashMap<>(subgrid.size()); - - Iterator<ClusterNode> iter = subgrid.iterator(); - - Collection<UUID> assigned = new ArrayList<>(subgrid.size()); - - for (int i = 0; i < arg; i++) { - // Recycle iterator. - if (!iter.hasNext()) - iter = subgrid.iterator(); - - ClusterNode node = iter.next(); - - assigned.add(node.id()); - - map.put(new GridLoadTestJob(arg - 1), node); - } - - ctx.setAttribute("nodes", assigned); - - return map; - } - - /** {@inheritDoc} */ - @Override public Integer reduce(List<ComputeJobResult> results) throws IgniteCheckedException { - assert results != null; - - int retVal = 0; - - for (ComputeJobResult res : results) { - assert res.getException() == null : "Load test jobs can never fail: " + ctx; - assert res.getData() != null; - - retVal += (Integer)res.getData(); - } - - return retVal; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/direct/multisplit/GridMultiSplitsLoadTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/direct/multisplit/GridMultiSplitsLoadTest.java b/modules/core/src/test/java/org/gridgain/loadtests/direct/multisplit/GridMultiSplitsLoadTest.java deleted file mode 100644 index 89d9d5f..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/direct/multisplit/GridMultiSplitsLoadTest.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.gridgain.loadtests.direct.multisplit; - -import org.apache.ignite.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.configuration.*; -import org.gridgain.grid.loadtest.*; -import org.apache.ignite.spi.communication.*; -import org.apache.ignite.spi.communication.tcp.*; -import org.apache.ignite.spi.discovery.*; -import org.apache.ignite.spi.discovery.tcp.*; -import org.apache.ignite.internal.util.typedef.*; -import org.gridgain.testframework.*; -import org.gridgain.testframework.config.*; -import org.gridgain.testframework.junits.common.*; - -import java.util.concurrent.*; - -/** - * Multi-splits load test. - */ -@GridCommonTest(group = "Load Test") -public class GridMultiSplitsLoadTest extends GridCommonAbstractTest { - /** */ - public GridMultiSplitsLoadTest() { - super(true); - } - - - /** {@inheritDoc} */ - @SuppressWarnings("ConstantConditions") - @Override public String getTestGridName() { - return null; - } - - /** {@inheritDoc} */ - @SuppressWarnings("ConstantConditions") - @Override protected IgniteConfiguration getConfiguration() throws Exception { - IgniteConfiguration cfg = super.getConfiguration(); - - CommunicationSpi commSpi = new TcpCommunicationSpi(); - - cfg.setCommunicationSpi(commSpi); - - DiscoverySpi discoSpi = new TcpDiscoverySpi(); - - cfg.setDiscoverySpi(discoSpi); - - ((ThreadPoolExecutor)cfg.getExecutorService()).prestartAllCoreThreads(); - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected long getTestTimeout() { - return (getTestDurationInMinutes() + 1) * 60 * 1000; - } - - /** - * @return Time for load test in minutes. - */ - private int getTestDurationInMinutes() { - return Integer.valueOf(GridTestProperties.getProperty("load.test.duration")); - } - - /** - * @return Number of threads for the test. - */ - private int getThreadCount() { - return Integer.valueOf(GridTestProperties.getProperty("load.test.threadnum")); - } - - /** - * Load test grid. - * - * @throws Exception If task execution failed. - */ - public void testLoad() throws Exception { - final Ignite ignite = G.ignite(getTestGridName()); - - 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() { - IgniteCompute comp = ignite.compute().enableAsync(); - - while (end - System.currentTimeMillis() > 0) { - int levels = 3; - - int exp = factorial(levels); - - long start = System.currentTimeMillis(); - - try { - comp.execute(GridLoadTestTask.class, levels); - - ComputeTaskFuture<Integer> fut = comp.future(); - - 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 (IgniteCheckedException e) { - error("Failed to execute grid task.", e); - - fail(); - } - } - } - }, getThreadCount(), "grid-notaop-load-test"); - - info("Final test statistics: " + stats); - } - - /** - * Calculates factorial. - * - * @param num Factorial to calculate. - * @return Factorial for the number passed in. - */ - private int factorial(int num) { - assert num > 0; - - if (num == 1) - return 1; - - return num * factorial(num -1); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/direct/multisplit/GridMultiSplitsRedeployLoadTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/direct/multisplit/GridMultiSplitsRedeployLoadTest.java b/modules/core/src/test/java/org/gridgain/loadtests/direct/multisplit/GridMultiSplitsRedeployLoadTest.java deleted file mode 100644 index b78a0c3..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/direct/multisplit/GridMultiSplitsRedeployLoadTest.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.gridgain.loadtests.direct.multisplit; - -import org.apache.ignite.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.configuration.*; -import org.gridgain.grid.loadtest.*; -import org.apache.ignite.internal.util.typedef.*; -import org.gridgain.testframework.*; -import org.gridgain.testframework.config.*; -import org.gridgain.testframework.junits.common.*; - -import java.util.concurrent.*; - -/** - * Multi splits redeploy load test. - */ -@GridCommonTest(group = "Load Test") -public class GridMultiSplitsRedeployLoadTest extends GridCommonAbstractTest { - /** Load test task type ID. */ - public static final String TASK_TYPE_ID = GridLoadTestTask.class.getName(); - - /** */ - public GridMultiSplitsRedeployLoadTest() { - super(true); - } - - /** {@inheritDoc} */ - @SuppressWarnings("ConstantConditions") - @Override protected IgniteConfiguration getConfiguration() throws Exception { - IgniteConfiguration cfg = super.getConfiguration(); - - ((ThreadPoolExecutor)cfg.getExecutorService()).prestartAllCoreThreads(); - - return cfg; - } - - /** - * @return Test timeout. - */ - @Override protected long getTestTimeout() { - return (getTestDurationInMinutes() + 1) * 60 * 1000; - } - - /** - * @return Time for load test in minutes. - */ - private int getTestDurationInMinutes() { - return Integer.valueOf(GridTestProperties.getProperty("load.test.duration")); - } - - /** - * @return Number of threads for the test. - */ - private int getThreadCount() { - return Integer.valueOf(GridTestProperties.getProperty("load.test.threadnum")); - } - - /** - * Load test grid. - * - * @throws Exception If task execution failed. - */ - public void testLoad() throws Exception { - final Ignite ignite = G.ignite(getTestGridName()); - - 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 (IgniteCheckedException e) { - error("Failed to deploy grid task.", e); - - fail(); - } - } - - if (taskCnt % 500 == 0) - info(stats.toString()); - } - catch (IgniteCheckedException e) { - error("Failed to execute grid task.", e); - - fail(); - } - } - } - }, getThreadCount(), "grid-notaop-load-test"); - - info("Final test statistics: " + stats); - } - - /** - * @param ignite Grid. - * @throws IgniteCheckedException If failed. - */ - @SuppressWarnings("unchecked") - private void deployTask(Ignite ignite) throws IgniteCheckedException { - ignite.compute().localDeployTask(GridLoadTestTask.class, GridLoadTestTask.class.getClassLoader()); - } - - /** - * Calculates factorial. - * - * @param num Factorial to calculate. - * @return Factorial for the number passed in. - */ - private int factorial(int num) { - assert num > 0; - - return num == 1 ? 1 : num * factorial(num - 1); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/direct/multisplit/package.html ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/direct/multisplit/package.html b/modules/core/src/test/java/org/gridgain/loadtests/direct/multisplit/package.html deleted file mode 100644 index 135eb1a..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/direct/multisplit/package.html +++ /dev/null @@ -1,24 +0,0 @@ -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - --> - -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> -<html> -<body> - <!-- Package description. --> - Contains internal tests or test related classes and interfaces. -</body> -</html> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/direct/newnodes/GridSingleSplitNewNodesTestJobTarget.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/direct/newnodes/GridSingleSplitNewNodesTestJobTarget.java b/modules/core/src/test/java/org/gridgain/loadtests/direct/newnodes/GridSingleSplitNewNodesTestJobTarget.java deleted file mode 100644 index 1b4a0be..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/direct/newnodes/GridSingleSplitNewNodesTestJobTarget.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.gridgain.loadtests.direct.newnodes; - -import org.apache.ignite.*; -import org.apache.ignite.compute.*; - -/** - * Single split on new nodes test job target. - */ -public class GridSingleSplitNewNodesTestJobTarget { - /** - * @param level Level. - * @param jobSes Job session. - * @return Always returns {@code 1}. - * @throws IgniteCheckedException If failed. - */ - @SuppressWarnings("unused") - public int executeLoadTestJob(int level, ComputeTaskSession jobSes) throws IgniteCheckedException { - assert level > 0; - assert jobSes != null; - - try { - assert "1".equals(jobSes.waitForAttribute("1st", 10000)); - - assert "2".equals(jobSes.waitForAttribute("2nd", 10000)); - } - catch (InterruptedException e) { - // Fail. - throw new IgniteCheckedException("Failed to wait for attribute.", e); - } - - return 1; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/direct/newnodes/GridSingleSplitNewNodesTestTask.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/direct/newnodes/GridSingleSplitNewNodesTestTask.java b/modules/core/src/test/java/org/gridgain/loadtests/direct/newnodes/GridSingleSplitNewNodesTestTask.java deleted file mode 100644 index 9cd8d5c..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/direct/newnodes/GridSingleSplitNewNodesTestTask.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.gridgain.loadtests.direct.newnodes; - -import org.apache.ignite.*; -import org.apache.ignite.cluster.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.resources.*; - -import java.io.*; -import java.util.*; - -/** - * Single split on new nodes test task. - */ -public class GridSingleSplitNewNodesTestTask extends ComputeTaskAdapter<Integer, Integer> { - /** */ - @IgniteTaskSessionResource - private ComputeTaskSession taskSes; - - /** */ - @IgniteLoadBalancerResource - private ComputeLoadBalancer balancer; - - /** {@inheritDoc} */ - @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, Integer arg) throws IgniteCheckedException { - assert !subgrid.isEmpty() : "Subgrid cannot be empty."; - - Map<ComputeJobAdapter, ClusterNode> jobs = new HashMap<>(subgrid.size()); - - taskSes.setAttribute("1st", "1"); - taskSes.setAttribute("2nd", "2"); - - Collection<UUID> assigned = new ArrayList<>(subgrid.size()); - - for (int i = 0; i < arg; i++) { - ComputeJobAdapter job = new ComputeJobAdapter(1) { - /** */ - @IgniteTaskSessionResource - private ComputeTaskSession jobSes; - - /** {@inheritDoc} */ - @Override public Serializable execute() throws IgniteCheckedException { - assert jobSes != null; - - Integer arg = this.<Integer>argument(0); - - assert arg != null; - - return new GridSingleSplitNewNodesTestJobTarget().executeLoadTestJob(arg, jobSes); - } - }; - - ClusterNode node = balancer.getBalancedNode(job, null); - - assert node != null; - - assigned.add(node.id()); - - jobs.put(job, node); - } - - taskSes.setAttribute("nodes", assigned); - - return jobs; - } - - /** {@inheritDoc} */ - @Override public Integer reduce(List<ComputeJobResult> results) throws IgniteCheckedException { - int retVal = 0; - - for (ComputeJobResult res : results) { - assert res.getData() != null : "Load test should return result: " + res; - - retVal += (Integer)res.getData(); - } - - return retVal; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/direct/newnodes/GridSingleSplitsNewNodesAbstractLoadTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/direct/newnodes/GridSingleSplitsNewNodesAbstractLoadTest.java b/modules/core/src/test/java/org/gridgain/loadtests/direct/newnodes/GridSingleSplitsNewNodesAbstractLoadTest.java deleted file mode 100644 index 5389702..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/direct/newnodes/GridSingleSplitsNewNodesAbstractLoadTest.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.gridgain.loadtests.direct.newnodes; - -import org.apache.ignite.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.configuration.*; -import org.apache.ignite.thread.*; -import org.gridgain.grid.loadtest.*; -import org.apache.ignite.spi.communication.tcp.*; -import org.apache.ignite.spi.discovery.*; -import org.apache.ignite.internal.util.typedef.*; -import org.gridgain.testframework.*; -import org.gridgain.testframework.config.*; -import org.gridgain.testframework.junits.common.*; - -import java.util.concurrent.*; -import java.util.concurrent.atomic.*; - -/** - * Base class for single split on new nodes tests. - */ -@GridCommonTest(group = "Load Test") -public abstract class GridSingleSplitsNewNodesAbstractLoadTest extends GridCommonAbstractTest { - /** - * @param cfg Current configuration. - * @return Configured discovery spi. - */ - protected abstract DiscoverySpi getDiscoverySpi(IgniteConfiguration cfg); - - /** - * @return Discovery spi heartbeat frequency. - */ - protected abstract int getHeartbeatFrequency(); - - /** {@inheritDoc} */ - @SuppressWarnings("ConstantConditions") - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - cfg.setCommunicationSpi(new TcpCommunicationSpi()); - - cfg.setDiscoverySpi(getDiscoverySpi(cfg)); - - cfg.setMetricsHistorySize(1000); - - // Set up new executor service because we have 1 per test and thus all - // nodes have the same executor service. As soon as node get stopped - // it stops executor service and may fail active nodes. - cfg.setExecutorService(new IgniteThreadPoolExecutor()); - - ((ThreadPoolExecutor)cfg.getExecutorService()).prestartAllCoreThreads(); - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected long getTestTimeout() { - return (getTestDurationInMinutes() + 1) * 60 * 1000; - } - - /** - * @return Time for load test in minutes. - */ - private int getTestDurationInMinutes() { - return Integer.valueOf(GridTestProperties.getProperty("load.test.duration")); - } - - /** - * @return Number of threads for the test. - */ - private int getThreadCount() { - return Integer.valueOf(GridTestProperties.getProperty("load.test.threadnum")); - } - - /** - * @return Number of nodes to start/stop. - */ - protected int getNodeCount() { - return Integer.valueOf(GridTestProperties.getProperty("load.test.nodenum")); - } - - /** - * Load test grid. - * - * @throws Exception If task execution failed. - */ - public void testLoad() throws Exception { - final Ignite ignite = startGrid(getTestGridName()); - - 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(getHeartbeatFrequency() * 3); - - stopGrid(idx); - - Thread.sleep(getHeartbeatFrequency() * 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() { - IgniteCompute comp = ignite.compute().enableAsync(); - - while (end - System.currentTimeMillis() > 0 - && !Thread.currentThread().isInterrupted()) { - long start = System.currentTimeMillis(); - - try { - int levels = 3; - - comp.execute(new GridSingleSplitNewNodesTestTask(), levels); - - ComputeTaskFuture<Integer> fut = comp.future(); - - 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(getTestGridName(), false); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/direct/newnodes/GridSingleSplitsNewNodesMulticastLoadTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/direct/newnodes/GridSingleSplitsNewNodesMulticastLoadTest.java b/modules/core/src/test/java/org/gridgain/loadtests/direct/newnodes/GridSingleSplitsNewNodesMulticastLoadTest.java deleted file mode 100644 index d9b2c2b..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/direct/newnodes/GridSingleSplitsNewNodesMulticastLoadTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.gridgain.loadtests.direct.newnodes; - -import org.apache.ignite.configuration.*; -import org.apache.ignite.spi.discovery.*; -import org.apache.ignite.spi.discovery.tcp.*; -import org.gridgain.testframework.junits.common.*; - -/** - * - */ -@GridCommonTest(group = "Load Test") -public class GridSingleSplitsNewNodesMulticastLoadTest extends GridSingleSplitsNewNodesAbstractLoadTest { - /** {@inheritDoc} */ - @Override protected DiscoverySpi getDiscoverySpi(IgniteConfiguration cfg) { - DiscoverySpi discoSpi = cfg.getDiscoverySpi(); - - assert discoSpi instanceof TcpDiscoverySpi : "Wrong default SPI implementation."; - - ((TcpDiscoverySpi)discoSpi).setHeartbeatFrequency(getHeartbeatFrequency()); - - return discoSpi; - } - - /** {@inheritDoc} */ - @Override protected int getHeartbeatFrequency() { - return 3000; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/direct/newnodes/package.html ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/direct/newnodes/package.html b/modules/core/src/test/java/org/gridgain/loadtests/direct/newnodes/package.html deleted file mode 100644 index 135eb1a..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/direct/newnodes/package.html +++ /dev/null @@ -1,24 +0,0 @@ -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - --> - -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> -<html> -<body> - <!-- Package description. --> - Contains internal tests or test related classes and interfaces. -</body> -</html> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/direct/redeploy/GridSingleSplitsRedeployLoadTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/direct/redeploy/GridSingleSplitsRedeployLoadTest.java b/modules/core/src/test/java/org/gridgain/loadtests/direct/redeploy/GridSingleSplitsRedeployLoadTest.java deleted file mode 100644 index 9d939d9..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/direct/redeploy/GridSingleSplitsRedeployLoadTest.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.gridgain.loadtests.direct.redeploy; - -import org.apache.ignite.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.configuration.*; -import org.gridgain.grid.loadtest.*; -import org.apache.ignite.spi.communication.*; -import org.apache.ignite.spi.communication.tcp.*; -import org.apache.ignite.spi.discovery.*; -import org.apache.ignite.spi.discovery.tcp.*; -import org.apache.ignite.internal.util.typedef.*; -import org.gridgain.testframework.*; -import org.gridgain.testframework.config.*; -import org.gridgain.testframework.junits.common.*; - -import java.util.concurrent.*; - -/** - * Single splits redeploy load test. - */ -@GridCommonTest(group = "Load Test") -public class GridSingleSplitsRedeployLoadTest extends GridCommonAbstractTest { - /** Load test task type ID. */ - public static final String TASK_NAME = "org.gridgain.grid.tests.p2p.GridSingleSplitTestTask"; - - /** */ - public GridSingleSplitsRedeployLoadTest() { - super(true); - } - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration() throws Exception { - IgniteConfiguration cfg = super.getConfiguration(); - - CommunicationSpi commSpi = new TcpCommunicationSpi(); - - cfg.setCommunicationSpi(commSpi); - - DiscoverySpi discoSpi = new TcpDiscoverySpi(); - - cfg.setDiscoverySpi(discoSpi); - - ((ThreadPoolExecutor)cfg.getExecutorService()).prestartAllCoreThreads(); - - cfg.setDeploymentMode(IgniteDeploymentMode.CONTINUOUS); - - return cfg; - } - - /** - * @return Test timeout. - */ - @Override protected long getTestTimeout() { - return (getTestDurationInMinutes() + 1) * 60 * 1000; - } - - /** - * @return Time for load test in minutes. - */ - private int getTestDurationInMinutes() { - return Integer.valueOf(GridTestProperties.getProperty("load.test.duration")); - } - - /** - * @return Number of threads for the test. - */ - private int getThreadCount() { - //return 1; - return Integer.valueOf(GridTestProperties.getProperty("load.test.threadnum")); - } - - /** - * Load test grid. - * - * @throws Exception If task execution failed. - */ - public void testLoad() throws Exception { - final Ignite ignite = G.ignite(getTestGridName()); - - 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 (IgniteCheckedException e) { - error("Failed to execute grid task.", e); - - fail(); - } - } - }, getThreadCount(), "grid-notaop-load-test"); - - info("Final test statistics: " + stats); - } - - /** - * @return Loaded task class. - * @throws Exception If failed. - */ - @SuppressWarnings({"unchecked"}) - private Class<? extends ComputeTask<?, ?>> loadTaskClass() throws Exception { - return (Class<? extends ComputeTask<?, ?>>)getExternalClassLoader().loadClass(TASK_NAME); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/direct/redeploy/package.html ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/direct/redeploy/package.html b/modules/core/src/test/java/org/gridgain/loadtests/direct/redeploy/package.html deleted file mode 100644 index 135eb1a..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/direct/redeploy/package.html +++ /dev/null @@ -1,24 +0,0 @@ -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - --> - -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> -<html> -<body> - <!-- Package description. --> - Contains internal tests or test related classes and interfaces. -</body> -</html> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/direct/session/GridSessionLoadTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/direct/session/GridSessionLoadTest.java b/modules/core/src/test/java/org/gridgain/loadtests/direct/session/GridSessionLoadTest.java deleted file mode 100644 index 8944b2c..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/direct/session/GridSessionLoadTest.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.gridgain.loadtests.direct.session; - -import org.apache.ignite.*; -import org.apache.ignite.compute.*; -import org.gridgain.grid.loadtest.*; -import org.apache.ignite.internal.util.typedef.*; -import org.gridgain.testframework.*; -import org.gridgain.testframework.config.*; -import org.gridgain.testframework.junits.common.*; - -import java.util.concurrent.atomic.*; - -/** - * Session load test. - */ -@GridCommonTest(group = "Load Test") -public class GridSessionLoadTest extends GridCommonAbstractTest { - /** */ - public GridSessionLoadTest() { - super(/*start Grid*/true); - } - - /** - * @return Time for load test in minutes. - */ - private int getTestDurationInMinutes() { - return Integer.valueOf(GridTestProperties.getProperty("load.test.duration")); - } - - /** - * @return Number of threads for the test. - */ - private int getThreadCount() { - return Integer.valueOf(GridTestProperties.getProperty("load.test.threadnum")); - } - - /** {@inheritDoc} */ - @Override protected long getTestTimeout() { - return (getTestDurationInMinutes() + 1) * 60 * 1000; - } - - /** - * @throws Exception If failed. - */ - @SuppressWarnings("unchecked") - public void testSessionLoad() throws Exception { - final Ignite ignite = G.ignite(getTestGridName()); - - 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(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/direct/session/GridSessionLoadTestJob.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/direct/session/GridSessionLoadTestJob.java b/modules/core/src/test/java/org/gridgain/loadtests/direct/session/GridSessionLoadTestJob.java deleted file mode 100644 index b13980c..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/direct/session/GridSessionLoadTestJob.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.gridgain.loadtests.direct.session; - -import org.apache.ignite.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.resources.*; -import org.gridgain.grid.*; - -import java.io.*; - -/** - * Session load test job. - */ -public class GridSessionLoadTestJob extends ComputeJobAdapter { - /** */ - @IgniteTaskSessionResource - private ComputeTaskSession taskSes; - - /** */ - @IgniteLoggerResource - private IgniteLogger log; - - /** */ - public GridSessionLoadTestJob() { - // No-op. - } - - /** - * @param arg Argument. - */ - public GridSessionLoadTestJob(String arg) { - super(arg); - } - - /** {@inheritDoc} */ - @Override public Serializable execute() throws IgniteCheckedException { - assert taskSes != null; - - Object arg = argument(0); - - assert arg != null; - - Serializable ser = taskSes.getAttribute(arg); - - assert ser != null; - - int val = (Integer)ser + 1; - - // Generate garbage. - for (int i = 0; i < 10; i++) - taskSes.setAttribute(arg, i); - - // Set final value. - taskSes.setAttribute(arg, val); - - if (log.isDebugEnabled()) - log.debug("Set session attribute [name=" + arg + ", value=" + val + ']'); - - return val; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/direct/session/GridSessionLoadTestTask.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/direct/session/GridSessionLoadTestTask.java b/modules/core/src/test/java/org/gridgain/loadtests/direct/session/GridSessionLoadTestTask.java deleted file mode 100644 index 8a8d56f..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/direct/session/GridSessionLoadTestTask.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.gridgain.loadtests.direct.session; - -import org.apache.ignite.*; -import org.apache.ignite.cluster.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.resources.*; -import org.gridgain.grid.*; - -import java.util.*; - -/** - * Session load test task. - */ -public class GridSessionLoadTestTask extends ComputeTaskAdapter<Integer, Boolean> { - /** */ - @IgniteTaskSessionResource - private ComputeTaskSession taskSes; - - /** */ - @IgniteLoggerResource - private IgniteLogger log; - - /** */ - private Map<String, Integer> params; - - /** {@inheritDoc} */ - @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, Integer arg) throws IgniteCheckedException { - assert taskSes != null; - assert arg != null; - assert arg > 0; - - Map<GridSessionLoadTestJob, ClusterNode> map = new HashMap<>(subgrid.size()); - - Iterator<ClusterNode> iter = subgrid.iterator(); - - Random rnd = new Random(); - - params = new HashMap<>(arg); - - Collection<UUID> assigned = new ArrayList<>(subgrid.size()); - - for (int i = 0; i < arg; i++) { - // Recycle iterator. - if (!iter.hasNext()) - iter = subgrid.iterator(); - - String paramName = UUID.randomUUID().toString(); - - int paramVal = rnd.nextInt(); - - taskSes.setAttribute(paramName, paramVal); - - ClusterNode node = iter.next(); - - assigned.add(node.id()); - - map.put(new GridSessionLoadTestJob(paramName), node); - - params.put(paramName, paramVal); - - if (log.isDebugEnabled()) - log.debug("Set session attribute [name=" + paramName + ", value=" + paramVal + ']'); - } - - taskSes.setAttribute("nodes", assigned); - - return map; - } - - /** {@inheritDoc} */ - @SuppressWarnings("BusyWait") - @Override public Boolean reduce(List<ComputeJobResult> results) throws IgniteCheckedException { - assert taskSes != null; - assert results != null; - assert params != null; - assert !params.isEmpty(); - assert results.size() == params.size(); - - Map<String, Integer> receivedParams = new HashMap<>(); - - boolean allAttrReceived = false; - - int cnt = 0; - - while (!allAttrReceived && cnt++ < 3) { - allAttrReceived = true; - - for (Map.Entry<String, Integer> entry : params.entrySet()) { - assert taskSes.getAttribute(entry.getKey()) != null; - - Integer newVal = (Integer)taskSes.getAttribute(entry.getKey()); - - assert newVal != null; - - receivedParams.put(entry.getKey(), newVal); - - if (newVal != entry.getValue() + 1) - allAttrReceived = false; - } - - if (!allAttrReceived) { - try { - Thread.sleep(100); - } - catch (InterruptedException e) { - throw new IgniteCheckedException("Thread interrupted.", e); - } - } - } - - if (log.isDebugEnabled()) { - for (Map.Entry<String, Integer> entry : receivedParams.entrySet()) { - log.debug("Received session attr value [name=" + entry.getKey() + ", val=" + entry.getValue() - + ", expected=" + (params.get(entry.getKey()) + 1) + ']'); - } - } - - return allAttrReceived; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/direct/session/package.html ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/direct/session/package.html b/modules/core/src/test/java/org/gridgain/loadtests/direct/session/package.html deleted file mode 100644 index 135eb1a..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/direct/session/package.html +++ /dev/null @@ -1,24 +0,0 @@ -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - --> - -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> -<html> -<body> - <!-- Package description. --> - Contains internal tests or test related classes and interfaces. -</body> -</html> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/direct/stealing/GridStealingLoadTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/direct/stealing/GridStealingLoadTest.java b/modules/core/src/test/java/org/gridgain/loadtests/direct/stealing/GridStealingLoadTest.java deleted file mode 100644 index 0f11e3d..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/direct/stealing/GridStealingLoadTest.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.gridgain.loadtests.direct.stealing; - -import org.apache.ignite.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.configuration.*; -import org.gridgain.grid.loadtest.*; -import org.apache.ignite.spi.collision.jobstealing.*; -import org.apache.ignite.spi.discovery.*; -import org.apache.ignite.spi.discovery.tcp.*; -import org.apache.ignite.spi.failover.jobstealing.*; -import org.gridgain.testframework.*; -import org.gridgain.testframework.config.*; -import org.gridgain.testframework.junits.common.*; - -import java.util.*; -import java.util.concurrent.atomic.*; - -/** - * - */ -@GridCommonTest(group = "Load Test") -public class GridStealingLoadTest extends GridCommonAbstractTest { - /** */ - public GridStealingLoadTest() { - super(false); - } - - /** - * @return Number of threads for the test. - */ - private int getThreadCount() { - return Integer.valueOf(GridTestProperties.getProperty("load.test.threadnum")); - } - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - startGrids(2); - } - - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { - stopAllGrids(); - } - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String name) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(name); - - JobStealingCollisionSpi colSpi = new JobStealingCollisionSpi(); - - assert colSpi.getActiveJobsThreshold() == JobStealingCollisionSpi.DFLT_ACTIVE_JOBS_THRESHOLD; - assert colSpi.getWaitJobsThreshold() == JobStealingCollisionSpi.DFLT_WAIT_JOBS_THRESHOLD; - - // One job at a time. - colSpi.setActiveJobsThreshold(5); - colSpi.setWaitJobsThreshold(0); - colSpi.setMessageExpireTime(5000); - - JobStealingFailoverSpi failSpi = new JobStealingFailoverSpi(); - - // Verify defaults. - assert failSpi.getMaximumFailoverAttempts() == JobStealingFailoverSpi.DFLT_MAX_FAILOVER_ATTEMPTS; - - DiscoverySpi discoSpi = new TcpDiscoverySpi(); - - cfg.setDiscoverySpi(discoSpi); - cfg.setCollisionSpi(colSpi); - cfg.setFailoverSpi(failSpi); - - return cfg; - } - - /** - * @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()); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/direct/stealing/GridStealingLoadTestJob.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/direct/stealing/GridStealingLoadTestJob.java b/modules/core/src/test/java/org/gridgain/loadtests/direct/stealing/GridStealingLoadTestJob.java deleted file mode 100644 index 03791db..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/direct/stealing/GridStealingLoadTestJob.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.gridgain.loadtests.direct.stealing; - -import org.apache.ignite.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.resources.*; -import org.gridgain.grid.*; - -import java.io.*; -import java.util.*; - -/** - * Stealing load test. - */ -public class GridStealingLoadTestJob extends ComputeJobAdapter { - /** */ - @IgniteLoggerResource - private IgniteLogger log; - - /** Ignite instance. */ - @IgniteInstanceResource - private Ignite ignite; - - /** */ - @IgniteJobContextResource - private ComputeJobContext ctx; - - /** {@inheritDoc} */ - @Override public Serializable execute() throws IgniteCheckedException { - UUID nodeId = ignite.configuration().getNodeId(); - - if (log.isDebugEnabled()) - log.debug("Executing job on node [nodeId=" + nodeId + ", jobId=" + ctx.getJobId() + ']'); - - try { - Thread.sleep(500); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - - // Here we gonna return node id which executed this job. - // Hopefully it would be stealing node. - return nodeId; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/direct/stealing/GridStealingLoadTestTask.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/direct/stealing/GridStealingLoadTestTask.java b/modules/core/src/test/java/org/gridgain/loadtests/direct/stealing/GridStealingLoadTestTask.java deleted file mode 100644 index 6424255..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/direct/stealing/GridStealingLoadTestTask.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.gridgain.loadtests.direct.stealing; - -import org.apache.ignite.*; -import org.apache.ignite.cluster.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.resources.*; - -import java.util.*; - -/** - * Stealing load test task. - */ -public class GridStealingLoadTestTask extends ComputeTaskAdapter<UUID, Integer> { - /** */ - @IgniteTaskSessionResource - private ComputeTaskSession taskSes; - - /** */ - private UUID stealingNodeId; - - /** */ - private int stolenJobs; - - /** {@inheritDoc} */ - @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, UUID arg) throws IgniteCheckedException { - assert arg != null; - assert subgrid.size() > 1: "Test requires at least 2 nodes. One with load and another one to steal."; - - int jobsNum = subgrid.size(); - - Map<GridStealingLoadTestJob, ClusterNode> map = new HashMap<>(jobsNum); - - stealingNodeId = arg; - - Iterator<ClusterNode> iter = subgrid.iterator(); - - Collection<UUID> assigned = new ArrayList<>(subgrid.size()); - - for (int i = 0; i < jobsNum; i++) { - ClusterNode node = null; - - boolean nextNodeFound = false; - - while (iter.hasNext() && !nextNodeFound) { - node = iter.next(); - - // Do not map jobs to the stealing node. - if (!node.id().equals(stealingNodeId)) - nextNodeFound = true; - - // Recycle iterator. - if (!iter.hasNext()) - iter = subgrid.iterator(); - } - - assert node != null; - - assigned.add(node.id()); - - map.put(new GridStealingLoadTestJob(), node); - } - - taskSes.setAttribute("nodes", assigned); - - return map; - } - - /** {@inheritDoc} */ - @Override public Integer reduce(List<ComputeJobResult> results) throws IgniteCheckedException { - assert results != null; - - for (ComputeJobResult res : results) { - if (res.getData() != null && stealingNodeId.equals(res.getData())) - stolenJobs++; - } - - return stolenJobs; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/direct/stealing/package.html ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/direct/stealing/package.html b/modules/core/src/test/java/org/gridgain/loadtests/direct/stealing/package.html deleted file mode 100644 index 135eb1a..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/direct/stealing/package.html +++ /dev/null @@ -1,24 +0,0 @@ -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - --> - -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> -<html> -<body> - <!-- Package description. --> - Contains internal tests or test related classes and interfaces. -</body> -</html> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/discovery/GridGcTimeoutTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/discovery/GridGcTimeoutTest.java b/modules/core/src/test/java/org/gridgain/loadtests/discovery/GridGcTimeoutTest.java deleted file mode 100644 index c412697..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/discovery/GridGcTimeoutTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.gridgain.loadtests.discovery; - -import org.apache.ignite.*; -import org.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.internal.util.typedef.internal.*; - -import java.util.*; - -/** - * - */ -public class GridGcTimeoutTest { - /** */ - public static final String CFG_PATH = "modules/core/src/test/config/discovery-stress.xml"; - - /** */ - public static final int VALUE_SIZE = 1024; - - /** - * @param args Args. - * @throws IgniteCheckedException If failed. - */ - @SuppressWarnings("InfiniteLoopStatement") - public static void main(String[] args) throws IgniteCheckedException { - Ignite g = G.start(U.resolveGridGainUrl(CFG_PATH)); - - IgniteDataLoader<Long, String> ldr = g.dataLoader(null); - - ldr.perNodeBufferSize(16 * 1024); - - StringBuilder sb = new StringBuilder(); - - for (int i = 0; i < VALUE_SIZE - 42; i++) - sb.append('a'); - - String str = sb.toString(); - long cntr = 0; - - while (true) { - ldr.addData(cntr++, UUID.randomUUID() + str); - - if (cntr % 1000000 == 0) - X.println("!!! Entries added: " + cntr); - } - } -}