Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4D59B17E3F for ; Fri, 4 Sep 2015 13:31:34 +0000 (UTC) Received: (qmail 58773 invoked by uid 500); 4 Sep 2015 13:31:34 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 58716 invoked by uid 500); 4 Sep 2015 13:31:34 -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 58702 invoked by uid 99); 4 Sep 2015 13:31:34 -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; Fri, 04 Sep 2015 13:31:34 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 034F2E01F5; Fri, 4 Sep 2015 13:31:34 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vozerov@apache.org To: commits@ignite.apache.org Date: Fri, 04 Sep 2015 13:31:33 -0000 Message-Id: <3a426a8bb9ba4e78b40db8a70740aff9@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [01/37] ignite git commit: IGNITE-1348: Moved GridGain's .Net module to Ignite. Repository: ignite Updated Branches: refs/heads/master 4d3c1f07b -> 5cec202cb http://git-wip-us.apache.org/repos/asf/ignite/blob/5cec202c/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs ---------------------------------------------------------------------- diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs index 73c9bcb..2b0ab8e 100644 --- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs +++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs @@ -20,6 +20,8 @@ namespace Apache.Ignite.Core.Tests using System; using System.Diagnostics; using System.Reflection; + using Apache.Ignite.Core.Tests.Memory; + using NUnit.ConsoleRunner; public static class TestRunner { @@ -31,16 +33,15 @@ namespace Apache.Ignite.Core.Tests //TestOne(typeof(ContinuousQueryAtomiclBackupTest), "TestInitialQuery"); - //TestAll(typeof(IgnitionTest)); - - TestAllInAssembly(); + TestAll(typeof (ExecutableTest)); + //TestAllInAssembly(); } private static void TestOne(Type testClass, string method) { string[] args = { "/run:" + testClass.FullName + "." + method, Assembly.GetAssembly(testClass).Location }; - int returnCode = NUnit.ConsoleRunner.Runner.Main(args); + int returnCode = Runner.Main(args); if (returnCode != 0) Console.Beep(); @@ -50,7 +51,7 @@ namespace Apache.Ignite.Core.Tests { string[] args = { "/run:" + testClass.FullName, Assembly.GetAssembly(testClass).Location }; - int returnCode = NUnit.ConsoleRunner.Runner.Main(args); + int returnCode = Runner.Main(args); if (returnCode != 0) Console.Beep(); @@ -58,9 +59,9 @@ namespace Apache.Ignite.Core.Tests private static void TestAllInAssembly() { - string[] args = { Assembly.GetAssembly(typeof(IgnitionTest)).Location }; + string[] args = { Assembly.GetAssembly(typeof(InteropMemoryTest)).Location }; - int returnCode = NUnit.ConsoleRunner.Runner.Main(args); + int returnCode = Runner.Main(args); if (returnCode != 0) Console.Beep(); http://git-wip-us.apache.org/repos/asf/ignite/blob/5cec202c/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs ---------------------------------------------------------------------- diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs new file mode 100644 index 0000000..ca45d68 --- /dev/null +++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs @@ -0,0 +1,292 @@ +/* + * 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. + */ + +namespace Apache.Ignite.Core.Tests +{ + using System; + using System.Collections.Concurrent; + using System.Collections.Generic; + using System.Linq; + using System.Threading; + using Apache.Ignite.Core.Impl; + using Apache.Ignite.Core.Tests.Process; + using NUnit.Framework; + + /// + /// Test utility methods. + /// + public static class TestUtils + { + /** Indicates long running and/or memory/cpu intensive test. */ + public const string CategoryIntensive = "LONG_TEST"; + + /** */ + public const int DfltBusywaitSleepInterval = 200; + + /** */ + + private static readonly IList TestJvmOpts = Environment.Is64BitProcess + ? new List + { + "-XX:+HeapDumpOnOutOfMemoryError", + "-Xms1g", + "-Xmx4g", + "-ea" + } + : new List + { + "-XX:+HeapDumpOnOutOfMemoryError", + "-Xms512m", + "-Xmx512m", + "-ea", + "-DIGNITE_ATOMIC_CACHE_DELETE_HISTORY_SIZE=1000" + }; + + /** */ + private static readonly IList JvmDebugOpts = + new List { "-Xdebug", "-Xnoagent", "-Djava.compiler=NONE", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005" }; + + /** */ + public static bool JvmDebug = true; + + /** */ + [ThreadStatic] + private static Random _random; + + /** */ + private static int _seed = Environment.TickCount; + + /// + /// Kill GridGain processes. + /// + public static void KillProcesses() + { + IgniteProcess.KillAll(); + } + + /// + /// + /// + public static Random Random + { + get { return _random ?? (_random = new Random(Interlocked.Increment(ref _seed))); } + } + + /// + /// + /// + /// + public static IList TestJavaOptions() + { + IList ops = new List(TestJvmOpts); + + if (JvmDebug) + { + foreach (string opt in JvmDebugOpts) + ops.Add(opt); + } + + return ops; + } + + /// + /// + /// + /// + public static string CreateTestClasspath() + { + return IgniteManager.CreateClasspath(forceTestClasspath: true); + } + + /// + /// + /// + /// + /// + public static void RunMultiThreaded(Action action, int threadNum) + { + List threads = new List(threadNum); + + var errors = new ConcurrentBag(); + + for (int i = 0; i < threadNum; i++) + { + threads.Add(new Thread(() => + { + try + { + action(); + } + catch (Exception e) + { + errors.Add(e); + } + })); + } + + foreach (Thread thread in threads) + thread.Start(); + + foreach (Thread thread in threads) + thread.Join(); + + foreach (var ex in errors) + Assert.Fail("Unexpected exception: " + ex); + } + + /// + /// + /// + /// + /// + /// Duration of test execution in seconds + public static void RunMultiThreaded(Action action, int threadNum, int duration) + { + List threads = new List(threadNum); + + var errors = new ConcurrentBag(); + + bool stop = false; + + for (int i = 0; i < threadNum; i++) + { + threads.Add(new Thread(() => + { + try + { + while (true) + { + Thread.MemoryBarrier(); + + // ReSharper disable once AccessToModifiedClosure + if (stop) + break; + + action(); + } + } + catch (Exception e) + { + errors.Add(e); + } + })); + } + + foreach (Thread thread in threads) + thread.Start(); + + Thread.Sleep(duration * 1000); + + stop = true; + + Thread.MemoryBarrier(); + + foreach (Thread thread in threads) + thread.Join(); + + foreach (var ex in errors) + Assert.Fail("Unexpected exception: " + ex); + } + + /// + /// Wait for particular topology size. + /// + /// Grid. + /// Size. + /// Timeout. + /// + /// True if topology took required size. + /// + public static bool WaitTopology(this IIgnite grid, int size, int timeout) + { + int left = timeout; + + while (true) + { + if (grid.Cluster.Nodes().Count != size) + { + if (left > 0) + { + Thread.Sleep(100); + + left -= 100; + } + else + break; + } + else + return true; + } + + return false; + } + + /// + /// Asserts that the handle registry is empty. + /// + /// Timeout, in milliseconds. + /// Grids to check. + public static void AssertHandleRegistryIsEmpty(int timeout, params IIgnite[] grids) + { + foreach (var g in grids) + AssertHandleRegistryIsEmpty(g, timeout); + } + + /// + /// Asserts that the handle registry is empty. + /// + /// The grid to check. + /// Timeout, in milliseconds. + public static void AssertHandleRegistryIsEmpty(IIgnite grid, int timeout) + { + var handleRegistry = ((Ignite)grid).HandleRegistry; + + if (WaitForCondition(() => handleRegistry.Count == 0, timeout)) + return; + + var items = handleRegistry.GetItems(); + + if (items.Any()) + Assert.Fail("HandleRegistry is not empty in grid '{0}':\n '{1}'", grid.Name, + items.Select(x => x.ToString()).Aggregate((x, y) => x + "\n" + y)); + } + + /// + /// Waits for condition, polling in busy wait loop. + /// + /// Condition. + /// Timeout, in milliseconds. + /// True if condition predicate returned true within interval; false otherwise. + public static bool WaitForCondition(Func cond, int timeout) + { + if (timeout <= 0) + return cond(); + + var maxTime = DateTime.Now.AddMilliseconds(timeout + DfltBusywaitSleepInterval); + + while (DateTime.Now < maxTime) + { + if (cond()) + return true; + + Thread.Sleep(DfltBusywaitSleepInterval); + } + + return false; + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/5cec202c/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs ---------------------------------------------------------------------- diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs new file mode 100644 index 0000000..a49ee1b --- /dev/null +++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs @@ -0,0 +1,107 @@ +/* + * 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. + */ + +namespace Apache.Ignite.Core.Tests +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Reflection; + using Apache.Ignite.Core.Impl.Portable; + using Apache.Ignite.Core.Tests.TestDll; + using NUnit.Framework; + + /// + /// tests. + /// + public class TypeResolverTest + { + /// + /// Tests generic type resolve. + /// + [Test] + public void TestGenerics() + { + var testTypes = new[] + { + typeof (TestGenericPortable), + typeof (TestGenericPortable), + typeof (TestGenericPortable>), + typeof (TestGenericPortable>>), + typeof (TestGenericPortable>>>>), + typeof (List>>>>>), + typeof (TestGenericPortable), + typeof (TestGenericPortable>), + typeof (TestGenericPortable), + typeof (TestGenericPortable>) + }; + + foreach (var type in testTypes) + { + // Without assembly + var resolvedType = new TypeResolver().ResolveType(type.FullName); + Assert.AreEqual(type.FullName, resolvedType.FullName); + + // With assembly + resolvedType = new TypeResolver().ResolveType(type.FullName, type.Assembly.FullName); + Assert.AreEqual(type.FullName, resolvedType.FullName); + + // Assembly-qualified + resolvedType = new TypeResolver().ResolveType(type.AssemblyQualifiedName); + Assert.AreEqual(type.FullName, resolvedType.FullName); + } + } + + /// + /// Tests loading a type from referenced assembly that is not yet loaded. + /// + [Test] + public void TestReferencedAssemblyLoading() + { + const string dllName = "Apache.Ignite.Core.Tests.TestDll"; + + const string typeName = "Apache.Ignite.Core.Tests.TestDll.TestClass"; + + // Check that the dll is not yet loaded + Assert.IsFalse(AppDomain.CurrentDomain.GetAssemblies().Any(x => x.FullName.StartsWith(dllName))); + + // Check that the dll is referenced by current assembly + Assert.IsTrue(Assembly.GetExecutingAssembly().GetReferencedAssemblies() + .Any(x => x.FullName.StartsWith(dllName))); + + // Check resolver + var type = new TypeResolver().ResolveType(typeName); + + Assert.IsNotNull(type); + Assert.AreEqual(typeName, type.FullName); + Assert.IsNotNull(Activator.CreateInstance(type)); + + // At this moment the dll should be loaded + Assert.IsTrue(AppDomain.CurrentDomain.GetAssemblies().Any(x => x.FullName.StartsWith(dllName))); + } + + /// + /// Unused method that forces C# compiler to include TestDll assembly reference. + /// Without this, compiler will remove the reference as unused. + /// However, since it is never called, TestDll does not get loaded. + /// + public void UnusedMethod() + { + Assert.IsNotNull(typeof(TestClass)); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/5cec202c/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputeBroadcastTask.java ---------------------------------------------------------------------- diff --git a/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputeBroadcastTask.java b/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputeBroadcastTask.java new file mode 100644 index 0000000..c721e16 --- /dev/null +++ b/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputeBroadcastTask.java @@ -0,0 +1,73 @@ +/* + * 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.platform; + +import org.apache.ignite.Ignite; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.compute.ComputeJob; +import org.apache.ignite.compute.ComputeJobAdapter; +import org.apache.ignite.compute.ComputeJobResult; +import org.apache.ignite.compute.ComputeTaskAdapter; +import org.apache.ignite.resources.IgniteInstanceResource; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +/** + * Task collecting IDs of all nodes where it was executed. + */ +public class PlatformComputeBroadcastTask extends ComputeTaskAdapter> { + /** {@inheritDoc} */ + @Nullable @Override public Map map(List subgrid, @Nullable Object arg) { + Map jobs = new HashMap<>(); + + for (ClusterNode node : subgrid) + jobs.put(new BroadcastJob(), node); + + return jobs; + } + + /** {@inheritDoc} */ + @Nullable @Override public Collection reduce(List results) { + List ids = new ArrayList<>(); + + for (ComputeJobResult res : results) + ids.add((UUID)res.getData()); + + return ids; + } + + /** + * Job. + */ + private static class BroadcastJob extends ComputeJobAdapter { + /** */ + @IgniteInstanceResource + private Ignite ignite; + + /** {@inheritDoc} */ + @Nullable @Override public Object execute() { + return ignite.cluster().localNode().id(); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/5cec202c/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputeDecimalTask.java ---------------------------------------------------------------------- diff --git a/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputeDecimalTask.java b/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputeDecimalTask.java new file mode 100644 index 0000000..a14e481 --- /dev/null +++ b/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputeDecimalTask.java @@ -0,0 +1,106 @@ +/* + * 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.platform; + +import org.apache.ignite.IgniteException; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.compute.ComputeJob; +import org.apache.ignite.compute.ComputeJobAdapter; +import org.apache.ignite.compute.ComputeJobResult; +import org.apache.ignite.compute.ComputeTaskAdapter; +import org.apache.ignite.internal.util.typedef.F; +import org.jetbrains.annotations.Nullable; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.math.BigDecimal; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +@SuppressWarnings({"ConstantConditions", "UnusedDeclaration"}) +public class PlatformComputeDecimalTask extends ComputeTaskAdapter { + /** {@inheritDoc} */ + @Nullable @Override public Map map(List subgrid, @Nullable Object[] arg) { + return Collections.singletonMap(new DecimalJob((BigDecimal)arg[0], (String)arg[1]), F.first(subgrid)); + } + + /** {@inheritDoc} */ + @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Nullable @Override public BigDecimal reduce(List results) { + ComputeJobResult res = results.get(0); + + if (res.getException() != null) + throw res.getException(); + else + return results.get(0).getData(); + } + + /** + * Job. + */ + private static class DecimalJob extends ComputeJobAdapter implements Externalizable { + /** Value. */ + private BigDecimal val; + + /** Value as string. */ + private String valStr; + + /** + * Constructor. + */ + public DecimalJob() { + // No-op. + } + + /** + * Constructor. + * + * @param val Value. + * @param valStr Value as string. + */ + private DecimalJob(BigDecimal val, String valStr) { + this.val = val; + this.valStr = valStr; + } + + /** {@inheritDoc} */ + @Nullable @Override public Object execute() { + BigDecimal exp = new BigDecimal(valStr.replace(',', '.')); + + if (val != null && !exp.equals(val)) + throw new IgniteException("Actual=" + val); + + return exp; + } + + /** {@inheritDoc} */ + @Override public void writeExternal(ObjectOutput out) throws IOException { + out.writeObject(val); + out.writeObject(valStr); + } + + /** {@inheritDoc} */ + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + val = (BigDecimal)in.readObject(); + valStr = (String)in.readObject(); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/5cec202c/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java ---------------------------------------------------------------------- diff --git a/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java b/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java new file mode 100644 index 0000000..f64ca7d --- /dev/null +++ b/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java @@ -0,0 +1,188 @@ +/* + * 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.platform; + +import org.apache.ignite.IgniteException; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.compute.ComputeJob; +import org.apache.ignite.compute.ComputeJobAdapter; +import org.apache.ignite.compute.ComputeJobResult; +import org.apache.ignite.compute.ComputeTaskAdapter; +import org.apache.ignite.internal.util.typedef.F; +import org.jetbrains.annotations.Nullable; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + * Test task producing result without any arguments. + */ +public class PlatformComputeEchoTask extends ComputeTaskAdapter { + /** Type: NULL. */ + private static final int TYPE_NULL = 0; + + /** Type: byte. */ + private static final int TYPE_BYTE = 1; + + /** Type: bool. */ + private static final int TYPE_BOOL = 2; + + /** Type: short. */ + private static final int TYPE_SHORT = 3; + + /** Type: char. */ + private static final int TYPE_CHAR = 4; + + /** Type: int. */ + private static final int TYPE_INT = 5; + + /** Type: long. */ + private static final int TYPE_LONG = 6; + + /** Type: float. */ + private static final int TYPE_FLOAT = 7; + + /** Type: double. */ + private static final int TYPE_DOUBLE = 8; + + /** Type: array. */ + private static final int TYPE_ARRAY = 9; + + /** Type: collection. */ + private static final int TYPE_COLLECTION = 10; + + /** Type: map. */ + private static final int TYPE_MAP = 11; + + /** Type: portable object which exists in all platforms. */ + private static final int TYPE_PORTABLE = 12; + + /** Type: portable object which exists only in Java. */ + private static final int TYPE_PORTABLE_JAVA = 13; + + /** Type: object array. */ + private static final int TYPE_OBJ_ARRAY = 14; + + /** Type: portable object array. */ + private static final int TYPE_PORTABLE_ARRAY = 15; + + /** Type: enum. */ + private static final int TYPE_ENUM = 16; + + /** Type: enum array. */ + private static final int TYPE_ENUM_ARRAY = 17; + + /** {@inheritDoc} */ + @Nullable @Override public Map map(List subgrid, + @Nullable Integer arg) { + return Collections.singletonMap(new EchoJob(arg), F.first(subgrid)); + } + + /** {@inheritDoc} */ + @Nullable @Override public Object reduce(List results) { + return results.get(0).getData(); + } + + /** + * Job. + */ + private static class EchoJob extends ComputeJobAdapter { + /** Type. */ + private Integer type; + + /** + * Constructor. + * + * @param type Result type. + */ + public EchoJob(Integer type) { + this.type = type; + } + + /** {@inheritDoc} */ + @Nullable @Override public Object execute() { + switch (type) { + case TYPE_NULL: + return null; + + case TYPE_BYTE: + return (byte)1; + + case TYPE_BOOL: + return true; + + case TYPE_SHORT: + return (short)1; + + case TYPE_CHAR: + return (char)1; + + case TYPE_INT: + return 1; + + case TYPE_LONG: + return (long)1; + + case TYPE_FLOAT: + return (float)1; + + case TYPE_DOUBLE: + return (double)1; + + case TYPE_ARRAY: + return new int[] { 1 }; + + case TYPE_COLLECTION: + return Collections.singletonList(1); + + case TYPE_MAP: + return Collections.singletonMap(1, 1); + + case TYPE_PORTABLE: + return new PlatformComputePortable(1); + + case TYPE_PORTABLE_JAVA: + return new PlatformComputeJavaPortable(1); + + case TYPE_OBJ_ARRAY: + return new String[] { "foo", "bar", "baz" }; + + case TYPE_PORTABLE_ARRAY: + return new PlatformComputePortable[] { + new PlatformComputePortable(1), + new PlatformComputePortable(2), + new PlatformComputePortable(3) + }; + + case TYPE_ENUM: + return PlatformComputeEnum.BAR; + + case TYPE_ENUM_ARRAY: + return new PlatformComputeEnum[] { + PlatformComputeEnum.BAR, + PlatformComputeEnum.BAZ, + PlatformComputeEnum.FOO + }; + + default: + throw new IgniteException("Unknown type: " + type); + } + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/5cec202c/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputeEnum.java ---------------------------------------------------------------------- diff --git a/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputeEnum.java b/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputeEnum.java new file mode 100644 index 0000000..7fc0623 --- /dev/null +++ b/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputeEnum.java @@ -0,0 +1,28 @@ +/* + * 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.platform; + +/** + * Test enum. + */ +public enum PlatformComputeEnum +{ + FOO, + BAR, + BAZ +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/5cec202c/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputeJavaPortable.java ---------------------------------------------------------------------- diff --git a/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputeJavaPortable.java b/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputeJavaPortable.java new file mode 100644 index 0000000..7a940c4 --- /dev/null +++ b/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputeJavaPortable.java @@ -0,0 +1,39 @@ +/* + * 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.platform; + +/** + * Portable object defined only in Java. + */ +public class PlatformComputeJavaPortable extends PlatformComputePortable { + /** + * Constructor. + */ + public PlatformComputeJavaPortable() { + // No-op. + } + + /** + * Constructor. + * + * @param field Field. + */ + public PlatformComputeJavaPortable(int field) { + super(field); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/5cec202c/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputePortable.java ---------------------------------------------------------------------- diff --git a/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputePortable.java b/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputePortable.java new file mode 100644 index 0000000..f31f093 --- /dev/null +++ b/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputePortable.java @@ -0,0 +1,42 @@ +/* + * 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.platform; + +/** + * Portable object for task tests. + */ +public class PlatformComputePortable { + /** Field. */ + public int field; + + /** + * Constructor. + */ + public PlatformComputePortable() { + // No-op. + } + + /** + * Constructor, + * + * @param field Field. + */ + public PlatformComputePortable(int field) { + this.field = field; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/5cec202c/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputePortableArgTask.java ---------------------------------------------------------------------- diff --git a/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputePortableArgTask.java b/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputePortableArgTask.java new file mode 100644 index 0000000..0e8b825 --- /dev/null +++ b/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputePortableArgTask.java @@ -0,0 +1,119 @@ +/* + * 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.platform; + +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteException; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.compute.ComputeJob; +import org.apache.ignite.compute.ComputeJobAdapter; +import org.apache.ignite.compute.ComputeJobResult; +import org.apache.ignite.compute.ComputeTaskAdapter; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.portable.PortableMetadata; +import org.apache.ignite.portable.PortableObject; +import org.apache.ignite.resources.IgniteInstanceResource; +import org.jetbrains.annotations.Nullable; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + * Task working with portable argument. + */ +public class PlatformComputePortableArgTask extends ComputeTaskAdapter { + /** {@inheritDoc} */ + @Nullable @Override public Map map(List subgrid, @Nullable Object arg) { + return Collections.singletonMap(new PortableArgJob(arg), F.first(subgrid)); + } + + /** {@inheritDoc} */ + @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Nullable @Override public Integer reduce(List results) { + ComputeJobResult res = results.get(0); + + if (res.getException() != null) + throw res.getException(); + else + return results.get(0).getData(); + } + + /** + * Job. + */ + private static class PortableArgJob extends ComputeJobAdapter implements Externalizable { + /** */ + @IgniteInstanceResource + private Ignite ignite; + + /** Argument. */ + private Object arg; + + /** + * Constructor. + */ + public PortableArgJob() { + // No-op. + } + + /** + * Constructor. + * + * @param arg Argument. + */ + private PortableArgJob(Object arg) { + this.arg = arg; + } + + /** {@inheritDoc} */ + @Nullable @Override public Object execute() { + PortableObject arg0 = ((PortableObject)arg); + + PortableMetadata meta = ignite.portables().metadata(arg0.typeId()); + + if (meta == null) + throw new IgniteException("Metadata doesn't exist."); + + if (meta.fields() == null || !meta.fields().contains("Field")) + throw new IgniteException("Field metadata doesn't exist."); + + if (!F.eq("int", meta.fieldTypeName("Field"))) + throw new IgniteException("Invalid field type: " + meta.fieldTypeName("Field")); + + if (meta.affinityKeyFieldName() != null) + throw new IgniteException("Unexpected affinity key: " + meta.affinityKeyFieldName()); + + return arg0.field("field"); + } + + /** {@inheritDoc} */ + @Override public void writeExternal(ObjectOutput out) throws IOException { + out.writeObject(arg); + } + + /** {@inheritDoc} */ + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + arg = in.readObject(); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/5cec202c/modules/platform/src/test/java/org/apache/ignite/platform/PlatformEventsWriteEventTask.java ---------------------------------------------------------------------- diff --git a/modules/platform/src/test/java/org/apache/ignite/platform/PlatformEventsWriteEventTask.java b/modules/platform/src/test/java/org/apache/ignite/platform/PlatformEventsWriteEventTask.java new file mode 100644 index 0000000..d9dee9d --- /dev/null +++ b/modules/platform/src/test/java/org/apache/ignite/platform/PlatformEventsWriteEventTask.java @@ -0,0 +1,146 @@ +/* + * 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.platform; + +import org.apache.ignite.Ignite; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.compute.ComputeJob; +import org.apache.ignite.compute.ComputeJobAdapter; +import org.apache.ignite.compute.ComputeJobResult; +import org.apache.ignite.compute.ComputeTaskAdapter; +import org.apache.ignite.events.CacheEvent; +import org.apache.ignite.events.CacheQueryExecutedEvent; +import org.apache.ignite.events.CacheQueryReadEvent; +import org.apache.ignite.events.CacheRebalancingEvent; +import org.apache.ignite.events.CheckpointEvent; +import org.apache.ignite.events.DiscoveryEvent; +import org.apache.ignite.events.JobEvent; +import org.apache.ignite.events.SwapSpaceEvent; +import org.apache.ignite.events.TaskEvent; +import org.apache.ignite.internal.portable.PortableRawWriterEx; +import org.apache.ignite.internal.processors.platform.PlatformContext; +import org.apache.ignite.internal.processors.platform.memory.PlatformMemory; +import org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream; +import org.apache.ignite.internal.processors.platform.utils.PlatformUtils; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.lang.IgniteUuid; +import org.apache.ignite.events.*; + +import org.apache.ignite.plugin.security.SecurityPermission; +import org.apache.ignite.plugin.security.SecuritySubjectType; +import org.apache.ignite.resources.IgniteInstanceResource; +import org.jetbrains.annotations.Nullable; + +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +/** + * Test task writing all events to a stream. + */ +@SuppressWarnings("UnusedDeclaration") +public class PlatformEventsWriteEventTask extends ComputeTaskAdapter { + /** {@inheritDoc} */ + @Nullable @Override public Map map(List subgrid, + Long ptr) { + return Collections.singletonMap(new Job(ptr, F.first(subgrid)), F.first(subgrid)); + } + + /** {@inheritDoc} */ + @Nullable @Override public Object reduce(List results) { + return results.get(0).getData(); + } + + /** + * Job. + */ + @SuppressWarnings("deprecation") + private static class Job extends ComputeJobAdapter { + /** Grid. */ + @IgniteInstanceResource + protected transient Ignite ignite; + + /** Stream ptr. */ + private final long ptr; + + private final ClusterNode node; + + /** + * Constructor. + * + * @param ptr Stream ptr. + */ + public Job(long ptr, ClusterNode node) { + this.ptr = ptr; + this.node = node; + } + + /** {@inheritDoc} */ + @Nullable @Override public Object execute() { + PlatformContext ctx = PlatformUtils.platformContext(ignite); + + try (PlatformMemory mem = ctx.memory().get(ptr)) { + PlatformOutputStream out = mem.output(); + PortableRawWriterEx writer = ctx.writer(out); + + int evtType = EventType.EVT_SWAP_SPACE_CLEARED; + String msg = "msg"; + UUID uuid = new UUID(1, 2); + IgniteUuid igniteUuid = new IgniteUuid(uuid, 3); + + ctx.writeEvent(writer, new CacheEvent("cacheName", node, node, "msg", evtType, 1, true, 2, + igniteUuid, 3, 4, true, 5, true, uuid, "cloClsName", "taskName")); + + //noinspection unchecked + ctx.writeEvent(writer, new CacheQueryExecutedEvent(node, msg, evtType, "qryType", "cacheName", + "clsName", "clause", null, null, null, uuid, "taskName")); + + //noinspection unchecked + ctx.writeEvent(writer, new CacheQueryReadEvent(node, msg, evtType, "qryType", "cacheName", + "clsName", "clause", null, null, null, uuid, "taskName", 1, 2, 3, 4)); + + ctx.writeEvent(writer, new CacheRebalancingEvent("cacheName", node, msg, evtType, 1, node, 2, 3)); + + ctx.writeEvent(writer, new CheckpointEvent(node, msg, evtType, "cpKey")); + + DiscoveryEvent discoveryEvent = new DiscoveryEvent(node, msg, evtType, node); + discoveryEvent.topologySnapshot(ignite.cluster().topologyVersion(), ignite.cluster().nodes()); + ctx.writeEvent(writer, discoveryEvent); + + JobEvent jobEvent = new JobEvent(node, msg, evtType); + jobEvent.jobId(igniteUuid); + jobEvent.taskClassName("taskClsName"); + jobEvent.taskName("taskName"); + jobEvent.taskNode(node); + jobEvent.taskSessionId(igniteUuid); + jobEvent.taskSubjectId(uuid); + ctx.writeEvent(writer, jobEvent); + + ctx.writeEvent(writer, new SwapSpaceEvent(node, msg, evtType, "space")); + + ctx.writeEvent(writer, new TaskEvent(node, msg, evtType, igniteUuid, "taskName", "taskClsName", + true, uuid)); + + out.synchronize(); + } + + return true; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/5cec202c/modules/platform/src/test/java/org/apache/ignite/platform/PlatformMaxMemoryTask.java ---------------------------------------------------------------------- diff --git a/modules/platform/src/test/java/org/apache/ignite/platform/PlatformMaxMemoryTask.java b/modules/platform/src/test/java/org/apache/ignite/platform/PlatformMaxMemoryTask.java new file mode 100644 index 0000000..6effb0f --- /dev/null +++ b/modules/platform/src/test/java/org/apache/ignite/platform/PlatformMaxMemoryTask.java @@ -0,0 +1,57 @@ +/* + * 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.platform; + +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.compute.ComputeJob; +import org.apache.ignite.compute.ComputeJobAdapter; +import org.apache.ignite.compute.ComputeJobResult; +import org.apache.ignite.compute.ComputeTaskAdapter; +import org.apache.ignite.internal.util.typedef.F; +import org.jetbrains.annotations.Nullable; + +import java.lang.management.ManagementFactory; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + * Task to get max Java heap memory for node. + */ +public class PlatformMaxMemoryTask extends ComputeTaskAdapter { + /** {@inheritDoc} */ + @Nullable @Override public Map map(List subgrid, + @Nullable Object arg) { + return Collections.singletonMap(new MaxMemoryJob(), F.first(subgrid)); + } + + /** {@inheritDoc} */ + @Nullable @Override public Long reduce(List results) { + return results.get(0).getData(); + } + + /** + * Job. + */ + private static class MaxMemoryJob extends ComputeJobAdapter { + /** {@inheritDoc} */ + @Nullable @Override public Object execute() { + return ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getMax(); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/5cec202c/modules/platform/src/test/java/org/apache/ignite/platform/PlatformMinMemoryTask.java ---------------------------------------------------------------------- diff --git a/modules/platform/src/test/java/org/apache/ignite/platform/PlatformMinMemoryTask.java b/modules/platform/src/test/java/org/apache/ignite/platform/PlatformMinMemoryTask.java new file mode 100644 index 0000000..23292f7 --- /dev/null +++ b/modules/platform/src/test/java/org/apache/ignite/platform/PlatformMinMemoryTask.java @@ -0,0 +1,57 @@ +/* + * 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.platform; + +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.compute.ComputeJob; +import org.apache.ignite.compute.ComputeJobAdapter; +import org.apache.ignite.compute.ComputeJobResult; +import org.apache.ignite.compute.ComputeTaskAdapter; +import org.apache.ignite.internal.util.typedef.F; +import org.jetbrains.annotations.Nullable; + +import java.lang.management.ManagementFactory; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + * Task to get min Java heap memory for node. + */ +public class PlatformMinMemoryTask extends ComputeTaskAdapter { + /** {@inheritDoc} */ + @Nullable @Override public Map map(List subgrid, + @Nullable Object arg) { + return Collections.singletonMap(new MinMemoryJob(), F.first(subgrid)); + } + + /** {@inheritDoc} */ + @Nullable @Override public Long reduce(List results) { + return results.get(0).getData(); + } + + /** + * Job. + */ + private static class MinMemoryJob extends ComputeJobAdapter { + /** {@inheritDoc} */ + @Nullable @Override public Object execute() { + return ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getInit(); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/5cec202c/modules/platform/src/test/java/org/apache/ignite/platform/lifecycle/PlatformJavaLifecycleBean.java ---------------------------------------------------------------------- diff --git a/modules/platform/src/test/java/org/apache/ignite/platform/lifecycle/PlatformJavaLifecycleBean.java b/modules/platform/src/test/java/org/apache/ignite/platform/lifecycle/PlatformJavaLifecycleBean.java new file mode 100644 index 0000000..d60912b --- /dev/null +++ b/modules/platform/src/test/java/org/apache/ignite/platform/lifecycle/PlatformJavaLifecycleBean.java @@ -0,0 +1,47 @@ +/* + * 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.platform.lifecycle; + +import org.apache.ignite.lifecycle.LifecycleBean; +import org.apache.ignite.lifecycle.LifecycleEventType; + +/** + * Java lifecycle bean. + */ +public class PlatformJavaLifecycleBean implements LifecycleBean { + /** Count of "beforeStart" invocations. */ + public static volatile int beforeStartCnt; + + /** Count of "afterStart" invocations. */ + public static volatile int afterStartCnt; + + /** {@inheritDoc} */ + @Override public void onLifecycleEvent(LifecycleEventType evt) { + switch (evt) { + case BEFORE_NODE_START: + beforeStartCnt++; + + break; + + case AFTER_NODE_START: + afterStartCnt++; + + break; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/5cec202c/modules/platform/src/test/java/org/apache/ignite/platform/lifecycle/PlatformJavaLifecycleTask.java ---------------------------------------------------------------------- diff --git a/modules/platform/src/test/java/org/apache/ignite/platform/lifecycle/PlatformJavaLifecycleTask.java b/modules/platform/src/test/java/org/apache/ignite/platform/lifecycle/PlatformJavaLifecycleTask.java new file mode 100644 index 0000000..ec01da1 --- /dev/null +++ b/modules/platform/src/test/java/org/apache/ignite/platform/lifecycle/PlatformJavaLifecycleTask.java @@ -0,0 +1,65 @@ +/* + * 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.platform.lifecycle; + +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.compute.ComputeJob; +import org.apache.ignite.compute.ComputeJobAdapter; +import org.apache.ignite.compute.ComputeJobResult; +import org.apache.ignite.compute.ComputeTaskAdapter; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Lifecycle task. + */ +public class PlatformJavaLifecycleTask extends ComputeTaskAdapter> { + /** {@inheritDoc} */ + @Nullable @Override public Map map(List subgrid, + @Nullable Object arg) { + Map jobs = new HashMap<>(); + + jobs.put(new LifecycleJob(), subgrid.get(0)); + + return jobs; + } + + /** {@inheritDoc} */ + @Nullable @Override public List reduce(List results) { + return results.get(0).getData(); + } + + /** + * Job. + */ + private static class LifecycleJob extends ComputeJobAdapter { + /** {@inheritDoc} */ + @Nullable @Override public Object execute() { + List res = new ArrayList(); + + res.add(PlatformJavaLifecycleBean.beforeStartCnt); + res.add(PlatformJavaLifecycleBean.afterStartCnt); + + return res; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/5cec202c/parent/pom.xml ---------------------------------------------------------------------- diff --git a/parent/pom.xml b/parent/pom.xml index 69b0cd0..846211b 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -757,6 +757,12 @@ **/*.slnrel **/*.opensdf **/module.def + **/ignite-common.pc.in + **/*.csproj + **/*.fxcop + **/*.metaproj + **/*.metaproj.tmp + **/x64/Debug/** **/teamcity_boost.cpp **/teamcity_messages.h **/teamcity_messages.cpp