http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cc186b52/modules/aop/src/test/java/org/apache/ignite/gridify/GridifySetToValueTargetInterface.java ---------------------------------------------------------------------- diff --git a/modules/aop/src/test/java/org/apache/ignite/gridify/GridifySetToValueTargetInterface.java b/modules/aop/src/test/java/org/apache/ignite/gridify/GridifySetToValueTargetInterface.java new file mode 100644 index 0000000..5250e7f --- /dev/null +++ b/modules/aop/src/test/java/org/apache/ignite/gridify/GridifySetToValueTargetInterface.java @@ -0,0 +1,100 @@ +/* + * 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.apache.ignite.gridify; + +import org.apache.ignite.compute.gridify.*; + +import java.util.*; + +/** + * Test set-to-value target interface. + */ +public interface GridifySetToValueTargetInterface { + /** + * Find maximum value in collection. + * + * @param input Input collection. + * @return Maximum value. + */ + @GridifySetToValue(gridName = "GridifySetToValueTarget", threshold = 2, splitSize = 2) + public Long findMaximum(Collection<Long> input); + + /** + * Find maximum value in collection. + * + * @param input Input collection. + * @return Maximum value. + */ + @GridifySetToValue(gridName = "GridifySetToValueTarget") + public Long findMaximumInList(List<Long> input); + + /** + * Find maximum value in collection. + * + * @param input Input collection. + * @return Maximum value. + */ + @GridifySetToValue(gridName = "GridifySetToValueTarget", threshold = 2) + public Long findMaximumWithoutSplitSize(Collection<Long> input); + + /** + * Find maximum value in collection. + * + * @param input Input collection. + * @return Maximum value. + */ + @GridifySetToValue(gridName = "GridifySetToValueTarget") + public Long findMaximumWithoutSplitSizeAndThreshold(Collection<Long> input); + + /** + * Find maximum in array. + * + * @param input Input array. + * @return Maximum value. + */ + @GridifySetToValue(gridName = "GridifySetToValueTarget", threshold = 2, splitSize = 2) + public Long findPrimesInArray(Long[] input); + + /** + * Find maximum in primitive array. + * + * @param input Input array. + * @return Maximum value. + */ + @GridifySetToValue(gridName = "GridifySetToValueTarget", threshold = 2, splitSize = 2) + public long findMaximumInPrimitiveArray(long[] input); + + /** + * Find maximum value in Iterator. + * + * @param input Input collection. + * @return Maximum value. + */ + @GridifySetToValue(gridName = "GridifySetToValueTarget", threshold = 2, splitSize = 2) + public long findMaximumInIterator(Iterator<Long> input); + + + /** + * Find maximum value in Enumeration. + * + * @param input Input collection. + * @return Maximum value. + */ + @GridifySetToValue(gridName = "GridifySetToValueTarget", threshold = 2, splitSize = 2) + public long findMaximumInEnumeration(Enumeration<Long> input); +}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cc186b52/modules/aop/src/test/java/org/apache/ignite/gridify/GridifySetToXXXNonSpringAopSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/aop/src/test/java/org/apache/ignite/gridify/GridifySetToXXXNonSpringAopSelfTest.java b/modules/aop/src/test/java/org/apache/ignite/gridify/GridifySetToXXXNonSpringAopSelfTest.java new file mode 100644 index 0000000..388f274 --- /dev/null +++ b/modules/aop/src/test/java/org/apache/ignite/gridify/GridifySetToXXXNonSpringAopSelfTest.java @@ -0,0 +1,203 @@ +/* + * 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.apache.ignite.gridify; + +import org.gridgain.testframework.junits.common.*; +import java.util.*; + +/** + * To run this test with JBoss AOP make sure of the following: + * + * 1. The JVM is started with following parameters to enable jboss online weaving + * (replace ${GRIDGAIN_HOME} to you $GRIDGAIN_HOME): + * -javaagent:${GRIDGAIN_HOME}libs/jboss-aop-jdk50-4.0.4.jar + * -Djboss.aop.class.path=[path to grid compiled classes (Idea out folder) or path to gridgain.jar] + * -Djboss.aop.exclude=org,com -Djboss.aop.include=org.gridgain + * + * 2. The following jars should be in a classpath: + * ${GRIDGAIN_HOME}libs/javassist-3.x.x.jar + * ${GRIDGAIN_HOME}libs/jboss-aop-jdk50-4.0.4.jar + * ${GRIDGAIN_HOME}libs/jboss-aspect-library-jdk50-4.0.4.jar + * ${GRIDGAIN_HOME}libs/jboss-common-4.2.2.jar + * ${GRIDGAIN_HOME}libs/trove-1.0.2.jar + * + * To run this test with AspectJ APO make sure of the following: + * + * 1. The JVM is started with following parameters for enable AspectJ online weaving + * (replace ${GRIDGAIN_HOME} to you $GRIDGAIN_HOME): + * -javaagent:${GRIDGAIN_HOME}/libs/aspectjweaver-1.7.2.jar + * + * 2. Classpath should contains the ${GRIDGAIN_HOME}/modules/tests/config/aop/aspectj folder. + */ +@GridCommonTest(group="AOP") +public class GridifySetToXXXNonSpringAopSelfTest extends GridCommonAbstractTest { + /** + * @throws Exception If failed. + */ + public void testGridifySetToSet() throws Exception { + try { + startGrid("GridifySetToSetTarget"); + startGrid("GridifySetToSetTarget2"); + startGrid("GridifySetToSetTarget3"); + + GridifySetToSetTarget target = new GridifySetToSetTarget(); + + Collection<Long> primesInSet = target.findPrimes(Arrays.asList(2L, 3L, 4L, 6L)); + + info(">>> Prime numbers in set '" + primesInSet + "'."); + + primesInSet = target.findPrimesWithoutSplitSize(Arrays.asList(2L, 3L, 4L, 6L)); + + info(">>> Prime numbers w/o splitsize in set '" + primesInSet + "'."); + + primesInSet = target.findPrimesWithoutSplitSizeAndThreshold(Arrays.asList(2L, 3L, 4L, 6L)); + + info(">>> Prime numbers w/o splitsize and threshold in set '" + primesInSet + "'."); + + primesInSet = target.findPrimesInListWithoutSplitSizeAndThreshold(Arrays.asList(2L, 3L, 4L, 6L)); + + info(">>> Prime numbers in list w/o splitsize and threshold in set '" + primesInSet + "'."); + + primesInSet = target.findPrimesInArrayListWithoutSplitSizeAndThreshold( + new ArrayList<>(Arrays.asList(2L, 3L, 4L, 6L))); + + info(">>> Prime numbers in arraylist w/o splitsize and threshold in set '" + primesInSet + "'."); + + Long[] primesInArr = target.findPrimesInArray(new Long[]{2L, 3L, 4L, 6L}); + + info(">>> Prime numbers in array '" + Arrays.asList(primesInArr) + "'."); + + long[] primesInPrimArr = target.findPrimesInPrimitiveArray(new long[]{2L, 3L, 4L, 6L}); + + info(">>> Prime numbers in primitive array '" + primesInPrimArr + "'."); + + Iterator<Long> primesInIter = target.findPrimesWithIterator(Arrays.asList(2L, 3L, 4L, 6L).iterator()); + + info(">>> Prime numbers in iterator '" + convert(primesInIter) + "'."); + + Enumeration<Long> primesInEnum = target.findPrimesWithEnumeration( + new MathEnumerationAdapter<>(Arrays.asList(2L, 3L, 4L, 6L))); + + info(">>> Prime numbers in enumeration '" + convert(primesInEnum) + "'."); + } + finally { + stopGrid("GridifySetToSetTarget"); + stopGrid("GridifySetToSetTarget2"); + stopGrid("GridifySetToSetTarget3"); + } + } + + /** + * @throws Exception If failed. + */ + public void testGridifySetToValue() throws Exception { + try { + startGrid("GridifySetToValueTarget"); + startGrid("GridifySetToValueTarget2"); + startGrid("GridifySetToValueTarget3"); + + GridifySetToValueTarget target = new GridifySetToValueTarget(); + + Long max = target.findMaximum(Arrays.asList(2L, 3L, 4L, 6L)); + + info(">>> Maximum in collection '" + max + "'."); + + max = target.findMaximumInList(Arrays.asList(2L, 3L, 4L, 6L)); + + info(">>> Maximum in list '" + max + "'."); + + max = target.findMaximumWithoutSplitSize(Arrays.asList(2L, 3L, 4L, 6L)); + + info(">>> Maximum w/o splitsize in collection '" + max + "'."); + + max = target.findMaximumWithoutSplitSizeAndThreshold(Arrays.asList(2L, 3L, 4L, 6L)); + + info(">>> Maximum w/o splitsize and threshold in collection '" + max + "'."); + + max = target.findMaximumInIterator(Arrays.asList(2L, 3L, 4L, 6L).iterator()); + + info(">>> Maximum in iterator '" + max + "'."); + + max = target.findMaximumInEnumeration(new MathEnumerationAdapter<>(Arrays.asList(2L, 3L, 4L, 6L))); + + info(">>> Maximum in enumeration '" + max + "'."); + } + finally { + stopGrid("GridifySetToValueTarget"); + stopGrid("GridifySetToValueTarget2"); + stopGrid("GridifySetToValueTarget3"); + } + } + + /** + * Convert data to collection. + * + * @param iter Iterator. + * @return Collection. + */ + private <T> Collection<T> convert(Iterator<T> iter) { + List<T> list = new ArrayList<>(); + + while (iter.hasNext()) + list.add(iter.next()); + + return list; + } + + /** + * Convert data to collection. + * + * @param iter Iterator. + * @return Collection. + */ + private <T> Collection<T> convert(Enumeration<T> iter) { + List<T> list = new ArrayList<>(); + + while (iter.hasMoreElements()) + list.add(iter.nextElement()); + + return list; + } + + /** + * Enumeration adapter. + */ + private static class MathEnumerationAdapter<T> implements Enumeration<T> { + /** */ + private Iterator<T> iter; + + /** + * Creates Enumeration. + * + * @param col Input collection. + */ + MathEnumerationAdapter(Collection<T> col) { + iter = col.iterator(); + } + + /** {@inheritDoc} */ + @Override public boolean hasMoreElements() { + return iter.hasNext(); + } + + /** {@inheritDoc} */ + @Override public T nextElement() { + return iter.next(); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cc186b52/modules/aop/src/test/java/org/apache/ignite/gridify/GridifySetToXXXSpringAopSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/aop/src/test/java/org/apache/ignite/gridify/GridifySetToXXXSpringAopSelfTest.java b/modules/aop/src/test/java/org/apache/ignite/gridify/GridifySetToXXXSpringAopSelfTest.java new file mode 100644 index 0000000..8d6e313 --- /dev/null +++ b/modules/aop/src/test/java/org/apache/ignite/gridify/GridifySetToXXXSpringAopSelfTest.java @@ -0,0 +1,204 @@ +/* + * 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.apache.ignite.gridify; + +import org.apache.ignite.compute.gridify.aop.spring.*; +import org.gridgain.testframework.junits.common.*; +import java.util.*; + +/** + * To run this test with JBoss AOP make sure of the following: + * + * 1. The JVM is started with following parameters to enable jboss online weaving + * (replace ${GRIDGAIN_HOME} to you $GRIDGAIN_HOME): + * -javaagent:${GRIDGAIN_HOME}libs/jboss-aop-jdk50-4.0.4.jar + * -Djboss.aop.class.path=[path to grid compiled classes (Idea out folder) or path to gridgain.jar] + * -Djboss.aop.exclude=org,com -Djboss.aop.include=org.gridgain + * + * 2. The following jars should be in a classpath: + * ${GRIDGAIN_HOME}libs/javassist-3.x.x.jar + * ${GRIDGAIN_HOME}libs/jboss-aop-jdk50-4.0.4.jar + * ${GRIDGAIN_HOME}libs/jboss-aspect-library-jdk50-4.0.4.jar + * ${GRIDGAIN_HOME}libs/jboss-common-4.2.2.jar + * ${GRIDGAIN_HOME}libs/trove-1.0.2.jar + * + * To run this test with AspectJ APO make sure of the following: + * + * 1. The JVM is started with following parameters for enable AspectJ online weaving + * (replace ${GRIDGAIN_HOME} to you $GRIDGAIN_HOME): + * -javaagent:${GRIDGAIN_HOME}/libs/aspectjweaver-1.7.2.jar + * + * 2. Classpath should contains the ${GRIDGAIN_HOME}/modules/tests/config/aop/aspectj folder. + */ +@GridCommonTest(group="AOP") +public class GridifySetToXXXSpringAopSelfTest extends GridCommonAbstractTest { + /** + * @throws Exception If failed. + */ + public void testGridifySetToSet() throws Exception { + try { + startGrid("GridifySetToSetTarget"); + startGrid("GridifySetToSetTarget2"); + startGrid("GridifySetToSetTarget3"); + + GridifySetToSetTargetInterface target = GridifySpringEnhancer.enhance(new GridifySetToSetTarget()); + + Collection<Long> primesInSet = target.findPrimes(Arrays.asList(2L, 3L, 4L, 6L)); + + info(">>> Prime numbers in set '" + primesInSet + "'."); + + primesInSet = target.findPrimesWithoutSplitSize(Arrays.asList(2L, 3L, 4L, 6L)); + + info(">>> Prime numbers w/o 'splitsize' in set '" + primesInSet + "'."); + + primesInSet = target.findPrimesWithoutSplitSizeAndThreshold(Arrays.asList(2L, 3L, 4L, 6L)); + + info(">>> Prime numbers w/o 'splitsize' and 'threshold' in set '" + primesInSet + "'."); + + primesInSet = target.findPrimesInListWithoutSplitSizeAndThreshold(Arrays.asList(2L, 3L, 4L, 6L)); + + info(">>> Prime numbers in list w/o 'splitsize' and 'threshold' in set '" + primesInSet + "'."); + + primesInSet = target.findPrimesInArrayListWithoutSplitSizeAndThreshold( + new ArrayList<>(Arrays.asList(2L, 3L, 4L, 6L))); + + info(">>> Prime numbers in 'arraylist' w/o 'splitsize' and threshold in set '" + primesInSet + "'."); + + Long[] primesInArr = target.findPrimesInArray(new Long[]{2L, 3L, 4L, 6L}); + + info(">>> Prime numbers in array '" + Arrays.asList(primesInArr) + "'."); + + long[] primesInPrimArr = target.findPrimesInPrimitiveArray(new long[]{2L, 3L, 4L, 6L}); + + info(">>> Prime numbers in primitive array '" + primesInPrimArr + "'."); + + Iterator<Long> primesInIter = target.findPrimesWithIterator(Arrays.asList(2L, 3L, 4L, 6L).iterator()); + + info(">>> Prime numbers in iterator '" + convert(primesInIter) + "'."); + + Enumeration<Long> primesInEnum = target.findPrimesWithEnumeration( + new MathEnumerationAdapter<>(Arrays.asList(2L, 3L, 4L, 6L))); + + info(">>> Prime numbers in enumeration '" + convert(primesInEnum) + "'."); + } + finally { + stopGrid("GridifySetToSetTarget"); + stopGrid("GridifySetToSetTarget2"); + stopGrid("GridifySetToSetTarget3"); + } + } + + /** + * @throws Exception If failed. + */ + public void testGridifySetToValue() throws Exception { + try { + startGrid("GridifySetToValueTarget"); + startGrid("GridifySetToValueTarget2"); + startGrid("GridifySetToValueTarget3"); + + GridifySetToValueTargetInterface target = GridifySpringEnhancer.enhance(new GridifySetToValueTarget()); + + Long max = target.findMaximum(Arrays.asList(2L, 3L, 4L, 6L)); + + info(">>> Maximum in collection '" + max + "'."); + + max = target.findMaximumInList(Arrays.asList(2L, 3L, 4L, 6L)); + + info(">>> Maximum in list '" + max + "'."); + + max = target.findMaximumWithoutSplitSize(Arrays.asList(2L, 3L, 4L, 6L)); + + info(">>> Maximum w/o splitsize in collection '" + max + "'."); + + max = target.findMaximumWithoutSplitSizeAndThreshold(Arrays.asList(2L, 3L, 4L, 6L)); + + info(">>> Maximum w/o splitsize and threshold in collection '" + max + "'."); + + max = target.findMaximumInIterator(Arrays.asList(2L, 3L, 4L, 6L).iterator()); + + info(">>> Maximum in iterator '" + max + "'."); + + max = target.findMaximumInEnumeration(new MathEnumerationAdapter<>(Arrays.asList(2L, 3L, 4L, 6L))); + + info(">>> Maximum in enumeration '" + max + "'."); + } + finally { + stopGrid("GridifySetToValueTarget"); + stopGrid("GridifySetToValueTarget2"); + stopGrid("GridifySetToValueTarget3"); + } + } + + /** + * Convert data to collection. + * + * @param iter Iterator. + * @return Collection. + */ + private <T> Collection<T> convert(Iterator<T> iter) { + List<T> list = new ArrayList<>(); + + while (iter.hasNext()) + list.add(iter.next()); + + return list; + } + + /** + * Convert data to collection. + * + * @param iter Iterator. + * @return Collection. + */ + private <T> Collection<T> convert(Enumeration<T> iter) { + List<T> list = new ArrayList<>(); + + while (iter.hasMoreElements()) + list.add(iter.nextElement()); + + return list; + } + + /** + * Enumeration adapter. + */ + private static class MathEnumerationAdapter<T> implements Enumeration<T> { + /** */ + private Iterator<T> iter; + + /** + * Creates Enumeration. + * + * @param col Input collection. + */ + MathEnumerationAdapter(Collection<T> col) { + iter = col.iterator(); + } + + /** {@inheritDoc} */ + @Override public boolean hasMoreElements() { + return iter.hasNext(); + } + + /** {@inheritDoc} */ + @Override public T nextElement() { + return iter.next(); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cc186b52/modules/aop/src/test/java/org/apache/ignite/gridify/hierarchy/GridSuperTarget.java ---------------------------------------------------------------------- diff --git a/modules/aop/src/test/java/org/apache/ignite/gridify/hierarchy/GridSuperTarget.java b/modules/aop/src/test/java/org/apache/ignite/gridify/hierarchy/GridSuperTarget.java new file mode 100644 index 0000000..66c5bca --- /dev/null +++ b/modules/aop/src/test/java/org/apache/ignite/gridify/hierarchy/GridSuperTarget.java @@ -0,0 +1,53 @@ +/* + * 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.apache.ignite.gridify.hierarchy; + +import org.apache.ignite.compute.gridify.*; + +/** + * Target base class. + */ +public abstract class GridSuperTarget { + /** + * @return Always returns "GridSuperTarget.methodA()". + */ + @Gridify(gridName = "GridifyHierarchyTest") + protected String methodA() { + System.out.println(">>> Called GridSuperTarget.methodA()"); + + return "GridSuperTarget.methodA()"; + } + + /** + * @return "GridSuperTarget.methodC()" string. + */ + protected String methodB() { + return methodC(); + } + + /** + * @return "GridSuperTarget.methodC()" string. + */ + @Gridify(gridName = "GridifyHierarchyTest") + private String methodC() { + System.out.println(">>> Called GridSuperTarget.methodC()"); + + return "GridSuperTarget.methodC()"; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cc186b52/modules/aop/src/test/java/org/apache/ignite/gridify/hierarchy/GridTarget.java ---------------------------------------------------------------------- diff --git a/modules/aop/src/test/java/org/apache/ignite/gridify/hierarchy/GridTarget.java b/modules/aop/src/test/java/org/apache/ignite/gridify/hierarchy/GridTarget.java new file mode 100644 index 0000000..eb406c5 --- /dev/null +++ b/modules/aop/src/test/java/org/apache/ignite/gridify/hierarchy/GridTarget.java @@ -0,0 +1,45 @@ +/* + * 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.apache.ignite.gridify.hierarchy; + +/** + * Target. + */ +public class GridTarget extends GridSuperTarget { + /** {@inheritDoc} */ + @Override protected String methodA() { + System.out.println(">>> Called GridTarget.methodA()"); + + String res = super.methodA(); + + assert "GridSuperTarget.methodA()".equals(res) == true : + "Unexpected GridSuperTarget.methodA() apply result [res=" + res + ']'; + + return "GridTarget.MethodA()"; + } + + /** {@inheritDoc} */ + @Override protected String methodB() { + String res = super.methodB(); + + assert "GridSuperTarget.methodC()".equals(res) == true: + "Unexpected GridSuperTarget.methodB() apply result [res=" + res + ']'; + + return res; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cc186b52/modules/aop/src/test/java/org/apache/ignite/gridify/hierarchy/GridifyHierarchyTest.java ---------------------------------------------------------------------- diff --git a/modules/aop/src/test/java/org/apache/ignite/gridify/hierarchy/GridifyHierarchyTest.java b/modules/aop/src/test/java/org/apache/ignite/gridify/hierarchy/GridifyHierarchyTest.java new file mode 100644 index 0000000..29081e8 --- /dev/null +++ b/modules/aop/src/test/java/org/apache/ignite/gridify/hierarchy/GridifyHierarchyTest.java @@ -0,0 +1,51 @@ +/* + * 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.apache.ignite.gridify.hierarchy; + +import org.gridgain.testframework.junits.common.*; + +/** + * Gridify hierarchy test. + */ +public class GridifyHierarchyTest extends GridCommonAbstractTest { + /** */ + public GridifyHierarchyTest() { + super(true); + } + + /** */ + public void noneTestGridifyHierarchyProtected() { + GridTarget target = new GridTarget(); + + target.methodA(); + } + + /** + * @throws Exception If failed. + */ + public void testGridifyHierarchyPrivate() throws Exception { + GridTarget target = new GridTarget(); + + target.methodB(); + } + + /** {@inheritDoc} */ + @Override public String getTestGridName() { + return "GridifyHierarchyTest"; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cc186b52/modules/aop/src/test/java/org/apache/ignite/gridify/hierarchy/package.html ---------------------------------------------------------------------- diff --git a/modules/aop/src/test/java/org/apache/ignite/gridify/hierarchy/package.html b/modules/aop/src/test/java/org/apache/ignite/gridify/hierarchy/package.html new file mode 100644 index 0000000..89e4866 --- /dev/null +++ b/modules/aop/src/test/java/org/apache/ignite/gridify/hierarchy/package.html @@ -0,0 +1,23 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<!-- + 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. + --> +<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/cc186b52/modules/aop/src/test/java/org/apache/ignite/gridify/package.html ---------------------------------------------------------------------- diff --git a/modules/aop/src/test/java/org/apache/ignite/gridify/package.html b/modules/aop/src/test/java/org/apache/ignite/gridify/package.html new file mode 100644 index 0000000..89e4866 --- /dev/null +++ b/modules/aop/src/test/java/org/apache/ignite/gridify/package.html @@ -0,0 +1,23 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<!-- + 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. + --> +<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/cc186b52/modules/aop/src/test/java/org/apache/ignite/gridify/test_resource.properties ---------------------------------------------------------------------- diff --git a/modules/aop/src/test/java/org/apache/ignite/gridify/test_resource.properties b/modules/aop/src/test/java/org/apache/ignite/gridify/test_resource.properties new file mode 100644 index 0000000..15b218e --- /dev/null +++ b/modules/aop/src/test/java/org/apache/ignite/gridify/test_resource.properties @@ -0,0 +1,18 @@ +# +# 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. +# + +param1=1 http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cc186b52/modules/aop/src/test/java/org/apache/ignite/marshaller/optimized/GridOptimizedMarshallerAopTest.java ---------------------------------------------------------------------- diff --git a/modules/aop/src/test/java/org/apache/ignite/marshaller/optimized/GridOptimizedMarshallerAopTest.java b/modules/aop/src/test/java/org/apache/ignite/marshaller/optimized/GridOptimizedMarshallerAopTest.java new file mode 100644 index 0000000..a796124 --- /dev/null +++ b/modules/aop/src/test/java/org/apache/ignite/marshaller/optimized/GridOptimizedMarshallerAopTest.java @@ -0,0 +1,105 @@ +/* + * 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.apache.ignite.marshaller.optimized; + +import org.apache.ignite.compute.gridify.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.events.*; +import org.apache.ignite.lang.*; +import org.apache.ignite.marshaller.optimized.*; +import org.apache.ignite.internal.util.typedef.*; +import org.gridgain.testframework.junits.common.*; + +import java.util.concurrent.atomic.*; + +import static org.apache.ignite.events.IgniteEventType.*; + +/** + * Test use GridOptimizedMarshaller and AspectJ AOP. + * + * The following configuration needs to be applied to enable AspectJ byte code + * weaving. + * <ul> + * <li> + * JVM configuration should include: + * <tt>-javaagent:[GRIDGAIN_HOME]/libs/aspectjweaver-1.7.2.jar</tt> + * </li> + * <li> + * Classpath should contain the <tt>[GRIDGAIN_HOME]/modules/tests/config/aop/aspectj</tt> folder. + * </li> + * </ul> + */ +public class GridOptimizedMarshallerAopTest extends GridCommonAbstractTest { + /** */ + private static final AtomicInteger cntr = new AtomicInteger(); + + /** + * Constructs a test. + */ + public GridOptimizedMarshallerAopTest() { + super(false /* start grid. */); + } + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + IgniteConfiguration cfg = new IgniteConfiguration(); + + cfg.setMarshaller(new IgniteOptimizedMarshaller()); + + G.start(cfg); + + assert G.allGrids().size() == 1; + } + + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); + + assert G.allGrids().isEmpty(); + } + + /** + * JUnit. + * + * @throws Exception If failed. + */ + public void testUp() throws Exception { + G.ignite().events().localListen(new IgnitePredicate<IgniteEvent>() { + @Override public boolean apply(IgniteEvent evt) { + cntr.incrementAndGet(); + + return true; + } + }, EVT_TASK_FINISHED); + + gridify1(); + + assertEquals("Method gridify() wasn't executed on grid.", 1, cntr.get()); + } + + /** + * Method grid-enabled with {@link org.apache.ignite.compute.gridify.Gridify} annotation. + * <p> + * Note that default {@code Gridify} configuration is used, so this method + * will be executed on remote node with the same argument. + */ + @Gridify + private void gridify1() { + X.println("Executes on grid"); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cc186b52/modules/aop/src/test/java/org/apache/ignite/p2p/GridP2PGridifySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/aop/src/test/java/org/apache/ignite/p2p/GridP2PGridifySelfTest.java b/modules/aop/src/test/java/org/apache/ignite/p2p/GridP2PGridifySelfTest.java new file mode 100644 index 0000000..7c85cab --- /dev/null +++ b/modules/aop/src/test/java/org/apache/ignite/p2p/GridP2PGridifySelfTest.java @@ -0,0 +1,242 @@ +/* + * 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.apache.ignite.p2p; + +import org.apache.ignite.*; +import org.apache.ignite.compute.*; +import org.apache.ignite.compute.gridify.*; +import org.apache.ignite.configuration.*; +import org.gridgain.grid.p2p.*; +import org.gridgain.testframework.*; +import org.gridgain.testframework.junits.common.*; + +import java.io.*; +import java.util.*; + +/** + * + */ +@SuppressWarnings({"ProhibitedExceptionDeclared"}) +@GridCommonTest(group = "P2P") +public class GridP2PGridifySelfTest extends GridCommonAbstractTest { + /** Current deployment mode. Used in {@link #getConfiguration(String)}. */ + private IgniteDeploymentMode depMode; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + // Override P2P configuration to exclude Task and Job classes + cfg.setPeerClassLoadingLocalClassPathExclude(GridP2PTestTask.class.getName(), GridP2PTestJob.class.getName()); + + cfg.setDeploymentMode(depMode); + + return cfg; + } + + /** + * @param depMode deployment mode. + * @throws Exception If failed. + */ + @SuppressWarnings("unchecked") + private void processTestBothNodesDeploy(IgniteDeploymentMode depMode) throws Exception { + int res = 0; + + try { + this.depMode = depMode; + + Ignite ignite1 = startGrid(1); + startGrid(2); + + GridTestClassLoader tstClsLdr = new GridTestClassLoader( + Collections.singletonMap("org/gridgain/grid/p2p/p2p.properties", "resource=loaded"), + getClass().getClassLoader(), + GridP2PTestTask.class.getName(), GridP2PTestJob.class.getName() + ); + + Class<? extends ComputeTask<?, ?>> taskCls1 = (Class<? extends ComputeTask<?, ?>>)tstClsLdr.loadClass( + GridP2PTestTask.class.getName()); + + ignite1.compute().localDeployTask(taskCls1, taskCls1.getClassLoader()); + + res = executeGridify(1); + + ignite1.compute().undeployTask(taskCls1.getName()); + } + finally { + stopGrid(2); + stopGrid(1); + } + + // P2P deployment + assert res == 10 : "Invalid gridify result: " + res; + } + + /** + * @param res Result. + * @return The same value as parameter has. + */ + @Gridify(taskName = "org.gridgain.grid.p2p.GridP2PTestTask", + gridName="org.gridgain.grid.p2p.GridP2PGridifySelfTest1") + public int executeGridify(int res) { + return res; + } + + /** + * @param depMode deployment mode. + * @throws Exception If failed. + */ + private void processTestGridifyResource(IgniteDeploymentMode depMode) throws Exception { + try { + this.depMode = depMode; + + startGrid(1); + + Integer res = executeGridifyResource(1); + + // P2P deployment + assert res != null : "res != null"; + assert res == 1 : "Unexpected result [res=" + res + ", expected=0]"; + + info("Tests passed."); + } + finally { + stopGrid(1); + } + } + + /** + * Note that this method sends instance of test class to remote node. + * Be sure that this instance does not have none-serializable fields or references + * to the objects that could not be instantiated like class loaders and so on. + * + * @param res Result. + * @return The same value as parameter has. + */ + @Gridify(gridName="org.gridgain.grid.p2p.GridP2PGridifySelfTest1") + public Integer executeGridifyResource(int res) { + String path = "org/gridgain/grid/p2p/p2p.properties"; + + GridTestClassLoader tstClsLdr = new GridTestClassLoader( + GridP2PTestTask.class.getName(), + GridP2PTestJob.class.getName() + ); + + // Test property file load. + byte [] bytes = new byte[20]; + + try (InputStream in = tstClsLdr.getResourceAsStream(path)) { + if (in == null) { + System.out.println("Resource could not be loaded: " + path); + + return -2; + } + + in.read(bytes); + } + catch (IOException e) { + System.out.println("Failed to read from resource stream: " + e.getMessage()); + + return -3; + } + + String rsrcVal = new String(bytes).trim(); + + System.out.println("Remote resource content is : " + rsrcVal); + + if (!rsrcVal.equals("resource=loaded")) { + System.out.println("Invalid loaded resource value: " + rsrcVal); + + return -4; + } + + return res; + } + + /** + * Test GridDeploymentMode.ISOLATED mode. + * + * @throws Exception if error occur. + */ + public void testPrivateMode() throws Exception { + processTestBothNodesDeploy(IgniteDeploymentMode.PRIVATE); + } + + /** + * Test GridDeploymentMode.ISOLATED mode. + * + * @throws Exception if error occur. + */ + public void testIsolatedMode() throws Exception { + processTestBothNodesDeploy(IgniteDeploymentMode.ISOLATED); + } + + /** + * Test GridDeploymentMode.CONTINUOUS mode. + * + * @throws Exception if error occur. + */ + public void testContinuousMode() throws Exception { + processTestBothNodesDeploy(IgniteDeploymentMode.CONTINUOUS); + } + + /** + * Test GridDeploymentMode.SHARED mode. + * + * @throws Exception if error occur. + */ + public void testSharedMode() throws Exception { + processTestBothNodesDeploy(IgniteDeploymentMode.SHARED); + } + + /** + * Test GridDeploymentMode.ISOLATED mode. + * + * @throws Exception if error occur. + */ + public void testResourcePrivateMode() throws Exception { + processTestGridifyResource(IgniteDeploymentMode.PRIVATE); + } + + /** + * Test GridDeploymentMode.ISOLATED mode. + * + * @throws Exception if error occur. + */ + public void testResourceIsolatedMode() throws Exception { + processTestGridifyResource(IgniteDeploymentMode.ISOLATED); + } + + /** + * Test GridDeploymentMode.CONTINUOUS mode. + * + * @throws Exception if error occur. + */ + public void testResourceContinuousMode() throws Exception { + processTestGridifyResource(IgniteDeploymentMode.CONTINUOUS); + } + + /** + * Test GridDeploymentMode.SHARED mode. + * + * @throws Exception if error occur. + */ + public void testResourceSharedMode() throws Exception { + processTestGridifyResource(IgniteDeploymentMode.SHARED); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cc186b52/modules/aop/src/test/java/org/apache/ignite/testsuites/GridAopSelfTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/aop/src/test/java/org/apache/ignite/testsuites/GridAopSelfTestSuite.java b/modules/aop/src/test/java/org/apache/ignite/testsuites/GridAopSelfTestSuite.java index a8535a5..2fac60a 100644 --- a/modules/aop/src/test/java/org/apache/ignite/testsuites/GridAopSelfTestSuite.java +++ b/modules/aop/src/test/java/org/apache/ignite/testsuites/GridAopSelfTestSuite.java @@ -18,7 +18,7 @@ package org.apache.ignite.testsuites; import junit.framework.*; -import org.gridgain.grid.gridify.*; +import org.apache.ignite.gridify.*; import org.gridgain.testframework.*; import org.test.gridify.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cc186b52/modules/aop/src/test/java/org/apache/loadtests/direct/singlesplit/GridSingleSplitTestJobTarget.java ---------------------------------------------------------------------- diff --git a/modules/aop/src/test/java/org/apache/loadtests/direct/singlesplit/GridSingleSplitTestJobTarget.java b/modules/aop/src/test/java/org/apache/loadtests/direct/singlesplit/GridSingleSplitTestJobTarget.java new file mode 100644 index 0000000..7c3b73c --- /dev/null +++ b/modules/aop/src/test/java/org/apache/loadtests/direct/singlesplit/GridSingleSplitTestJobTarget.java @@ -0,0 +1,46 @@ +/* + * 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.apache.loadtests.direct.singlesplit; + +import org.apache.ignite.*; +import org.apache.ignite.compute.*; +import org.apache.ignite.compute.gridify.*; +import org.apache.loadtests.gridify.*; + +/** + * Single split test job target. + */ +public class GridSingleSplitTestJobTarget { + /** + * @param level Level. + * @param jobSes Job session. + * @return ALways returns {@code 1}. + * @throws IgniteCheckedException If failed. + */ + @SuppressWarnings("unused") + @Gridify(taskClass = GridifyLoadTestTask.class, timeout = 10000) + public int executeLoadTestJob(int level, ComputeTaskSession jobSes) throws IgniteCheckedException { + assert level > 0; + assert jobSes != null; + + jobSes.setAttribute("1st", 10000); + jobSes.setAttribute("2nd", 10000); + + return 1; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cc186b52/modules/aop/src/test/java/org/apache/loadtests/direct/singlesplit/GridSingleSplitTestTask.java ---------------------------------------------------------------------- diff --git a/modules/aop/src/test/java/org/apache/loadtests/direct/singlesplit/GridSingleSplitTestTask.java b/modules/aop/src/test/java/org/apache/loadtests/direct/singlesplit/GridSingleSplitTestTask.java new file mode 100644 index 0000000..86f75ce --- /dev/null +++ b/modules/aop/src/test/java/org/apache/loadtests/direct/singlesplit/GridSingleSplitTestTask.java @@ -0,0 +1,94 @@ +/* + * 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.apache.loadtests.direct.singlesplit; + +import org.apache.ignite.*; +import org.apache.ignite.cluster.*; +import org.apache.ignite.compute.*; +import org.apache.ignite.resources.*; + +import java.util.*; + +/** + * Single split test task. + */ +public class GridSingleSplitTestTask 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 Object execute() throws IgniteCheckedException { + assert jobSes != null; + + Integer arg = this.<Integer>argument(0); + + assert arg != null; + + return new GridSingleSplitTestJobTarget().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.getException() == null : "Load test jobs can never fail: " + res; + + retVal += (Integer)res.getData(); + } + + return retVal; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cc186b52/modules/aop/src/test/java/org/apache/loadtests/direct/singlesplit/GridSingleSplitsLoadTest.java ---------------------------------------------------------------------- diff --git a/modules/aop/src/test/java/org/apache/loadtests/direct/singlesplit/GridSingleSplitsLoadTest.java b/modules/aop/src/test/java/org/apache/loadtests/direct/singlesplit/GridSingleSplitsLoadTest.java new file mode 100644 index 0000000..7d12bea --- /dev/null +++ b/modules/aop/src/test/java/org/apache/loadtests/direct/singlesplit/GridSingleSplitsLoadTest.java @@ -0,0 +1,135 @@ +/* + * 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.apache.loadtests.direct.singlesplit; + +import org.apache.ignite.*; +import org.apache.ignite.compute.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.logger.log4j.*; +import org.apache.log4j.*; +import org.gridgain.grid.loadtest.*; +import org.apache.ignite.spi.communication.tcp.*; +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 split load test. + */ +@GridCommonTest(group = "Load Test") +public class GridSingleSplitsLoadTest extends GridCommonAbstractTest { + /** */ + public GridSingleSplitsLoadTest() { + super(true); + } + + /** {@inheritDoc} */ + @SuppressWarnings("ConstantConditions") + @Override protected IgniteConfiguration getConfiguration() throws Exception { + IgniteConfiguration cfg = super.getConfiguration(); + + cfg.setCommunicationSpi(new TcpCommunicationSpi()); + cfg.setDiscoverySpi(new TcpDiscoverySpi()); + + IgniteLog4jLogger log = (IgniteLog4jLogger)cfg.getGridLogger().getLogger(null); + + log.setLevel(Level.INFO); + + ((ThreadPoolExecutor)cfg.getExecutorService()).prestartAllCoreThreads(); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected long getTestTimeout() { + return (getTestDurationInMinutes() + 5) * 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(GridSingleSplitTestTask.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; + + IgniteCompute comp = ignite.compute().enableAsync(); + + comp.execute(new GridSingleSplitTestTask(), 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 (IgniteCheckedException e) { + error("Failed to execute grid task.", e); + + fail(); + } + } + } + }, getThreadCount(), "grid-notaop-load-test"); + + info("Final test statistics: " + stats); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cc186b52/modules/aop/src/test/java/org/apache/loadtests/direct/singlesplit/package.html ---------------------------------------------------------------------- diff --git a/modules/aop/src/test/java/org/apache/loadtests/direct/singlesplit/package.html b/modules/aop/src/test/java/org/apache/loadtests/direct/singlesplit/package.html new file mode 100644 index 0000000..135eb1a --- /dev/null +++ b/modules/aop/src/test/java/org/apache/loadtests/direct/singlesplit/package.html @@ -0,0 +1,24 @@ +<!-- + 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/cc186b52/modules/aop/src/test/java/org/apache/loadtests/gridify/GridifyLoadTestJobTarget.java ---------------------------------------------------------------------- diff --git a/modules/aop/src/test/java/org/apache/loadtests/gridify/GridifyLoadTestJobTarget.java b/modules/aop/src/test/java/org/apache/loadtests/gridify/GridifyLoadTestJobTarget.java new file mode 100644 index 0000000..dcafd5c --- /dev/null +++ b/modules/aop/src/test/java/org/apache/loadtests/gridify/GridifyLoadTestJobTarget.java @@ -0,0 +1,37 @@ +/* + * 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.apache.loadtests.gridify; + +import org.apache.ignite.compute.gridify.*; + +/** + * Gridify load test job target. + */ +public class GridifyLoadTestJobTarget { + /** + * @param level Level. + * @return Always returns {@code 1}. + */ + @SuppressWarnings("unused") + @Gridify(taskClass = GridifyLoadTestTask.class, timeout = 20000) + public int executeLoadTestJob(int level) { + assert level > 0; + + return 1; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cc186b52/modules/aop/src/test/java/org/apache/loadtests/gridify/GridifyLoadTestTask.java ---------------------------------------------------------------------- diff --git a/modules/aop/src/test/java/org/apache/loadtests/gridify/GridifyLoadTestTask.java b/modules/aop/src/test/java/org/apache/loadtests/gridify/GridifyLoadTestTask.java new file mode 100644 index 0000000..af1d708 --- /dev/null +++ b/modules/aop/src/test/java/org/apache/loadtests/gridify/GridifyLoadTestTask.java @@ -0,0 +1,70 @@ +/* + * 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.apache.loadtests.gridify; + +import org.apache.ignite.*; +import org.apache.ignite.compute.*; +import org.apache.ignite.compute.gridify.*; + +import java.io.*; +import java.util.*; + +/** + * Gridify load test task. + */ +public class GridifyLoadTestTask extends ComputeTaskSplitAdapter<GridifyArgument, Integer> { + /** {@inheritDoc} */ + @Override protected Collection<? extends ComputeJob> split(int gridSize, GridifyArgument arg) throws IgniteCheckedException { + assert gridSize > 0 : "Subgrid cannot be empty."; + + int jobsNum = (Integer)arg.getMethodParameters()[0]; + + assert jobsNum > 0; + + Collection<ComputeJobAdapter> jobs = new ArrayList<>(gridSize); + + for (int i = 0; i < jobsNum; i++) + jobs.add(new ComputeJobAdapter(1) { + @Override public Serializable execute() { + Integer arg = this.<Integer>argument(0); + + assert arg != null; + + return new GridifyLoadTestJobTarget().executeLoadTestJob(arg); + } + }); + + return jobs; + } + + /** {@inheritDoc} */ + @Override public Integer reduce(List<ComputeJobResult> results) throws IgniteCheckedException { + int retVal = 0; + + for (ComputeJobResult res : results) { + if (res.getException() != null) { + throw new IgniteCheckedException("Received exception in reduce method (load test jobs can never fail): " + res, + res.getException()); + } + + retVal += (Integer)res.getData(); + } + + return retVal; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cc186b52/modules/aop/src/test/java/org/apache/loadtests/gridify/GridifySingleSplitLoadTest.java ---------------------------------------------------------------------- diff --git a/modules/aop/src/test/java/org/apache/loadtests/gridify/GridifySingleSplitLoadTest.java b/modules/aop/src/test/java/org/apache/loadtests/gridify/GridifySingleSplitLoadTest.java new file mode 100644 index 0000000..6c1da57 --- /dev/null +++ b/modules/aop/src/test/java/org/apache/loadtests/gridify/GridifySingleSplitLoadTest.java @@ -0,0 +1,157 @@ +/* + * 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.apache.loadtests.gridify; + +import org.apache.ignite.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.logger.log4j.*; +import org.apache.log4j.*; +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.*; + +/** + * Gridify single split load test. + */ +@SuppressWarnings({"CatchGenericClass"}) +@GridCommonTest(group = "Load Test") +public class GridifySingleSplitLoadTest extends GridCommonAbstractTest { + /** */ + public GridifySingleSplitLoadTest() { + super(true); + } + + + /** {@inheritDoc} */ + @SuppressWarnings("ConstantConditions") + @Override public String getTestGridName() { + // Gridify task has empty grid name by default so we need to change it + // here. + return null; + } + + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration() throws Exception { + IgniteConfiguration cfg = super.getConfiguration(); + + /* Uncomment following code if you start it manually. */ + CommunicationSpi commSpi = new TcpCommunicationSpi(); + + cfg.setCommunicationSpi(commSpi); + + DiscoverySpi discoSpi = new TcpDiscoverySpi(); + + cfg.setDiscoverySpi(discoSpi); + /* + */ + @SuppressWarnings("TypeMayBeWeakened") + IgniteLog4jLogger log = (IgniteLog4jLogger)cfg.getGridLogger(); + + log.getLogger("org.gridgain.grid").setLevel(Level.INFO); + + ((ThreadPoolExecutor)cfg.getExecutorService()).prestartAllCoreThreads(); + + return cfg; + } + + /** + * @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; + } + + /** + * Load test grid. + * + * @throws Exception If task execution failed. + */ + @SuppressWarnings("unchecked") + public void testGridifyLoad() throws Exception { + Ignite ignite = G.ignite(getTestGridName()); + + 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); + } + + /** + * 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/cc186b52/modules/aop/src/test/java/org/gridgain/grid/marshaller/optimized/GridOptimizedMarshallerAopTest.java ---------------------------------------------------------------------- diff --git a/modules/aop/src/test/java/org/gridgain/grid/marshaller/optimized/GridOptimizedMarshallerAopTest.java b/modules/aop/src/test/java/org/gridgain/grid/marshaller/optimized/GridOptimizedMarshallerAopTest.java deleted file mode 100644 index 1f69635..0000000 --- a/modules/aop/src/test/java/org/gridgain/grid/marshaller/optimized/GridOptimizedMarshallerAopTest.java +++ /dev/null @@ -1,105 +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.grid.marshaller.optimized; - -import org.apache.ignite.compute.gridify.*; -import org.apache.ignite.configuration.*; -import org.apache.ignite.events.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.marshaller.optimized.*; -import org.apache.ignite.internal.util.typedef.*; -import org.gridgain.testframework.junits.common.*; - -import java.util.concurrent.atomic.*; - -import static org.apache.ignite.events.IgniteEventType.*; - -/** - * Test use GridOptimizedMarshaller and AspectJ AOP. - * - * The following configuration needs to be applied to enable AspectJ byte code - * weaving. - * <ul> - * <li> - * JVM configuration should include: - * <tt>-javaagent:[GRIDGAIN_HOME]/libs/aspectjweaver-1.7.2.jar</tt> - * </li> - * <li> - * Classpath should contain the <tt>[GRIDGAIN_HOME]/modules/tests/config/aop/aspectj</tt> folder. - * </li> - * </ul> - */ -public class GridOptimizedMarshallerAopTest extends GridCommonAbstractTest { - /** */ - private static final AtomicInteger cntr = new AtomicInteger(); - - /** - * Constructs a test. - */ - public GridOptimizedMarshallerAopTest() { - super(false /* start grid. */); - } - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - IgniteConfiguration cfg = new IgniteConfiguration(); - - cfg.setMarshaller(new IgniteOptimizedMarshaller()); - - G.start(cfg); - - assert G.allGrids().size() == 1; - } - - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { - stopAllGrids(); - - assert G.allGrids().isEmpty(); - } - - /** - * JUnit. - * - * @throws Exception If failed. - */ - public void testUp() throws Exception { - G.ignite().events().localListen(new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { - cntr.incrementAndGet(); - - return true; - } - }, EVT_TASK_FINISHED); - - gridify1(); - - assertEquals("Method gridify() wasn't executed on grid.", 1, cntr.get()); - } - - /** - * Method grid-enabled with {@link org.apache.ignite.compute.gridify.Gridify} annotation. - * <p> - * Note that default {@code Gridify} configuration is used, so this method - * will be executed on remote node with the same argument. - */ - @Gridify - private void gridify1() { - X.println("Executes on grid"); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cc186b52/modules/aop/src/test/java/org/gridgain/grid/p2p/GridP2PGridifySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/aop/src/test/java/org/gridgain/grid/p2p/GridP2PGridifySelfTest.java b/modules/aop/src/test/java/org/gridgain/grid/p2p/GridP2PGridifySelfTest.java deleted file mode 100644 index 6e79aec..0000000 --- a/modules/aop/src/test/java/org/gridgain/grid/p2p/GridP2PGridifySelfTest.java +++ /dev/null @@ -1,241 +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.grid.p2p; - -import org.apache.ignite.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.compute.gridify.*; -import org.apache.ignite.configuration.*; -import org.gridgain.testframework.*; -import org.gridgain.testframework.junits.common.*; - -import java.io.*; -import java.util.*; - -/** - * - */ -@SuppressWarnings({"ProhibitedExceptionDeclared"}) -@GridCommonTest(group = "P2P") -public class GridP2PGridifySelfTest extends GridCommonAbstractTest { - /** Current deployment mode. Used in {@link #getConfiguration(String)}. */ - private IgniteDeploymentMode depMode; - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - // Override P2P configuration to exclude Task and Job classes - cfg.setPeerClassLoadingLocalClassPathExclude(GridP2PTestTask.class.getName(), GridP2PTestJob.class.getName()); - - cfg.setDeploymentMode(depMode); - - return cfg; - } - - /** - * @param depMode deployment mode. - * @throws Exception If failed. - */ - @SuppressWarnings("unchecked") - private void processTestBothNodesDeploy(IgniteDeploymentMode depMode) throws Exception { - int res = 0; - - try { - this.depMode = depMode; - - Ignite ignite1 = startGrid(1); - startGrid(2); - - GridTestClassLoader tstClsLdr = new GridTestClassLoader( - Collections.singletonMap("org/gridgain/grid/p2p/p2p.properties", "resource=loaded"), - getClass().getClassLoader(), - GridP2PTestTask.class.getName(), GridP2PTestJob.class.getName() - ); - - Class<? extends ComputeTask<?, ?>> taskCls1 = (Class<? extends ComputeTask<?, ?>>)tstClsLdr.loadClass( - GridP2PTestTask.class.getName()); - - ignite1.compute().localDeployTask(taskCls1, taskCls1.getClassLoader()); - - res = executeGridify(1); - - ignite1.compute().undeployTask(taskCls1.getName()); - } - finally { - stopGrid(2); - stopGrid(1); - } - - // P2P deployment - assert res == 10 : "Invalid gridify result: " + res; - } - - /** - * @param res Result. - * @return The same value as parameter has. - */ - @Gridify(taskName = "org.gridgain.grid.p2p.GridP2PTestTask", - gridName="org.gridgain.grid.p2p.GridP2PGridifySelfTest1") - public int executeGridify(int res) { - return res; - } - - /** - * @param depMode deployment mode. - * @throws Exception If failed. - */ - private void processTestGridifyResource(IgniteDeploymentMode depMode) throws Exception { - try { - this.depMode = depMode; - - startGrid(1); - - Integer res = executeGridifyResource(1); - - // P2P deployment - assert res != null : "res != null"; - assert res == 1 : "Unexpected result [res=" + res + ", expected=0]"; - - info("Tests passed."); - } - finally { - stopGrid(1); - } - } - - /** - * Note that this method sends instance of test class to remote node. - * Be sure that this instance does not have none-serializable fields or references - * to the objects that could not be instantiated like class loaders and so on. - * - * @param res Result. - * @return The same value as parameter has. - */ - @Gridify(gridName="org.gridgain.grid.p2p.GridP2PGridifySelfTest1") - public Integer executeGridifyResource(int res) { - String path = "org/gridgain/grid/p2p/p2p.properties"; - - GridTestClassLoader tstClsLdr = new GridTestClassLoader( - GridP2PTestTask.class.getName(), - GridP2PTestJob.class.getName() - ); - - // Test property file load. - byte [] bytes = new byte[20]; - - try (InputStream in = tstClsLdr.getResourceAsStream(path)) { - if (in == null) { - System.out.println("Resource could not be loaded: " + path); - - return -2; - } - - in.read(bytes); - } - catch (IOException e) { - System.out.println("Failed to read from resource stream: " + e.getMessage()); - - return -3; - } - - String rsrcVal = new String(bytes).trim(); - - System.out.println("Remote resource content is : " + rsrcVal); - - if (!rsrcVal.equals("resource=loaded")) { - System.out.println("Invalid loaded resource value: " + rsrcVal); - - return -4; - } - - return res; - } - - /** - * Test GridDeploymentMode.ISOLATED mode. - * - * @throws Exception if error occur. - */ - public void testPrivateMode() throws Exception { - processTestBothNodesDeploy(IgniteDeploymentMode.PRIVATE); - } - - /** - * Test GridDeploymentMode.ISOLATED mode. - * - * @throws Exception if error occur. - */ - public void testIsolatedMode() throws Exception { - processTestBothNodesDeploy(IgniteDeploymentMode.ISOLATED); - } - - /** - * Test GridDeploymentMode.CONTINUOUS mode. - * - * @throws Exception if error occur. - */ - public void testContinuousMode() throws Exception { - processTestBothNodesDeploy(IgniteDeploymentMode.CONTINUOUS); - } - - /** - * Test GridDeploymentMode.SHARED mode. - * - * @throws Exception if error occur. - */ - public void testSharedMode() throws Exception { - processTestBothNodesDeploy(IgniteDeploymentMode.SHARED); - } - - /** - * Test GridDeploymentMode.ISOLATED mode. - * - * @throws Exception if error occur. - */ - public void testResourcePrivateMode() throws Exception { - processTestGridifyResource(IgniteDeploymentMode.PRIVATE); - } - - /** - * Test GridDeploymentMode.ISOLATED mode. - * - * @throws Exception if error occur. - */ - public void testResourceIsolatedMode() throws Exception { - processTestGridifyResource(IgniteDeploymentMode.ISOLATED); - } - - /** - * Test GridDeploymentMode.CONTINUOUS mode. - * - * @throws Exception if error occur. - */ - public void testResourceContinuousMode() throws Exception { - processTestGridifyResource(IgniteDeploymentMode.CONTINUOUS); - } - - /** - * Test GridDeploymentMode.SHARED mode. - * - * @throws Exception if error occur. - */ - public void testResourceSharedMode() throws Exception { - processTestGridifyResource(IgniteDeploymentMode.SHARED); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cc186b52/modules/aop/src/test/java/org/gridgain/loadtests/direct/singlesplit/GridSingleSplitTestJobTarget.java ---------------------------------------------------------------------- diff --git a/modules/aop/src/test/java/org/gridgain/loadtests/direct/singlesplit/GridSingleSplitTestJobTarget.java b/modules/aop/src/test/java/org/gridgain/loadtests/direct/singlesplit/GridSingleSplitTestJobTarget.java deleted file mode 100644 index c3c1090..0000000 --- a/modules/aop/src/test/java/org/gridgain/loadtests/direct/singlesplit/GridSingleSplitTestJobTarget.java +++ /dev/null @@ -1,46 +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.singlesplit; - -import org.apache.ignite.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.compute.gridify.*; -import org.gridgain.loadtests.gridify.*; - -/** - * Single split test job target. - */ -public class GridSingleSplitTestJobTarget { - /** - * @param level Level. - * @param jobSes Job session. - * @return ALways returns {@code 1}. - * @throws IgniteCheckedException If failed. - */ - @SuppressWarnings("unused") - @Gridify(taskClass = GridifyLoadTestTask.class, timeout = 10000) - public int executeLoadTestJob(int level, ComputeTaskSession jobSes) throws IgniteCheckedException { - assert level > 0; - assert jobSes != null; - - jobSes.setAttribute("1st", 10000); - jobSes.setAttribute("2nd", 10000); - - return 1; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cc186b52/modules/aop/src/test/java/org/gridgain/loadtests/direct/singlesplit/GridSingleSplitTestTask.java ---------------------------------------------------------------------- diff --git a/modules/aop/src/test/java/org/gridgain/loadtests/direct/singlesplit/GridSingleSplitTestTask.java b/modules/aop/src/test/java/org/gridgain/loadtests/direct/singlesplit/GridSingleSplitTestTask.java deleted file mode 100644 index d1c2c69..0000000 --- a/modules/aop/src/test/java/org/gridgain/loadtests/direct/singlesplit/GridSingleSplitTestTask.java +++ /dev/null @@ -1,94 +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.singlesplit; - -import org.apache.ignite.*; -import org.apache.ignite.cluster.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.resources.*; - -import java.util.*; - -/** - * Single split test task. - */ -public class GridSingleSplitTestTask 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 Object execute() throws IgniteCheckedException { - assert jobSes != null; - - Integer arg = this.<Integer>argument(0); - - assert arg != null; - - return new GridSingleSplitTestJobTarget().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.getException() == null : "Load test jobs can never fail: " + res; - - retVal += (Integer)res.getData(); - } - - return retVal; - } -}