Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 1A061200BD3 for ; Tue, 1 Nov 2016 03:37:26 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 185F5160B05; Tue, 1 Nov 2016 02:37:26 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 00182160B0E for ; Tue, 1 Nov 2016 03:37:21 +0100 (CET) Received: (qmail 33471 invoked by uid 500); 1 Nov 2016 02:37:21 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 33164 invoked by uid 99); 1 Nov 2016 02:37:20 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Nov 2016 02:37:20 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B4FDBEFE5E; Tue, 1 Nov 2016 02:37:20 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: shroman@apache.org To: commits@ignite.apache.org Date: Tue, 01 Nov 2016 02:37:25 -0000 Message-Id: <1b48c2f0fcf349f2a8eeebd316ae0a71@git.apache.org> In-Reply-To: <58ea4a590a9e4d1c9109181957ebbad1@git.apache.org> References: <58ea4a590a9e4d1c9109181957ebbad1@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [06/50] [abbrv] ignite git commit: IGNITE-3019 Implement config variations test for IgniteCompute archived-at: Tue, 01 Nov 2016 02:37:26 -0000 IGNITE-3019 Implement config variations test for IgniteCompute Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/24b24bf8 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/24b24bf8 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/24b24bf8 Branch: refs/heads/ignite-2788 Commit: 24b24bf8a8fedac55d41f69ebf75e08975ff1bea Parents: b674865 Author: sboikov Authored: Fri Apr 22 16:44:39 2016 +0300 Committer: shtykh_roman Committed: Fri May 13 16:11:14 2016 +0900 ---------------------------------------------------------------------- ...gniteComputeConfigVariationsFullApiTest.java | 2009 ++++++++++++++++++ .../configvariations/ConfigVariations.java | 2 +- .../IgniteConfigVariationsAbstractTest.java | 43 +- ...teBasicConfigVariationsFullApiTestSuite.java | 72 + 4 files changed, 2124 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/24b24bf8/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeConfigVariationsFullApiTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeConfigVariationsFullApiTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeConfigVariationsFullApiTest.java new file mode 100644 index 0000000..81cdb15 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeConfigVariationsFullApiTest.java @@ -0,0 +1,2009 @@ +/* + * 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.internal.processors.compute; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import javax.cache.configuration.Factory; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCompute; +import org.apache.ignite.IgniteException; +import org.apache.ignite.binary.BinaryObjectException; +import org.apache.ignite.binary.BinaryReader; +import org.apache.ignite.binary.BinaryWriter; +import org.apache.ignite.binary.Binarylizable; +import org.apache.ignite.compute.ComputeJob; +import org.apache.ignite.compute.ComputeJobAdapter; +import org.apache.ignite.compute.ComputeJobResult; +import org.apache.ignite.compute.ComputeTaskFuture; +import org.apache.ignite.compute.ComputeTaskSplitAdapter; +import org.apache.ignite.internal.util.typedef.T2; +import org.apache.ignite.lang.IgniteCallable; +import org.apache.ignite.lang.IgniteClosure; +import org.apache.ignite.lang.IgniteReducer; +import org.apache.ignite.lang.IgniteRunnable; +import org.apache.ignite.testframework.junits.IgniteConfigVariationsAbstractTest; +import org.jetbrains.annotations.Nullable; +import org.junit.Assert; + +/** + * Full API compute test. + */ +@SuppressWarnings("unchecked") +public class IgniteComputeConfigVariationsFullApiTest extends IgniteConfigVariationsAbstractTest { + /** Max job count. */ + private static final int MAX_JOB_COUNT = 10; + + /** Test cache name. */ + private static final String CACHE_NAME = "test"; + + /** */ + private static final String STR_VAL = "string value"; + + /** */ + private static final Object[] ARRAY_VAL = {"str0", "str1", "str2"}; + + /** Job factories. */ + private static final JobFactory[] jobFactories = new JobFactory[] { + new JobFactory(EchoJob.class), + new JobFactory(EchoJobExternalizable.class), + new JobFactory(EchoJobBinarylizable.class) + }; + + /** Closure factories. */ + private static final Factory[] closureFactories = new Factory[] { + new JobFactory(EchoClosure.class), + new JobFactory(EchoClosureExternalizable.class), + new JobFactory(EchoClosureBinarylizable.class) + }; + + /** Callable factories. */ + private static final Factory[] callableFactories = new Factory[] { + new JobFactory(EchoCallable.class), + new JobFactory(EchoCallableExternalizable.class), + new JobFactory(EchoCallableBinarylizable.class) + }; + + /** Runnable factories. */ + private static final Factory[] runnableFactories = new Factory[] { + new JobFactory(ComputeTestRunnable.class), + new JobFactory(ComputeTestRunnableExternalizable.class), + new JobFactory(ComputeTestRunnableBinarylizable.class) + }; + + /** + * @param expCnt Expected count. + * @param results Results. + * @param dataCls Data class. + */ + private static void checkResultsClassCount(final int expCnt, final Collection results, + final Class dataCls) { + int cnt = 0; + + for (Object o : results) { + if ((o != null) && dataCls.equals(o.getClass())) + ++cnt; + } + + assertEquals("Count of the result objects' type mismatch (null values are filtered)", expCnt, cnt); + } + + /** + * @return Expected valid result. + */ + private Collection createGoldenResults() { + Collection results = new ArrayList<>(MAX_JOB_COUNT); + + for (int i = 0; i < MAX_JOB_COUNT; ++i) + results.add(value(i - 1)); + + return results; + } + + /** + * @param msg Message. + * @param exp Expected. + * @param act Action. + */ + private void assertCollectionsEquals(String msg, Collection exp, Collection act) { + assertEquals(msg + "; Size are different", exp.size(), act.size()); + + for (Object o : exp) { + if (!act.contains(o)) { + error("Expected: " + exp.toString()); + error("Actual: " + act.toString()); + + assertTrue(msg + String.format("; actual collection doesn't contain the object [%s]", o), false); + } + } + } + + /** + * The test's wrapper provides variations of the argument data model and user factories. The test is launched {@code + * factories.length * DataMode.values().length} times with each datamodel and each factory. + * + * @param test Test. + * @param factories various factories + * @throws Exception If failed. + */ + protected void runTest(final Factory[] factories, final ComputeTest test) throws Exception { + runInAllDataModes(new TestRunnable() { + @Override public void run() throws Exception { + for (int i = 0; i < factories.length; i++) { + Factory factory = factories[i]; + + info("Running test with jobs model: " + factory.create().getClass().getSimpleName()); + + if (i != 0) + beforeTest(); + + try { + test.test(factory, grid(testedNodeIdx)); + } + finally { + if (i + 1 != factories.length) + afterTest(); + } + } + } + }); + } + + /** + * @throws Exception If failed. + */ + public void testExecuteTaskClass() throws Exception { + runTest(jobFactories, new ComputeTest() { + @Override public void test(Factory factory, Ignite ignite) throws Exception { + // Begin with negative to check 'null' value in the test. + final int[] i = {-1}; + + List results = ignite.compute().execute( + TestTask.class, + new T2<>((Factory)factory, + (Factory)new Factory() { + @Override public Object create() { + return value(i[0]++); + } + })); + + checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass()); + assertCollectionsEquals("Results value mismatch", createGoldenResults(), results); + } + }); + } + + /** + * @throws Exception If failed. + */ + public void testExecuteTask() throws Exception { + runTest(jobFactories, new ComputeTest() { + @Override public void test(Factory factory, Ignite ignite) throws Exception { + // Begin with negative to check 'null' value in the test. + final int[] i = {-1}; + + List results = ignite.compute().execute(new TestTask(), + new T2<>((Factory)factory, + (Factory)new Factory() { + @Override public Object create() { + return value(i[0]++); + } + })); + + checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass()); + assertCollectionsEquals("Results value mismatch", createGoldenResults(), results); + } + }); + } + + /** + * @throws Exception If failed. + */ + public void testBroadcastClosure() throws Exception { + runTest(closureFactories, new ComputeTest() { + @Override public void test(Factory factory, Ignite ignite) throws Exception { + final Collection resultsAllNull = ignite.compute() + .broadcast((IgniteClosure)factory.create(), null); + + assertEquals("Result's size mismatch: job must be run on all server nodes", + gridCount() - clientsCount(), resultsAllNull.size()); + + for (Object o : resultsAllNull) + assertNull("All results must be null", o); + + Collection resultsNotNull = ignite.compute() + .broadcast((IgniteClosure)factory.create(), value(0)); + + checkResultsClassCount(gridCount() - clientsCount(), resultsNotNull, value(0).getClass()); + } + }); + } + + /** + * @throws Exception If failed. + */ + public void testBroadcastCallable() throws Exception { + runTest(callableFactories, new ComputeTest() { + @Override public void test(Factory factory, Ignite ignite) throws Exception { + EchoCallable job = (EchoCallable)factory.create(); + job.setArg(null); + + final Collection resultsAllNull = ignite.compute() + .broadcast(job); + + assertEquals("Result's size mismatch: job must be run on all server nodes", + gridCount() - clientsCount(), resultsAllNull.size()); + + for (Object o : resultsAllNull) + assertNull("All results must be null", o); + + job.setArg(value(0)); + Collection resultsNotNull = ignite.compute() + .broadcast(job); + + checkResultsClassCount(gridCount() - clientsCount(), resultsNotNull, value(0).getClass()); + for (Object o : resultsNotNull) + assertEquals("Invalid broadcast results", value(0), o); + } + }); + } + + /** + * @throws Exception If failed. + */ + public void testBroadcastRunnable() throws Exception { + runTest(runnableFactories, new ComputeTest() { + @Override public void test(Factory factory, Ignite ignite) throws Exception { + IgniteRunnable job = (IgniteRunnable)factory.create(); + + ignite.compute().broadcast(job); + // All checks are inside the run() method of the job. + } + }); + } + + /** + * @throws Exception If failed. + */ + public void testRun() throws Exception { + runTest(runnableFactories, new ComputeTest() { + @Override public void test(Factory factory, Ignite ignite) throws Exception { + IgniteRunnable job = (IgniteRunnable)factory.create(); + + ignite.compute().run(job); + // All checks are inside the run() method of the job. + + Collection jobs = new ArrayList<>(MAX_JOB_COUNT); + + for (int i = 0; i < MAX_JOB_COUNT; ++i) + jobs.add((IgniteRunnable)factory.create()); + + ignite.compute().run(jobs); + // All checks are inside the run() method of the job. + } + }); + } + + /** + * @throws Exception If failed. + */ + public void testApplyAsync() throws Exception { + runTest(closureFactories, new ComputeTest() { + @Override public void test(Factory factory, Ignite ignite) throws Exception { + final IgniteCompute comp = ignite.compute().withAsync(); + + Collection> futures = new ArrayList<>(MAX_JOB_COUNT); + + for (int i = 0; i < MAX_JOB_COUNT; ++i) { + // value(i - 1): use negative argument of the value method to generate nullong value. + comp.apply((IgniteClosure)factory.create(), value(i - 1)); + + futures.add(comp.future()); + } + + // Wait for results. + Collection results = new ArrayList<>(MAX_JOB_COUNT); + + for (ComputeTaskFuture future : futures) + results.add(future.get()); + + checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass()); + assertCollectionsEquals("Results value mismatch", createGoldenResults(), results); + } + }); + } + + /** + * @throws Exception If failed. + */ + public void testApplySync() throws Exception { + runTest(closureFactories, new ComputeTest() { + @Override public void test(Factory factory, Ignite ignite) throws Exception { + Collection results = new ArrayList<>(MAX_JOB_COUNT); + + for (int i = 0; i < MAX_JOB_COUNT; ++i) { + // value(i - 1): use negative argument of the value method to generate nullong value. + results.add(ignite.compute().apply((IgniteClosure)factory.create(), value(i - 1))); + } + + checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass()); + assertCollectionsEquals("Results value mismatch", createGoldenResults(), results); + } + }); + } + + /** + * @throws Exception If failed. + */ + public void testApplyForCollection() throws Exception { + runTest(closureFactories, new ComputeTest() { + @Override public void test(Factory factory, Ignite ignite) throws Exception { + Collection params = new ArrayList<>(MAX_JOB_COUNT); + + for (int i = 0; i < MAX_JOB_COUNT; ++i) { + // value(i - 1): use negative argument of the value method to generate nullong value. + // Use type casting to avoid ambiguous for apply(Callable, Object) vs apply(Callable, Collection). + params.add((TestObject)value(i - 1)); + } + + Collection results = ignite.compute() + .apply((IgniteClosure)factory.create(), params); + + checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass()); + assertCollectionsEquals("Results value mismatch", createGoldenResults(), results); + } + }); + } + + /** + * @throws Exception If failed. + */ + public void testApplyForCollectionWithReducer() throws Exception { + runTest(closureFactories, new ComputeTest() { + @Override public void test(Factory factory, Ignite ignite) throws Exception { + Collection params = new ArrayList<>(MAX_JOB_COUNT); + + for (int i = 0; i < MAX_JOB_COUNT; ++i) { + // value(i - 1): use negative argument of the value method to generate nullong value. + params.add(value(i - 1)); + } + + boolean res = ignite.compute() + .apply((IgniteClosure)factory.create(), params, new IgniteReducer() { + + private Collection results = new ArrayList<>(MAX_JOB_COUNT); + + @Override public boolean collect(@Nullable Object o) { + results.add(o); + return true; + } + + @Override public Boolean reduce() { + checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass()); + assertCollectionsEquals("Results value mismatch", createGoldenResults(), results); + return true; + } + }); + assertTrue(res); + } + }); + } + + /** + * @throws Exception If failed. + */ + public void testCallAsync() throws Exception { + runTest(callableFactories, new ComputeTest() { + @Override public void test(Factory factory, Ignite ignite) throws Exception { + final IgniteCompute comp = ignite.compute().withAsync(); + + Collection> futures = new ArrayList<>(MAX_JOB_COUNT); + + for (int i = 0; i < MAX_JOB_COUNT; ++i) { + EchoCallable job = (EchoCallable)factory.create(); + job.setArg(value(i - 1)); + + comp.call(job); + futures.add(comp.future()); + } + + // Wait for results. + Collection results = new ArrayList<>(MAX_JOB_COUNT); + for (ComputeTaskFuture future : futures) + results.add(future.get()); + + checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass()); + assertCollectionsEquals("Results value mismatch", createGoldenResults(), results); + } + }); + } + + /** + * @throws Exception If failed. + */ + public void testCallSync() throws Exception { + runTest(callableFactories, new ComputeTest() { + @Override public void test(Factory factory, Ignite ignite) throws Exception { + Collection results = new ArrayList<>(MAX_JOB_COUNT); + + for (int i = 0; i < MAX_JOB_COUNT; ++i) { + EchoCallable job = (EchoCallable)factory.create(); + job.setArg(value(i - 1)); + results.add(ignite.compute().call(job)); + } + + checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass()); + assertCollectionsEquals("Results value mismatch", createGoldenResults(), results); + } + }); + } + + /** + * @throws Exception If failed. + */ + public void testCallCollection() throws Exception { + runTest(callableFactories, new ComputeTest() { + @Override public void test(Factory factory, Ignite ignite) throws Exception { + Collection jobs = new ArrayList<>(MAX_JOB_COUNT); + + for (int i = 0; i < MAX_JOB_COUNT; ++i) { + EchoCallable job = (EchoCallable)factory.create(); + job.setArg(value(i - 1)); + jobs.add(job); + } + + Collection results = ignite.compute().call(jobs); + + checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass()); + assertCollectionsEquals("Results value mismatch", createGoldenResults(), results); + } + }); + } + + /** + * @throws Exception If failed. + */ + public void testCallCollectionWithReducer() throws Exception { + runTest(callableFactories, new ComputeTest() { + @Override public void test(Factory factory, Ignite ignite) throws Exception { + Collection jobs = new ArrayList<>(MAX_JOB_COUNT); + + for (int i = 0; i < MAX_JOB_COUNT; ++i) { + EchoCallable job = (EchoCallable)factory.create(); + job.setArg(value(i - 1)); + jobs.add(job); + } + + boolean res = ignite.compute().call(jobs, new IgniteReducer() { + private Collection results = new ArrayList<>(MAX_JOB_COUNT); + + @Override public boolean collect(@Nullable Object o) { + results.add(o); + return true; + } + + @Override public Boolean reduce() { + checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass()); + assertCollectionsEquals("Results value mismatch", createGoldenResults(), results); + return true; + } + }); + + assertTrue(res); + } + }); + } + + /** + * @throws Exception If failed. + */ + public void testDummyAffinityCall() throws Exception { + runTest(callableFactories, new ComputeTest() { + @Override public void test(Factory factory, Ignite ignite) throws Exception { + ignite.getOrCreateCache(CACHE_NAME); + + final IgniteCompute comp = ignite.compute(); + + Collection results = new ArrayList<>(MAX_JOB_COUNT); + + for (int i = 0; i < MAX_JOB_COUNT; ++i) { + EchoCallable job = (EchoCallable)factory.create(); + + job.setArg(value(i - 1)); + + results.add(comp.affinityCall("test", key(0), job)); + } + + checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass()); + assertCollectionsEquals("Results value mismatch", createGoldenResults(), results); + } + }); + } + + /** + * @throws Exception If failed. + */ + public void testDummyAffinityRun() throws Exception { + runTest(runnableFactories, new ComputeTest() { + @Override public void test(Factory factory, Ignite ignite) throws Exception { + ignite.getOrCreateCache(CACHE_NAME); + + final IgniteCompute comp = ignite.compute(); + + for (int i = 0; i < MAX_JOB_COUNT; ++i) { + IgniteRunnable job = (IgniteRunnable)factory.create(); + + comp.affinityRun("test", key(0), job); + } + } + }); + } + + /** + * @throws Exception If failed. + */ + public void testDeployExecuteByName() throws Exception { + runTest(jobFactories, new ComputeTest() { + @Override public void test(Factory factory, Ignite ignite) throws Exception { + final int[] i = {-1}; + + final IgniteCompute comp = ignite.compute(); + + comp.localDeployTask(TestTask.class, TestTask.class.getClassLoader()); + + List results = ignite.compute().execute( + TestTask.class.getName(), + new T2<>((Factory)factory, + (Factory)new Factory() { + @Override public Object create() { + return value(i[0]++); + } + })); + + checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass()); + assertCollectionsEquals("Results value mismatch", createGoldenResults(), results); + + comp.undeployTask(TestTask.class.getName()); + } + }); + } + + /** + * Override the base method to return {@code null} value in case the valId is negative. + */ + @Nullable @Override public Object value(int valId) { + if (valId < 0) + return null; + + return super.value(valId); + } + + /** + * + */ + enum TestJobEnum { + /** */ + VALUE_0, + /** */ + VALUE_1, + /** */ + VALUE_2 + } + + /** + * + */ + public interface ComputeTest { + /** + * @param factory Factory. + * @param ignite Ignite instance to use. + * @throws Exception If failed. + */ + public void test(Factory factory, Ignite ignite) throws Exception; + } + + /** + * Creates set of jobs. + */ + static class TestTask + extends ComputeTaskSplitAdapter, Factory>, List> { + /** {@inheritDoc} */ + @Override protected Collection split(int gridSize, + T2, Factory> factoriesJobAndArg) throws IgniteException { + Collection jobs = new HashSet<>(); + + for (int i = 0; i < MAX_JOB_COUNT; ++i) { + ComputeJobAdapter job = factoriesJobAndArg.get1().create(); + + job.setArguments(factoriesJobAndArg.get2().create()); + jobs.add(job); + } + + return jobs; + } + + /** {@inheritDoc} */ + @Nullable @Override public List reduce(List results) throws IgniteException { + List ret = new ArrayList<>(results.size()); + + for (ComputeJobResult result : results) + ret.add(result.getData()); + + return ret; + } + } + + /** + * Echo job, serializable object. All fields are used only for serialization check. + */ + @SuppressWarnings({"PublicInnerClass"}) + public static class EchoJob extends ComputeJobAdapter { + /** */ + private boolean isVal; + + /** */ + private byte bVal; + + /** */ + private char cVal; + + /** */ + private short sVal; + + /** */ + private int intVal; + + /** */ + private long lVal; + + /** */ + private float fltVal; + + /** */ + private double dblVal; + + /** */ + private String strVal; + + /** */ + private Object[] arrVal; + + /** */ + private TestJobEnum eVal; + + /** + * Default constructor (required by ReflectionFactory). + */ + public EchoJob() { + // No-op. + } + + /** + * @param isVal boolean value. + * @param bVal byte value. + * @param cVal char value. + * @param sVal short value. + * @param intVal int value. + * @param lVal long value. + * @param fltVal float value. + * @param dblVal double value. + * @param strVal String value. + * @param arrVal Array value. + * @param val Enum value. + */ + public EchoJob(boolean isVal, byte bVal, char cVal, short sVal, int intVal, long lVal, float fltVal, + double dblVal, + String strVal, Object[] arrVal, TestJobEnum val) { + this.isVal = isVal; + this.bVal = bVal; + this.cVal = cVal; + this.sVal = sVal; + this.intVal = intVal; + this.lVal = lVal; + this.fltVal = fltVal; + this.dblVal = dblVal; + this.strVal = strVal; + this.arrVal = arrVal; + eVal = val; + } + + /** {@inheritDoc} */ + @Nullable @Override public Object execute() { + checkState(); + + return argument(0); + } + + /** + * Check the object state after serialization / deserialization + */ + protected void checkState() { + JobUtils.checkJobState(isVal, bVal, cVal, sVal, intVal, lVal, fltVal, dblVal, strVal, arrVal, eVal); + } + } + + /** + * Echo job, externalizable. All fields are used only for serialization check. + */ + @SuppressWarnings({"PublicInnerClass"}) + public static class EchoJobExternalizable extends EchoJob implements Externalizable { + /** */ + private boolean isVal; + + /** */ + private byte bVal; + + /** */ + private char cVal; + + /** */ + private short sVal; + + /** */ + private int intVal; + + /** */ + private long lVal; + + /** */ + private float fltVal; + + /** */ + private double dblVal; + + /** */ + private String strVal; + + /** */ + private Object[] arrVal; + + /** */ + private TestJobEnum eVal; + + /** + * Default constructor (required by {@link Externalizable}). + */ + public EchoJobExternalizable() { + // No-op. + } + + /** + * @param isVal boolean value. + * @param bVal byte value. + * @param cVal char value. + * @param sVal short value. + * @param intVal int value. + * @param lVal long value. + * @param fltVal float value. + * @param dblVal double value. + * @param strVal String value. + * @param arrVal Array value. + * @param val Enum value. + */ + public EchoJobExternalizable(boolean isVal, byte bVal, char cVal, short sVal, int intVal, long lVal, + float fltVal, + double dblVal, String strVal, Object[] arrVal, TestJobEnum val) { + this.isVal = isVal; + this.bVal = bVal; + this.cVal = cVal; + this.sVal = sVal; + this.intVal = intVal; + this.lVal = lVal; + this.fltVal = fltVal; + this.dblVal = dblVal; + this.strVal = strVal; + this.arrVal = arrVal; + eVal = val; + } + + /** + * {@inheritDoc} + */ + @Override public void writeExternal(ObjectOutput out) throws IOException { + out.writeObject(argument(0)); + + JobUtils.writeJobState(out, isVal, bVal, cVal, sVal, intVal, lVal, fltVal, dblVal, strVal, arrVal, eVal); + } + + /** + * {@inheritDoc} + */ + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + setArguments(in.readObject()); + + isVal = in.readBoolean(); + bVal = in.readByte(); + cVal = in.readChar(); + sVal = in.readShort(); + intVal = in.readInt(); + lVal = in.readLong(); + fltVal = in.readFloat(); + dblVal = in.readDouble(); + strVal = (String)in.readObject(); + arrVal = (Object[])in.readObject(); + eVal = (TestJobEnum)in.readObject(); + } + + /** + * {@inheritDoc} + */ + @Override protected void checkState() { + JobUtils.checkJobState(isVal, bVal, cVal, sVal, intVal, lVal, fltVal, dblVal, strVal, arrVal, eVal); + } + } + + /** + * Echo job, externalizable. All fields are used only for serialization check. + */ + @SuppressWarnings({"PublicInnerClass"}) + public static class EchoJobBinarylizable extends EchoJob implements Binarylizable { + /** */ + private boolean isVal; + + /** */ + private byte bVal; + + /** */ + private char cVal; + + /** */ + private short sVal; + + /** */ + private int intVal; + + /** */ + private long lVal; + + /** */ + private float fltVal; + + /** */ + private double dblVal; + + /** */ + private String strVal; + + /** */ + private Object[] arrVal; + + /** */ + private TestJobEnum eVal; + + /** + * Default constructor (required by ReflectionFactory). + */ + public EchoJobBinarylizable() { + // No-op. + } + + /** + * @param isVal boolean value. + * @param bVal byte value. + * @param cVal char value. + * @param sVal short value. + * @param intVal int value. + * @param lVal long value. + * @param fltVal float value. + * @param dblVal double value. + * @param strVal String value. + * @param arrVal Array value. + * @param val Enum value. + */ + public EchoJobBinarylizable(boolean isVal, byte bVal, char cVal, short sVal, int intVal, long lVal, + float fltVal, + double dblVal, String strVal, Object[] arrVal, TestJobEnum val) { + this.isVal = isVal; + this.bVal = bVal; + this.cVal = cVal; + this.sVal = sVal; + this.intVal = intVal; + this.lVal = lVal; + this.fltVal = fltVal; + this.dblVal = dblVal; + this.strVal = strVal; + this.arrVal = arrVal; + eVal = val; + } + + /** + * {@inheritDoc} + */ + @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException { + writer.writeObject("arg", argument(0)); + + JobUtils.writeJobState(writer, isVal, bVal, cVal, sVal, intVal, lVal, fltVal, dblVal, strVal, arrVal, eVal); + } + + /** + * {@inheritDoc} + */ + @Override public void readBinary(BinaryReader reader) throws BinaryObjectException { + Object arg = reader.readObject("arg"); + + setArguments(arg); + + isVal = reader.readBoolean("isVal"); + bVal = reader.readByte("bVal"); + cVal = reader.readChar("cVal"); + sVal = reader.readShort("sVal"); + intVal = reader.readInt("intVal"); + lVal = reader.readLong("lVal"); + fltVal = reader.readFloat("fltVal"); + dblVal = reader.readDouble("dblVal"); + strVal = reader.readString("strVal"); + arrVal = reader.readObjectArray("arrVal"); + eVal = reader.readEnum("eVal"); + } + + /** + * {@inheritDoc} + */ + @Override protected void checkState() { + JobUtils.checkJobState(isVal, bVal, cVal, sVal, intVal, lVal, fltVal, dblVal, strVal, arrVal, eVal); + } + } + + /** + * Echo job, serializable object. All fields are used only for serialization check. + */ + @SuppressWarnings({"PublicInnerClass"}) + public static class EchoClosure implements IgniteClosure { + /** */ + private boolean isVal; + + /** */ + private byte bVal; + + /** */ + private char cVal; + + /** */ + private short sVal; + + /** */ + private int intVal; + + /** */ + private long lVal; + + /** */ + private float fltVal; + + /** */ + private double dblVal; + + /** */ + private String strVal; + + /** */ + private Object[] arrVal; + + /** */ + private TestJobEnum eVal; + + /** + * Default constructor. + */ + public EchoClosure() { + // No-op. + } + + /** + * @param isVal boolean value. + * @param bVal byte value. + * @param cVal char value. + * @param sVal short value. + * @param intVal int value. + * @param lVal long value. + * @param fltVal float value. + * @param dblVal double value. + * @param strVal String value. + * @param arrVal Array value. + * @param val Enum value. + */ + public EchoClosure(boolean isVal, byte bVal, char cVal, short sVal, int intVal, long lVal, float fltVal, + double dblVal, + String strVal, Object[] arrVal, TestJobEnum val) { + this.isVal = isVal; + this.bVal = bVal; + this.cVal = cVal; + this.sVal = sVal; + this.intVal = intVal; + this.lVal = lVal; + this.fltVal = fltVal; + this.dblVal = dblVal; + this.strVal = strVal; + this.arrVal = arrVal; + eVal = val; + } + + /** {@inheritDoc} */ + @Override public Object apply(Object arg) { + checkState(); + + return arg; + } + + /** + * Check the object state after serialization / deserialization + */ + protected void checkState() { + JobUtils.checkJobState(isVal, bVal, cVal, sVal, intVal, lVal, fltVal, dblVal, strVal, arrVal, eVal); + } + } + + /** + * Echo closure, externalizable. All fields are used only for serialization check. + */ + @SuppressWarnings({"PublicInnerClass"}) + public static class EchoClosureExternalizable extends EchoClosure implements Externalizable { + /** */ + private boolean isVal; + + /** */ + private byte bVal; + + /** */ + private char cVal; + + /** */ + private short sVal; + + /** */ + private int intVal; + + /** */ + private long lVal; + + /** */ + private float fltVal; + + /** */ + private double dblVal; + + /** */ + private String strVal; + + /** */ + private Object[] arrVal; + + /** */ + private TestJobEnum eVal; + + /** + * Default constructor (required by Externalizable). + */ + public EchoClosureExternalizable() { + // No-op + } + + /** + * @param isVal boolean value. + * @param bVal byte value. + * @param cVal char value. + * @param sVal short value. + * @param intVal int value. + * @param lVal long value. + * @param fltVal float value. + * @param dblVal double value. + * @param strVal String value. + * @param arrVal Array value. + * @param val Enum value. + */ + public EchoClosureExternalizable(boolean isVal, byte bVal, char cVal, short sVal, int intVal, long lVal, + float fltVal, + double dblVal, String strVal, Object[] arrVal, TestJobEnum val) { + this.isVal = isVal; + this.bVal = bVal; + this.cVal = cVal; + this.sVal = sVal; + this.intVal = intVal; + this.lVal = lVal; + this.fltVal = fltVal; + this.dblVal = dblVal; + this.strVal = strVal; + this.arrVal = arrVal; + eVal = val; + } + + /** {@inheritDoc} */ + @Override public void writeExternal(ObjectOutput out) throws IOException { + JobUtils.writeJobState(out, isVal, bVal, cVal, sVal, intVal, lVal, fltVal, dblVal, strVal, arrVal, eVal); + } + + /** {@inheritDoc} */ + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + isVal = in.readBoolean(); + bVal = in.readByte(); + cVal = in.readChar(); + sVal = in.readShort(); + intVal = in.readInt(); + lVal = in.readLong(); + fltVal = in.readFloat(); + dblVal = in.readDouble(); + strVal = (String)in.readObject(); + arrVal = (Object[])in.readObject(); + eVal = (TestJobEnum)in.readObject(); + } + + /** + * {@inheritDoc} + */ + @Override protected void checkState() { + JobUtils.checkJobState(isVal, bVal, cVal, sVal, intVal, lVal, fltVal, dblVal, strVal, arrVal, eVal); + } + } + + /** + * Echo closure, externalizable. All fields are used only for serialization check. + */ + @SuppressWarnings({"PublicInnerClass"}) + public static class EchoClosureBinarylizable extends EchoClosure implements Binarylizable { + /** */ + private boolean isVal; + + /** */ + private byte bVal; + + /** */ + private char cVal; + + /** */ + private short sVal; + + /** */ + private int intVal; + + /** */ + private long lVal; + + /** */ + private float fltVal; + + /** */ + private double dblVal; + + /** */ + private String strVal; + + /** */ + private Object[] arrVal; + + /** */ + private TestJobEnum eVal; + + /** + * @param isVal boolean value. + * @param bVal byte value. + * @param cVal char value. + * @param sVal short value. + * @param intVal int value. + * @param lVal long value. + * @param fltVal float value. + * @param dblVal double value. + * @param strVal String value. + * @param arrVal Array value. + * @param val Enum value. + */ + public EchoClosureBinarylizable(boolean isVal, byte bVal, char cVal, short sVal, int intVal, long lVal, + float fltVal, + double dblVal, String strVal, Object[] arrVal, TestJobEnum val) { + this.isVal = isVal; + this.bVal = bVal; + this.cVal = cVal; + this.sVal = sVal; + this.intVal = intVal; + this.lVal = lVal; + this.fltVal = fltVal; + this.dblVal = dblVal; + this.strVal = strVal; + this.arrVal = arrVal; + eVal = val; + } + + /** {@inheritDoc} */ + @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException { + JobUtils.writeJobState(writer, isVal, bVal, cVal, sVal, intVal, lVal, fltVal, dblVal, strVal, arrVal, eVal); + } + + /** {@inheritDoc} */ + @Override public void readBinary(BinaryReader reader) throws BinaryObjectException { + isVal = reader.readBoolean("isVal"); + bVal = reader.readByte("bVal"); + cVal = reader.readChar("cVal"); + sVal = reader.readShort("sVal"); + intVal = reader.readInt("intVal"); + lVal = reader.readLong("lVal"); + fltVal = reader.readFloat("fltVal"); + dblVal = reader.readDouble("dblVal"); + strVal = reader.readString("strVal"); + arrVal = reader.readObjectArray("arrVal"); + eVal = reader.readEnum("eVal"); + } + + /** + * {@inheritDoc} + */ + @Override protected void checkState() { + JobUtils.checkJobState(isVal, bVal, cVal, sVal, intVal, lVal, fltVal, dblVal, strVal, arrVal, eVal); + } + } + + /** + * Test callable, serializable object. All fields are used only for serialization check. + */ + @SuppressWarnings({"PublicInnerClass"}) + public static class EchoCallable implements IgniteCallable { + /** */ + protected Object arg; + + /** */ + private boolean isVal; + + /** */ + private byte bVal; + + /** */ + private char cVal; + + /** */ + private short sVal; + + /** */ + private int intVal; + + /** */ + private long lVal; + + /** */ + private float fltVal; + + /** */ + private double dblVal; + + /** */ + private String strVal; + + /** */ + private Object[] arrVal; + + /** */ + private TestJobEnum eVal; + + /** + * Default constructor. + */ + public EchoCallable() { + // No-op. + } + + /** + * @param isVal boolean value. + * @param bVal byte value. + * @param cVal char value. + * @param sVal short value. + * @param intVal int value. + * @param lVal long value. + * @param fltVal float value. + * @param dblVal double value. + * @param strVal String value. + * @param arrVal Array value. + * @param val Enum value. + */ + public EchoCallable(boolean isVal, byte bVal, char cVal, short sVal, int intVal, long lVal, float fltVal, + double dblVal, + String strVal, Object[] arrVal, TestJobEnum val) { + this.isVal = isVal; + this.bVal = bVal; + this.cVal = cVal; + this.sVal = sVal; + this.intVal = intVal; + this.lVal = lVal; + this.fltVal = fltVal; + this.dblVal = dblVal; + this.strVal = strVal; + this.arrVal = arrVal; + eVal = val; + } + + /** + * @param arg Argument. + */ + void setArg(@Nullable Object arg) { + this.arg = arg; + } + + /** {@inheritDoc} */ + @Nullable @Override public Object call() throws Exception { + checkState(); + + return arg; + } + + /** + * Check the object state after serialization / deserialization + */ + protected void checkState() { + JobUtils.checkJobState(isVal, bVal, cVal, sVal, intVal, lVal, fltVal, dblVal, strVal, arrVal, eVal); + } + } + + /** + * Echo callable, externalizable object. All fields are used only for serialization check. + */ + @SuppressWarnings({"PublicInnerClass"}) + public static class EchoCallableExternalizable extends EchoCallable implements Externalizable { + /** */ + private boolean isVal; + + /** */ + private byte bVal; + + /** */ + private char cVal; + + /** */ + private short sVal; + + /** */ + private int intVal; + + /** */ + private long lVal; + + /** */ + private float fltVal; + + /** */ + private double dblVal; + + /** */ + private String strVal; + + /** */ + private Object[] arrVal; + + /** */ + private TestJobEnum eVal; + + /** + * Default constructor. + */ + public EchoCallableExternalizable() { + // No-op. + } + + /** + * @param isVal boolean value. + * @param bVal byte value. + * @param cVal char value. + * @param sVal short value. + * @param intVal int value. + * @param lVal long value. + * @param fltVal float value. + * @param dblVal double value. + * @param strVal String value. + * @param arrVal Array value. + * @param val Enum value. + */ + public EchoCallableExternalizable(boolean isVal, byte bVal, char cVal, short sVal, int intVal, long lVal, + float fltVal, + double dblVal, String strVal, Object[] arrVal, TestJobEnum val) { + this.isVal = isVal; + this.bVal = bVal; + this.cVal = cVal; + this.sVal = sVal; + this.intVal = intVal; + this.lVal = lVal; + this.fltVal = fltVal; + this.dblVal = dblVal; + this.strVal = strVal; + this.arrVal = arrVal; + eVal = val; + } + + /** + * {@inheritDoc} + */ + @Override public void writeExternal(ObjectOutput out) throws IOException { + out.writeObject(arg); + + JobUtils.writeJobState(out, isVal, bVal, cVal, sVal, intVal, lVal, fltVal, dblVal, strVal, arrVal, eVal); + } + + /** + * {@inheritDoc} + */ + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + arg = in.readObject(); + + isVal = in.readBoolean(); + bVal = in.readByte(); + cVal = in.readChar(); + sVal = in.readShort(); + intVal = in.readInt(); + lVal = in.readLong(); + fltVal = in.readFloat(); + dblVal = in.readDouble(); + strVal = (String)in.readObject(); + arrVal = (Object[])in.readObject(); + eVal = (TestJobEnum)in.readObject(); + } + + /** + * {@inheritDoc} + */ + @Override protected void checkState() { + JobUtils.checkJobState(isVal, bVal, cVal, sVal, intVal, lVal, fltVal, dblVal, strVal, arrVal, eVal); + } + } + + /** + * Echo callable, binarylizable object. All fields are used only for serialization check. + */ + @SuppressWarnings({"PublicInnerClass"}) + public static class EchoCallableBinarylizable extends EchoCallable implements Binarylizable { + /** */ + private boolean isVal; + + /** */ + private byte bVal; + + /** */ + private char cVal; + + /** */ + private short sVal; + + /** */ + private int intVal; + + /** */ + private long lVal; + + /** */ + private float fltVal; + + /** */ + private double dblVal; + + /** */ + private String strVal; + + /** */ + private Object[] arrVal; + + /** */ + private TestJobEnum eVal; + + /** + * Default constructor. + */ + public EchoCallableBinarylizable() { + // No-op. + } + + /** + * @param isVal boolean value. + * @param bVal byte value. + * @param cVal char value. + * @param sVal short value. + * @param intVal int value. + * @param lVal long value. + * @param fltVal float value. + * @param dblVal double value. + * @param strVal String value. + * @param arrVal Array value. + * @param val Enum value. + */ + public EchoCallableBinarylizable(boolean isVal, byte bVal, char cVal, short sVal, int intVal, long lVal, + float fltVal, + double dblVal, String strVal, Object[] arrVal, TestJobEnum val) { + this.isVal = isVal; + this.bVal = bVal; + this.cVal = cVal; + this.sVal = sVal; + this.intVal = intVal; + this.lVal = lVal; + this.fltVal = fltVal; + this.dblVal = dblVal; + this.strVal = strVal; + this.arrVal = arrVal; + eVal = val; + } + + /** + * {@inheritDoc} + */ + @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException { + writer.writeObject("arg", arg); + + JobUtils.writeJobState(writer, isVal, bVal, cVal, sVal, intVal, lVal, fltVal, dblVal, strVal, arrVal, eVal); + } + + /** + * {@inheritDoc} + */ + @Override public void readBinary(BinaryReader reader) throws BinaryObjectException { + arg = reader.readObject("arg"); + + isVal = reader.readBoolean("isVal"); + bVal = reader.readByte("bVal"); + cVal = reader.readChar("cVal"); + sVal = reader.readShort("sVal"); + intVal = reader.readInt("intVal"); + lVal = reader.readLong("lVal"); + fltVal = reader.readFloat("fltVal"); + dblVal = reader.readDouble("dblVal"); + strVal = reader.readString("strVal"); + arrVal = reader.readObjectArray("arrVal"); + eVal = reader.readEnum("eVal"); + } + + /** + * {@inheritDoc} + */ + @Override protected void checkState() { + JobUtils.checkJobState(isVal, bVal, cVal, sVal, intVal, lVal, fltVal, dblVal, strVal, arrVal, eVal); + } + } + + /** + * Test runnable, serializable object. All fields are used only for serialization check. + */ + @SuppressWarnings({"PublicInnerClass"}) + public static class ComputeTestRunnable implements IgniteRunnable { + /** */ + private boolean isVal; + + /** */ + private byte bVal; + + /** */ + private char cVal; + + /** */ + private short sVal; + + /** */ + private int intVal; + + /** */ + private long lVal; + + /** */ + private float fltVal; + + /** */ + private double dblVal; + + /** */ + private String strVal; + + /** */ + private Object[] arrVal; + + /** */ + private TestJobEnum eVal; + + /** + * Default constructor. + */ + public ComputeTestRunnable() { + // No-op. + } + + /** + * @param isVal boolean value. + * @param bVal byte value. + * @param cVal char value. + * @param sVal short value. + * @param intVal int value. + * @param lVal long value. + * @param fltVal float value. + * @param dblVal double value. + * @param strVal String value. + * @param arrVal Array value. + * @param val Enum value. + */ + public ComputeTestRunnable(boolean isVal, byte bVal, char cVal, short sVal, int intVal, long lVal, float fltVal, + double dblVal, String strVal, Object[] arrVal, TestJobEnum val) { + this.isVal = isVal; + this.bVal = bVal; + this.cVal = cVal; + this.sVal = sVal; + this.intVal = intVal; + this.lVal = lVal; + this.fltVal = fltVal; + this.dblVal = dblVal; + this.strVal = strVal; + this.arrVal = arrVal; + eVal = val; + } + + /** + * {@inheritDoc} + */ + @Override public void run() { + checkState(); + } + + /** + * Check the object state after serialization / deserialization + */ + protected void checkState() { + JobUtils.checkJobState(isVal, bVal, cVal, sVal, intVal, lVal, fltVal, dblVal, strVal, arrVal, eVal); + } + } + + /** + * Test runnable, externalizable object. All fields are used only for serialization check. + */ + public static class ComputeTestRunnableExternalizable extends ComputeTestRunnable implements Externalizable { + /** */ + private boolean isVal; + + /** */ + private byte bVal; + + /** */ + private char cVal; + + /** */ + private short sVal; + + /** */ + private int intVal; + + /** */ + private long lVal; + + /** */ + private float fltVal; + + /** */ + private double dblVal; + + /** */ + private String strVal; + + /** */ + private Object[] arrVal; + + /** */ + private TestJobEnum eVal; + + /** + * Default constructor (required by Externalizable). + */ + public ComputeTestRunnableExternalizable() { + // No-op + } + + /** + * @param isVal boolean value. + * @param bVal byte value. + * @param cVal char value. + * @param sVal short value. + * @param intVal int value. + * @param lVal long value. + * @param fltVal float value. + * @param dblVal double value. + * @param strVal String value. + * @param arrVal Array value. + * @param val Enum value. + */ + public ComputeTestRunnableExternalizable(boolean isVal, byte bVal, char cVal, short sVal, int intVal, long lVal, + float fltVal, double dblVal, String strVal, Object[] arrVal, + TestJobEnum val) { + this.intVal = intVal; + this.isVal = isVal; + this.bVal = bVal; + this.cVal = cVal; + this.sVal = sVal; + this.lVal = lVal; + this.fltVal = fltVal; + this.dblVal = dblVal; + this.strVal = strVal; + this.arrVal = arrVal; + eVal = val; + } + + /** + * {@inheritDoc} + */ + @Override public void writeExternal(ObjectOutput out) throws IOException { + JobUtils.writeJobState(out, isVal, bVal, cVal, sVal, intVal, lVal, fltVal, dblVal, strVal, arrVal, eVal); + } + + /** + * {@inheritDoc} + */ + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + isVal = in.readBoolean(); + bVal = in.readByte(); + cVal = in.readChar(); + sVal = in.readShort(); + intVal = in.readInt(); + lVal = in.readLong(); + fltVal = in.readFloat(); + dblVal = in.readDouble(); + strVal = (String)in.readObject(); + arrVal = (Object[])in.readObject(); + eVal = (TestJobEnum)in.readObject(); + } + + /** + * {@inheritDoc} + */ + @Override protected void checkState() { + JobUtils.checkJobState(isVal, bVal, cVal, sVal, intVal, lVal, fltVal, dblVal, strVal, arrVal, eVal); + } + } + + /** + * Test runnable, binarylizable object. All fields are used only for serialization check. + */ + public static class ComputeTestRunnableBinarylizable extends ComputeTestRunnable implements Binarylizable { + /** */ + private boolean isVal; + + /** */ + private byte bVal; + + /** */ + private char cVal; + + /** */ + private short sVal; + + /** */ + private int intVal; + + /** */ + private long lVal; + + /** */ + private float fltVal; + + /** */ + private double dblVal; + + /** */ + private String strVal; + + /** */ + private Object[] arrVal; + + /** */ + private TestJobEnum eVal; + + /** + * Default constructor. + */ + public ComputeTestRunnableBinarylizable() { + // No-op. + } + + /** + * @param isVal boolean value. + * @param bVal byte value. + * @param cVal char value. + * @param sVal short value. + * @param intVal int value. + * @param lVal long value. + * @param fltVal float value. + * @param dblVal double value. + * @param strVal String value. + * @param arrVal Array value. + * @param val Enum value. + */ + public ComputeTestRunnableBinarylizable(boolean isVal, byte bVal, char cVal, short sVal, int intVal, long lVal, + float fltVal, double dblVal, String strVal, Object[] arrVal, + TestJobEnum val) { + this.isVal = isVal; + this.bVal = bVal; + this.cVal = cVal; + this.sVal = sVal; + this.intVal = intVal; + this.lVal = lVal; + this.fltVal = fltVal; + this.dblVal = dblVal; + this.strVal = strVal; + this.arrVal = arrVal; + eVal = val; + } + + /** + * {@inheritDoc} + */ + @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException { + JobUtils.writeJobState(writer, isVal, bVal, cVal, sVal, intVal, lVal, fltVal, dblVal, strVal, arrVal, eVal); + } + + /** + * {@inheritDoc} + */ + @Override public void readBinary(BinaryReader reader) throws BinaryObjectException { + isVal = reader.readBoolean("isVal"); + bVal = reader.readByte("bVal"); + cVal = reader.readChar("cVal"); + sVal = reader.readShort("sVal"); + intVal = reader.readInt("intVal"); + lVal = reader.readLong("lVal"); + fltVal = reader.readFloat("fltVal"); + dblVal = reader.readDouble("dblVal"); + strVal = reader.readString("strVal"); + arrVal = reader.readObjectArray("arrVal"); + eVal = reader.readEnum("eVal"); + } + + /** + * {@inheritDoc} + */ + @Override protected void checkState() { + JobUtils.checkJobState(isVal, bVal, cVal, sVal, intVal, lVal, fltVal, dblVal, strVal, arrVal, eVal); + } + } + + /** + * Creates test jobs with tested parameters + */ + private static class JobFactory implements Factory { + /** */ + private static final long serialVersionUID = 0; + + /** */ + private Class cls; + + /** + * @param cls Class. + */ + JobFactory(Class cls) { + this.cls = cls; + } + + /** {@inheritDoc} */ + @Override public T create() { + try { + Constructor constructor = cls.getConstructor(Boolean.TYPE, Byte.TYPE, Character.TYPE, + Short.TYPE, Integer.TYPE, Long.TYPE, Float.TYPE, Double.TYPE, String.class, Object[].class, TestJobEnum.class); + + return (T)constructor.newInstance(true, + Byte.MAX_VALUE, + Character.MAX_VALUE, + Short.MAX_VALUE, + Integer.MAX_VALUE, + Long.MAX_VALUE, + Float.MAX_VALUE, + Double.MAX_VALUE, + STR_VAL, ARRAY_VAL, + TestJobEnum.VALUE_2); + } + catch (NoSuchMethodException | InstantiationException | InvocationTargetException | + IllegalAccessException e) { + throw new IgniteException("Failed to create object using default constructor: " + cls, e); + } + } + } + + /** + * Collection of utility methods to simplify EchoJob*, EchoCLosure*, EchoCallable* and ComputeTestRunnable* classes + */ + private static class JobUtils { + /** + * @param isVal boolean value. + * @param bVal byte value. + * @param cVal char value. + * @param sVal short value. + * @param intVal int value. + * @param lVal long value. + * @param fltVal float value. + * @param dblVal double value. + * @param strVal String value. + * @param arrVal Array value. + * @param eVal Enum value. + */ + private static void checkJobState(boolean isVal, byte bVal, char cVal, short sVal, int intVal, long lVal, + float fltVal, + double dblVal, String strVal, Object[] arrVal, TestJobEnum eVal) { + assertEquals(true, isVal); + assertEquals(Byte.MAX_VALUE, bVal); + assertEquals(Character.MAX_VALUE, cVal); + assertEquals(Short.MAX_VALUE, sVal); + assertEquals(Integer.MAX_VALUE, intVal); + assertEquals(Long.MAX_VALUE, lVal); + assertEquals(Float.MAX_VALUE, fltVal); + assertEquals(Double.MAX_VALUE, dblVal); + assertEquals(STR_VAL, strVal); + Assert.assertArrayEquals(ARRAY_VAL, arrVal); + assertEquals(TestJobEnum.VALUE_2, eVal); + } + + /** + * @param writer Writer. + * @param isVal boolean value. + * @param bVal byte value. + * @param cVal char value. + * @param sVal short value. + * @param intVal int value. + * @param lVal long value. + * @param fltVal float value. + * @param dblVal double value. + * @param strVal String value. + * @param arrVal Array value. + * @param eVal Enum value. + * @throws BinaryObjectException If failed. + */ + private static void writeJobState(BinaryWriter writer, boolean isVal, byte bVal, char cVal, short sVal, + int intVal, long lVal, float fltVal, double dblVal, String strVal, + Object[] arrVal, TestJobEnum eVal) throws BinaryObjectException { + writer.writeBoolean("isVal", isVal); + writer.writeByte("bVal", bVal); + writer.writeChar("cVal", cVal); + writer.writeShort("sVal", sVal); + writer.writeInt("intVal", intVal); + writer.writeLong("lVal", lVal); + writer.writeFloat("fltVal", fltVal); + writer.writeDouble("dblVal", dblVal); + writer.writeString("strVal", strVal); + writer.writeObjectArray("arrVal", arrVal); + writer.writeEnum("eVal", eVal); + } + + /** + * @param out Out. + * @param isVal boolean value. + * @param bVal byte value. + * @param cVal char value. + * @param sVal short value. + * @param intVal int value. + * @param lVal long value. + * @param fltVal float value. + * @param dblVal double value. + * @param strVal String value. + * @param arrVal Array value. + * @param eVal Enum value. + * @throws IOException If failed. + */ + private static void writeJobState(ObjectOutput out, boolean isVal, byte bVal, char cVal, short sVal, + int intVal, long lVal, float fltVal, double dblVal, String strVal, Object[] arrVal, + TestJobEnum eVal) throws IOException { + out.writeBoolean(isVal); + out.writeByte(bVal); + out.writeChar(cVal); + out.writeShort(sVal); + out.writeInt(intVal); + out.writeLong(lVal); + out.writeFloat(fltVal); + out.writeDouble(dblVal); + out.writeObject(strVal); + out.writeObject(arrVal); + out.writeObject(eVal); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/24b24bf8/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariations.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariations.java b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariations.java index e5856f0..0be6d50 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariations.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariations.java @@ -215,7 +215,7 @@ public class ConfigVariations { /** * @return Marshaller. */ - private static Factory optimizedMarshallerFactory() { + public static Factory optimizedMarshallerFactory() { return new Factory() { @Override public OptimizedMarshaller create() { OptimizedMarshaller marsh = new OptimizedMarshaller(true); http://git-wip-us.apache.org/repos/asf/ignite/blob/24b24bf8/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java index b22f289..258eba8 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java @@ -21,13 +21,16 @@ import java.io.Externalizable; import java.io.File; import java.io.IOException; import java.io.ObjectInput; +import java.io.ObjectInputStream; import java.io.ObjectOutput; +import java.io.ObjectOutputStream; import java.io.Serializable; import org.apache.commons.io.FileUtils; import org.apache.ignite.Ignition; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.marshaller.jdk.JdkMarshaller; import org.apache.ignite.testframework.configvariations.VariationsTestsConfig; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; @@ -197,6 +200,12 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr for (int i = 0; i < DataMode.values().length; i++) { dataMode = DataMode.values()[i]; + if ((getConfiguration().getMarshaller() instanceof JdkMarshaller) + && (dataMode == DataMode.PLANE_OBJECT)) { + info("Skip test for JdkMarshaller & PLANE_OBJECT data mode"); + continue; + } + info("Running test in data mode: " + dataMode); if (i != 0) @@ -289,6 +298,13 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr protected TestEnum enumVal; /** + * Default constructor must be accessible for deserialize subclasses by JDK serialization API. + */ + TestObject() { + // No-op. + } + + /** * @param val Value. */ TestObject(int val) { @@ -345,6 +361,31 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr public SerializableObject(int val) { super(val); } + + /** + * Custom serialization of superclass because {@link TestObject} is non-serializable. + * + * @param out output stream. + * @throws IOException if de-serialization failed. + */ + private void writeObject(ObjectOutputStream out) throws IOException { + out.writeInt(val); + out.writeObject(strVal); + out.writeObject(enumVal); + } + + /** + * Custom deserialization of superclass because {@link TestObject} is non-serializable. + * + * @param in input stream + * @throws IOException if de-serialization failed. + * @throws ClassNotFoundException if de-serialization failed. + */ + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { + val = in.readInt(); + strVal = (String)in.readObject(); + enumVal = (TestEnum)in.readObject(); + } } /** @@ -354,7 +395,7 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr /** * Default constructor. */ - ExternalizableObject() { + public ExternalizableObject() { super(-1); } http://git-wip-us.apache.org/repos/asf/ignite/blob/24b24bf8/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeBasicConfigVariationsFullApiTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeBasicConfigVariationsFullApiTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeBasicConfigVariationsFullApiTestSuite.java new file mode 100644 index 0000000..1be932a --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeBasicConfigVariationsFullApiTestSuite.java @@ -0,0 +1,72 @@ +/* + * 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.testsuites; + +import junit.framework.TestSuite; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.binary.BinaryMarshaller; +import org.apache.ignite.internal.processors.compute.IgniteComputeConfigVariationsFullApiTest; +import org.apache.ignite.marshaller.jdk.JdkMarshaller; +import org.apache.ignite.testframework.configvariations.ConfigParameter; +import org.apache.ignite.testframework.configvariations.ConfigVariations; +import org.apache.ignite.testframework.configvariations.ConfigVariationsTestSuiteBuilder; +import org.apache.ignite.testframework.configvariations.Parameters; + +/** + * Full API compute test. + */ +public class IgniteComputeBasicConfigVariationsFullApiTestSuite extends TestSuite { + /** */ + @SuppressWarnings("unchecked") + private static final ConfigParameter[][] BASIC_COMPUTE_SET = new ConfigParameter[][] { + Parameters.objectParameters("setMarshaller", + Parameters.factory(JdkMarshaller.class), + Parameters.factory(BinaryMarshaller.class), + ConfigVariations.optimizedMarshallerFactory() + ), + Parameters.booleanParameters("setPeerClassLoadingEnabled"), + Parameters.booleanParameters("setMarshalLocalJobs"), + }; + + /** + * @return Compute API test suite. + * @throws Exception If failed. + */ + public static TestSuite suite() throws Exception { + TestSuite suite = new TestSuite("Compute New Full API Test Suite"); + + suite.addTest(new ConfigVariationsTestSuiteBuilder( + "Single server", + IgniteComputeConfigVariationsFullApiTest.class) + .igniteParams(BASIC_COMPUTE_SET) + .gridsCount(1) + .build()); + + // Tests run on server (node#0) & client(node#1). + suite.addTest(new ConfigVariationsTestSuiteBuilder( + "3 servers, 1 client", + IgniteComputeConfigVariationsFullApiTest.class) + .igniteParams(BASIC_COMPUTE_SET) + .gridsCount(4) + .testedNodesCount(2) + .withClients() + .build()); + + return suite; + } +}