You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/09/22 09:19:03 UTC
[01/37] ignite git commit: IGNITE-1513: WIP on .Net.
Repository: ignite
Updated Branches:
refs/heads/ignite-1513-final 524f5653e -> 65bb69da2
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs
new file mode 100644
index 0000000..2267154
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+
+using System;
+
+namespace Apache.Ignite.ExamplesDll.Portable
+{
+ /// <summary>
+ /// Employee key. Used in query example to co-locate employees with their organizations.
+ /// </summary>
+ [Serializable]
+ public class EmployeeKey
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="id">ID.</param>
+ /// <param name="orgId">Organization ID.</param>
+ public EmployeeKey(int id, int orgId)
+ {
+ Id = id;
+ OrganizationId = orgId;
+ }
+
+ /// <summary>
+ /// ID.
+ /// </summary>
+ public int Id { get; private set; }
+
+ /// <summary>
+ /// Organization ID.
+ /// </summary>
+ public int OrganizationId { get; private set; }
+
+ /// <summary>
+ /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
+ /// </summary>
+ /// <returns>
+ /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
+ /// </returns>
+ /// <param name="obj">The object to compare with the current object. </param><filterpriority>2</filterpriority>
+ public override bool Equals(object obj)
+ {
+ EmployeeKey other = obj as EmployeeKey;
+
+ return other != null && Id == other.Id && OrganizationId == other.OrganizationId;
+ }
+
+ /// <summary>
+ /// Serves as a hash function for a particular type.
+ /// </summary>
+ /// <returns>
+ /// A hash code for the current <see cref="T:System.Object"/>.
+ /// </returns>
+ /// <filterpriority>2</filterpriority>
+ public override int GetHashCode()
+ {
+ return 31 * Id + OrganizationId;
+ }
+
+ /// <summary>
+ /// Returns a string that represents the current object.
+ /// </summary>
+ /// <returns>
+ /// A string that represents the current object.
+ /// </returns>
+ public override string ToString()
+ {
+ return string.Format("{0} [id={1}, organizationId={2}]", typeof (EmployeeKey).Name, Id, OrganizationId);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Organization.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Organization.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Organization.cs
new file mode 100644
index 0000000..e23c3c1
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Organization.cs
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+
+using System;
+
+namespace Apache.Ignite.ExamplesDll.Portable
+{
+ /// <summary>
+ /// Organization.
+ /// </summary>
+ [Serializable]
+ public class Organization
+ {
+ /// <summary>
+ /// Default constructor.
+ /// </summary>
+ public Organization()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="name">Name.</param>
+ /// <param name="address">Address.</param>
+ /// <param name="type">Type.</param>
+ /// <param name="lastUpdated">Last update time.</param>
+ public Organization(string name, Address address, OrganizationType type, DateTime lastUpdated)
+ {
+ Name = name;
+ Address = address;
+ Type = type;
+ LastUpdated = lastUpdated;
+ }
+
+ /// <summary>
+ /// Name.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Address.
+ /// </summary>
+ public Address Address { get; set; }
+
+ /// <summary>
+ /// Type.
+ /// </summary>
+ public OrganizationType Type { get; set; }
+
+ /// <summary>
+ /// Last update time.
+ /// </summary>
+ public DateTime LastUpdated { get; set; }
+
+ /// <summary>
+ /// Returns a string that represents the current object.
+ /// </summary>
+ /// <returns>
+ /// A string that represents the current object.
+ /// </returns>
+ /// <filterpriority>2</filterpriority>
+ public override string ToString()
+ {
+ return string.Format("{0} [name={1}, address={2}, type={3}, lastUpdated={4}]", typeof (Organization).Name,
+ Name, Address, Type, LastUpdated);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs
new file mode 100644
index 0000000..198edb1
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+
+using System;
+
+namespace Apache.Ignite.ExamplesDll.Portable
+{
+ /// <summary>
+ /// Organization type.
+ /// </summary>
+ [Serializable]
+ public enum OrganizationType
+ {
+ /// <summary>
+ /// Non-profit organization.
+ /// </summary>
+ NonProfit,
+
+ /// <summary>
+ /// Private organization.
+ /// </summary>
+ Private,
+
+ /// <summary>
+ /// Government organization.
+ /// </summary>
+ Government
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..f149d64
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("Apache Ignite Examples Dll")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("Apache Ignite")]
+[assembly: AssemblyCopyright("Copyright © 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+[assembly: ComVisible(false)]
+
+[assembly: Guid("ce65ec7c-d3cf-41ad-8f45-f90d5af68d77")]
+
+[assembly: AssemblyVersion("1.5.0")]
+[assembly: AssemblyFileVersion("1.5.0")]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Services/MapService.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Services/MapService.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Services/MapService.cs
new file mode 100644
index 0000000..d577ff7
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Services/MapService.cs
@@ -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.
+ */
+
+using System;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Cache;
+using Apache.Ignite.Core.Resource;
+using Apache.Ignite.Core.Services;
+
+namespace Apache.Ignite.ExamplesDll.Services
+{
+ /// <summary>
+ /// Service implementation.
+ /// </summary>
+ [Serializable]
+ public class MapService<TK, TV> : IService
+ {
+ /** Injected Ignite instance. */
+#pragma warning disable 649
+ [InstanceResource] private readonly IIgnite _ignite;
+#pragma warning restore 649
+
+ /** Cache. */
+ private ICache<TK, TV> _cache;
+
+ /// <summary>
+ /// Initializes this instance before execution.
+ /// </summary>
+ /// <param name="context">Service execution context.</param>
+ public void Init(IServiceContext context)
+ {
+ // Create a new cache for every service deployment.
+ // Note that we use service name as cache name, which allows
+ // for each service deployment to use its own isolated cache.
+ _cache = _ignite.GetOrCreateCache<TK, TV>("MapService_" + context.Name);
+
+ Console.WriteLine("Service initialized: " + context.Name);
+ }
+
+ /// <summary>
+ /// Starts execution of this service. This method is automatically invoked whenever an instance of the service
+ /// is deployed on an Ignite node. Note that service is considered deployed even after it exits the Execute
+ /// method and can be cancelled (or undeployed) only by calling any of the Cancel methods on
+ /// <see cref="IServices"/> API. Also note that service is not required to exit from Execute method until
+ /// Cancel method was called.
+ /// </summary>
+ /// <param name="context">Service execution context.</param>
+ public void Execute(IServiceContext context)
+ {
+ Console.WriteLine("Service started: " + context.Name);
+ }
+
+ /// <summary>
+ /// Cancels this instance.
+ /// <para/>
+ /// Note that Ignite cannot guarantee that the service exits from <see cref="IService.Execute"/>
+ /// method whenever <see cref="IService.Cancel"/> is called. It is up to the user to
+ /// make sure that the service code properly reacts to cancellations.
+ /// </summary>
+ /// <param name="context">Service execution context.</param>
+ public void Cancel(IServiceContext context)
+ {
+ Console.WriteLine("Service cancelled: " + context.Name);
+ }
+
+ /// <summary>
+ /// Puts an entry to the map.
+ /// </summary>
+ /// <param name="key">The key.</param>
+ /// <param name="value">The value.</param>
+ public void Put(TK key, TV value)
+ {
+ _cache.Put(key, value);
+ }
+
+ /// <summary>
+ /// Gets an entry from the map.
+ /// </summary>
+ /// <param name="key">The key.</param>
+ /// <returns>Entry value.</returns>
+ public TV Get(TK key)
+ {
+ return _cache.Get(key);
+ }
+
+ /// <summary>
+ /// Clears the map.
+ /// </summary>
+ public void Clear()
+ {
+ _cache.Clear();
+ }
+
+ /// <summary>
+ /// Gets the size of the map.
+ /// </summary>
+ /// <value>
+ /// The size.
+ /// </value>
+ public int Size
+ {
+ get { return _cache.GetSize(); }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Config/example-cache-query.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Config/example-cache-query.xml b/modules/platform/dotnet/Examples2/Config/example-cache-query.xml
new file mode 100644
index 0000000..c9ea7e1
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Config/example-cache-query.xml
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+
+ <property name="platformConfiguration">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
+ <property name="portableConfiguration">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
+ <property name="types">
+ <list>
+ <value>Apache.Ignite.Examples.Dll.Portable.Account</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.Address</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.Employee</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.EmployeeKey</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.Organization</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.OrganizationType</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+
+ <!-- Cache configurations (all properties are optional). -->
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="atomicityMode" value="ATOMIC"/>
+ <property name="backups" value="1"/>
+
+ <!-- Configure type metadata to enable queries. -->
+ <property name="typeMetadata">
+ <list>
+ <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+ <property name="keyType" value="java.lang.Integer"/>
+ <property name="valueType" value="Organization"/>
+ <property name="ascendingFields">
+ <map>
+ <entry key="name" value="java.lang.String"/>
+ </map>
+ </property>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+ <property name="keyType" value="EmployeeKey"/>
+ <property name="valueType" value="Employee"/>
+ <property name="ascendingFields">
+ <map>
+ <entry key="organizationId" value="java.lang.Integer"/>
+ <entry key="address.zip" value="java.lang.Integer"/>
+ </map>
+ </property>
+ <property name="queryFields">
+ <map>
+ <entry key="name" value="java.lang.String"/>
+ <entry key="salary" value="java.lang.Long"/>
+ </map>
+ </property>
+ <property name="textFields">
+ <list>
+ <value>address.street</value>
+ </list>
+ </property>
+ </bean>
+ </list>
+ </property>
+ </bean>
+ </list>
+ </property>
+
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47501</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Config/example-cache-store.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Config/example-cache-store.xml b/modules/platform/dotnet/Examples2/Config/example-cache-store.xml
new file mode 100644
index 0000000..adc5f45
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Config/example-cache-store.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="writeThrough" value="true"/>
+ <property name="readThrough" value="true"/>
+ <property name="cacheStoreFactory">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
+ <property name="assemblyName" value="Apache.Ignite.ExamplesDll"/>
+ <property name="className" value="Apache.Ignite.ExamplesDll.Datagrid.EmployeeStore"/>
+ </bean>
+ </property>
+ </bean>
+ </list>
+ </property>
+
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47501</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Config/example-cache.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Config/example-cache.xml b/modules/platform/dotnet/Examples2/Config/example-cache.xml
new file mode 100644
index 0000000..a262ce1
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Config/example-cache.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <!-- Set to true to enable distributed class loading for examples, default is false. -->
+ <property name="peerClassLoadingEnabled" value="true"/>
+
+ <property name="platformConfiguration">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
+ <property name="portableConfiguration">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
+ <property name="types">
+ <list>
+ <value>Apache.Ignite.Examples.Dll.Portable.Account</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.Address</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.Employee</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.EmployeeKey</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.Organization</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.OrganizationType</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="cache*"/>
+ <property name="atomicityMode" value="ATOMIC"/>
+ <property name="backups" value="1"/>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="tx"/>
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="backups" value="1"/>
+ </bean>
+ </list>
+ </property>
+
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47501</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Config/example-compute.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Config/example-compute.xml b/modules/platform/dotnet/Examples2/Config/example-compute.xml
new file mode 100644
index 0000000..bbc6550
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Config/example-compute.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47501</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+
+ <!-- Enable task execution events for examples. -->
+ <property name="includeEventTypes">
+ <list>
+ <!-- Task execution events -->
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED"/>
+
+ <!-- Job execution events -->
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_MAPPED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_RESULTED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_FAILED_OVER"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_STARTED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_FINISHED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_TIMEDOUT"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_REJECTED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_FAILED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_QUEUED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_CANCELLED"/>
+ </list>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/README.txt
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/README.txt b/modules/platform/dotnet/Examples2/README.txt
new file mode 100644
index 0000000..c49dc5a
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/README.txt
@@ -0,0 +1,14 @@
+Apache Ignite .Net Examples
+==================================
+
+Common requirements
+----------------------------------
+ * Apache Ignite .Net library must be built using instructions from %IGNITE_HOME%\platforms\dotnet\README.txt.
+
+
+Running examples
+----------------------------------
+
+ * Open Visual Studio solution %IGNITE_HOME%\platforms\dotnet\examples\Apache.Ignite.Examples.sln
+ * Build Apache.Ignite.ExamplesDll project.
+ * Set desired example as startup object in Apache.Ignite.Examples project and run it.
\ No newline at end of file
[27/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
new file mode 100644
index 0000000..b9a9936
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
@@ -0,0 +1,1787 @@
+/*
+ * 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.
+ */
+
+// ReSharper disable UnassignedField.Global
+// ReSharper disable CollectionNeverUpdated.Global
+namespace Apache.Ignite.Core.Tests.Portable
+{
+ using System;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+ using Apache.Ignite.Core.Impl;
+ using Apache.Ignite.Core.Impl.Portable;
+ using Apache.Ignite.Core.Portable;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Portable builder self test.
+ /// </summary>
+ public class PortableApiSelfTest
+ {
+ /** Undefined type: Empty. */
+ private const string TypeEmpty = "EmptyUndefined";
+
+ /** Grid. */
+ private Ignite _grid;
+
+ /** Marshaller. */
+ private PortableMarshaller _marsh;
+
+ /// <summary>
+ /// Set up routine.
+ /// </summary>
+ [TestFixtureSetUp]
+ public void SetUp()
+ {
+ TestUtils.KillProcesses();
+
+ var cfg = new IgniteConfiguration
+ {
+ PortableConfiguration = new PortableConfiguration
+ {
+ TypeConfigurations = new List<PortableTypeConfiguration>
+ {
+ new PortableTypeConfiguration(typeof (Empty)),
+ new PortableTypeConfiguration(typeof (Primitives)),
+ new PortableTypeConfiguration(typeof (PrimitiveArrays)),
+ new PortableTypeConfiguration(typeof (StringDateGuidEnum)),
+ new PortableTypeConfiguration(typeof (WithRaw)),
+ new PortableTypeConfiguration(typeof (MetaOverwrite)),
+ new PortableTypeConfiguration(typeof (NestedOuter)),
+ new PortableTypeConfiguration(typeof (NestedInner)),
+ new PortableTypeConfiguration(typeof (MigrationOuter)),
+ new PortableTypeConfiguration(typeof (MigrationInner)),
+ new PortableTypeConfiguration(typeof (InversionOuter)),
+ new PortableTypeConfiguration(typeof (InversionInner)),
+ new PortableTypeConfiguration(typeof (CompositeOuter)),
+ new PortableTypeConfiguration(typeof (CompositeInner)),
+ new PortableTypeConfiguration(typeof (CompositeArray)),
+ new PortableTypeConfiguration(typeof (CompositeContainer)),
+ new PortableTypeConfiguration(typeof (ToPortable)),
+ new PortableTypeConfiguration(typeof (Remove)),
+ new PortableTypeConfiguration(typeof (RemoveInner)),
+ new PortableTypeConfiguration(typeof (BuilderInBuilderOuter)),
+ new PortableTypeConfiguration(typeof (BuilderInBuilderInner)),
+ new PortableTypeConfiguration(typeof (BuilderCollection)),
+ new PortableTypeConfiguration(typeof (BuilderCollectionItem)),
+ new PortableTypeConfiguration(typeof (DecimalHolder)),
+ new PortableTypeConfiguration(TypeEmpty),
+ TypeConfigurationNoMeta(typeof (EmptyNoMeta)),
+ TypeConfigurationNoMeta(typeof (ToPortableNoMeta))
+ },
+ DefaultIdMapper = new IdMapper()
+ },
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = new List<string>
+ {
+ "-ea",
+ "-Xcheck:jni",
+ "-Xms4g",
+ "-Xmx4g",
+ "-DIGNITE_QUIET=false",
+ "-Xnoagent",
+ "-Djava.compiler=NONE",
+ "-Xdebug",
+ "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005",
+ "-XX:+HeapDumpOnOutOfMemoryError"
+ },
+ SpringConfigUrl = "config\\portable.xml"
+ };
+
+ _grid = (Ignite) Ignition.Start(cfg);
+
+ _marsh = _grid.Marshaller;
+ }
+
+ /// <summary>
+ /// Tear down routine.
+ /// </summary>
+ [TestFixtureTearDown]
+ public virtual void TearDown()
+ {
+ if (_grid != null)
+ Ignition.Stop(_grid.Name, true);
+
+ _grid = null;
+ }
+
+ /// <summary>
+ /// Ensure that portable engine is able to work with type names, which are not configured.
+ /// </summary>
+ [Test]
+ public void TestNonConfigured()
+ {
+ string typeName1 = "Type1";
+ string typeName2 = "Type2";
+ string field1 = "field1";
+ string field2 = "field2";
+
+ // 1. Ensure that builder works fine.
+ IPortableObject portObj1 = _grid.GetPortables().GetBuilder(typeName1).SetField(field1, 1).Build();
+
+ Assert.AreEqual(typeName1, portObj1.GetMetadata().TypeName);
+ Assert.AreEqual(1, portObj1.GetMetadata().Fields.Count);
+ Assert.AreEqual(field1, portObj1.GetMetadata().Fields.First());
+ Assert.AreEqual(PortableTypeNames.TypeNameInt, portObj1.GetMetadata().GetFieldTypeName(field1));
+
+ Assert.AreEqual(1, portObj1.GetField<int>(field1));
+
+ // 2. Ensure that object can be unmarshalled without deserialization.
+ byte[] data = ((PortableUserObject) portObj1).Data;
+
+ portObj1 = _grid.Marshaller.Unmarshal<IPortableObject>(data, PortableMode.ForcePortable);
+
+ Assert.AreEqual(typeName1, portObj1.GetMetadata().TypeName);
+ Assert.AreEqual(1, portObj1.GetMetadata().Fields.Count);
+ Assert.AreEqual(field1, portObj1.GetMetadata().Fields.First());
+ Assert.AreEqual(PortableTypeNames.TypeNameInt, portObj1.GetMetadata().GetFieldTypeName(field1));
+
+ Assert.AreEqual(1, portObj1.GetField<int>(field1));
+
+ // 3. Ensure that we can nest one anonymous object inside another
+ IPortableObject portObj2 =
+ _grid.GetPortables().GetBuilder(typeName2).SetField(field2, portObj1).Build();
+
+ Assert.AreEqual(typeName2, portObj2.GetMetadata().TypeName);
+ Assert.AreEqual(1, portObj2.GetMetadata().Fields.Count);
+ Assert.AreEqual(field2, portObj2.GetMetadata().Fields.First());
+ Assert.AreEqual(PortableTypeNames.TypeNameObject, portObj2.GetMetadata().GetFieldTypeName(field2));
+
+ portObj1 = portObj2.GetField<IPortableObject>(field2);
+
+ Assert.AreEqual(typeName1, portObj1.GetMetadata().TypeName);
+ Assert.AreEqual(1, portObj1.GetMetadata().Fields.Count);
+ Assert.AreEqual(field1, portObj1.GetMetadata().Fields.First());
+ Assert.AreEqual(PortableTypeNames.TypeNameInt, portObj1.GetMetadata().GetFieldTypeName(field1));
+
+ Assert.AreEqual(1, portObj1.GetField<int>(field1));
+
+ // 4. Ensure that we can unmarshal object with other nested object.
+ data = ((PortableUserObject) portObj2).Data;
+
+ portObj2 = _grid.Marshaller.Unmarshal<IPortableObject>(data, PortableMode.ForcePortable);
+
+ Assert.AreEqual(typeName2, portObj2.GetMetadata().TypeName);
+ Assert.AreEqual(1, portObj2.GetMetadata().Fields.Count);
+ Assert.AreEqual(field2, portObj2.GetMetadata().Fields.First());
+ Assert.AreEqual(PortableTypeNames.TypeNameObject, portObj2.GetMetadata().GetFieldTypeName(field2));
+
+ portObj1 = portObj2.GetField<IPortableObject>(field2);
+
+ Assert.AreEqual(typeName1, portObj1.GetMetadata().TypeName);
+ Assert.AreEqual(1, portObj1.GetMetadata().Fields.Count);
+ Assert.AreEqual(field1, portObj1.GetMetadata().Fields.First());
+ Assert.AreEqual(PortableTypeNames.TypeNameInt, portObj1.GetMetadata().GetFieldTypeName(field1));
+
+ Assert.AreEqual(1, portObj1.GetField<int>(field1));
+ }
+
+ /// <summary>
+ /// Test "ToPortable()" method.
+ /// </summary>
+ [Test]
+ public void TestToPortable()
+ {
+ DateTime date = DateTime.Now.ToUniversalTime();
+ Guid guid = Guid.NewGuid();
+
+ IPortables api = _grid.GetPortables();
+
+ // 1. Primitives.
+ Assert.AreEqual(1, api.ToPortable<byte>((byte)1));
+ Assert.AreEqual(1, api.ToPortable<short>((short)1));
+ Assert.AreEqual(1, api.ToPortable<int>(1));
+ Assert.AreEqual(1, api.ToPortable<long>((long)1));
+
+ Assert.AreEqual((float)1, api.ToPortable<float>((float)1));
+ Assert.AreEqual((double)1, api.ToPortable<double>((double)1));
+
+ Assert.AreEqual(true, api.ToPortable<bool>(true));
+ Assert.AreEqual('a', api.ToPortable<char>('a'));
+
+ // 2. Special types.
+ Assert.AreEqual("a", api.ToPortable<string>("a"));
+ Assert.AreEqual(date, api.ToPortable<DateTime>(date));
+ Assert.AreEqual(guid, api.ToPortable<Guid>(guid));
+ Assert.AreEqual(TestEnum.One, api.ToPortable<TestEnum>(TestEnum.One));
+
+ // 3. Arrays.
+ Assert.AreEqual(new byte[] { 1 }, api.ToPortable<byte[]>(new byte[] { 1 }));
+ Assert.AreEqual(new short[] { 1 }, api.ToPortable<short[]>(new short[] { 1 }));
+ Assert.AreEqual(new[] { 1 }, api.ToPortable<int[]>(new[] { 1 }));
+ Assert.AreEqual(new long[] { 1 }, api.ToPortable<long[]>(new long[] { 1 }));
+
+ Assert.AreEqual(new float[] { 1 }, api.ToPortable<float[]>(new float[] { 1 }));
+ Assert.AreEqual(new double[] { 1 }, api.ToPortable<double[]>(new double[] { 1 }));
+
+ Assert.AreEqual(new[] { true }, api.ToPortable<bool[]>(new[] { true }));
+ Assert.AreEqual(new[] { 'a' }, api.ToPortable<char[]>(new[] { 'a' }));
+
+ Assert.AreEqual(new[] { "a" }, api.ToPortable<string[]>(new[] { "a" }));
+ Assert.AreEqual(new[] { date }, api.ToPortable<DateTime[]>(new[] { date }));
+ Assert.AreEqual(new[] { guid }, api.ToPortable<Guid[]>(new[] { guid }));
+ Assert.AreEqual(new[] { TestEnum.One }, api.ToPortable<TestEnum[]>(new[] { TestEnum.One }));
+
+ // 4. Objects.
+ IPortableObject portObj = api.ToPortable<IPortableObject>(new ToPortable(1));
+
+ Assert.AreEqual(typeof(ToPortable).Name, portObj.GetMetadata().TypeName);
+ Assert.AreEqual(1, portObj.GetMetadata().Fields.Count);
+ Assert.AreEqual("Val", portObj.GetMetadata().Fields.First());
+ Assert.AreEqual(PortableTypeNames.TypeNameInt, portObj.GetMetadata().GetFieldTypeName("Val"));
+
+ Assert.AreEqual(1, portObj.GetField<int>("val"));
+ Assert.AreEqual(1, portObj.Deserialize<ToPortable>().Val);
+
+ portObj = api.ToPortable<IPortableObject>(new ToPortableNoMeta(1));
+
+ Assert.AreEqual(0, portObj.GetMetadata().Fields.Count);
+
+ Assert.AreEqual(1, portObj.GetField<int>("Val"));
+ Assert.AreEqual(1, portObj.Deserialize<ToPortableNoMeta>().Val);
+
+ // 5. Object array.
+ IPortableObject[] portObjArr = api.ToPortable<IPortableObject[]>(new[] { new ToPortable(1) });
+
+ Assert.AreEqual(1, portObjArr.Length);
+ Assert.AreEqual(1, portObjArr[0].GetField<int>("Val"));
+ Assert.AreEqual(1, portObjArr[0].Deserialize<ToPortable>().Val);
+ }
+
+ /// <summary>
+ /// Test builder field remove logic.
+ /// </summary>
+ [Test]
+ public void TestRemove()
+ {
+ // Create empty object.
+ IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(Remove)).Build();
+
+ Assert.IsNull(portObj.GetField<object>("val"));
+ Assert.IsNull(portObj.Deserialize<Remove>().Val);
+
+ IPortableMetadata meta = portObj.GetMetadata();
+
+ Assert.AreEqual(typeof(Remove).Name, meta.TypeName);
+ Assert.AreEqual(0, meta.Fields.Count);
+
+ // Populate it with field.
+ IPortableBuilder builder = _grid.GetPortables().GetBuilder(portObj);
+
+ Assert.IsNull(builder.GetField<object>("val"));
+
+ object val = 1;
+
+ builder.SetField("val", val);
+
+ Assert.AreEqual(val, builder.GetField<object>("val"));
+
+ portObj = builder.Build();
+
+ Assert.AreEqual(val, portObj.GetField<object>("val"));
+ Assert.AreEqual(val, portObj.Deserialize<Remove>().Val);
+
+ meta = portObj.GetMetadata();
+
+ Assert.AreEqual(typeof(Remove).Name, meta.TypeName);
+ Assert.AreEqual(1, meta.Fields.Count);
+ Assert.AreEqual("val", meta.Fields.First());
+ Assert.AreEqual(PortableTypeNames.TypeNameObject, meta.GetFieldTypeName("val"));
+
+ // Perform field remove.
+ builder = _grid.GetPortables().GetBuilder(portObj);
+
+ Assert.AreEqual(val, builder.GetField<object>("val"));
+
+ builder.RemoveField("val");
+ Assert.IsNull(builder.GetField<object>("val"));
+
+ builder.SetField("val", val);
+ Assert.AreEqual(val, builder.GetField<object>("val"));
+
+ builder.RemoveField("val");
+ Assert.IsNull(builder.GetField<object>("val"));
+
+ portObj = builder.Build();
+
+ Assert.IsNull(portObj.GetField<object>("val"));
+ Assert.IsNull(portObj.Deserialize<Remove>().Val);
+
+ // Test correct removal of field being referenced by handle somewhere else.
+ RemoveInner inner = new RemoveInner(2);
+
+ portObj = _grid.GetPortables().GetBuilder(typeof(Remove))
+ .SetField("val", inner)
+ .SetField("val2", inner)
+ .Build();
+
+ portObj = _grid.GetPortables().GetBuilder(portObj).RemoveField("val").Build();
+
+ Remove obj = portObj.Deserialize<Remove>();
+
+ Assert.IsNull(obj.Val);
+ Assert.AreEqual(2, obj.Val2.Val);
+ }
+
+ /// <summary>
+ /// Test builder-in-builder scenario.
+ /// </summary>
+ [Test]
+ public void TestBuilderInBuilder()
+ {
+ // Test different builders assembly.
+ IPortableBuilder builderOuter = _grid.GetPortables().GetBuilder(typeof(BuilderInBuilderOuter));
+ IPortableBuilder builderInner = _grid.GetPortables().GetBuilder(typeof(BuilderInBuilderInner));
+
+ builderOuter.SetField<object>("inner", builderInner);
+ builderInner.SetField<object>("outer", builderOuter);
+
+ IPortableObject outerPortObj = builderOuter.Build();
+
+ IPortableMetadata meta = outerPortObj.GetMetadata();
+
+ Assert.AreEqual(typeof(BuilderInBuilderOuter).Name, meta.TypeName);
+ Assert.AreEqual(1, meta.Fields.Count);
+ Assert.AreEqual("inner", meta.Fields.First());
+ Assert.AreEqual(PortableTypeNames.TypeNameObject, meta.GetFieldTypeName("inner"));
+
+ IPortableObject innerPortObj = outerPortObj.GetField<IPortableObject>("inner");
+
+ meta = innerPortObj.GetMetadata();
+
+ Assert.AreEqual(typeof(BuilderInBuilderInner).Name, meta.TypeName);
+ Assert.AreEqual(1, meta.Fields.Count);
+ Assert.AreEqual("outer", meta.Fields.First());
+ Assert.AreEqual(PortableTypeNames.TypeNameObject, meta.GetFieldTypeName("outer"));
+
+ BuilderInBuilderOuter outer = outerPortObj.Deserialize<BuilderInBuilderOuter>();
+
+ Assert.AreSame(outer, outer.Inner.Outer);
+
+ // Test same builders assembly.
+ innerPortObj = _grid.GetPortables().GetBuilder(typeof(BuilderInBuilderInner)).Build();
+
+ outerPortObj = _grid.GetPortables().GetBuilder(typeof(BuilderInBuilderOuter))
+ .SetField("inner", innerPortObj)
+ .SetField("inner2", innerPortObj)
+ .Build();
+
+ meta = outerPortObj.GetMetadata();
+
+ Assert.AreEqual(typeof(BuilderInBuilderOuter).Name, meta.TypeName);
+ Assert.AreEqual(2, meta.Fields.Count);
+ Assert.IsTrue(meta.Fields.Contains("inner"));
+ Assert.IsTrue(meta.Fields.Contains("inner2"));
+ Assert.AreEqual(PortableTypeNames.TypeNameObject, meta.GetFieldTypeName("inner"));
+ Assert.AreEqual(PortableTypeNames.TypeNameObject, meta.GetFieldTypeName("inner2"));
+
+ outer = outerPortObj.Deserialize<BuilderInBuilderOuter>();
+
+ Assert.AreSame(outer.Inner, outer.Inner2);
+
+ builderOuter = _grid.GetPortables().GetBuilder(outerPortObj);
+ IPortableBuilder builderInner2 = builderOuter.GetField<IPortableBuilder>("inner2");
+
+ builderInner2.SetField("outer", builderOuter);
+
+ outerPortObj = builderOuter.Build();
+
+ outer = outerPortObj.Deserialize<BuilderInBuilderOuter>();
+
+ Assert.AreSame(outer, outer.Inner.Outer);
+ Assert.AreSame(outer.Inner, outer.Inner2);
+ }
+
+ /// <summary>
+ /// Test for decimals building.
+ /// </summary>
+ [Test]
+ public void TestDecimals()
+ {
+ IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(DecimalHolder))
+ .SetField("val", decimal.One)
+ .SetField("valArr", new[] { decimal.MinusOne })
+ .Build();
+
+ IPortableMetadata meta = portObj.GetMetadata();
+
+ Assert.AreEqual(typeof(DecimalHolder).Name, meta.TypeName);
+ Assert.AreEqual(2, meta.Fields.Count);
+ Assert.IsTrue(meta.Fields.Contains("val"));
+ Assert.IsTrue(meta.Fields.Contains("valArr"));
+ Assert.AreEqual(PortableTypeNames.TypeNameDecimal, meta.GetFieldTypeName("val"));
+ Assert.AreEqual(PortableTypeNames.TypeNameArrayDecimal, meta.GetFieldTypeName("valArr"));
+
+ Assert.AreEqual(decimal.One, portObj.GetField<decimal>("val"));
+ Assert.AreEqual(new[] { decimal.MinusOne }, portObj.GetField<decimal[]>("valArr"));
+
+ DecimalHolder obj = portObj.Deserialize<DecimalHolder>();
+
+ Assert.AreEqual(decimal.One, obj.Val);
+ Assert.AreEqual(new[] { decimal.MinusOne }, obj.ValArr);
+ }
+
+ /// <summary>
+ /// Test for an object returning collection of builders.
+ /// </summary>
+ [Test]
+ public void TestBuilderCollection()
+ {
+ // Test collection with single element.
+ IPortableBuilder builderCol = _grid.GetPortables().GetBuilder(typeof(BuilderCollection));
+ IPortableBuilder builderItem =
+ _grid.GetPortables().GetBuilder(typeof(BuilderCollectionItem)).SetField("val", 1);
+
+ builderCol.SetField<ICollection>("col", new List<IPortableBuilder> { builderItem });
+
+ IPortableObject portCol = builderCol.Build();
+
+ IPortableMetadata meta = portCol.GetMetadata();
+
+ Assert.AreEqual(typeof(BuilderCollection).Name, meta.TypeName);
+ Assert.AreEqual(1, meta.Fields.Count);
+ Assert.AreEqual("col", meta.Fields.First());
+ Assert.AreEqual(PortableTypeNames.TypeNameCollection, meta.GetFieldTypeName("col"));
+
+ ICollection<IPortableObject> portColItems = portCol.GetField<ICollection<IPortableObject>>("col");
+
+ Assert.AreEqual(1, portColItems.Count);
+
+ IPortableObject portItem = portColItems.First();
+
+ meta = portItem.GetMetadata();
+
+ Assert.AreEqual(typeof(BuilderCollectionItem).Name, meta.TypeName);
+ Assert.AreEqual(1, meta.Fields.Count);
+ Assert.AreEqual("val", meta.Fields.First());
+ Assert.AreEqual(PortableTypeNames.TypeNameInt, meta.GetFieldTypeName("val"));
+
+ BuilderCollection col = portCol.Deserialize<BuilderCollection>();
+
+ Assert.IsNotNull(col.Col);
+ Assert.AreEqual(1, col.Col.Count);
+ Assert.AreEqual(1, col.Col.First().Val);
+
+ // Add more portable objects to collection.
+ builderCol = _grid.GetPortables().GetBuilder(portCol);
+
+ IList builderColItems = builderCol.GetField<IList>("col");
+
+ Assert.AreEqual(1, builderColItems.Count);
+
+ PortableBuilderImpl builderColItem = (PortableBuilderImpl) builderColItems[0];
+
+ builderColItem.SetField("val", 2); // Change nested value.
+
+ builderColItems.Add(builderColItem); // Add the same object to check handles.
+ builderColItems.Add(builderItem); // Add item from another builder.
+ builderColItems.Add(portItem); // Add item in portable form.
+
+ portCol = builderCol.Build();
+
+ col = portCol.Deserialize<BuilderCollection>();
+
+ Assert.AreEqual(4, col.Col.Count);
+
+ BuilderCollectionItem item0 = col.Col.ElementAt(0);
+ BuilderCollectionItem item1 = col.Col.ElementAt(1);
+ BuilderCollectionItem item2 = col.Col.ElementAt(2);
+ BuilderCollectionItem item3 = col.Col.ElementAt(3);
+
+ Assert.AreEqual(2, item0.Val);
+
+ Assert.AreSame(item0, item1);
+ Assert.AreNotSame(item0, item2);
+ Assert.AreNotSame(item0, item3);
+
+ Assert.AreEqual(1, item2.Val);
+ Assert.AreEqual(1, item3.Val);
+
+ Assert.AreNotSame(item2, item3);
+
+ // Test handle update inside collection.
+ builderCol = _grid.GetPortables().GetBuilder(portCol);
+
+ builderColItems = builderCol.GetField<IList>("col");
+
+ ((PortableBuilderImpl) builderColItems[1]).SetField("val", 3);
+
+ portCol = builderCol.Build();
+
+ col = portCol.Deserialize<BuilderCollection>();
+
+ item0 = col.Col.ElementAt(0);
+ item1 = col.Col.ElementAt(1);
+
+ Assert.AreEqual(3, item0.Val);
+ Assert.AreSame(item0, item1);
+ }
+
+ /// <summary>
+ /// Test build of an empty object.
+ /// </summary>
+ [Test]
+ public void TestEmptyDefined()
+ {
+ IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(Empty)).Build();
+
+ Assert.IsNotNull(portObj);
+ Assert.AreEqual(0, portObj.GetHashCode());
+
+ IPortableMetadata meta = portObj.GetMetadata();
+
+ Assert.IsNotNull(meta);
+ Assert.AreEqual(typeof(Empty).Name, meta.TypeName);
+ Assert.AreEqual(0, meta.Fields.Count);
+
+ Empty obj = portObj.Deserialize<Empty>();
+
+ Assert.IsNotNull(obj);
+ }
+
+ /// <summary>
+ /// Test build of an empty object with disabled metadata.
+ /// </summary>
+ [Test]
+ public void TestEmptyNoMeta()
+ {
+ IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(EmptyNoMeta)).Build();
+
+ Assert.IsNotNull(portObj);
+ Assert.AreEqual(0, portObj.GetHashCode());
+
+ EmptyNoMeta obj = portObj.Deserialize<EmptyNoMeta>();
+
+ Assert.IsNotNull(obj);
+ }
+
+ /// <summary>
+ /// Test build of an empty undefined object.
+ /// </summary>
+ [Test]
+ public void TestEmptyUndefined()
+ {
+ IPortableObject portObj = _grid.GetPortables().GetBuilder(TypeEmpty).Build();
+
+ Assert.IsNotNull(portObj);
+ Assert.AreEqual(0, portObj.GetHashCode());
+
+ IPortableMetadata meta = portObj.GetMetadata();
+
+ Assert.IsNotNull(meta);
+ Assert.AreEqual(TypeEmpty, meta.TypeName);
+ Assert.AreEqual(0, meta.Fields.Count);
+ }
+
+ /// <summary>
+ /// Test object rebuild with no changes.
+ /// </summary>
+ [Test]
+ public void TestEmptyRebuild()
+ {
+ var portObj = (PortableUserObject) _grid.GetPortables().GetBuilder(typeof(EmptyNoMeta)).Build();
+
+ PortableUserObject newPortObj = (PortableUserObject) _grid.GetPortables().GetBuilder(portObj).Build();
+
+ Assert.AreEqual(portObj.Data, newPortObj.Data);
+ }
+
+ /// <summary>
+ /// Test hash code alteration.
+ /// </summary>
+ [Test]
+ public void TestHashCodeChange()
+ {
+ IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(EmptyNoMeta)).SetHashCode(100).Build();
+
+ Assert.AreEqual(100, portObj.GetHashCode());
+ }
+
+ /// <summary>
+ /// Test primitive fields setting.
+ /// </summary>
+ [Test]
+ public void TestPrimitiveFields()
+ {
+ IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(Primitives))
+ .SetField<byte>("fByte", 1)
+ .SetField("fBool", true)
+ .SetField<short>("fShort", 2)
+ .SetField("fChar", 'a')
+ .SetField("fInt", 3)
+ .SetField<long>("fLong", 4)
+ .SetField<float>("fFloat", 5)
+ .SetField<double>("fDouble", 6)
+ .SetHashCode(100)
+ .Build();
+
+ Assert.AreEqual(100, portObj.GetHashCode());
+
+ IPortableMetadata meta = portObj.GetMetadata();
+
+ Assert.AreEqual(typeof(Primitives).Name, meta.TypeName);
+
+ Assert.AreEqual(8, meta.Fields.Count);
+
+ Assert.AreEqual(PortableTypeNames.TypeNameByte, meta.GetFieldTypeName("fByte"));
+ Assert.AreEqual(PortableTypeNames.TypeNameBool, meta.GetFieldTypeName("fBool"));
+ Assert.AreEqual(PortableTypeNames.TypeNameShort, meta.GetFieldTypeName("fShort"));
+ Assert.AreEqual(PortableTypeNames.TypeNameChar, meta.GetFieldTypeName("fChar"));
+ Assert.AreEqual(PortableTypeNames.TypeNameInt, meta.GetFieldTypeName("fInt"));
+ Assert.AreEqual(PortableTypeNames.TypeNameLong, meta.GetFieldTypeName("fLong"));
+ Assert.AreEqual(PortableTypeNames.TypeNameFloat, meta.GetFieldTypeName("fFloat"));
+ Assert.AreEqual(PortableTypeNames.TypeNameDouble, meta.GetFieldTypeName("fDouble"));
+
+ Assert.AreEqual(1, portObj.GetField<byte>("fByte"));
+ Assert.AreEqual(true, portObj.GetField<bool>("fBool"));
+ Assert.AreEqual(2, portObj.GetField<short>("fShort"));
+ Assert.AreEqual('a', portObj.GetField<char>("fChar"));
+ Assert.AreEqual(3, portObj.GetField<int>("fInt"));
+ Assert.AreEqual(4, portObj.GetField<long>("fLong"));
+ Assert.AreEqual(5, portObj.GetField<float>("fFloat"));
+ Assert.AreEqual(6, portObj.GetField<double>("fDouble"));
+
+ Primitives obj = portObj.Deserialize<Primitives>();
+
+ Assert.AreEqual(1, obj.FByte);
+ Assert.AreEqual(true, obj.FBool);
+ Assert.AreEqual(2, obj.FShort);
+ Assert.AreEqual('a', obj.FChar);
+ Assert.AreEqual(3, obj.FInt);
+ Assert.AreEqual(4, obj.FLong);
+ Assert.AreEqual(5, obj.FFloat);
+ Assert.AreEqual(6, obj.FDouble);
+
+ // Overwrite.
+ portObj = _grid.GetPortables().GetBuilder(portObj)
+ .SetField<byte>("fByte", 7)
+ .SetField("fBool", false)
+ .SetField<short>("fShort", 8)
+ .SetField("fChar", 'b')
+ .SetField("fInt", 9)
+ .SetField<long>("fLong", 10)
+ .SetField<float>("fFloat", 11)
+ .SetField<double>("fDouble", 12)
+ .SetHashCode(200)
+ .Build();
+
+ Assert.AreEqual(200, portObj.GetHashCode());
+
+ Assert.AreEqual(7, portObj.GetField<byte>("fByte"));
+ Assert.AreEqual(false, portObj.GetField<bool>("fBool"));
+ Assert.AreEqual(8, portObj.GetField<short>("fShort"));
+ Assert.AreEqual('b', portObj.GetField<char>("fChar"));
+ Assert.AreEqual(9, portObj.GetField<int>("fInt"));
+ Assert.AreEqual(10, portObj.GetField<long>("fLong"));
+ Assert.AreEqual(11, portObj.GetField<float>("fFloat"));
+ Assert.AreEqual(12, portObj.GetField<double>("fDouble"));
+
+ obj = portObj.Deserialize<Primitives>();
+
+ Assert.AreEqual(7, obj.FByte);
+ Assert.AreEqual(false, obj.FBool);
+ Assert.AreEqual(8, obj.FShort);
+ Assert.AreEqual('b', obj.FChar);
+ Assert.AreEqual(9, obj.FInt);
+ Assert.AreEqual(10, obj.FLong);
+ Assert.AreEqual(11, obj.FFloat);
+ Assert.AreEqual(12, obj.FDouble);
+ }
+
+ /// <summary>
+ /// Test primitive array fields setting.
+ /// </summary>
+ [Test]
+ public void TestPrimitiveArrayFields()
+ {
+ IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(PrimitiveArrays))
+ .SetField("fByte", new byte[] { 1 })
+ .SetField("fBool", new[] { true })
+ .SetField("fShort", new short[] { 2 })
+ .SetField("fChar", new[] { 'a' })
+ .SetField("fInt", new[] { 3 })
+ .SetField("fLong", new long[] { 4 })
+ .SetField("fFloat", new float[] { 5 })
+ .SetField("fDouble", new double[] { 6 })
+ .SetHashCode(100)
+ .Build();
+
+ Assert.AreEqual(100, portObj.GetHashCode());
+
+ IPortableMetadata meta = portObj.GetMetadata();
+
+ Assert.AreEqual(typeof(PrimitiveArrays).Name, meta.TypeName);
+
+ Assert.AreEqual(8, meta.Fields.Count);
+
+ Assert.AreEqual(PortableTypeNames.TypeNameArrayByte, meta.GetFieldTypeName("fByte"));
+ Assert.AreEqual(PortableTypeNames.TypeNameArrayBool, meta.GetFieldTypeName("fBool"));
+ Assert.AreEqual(PortableTypeNames.TypeNameArrayShort, meta.GetFieldTypeName("fShort"));
+ Assert.AreEqual(PortableTypeNames.TypeNameArrayChar, meta.GetFieldTypeName("fChar"));
+ Assert.AreEqual(PortableTypeNames.TypeNameArrayInt, meta.GetFieldTypeName("fInt"));
+ Assert.AreEqual(PortableTypeNames.TypeNameArrayLong, meta.GetFieldTypeName("fLong"));
+ Assert.AreEqual(PortableTypeNames.TypeNameArrayFloat, meta.GetFieldTypeName("fFloat"));
+ Assert.AreEqual(PortableTypeNames.TypeNameArrayDouble, meta.GetFieldTypeName("fDouble"));
+
+ Assert.AreEqual(new byte[] { 1 }, portObj.GetField<byte[]>("fByte"));
+ Assert.AreEqual(new[] { true }, portObj.GetField<bool[]>("fBool"));
+ Assert.AreEqual(new short[] { 2 }, portObj.GetField<short[]>("fShort"));
+ Assert.AreEqual(new[] { 'a' }, portObj.GetField<char[]>("fChar"));
+ Assert.AreEqual(new[] { 3 }, portObj.GetField<int[]>("fInt"));
+ Assert.AreEqual(new long[] { 4 }, portObj.GetField<long[]>("fLong"));
+ Assert.AreEqual(new float[] { 5 }, portObj.GetField<float[]>("fFloat"));
+ Assert.AreEqual(new double[] { 6 }, portObj.GetField<double[]>("fDouble"));
+
+ PrimitiveArrays obj = portObj.Deserialize<PrimitiveArrays>();
+
+ Assert.AreEqual(new byte[] { 1 }, obj.FByte);
+ Assert.AreEqual(new[] { true }, obj.FBool);
+ Assert.AreEqual(new short[] { 2 }, obj.FShort);
+ Assert.AreEqual(new[] { 'a' }, obj.FChar);
+ Assert.AreEqual(new[] { 3 }, obj.FInt);
+ Assert.AreEqual(new long[] { 4 }, obj.FLong);
+ Assert.AreEqual(new float[] { 5 }, obj.FFloat);
+ Assert.AreEqual(new double[] { 6 }, obj.FDouble);
+
+ // Overwrite.
+ portObj = _grid.GetPortables().GetBuilder(portObj)
+ .SetField("fByte", new byte[] { 7 })
+ .SetField("fBool", new[] { false })
+ .SetField("fShort", new short[] { 8 })
+ .SetField("fChar", new[] { 'b' })
+ .SetField("fInt", new[] { 9 })
+ .SetField("fLong", new long[] { 10 })
+ .SetField("fFloat", new float[] { 11 })
+ .SetField("fDouble", new double[] { 12 })
+ .SetHashCode(200)
+ .Build();
+
+ Assert.AreEqual(200, portObj.GetHashCode());
+
+ Assert.AreEqual(new byte[] { 7 }, portObj.GetField<byte[]>("fByte"));
+ Assert.AreEqual(new[] { false }, portObj.GetField<bool[]>("fBool"));
+ Assert.AreEqual(new short[] { 8 }, portObj.GetField<short[]>("fShort"));
+ Assert.AreEqual(new[] { 'b' }, portObj.GetField<char[]>("fChar"));
+ Assert.AreEqual(new[] { 9 }, portObj.GetField<int[]>("fInt"));
+ Assert.AreEqual(new long[] { 10 }, portObj.GetField<long[]>("fLong"));
+ Assert.AreEqual(new float[] { 11 }, portObj.GetField<float[]>("fFloat"));
+ Assert.AreEqual(new double[] { 12 }, portObj.GetField<double[]>("fDouble"));
+
+ obj = portObj.Deserialize<PrimitiveArrays>();
+
+ Assert.AreEqual(new byte[] { 7 }, obj.FByte);
+ Assert.AreEqual(new[] { false }, obj.FBool);
+ Assert.AreEqual(new short[] { 8 }, obj.FShort);
+ Assert.AreEqual(new[] { 'b' }, obj.FChar);
+ Assert.AreEqual(new[] { 9 }, obj.FInt);
+ Assert.AreEqual(new long[] { 10 }, obj.FLong);
+ Assert.AreEqual(new float[] { 11 }, obj.FFloat);
+ Assert.AreEqual(new double[] { 12 }, obj.FDouble);
+ }
+
+ /// <summary>
+ /// Test non-primitive fields and their array counterparts.
+ /// </summary>
+ [Test]
+ public void TestStringDateGuidEnum()
+ {
+ DateTime date = DateTime.Now.ToUniversalTime();
+ DateTime? nDate = DateTime.Now.ToUniversalTime();
+
+ Guid guid = Guid.NewGuid();
+ Guid? nGuid = Guid.NewGuid();
+
+ IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(StringDateGuidEnum))
+ .SetField("fStr", "str")
+ .SetField("fDate", date)
+ .SetField("fNDate", nDate)
+ .SetField("fGuid", guid)
+ .SetField("fNGuid", nGuid)
+ .SetField("fEnum", TestEnum.One)
+ .SetField("fStrArr", new[] { "str" })
+ .SetField("fDateArr", new[] { nDate })
+ .SetField("fGuidArr", new[] { nGuid })
+ .SetField("fEnumArr", new[] { TestEnum.One })
+ .SetHashCode(100)
+ .Build();
+
+ Assert.AreEqual(100, portObj.GetHashCode());
+
+ IPortableMetadata meta = portObj.GetMetadata();
+
+ Assert.AreEqual(typeof(StringDateGuidEnum).Name, meta.TypeName);
+
+ Assert.AreEqual(10, meta.Fields.Count);
+
+ Assert.AreEqual(PortableTypeNames.TypeNameString, meta.GetFieldTypeName("fStr"));
+ Assert.AreEqual(PortableTypeNames.TypeNameDate, meta.GetFieldTypeName("fDate"));
+ Assert.AreEqual(PortableTypeNames.TypeNameDate, meta.GetFieldTypeName("fNDate"));
+ Assert.AreEqual(PortableTypeNames.TypeNameGuid, meta.GetFieldTypeName("fGuid"));
+ Assert.AreEqual(PortableTypeNames.TypeNameGuid, meta.GetFieldTypeName("fNGuid"));
+ Assert.AreEqual(PortableTypeNames.TypeNameEnum, meta.GetFieldTypeName("fEnum"));
+ Assert.AreEqual(PortableTypeNames.TypeNameArrayString, meta.GetFieldTypeName("fStrArr"));
+ Assert.AreEqual(PortableTypeNames.TypeNameArrayDate, meta.GetFieldTypeName("fDateArr"));
+ Assert.AreEqual(PortableTypeNames.TypeNameArrayGuid, meta.GetFieldTypeName("fGuidArr"));
+ Assert.AreEqual(PortableTypeNames.TypeNameArrayEnum, meta.GetFieldTypeName("fEnumArr"));
+
+ Assert.AreEqual("str", portObj.GetField<string>("fStr"));
+ Assert.AreEqual(date, portObj.GetField<DateTime>("fDate"));
+ Assert.AreEqual(nDate, portObj.GetField<DateTime?>("fNDate"));
+ Assert.AreEqual(guid, portObj.GetField<Guid>("fGuid"));
+ Assert.AreEqual(nGuid, portObj.GetField<Guid?>("fNGuid"));
+ Assert.AreEqual(TestEnum.One, portObj.GetField<TestEnum>("fEnum"));
+ Assert.AreEqual(new[] { "str" }, portObj.GetField<string[]>("fStrArr"));
+ Assert.AreEqual(new[] { nDate }, portObj.GetField<DateTime?[]>("fDateArr"));
+ Assert.AreEqual(new[] { nGuid }, portObj.GetField<Guid?[]>("fGuidArr"));
+ Assert.AreEqual(new[] { TestEnum.One }, portObj.GetField<TestEnum[]>("fEnumArr"));
+
+ StringDateGuidEnum obj = portObj.Deserialize<StringDateGuidEnum>();
+
+ Assert.AreEqual("str", obj.FStr);
+ Assert.AreEqual(date, obj.FDate);
+ Assert.AreEqual(nDate, obj.FnDate);
+ Assert.AreEqual(guid, obj.FGuid);
+ Assert.AreEqual(nGuid, obj.FnGuid);
+ Assert.AreEqual(TestEnum.One, obj.FEnum);
+ Assert.AreEqual(new[] { "str" }, obj.FStrArr);
+ Assert.AreEqual(new[] { nDate }, obj.FDateArr);
+ Assert.AreEqual(new[] { nGuid }, obj.FGuidArr);
+ Assert.AreEqual(new[] { TestEnum.One }, obj.FEnumArr);
+
+ // Overwrite.
+ date = DateTime.Now.ToUniversalTime();
+ nDate = DateTime.Now.ToUniversalTime();
+
+ guid = Guid.NewGuid();
+ nGuid = Guid.NewGuid();
+
+ portObj = _grid.GetPortables().GetBuilder(typeof(StringDateGuidEnum))
+ .SetField("fStr", "str2")
+ .SetField("fDate", date)
+ .SetField("fNDate", nDate)
+ .SetField("fGuid", guid)
+ .SetField("fNGuid", nGuid)
+ .SetField("fEnum", TestEnum.Two)
+ .SetField("fStrArr", new[] { "str2" })
+ .SetField("fDateArr", new[] { nDate })
+ .SetField("fGuidArr", new[] { nGuid })
+ .SetField("fEnumArr", new[] { TestEnum.Two })
+ .SetHashCode(200)
+ .Build();
+
+ Assert.AreEqual(200, portObj.GetHashCode());
+
+ Assert.AreEqual("str2", portObj.GetField<string>("fStr"));
+ Assert.AreEqual(date, portObj.GetField<DateTime>("fDate"));
+ Assert.AreEqual(nDate, portObj.GetField<DateTime?>("fNDate"));
+ Assert.AreEqual(guid, portObj.GetField<Guid>("fGuid"));
+ Assert.AreEqual(nGuid, portObj.GetField<Guid?>("fNGuid"));
+ Assert.AreEqual(TestEnum.Two, portObj.GetField<TestEnum>("fEnum"));
+ Assert.AreEqual(new[] { "str2" }, portObj.GetField<string[]>("fStrArr"));
+ Assert.AreEqual(new[] { nDate }, portObj.GetField<DateTime?[]>("fDateArr"));
+ Assert.AreEqual(new[] { nGuid }, portObj.GetField<Guid?[]>("fGuidArr"));
+ Assert.AreEqual(new[] { TestEnum.Two }, portObj.GetField<TestEnum[]>("fEnumArr"));
+
+ obj = portObj.Deserialize<StringDateGuidEnum>();
+
+ Assert.AreEqual("str2", obj.FStr);
+ Assert.AreEqual(date, obj.FDate);
+ Assert.AreEqual(nDate, obj.FnDate);
+ Assert.AreEqual(guid, obj.FGuid);
+ Assert.AreEqual(nGuid, obj.FnGuid);
+ Assert.AreEqual(TestEnum.Two, obj.FEnum);
+ Assert.AreEqual(new[] { "str2" }, obj.FStrArr);
+ Assert.AreEqual(new[] { nDate }, obj.FDateArr);
+ Assert.AreEqual(new[] { nGuid }, obj.FGuidArr);
+ Assert.AreEqual(new[] { TestEnum.Two }, obj.FEnumArr);
+ }
+
+ /// <summary>
+ /// Test arrays.
+ /// </summary>
+ [Test]
+ public void TestCompositeArray()
+ {
+ // 1. Test simple array.
+ CompositeInner[] inArr = { new CompositeInner(1) };
+
+ IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
+ .SetField("inArr", inArr).Build();
+
+ IPortableMetadata meta = portObj.GetMetadata();
+
+ Assert.AreEqual(typeof(CompositeArray).Name, meta.TypeName);
+ Assert.AreEqual(1, meta.Fields.Count);
+ Assert.AreEqual(PortableTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("inArr"));
+
+ Assert.AreEqual(100, portObj.GetHashCode());
+
+ IPortableObject[] portInArr = portObj.GetField<IPortableObject[]>("inArr");
+
+ Assert.AreEqual(1, portInArr.Length);
+ Assert.AreEqual(1, portInArr[0].GetField<int>("val"));
+
+ CompositeArray arr = portObj.Deserialize<CompositeArray>();
+
+ Assert.IsNull(arr.OutArr);
+ Assert.AreEqual(1, arr.InArr.Length);
+ Assert.AreEqual(1, arr.InArr[0].Val);
+
+ // 2. Test addition to array.
+ portInArr = new[] { portInArr[0], null };
+
+ portObj = _grid.GetPortables().GetBuilder(portObj).SetHashCode(200)
+ .SetField("inArr", portInArr).Build();
+
+ Assert.AreEqual(200, portObj.GetHashCode());
+
+ portInArr = portObj.GetField<IPortableObject[]>("inArr");
+
+ Assert.AreEqual(2, portInArr.Length);
+ Assert.AreEqual(1, portInArr[0].GetField<int>("val"));
+ Assert.IsNull(portInArr[1]);
+
+ arr = portObj.Deserialize<CompositeArray>();
+
+ Assert.IsNull(arr.OutArr);
+ Assert.AreEqual(2, arr.InArr.Length);
+ Assert.AreEqual(1, arr.InArr[0].Val);
+ Assert.IsNull(arr.InArr[1]);
+
+ portInArr[1] = _grid.GetPortables().GetBuilder(typeof(CompositeInner)).SetField("val", 2).Build();
+
+ portObj = _grid.GetPortables().GetBuilder(portObj).SetHashCode(300)
+ .SetField("inArr", portInArr).Build();
+
+ Assert.AreEqual(300, portObj.GetHashCode());
+
+ portInArr = portObj.GetField<IPortableObject[]>("inArr");
+
+ Assert.AreEqual(2, portInArr.Length);
+ Assert.AreEqual(1, portInArr[0].GetField<int>("val"));
+ Assert.AreEqual(2, portInArr[1].GetField<int>("val"));
+
+ arr = portObj.Deserialize<CompositeArray>();
+
+ Assert.IsNull(arr.OutArr);
+ Assert.AreEqual(2, arr.InArr.Length);
+ Assert.AreEqual(1, arr.InArr[0].Val);
+ Assert.AreEqual(2, arr.InArr[1].Val);
+
+ // 3. Test top-level handle inversion.
+ CompositeInner inner = new CompositeInner(1);
+
+ inArr = new[] { inner, inner };
+
+ portObj = _grid.GetPortables().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
+ .SetField("inArr", inArr).Build();
+
+ Assert.AreEqual(100, portObj.GetHashCode());
+
+ portInArr = portObj.GetField<IPortableObject[]>("inArr");
+
+ Assert.AreEqual(2, portInArr.Length);
+ Assert.AreEqual(1, portInArr[0].GetField<int>("val"));
+ Assert.AreEqual(1, portInArr[1].GetField<int>("val"));
+
+ arr = portObj.Deserialize<CompositeArray>();
+
+ Assert.IsNull(arr.OutArr);
+ Assert.AreEqual(2, arr.InArr.Length);
+ Assert.AreEqual(1, arr.InArr[0].Val);
+ Assert.AreEqual(1, arr.InArr[1].Val);
+
+ portInArr[0] = _grid.GetPortables().GetBuilder(typeof(CompositeInner)).SetField("val", 2).Build();
+
+ portObj = _grid.GetPortables().GetBuilder(portObj).SetHashCode(200)
+ .SetField("inArr", portInArr).Build();
+
+ Assert.AreEqual(200, portObj.GetHashCode());
+
+ portInArr = portObj.GetField<IPortableObject[]>("inArr");
+
+ Assert.AreEqual(2, portInArr.Length);
+ Assert.AreEqual(2, portInArr[0].GetField<int>("val"));
+ Assert.AreEqual(1, portInArr[1].GetField<int>("val"));
+
+ arr = portObj.Deserialize<CompositeArray>();
+
+ Assert.IsNull(arr.OutArr);
+ Assert.AreEqual(2, arr.InArr.Length);
+ Assert.AreEqual(2, arr.InArr[0].Val);
+ Assert.AreEqual(1, arr.InArr[1].Val);
+
+ // 4. Test nested object handle inversion.
+ CompositeOuter[] outArr = { new CompositeOuter(inner), new CompositeOuter(inner) };
+
+ portObj = _grid.GetPortables().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
+ .SetField("outArr", outArr).Build();
+
+ meta = portObj.GetMetadata();
+
+ Assert.AreEqual(typeof(CompositeArray).Name, meta.TypeName);
+ Assert.AreEqual(2, meta.Fields.Count);
+ Assert.AreEqual(PortableTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("inArr"));
+ Assert.AreEqual(PortableTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("outArr"));
+
+ Assert.AreEqual(100, portObj.GetHashCode());
+
+ IPortableObject[] portOutArr = portObj.GetField<IPortableObject[]>("outArr");
+
+ Assert.AreEqual(2, portOutArr.Length);
+ Assert.AreEqual(1, portOutArr[0].GetField<IPortableObject>("inner").GetField<int>("val"));
+ Assert.AreEqual(1, portOutArr[1].GetField<IPortableObject>("inner").GetField<int>("val"));
+
+ arr = portObj.Deserialize<CompositeArray>();
+
+ Assert.IsNull(arr.InArr);
+ Assert.AreEqual(2, arr.OutArr.Length);
+ Assert.AreEqual(1, arr.OutArr[0].Inner.Val);
+ Assert.AreEqual(1, arr.OutArr[1].Inner.Val);
+
+ portOutArr[0] = _grid.GetPortables().GetBuilder(typeof(CompositeOuter))
+ .SetField("inner", new CompositeInner(2)).Build();
+
+ portObj = _grid.GetPortables().GetBuilder(portObj).SetHashCode(200)
+ .SetField("outArr", portOutArr).Build();
+
+ Assert.AreEqual(200, portObj.GetHashCode());
+
+ portInArr = portObj.GetField<IPortableObject[]>("outArr");
+
+ Assert.AreEqual(2, portInArr.Length);
+ Assert.AreEqual(2, portOutArr[0].GetField<IPortableObject>("inner").GetField<int>("val"));
+ Assert.AreEqual(1, portOutArr[1].GetField<IPortableObject>("inner").GetField<int>("val"));
+
+ arr = portObj.Deserialize<CompositeArray>();
+
+ Assert.IsNull(arr.InArr);
+ Assert.AreEqual(2, arr.OutArr.Length);
+ Assert.AreEqual(2, arr.OutArr[0].Inner.Val);
+ Assert.AreEqual(1, arr.OutArr[1].Inner.Val);
+ }
+
+ /// <summary>
+ /// Test container types other than array.
+ /// </summary>
+ [Test]
+ public void TestCompositeContainer()
+ {
+ ArrayList col = new ArrayList();
+ ICollection<CompositeInner> gCol = new List<CompositeInner>();
+ IDictionary dict = new Hashtable();
+ IDictionary<int, CompositeInner> gDict = new Dictionary<int, CompositeInner>();
+
+ col.Add(new CompositeInner(1));
+ gCol.Add(new CompositeInner(2));
+ dict[3] = new CompositeInner(3);
+ gDict[4] = new CompositeInner(4);
+
+ IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(CompositeContainer)).SetHashCode(100)
+ .SetField<ICollection>("col", col)
+ .SetField("gCol", gCol)
+ .SetField("dict", dict)
+ .SetField("gDict", gDict).Build();
+
+ // 1. Check meta.
+ IPortableMetadata meta = portObj.GetMetadata();
+
+ Assert.AreEqual(typeof(CompositeContainer).Name, meta.TypeName);
+
+ Assert.AreEqual(4, meta.Fields.Count);
+ Assert.AreEqual(PortableTypeNames.TypeNameCollection, meta.GetFieldTypeName("col"));
+ Assert.AreEqual(PortableTypeNames.TypeNameCollection, meta.GetFieldTypeName("gCol"));
+ Assert.AreEqual(PortableTypeNames.TypeNameMap, meta.GetFieldTypeName("dict"));
+ Assert.AreEqual(PortableTypeNames.TypeNameMap, meta.GetFieldTypeName("gDict"));
+
+ // 2. Check in portable form.
+ Assert.AreEqual(1, portObj.GetField<ICollection>("col").Count);
+ Assert.AreEqual(1, portObj.GetField<ICollection>("col").OfType<IPortableObject>().First()
+ .GetField<int>("val"));
+
+ Assert.AreEqual(1, portObj.GetField<ICollection<IPortableObject>>("gCol").Count);
+ Assert.AreEqual(2, portObj.GetField<ICollection<IPortableObject>>("gCol").First().GetField<int>("val"));
+
+ Assert.AreEqual(1, portObj.GetField<IDictionary>("dict").Count);
+ Assert.AreEqual(3, ((IPortableObject) portObj.GetField<IDictionary>("dict")[3]).GetField<int>("val"));
+
+ Assert.AreEqual(1, portObj.GetField<IDictionary<int, IPortableObject>>("gDict").Count);
+ Assert.AreEqual(4, portObj.GetField<IDictionary<int, IPortableObject>>("gDict")[4].GetField<int>("val"));
+
+ // 3. Check in deserialized form.
+ CompositeContainer obj = portObj.Deserialize<CompositeContainer>();
+
+ Assert.AreEqual(1, obj.Col.Count);
+ Assert.AreEqual(1, obj.Col.OfType<CompositeInner>().First().Val);
+
+ Assert.AreEqual(1, obj.GCol.Count);
+ Assert.AreEqual(2, obj.GCol.First().Val);
+
+ Assert.AreEqual(1, obj.Dict.Count);
+ Assert.AreEqual(3, ((CompositeInner) obj.Dict[3]).Val);
+
+ Assert.AreEqual(1, obj.GDict.Count);
+ Assert.AreEqual(4, obj.GDict[4].Val);
+ }
+
+ /// <summary>
+ /// Ensure that raw data is not lost during build.
+ /// </summary>
+ [Test]
+ public void TestRawData()
+ {
+ var raw = new WithRaw
+ {
+ A = 1,
+ B = 2
+ };
+
+ var portObj = _marsh.Unmarshal<IPortableObject>(_marsh.Marshal(raw), PortableMode.ForcePortable);
+
+ raw = portObj.Deserialize<WithRaw>();
+
+ Assert.AreEqual(1, raw.A);
+ Assert.AreEqual(2, raw.B);
+
+ IPortableObject newPortObj = _grid.GetPortables().GetBuilder(portObj).SetField("a", 3).Build();
+
+ raw = newPortObj.Deserialize<WithRaw>();
+
+ Assert.AreEqual(3, raw.A);
+ Assert.AreEqual(2, raw.B);
+ }
+
+ /// <summary>
+ /// Test nested objects.
+ /// </summary>
+ [Test]
+ public void TestNested()
+ {
+ // 1. Create from scratch.
+ IPortableBuilder builder = _grid.GetPortables().GetBuilder(typeof(NestedOuter));
+
+ NestedInner inner1 = new NestedInner {Val = 1};
+ builder.SetField("inner1", inner1);
+
+ IPortableObject outerPortObj = builder.Build();
+
+ IPortableMetadata meta = outerPortObj.GetMetadata();
+
+ Assert.AreEqual(typeof(NestedOuter).Name, meta.TypeName);
+ Assert.AreEqual(1, meta.Fields.Count);
+ Assert.AreEqual(PortableTypeNames.TypeNameObject, meta.GetFieldTypeName("inner1"));
+
+ IPortableObject innerPortObj1 = outerPortObj.GetField<IPortableObject>("inner1");
+
+ IPortableMetadata innerMeta = innerPortObj1.GetMetadata();
+
+ Assert.AreEqual(typeof(NestedInner).Name, innerMeta.TypeName);
+ Assert.AreEqual(1, innerMeta.Fields.Count);
+ Assert.AreEqual(PortableTypeNames.TypeNameInt, innerMeta.GetFieldTypeName("Val"));
+
+ inner1 = innerPortObj1.Deserialize<NestedInner>();
+
+ Assert.AreEqual(1, inner1.Val);
+
+ NestedOuter outer = outerPortObj.Deserialize<NestedOuter>();
+ Assert.AreEqual(outer.Inner1.Val, 1);
+ Assert.IsNull(outer.Inner2);
+
+ // 2. Add another field over existing portable object.
+ builder = _grid.GetPortables().GetBuilder(outerPortObj);
+
+ NestedInner inner2 = new NestedInner {Val = 2};
+ builder.SetField("inner2", inner2);
+
+ outerPortObj = builder.Build();
+
+ outer = outerPortObj.Deserialize<NestedOuter>();
+ Assert.AreEqual(1, outer.Inner1.Val);
+ Assert.AreEqual(2, outer.Inner2.Val);
+
+ // 3. Try setting inner object in portable form.
+ innerPortObj1 = _grid.GetPortables().GetBuilder(innerPortObj1).SetField("val", 3).Build();
+
+ inner1 = innerPortObj1.Deserialize<NestedInner>();
+
+ Assert.AreEqual(3, inner1.Val);
+
+ outerPortObj = _grid.GetPortables().GetBuilder(outerPortObj).SetField<object>("inner1", innerPortObj1).Build();
+
+ outer = outerPortObj.Deserialize<NestedOuter>();
+ Assert.AreEqual(3, outer.Inner1.Val);
+ Assert.AreEqual(2, outer.Inner2.Val);
+ }
+
+ /// <summary>
+ /// Test handle migration.
+ /// </summary>
+ [Test]
+ public void TestHandleMigration()
+ {
+ // 1. Simple comparison of results.
+ MigrationInner inner = new MigrationInner {Val = 1};
+
+ MigrationOuter outer = new MigrationOuter
+ {
+ Inner1 = inner,
+ Inner2 = inner
+ };
+
+ byte[] outerBytes = _marsh.Marshal(outer);
+
+ IPortableBuilder builder = _grid.GetPortables().GetBuilder(typeof(MigrationOuter));
+
+ builder.SetHashCode(outer.GetHashCode());
+
+ builder.SetField<object>("inner1", inner);
+ builder.SetField<object>("inner2", inner);
+
+ PortableUserObject portOuter = (PortableUserObject) builder.Build();
+
+ byte[] portOuterBytes = new byte[outerBytes.Length];
+
+ Buffer.BlockCopy(portOuter.Data, 0, portOuterBytes, 0, portOuterBytes.Length);
+
+ Assert.AreEqual(outerBytes, portOuterBytes);
+
+ // 2. Change the first inner object so that the handle must migrate.
+ MigrationInner inner1 = new MigrationInner {Val = 2};
+
+ IPortableObject portOuterMigrated =
+ _grid.GetPortables().GetBuilder(portOuter).SetField<object>("inner1", inner1).Build();
+
+ MigrationOuter outerMigrated = portOuterMigrated.Deserialize<MigrationOuter>();
+
+ Assert.AreEqual(2, outerMigrated.Inner1.Val);
+ Assert.AreEqual(1, outerMigrated.Inner2.Val);
+
+ // 3. Change the first value using serialized form.
+ IPortableObject inner1Port =
+ _grid.GetPortables().GetBuilder(typeof(MigrationInner)).SetField("val", 2).Build();
+
+ portOuterMigrated =
+ _grid.GetPortables().GetBuilder(portOuter).SetField<object>("inner1", inner1Port).Build();
+
+ outerMigrated = portOuterMigrated.Deserialize<MigrationOuter>();
+
+ Assert.AreEqual(2, outerMigrated.Inner1.Val);
+ Assert.AreEqual(1, outerMigrated.Inner2.Val);
+ }
+
+ /// <summary>
+ /// Test handle inversion.
+ /// </summary>
+ [Test]
+ public void TestHandleInversion()
+ {
+ InversionInner inner = new InversionInner();
+ InversionOuter outer = new InversionOuter();
+
+ inner.Outer = outer;
+ outer.Inner = inner;
+
+ byte[] rawOuter = _marsh.Marshal(outer);
+
+ IPortableObject portOuter = _marsh.Unmarshal<IPortableObject>(rawOuter, PortableMode.ForcePortable);
+ IPortableObject portInner = portOuter.GetField<IPortableObject>("inner");
+
+ // 1. Ensure that inner object can be deserialized after build.
+ IPortableObject portInnerNew = _grid.GetPortables().GetBuilder(portInner).Build();
+
+ InversionInner innerNew = portInnerNew.Deserialize<InversionInner>();
+
+ Assert.AreSame(innerNew, innerNew.Outer.Inner);
+
+ // 2. Ensure that portable object with external dependencies could be added to builder.
+ IPortableObject portOuterNew =
+ _grid.GetPortables().GetBuilder(typeof(InversionOuter)).SetField<object>("inner", portInner).Build();
+
+ InversionOuter outerNew = portOuterNew.Deserialize<InversionOuter>();
+
+ Assert.AreNotSame(outerNew, outerNew.Inner.Outer);
+ Assert.AreSame(outerNew.Inner, outerNew.Inner.Outer.Inner);
+ }
+
+ /// <summary>
+ /// Test build multiple objects.
+ /// </summary>
+ [Test]
+ public void TestBuildMultiple()
+ {
+ IPortableBuilder builder = _grid.GetPortables().GetBuilder(typeof(Primitives));
+
+ builder.SetField<byte>("fByte", 1).SetField("fBool", true);
+
+ IPortableObject po1 = builder.Build();
+ IPortableObject po2 = builder.Build();
+
+ Assert.AreEqual(1, po1.GetField<byte>("fByte"));
+ Assert.AreEqual(true, po1.GetField<bool>("fBool"));
+
+ Assert.AreEqual(1, po2.GetField<byte>("fByte"));
+ Assert.AreEqual(true, po2.GetField<bool>("fBool"));
+
+ builder.SetField<byte>("fByte", 2);
+
+ IPortableObject po3 = builder.Build();
+
+ Assert.AreEqual(1, po1.GetField<byte>("fByte"));
+ Assert.AreEqual(true, po1.GetField<bool>("fBool"));
+
+ Assert.AreEqual(1, po2.GetField<byte>("fByte"));
+ Assert.AreEqual(true, po2.GetField<bool>("fBool"));
+
+ Assert.AreEqual(2, po3.GetField<byte>("fByte"));
+ Assert.AreEqual(true, po2.GetField<bool>("fBool"));
+
+ builder = _grid.GetPortables().GetBuilder(po1);
+
+ builder.SetField<byte>("fByte", 10);
+
+ po1 = builder.Build();
+ po2 = builder.Build();
+
+ builder.SetField<byte>("fByte", 20);
+
+ po3 = builder.Build();
+
+ Assert.AreEqual(10, po1.GetField<byte>("fByte"));
+ Assert.AreEqual(true, po1.GetField<bool>("fBool"));
+
+ Assert.AreEqual(10, po2.GetField<byte>("fByte"));
+ Assert.AreEqual(true, po2.GetField<bool>("fBool"));
+
+ Assert.AreEqual(20, po3.GetField<byte>("fByte"));
+ Assert.AreEqual(true, po3.GetField<bool>("fBool"));
+ }
+
+ /// <summary>
+ /// Tests type id method.
+ /// </summary>
+ [Test]
+ public void TestTypeId()
+ {
+ Assert.Throws<ArgumentException>(() => _grid.GetPortables().GetTypeId(null));
+
+ Assert.AreEqual(IdMapper.TestTypeId, _grid.GetPortables().GetTypeId(IdMapper.TestTypeName));
+
+ Assert.AreEqual(PortableUtils.StringHashCode("someTypeName"), _grid.GetPortables().GetTypeId("someTypeName"));
+ }
+
+ /// <summary>
+ /// Tests metadata methods.
+ /// </summary>
+ [Test]
+ public void TestMetadata()
+ {
+ // Populate metadata
+ var portables = _grid.GetPortables();
+
+ portables.ToPortable<IPortableObject>(new DecimalHolder());
+
+ // All meta
+ var allMetas = portables.GetMetadata();
+
+ var decimalMeta = allMetas.Single(x => x.TypeName == "DecimalHolder");
+
+ Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
+
+ // By type
+ decimalMeta = portables.GetMetadata(typeof (DecimalHolder));
+
+ Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
+
+ // By type id
+ decimalMeta = portables.GetMetadata(portables.GetTypeId("DecimalHolder"));
+
+ Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
+
+ // By type name
+ decimalMeta = portables.GetMetadata("DecimalHolder");
+
+ Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
+ }
+
+ /// <summary>
+ /// Create portable type configuration with disabled metadata.
+ /// </summary>
+ /// <param name="typ">Type.</param>
+ /// <returns>Configuration.</returns>
+ private static PortableTypeConfiguration TypeConfigurationNoMeta(Type typ)
+ {
+ return new PortableTypeConfiguration(typ) {MetadataEnabled = false};
+ }
+ }
+
+ /// <summary>
+ /// Empty portable class.
+ /// </summary>
+ public class Empty
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Empty portable class with no metadata.
+ /// </summary>
+ public class EmptyNoMeta
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Portable with primitive fields.
+ /// </summary>
+ public class Primitives
+ {
+ public byte FByte;
+ public bool FBool;
+ public short FShort;
+ public char FChar;
+ public int FInt;
+ public long FLong;
+ public float FFloat;
+ public double FDouble;
+ }
+
+ /// <summary>
+ /// Portable with primitive array fields.
+ /// </summary>
+ public class PrimitiveArrays
+ {
+ public byte[] FByte;
+ public bool[] FBool;
+ public short[] FShort;
+ public char[] FChar;
+ public int[] FInt;
+ public long[] FLong;
+ public float[] FFloat;
+ public double[] FDouble;
+ }
+
+ /// <summary>
+ /// Portable having strings, dates, Guids and enums.
+ /// </summary>
+ public class StringDateGuidEnum
+ {
+ public string FStr;
+ public DateTime FDate;
+ public DateTime? FnDate;
+ public Guid FGuid;
+ public Guid? FnGuid;
+ public TestEnum FEnum;
+
+ public string[] FStrArr;
+ public DateTime?[] FDateArr;
+ public Guid?[] FGuidArr;
+ public TestEnum[] FEnumArr;
+ }
+
+ /// <summary>
+ /// Enumeration.
+ /// </summary>
+ public enum TestEnum
+ {
+ One, Two
+ }
+
+ /// <summary>
+ /// Portable with raw data.
+ /// </summary>
+ public class WithRaw : IPortableMarshalAware
+ {
+ public int A;
+ public int B;
+
+ /** <inheritDoc /> */
+ public void WritePortable(IPortableWriter writer)
+ {
+ writer.WriteInt("a", A);
+ writer.RawWriter().WriteInt(B);
+ }
+
+ /** <inheritDoc /> */
+ public void ReadPortable(IPortableReader reader)
+ {
+ A = reader.ReadInt("a");
+ B = reader.RawReader().ReadInt();
+ }
+ }
+
+ /// <summary>
+ /// Empty class for metadata overwrite test.
+ /// </summary>
+ public class MetaOverwrite
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Nested outer object.
+ /// </summary>
+ public class NestedOuter
+ {
+ public NestedInner Inner1;
+ public NestedInner Inner2;
+ }
+
+ /// <summary>
+ /// Nested inner object.
+ /// </summary>
+ public class NestedInner
+ {
+ public int Val;
+ }
+
+ /// <summary>
+ /// Outer object for handle migration test.
+ /// </summary>
+ public class MigrationOuter
+ {
+ public MigrationInner Inner1;
+ public MigrationInner Inner2;
+ }
+
+ /// <summary>
+ /// Inner object for handle migration test.
+ /// </summary>
+ public class MigrationInner
+ {
+ public int Val;
+ }
+
+ /// <summary>
+ /// Outer object for handle inversion test.
+ /// </summary>
+ public class InversionOuter
+ {
+ public InversionInner Inner;
+ }
+
+ /// <summary>
+ /// Inner object for handle inversion test.
+ /// </summary>
+ public class InversionInner
+ {
+ public InversionOuter Outer;
+ }
+
+ /// <summary>
+ /// Object for composite array tests.
+ /// </summary>
+ public class CompositeArray
+ {
+ public CompositeInner[] InArr;
+ public CompositeOuter[] OutArr;
+ }
+
+ /// <summary>
+ /// Object for composite collection/dictionary tests.
+ /// </summary>
+ public class CompositeContainer
+ {
+ public ICollection Col;
+ public ICollection<CompositeInner> GCol;
+
+ public IDictionary Dict;
+ public IDictionary<int, CompositeInner> GDict;
+ }
+
+ /// <summary>
+ /// OUter object for composite structures test.
+ /// </summary>
+ public class CompositeOuter
+ {
+ public CompositeInner Inner;
+
+ public CompositeOuter()
+ {
+ // No-op.
+ }
+
+ public CompositeOuter(CompositeInner inner)
+ {
+ Inner = inner;
+ }
+ }
+
+ /// <summary>
+ /// Inner object for composite structures test.
+ /// </summary>
+ public class CompositeInner
+ {
+ public int Val;
+
+ public CompositeInner()
+ {
+ // No-op.
+ }
+
+ public CompositeInner(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ /// Type to test "ToPortable()" logic.
+ /// </summary>
+ public class ToPortable
+ {
+ public int Val;
+
+ public ToPortable(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ /// Type to test "ToPortable()" logic with metadata disabled.
+ /// </summary>
+ public class ToPortableNoMeta
+ {
+ public int Val;
+
+ public ToPortableNoMeta(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ /// Type to test removal.
+ /// </summary>
+ public class Remove
+ {
+ public object Val;
+ public RemoveInner Val2;
+ }
+
+ /// <summary>
+ /// Inner type to test removal.
+ /// </summary>
+ public class RemoveInner
+ {
+ /** */
+ public int Val;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="val"></param>
+ public RemoveInner(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public class BuilderInBuilderOuter
+ {
+ /** */
+ public BuilderInBuilderInner Inner;
+
+ /** */
+ public BuilderInBuilderInner Inner2;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public class BuilderInBuilderInner
+ {
+ /** */
+ public BuilderInBuilderOuter Outer;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public class BuilderCollection
+ {
+ /** */
+ public ICollection<BuilderCollectionItem> Col;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="col"></param>
+ public BuilderCollection(ICollection<BuilderCollectionItem> col)
+ {
+ Col = col;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public class BuilderCollectionItem
+ {
+ /** */
+ public int Val;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="val"></param>
+ public BuilderCollectionItem(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public class DecimalHolder
+ {
+ /** */
+ public decimal Val;
+
+ /** */
+ public decimal[] ValArr;
+ }
+
+ /// <summary>
+ /// Test id mapper.
+ /// </summary>
+ public class IdMapper : IPortableIdMapper
+ {
+ /** */
+ public const string TestTypeName = "IdMapperTestType";
+
+ /** */
+ public const int TestTypeId = -65537;
+
+ /** <inheritdoc /> */
+ public int GetTypeId(string typeName)
+ {
+ return typeName == TestTypeName ? TestTypeId : 0;
+ }
+
+ /** <inheritdoc /> */
+ public int GetFieldId(int typeId, string fieldName)
+ {
+ return 0;
+ }
+ }
+}
[06/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs
new file mode 100644
index 0000000..2267154
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+
+using System;
+
+namespace Apache.Ignite.ExamplesDll.Portable
+{
+ /// <summary>
+ /// Employee key. Used in query example to co-locate employees with their organizations.
+ /// </summary>
+ [Serializable]
+ public class EmployeeKey
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="id">ID.</param>
+ /// <param name="orgId">Organization ID.</param>
+ public EmployeeKey(int id, int orgId)
+ {
+ Id = id;
+ OrganizationId = orgId;
+ }
+
+ /// <summary>
+ /// ID.
+ /// </summary>
+ public int Id { get; private set; }
+
+ /// <summary>
+ /// Organization ID.
+ /// </summary>
+ public int OrganizationId { get; private set; }
+
+ /// <summary>
+ /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
+ /// </summary>
+ /// <returns>
+ /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
+ /// </returns>
+ /// <param name="obj">The object to compare with the current object. </param><filterpriority>2</filterpriority>
+ public override bool Equals(object obj)
+ {
+ EmployeeKey other = obj as EmployeeKey;
+
+ return other != null && Id == other.Id && OrganizationId == other.OrganizationId;
+ }
+
+ /// <summary>
+ /// Serves as a hash function for a particular type.
+ /// </summary>
+ /// <returns>
+ /// A hash code for the current <see cref="T:System.Object"/>.
+ /// </returns>
+ /// <filterpriority>2</filterpriority>
+ public override int GetHashCode()
+ {
+ return 31 * Id + OrganizationId;
+ }
+
+ /// <summary>
+ /// Returns a string that represents the current object.
+ /// </summary>
+ /// <returns>
+ /// A string that represents the current object.
+ /// </returns>
+ public override string ToString()
+ {
+ return string.Format("{0} [id={1}, organizationId={2}]", typeof (EmployeeKey).Name, Id, OrganizationId);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Organization.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Organization.cs b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Organization.cs
new file mode 100644
index 0000000..e23c3c1
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Organization.cs
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+
+using System;
+
+namespace Apache.Ignite.ExamplesDll.Portable
+{
+ /// <summary>
+ /// Organization.
+ /// </summary>
+ [Serializable]
+ public class Organization
+ {
+ /// <summary>
+ /// Default constructor.
+ /// </summary>
+ public Organization()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="name">Name.</param>
+ /// <param name="address">Address.</param>
+ /// <param name="type">Type.</param>
+ /// <param name="lastUpdated">Last update time.</param>
+ public Organization(string name, Address address, OrganizationType type, DateTime lastUpdated)
+ {
+ Name = name;
+ Address = address;
+ Type = type;
+ LastUpdated = lastUpdated;
+ }
+
+ /// <summary>
+ /// Name.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Address.
+ /// </summary>
+ public Address Address { get; set; }
+
+ /// <summary>
+ /// Type.
+ /// </summary>
+ public OrganizationType Type { get; set; }
+
+ /// <summary>
+ /// Last update time.
+ /// </summary>
+ public DateTime LastUpdated { get; set; }
+
+ /// <summary>
+ /// Returns a string that represents the current object.
+ /// </summary>
+ /// <returns>
+ /// A string that represents the current object.
+ /// </returns>
+ /// <filterpriority>2</filterpriority>
+ public override string ToString()
+ {
+ return string.Format("{0} [name={1}, address={2}, type={3}, lastUpdated={4}]", typeof (Organization).Name,
+ Name, Address, Type, LastUpdated);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs
new file mode 100644
index 0000000..198edb1
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+
+using System;
+
+namespace Apache.Ignite.ExamplesDll.Portable
+{
+ /// <summary>
+ /// Organization type.
+ /// </summary>
+ [Serializable]
+ public enum OrganizationType
+ {
+ /// <summary>
+ /// Non-profit organization.
+ /// </summary>
+ NonProfit,
+
+ /// <summary>
+ /// Private organization.
+ /// </summary>
+ Private,
+
+ /// <summary>
+ /// Government organization.
+ /// </summary>
+ Government
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..f149d64
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("Apache Ignite Examples Dll")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("Apache Ignite")]
+[assembly: AssemblyCopyright("Copyright © 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+[assembly: ComVisible(false)]
+
+[assembly: Guid("ce65ec7c-d3cf-41ad-8f45-f90d5af68d77")]
+
+[assembly: AssemblyVersion("1.5.0")]
+[assembly: AssemblyFileVersion("1.5.0")]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Services/MapService.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Services/MapService.cs b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Services/MapService.cs
new file mode 100644
index 0000000..d577ff7
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Services/MapService.cs
@@ -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.
+ */
+
+using System;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Cache;
+using Apache.Ignite.Core.Resource;
+using Apache.Ignite.Core.Services;
+
+namespace Apache.Ignite.ExamplesDll.Services
+{
+ /// <summary>
+ /// Service implementation.
+ /// </summary>
+ [Serializable]
+ public class MapService<TK, TV> : IService
+ {
+ /** Injected Ignite instance. */
+#pragma warning disable 649
+ [InstanceResource] private readonly IIgnite _ignite;
+#pragma warning restore 649
+
+ /** Cache. */
+ private ICache<TK, TV> _cache;
+
+ /// <summary>
+ /// Initializes this instance before execution.
+ /// </summary>
+ /// <param name="context">Service execution context.</param>
+ public void Init(IServiceContext context)
+ {
+ // Create a new cache for every service deployment.
+ // Note that we use service name as cache name, which allows
+ // for each service deployment to use its own isolated cache.
+ _cache = _ignite.GetOrCreateCache<TK, TV>("MapService_" + context.Name);
+
+ Console.WriteLine("Service initialized: " + context.Name);
+ }
+
+ /// <summary>
+ /// Starts execution of this service. This method is automatically invoked whenever an instance of the service
+ /// is deployed on an Ignite node. Note that service is considered deployed even after it exits the Execute
+ /// method and can be cancelled (or undeployed) only by calling any of the Cancel methods on
+ /// <see cref="IServices"/> API. Also note that service is not required to exit from Execute method until
+ /// Cancel method was called.
+ /// </summary>
+ /// <param name="context">Service execution context.</param>
+ public void Execute(IServiceContext context)
+ {
+ Console.WriteLine("Service started: " + context.Name);
+ }
+
+ /// <summary>
+ /// Cancels this instance.
+ /// <para/>
+ /// Note that Ignite cannot guarantee that the service exits from <see cref="IService.Execute"/>
+ /// method whenever <see cref="IService.Cancel"/> is called. It is up to the user to
+ /// make sure that the service code properly reacts to cancellations.
+ /// </summary>
+ /// <param name="context">Service execution context.</param>
+ public void Cancel(IServiceContext context)
+ {
+ Console.WriteLine("Service cancelled: " + context.Name);
+ }
+
+ /// <summary>
+ /// Puts an entry to the map.
+ /// </summary>
+ /// <param name="key">The key.</param>
+ /// <param name="value">The value.</param>
+ public void Put(TK key, TV value)
+ {
+ _cache.Put(key, value);
+ }
+
+ /// <summary>
+ /// Gets an entry from the map.
+ /// </summary>
+ /// <param name="key">The key.</param>
+ /// <returns>Entry value.</returns>
+ public TV Get(TK key)
+ {
+ return _cache.Get(key);
+ }
+
+ /// <summary>
+ /// Clears the map.
+ /// </summary>
+ public void Clear()
+ {
+ _cache.Clear();
+ }
+
+ /// <summary>
+ /// Gets the size of the map.
+ /// </summary>
+ /// <value>
+ /// The size.
+ /// </value>
+ public int Size
+ {
+ get { return _cache.GetSize(); }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Config/example-cache-query.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Config/example-cache-query.xml b/modules/platform/dotnet/examples/Config/example-cache-query.xml
new file mode 100644
index 0000000..c9ea7e1
--- /dev/null
+++ b/modules/platform/dotnet/examples/Config/example-cache-query.xml
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+
+ <property name="platformConfiguration">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
+ <property name="portableConfiguration">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
+ <property name="types">
+ <list>
+ <value>Apache.Ignite.Examples.Dll.Portable.Account</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.Address</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.Employee</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.EmployeeKey</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.Organization</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.OrganizationType</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+
+ <!-- Cache configurations (all properties are optional). -->
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="atomicityMode" value="ATOMIC"/>
+ <property name="backups" value="1"/>
+
+ <!-- Configure type metadata to enable queries. -->
+ <property name="typeMetadata">
+ <list>
+ <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+ <property name="keyType" value="java.lang.Integer"/>
+ <property name="valueType" value="Organization"/>
+ <property name="ascendingFields">
+ <map>
+ <entry key="name" value="java.lang.String"/>
+ </map>
+ </property>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+ <property name="keyType" value="EmployeeKey"/>
+ <property name="valueType" value="Employee"/>
+ <property name="ascendingFields">
+ <map>
+ <entry key="organizationId" value="java.lang.Integer"/>
+ <entry key="address.zip" value="java.lang.Integer"/>
+ </map>
+ </property>
+ <property name="queryFields">
+ <map>
+ <entry key="name" value="java.lang.String"/>
+ <entry key="salary" value="java.lang.Long"/>
+ </map>
+ </property>
+ <property name="textFields">
+ <list>
+ <value>address.street</value>
+ </list>
+ </property>
+ </bean>
+ </list>
+ </property>
+ </bean>
+ </list>
+ </property>
+
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47501</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Config/example-cache-store.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Config/example-cache-store.xml b/modules/platform/dotnet/examples/Config/example-cache-store.xml
new file mode 100644
index 0000000..adc5f45
--- /dev/null
+++ b/modules/platform/dotnet/examples/Config/example-cache-store.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="writeThrough" value="true"/>
+ <property name="readThrough" value="true"/>
+ <property name="cacheStoreFactory">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
+ <property name="assemblyName" value="Apache.Ignite.ExamplesDll"/>
+ <property name="className" value="Apache.Ignite.ExamplesDll.Datagrid.EmployeeStore"/>
+ </bean>
+ </property>
+ </bean>
+ </list>
+ </property>
+
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47501</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Config/example-cache.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Config/example-cache.xml b/modules/platform/dotnet/examples/Config/example-cache.xml
new file mode 100644
index 0000000..a262ce1
--- /dev/null
+++ b/modules/platform/dotnet/examples/Config/example-cache.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <!-- Set to true to enable distributed class loading for examples, default is false. -->
+ <property name="peerClassLoadingEnabled" value="true"/>
+
+ <property name="platformConfiguration">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
+ <property name="portableConfiguration">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
+ <property name="types">
+ <list>
+ <value>Apache.Ignite.Examples.Dll.Portable.Account</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.Address</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.Employee</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.EmployeeKey</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.Organization</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.OrganizationType</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="cache*"/>
+ <property name="atomicityMode" value="ATOMIC"/>
+ <property name="backups" value="1"/>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="tx"/>
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="backups" value="1"/>
+ </bean>
+ </list>
+ </property>
+
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47501</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Config/example-compute.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Config/example-compute.xml b/modules/platform/dotnet/examples/Config/example-compute.xml
new file mode 100644
index 0000000..bbc6550
--- /dev/null
+++ b/modules/platform/dotnet/examples/Config/example-compute.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47501</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+
+ <!-- Enable task execution events for examples. -->
+ <property name="includeEventTypes">
+ <list>
+ <!-- Task execution events -->
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED"/>
+
+ <!-- Job execution events -->
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_MAPPED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_RESULTED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_FAILED_OVER"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_STARTED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_FINISHED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_TIMEDOUT"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_REJECTED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_FAILED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_QUEUED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_CANCELLED"/>
+ </list>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/README.txt
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/README.txt b/modules/platform/dotnet/examples/README.txt
new file mode 100644
index 0000000..c49dc5a
--- /dev/null
+++ b/modules/platform/dotnet/examples/README.txt
@@ -0,0 +1,14 @@
+Apache Ignite .Net Examples
+==================================
+
+Common requirements
+----------------------------------
+ * Apache Ignite .Net library must be built using instructions from %IGNITE_HOME%\platforms\dotnet\README.txt.
+
+
+Running examples
+----------------------------------
+
+ * Open Visual Studio solution %IGNITE_HOME%\platforms\dotnet\examples\Apache.Ignite.Examples.sln
+ * Build Apache.Ignite.ExamplesDll project.
+ * Set desired example as startup object in Apache.Ignite.Examples project and run it.
\ No newline at end of file
[15/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/MessagingTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/MessagingTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/MessagingTest.cs
deleted file mode 100644
index 95e48d3..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/MessagingTest.cs
+++ /dev/null
@@ -1,646 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests
-{
- using System;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
- using System.Linq;
- using System.Threading;
- using System.Threading.Tasks;
- using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Messaging;
- using Apache.Ignite.Core.Resource;
- using NUnit.Framework;
-
- /// <summary>
- /// <see cref="IMessaging"/> tests.
- /// </summary>
- public class MessagingTest
- {
- /** */
- private IIgnite _grid1;
-
- /** */
- private IIgnite _grid2;
-
- /** */
- private IIgnite _grid3;
-
- /** */
- public static int MessageId;
-
- /// <summary>
- /// Executes before each test.
- /// </summary>
- [SetUp]
- public void SetUp()
- {
- _grid1 = Ignition.Start(Configuration("config\\compute\\compute-grid1.xml"));
- _grid2 = Ignition.Start(Configuration("config\\compute\\compute-grid2.xml"));
- _grid3 = Ignition.Start(Configuration("config\\compute\\compute-grid3.xml"));
- }
-
- /// <summary>
- /// Executes after each test.
- /// </summary>
- [TearDown]
- public virtual void TearDown()
- {
- try
- {
- TestUtils.AssertHandleRegistryIsEmpty(1000, _grid1, _grid2, _grid3);
-
- MessagingTestHelper.AssertFailures();
- }
- finally
- {
- // Stop all grids between tests to drop any hanging messages
- Ignition.StopAll(true);
- }
- }
-
- /// <summary>
- /// Tests LocalListen.
- /// </summary>
- [Test]
- public void TestLocalListen()
- {
- TestLocalListen(null);
- TestLocalListen("string topic");
- TestLocalListen(NextId());
- }
-
- /// <summary>
- /// Tests LocalListen.
- /// </summary>
- [SuppressMessage("ReSharper", "AccessToModifiedClosure")]
- public void TestLocalListen(object topic)
- {
- var messaging = _grid1.GetMessaging();
- var listener = MessagingTestHelper.GetListener();
- messaging.LocalListen(listener, topic);
-
- // Test sending
- CheckSend(topic);
- CheckSend(topic, _grid2);
- CheckSend(topic, _grid3);
-
- // Test different topic
- CheckNoMessage(NextId());
- CheckNoMessage(NextId(), _grid2);
-
- // Test multiple subscriptions for the same filter
- messaging.LocalListen(listener, topic);
- messaging.LocalListen(listener, topic);
- CheckSend(topic, repeatMultiplier: 3); // expect all messages repeated 3 times
-
- messaging.StopLocalListen(listener, topic);
- CheckSend(topic, repeatMultiplier: 2); // expect all messages repeated 2 times
-
- messaging.StopLocalListen(listener, topic);
- CheckSend(topic); // back to 1 listener
-
- // Test message type mismatch
- var ex = Assert.Throws<IgniteException>(() => messaging.Send(1.1, topic));
- Assert.AreEqual("Unable to cast object of type 'System.Double' to type 'System.String'.", ex.Message);
-
- // Test end listen
- MessagingTestHelper.ListenResult = false;
- CheckSend(topic, single: true); // we'll receive one more and then unsubscribe because of delegate result.
- CheckNoMessage(topic);
-
- // Start again
- MessagingTestHelper.ListenResult = true;
- messaging.LocalListen(listener, topic);
- CheckSend(topic);
-
- // Stop
- messaging.StopLocalListen(listener, topic);
- CheckNoMessage(topic);
- }
-
- /// <summary>
- /// Tests LocalListen with projection.
- /// </summary>
- [Test]
- public void TestLocalListenProjection()
- {
- TestLocalListenProjection(null);
- TestLocalListenProjection("prj");
- TestLocalListenProjection(NextId());
- }
-
- /// <summary>
- /// Tests LocalListen with projection.
- /// </summary>
- private void TestLocalListenProjection(object topic)
- {
- var grid3GotMessage = false;
-
- var grid3Listener = new MessageFilter<string>((id, x) =>
- {
- grid3GotMessage = true;
- return true;
- });
-
- _grid3.GetMessaging().LocalListen(grid3Listener, topic);
-
- var clusterMessaging = _grid1.GetCluster().ForNodes(_grid1.GetCluster().GetLocalNode(), _grid2.GetCluster().GetLocalNode()).GetMessaging();
- var clusterListener = MessagingTestHelper.GetListener();
- clusterMessaging.LocalListen(clusterListener, topic);
-
- CheckSend(msg: clusterMessaging, topic: topic);
- Assert.IsFalse(grid3GotMessage, "Grid3 should not get messages");
-
- CheckSend(grid: _grid2, msg: clusterMessaging, topic: topic);
- Assert.IsFalse(grid3GotMessage, "Grid3 should not get messages");
-
- clusterMessaging.StopLocalListen(clusterListener, topic);
- _grid3.GetMessaging().StopLocalListen(grid3Listener, topic);
- }
-
- /// <summary>
- /// Tests LocalListen in multithreaded mode.
- /// </summary>
- [Test]
- [SuppressMessage("ReSharper", "AccessToModifiedClosure")]
- [Category(TestUtils.CategoryIntensive)]
- public void TestLocalListenMultithreaded()
- {
- const int threadCnt = 20;
- const int runSeconds = 20;
-
- var messaging = _grid1.GetMessaging();
-
- var senders = Task.Factory.StartNew(() => TestUtils.RunMultiThreaded(() =>
- {
- messaging.Send((object) NextMessage());
- Thread.Sleep(50);
- }, threadCnt, runSeconds));
-
-
- var sharedReceived = 0;
-
- var sharedListener = new MessageFilter<string>((id, x) =>
- {
- Interlocked.Increment(ref sharedReceived);
- Thread.MemoryBarrier();
- return true;
- });
-
- TestUtils.RunMultiThreaded(() =>
- {
- // Check that listen/stop work concurrently
- messaging.LocalListen(sharedListener);
-
- for (int i = 0; i < 100; i++)
- {
- messaging.LocalListen(sharedListener);
- messaging.StopLocalListen(sharedListener);
- }
-
- var localReceived = 0;
- var stopLocal = 0;
-
- var localListener = new MessageFilter<string>((id, x) =>
- {
- Interlocked.Increment(ref localReceived);
- Thread.MemoryBarrier();
- return Thread.VolatileRead(ref stopLocal) == 0;
- });
-
- messaging.LocalListen(localListener);
-
- Thread.Sleep(100);
-
- Thread.VolatileWrite(ref stopLocal, 1);
-
- Thread.Sleep(1000);
-
- var result = Thread.VolatileRead(ref localReceived);
-
- Thread.Sleep(100);
-
- // Check that unsubscription worked properly
- Assert.AreEqual(result, Thread.VolatileRead(ref localReceived));
-
- messaging.StopLocalListen(sharedListener);
-
- }, threadCnt, runSeconds);
-
- senders.Wait();
-
- Thread.Sleep(100);
-
- var sharedResult = Thread.VolatileRead(ref sharedReceived);
-
- messaging.Send((object)NextMessage());
-
- Thread.Sleep(MessagingTestHelper.MessageTimeout);
-
- // Check that unsubscription worked properly
- Assert.AreEqual(sharedResult, Thread.VolatileRead(ref sharedReceived));
- }
-
- /// <summary>
- /// Tests RemoteListen.
- /// </summary>
- [Test]
- public void TestRemoteListen()
- {
- TestRemoteListen(null);
- TestRemoteListen("string topic");
- TestRemoteListen(NextId());
- }
-
- /// <summary>
- /// Tests RemoteListen with async mode enabled.
- /// </summary>
- [Test]
- public void TestRemoteListenAsync()
- {
- TestRemoteListen(null, true);
- TestRemoteListen("string topic", true);
- TestRemoteListen(NextId(), true);
- }
-
- /// <summary>
- /// Tests RemoteListen.
- /// </summary>
- public void TestRemoteListen(object topic, bool async = false)
- {
- var messaging = async ? _grid1.GetMessaging().WithAsync() : _grid1.GetMessaging();
-
- var listener = MessagingTestHelper.GetListener();
- var listenId = messaging.RemoteListen(listener, topic);
-
- if (async)
- listenId = messaging.GetFuture<Guid>().Get();
-
- // Test sending
- CheckSend(topic, msg: messaging, remoteListen: true);
-
- // Test different topic
- CheckNoMessage(NextId());
-
- // Test multiple subscriptions for the same filter
- var listenId2 = messaging.RemoteListen(listener, topic);
-
- if (async)
- listenId2 = messaging.GetFuture<Guid>().Get();
-
- CheckSend(topic, msg: messaging, remoteListen: true, repeatMultiplier: 2); // expect twice the messages
-
- messaging.StopRemoteListen(listenId2);
-
- if (async)
- messaging.GetFuture().Get();
-
- CheckSend(topic, msg: messaging, remoteListen: true); // back to normal after unsubscription
-
- // Test message type mismatch
- var ex = Assert.Throws<IgniteException>(() => messaging.Send(1.1, topic));
- Assert.AreEqual("Unable to cast object of type 'System.Double' to type 'System.String'.", ex.Message);
-
- // Test end listen
- messaging.StopRemoteListen(listenId);
-
- if (async)
- messaging.GetFuture().Get();
-
- CheckNoMessage(topic);
- }
-
- /// <summary>
- /// Tests RemoteListen with a projection.
- /// </summary>
- [Test]
- public void TestRemoteListenProjection()
- {
- TestRemoteListenProjection(null);
- TestRemoteListenProjection("string topic");
- TestRemoteListenProjection(NextId());
- }
-
- /// <summary>
- /// Tests RemoteListen with a projection.
- /// </summary>
- private void TestRemoteListenProjection(object topic)
- {
- var clusterMessaging = _grid1.GetCluster().ForNodes(_grid1.GetCluster().GetLocalNode(), _grid2.GetCluster().GetLocalNode()).GetMessaging();
- var clusterListener = MessagingTestHelper.GetListener();
- var listenId = clusterMessaging.RemoteListen(clusterListener, topic);
-
- CheckSend(msg: clusterMessaging, topic: topic, remoteListen: true);
-
- clusterMessaging.StopRemoteListen(listenId);
-
- CheckNoMessage(topic);
- }
-
- /// <summary>
- /// Tests LocalListen in multithreaded mode.
- /// </summary>
- [Test]
- [Category(TestUtils.CategoryIntensive)]
- public void TestRemoteListenMultithreaded()
- {
- const int threadCnt = 20;
- const int runSeconds = 20;
-
- var messaging = _grid1.GetMessaging();
-
- var senders = Task.Factory.StartNew(() => TestUtils.RunMultiThreaded(() =>
- {
- MessagingTestHelper.ClearReceived(int.MaxValue);
- messaging.Send((object) NextMessage());
- Thread.Sleep(50);
- }, threadCnt, runSeconds));
-
-
- var sharedListener = MessagingTestHelper.GetListener();
-
- for (int i = 0; i < 100; i++)
- messaging.RemoteListen(sharedListener); // add some listeners to be stopped by filter result
-
- TestUtils.RunMultiThreaded(() =>
- {
- // Check that listen/stop work concurrently
- messaging.StopRemoteListen(messaging.RemoteListen(sharedListener));
-
- }, threadCnt, runSeconds);
-
- MessagingTestHelper.ListenResult = false;
-
- messaging.Send((object) NextMessage()); // send a message to make filters return false
-
- Thread.Sleep(MessagingTestHelper.MessageTimeout); // wait for all to unsubscribe
-
- MessagingTestHelper.ListenResult = true;
-
- senders.Wait(); // wait for senders to stop
-
- var sharedResult = MessagingTestHelper.ReceivedMessages.Count;
-
- messaging.Send((object) NextMessage());
-
- Thread.Sleep(MessagingTestHelper.MessageTimeout);
-
- // Check that unsubscription worked properly
- Assert.AreEqual(sharedResult, MessagingTestHelper.ReceivedMessages.Count);
-
- }
-
- /// <summary>
- /// Sends messages in various ways and verefies correct receival.
- /// </summary>
- /// <param name="topic">Topic.</param>
- /// <param name="grid">The grid to use.</param>
- /// <param name="msg">Messaging to use.</param>
- /// <param name="remoteListen">Whether to expect remote listeners.</param>
- /// <param name="single">When true, only check one message.</param>
- /// <param name="repeatMultiplier">Expected message count multiplier.</param>
- private void CheckSend(object topic = null, IIgnite grid = null,
- IMessaging msg = null, bool remoteListen = false, bool single = false, int repeatMultiplier = 1)
- {
- IClusterGroup cluster;
-
- if (msg != null)
- cluster = msg.ClusterGroup;
- else
- {
- grid = grid ?? _grid1;
- msg = grid.GetMessaging();
- cluster = grid.GetCluster().ForLocal();
- }
-
- // Messages will repeat due to multiple nodes listening
- var expectedRepeat = repeatMultiplier * (remoteListen ? cluster.GetNodes().Count : 1);
-
- var messages = Enumerable.Range(1, 10).Select(x => NextMessage()).OrderBy(x => x).ToList();
-
- // Single message
- MessagingTestHelper.ClearReceived(expectedRepeat);
- msg.Send((object) messages[0], topic);
- MessagingTestHelper.VerifyReceive(cluster, messages.Take(1), m => m.ToList(), expectedRepeat);
-
- if (single)
- return;
-
- // Multiple messages (receive order is undefined)
- MessagingTestHelper.ClearReceived(messages.Count * expectedRepeat);
- msg.Send(messages, topic);
- MessagingTestHelper.VerifyReceive(cluster, messages, m => m.OrderBy(x => x), expectedRepeat);
-
- // Multiple messages, ordered
- MessagingTestHelper.ClearReceived(messages.Count * expectedRepeat);
- messages.ForEach(x => msg.SendOrdered(x, topic, MessagingTestHelper.MessageTimeout));
-
- if (remoteListen) // in remote scenario messages get mixed up due to different timing on different nodes
- MessagingTestHelper.VerifyReceive(cluster, messages, m => m.OrderBy(x => x), expectedRepeat);
- else
- MessagingTestHelper.VerifyReceive(cluster, messages, m => m.Reverse(), expectedRepeat);
- }
-
- /// <summary>
- /// Checks that no message has arrived.
- /// </summary>
- private void CheckNoMessage(object topic, IIgnite grid = null)
- {
- // this will result in an exception in case of a message
- MessagingTestHelper.ClearReceived(0);
-
- (grid ?? _grid1).GetMessaging().Send(NextMessage(), topic);
-
- Thread.Sleep(MessagingTestHelper.MessageTimeout);
-
- MessagingTestHelper.AssertFailures();
- }
-
- /// <summary>
- /// Gets the Ignite configuration.
- /// </summary>
- private static IgniteConfiguration Configuration(string springConfigUrl)
- {
- return new IgniteConfiguration
- {
- SpringConfigUrl = springConfigUrl,
- JvmClasspath = TestUtils.CreateTestClasspath(),
- JvmOptions = TestUtils.TestJavaOptions()
- };
- }
-
- /// <summary>
- /// Generates next message with sequential ID and current test name.
- /// </summary>
- private static string NextMessage()
- {
- var id = NextId();
- return id + "_" + TestContext.CurrentContext.Test.Name;
- }
-
- /// <summary>
- /// Generates next sequential ID.
- /// </summary>
- private static int NextId()
- {
- return Interlocked.Increment(ref MessageId);
- }
- }
-
- /// <summary>
- /// Messaging test helper class.
- /// </summary>
- [Serializable]
- public static class MessagingTestHelper
- {
- /** */
- public static readonly ConcurrentStack<string> ReceivedMessages = new ConcurrentStack<string>();
-
- /** */
- public static readonly ConcurrentStack<string> Failures = new ConcurrentStack<string>();
-
- /** */
- public static readonly CountdownEvent ReceivedEvent = new CountdownEvent(0);
-
- /** */
- public static readonly ConcurrentStack<Guid> LastNodeIds = new ConcurrentStack<Guid>();
-
- /** */
- public static volatile bool ListenResult = true;
-
- /** */
- public static readonly TimeSpan MessageTimeout = TimeSpan.FromMilliseconds(700);
-
- /// <summary>
- /// Clears received message information.
- /// </summary>
- /// <param name="expectedCount">The expected count of messages to be received.</param>
- public static void ClearReceived(int expectedCount)
- {
- ReceivedMessages.Clear();
- ReceivedEvent.Reset(expectedCount);
- LastNodeIds.Clear();
- }
-
- /// <summary>
- /// Verifies received messages against expected messages.
- /// </summary>
- /// <param name="cluster">Cluster.</param>
- /// <param name="expectedMessages">Expected messages.</param>
- /// <param name="resultFunc">Result transform function.</param>
- /// <param name="expectedRepeat">Expected repeat count.</param>
- public static void VerifyReceive(IClusterGroup cluster, IEnumerable<string> expectedMessages,
- Func<IEnumerable<string>, IEnumerable<string>> resultFunc, int expectedRepeat)
- {
- // check if expected message count has been received; Wait returns false if there were none.
- Assert.IsTrue(ReceivedEvent.Wait(MessageTimeout));
-
- expectedMessages = expectedMessages.SelectMany(x => Enumerable.Repeat(x, expectedRepeat));
-
- Assert.AreEqual(expectedMessages, resultFunc(ReceivedMessages));
-
- // check that all messages came from local node.
- var localNodeId = cluster.Ignite.GetCluster().GetLocalNode().Id;
- Assert.AreEqual(localNodeId, LastNodeIds.Distinct().Single());
-
- AssertFailures();
- }
-
- /// <summary>
- /// Gets the message listener.
- /// </summary>
- /// <returns>New instance of message listener.</returns>
- public static IMessageFilter<string> GetListener()
- {
- return new MessageFilter<string>(Listen);
- }
-
- /// <summary>
- /// Combines accumulated failures and throws an assertion, if there are any.
- /// Clears accumulated failures.
- /// </summary>
- public static void AssertFailures()
- {
- if (Failures.Any())
- Assert.Fail(Failures.Reverse().Aggregate((x, y) => string.Format("{0}\n{1}", x, y)));
-
- Failures.Clear();
- }
-
- /// <summary>
- /// Listen method.
- /// </summary>
- /// <param name="id">Originating node ID.</param>
- /// <param name="msg">Message.</param>
- private static bool Listen(Guid id, string msg)
- {
- try
- {
- LastNodeIds.Push(id);
- ReceivedMessages.Push(msg);
-
- ReceivedEvent.Signal();
-
- return ListenResult;
- }
- catch (Exception ex)
- {
- // When executed on remote nodes, these exceptions will not go to sender,
- // so we have to accumulate them.
- Failures.Push(string.Format("Exception in Listen (msg: {0}, id: {1}): {2}", msg, id, ex));
- throw;
- }
- }
- }
-
- /// <summary>
- /// Test message filter.
- /// </summary>
- [Serializable]
- public class MessageFilter<T> : IMessageFilter<T>
- {
- /** */
- private readonly Func<Guid, T, bool> _invoke;
-
- #pragma warning disable 649
- /** Grid. */
- [InstanceResource]
- private IIgnite _grid;
- #pragma warning restore 649
-
- /// <summary>
- /// Initializes a new instance of the <see cref="MessageFilter{T}"/> class.
- /// </summary>
- /// <param name="invoke">The invoke delegate.</param>
- public MessageFilter(Func<Guid, T, bool> invoke)
- {
- _invoke = invoke;
- }
-
- /** <inheritdoc /> */
- public bool Invoke(Guid nodeId, T message)
- {
- Assert.IsNotNull(_grid);
- return _invoke(nodeId, message);
- }
- }
-}
[23/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
deleted file mode 100644
index ae00c91..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
+++ /dev/null
@@ -1,3252 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache
-{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
- using System.Linq;
- using System.Runtime.Serialization;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using Apache.Ignite.Core.Cache;
- using Apache.Ignite.Core.Cache.Expiry;
- using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Impl;
- using Apache.Ignite.Core.Impl.Cache;
- using Apache.Ignite.Core.Portable;
- using Apache.Ignite.Core.Tests.Query;
- using Apache.Ignite.Core.Transactions;
- using NUnit.Framework;
-
- /// <summary>
- ///
- /// </summary>
- class CacheTestKey
- {
- /// <summary>
- /// Default constructor.
- /// </summary>
- public CacheTestKey()
- {
- // No-op.
- }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="id">ID.</param>
- public CacheTestKey(int id)
- {
- Id = id;
- }
-
- /// <summary>
- /// ID.
- /// </summary>
- public int Id
- {
- get;
- set;
- }
-
- /** <inheritdoc /> */
- public override bool Equals(object obj)
- {
- CacheTestKey other = obj as CacheTestKey;
-
- return other != null && Id == other.Id;
- }
-
- /** <inheritdoc /> */
- public override int GetHashCode()
- {
- return Id;
- }
-
- /** <inheritdoc /> */
- public override string ToString()
- {
- return new StringBuilder()
- .Append(typeof(CacheTestKey).Name)
- .Append(" [id=").Append(Id)
- .Append(']').ToString();
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- class TestReferenceObject
- {
- public TestReferenceObject Obj;
-
- /// <summary>
- /// Default constructor.
- /// </summary>
- public TestReferenceObject()
- {
- // No-op.
- }
-
- public TestReferenceObject(TestReferenceObject obj)
- {
- Obj = obj;
- }
- }
-
- [Serializable]
- public class TestSerializableObject
- {
- public string Name { get; set; }
- public int Id { get; set; }
-
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj)) return false;
- if (ReferenceEquals(this, obj)) return true;
-
- var other = (TestSerializableObject) obj;
- return obj.GetType() == GetType() && (string.Equals(Name, other.Name) && Id == other.Id);
- }
-
- public override int GetHashCode()
- {
- unchecked
- {
- return ((Name != null ? Name.GetHashCode() : 0) * 397) ^ Id;
- }
- }
- }
-
- /// <summary>
- /// Cache entry processor that adds argument value to the entry value.
- /// </summary>
- [Serializable]
- public class AddArgCacheEntryProcessor : ICacheEntryProcessor<int, int, int, int>
- {
- // Expected exception text
- public const string ExceptionText = "Exception from AddArgCacheEntryProcessor.";
-
- // Error flag
- public bool ThrowErr { get; set; }
-
- // Error flag
- public bool ThrowErrPortable { get; set; }
-
- // Error flag
- public bool ThrowErrNonSerializable { get; set; }
-
- // Key value to throw error on
- public int ThrowOnKey { get; set; }
-
- // Remove flag
- public bool Remove { get; set; }
-
- // Exists flag
- public bool Exists { get; set; }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="AddArgCacheEntryProcessor"/> class.
- /// </summary>
- public AddArgCacheEntryProcessor()
- {
- Exists = true;
- ThrowOnKey = -1;
- }
-
- /** <inheritdoc /> */
- int ICacheEntryProcessor<int, int, int, int>.Process(IMutableCacheEntry<int, int> entry, int arg)
- {
- if (ThrowOnKey < 0 || ThrowOnKey == entry.Key)
- {
- if (ThrowErr)
- throw new Exception(ExceptionText);
-
- if (ThrowErrPortable)
- throw new PortableTestException {Info = ExceptionText};
-
- if (ThrowErrNonSerializable)
- throw new NonSerializableException();
- }
-
- Assert.AreEqual(Exists, entry.Exists);
-
- if (Remove)
- entry.Remove();
- else
- entry.Value = entry.Value + arg;
-
- return entry.Value;
- }
-
- /** <inheritdoc /> */
- public int Process(IMutableCacheEntry<int, int> entry, int arg)
- {
- throw new Exception("Invalid method");
- }
- }
-
- /// <summary>
- /// Portable add processor.
- /// </summary>
- public class PortableAddArgCacheEntryProcessor : AddArgCacheEntryProcessor, IPortableMarshalAware
- {
- /** <inheritdoc /> */
- public void WritePortable(IPortableWriter writer)
- {
- var w = writer.RawWriter();
-
- w.WriteBoolean(ThrowErr);
- w.WriteBoolean(ThrowErrPortable);
- w.WriteBoolean(ThrowErrNonSerializable);
- w.WriteInt(ThrowOnKey);
- w.WriteBoolean(Remove);
- w.WriteBoolean(Exists);
- }
-
- /** <inheritdoc /> */
- public void ReadPortable(IPortableReader reader)
- {
- var r = reader.RawReader();
-
- ThrowErr = r.ReadBoolean();
- ThrowErrPortable = r.ReadBoolean();
- ThrowErrNonSerializable = r.ReadBoolean();
- ThrowOnKey = r.ReadInt();
- Remove = r.ReadBoolean();
- Exists = r.ReadBoolean();
- }
- }
-
- /// <summary>
- /// Non-serializable processor.
- /// </summary>
- public class NonSerializableCacheEntryProcessor : AddArgCacheEntryProcessor
- {
- // No-op.
- }
-
- /// <summary>
- /// Portable exception.
- /// </summary>
- public class PortableTestException : Exception, IPortableMarshalAware
- {
- /// <summary>
- /// Gets or sets exception info.
- /// </summary>
- public string Info { get; set; }
-
- /** <inheritdoc /> */
- public override string Message
- {
- get { return Info; }
- }
-
- /** <inheritdoc /> */
- public void WritePortable(IPortableWriter writer)
- {
- writer.RawWriter().WriteString(Info);
- }
-
- /** <inheritdoc /> */
- public void ReadPortable(IPortableReader reader)
- {
- Info = reader.RawReader().ReadString();
- }
- }
-
- /// <summary>
- /// Non-serializable exception.
- /// </summary>
- public class NonSerializableException : Exception
- {
- // No-op
- }
-
- /// <summary>
- ///
- /// </summary>
- [SuppressMessage("ReSharper", "UnusedVariable")]
- public abstract class CacheAbstractTest {
- /// <summary>
- ///
- /// </summary>
- [TestFixtureSetUp]
- public virtual void StartGrids() {
- TestUtils.KillProcesses();
-
- IgniteConfigurationEx cfg = new IgniteConfigurationEx();
-
- PortableConfiguration portCfg = new PortableConfiguration();
-
- ICollection<PortableTypeConfiguration> portTypeCfgs = new List<PortableTypeConfiguration>();
-
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortablePerson)));
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(CacheTestKey)));
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(TestReferenceObject)));
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableAddArgCacheEntryProcessor)));
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableTestException)));
-
- portCfg.TypeConfigurations = portTypeCfgs;
-
- cfg.PortableConfiguration = portCfg;
- cfg.JvmClasspath = TestUtils.CreateTestClasspath();
- cfg.JvmOptions = TestUtils.TestJavaOptions();
- cfg.SpringConfigUrl = "config\\native-client-test-cache.xml";
-
- for (int i = 0; i < GridCount(); i++) {
- cfg.GridName = "grid-" + i;
-
- Ignition.Start(cfg);
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- [TestFixtureTearDown]
- public virtual void StopGrids() {
- for (int i = 0; i < GridCount(); i++)
- Ignition.Stop("grid-" + i, true);
- }
-
- /// <summary>
- ///
- /// </summary>
- [SetUp]
- public virtual void BeforeTest()
- {
- Console.WriteLine("Test started: " + TestContext.CurrentContext.Test.Name);
- }
-
- /// <summary>
- ///
- /// </summary>
- [TearDown]
- public virtual void AfterTest() {
- for (int i = 0; i < GridCount(); i++)
- Cache(i).RemoveAll();
-
- for (int i = 0; i < GridCount(); i++)
- {
- var cache = Cache(i);
-
- if (!cache.IsEmpty())
- {
- var entries = Enumerable.Range(0, 2000)
- .Select(x => new KeyValuePair<int, int>(x, cache.LocalPeek(x)))
- .Where(x => x.Value != 0)
- .Select(pair => pair.ToString() + GetKeyAffinity(cache, pair.Key))
- .Aggregate((acc, val) => string.Format("{0}, {1}", acc, val));
-
- Assert.Fail("Cache '{0}' is not empty in grid [{1}]: ({2})", CacheName(), i, entries);
- }
- }
-
- Console.WriteLine("Test finished: " + TestContext.CurrentContext.Test.Name);
- }
-
- public IIgnite GetIgnite(int idx)
- {
- return Ignition.GetIgnite("grid-" + idx);
- }
-
- public ICache<int, int> Cache(int idx) {
- return Cache<int, int>(idx);
- }
-
- public ICache<TK, TV> Cache<TK, TV>(int idx) {
- return GetIgnite(idx).GetCache<TK, TV>(CacheName());
- }
-
- public ICache<int, int> Cache()
- {
- return Cache<int, int>(0);
- }
-
- public ICache<TK, TV> Cache<TK, TV>()
- {
- return Cache<TK, TV>(0);
- }
-
- public ICacheAffinity Affinity()
- {
- return GetIgnite(0).GetAffinity(CacheName());
- }
-
- public ITransactions Transactions
- {
- get { return GetIgnite(0).GetTransactions(); }
- }
-
- [Test]
- public void TestCircularReference()
- {
- var cache = Cache().WithKeepPortable<int, object>();
-
- TestReferenceObject obj1 = new TestReferenceObject();
-
- obj1.Obj = new TestReferenceObject(obj1);
-
- cache.Put(1, obj1);
-
- var po = (IPortableObject) cache.Get(1);
-
- Assert.IsNotNull(po);
-
- TestReferenceObject objRef = po.Deserialize<TestReferenceObject>();
-
- Assert.IsNotNull(objRef);
- }
-
- [Test]
- public void TestName()
- {
- for (int i = 0; i < GridCount(); i++ )
- Assert.AreEqual(CacheName(), Cache(i).Name);
- }
-
- [Test]
- public void TestIsEmpty()
- {
- for (int i = 0; i < GridCount(); i++)
- {
- var cache = Cache(i);
-
- Assert.IsTrue(cache.IsEmpty());
- }
-
- for (int i = 0; i < GridCount(); i++)
- {
- var cache = Cache(i);
-
- cache.Put(PrimaryKeyForCache(cache), 1);
- }
-
- for (int i = 0; i < GridCount(); i++)
- {
- var cache = Cache(i);
-
- Assert.IsFalse(cache.IsEmpty());
- }
- }
-
- [Test]
- public void TestContainsKey()
- {
- var cache = Cache();
-
- int key = PrimaryKeyForCache(cache);
-
- cache.Put(key, 1);
-
- Assert.IsTrue(cache.ContainsKey(key));
- Assert.IsFalse(cache.ContainsKey(-1));
- }
-
- [Test]
- public void TestContainsKeys()
- {
- var cache = Cache();
-
- var keys = PrimaryKeysForCache(cache, 5);
-
- Assert.IsFalse(cache.ContainsKeys(keys));
-
- cache.PutAll(keys.ToDictionary(k => k, k => k));
-
- Assert.IsTrue(cache.ContainsKeys(keys));
-
- Assert.IsFalse(cache.ContainsKeys(keys.Concat(new[] {int.MaxValue})));
- }
-
- [Test]
- public void TestPeek()
- {
- var cache = Cache();
-
- int key1 = PrimaryKeyForCache(cache);
-
- cache.Put(key1, 1);
-
- Assert.AreEqual(1, cache.LocalPeek(key1));
- Assert.AreEqual(0, cache.LocalPeek(-1));
-
- Assert.AreEqual(1, cache.LocalPeek(key1, CachePeekMode.All));
- Assert.AreEqual(0, cache.LocalPeek(-1, CachePeekMode.All));
- }
-
- [Test]
- public void TestGet()
- {
- var cache = Cache();
-
- cache.Put(1, 1);
- cache.Put(2, 2);
-
- Assert.AreEqual(1, cache.Get(1));
- Assert.AreEqual(2, cache.Get(2));
- Assert.AreEqual(0, cache.Get(3));
- }
-
- [Test]
- public void TestGetAsync()
- {
- var cache = Cache().WithAsync().WrapAsync();
-
- cache.Put(1, 1);
- cache.Put(2, 2);
-
- Assert.AreEqual(1, cache.Get(1));
- Assert.AreEqual(2, cache.Get(2));
- Assert.AreEqual(0, cache.Get(3));
- }
-
- [Test]
- public void TestGetAll()
- {
- var cache = Cache();
-
- cache.Put(1, 1);
- cache.Put(2, 2);
- cache.Put(3, 3);
- cache.Put(4, 4);
- cache.Put(5, 5);
-
- IDictionary<int, int> map = cache.GetAll(new List<int> { 0, 1, 2, 5 });
-
- Assert.AreEqual(3, map.Count);
-
- Assert.AreEqual(1, map[1]);
- Assert.AreEqual(2, map[2]);
- }
-
- [Test]
- public void TestGetAllAsync()
- {
- var cache = Cache().WithAsync().WrapAsync();
-
- cache.Put(1, 1);
- cache.Put(2, 2);
- cache.Put(3, 3);
-
- var map = cache.GetAll(new List<int> { 0, 1, 2 });
-
- Assert.AreEqual(2, map.Count);
-
- Assert.AreEqual(1, map[1]);
- Assert.AreEqual(2, map[2]);
- }
-
- [Test]
- public void TestGetAndPut()
- {
- var cache = Cache();
-
- Assert.AreEqual(0, cache.Get(1));
-
- int old = cache.GetAndPut(1, 1);
-
- Assert.AreEqual(0, old);
-
- Assert.AreEqual(1, cache.Get(1));
-
- old = cache.GetAndPut(1, 2);
-
- Assert.AreEqual(1, old);
-
- Assert.AreEqual(2, cache.Get(1));
- }
-
- [Test]
- public void TestGetAndReplace()
- {
- var cache = Cache();
-
- cache.Put(1, 10);
-
- Assert.AreEqual(10, cache.GetAndReplace(1, 100));
-
- Assert.AreEqual(0, cache.GetAndReplace(2, 2));
-
- Assert.AreEqual(0, cache.Get(2));
-
- Assert.AreEqual(100, cache.Get(1));
-
- Assert.IsTrue(cache.Remove(1));
- }
-
- [Test]
- public void TestGetAndRemove()
- {
- var cache = Cache();
-
- cache.Put(1, 1);
-
- Assert.AreEqual(1, cache.Get(1));
-
- Assert.AreEqual(0, cache.GetAndRemove(0));
-
- Assert.AreEqual(1, cache.GetAndRemove(1));
-
- Assert.AreEqual(0, cache.GetAndRemove(1));
-
- Assert.AreEqual(0, cache.Get(1));
- }
-
- [Test]
- public void TestGetAndPutAsync()
- {
- var cache = Cache().WithAsync().WrapAsync();
-
- Assert.AreEqual(0, cache.Get(1));
-
- int old = cache.GetAndPut(1, 1);
-
- Assert.AreEqual(0, old);
-
- Assert.AreEqual(1, cache.Get(1));
-
- old = cache.GetAndPut(1, 2);
-
- Assert.AreEqual(1, old);
-
- Assert.AreEqual(2, cache.Get(1));
- }
-
- [Test]
- public void TestPut()
- {
- var cache = Cache();
-
- cache.Put(1, 1);
-
- Assert.AreEqual(1, cache.Get(1));
- }
-
- [Test]
- public void TestPutxAsync()
- {
- var cache = Cache().WithAsync().WrapAsync();
-
- cache.Put(1, 1);
-
- Assert.AreEqual(1, cache.Get(1));
- }
-
- [Test]
- public void TestPutIfAbsent()
- {
- var cache = Cache();
-
- Assert.AreEqual(0, cache.Get(1));
-
- Assert.AreEqual(true, cache.PutIfAbsent(1, 1));
-
- Assert.AreEqual(1, cache.Get(1));
-
- Assert.AreEqual(false, cache.PutIfAbsent(1, 2));
-
- Assert.AreEqual(1, cache.Get(1));
- }
-
- [Test]
- public void TestGetAndPutIfAbsent()
- {
- var cache = Cache();
-
- Assert.AreEqual(0, cache.Get(1));
-
- Assert.AreEqual(0, cache.GetAndPutIfAbsent(1, 1));
-
- Assert.AreEqual(1, cache.Get(1));
-
- Assert.AreEqual(1, cache.GetAndPutIfAbsent(1, 2));
-
- Assert.AreEqual(1, cache.Get(1));
- }
-
- [Test]
- public void TestGetAndPutIfAbsentAsync()
- {
- var cache = Cache().WithAsync().WrapAsync();
-
- Assert.AreEqual(0, cache.Get(1));
-
- int old = cache.GetAndPutIfAbsent(1, 1);
-
- Assert.AreEqual(0, old);
-
- Assert.AreEqual(1, cache.Get(1));
-
- old = cache.GetAndPutIfAbsent(1, 2);
-
- Assert.AreEqual(1, old);
-
- Assert.AreEqual(1, cache.Get(1));
- }
-
- [Test]
- public void TestPutIfAbsentAsync()
- {
- var cache = Cache().WithAsync().WrapAsync();
-
- Assert.AreEqual(0, cache.Get(1));
-
- Assert.IsTrue(cache.PutIfAbsent(1, 1));
-
- Assert.AreEqual(1, cache.Get(1));
-
- Assert.IsFalse(cache.PutIfAbsent(1, 2));
-
- Assert.AreEqual(1, cache.Get(1));
- }
-
- [Test]
- public void TestReplace()
- {
- var cache = Cache();
-
- Assert.AreEqual(0, cache.Get(1));
-
- bool success = cache.Replace(1, 1);
-
- Assert.AreEqual(false, success);
-
- Assert.AreEqual(0, cache.Get(1));
-
- cache.Put(1, 1);
-
- Assert.AreEqual(1, cache.Get(1));
-
- success = cache.Replace(1, 2);
-
- Assert.AreEqual(true, success);
-
- Assert.AreEqual(2, cache.Get(1));
-
- Assert.IsFalse(cache.Replace(1, -1, 3));
-
- Assert.AreEqual(2, cache.Get(1));
-
- Assert.IsTrue(cache.Replace(1, 2, 3));
-
- Assert.AreEqual(3, cache.Get(1));
- }
-
- [Test]
- public void TestGetAndReplaceAsync()
- {
- var cache = Cache().WithAsync().WrapAsync();
-
- Assert.AreEqual(0, cache.Get(1));
-
- int old = cache.GetAndReplace(1, 1);
-
- Assert.AreEqual(0, old);
-
- Assert.AreEqual(0, cache.Get(1));
-
- cache.Put(1, 1);
-
- Assert.AreEqual(1, cache.Get(1));
-
- old = cache.GetAndReplace(1, 2);
-
- Assert.AreEqual(1, old);
-
- Assert.AreEqual(2, cache.Get(1));
-
- Assert.IsFalse(cache.Replace(1, -1, 3));
-
- Assert.AreEqual(2, cache.Get(1));
-
- Assert.IsTrue(cache.Replace(1, 2, 3));
-
- Assert.AreEqual(3, cache.Get(1));
- }
-
- [Test]
- public void TestReplacex()
- {
- var cache = Cache();
-
- Assert.AreEqual(0, cache.Get(1));
-
- Assert.IsFalse(cache.Replace(1, 1));
-
- Assert.AreEqual(0, cache.Get(1));
-
- cache.Put(1, 1);
-
- Assert.AreEqual(1, cache.Get(1));
-
- Assert.IsTrue(cache.Replace(1, 2));
-
- Assert.AreEqual(2, cache.Get(1));
- }
-
- [Test]
- public void TestReplaceAsync()
- {
- var cache = Cache().WithAsync().WrapAsync();
-
- Assert.AreEqual(0, cache.Get(1));
-
- Assert.IsFalse(cache.Replace(1, 1));
-
- Assert.AreEqual(0, cache.Get(1));
-
- cache.Put(1, 1);
-
- Assert.AreEqual(1, cache.Get(1));
-
- Assert.IsTrue(cache.Replace(1, 2));
-
- Assert.AreEqual(2, cache.Get(1));
- }
-
- [Test]
- public void TestPutAll()
- {
- var cache = Cache();
-
- cache.PutAll(new Dictionary<int, int> { { 1, 1 }, { 2, 2 }, { 3, 3 } });
-
- Assert.AreEqual(1, cache.Get(1));
- Assert.AreEqual(2, cache.Get(2));
- Assert.AreEqual(3, cache.Get(3));
- }
-
- [Test]
- public void TestPutAllAsync()
- {
- var cache = Cache().WithAsync().WrapAsync();
-
- cache.PutAll(new Dictionary<int, int> { { 1, 1 }, { 2, 2 }, { 3, 3 } });
-
- Assert.AreEqual(1, cache.Get(1));
- Assert.AreEqual(2, cache.Get(2));
- Assert.AreEqual(3, cache.Get(3));
- }
-
- /// <summary>
- /// Expiry policy tests.
- /// </summary>
- [Test]
- public void TestWithExpiryPolicy()
- {
- ICache<int, int> cache0 = Cache(0);
-
- int key0;
- int key1;
-
- if (LocalCache())
- {
- key0 = 0;
- key1 = 1;
- }
- else
- {
- key0 = PrimaryKeyForCache(cache0);
- key1 = PrimaryKeyForCache(Cache(1));
- }
-
- // Test unchanged expiration.
- ICache<int, int> cache = cache0.WithExpiryPolicy(new ExpiryPolicy(null, null, null));
-
- cache.Put(key0, key0);
- cache.Put(key1, key1);
- Thread.Sleep(200);
- Assert.IsTrue(cache0.ContainsKey(key0));
- Assert.IsTrue(cache0.ContainsKey(key1));
-
- cache.Put(key0, key0 + 1);
- cache.Put(key1, key1 + 1);
- Thread.Sleep(200);
- Assert.IsTrue(cache0.ContainsKey(key0));
- Assert.IsTrue(cache0.ContainsKey(key1));
-
- cache.Get(key0);
- cache.Get(key1);
- Thread.Sleep(200);
- Assert.IsTrue(cache0.ContainsKey(key0));
- Assert.IsTrue(cache0.ContainsKey(key1));
-
- cache0.RemoveAll(new List<int> { key0, key1 });
-
- // Test eternal expiration.
- cache = cache0.WithExpiryPolicy(new ExpiryPolicy(TimeSpan.MaxValue, TimeSpan.MaxValue, TimeSpan.MaxValue));
-
- cache.Put(key0, key0);
- cache.Put(key1, key1);
- Thread.Sleep(200);
- Assert.IsTrue(cache0.ContainsKey(key0));
- Assert.IsTrue(cache0.ContainsKey(key1));
-
- cache.Put(key0, key0 + 1);
- cache.Put(key1, key1 + 1);
- Thread.Sleep(200);
- Assert.IsTrue(cache0.ContainsKey(key0));
- Assert.IsTrue(cache0.ContainsKey(key1));
-
- cache.Get(key0);
- cache.Get(key1);
- Thread.Sleep(200);
- Assert.IsTrue(cache0.ContainsKey(key0));
- Assert.IsTrue(cache0.ContainsKey(key1));
-
- cache0.RemoveAll(new List<int> { key0, key1 });
-
- // Test zero expiration.
- cache = cache0.WithExpiryPolicy(new ExpiryPolicy(TimeSpan.Zero, TimeSpan.Zero, TimeSpan.Zero));
-
- cache.Put(key0, key0);
- cache.Put(key1, key1);
- Assert.IsFalse(cache0.ContainsKey(key0));
- Assert.IsFalse(cache0.ContainsKey(key1));
-
- cache0.Put(key0, key0);
- cache0.Put(key1, key1);
- Assert.IsTrue(cache0.ContainsKey(key0));
- Assert.IsTrue(cache0.ContainsKey(key1));
- cache.Put(key0, key0 + 1);
- cache.Put(key1, key1 + 1);
- Assert.IsFalse(cache0.ContainsKey(key0));
- Assert.IsFalse(cache0.ContainsKey(key1));
-
- cache0.Put(key0, key0);
- cache0.Put(key1, key1);
- cache.Get(key0);
- cache.Get(key1);
- Assert.IsFalse(cache0.ContainsKey(key0));
- Assert.IsFalse(cache0.ContainsKey(key1));
-
- cache0.RemoveAll(new List<int> { key0, key1 });
-
- // Test negative expiration.
- cache = cache0.WithExpiryPolicy(new ExpiryPolicy(TimeSpan.FromMilliseconds(-100),
- TimeSpan.FromMilliseconds(-100), TimeSpan.FromMilliseconds(-100)));
-
- cache.Put(key0, key0);
- cache.Put(key1, key1);
- Assert.IsFalse(cache0.ContainsKey(key0));
- Assert.IsFalse(cache0.ContainsKey(key1));
-
- cache0.Put(key0, key0);
- cache0.Put(key1, key1);
- Assert.IsTrue(cache0.ContainsKey(key0));
- Assert.IsTrue(cache0.ContainsKey(key1));
- cache.Put(key0, key0 + 1);
- cache.Put(key1, key1 + 1);
- Assert.IsFalse(cache0.ContainsKey(key0));
- Assert.IsFalse(cache0.ContainsKey(key1));
-
- cache0.Put(key0, key0);
- cache0.Put(key1, key1);
- cache.Get(key0);
- cache.Get(key1);
- Assert.IsFalse(cache0.ContainsKey(key0));
- Assert.IsFalse(cache0.ContainsKey(key1));
-
- cache0.RemoveAll(new List<int> { key0, key1 });
-
- // Test regular expiration.
- cache = cache0.WithExpiryPolicy(new ExpiryPolicy(TimeSpan.FromMilliseconds(100),
- TimeSpan.FromMilliseconds(100), TimeSpan.FromMilliseconds(100)));
-
- cache.Put(key0, key0);
- cache.Put(key1, key1);
- Assert.IsTrue(cache0.ContainsKey(key0));
- Assert.IsTrue(cache0.ContainsKey(key1));
- Thread.Sleep(200);
- Assert.IsFalse(cache0.ContainsKey(key0));
- Assert.IsFalse(cache0.ContainsKey(key1));
-
- cache0.Put(key0, key0);
- cache0.Put(key1, key1);
- cache.Put(key0, key0 + 1);
- cache.Put(key1, key1 + 1);
- Assert.IsTrue(cache0.ContainsKey(key0));
- Assert.IsTrue(cache0.ContainsKey(key1));
- Thread.Sleep(200);
- Assert.IsFalse(cache0.ContainsKey(key0));
- Assert.IsFalse(cache0.ContainsKey(key1));
-
- cache0.Put(key0, key0);
- cache0.Put(key1, key1);
- cache.Get(key0);
- cache.Get(key1);
- Assert.IsTrue(cache0.ContainsKey(key0));
- Assert.IsTrue(cache0.ContainsKey(key1));
- Thread.Sleep(200);
- Assert.IsFalse(cache0.ContainsKey(key0));
- Assert.IsFalse(cache0.ContainsKey(key1));
- }
-
- [Test]
- public void TestEvict()
- {
- var cache = Cache();
-
- int key = PrimaryKeyForCache(cache);
-
- cache.Put(key, 1);
-
- Assert.AreEqual(1, PeekInt(cache, key));
-
- cache.LocalEvict(new[] {key});
-
- Assert.AreEqual(0, cache.GetLocalSize(CachePeekMode.Onheap));
-
- Assert.AreEqual(0, PeekInt(cache, key));
-
- Assert.AreEqual(1, cache.Get(key));
-
- Assert.AreEqual(1, cache.GetLocalSize(CachePeekMode.Onheap));
-
- Assert.AreEqual(1, PeekInt(cache, key));
- }
-
- [Test]
- public void TestEvictAllKeys()
- {
- var cache = Cache();
-
- List<int> keys = PrimaryKeysForCache(cache, 3);
-
- cache.Put(keys[0], 1);
- cache.Put(keys[1], 2);
- cache.Put(keys[2], 3);
-
- Assert.AreEqual(1, PeekInt(cache, keys[0]));
- Assert.AreEqual(2, PeekInt(cache, keys[1]));
- Assert.AreEqual(3, PeekInt(cache, keys[2]));
-
- cache.LocalEvict(new List<int> { -1, keys[0], keys[1] });
-
- Assert.AreEqual(1, cache.GetLocalSize(CachePeekMode.Onheap));
-
- Assert.AreEqual(0, PeekInt(cache, keys[0]));
- Assert.AreEqual(0, PeekInt(cache, keys[1]));
- Assert.AreEqual(3, PeekInt(cache, keys[2]));
-
- Assert.AreEqual(1, cache.Get(keys[0]));
- Assert.AreEqual(2, cache.Get(keys[1]));
-
- Assert.AreEqual(3, cache.GetLocalSize());
-
- Assert.AreEqual(1, PeekInt(cache, keys[0]));
- Assert.AreEqual(2, PeekInt(cache, keys[1]));
- Assert.AreEqual(3, PeekInt(cache, keys[2]));
- }
-
- [Test]
- public void TestClear()
- {
- for (int i = 0; i < GridCount(); i++)
- {
- var cache = Cache(i);
-
- cache.Put(PrimaryKeyForCache(cache, 500), 1);
-
- Assert.IsFalse(cache.IsEmpty());
- }
-
- Cache().Clear();
-
- for (int i = 0; i < GridCount(); i++)
- Assert.IsTrue(Cache(i).IsEmpty());
- }
-
- [Test]
- public void TestClearKey()
- {
- var cache = Cache();
- var keys = PrimaryKeysForCache(cache, 10);
-
- foreach (var key in keys)
- cache.Put(key, 3);
-
- var i = cache.GetSize();
-
- foreach (var key in keys)
- {
- cache.Clear(key);
-
- Assert.AreEqual(0, cache.Get(key));
-
- Assert.Less(cache.GetSize(), i);
-
- i = cache.GetSize();
- }
- }
-
- [Test]
- public void TestClearKeys()
- {
- var cache = Cache();
- var keys = PrimaryKeysForCache(cache, 10);
-
- foreach (var key in keys)
- cache.Put(key, 3);
-
- cache.ClearAll(keys);
-
- foreach (var key in keys)
- Assert.AreEqual(0, cache.Get(key));
- }
-
- [Test]
- public void TestLocalClearKey()
- {
- var cache = Cache();
- var keys = PrimaryKeysForCache(cache, 10);
-
- foreach (var key in keys)
- cache.Put(key, 3);
-
- var i = cache.GetSize();
-
- foreach (var key in keys)
- {
- cache.LocalClear(key);
-
- Assert.AreEqual(0, cache.LocalPeek(key));
-
- Assert.Less(cache.GetSize(), i);
-
- i = cache.GetSize();
- }
-
- cache.Clear();
- }
-
- [Test]
- public void TestLocalClearKeys()
- {
- var cache = Cache();
- var keys = PrimaryKeysForCache(cache, 10);
-
- foreach (var key in keys)
- cache.Put(key, 3);
-
- cache.LocalClearAll(keys);
-
- foreach (var key in keys)
- Assert.AreEqual(0, cache.LocalPeek(key));
-
- cache.Clear();
- }
-
- [Test]
- public void TestRemove()
- {
- var cache = Cache();
-
- cache.Put(1, 1);
-
- Assert.AreEqual(1, cache.Get(1));
-
- Assert.AreEqual(true, cache.Remove(1));
-
- Assert.AreEqual(0, cache.GetSize());
-
- Assert.AreEqual(0, cache.Get(1));
-
- cache.Put(1, 1);
-
- Assert.AreEqual(1, cache.Get(1));
-
- Assert.IsFalse(cache.Remove(1, -1));
- Assert.IsTrue(cache.Remove(1, 1));
-
- Assert.AreEqual(0, cache.GetSize());
-
- Assert.AreEqual(0, cache.Get(1));
- }
-
- [Test]
- public void TestGetAndRemoveAsync()
- {
- var cache = Cache().WithAsync().WrapAsync();
-
- cache.Put(1, 1);
-
- Assert.AreEqual(1, cache.Get(1));
-
- Assert.AreEqual(1, cache.GetAndRemove(1));
-
- Assert.AreEqual(0, cache.GetSize());
-
- Assert.AreEqual(0, cache.Get(1));
-
- cache.Put(1, 1);
-
- Assert.AreEqual(1, cache.Get(1));
-
- Assert.IsFalse(cache.Remove(1, -1));
- Assert.IsTrue(cache.Remove(1, 1));
-
- Assert.AreEqual(0, cache.GetSize());
-
- Assert.AreEqual(0, cache.Get(1));
- }
-
- [Test]
- public void TestRemovex()
- {
- var cache = Cache();
-
- cache.Put(1, 1);
-
- Assert.AreEqual(1, cache.Get(1));
-
- Assert.IsFalse(cache.Remove(-1));
- Assert.IsTrue(cache.Remove(1));
-
- Assert.AreEqual(0, cache.GetSize());
-
- Assert.AreEqual(0, cache.Get(1));
- }
-
- [Test]
- public void TestRemoveAsync()
- {
- var cache = Cache().WithAsync().WrapAsync();
-
- cache.Put(1, 1);
-
- Assert.AreEqual(1, cache.Get(1));
-
- Assert.IsFalse(cache.Remove(-1));
- Assert.IsTrue(cache.Remove(1));
-
- Assert.AreEqual(0, cache.GetSize());
-
- Assert.AreEqual(0, cache.Get(1));
- }
-
- [Test]
- public void TestRemoveAll()
- {
- var cache = Cache();
-
- List<int> keys = PrimaryKeysForCache(cache, 2);
-
- cache.Put(keys[0], 1);
- cache.Put(keys[1], 2);
-
- Assert.AreEqual(1, cache.Get(keys[0]));
- Assert.AreEqual(2, cache.Get(keys[1]));
-
- cache.RemoveAll();
-
- Assert.AreEqual(0, cache.GetSize());
-
- Assert.AreEqual(0, cache.Get(keys[0]));
- Assert.AreEqual(0, cache.Get(keys[1]));
- }
-
- [Test]
- public void TestRemoveAllAsync()
- {
- var cache = Cache().WithAsync().WrapAsync();
-
- List<int> keys = PrimaryKeysForCache(cache, 2);
-
- cache.Put(keys[0], 1);
- cache.Put(keys[1], 2);
-
- Assert.AreEqual(1, cache.Get(keys[0]));
- Assert.AreEqual(2, cache.Get(keys[1]));
-
- cache.RemoveAll();
-
- Assert.AreEqual(0, cache.GetSize());
-
- Assert.AreEqual(0, cache.Get(keys[0]));
- Assert.AreEqual(0, cache.Get(keys[1]));
- }
-
- [Test]
- public void TestRemoveAllKeys()
- {
- var cache = Cache();
-
- Assert.AreEqual(0, cache.GetSize());
-
- cache.Put(1, 1);
- cache.Put(2, 2);
- cache.Put(3, 3);
-
- Assert.AreEqual(1, cache.Get(1));
- Assert.AreEqual(2, cache.Get(2));
- Assert.AreEqual(3, cache.Get(3));
-
- cache.RemoveAll(new List<int> { 0, 1, 2 });
-
- Assert.AreEqual(1, cache.GetSize(CachePeekMode.Primary));
-
- Assert.AreEqual(0, cache.Get(1));
- Assert.AreEqual(0, cache.Get(2));
- Assert.AreEqual(3, cache.Get(3));
- }
-
- [Test]
- public void TestRemoveAllKeysAsync()
- {
- var cache = Cache().WithAsync().WrapAsync();
-
- Assert.AreEqual(0, cache.GetSize());
-
- cache.Put(1, 1);
- cache.Put(2, 2);
- cache.Put(3, 3);
-
- Assert.AreEqual(1, cache.Get(1));
- Assert.AreEqual(2, cache.Get(2));
- Assert.AreEqual(3, cache.Get(3));
-
- cache.RemoveAll(new List<int> { 0, 1, 2 });
-
- Assert.AreEqual(1, cache.GetSize(CachePeekMode.Primary));
-
- Assert.AreEqual(0, cache.Get(1));
- Assert.AreEqual(0, cache.Get(2));
- Assert.AreEqual(3, cache.Get(3));
- }
-
- [Test]
- public void TestSizes()
- {
- for (int i = 0; i < GridCount(); i++)
- {
- var cache = Cache(i);
-
- List<int> keys = PrimaryKeysForCache(cache, 2);
-
- foreach (int key in keys)
- cache.Put(key, 1);
-
- Assert.IsTrue(cache.GetSize() >= 2);
- Assert.AreEqual(2, cache.GetLocalSize(CachePeekMode.Primary));
- }
-
- ICache<int, int> cache0 = Cache();
-
- Assert.AreEqual(GridCount() * 2, cache0.GetSize(CachePeekMode.Primary));
-
- if (!LocalCache() && !ReplicatedCache())
- {
- int nearKey = NearKeyForCache(cache0);
-
- cache0.Put(nearKey, 1);
-
- Assert.AreEqual(NearEnabled() ? 1 : 0, cache0.GetSize(CachePeekMode.Near));
- }
- }
-
- [Test]
- public void TestLocalSize()
- {
- var cache = Cache();
- var keys = PrimaryKeysForCache(cache, 3);
-
- cache.Put(keys[0], 1);
- cache.Put(keys[1], 2);
-
- var localSize = cache.GetLocalSize();
-
- cache.LocalEvict(keys.Take(2).ToArray());
-
- Assert.AreEqual(0, cache.GetLocalSize(CachePeekMode.Onheap));
- Assert.AreEqual(localSize, cache.GetLocalSize(CachePeekMode.All));
-
- cache.Put(keys[2], 3);
-
- Assert.AreEqual(localSize + 1, cache.GetLocalSize(CachePeekMode.All));
-
- cache.RemoveAll(keys.Take(2).ToArray());
- }
-
- /// <summary>
- /// Test enumerators.
- /// </summary>
- [Test]
- [SuppressMessage("ReSharper", "PossibleMultipleEnumeration")]
- public void TestEnumerators()
- {
- var cache = Cache();
- var keys = PrimaryKeysForCache(cache, 2);
-
- cache.Put(keys[0], keys[0] + 1);
- cache.Put(keys[1], keys[1] + 1);
-
- // Check distributed enumerator.
- IEnumerable<ICacheEntry<int, int>> e = cache;
-
- CheckEnumerator(e.GetEnumerator(), keys);
- CheckEnumerator(e.GetEnumerator(), keys);
-
- // Check local enumerator.
- e = cache.GetLocalEntries();
-
- CheckEnumerator(e.GetEnumerator(), keys);
- CheckEnumerator(e.GetEnumerator(), keys);
-
- // Evict and check peek modes.
- cache.LocalEvict(new List<int> { keys[0] } );
-
- e = cache.GetLocalEntries(CachePeekMode.Onheap);
- CheckEnumerator(e.GetEnumerator(), new List<int> { keys[1] });
- CheckEnumerator(e.GetEnumerator(), new List<int> { keys[1] });
-
- e = cache.GetLocalEntries(CachePeekMode.All);
- CheckEnumerator(e.GetEnumerator(), keys);
- CheckEnumerator(e.GetEnumerator(), keys);
-
- e = cache.GetLocalEntries(CachePeekMode.Onheap, CachePeekMode.Swap);
- CheckEnumerator(e.GetEnumerator(), keys);
- CheckEnumerator(e.GetEnumerator(), keys);
-
- cache.Remove(keys[0]);
- }
-
- /// <summary>
- /// Check enumerator content.
- /// </summary>
- /// <param name="e">Enumerator.</param>
- /// <param name="keys">Keys.</param>
- private static void CheckEnumerator(IEnumerator<ICacheEntry<int, int>> e, IList<int> keys)
- {
- CheckEnumerator0(e, keys);
-
- e.Reset();
-
- CheckEnumerator0(e, keys);
-
- e.Dispose();
-
- Assert.Throws<ObjectDisposedException>(() => { e.MoveNext(); });
- Assert.Throws<ObjectDisposedException>(() => { var entry = e.Current; });
- Assert.Throws<ObjectDisposedException>(e.Reset);
-
- e.Dispose();
- }
-
- /// <summary>
- /// Check enumerator content.
- /// </summary>
- /// <param name="e">Enumerator.</param>
- /// <param name="keys">Keys.</param>
- private static void CheckEnumerator0(IEnumerator<ICacheEntry<int, int>> e, IList<int> keys)
- {
- Assert.Throws<InvalidOperationException>(() => { var entry = e.Current; });
-
- int cnt = 0;
-
- while (e.MoveNext())
- {
- ICacheEntry<int, int> entry = e.Current;
-
- Assert.IsTrue(keys.Contains(entry.Key), "Unexpected entry: " + entry);
-
- Assert.AreEqual(entry.Key + 1, entry.Value);
-
- cnt++;
- }
-
- Assert.AreEqual(keys.Count, cnt);
-
- Assert.IsFalse(e.MoveNext());
-
- Assert.Throws<InvalidOperationException>(() => { var entry = e.Current; });
- }
-
- [Test]
- public void TestPromote()
- {
- var cache = Cache();
-
- int key = PrimaryKeyForCache(cache);
-
- cache.Put(key, 1);
-
- Assert.AreEqual(1, PeekInt(cache, key));
-
- cache.LocalEvict(new[] {key});
-
- Assert.AreEqual(0, cache.GetLocalSize(CachePeekMode.Onheap));
-
- Assert.AreEqual(0, PeekInt(cache, key));
-
- cache.LocalPromote(new[] { key });
-
- Assert.AreEqual(1, cache.GetLocalSize(CachePeekMode.Onheap));
-
- Assert.AreEqual(1, PeekInt(cache, key));
- }
-
- [Test]
- public void TestPromoteAll()
- {
- var cache = Cache();
-
- List<int> keys = PrimaryKeysForCache(cache, 3);
-
- cache.Put(keys[0], 1);
- cache.Put(keys[1], 2);
- cache.Put(keys[2], 3);
-
- Assert.AreEqual(1, PeekInt(cache, keys[0]));
- Assert.AreEqual(2, PeekInt(cache, keys[1]));
- Assert.AreEqual(3, PeekInt(cache, keys[2]));
-
- cache.LocalEvict(new List<int> { -1, keys[0], keys[1] });
-
- Assert.AreEqual(1, cache.GetLocalSize(CachePeekMode.Onheap));
-
- Assert.AreEqual(0, PeekInt(cache, keys[0]));
- Assert.AreEqual(0, PeekInt(cache, keys[1]));
- Assert.AreEqual(3, PeekInt(cache, keys[2]));
-
- cache.LocalPromote(new[] {keys[0], keys[1]});
-
- Assert.AreEqual(3, cache.GetLocalSize(CachePeekMode.Onheap));
-
- Assert.AreEqual(1, PeekInt(cache, keys[0]));
- Assert.AreEqual(2, PeekInt(cache, keys[1]));
- Assert.AreEqual(3, PeekInt(cache, keys[2]));
- }
-
- [Test]
- public void TestPutGetPortable()
- {
- var cache = Cache<int, PortablePerson>();
-
- PortablePerson obj1 = new PortablePerson("obj1", 1);
-
- cache.Put(1, obj1);
-
- obj1 = cache.Get(1);
-
- Assert.AreEqual("obj1", obj1.Name);
- Assert.AreEqual(1, obj1.Age);
- }
-
- [Test]
- public void TestPutGetPortableAsync()
- {
- var cache = Cache<int, PortablePerson>().WithAsync().WrapAsync();
-
- PortablePerson obj1 = new PortablePerson("obj1", 1);
-
- cache.Put(1, obj1);
-
- obj1 = cache.Get(1);
-
- Assert.AreEqual("obj1", obj1.Name);
- Assert.AreEqual(1, obj1.Age);
- }
-
- [Test]
- public void TestPutGetPortableKey()
- {
- var cache = Cache<CacheTestKey, string>();
-
- int cnt = 100;
-
- for (int i = 0; i < cnt; i++)
- cache.Put(new CacheTestKey(i), "val-" + i);
-
- for (int i = 0; i < cnt; i++)
- Assert.AreEqual("val-" + i, cache.Get(new CacheTestKey(i)));
- }
-
- [Test]
- public void TestGetAsync2()
- {
- var cache = Cache().WithAsync();
-
- for (int i = 0; i < 100; i++)
- {
- cache.Put(i, i);
-
- cache.GetFuture<object>().Get();
- }
-
- var futs = new List<IFuture<int>>();
-
- for (int i = 0; i < 1000; i++)
- {
- cache.Get(i % 100);
-
- futs.Add(cache.GetFuture<int>());
- }
-
- for (int i = 0; i < 1000; i++) {
- Assert.AreEqual(i % 100, futs[i].Get(), "Unexpected result: " + i);
-
- Assert.IsTrue(futs[i].IsDone);
- }
- }
-
- [Test]
- [Category(TestUtils.CategoryIntensive)]
- public void TestGetAsyncMultithreaded()
- {
- var cache = Cache().WithAsync();
-
- for (int i = 0; i < 100; i++)
- {
- cache.Put(i, i);
-
- cache.GetFuture<object>().Get();
- }
-
- TestUtils.RunMultiThreaded(() =>
- {
- for (int i = 0; i < 100; i++)
- {
- var futs = new List<IFuture<int>>();
-
- for (int j = 0; j < 100; j++)
- {
- cache.Get(j);
-
- futs.Add(cache.GetFuture<int>());
- }
-
- for (int j = 0; j < 100; j++)
- Assert.AreEqual(j, futs[j].Get());
- }
- }, 10);
- }
-
- [Test]
- [Category(TestUtils.CategoryIntensive)]
- public void TestPutxAsyncMultithreaded()
- {
- var cache = Cache().WithAsync();
-
- TestUtils.RunMultiThreaded(() =>
- {
- Random rnd = new Random();
-
- for (int i = 0; i < 50; i++)
- {
- var futs = new List<IFuture<object>>();
-
- for (int j = 0; j < 10; j++)
- {
- cache.Put(rnd.Next(1000), i);
-
- futs.Add(cache.GetFuture<object>());
- }
-
- foreach (var fut in futs)
- fut.Get();
- }
- }, 5);
- }
-
- [Test]
- [Category(TestUtils.CategoryIntensive)]
- public void TestPutGetAsyncMultithreaded()
- {
- var cache = Cache<CacheTestKey, PortablePerson>().WithAsync();
-
- const int threads = 10;
- const int objPerThread = 1000;
-
- int cntr = 0;
-
- TestUtils.RunMultiThreaded(() =>
- {
- // ReSharper disable once AccessToModifiedClosure
- int threadIdx = Interlocked.Increment(ref cntr);
-
- var futs = new List<IFuture<object>>();
-
- for (int i = 0; i < objPerThread; i++)
- {
- int key = threadIdx * objPerThread + i;
-
- cache.Put(new CacheTestKey(key), new PortablePerson("Person-" + key, key));
-
- futs.Add(cache.GetFuture<object>());
- }
-
- foreach (var fut in futs)
- {
- fut.Get();
-
- Assert.IsTrue(fut.IsDone);
- }
- }, threads);
-
- for (int i = 0; i < threads; i++)
- {
- int threadIdx = i + 1;
-
- for (int j = 0; j < objPerThread; j++)
- {
- int key = threadIdx * objPerThread + i;
-
- cache.Get(new CacheTestKey(key));
- var p = cache.GetFuture<PortablePerson>().Get();
-
- Assert.IsNotNull(p);
- Assert.AreEqual(key, p.Age);
- Assert.AreEqual("Person-" + key, p.Name);
- }
- }
-
- cntr = 0;
-
- TestUtils.RunMultiThreaded(() =>
- {
- int threadIdx = Interlocked.Increment(ref cntr);
-
- for (int i = 0; i < objPerThread; i++)
- {
- int key = threadIdx * objPerThread + i;
-
- cache.Put(new CacheTestKey(key), new PortablePerson("Person-" + key, key));
-
- cache.GetFuture<object>().Get();
- }
- }, threads);
-
- cntr = 0;
-
- TestUtils.RunMultiThreaded(() =>
- {
- int threadIdx = Interlocked.Increment(ref cntr);
-
- var futs = new List<IFuture<PortablePerson>>();
-
- for (int i = 0; i < objPerThread; i++)
- {
- int key = threadIdx * objPerThread + i;
-
- cache.Get(new CacheTestKey(key));
-
- futs.Add(cache.GetFuture<PortablePerson>());
- }
-
- for (int i = 0; i < objPerThread; i++)
- {
- var fut = futs[i];
-
- int key = threadIdx * objPerThread + i;
-
- var p = fut.Get();
-
- Assert.IsNotNull(p);
- Assert.AreEqual(key, p.Age);
- Assert.AreEqual("Person-" + key, p.Name);
- }
- }, threads);
- }
-
- //[Test]
- //[Category(TestUtils.CATEGORY_INTENSIVE)]
- public void TestAsyncMultithreadedKeepPortable()
- {
- var cache = Cache().WithAsync().WithKeepPortable<CacheTestKey, PortablePerson>();
- var portCache = Cache().WithAsync().WithKeepPortable<CacheTestKey, IPortableObject>();
-
- const int threads = 10;
- const int objPerThread = 1000;
-
- int cntr = 0;
-
- TestUtils.RunMultiThreaded(() =>
- {
- // ReSharper disable once AccessToModifiedClosure
- int threadIdx = Interlocked.Increment(ref cntr);
-
- var futs = new List<IFuture<object>>();
-
- for (int i = 0; i < objPerThread; i++)
- {
- int key = threadIdx * objPerThread + i;
-
- cache.Put(new CacheTestKey(key), new PortablePerson("Person-" + key, key));
-
- futs.Add(cache.GetFuture<object>());
- }
-
- foreach (var fut in futs)
- Assert.IsNull(fut.Get());
- }, threads);
-
- for (int i = 0; i < threads; i++)
- {
- int threadIdx = i + 1;
-
- for (int j = 0; j < objPerThread; j++)
- {
- int key = threadIdx * objPerThread + i;
-
- IPortableObject p = portCache.Get(new CacheTestKey(key));
-
- Assert.IsNotNull(p);
- Assert.AreEqual(key, p.GetField<int>("age"));
- Assert.AreEqual("Person-" + key, p.GetField<string>("name"));
- }
- }
-
- cntr = 0;
-
- TestUtils.RunMultiThreaded(() =>
- {
- int threadIdx = Interlocked.Increment(ref cntr);
-
- var futs = new List<IFuture<IPortableObject>>();
-
- for (int i = 0; i < objPerThread; i++)
- {
- int key = threadIdx * objPerThread + i;
-
- portCache.Get(new CacheTestKey(key));
-
- futs.Add(cache.GetFuture<IPortableObject>());
- }
-
- for (int i = 0; i < objPerThread; i++)
- {
- var fut = futs[i];
-
- int key = threadIdx * objPerThread + i;
-
- var p = fut.Get();
-
- Assert.IsNotNull(p);
- Assert.AreEqual(key, p.GetField<int>("age"));
- Assert.AreEqual("Person-" + key, p.GetField<string>("name"));
- }
- }, threads);
-
- cntr = 0;
-
- TestUtils.RunMultiThreaded(() =>
- {
- int threadIdx = Interlocked.Increment(ref cntr);
-
- var futs = new List<IFuture<bool>>();
-
- for (int i = 0; i < objPerThread; i++)
- {
- int key = threadIdx * objPerThread + i;
-
- cache.Remove(new CacheTestKey(key));
-
- futs.Add(cache.GetFuture<bool>());
- }
-
- for (int i = 0; i < objPerThread; i++)
- {
- var fut = futs[i];
-
- Assert.AreEqual(true, fut.Get());
- }
- }, threads);
- }
-
- [Test]
- [Ignore("IGNITE-835")]
- public void TestLock()
- {
- if (!LockingEnabled())
- return;
-
- var cache = Cache();
-
- const int key = 7;
-
- // Lock
- CheckLock(cache, key, () => cache.Lock(key));
-
- // LockAll
- CheckLock(cache, key, () => cache.LockAll(new[] { key, 2, 3, 4, 5 }));
- }
-
- /// <summary>
- /// Internal lock test routine.
- /// </summary>
- /// <param name="cache">Cache.</param>
- /// <param name="key">Key.</param>
- /// <param name="getLock">Function to get the lock.</param>
- private static void CheckLock(ICache<int, int> cache, int key, Func<ICacheLock> getLock)
- {
- var sharedLock = getLock();
-
- using (sharedLock)
- {
- Assert.Throws<InvalidOperationException>(() => sharedLock.Exit()); // can't exit if not entered
-
- sharedLock.Enter();
-
- try
- {
- Assert.IsTrue(cache.IsLocalLocked(key, true));
- Assert.IsTrue(cache.IsLocalLocked(key, false));
-
- EnsureCannotLock(getLock, sharedLock);
-
- sharedLock.Enter();
-
- try
- {
- Assert.IsTrue(cache.IsLocalLocked(key, true));
- Assert.IsTrue(cache.IsLocalLocked(key, false));
-
- EnsureCannotLock(getLock, sharedLock);
- }
- finally
- {
- sharedLock.Exit();
- }
-
- Assert.IsTrue(cache.IsLocalLocked(key, true));
- Assert.IsTrue(cache.IsLocalLocked(key, false));
-
- EnsureCannotLock(getLock, sharedLock);
-
- Assert.Throws<SynchronizationLockException>(() => sharedLock.Dispose()); // can't dispose while locked
- }
- finally
- {
- sharedLock.Exit();
- }
-
- Assert.IsFalse(cache.IsLocalLocked(key, true));
- Assert.IsFalse(cache.IsLocalLocked(key, false));
-
- var innerTask = new Task(() =>
- {
- Assert.IsTrue(sharedLock.TryEnter());
- sharedLock.Exit();
-
- using (var otherLock = getLock())
- {
- Assert.IsTrue(otherLock.TryEnter());
- otherLock.Exit();
- }
- });
-
- innerTask.Start();
- innerTask.Wait();
- }
-
- Assert.IsFalse(cache.IsLocalLocked(key, true));
- Assert.IsFalse(cache.IsLocalLocked(key, false));
-
- var outerTask = new Task(() =>
- {
- using (var otherLock = getLock())
- {
- Assert.IsTrue(otherLock.TryEnter());
- otherLock.Exit();
- }
- });
-
- outerTask.Start();
- outerTask.Wait();
-
- Assert.Throws<ObjectDisposedException>(() => sharedLock.Enter()); // Can't enter disposed lock
- }
-
- /// <summary>
- /// ENsure taht lock cannot be obtained by other threads.
- /// </summary>
- /// <param name="getLock">Get lock function.</param>
- /// <param name="sharedLock">Shared lock.</param>
- private static void EnsureCannotLock(Func<ICacheLock> getLock, ICacheLock sharedLock)
- {
- var task = new Task(() =>
- {
- Assert.IsFalse(sharedLock.TryEnter());
- Assert.IsFalse(sharedLock.TryEnter(TimeSpan.FromMilliseconds(100)));
-
- using (var otherLock = getLock())
- {
- Assert.IsFalse(otherLock.TryEnter());
- Assert.IsFalse(otherLock.TryEnter(TimeSpan.FromMilliseconds(100)));
- }
- });
-
- task.Start();
- task.Wait();
- }
-
- [Test]
- public void TestTxCommit()
- {
- TestTxCommit(false);
- }
-
- [Test]
- public void TestTxCommitAsync()
- {
- TestTxCommit(true);
- }
-
- private void TestTxCommit(bool async)
- {
- if (!TxEnabled())
- return;
-
- var cache = Cache();
-
- ITransaction tx = Transactions.Tx;
-
- Assert.IsNull(tx);
-
- tx = Transactions.TxStart();
-
- try
- {
- cache.Put(1, 1);
-
- cache.Put(2, 2);
-
- if (async)
- {
- var asyncTx = tx.WithAsync();
-
- asyncTx.Commit();
-
- var fut = asyncTx.GetFuture();
-
- fut.Get();
-
- Assert.IsTrue(fut.IsDone);
- Assert.AreEqual(fut.Get(), null);
- }
- else
- tx.Commit();
- }
- finally
- {
- tx.Dispose();
- }
-
- Assert.AreEqual(1, cache.Get(1));
-
- Assert.AreEqual(2, cache.Get(2));
-
- tx = Transactions.Tx;
-
- Assert.IsNull(tx);
- }
-
- [Test]
- public void TestTxRollback()
- {
- if (!TxEnabled())
- return;
-
- var cache = Cache();
-
- cache.Put(1, 1);
-
- cache.Put(2, 2);
-
- ITransaction tx = Transactions.Tx;
-
- Assert.IsNull(tx);
-
- tx = Transactions.TxStart();
-
- try {
- cache.Put(1, 10);
-
- cache.Put(2, 20);
- }
- finally {
- tx.Rollback();
- }
-
- Assert.AreEqual(1, cache.Get(1));
-
- Assert.AreEqual(2, cache.Get(2));
-
- Assert.IsNull(Transactions.Tx);
- }
-
- [Test]
- public void TestTxClose()
- {
- if (!TxEnabled())
- return;
-
- var cache = Cache();
-
- cache.Put(1, 1);
-
- cache.Put(2, 2);
-
- ITransaction tx = Transactions.Tx;
-
- Assert.IsNull(tx);
-
- tx = Transactions.TxStart();
-
- try
- {
- cache.Put(1, 10);
-
- cache.Put(2, 20);
- }
- finally
- {
- tx.Dispose();
- }
-
- Assert.AreEqual(1, cache.Get(1));
-
- Assert.AreEqual(2, cache.Get(2));
-
- tx = Transactions.Tx;
-
- Assert.IsNull(tx);
- }
-
- [Test]
- public void TestTxAllModes()
- {
- TestTxAllModes(false);
-
- TestTxAllModes(true);
-
- Console.WriteLine("Done");
- }
-
- protected void TestTxAllModes(bool withTimeout)
- {
- if (!TxEnabled())
- return;
-
- var cache = Cache();
-
- int cntr = 0;
-
- foreach (TransactionConcurrency concurrency in Enum.GetValues(typeof(TransactionConcurrency))) {
- foreach (TransactionIsolation isolation in Enum.GetValues(typeof(TransactionIsolation))) {
- Console.WriteLine("Test tx [concurrency=" + concurrency + ", isolation=" + isolation + "]");
-
- ITransaction tx = Transactions.Tx;
-
- Assert.IsNull(tx);
-
- tx = withTimeout
- ? Transactions.TxStart(concurrency, isolation, TimeSpan.FromMilliseconds(1100), 10)
- : Transactions.TxStart(concurrency, isolation);
-
- Assert.AreEqual(concurrency, tx.Concurrency);
- Assert.AreEqual(isolation, tx.Isolation);
-
- if (withTimeout)
- Assert.AreEqual(1100, tx.Timeout.TotalMilliseconds);
-
- try {
- cache.Put(1, cntr);
-
- tx.Commit();
- }
- finally {
- tx.Dispose();
- }
-
- tx = Transactions.Tx;
-
- Assert.IsNull(tx);
-
- Assert.AreEqual(cntr, cache.Get(1));
-
- cntr++;
- }
- }
- }
-
- [Test]
- public void TestTxAttributes()
- {
- if (!TxEnabled())
- return;
-
- ITransaction tx = Transactions.TxStart(TransactionConcurrency.Optimistic,
- TransactionIsolation.RepeatableRead, TimeSpan.FromMilliseconds(2500), 100);
-
- Assert.IsFalse(tx.IsRollbackOnly);
- Assert.AreEqual(TransactionConcurrency.Optimistic, tx.Concurrency);
- Assert.AreEqual(TransactionIsolation.RepeatableRead, tx.Isolation);
- Assert.AreEqual(2500, tx.Timeout.TotalMilliseconds);
- Assert.AreEqual(TransactionState.Active, tx.State);
- Assert.IsTrue(tx.StartTime.Ticks > 0);
- Assert.AreEqual(tx.NodeId, GetIgnite(0).GetCluster().GetLocalNode().Id);
-
- DateTime startTime1 = tx.StartTime;
-
- tx.Commit();
-
- Assert.IsFalse(tx.IsRollbackOnly);
- Assert.AreEqual(TransactionState.Committed, tx.State);
- Assert.AreEqual(TransactionConcurrency.Optimistic, tx.Concurrency);
- Assert.AreEqual(TransactionIsolation.RepeatableRead, tx.Isolation);
- Assert.AreEqual(2500, tx.Timeout.TotalMilliseconds);
- Assert.AreEqual(startTime1, tx.StartTime);
-
- Thread.Sleep(100);
-
- tx = Transactions.TxStart(TransactionConcurrency.Pessimistic, TransactionIsolation.ReadCommitted,
- TimeSpan.FromMilliseconds(3500), 200);
-
- Assert.IsFalse(tx.IsRollbackOnly);
- Assert.AreEqual(TransactionConcurrency.Pessimistic, tx.Concurrency);
- Assert.AreEqual(TransactionIsolation.ReadCommitted, tx.Isolation);
- Assert.AreEqual(3500, tx.Timeout.TotalMilliseconds);
- Assert.AreEqual(TransactionState.Active, tx.State);
- Assert.IsTrue(tx.StartTime.Ticks > 0);
- Assert.IsTrue(tx.StartTime > startTime1);
-
- DateTime startTime2 = tx.StartTime;
-
- tx.Rollback();
-
- Assert.AreEqual(TransactionState.RolledBack, tx.State);
- Assert.AreEqual(TransactionConcurrency.Pessimistic, tx.Concurrency);
- Assert.AreEqual(TransactionIsolation.ReadCommitted, tx.Isolation);
- Assert.AreEqual(3500, tx.Timeout.TotalMilliseconds);
- Assert.AreEqual(startTime2, tx.StartTime);
-
- Thread.Sleep(100);
-
- tx = Transactions.TxStart(TransactionConcurrency.Optimistic, TransactionIsolation.RepeatableRead,
- TimeSpan.FromMilliseconds(2500), 100);
-
- Assert.IsFalse(tx.IsRollbackOnly);
- Assert.AreEqual(TransactionConcurrency.Optimistic, tx.Concurrency);
- Assert.AreEqual(TransactionIsolation.RepeatableRead, tx.Isolation);
- Assert.AreEqual(2500, tx.Timeout.TotalMilliseconds);
- Assert.AreEqual(TransactionState.Active, tx.State);
- Assert.IsTrue(tx.StartTime > startTime2);
-
- DateTime startTime3 = tx.StartTime;
-
- tx.Commit();
-
- Assert.IsFalse(tx.IsRollbackOnly);
- Assert.AreEqual(TransactionState.Committed, tx.State);
- Assert.AreEqual(TransactionConcurrency.Optimistic, tx.Concurrency);
- Assert.AreEqual(TransactionIsolation.RepeatableRead, tx.Isolation);
- Assert.AreEqual(2500, tx.Timeout.TotalMilliseconds);
- Assert.AreEqual(startTime3, tx.StartTime);
- }
-
- [Test]
- public void TestTxRollbackOnly()
- {
- if (!TxEnabled())
- return;
-
- var cache = Cache();
-
- cache.Put(1, 1);
-
- cache.Put(2, 2);
-
- ITransaction tx = Transactions.TxStart();
-
- cache.Put(1, 10);
-
- cache.Put(2, 20);
-
- Assert.IsFalse(tx.IsRollbackOnly);
-
- tx.SetRollbackonly();
-
- Assert.IsTrue(tx.IsRollbackOnly);
-
- Assert.AreEqual(TransactionState.MarkedRollback, tx.State);
-
- try
- {
- tx.Commit();
-
- Assert.Fail("Commit must fail.");
- }
- catch (IgniteException e)
- {
- Console.WriteLine("Expected exception: " + e);
- }
-
- tx.Dispose();
-
- Assert.AreEqual(TransactionState.RolledBack, tx.State);
-
- Assert.IsTrue(tx.IsRollbackOnly);
-
- Assert.AreEqual(1, cache.Get(1));
-
- Assert.AreEqual(2, cache.Get(2));
-
- tx = Transactions.Tx;
-
- Assert.IsNull(tx);
- }
-
- [Test]
- public void TestTxMetrics()
- {
- if (!TxEnabled())
- return;
-
- var cache = Cache();
-
- var startTime = DateTime.UtcNow.AddSeconds(-1);
-
- Transactions.ResetMetrics();
-
- var metrics = Transactions.GetMetrics();
-
- Assert.AreEqual(0, metrics.TxCommits);
- Assert.AreEqual(0, metrics.TxRollbacks);
-
- using (Transactions.TxStart())
- {
- cache.Put(1, 1);
- }
-
- using (var tx = Transactions.TxStart())
- {
- cache.Put(1, 1);
- tx.Commit();
- }
-
- metrics = Transactions.GetMetrics();
-
- Assert.AreEqual(1, metrics.TxCommits);
- Assert.AreEqual(1, metrics.TxRollbacks);
-
- Assert.LessOrEqual(startTime, metrics.CommitTime);
- Assert.LessOrEqual(startTime, metrics.RollbackTime);
-
- Assert.GreaterOrEqual(DateTime.UtcNow, metrics.CommitTime);
- Assert.GreaterOrEqual(DateTime.UtcNow, metrics.RollbackTime);
- }
-
- [Test]
- public void TestTxStateAndExceptions()
- {
- if (!TxEnabled())
- return;
-
- var tx = Transactions.TxStart();
-
- Assert.AreEqual(TransactionState.Active, tx.State);
-
- tx.Rollback();
-
- Assert.AreEqual(TransactionState.RolledBack, tx.State);
-
- try
- {
- tx.Commit();
- Assert.Fail();
- }
- catch (InvalidOperationException)
- {
- // Expected
- }
-
- tx = Transactions.TxStart().WithAsync();
-
- Assert.AreEqual(TransactionState.Active, tx.State);
-
- tx.Commit();
-
- tx.GetFuture().Get();
-
- Assert.AreEqual(TransactionState.Committed, tx.State);
-
- tx.Rollback(); // Illegal, but should not fail here; will fail in future
-
- try
- {
- tx.GetFuture<object>().Get();
- Assert.Fail();
- }
- catch (InvalidOperationException)
- {
- // Expected
- }
- }
-
- /// <summary>
- /// Test thraed-locals leak.
- /// </summary>
- [Test]
- [Category(TestUtils.CategoryIntensive)]
- public void TestThreadLocalLeak()
- {
- var cache = Cache<string, string>();
-
- Exception err = null;
-
- const int threadCnt = 10;
-
- Thread[] threads = new Thread[threadCnt];
-
- ThreadStart[] threadStarts = new ThreadStart[threadCnt];
-
- for (int j = 0; j < threadCnt; j++)
- {
- string key = "key" + j;
-
- threadStarts[j] = () =>
- {
- try
- {
- cache.Put(key, key);
-
- Assert.AreEqual(key, cache.Get(key));
- }
- catch (Exception e)
- {
- Interlocked.CompareExchange(ref err, e, null);
-
- Assert.Fail("Unexpected error: " + e);
- }
- };
- }
-
- for (int i = 0; i < 100 && err == null; i++)
- {
- for (int j = 0 ; j < threadCnt; j++) {
- Thread t = new Thread(threadStarts[j]);
-
- threads[j] = t;
- }
-
- foreach (Thread t in threads)
- t.Start();
-
- foreach (Thread t in threads)
- t.Join();
-
- if (i % 500 == 0)
- {
- Console.WriteLine("Iteration: " + i);
-
- GC.Collect();
- }
- }
-
- Assert.IsNull(err);
- }
-
- /**
- * Test tries to provoke garbage collection for .Net future before it was completed to verify
- * futures pinning works.
- */
- [Test]
- [Category(TestUtils.CategoryIntensive)]
- public void TestFuturesGc()
- {
- var cache = Cache().WithAsync();
-
- cache.Put(1, 1);
-
- for (int i = 0; i < 10; i++)
- {
- TestUtils.RunMultiThreaded(() =>
- {
- for (int j = 0; j < 1000; j++)
- cache.Get(1);
- }, 5);
-
- GC.Collect();
-
- cache.Get(1);
- Assert.AreEqual(1, cache.GetFuture<int>().Get());
- }
-
- Thread.Sleep(2000);
- }
-
- [Test]
- public void TestPartitions()
- {
- ICacheAffinity aff = Affinity();
-
- for (int i = 0; i < 5; i++ )
- Assert.AreEqual(CachePartitions(), aff.Partitions);
- }
-
- [Test]
- public void TestKeyPartition()
- {
- ICacheAffinity aff = Affinity();
-
- {
- ISet<int> parts = new HashSet<int>();
-
- for (int i = 0; i < 1000; i++)
- parts.Add(aff.GetPartition(i));
-
- if (LocalCache())
- Assert.AreEqual(1, parts.Count);
- else
- Assert.IsTrue(parts.Count > 10);
- }
-
- {
- ISet<int> parts = new HashSet<int>();
-
- for (int i = 0; i < 1000; i++)
- parts.Add(aff.GetPartition("key" + i));
-
- if (LocalCache())
- Assert.AreEqual(1, parts.Count);
- else
- Assert.IsTrue(parts.Count > 10);
- }
- }
-
- [Test]
- public void TestIsPrimaryOrBackup()
- {
- ICacheAffinity aff = Affinity();
-
- ICollection<IClusterNode> nodes = GetIgnite(0).GetCluster().GetNodes();
-
- Assert.IsTrue(nodes.Count > 0);
-
- IClusterNode node = nodes.First();
-
- {
- bool found = false;
-
- for (int i = 0; i < 1000; i++)
- {
- if (aff.IsPrimary(node, i))
- {
- Assert.IsTrue(aff.IsPrimaryOrBackup(node, i));
-
- found = true;
-
- if (nodes.Count > 1)
- Assert.IsFalse(aff.IsPrimary(nodes.Last(), i));
-
- break;
- }
- }
-
- Assert.IsTrue(found, "Failed to find primary key for node " + node);
- }
-
- if (nodes.Count > 1)
- {
- bool found = false;
-
- for (int i = 0; i < 1000; i++)
- {
- if (aff.IsBackup(node, i))
- {
- Assert.IsTrue(aff.IsPrimaryOrBackup(node, i));
-
- found = true;
-
- break;
- }
- }
-
- Assert.IsTrue(found, "Failed to find backup key for node " + node);
- }
- }
-
- [Test]
- public void TestNodePartitions()
- {
- ICacheAffinity aff = Affinity();
-
- ICollection<IClusterNode> nodes = GetIgnite(0).GetCluster().GetNodes();
-
- Assert.IsTrue(nodes.Count > 0);
-
- if (nodes.Count == 1)
- {
- IClusterNode node = nodes.First();
-
- int[] parts = aff.GetBackupPartitions(node);
-
- Assert.AreEqual(0, parts.Length);
-
- parts = aff.GetAllPartitions(node);
-
- Assert.AreEqual(CachePartitions(), parts.Length);
- }
- else
- {
- IList<int> allPrimaryParts = new List<int>();
- IList<int> allBackupParts = new List<int>();
- IList<int> allParts = new List<int>();
-
- foreach(IClusterNode node in nodes) {
- int[] parts = aff.GetPrimaryPartitions(node);
-
- foreach (int part in parts)
- allPrimaryParts.Add(part);
-
- parts = aff.GetBackupPartitions(node);
-
- foreach (int part in parts)
- allBackupParts.Add(part);
-
- parts = aff.GetAllPartitions(node);
-
- foreach (int part in parts)
- allParts.Add(part);
- }
-
- Assert.AreEqual(CachePartitions(), allPrimaryParts.Count);
- Assert.AreEqual(CachePartitions() * Backups(), allBackupParts.Count);
- Assert.AreEqual(CachePartitions() * (Backups() + 1), allParts.Count);
- }
- }
-
- [Test]
- public void TestAffinityKey()
- {
- ICacheAffinity aff = Affinity();
-
- Assert.AreEqual(10, aff.GetAffinityKey<int, int>(10));
-
- Assert.AreEqual("string", aff.GetAffinityKey<string, string>("string"));
- }
-
- [Test]
- public void TestMapToNode()
- {
- ICacheAffinity aff = Affinity();
-
- const int key = 1;
-
- IClusterNode node = aff.MapKeyToNode(key);
-
- Assert.IsNotNull(node);
-
- Assert.IsTrue(GetIgnite(0).GetCluster().GetNodes().Contains(node));
-
- Assert.IsTrue(aff.IsPrimary(node, key));
-
- Assert.IsTrue(aff.IsPrimaryOrBackup(node, key));
-
- Assert.IsFalse(aff.IsBackup(node, key));
-
- int part = aff.GetPartition(key);
-
- IClusterNode partNode = aff.MapPartitionToNode(part);
-
- Assert.AreEqual(node, partNode);
- }
-
- [Test]
- public void TestMapToPrimaryAndBackups()
- {
- ICacheAffinity aff = Affinity();
-
- const int key = 1;
-
- IList<IClusterNode> nodes = aff.MapKeyToPrimaryAndBackups(key);
-
- Assert.IsTrue(nodes.Count > 0);
-
- for (int i = 0; i < nodes.Count; i++)
- {
- if (i == 0)
- Assert.IsTrue(aff.IsPrimary(nodes[i], key));
- else
- Assert.IsTrue(aff.IsBackup(nodes[i], key));
- }
-
- int part = aff.GetPartition(key);
-
- IList<IClusterNode> partNodes = aff.MapPartitionToPrimaryAndBackups(part);
-
- Assert.AreEqual(nodes, partNodes);
- }
-
- [Test]
- public void TestMapKeysToNodes()
- {
- ICacheAffinity aff = Affinity();
-
- IList<int> keys = new List<int> {1, 2, 3};
-
- IDictionary<IClusterNode, IList<int>> map = aff.MapKeysToNodes(keys);
-
- Assert.IsTrue(map.Count > 0);
-
- foreach (int key in keys)
- {
- IClusterNode primary = aff.MapKeyToNode(key);
-
- Assert.IsTrue(map.ContainsKey(primary));
-
- IList<int> nodeKeys = map[primary];
-
- Assert.IsNotNull(nodeKeys);
-
- Assert.IsTrue(nodeKeys.Contains(key));
- }
- }
-
- [Test]
- public void TestMapPartitionsToNodes()
- {
- ICacheAffinity aff = Affinity();
-
- if (LocalCache())
- {
- IList<int> parts = new List<int> { 0 };
-
- IDictionary<int, IClusterNode> map = aff.MapPartitionsToNodes(parts);
-
- Assert.AreEqual(parts.Count, map.Count);
-
- Assert.AreEqual(GetIgnite(0).GetCluster().GetLocalNode(), map[0]);
- }
- else
- {
- IList<int> parts = new List<int> { 1, 2, 3 };
-
- IDictionary<int, IClusterNode> map = aff.MapPartitionsToNodes(parts);
-
- Assert.AreEqual(parts.Count, map.Count);
-
- foreach (int part in parts)
- {
- Assert.IsTrue(map.ContainsKey(part));
-
- IClusterNode primary = aff.MapPartitionToNode(part);
-
- Assert.AreEqual(primary, map[part], "Wrong node for partition: " + part);
- }
- }
- }
-
- [Test]
- public void TestKeepPortableFlag()
- {
- TestKeepPortableFlag(false);
- }
-
- [Test]
- public void TestKeepPortableFlagAsync()
- {
- TestKeepPortableFlag(true);
- }
-
- [Test]
- public void TestNearKeys()
- {
- if (!NearEnabled())
- return;
-
- const int count = 20;
-
- var cache = Cache();
- var aff = cache.Ignite.GetAffinity(cache.Name);
- var node = cache.Ignite.GetCluster().GetLocalNode();
-
- for (int i = 0; i < count; i++)
- cache.Put(i, -i - 1);
-
- var nearKeys = Enumerable.Range(0, count).Where(x => !aff.IsPrimaryOrBackup(node, x)).ToArray();
-
- var nearKeysString = nearKeys.Select(x => x.ToString()).Aggregate((x, y) => x + ", " + y);
-
- Console.WriteLine("Near keys: " + nearKeysString);
-
- foreach (var nearKey in nearKeys.Take(3))
- Assert.AreNotEqual(0, cache.Get(nearKey));
- }
-
- [Test]
- public void TestSerializable()
- {
- var cache = Cache<int, TestSerializableObject>();
-
- var obj = new TestSerializableObject {Name = "Vasya", Id = 128};
-
- cache.Put(1, obj);
-
- var resultObj = cache.Get(1);
-
- Assert.AreEqual(obj, resultObj);
- }
-
- [Test]
- public void TestInvoke()
- {
- TestInvoke(false);
- }
-
- [Test]
- public void TestInvokeAsync()
- {
- TestInvoke(true);
- }
-
- private void TestInvoke(bool async)
- {
- TestInvoke<AddArgCacheEntryProcessor>(async);
- TestInvoke<PortableAddArgCacheEntryProcessor>(async);
-
- try
- {
- TestInvoke<NonSerializableCacheEntryProcessor>(async);
- Assert.Fail();
- }
- catch (SerializationException)
- {
- // Expected
- }
- }
-
- private void TestInvoke<T>(bool async) where T: AddArgCacheEntryProcessor, new()
- {
- var cache = async ? Cache().WithAsync().WrapAsync() : Cache();
-
- cache.Clear();
-
- const int key = 1;
- const int value = 3;
- const int arg = 5;
-
- cache.Put(key, value);
-
- // Existing entry
- Assert.AreEqual(value + arg, cache.Invoke(key, new T(), arg));
- Assert.AreEqual(value + arg, cache.Get(key));
-
- // Non-existing entry
- Assert.AreEqual(arg, cache.Invoke(10, new T {Exists = false}, arg));
- Assert.AreEqual(arg, cache.Get(10));
-
- // Remove entry
- Assert.AreEqual(0, cache.Invoke(key, new T {Remove = true}, arg));
- Assert.AreEqual(0, cache.Get(key));
-
- // Test exceptions
- AssertThrowsCacheEntryProcessorException(() => cache.Invoke(key, new T {ThrowErr = true}, arg));
- AssertThrowsCacheEntryProcessorException(
- () => cache.Invoke(key, new T {ThrowErrPortable = true}, arg));
- AssertThrowsCacheEntryProcessorException(
- () => cache.Invoke(key, new T { ThrowErrNonSerializable = true }, arg), "SerializationException");
- }
-
- private static void AssertThrowsCacheEntryProcessorException(Action action, string containsText = null)
- {
- try
- {
- action();
-
- Assert.Fail();
- }
- catch (Exception ex)
- {
- Assert.IsInstanceOf<CacheEntryProcessorException>(ex);
-
- if (string.IsNullOrEmpty(containsText))
- Assert.AreEqual(ex.InnerException.Message, AddArgCacheEntryProcessor.ExceptionText);
- else
- Assert.IsTrue(ex.ToString().Contains(containsText));
- }
- }
-
- [Test]
- public void TestInvokeAll()
- {
- TestInvokeAll(false);
- }
-
- [Test]
- public void TestInvokeAllAsync()
- {
- TestInvokeAll(true);
- }
-
- private void TestInvokeAll(bool async)
- {
- for (var i = 1; i < 10; i++)
- {
- TestInvokeAll<AddArgCacheEntryProcessor>(async, i);
- TestInvokeAll<PortableAddArgCacheEntryProcessor>(async, i);
-
- try
- {
- TestInvokeAll<NonSerializableCacheEntryProcessor>(async, i);
- Assert.Fail();
- }
- catch (SerializationException)
- {
- // Expected
- }
- }
- }
-
- public void TestInvokeAll<T>(bool async, int entryCount) where T : AddArgCacheEntryProcessor, new()
- {
- var cache = async ? Cache().WithAsync().WrapAsync() : Cache();
-
- var entries = Enumerable.Range(1, entryCount).ToDictionary(x => x, x => x + 1);
-
- cache.PutAll(entries);
-
- const int arg = 5;
-
- // Existing entries
- var res = cache.InvokeAll(entries.Keys, new T(), arg);
-
- var results = res.OrderBy(x => x.Key).Select(x => x.Value.Result);
- var expectedResults = entries.OrderBy(x => x.Key).Select(x => x.Value + arg);
-
- Assert.IsTrue(results.SequenceEqual(expectedResults));
-
- var resultEntries = cache.GetAll(entries.Keys);
-
- Assert.IsTrue(resultEntries.All(x => x.Value == x.Key + 1 + arg));
-
- // Remove entries
- res = cache.InvokeAll(entries.Keys, new T {Remove = true}, arg);
-
- Assert.IsTrue(res.All(x => x.Value.Result == 0));
- Assert.AreEqual(0, cache.GetAll(entries.Keys).Count);
-
- // Non-existing entries
- res = cache.InvokeAll(entries.Keys, new T {Exists = false}, arg);
-
- Assert.IsTrue(res.All(x => x.Value.Result == arg));
- Assert.IsTrue(cache.GetAll(entries.Keys).All(x => x.Value == arg));
-
- // Test exceptions
- var errKey = entries.Keys.Reverse().Take(5).Last();
-
- TestInvokeAllException(cache, entries, new T { ThrowErr = true, ThrowOnKey = errKey }, arg, errKey);
- TestInvokeAllException(cache, entries, new T { ThrowErrPortable = true, ThrowOnKey = errKey },
- arg, errKey);
- TestInvokeAllException(cache, entries, new T { ThrowErrNonSerializable = true, ThrowOnKey = errKey },
- arg, errKey, "SerializationException");
-
- }
-
- private static void TestInvokeAllException<T>(ICache<int, int> cache, Dictionary<int, int> entries,
- T processor, int arg, int errKey, string exceptionText = null) where T : AddArgCacheEntryProcessor
- {
- var res = cache.InvokeAll(entries.Keys, processor, arg);
-
- foreach (var procRes in res)
- {
- if (procRes.Key == errKey)
- // ReSharper disable once AccessToForEachVariableInClosure
- AssertThrowsCacheEntryProcessorException(() => { var x = procRes.Value.Result; }, exceptionText);
- else
- Assert.Greater(procRes.Value.Result, 0);
- }
- }
-
- /// <summary>
- /// Test skip-store semantics.
- /// </summary>
- [Test]
- public void TestSkipStore()
- {
- CacheProxyImpl<int, int> cache = (CacheProxyImpl<int, int>)Cache();
-
- Assert.IsFalse(cache.SkipStore);
-
- // Ensure correct flag set.
- CacheProxyImpl<int, int> cacheSkipStore1 = (CacheProxyImpl<int, int>)cache.WithSkipStore();
-
- Assert.AreNotSame(cache, cacheSkipStore1);
- Assert.IsFalse(cache.SkipStore);
- Assert.IsTrue(cacheSkipStore1.SkipStore);
-
- // Ensure that the same instance is returned if flag is already set.
- CacheProxyImpl<int, int> cacheSkipStore2 = (CacheProxyImpl<int, int>)cacheSkipStore1.WithSkipStore();
-
- Assert.IsTrue(cacheSkipStore2.SkipStore);
- Assert.AreSame(cacheSkipStore1, cacheSkipStore2);
-
- // Ensure other flags are preserved.
- Assert.IsTrue(((CacheProxyImpl<int, int>)cache.WithKeepPortable<int, int>().WithSkipStore()).IsKeepPortable);
- Assert.IsTrue(cache.WithAsync().WithSkipStore().IsAsync);
- }
-
- [Test]
- public void TestCacheMetrics()
- {
- var cache = Cache();
-
- cache.Put(1, 1);
-
- var m = cache.GetMetrics();
-
- Assert.AreEqual(cache.Name, m.CacheName);
-
- Assert.AreEqual(cache.GetSize(), m.Size);
- }
-
- [Test]
- public void TestRebalance()
- {
- var cache = Cache();
-
- var fut = cache.Rebalance();
-
- Assert.IsNull(fut.Get());
- }
-
- [Test]
- public void TestCreate()
- {
- // Create a cache with random name
- var randomName = "template" + Guid.New
<TRUNCATED>
[02/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/StoreExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/StoreExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/StoreExample.cs
new file mode 100644
index 0000000..6c2b40d
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/StoreExample.cs
@@ -0,0 +1,114 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.ExamplesDll.Datagrid;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+ /// <summary>
+ /// Example demonstrating cache store.
+ /// <para />
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+ /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start example (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run with standalone Apache Ignite .Net node:
+ /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+ /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache-store.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// 2) Start example.
+ /// </summary>
+ class StoreExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache-store.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Cache store example started.");
+
+ var cache = ignite.GetCache<int, Employee>(null);
+
+ // Clean up caches on all nodes before run.
+ cache.Clear();
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Cleared values from cache.");
+ Console.WriteLine(">>> Current cache size: " + cache.GetSize());
+
+ // Load entries from store which pass provided filter.
+ cache.LoadCache(new EmployeeStorePredicate());
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Loaded entry from store through ICache.LoadCache().");
+ Console.WriteLine(">>> Current cache size: " + cache.GetSize());
+
+ // Load entry from store calling ICache.Get() method.
+ Employee emp = cache.Get(2);
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Loaded entry from store through ICache.Get(): " + emp);
+ Console.WriteLine(">>> Current cache size: " + cache.GetSize());
+
+ // Put an entry to the cache
+ cache.Put(3, new Employee(
+ "James Wilson",
+ 12500,
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ new List<string> { "Human Resources", "Customer Service" }
+ ));
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Put entry to cache. ");
+ Console.WriteLine(">>> Current cache size: " + cache.GetSize());
+
+ // Clear values again.
+ cache.Clear();
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Cleared values from cache again.");
+ Console.WriteLine(">>> Current cache size: " + cache.GetSize());
+
+ // Read values from cache after clear.
+ Console.WriteLine();
+ Console.WriteLine(">>> Read values after clear:");
+
+ for (int i = 1; i <= 3; i++)
+ Console.WriteLine(">>> Key=" + i + ", value=" + cache.Get(i));
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/TransactionExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
new file mode 100644
index 0000000..6be3523
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
@@ -0,0 +1,104 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Transactions;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+ /// <summary>
+ /// This example demonstrates how to use transactions on Apache cache.
+ /// <para />
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+ /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start example (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run with standalone Apache Ignite .Net node:
+ /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+ /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// 2) Start example.
+ /// </summary>
+ class TransactionExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Transaction example started.");
+
+ var cache = ignite.GetCache<int, Account>("tx");
+
+ // Clean up caches on all nodes before run.
+ cache.Clear();
+
+ // Initialize.
+ cache.Put(1, new Account(1, 100));
+ cache.Put(2, new Account(2, 200));
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Accounts before transfer: ");
+ Console.WriteLine(">>> " + cache.Get(1));
+ Console.WriteLine(">>> " + cache.Get(2));
+ Console.WriteLine();
+
+ // Transfer money between accounts in a single transaction.
+ using (var tx = cache.Ignite.GetTransactions().TxStart(TransactionConcurrency.Pessimistic,
+ TransactionIsolation.RepeatableRead))
+ {
+ Account acc1 = cache.Get(1);
+ Account acc2 = cache.Get(2);
+
+ acc1.Balance += 100;
+ acc2.Balance -= 100;
+
+ cache.Put(1, acc1);
+ cache.Put(2, acc2);
+
+ tx.Commit();
+ }
+
+ Console.WriteLine(">>> Transfer finished.");
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Accounts after transfer: ");
+ Console.WriteLine(">>> " + cache.Get(1));
+ Console.WriteLine(">>> " + cache.Get(2));
+ Console.WriteLine();
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Events/EventsExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Events/EventsExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Events/EventsExample.cs
new file mode 100644
index 0000000..83802cc
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Events/EventsExample.cs
@@ -0,0 +1,118 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Events;
+using Apache.Ignite.ExamplesDll.Compute;
+using Apache.Ignite.ExamplesDll.Events;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Events
+{
+ /// <summary>
+ /// Example demonstrating Ignite events.
+ /// <para />
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+ /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start example (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run with standalone Apache Ignite .Net node:
+ /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+ /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-compute.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// 2) Start example.
+ /// </summary>
+ public class EventsExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
+ JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine(">>> Events example started.");
+ Console.WriteLine();
+
+ // Local listen example
+ Console.WriteLine(">>> Listening for a local event...");
+
+ var listener = new LocalListener();
+ ignite.GetEvents().LocalListen(listener, EventType.EvtsTaskExecution);
+
+ ExecuteTask(ignite);
+
+ ignite.GetEvents().StopLocalListen(listener);
+
+ Console.WriteLine(">>> Received events count: " + listener.EventsReceived);
+ Console.WriteLine();
+
+ // Remote listen example (start standalone nodes for better demonstration)
+ Console.WriteLine(">>> Listening for remote events...");
+
+ var localListener = new LocalListener();
+ var remoteFilter = new RemoteFilter();
+
+ var listenId = ignite.GetEvents().RemoteListen(localListener: localListener,
+ remoteFilter: remoteFilter, types: EventType.EvtsJobExecution);
+
+ ExecuteTask(ignite);
+
+ ignite.GetEvents().StopRemoteListen(listenId);
+
+ Console.WriteLine(">>> Received events count: " + localListener.EventsReceived);
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+
+ /// <summary>
+ /// Executes a task to generate events.
+ /// </summary>
+ /// <param name="ignite">Ignite instance.</param>
+ private static void ExecuteTask(IIgnite ignite)
+ {
+ var employees = Enumerable.Range(1, 10).SelectMany(x => new[]
+ {
+ new Employee("Allison Mathis",
+ 25300,
+ new Address("2702 Freedom Lane, San Francisco, CA", 94109),
+ new[] {"Development"}),
+
+ new Employee("Breana Robbin",
+ 6500,
+ new Address("3960 Sundown Lane, Austin, TX", 78130),
+ new[] {"Sales"})
+ }).ToArray();
+
+ ignite.GetCompute().Execute(new AverageSalaryTask(), employees);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Messaging/MessagingExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Messaging/MessagingExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Messaging/MessagingExample.cs
new file mode 100644
index 0000000..a24c47c
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Messaging/MessagingExample.cs
@@ -0,0 +1,112 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using Apache.Ignite.Core;
+using Apache.Ignite.ExamplesDll.Messaging;
+
+namespace Apache.Ignite.Examples.Messaging
+{
+ /// <summary>
+ /// Example demonstrating Ignite messaging. Should be run with standalone Apache Ignite .Net node.
+ /// <para />
+ /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+ /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-compute.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// 2) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+ /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+ /// 3) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 4) Start example (F5 or Ctrl+F5).
+ /// </summary>
+ public class MessagingExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ var remotes = ignite.GetCluster().ForRemotes();
+
+ if (remotes.GetNodes().Count == 0)
+ {
+ Console.WriteLine(">>> This example requires remote nodes to be started.");
+ Console.WriteLine(">>> Please start at least 1 remote node.");
+ Console.WriteLine(">>> Refer to example's documentation for details on configuration.");
+ }
+ else
+ {
+ Console.WriteLine(">>> Messaging example started.");
+ Console.WriteLine();
+
+ // Set up local listeners
+ var localMessaging = ignite.GetCluster().ForLocal().GetMessaging();
+
+ var msgCount = remotes.GetNodes().Count * 10;
+
+ var orderedCounter = new CountdownEvent(msgCount);
+ var unorderedCounter = new CountdownEvent(msgCount);
+
+ localMessaging.LocalListen(new LocalListener(unorderedCounter), Topic.Unordered);
+ localMessaging.LocalListen(new LocalListener(orderedCounter), Topic.Ordered);
+
+ // Set up remote listeners
+ var remoteMessaging = remotes.GetMessaging();
+
+ remoteMessaging.RemoteListen(new RemoteUnorderedListener(), Topic.Unordered);
+ remoteMessaging.RemoteListen(new RemoteOrderedListener(), Topic.Ordered);
+
+ // Send unordered
+ Console.WriteLine(">>> Sending unordered messages...");
+
+ for (var i = 0; i < 10; i++)
+ remoteMessaging.Send(i, Topic.Unordered);
+
+ Console.WriteLine(">>> Finished sending unordered messages.");
+
+ // Send ordered
+ Console.WriteLine(">>> Sending ordered messages...");
+
+ for (var i = 0; i < 10; i++)
+ remoteMessaging.SendOrdered(i, Topic.Ordered);
+
+ Console.WriteLine(">>> Finished sending ordered messages.");
+
+ Console.WriteLine(">>> Check output on all nodes for message printouts.");
+ Console.WriteLine(">>> Waiting for messages acknowledgements from all remote nodes...");
+
+ unorderedCounter.Wait();
+ orderedCounter.Wait();
+ }
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Misc/LifecycleExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Misc/LifecycleExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Misc/LifecycleExample.cs
new file mode 100644
index 0000000..2d319e8
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Misc/LifecycleExample.cs
@@ -0,0 +1,109 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Lifecycle;
+using Apache.Ignite.Core.Resource;
+
+namespace Apache.Ignite.Examples.Misc
+{
+ /// <summary>
+ /// This example shows how to provide your own <see cref="ILifecycleBean"/> implementation
+ /// to be able to hook into Apache lifecycle. Example bean will output occurred lifecycle
+ /// events to the console.
+ /// <para />
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+ /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start example (F5 or Ctrl+F5).
+ /// </summary>
+ public class LifecycleExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Lifecycle example started.");
+
+ // Create new configuration.
+ var lifecycleExampleBean = new LifecycleExampleBean();
+
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" },
+ LifecycleBeans = new List<ILifecycleBean> { lifecycleExampleBean }
+ };
+
+ // Provide lifecycle bean to configuration.
+ using (Ignition.Start(cfg))
+ {
+ // Make sure that lifecycle bean was notified about Ignite startup.
+ Console.WriteLine();
+ Console.WriteLine(">>> Started (should be true): " + lifecycleExampleBean.Started);
+ }
+
+ // Make sure that lifecycle bean was notified about Ignite stop.
+ Console.WriteLine();
+ Console.WriteLine(">>> Started (should be false): " + lifecycleExampleBean.Started);
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+
+ /// <summary>
+ /// Sample lifecycle bean implementation.
+ /// </summary>
+ private class LifecycleExampleBean : ILifecycleBean
+ {
+ /** Auto-injected Ignite instance. */
+ [InstanceResource]
+#pragma warning disable 649
+ private IIgnite _ignite;
+#pragma warning restore 649
+
+ /** <inheritDoc /> */
+ public void OnLifecycleEvent(LifecycleEventType evt)
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Ignite lifecycle event occurred: " + evt);
+ Console.WriteLine(">>> Ignite name: " + (_ignite != null ? _ignite.Name : "not available"));
+
+ if (evt == LifecycleEventType.AfterNodeStart)
+ Started = true;
+ else if (evt == LifecycleEventType.AfterNodeStop)
+ Started = false;
+ }
+
+ /// <summary>
+ /// Started flag.
+ /// </summary>
+ public bool Started
+ {
+ get;
+ private set;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Properties/AssemblyInfo.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..555a35f
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("Apache Ignite Examples")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("Apache Ignite")]
+[assembly: AssemblyCopyright("Copyright © 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+[assembly: ComVisible(false)]
+
+[assembly: Guid("41a0cb95-3435-4c78-b867-900b28e2c9ee")]
+
+[assembly: AssemblyVersion("1.5.0")]
+[assembly: AssemblyFileVersion("1.5.0")]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Services/IMapService.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Services/IMapService.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Services/IMapService.cs
new file mode 100644
index 0000000..7253a0b
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Services/IMapService.cs
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+
+using Apache.Ignite.ExamplesDll.Services;
+
+namespace Apache.Ignite.Examples.Services
+{
+ /// <summary>
+ /// Interface for service proxy interaction.
+ /// Actual service class (<see cref="MapService{TK,TV}"/>) does not have to implement this interface.
+ /// Target method/property will be searched by signature (name, arguments).
+ /// </summary>
+ public interface IMapService<TK, TV>
+ {
+ /// <summary>
+ /// Puts an entry to the map.
+ /// </summary>
+ /// <param name="key">The key.</param>
+ /// <param name="value">The value.</param>
+ void Put(TK key, TV value);
+
+ /// <summary>
+ /// Gets an entry from the map.
+ /// </summary>
+ /// <param name="key">The key.</param>
+ /// <returns>Entry value.</returns>
+ TV Get(TK key);
+
+ /// <summary>
+ /// Clears the map.
+ /// </summary>
+ void Clear();
+
+ /// <summary>
+ /// Gets the size of the map.
+ /// </summary>
+ /// <value>
+ /// The size.
+ /// </value>
+ int Size { get; }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Services/ServicesExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Services/ServicesExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Services/ServicesExample.cs
new file mode 100644
index 0000000..6d0ddd0
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Services/ServicesExample.cs
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.ExamplesDll.Services;
+
+namespace Apache.Ignite.Examples.Services
+{
+ /// <summary>
+ /// Example demonstrating Ignite services.
+ /// <para />
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+ /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start example (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run with standalone Apache Ignite .Net node:
+ /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+ /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// 2) Start example.
+ /// </summary>
+ public class ServicesExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
+ JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine(">>> Services example started.");
+ Console.WriteLine();
+
+ // Deploy a service
+ var svc = new MapService<int, string>();
+ Console.WriteLine(">>> Deploying service to all nodes...");
+ ignite.GetServices().DeployNodeSingleton("service", svc);
+
+ // Get a sticky service proxy so that we will always be contacting the same remote node.
+ var prx = ignite.GetServices().GetServiceProxy<IMapService<int, string>>("service", true);
+
+ for (var i = 0; i < 10; i++)
+ prx.Put(i, i.ToString());
+
+ var mapSize = prx.Size;
+
+ Console.WriteLine(">>> Map service size: " + mapSize);
+
+ ignite.GetServices().CancelAll();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
new file mode 100644
index 0000000..cb2ff6f
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{DFB08363-202E-412D-8812-349EF10A8702}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Apache.Ignite.ExamplesDll</RootNamespace>
+ <AssemblyName>Apache.Ignite.ExamplesDll</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Debug\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Release\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\x86\Debug\</OutputPath>
+ <PlatformTarget>x86</PlatformTarget>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+ <OutputPath>bin\x86\Release\</OutputPath>
+ <PlatformTarget>x86</PlatformTarget>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Compute\AverageSalaryJob.cs" />
+ <Compile Include="Compute\AverageSalaryTask.cs" />
+ <Compile Include="Compute\CharacterCountClosure.cs" />
+ <Compile Include="Compute\CharacterCountReducer.cs" />
+ <Compile Include="Datagrid\EmployeeStorePredicate.cs" />
+ <Compile Include="Datagrid\ContinuousQueryFilter.cs" />
+ <Compile Include="Datagrid\EmployeeStore.cs" />
+ <Compile Include="Events\LocalListener.cs" />
+ <Compile Include="Events\RemoteFilter.cs" />
+ <Compile Include="Messaging\LocalListener.cs" />
+ <Compile Include="Messaging\RemoteOrderedListener.cs" />
+ <Compile Include="Messaging\RemoteUnorderedListener.cs" />
+ <Compile Include="Messaging\Topic.cs" />
+ <Compile Include="Portable\Account.cs" />
+ <Compile Include="Portable\Address.cs" />
+ <Compile Include="Portable\Employee.cs" />
+ <Compile Include="Portable\EmployeeKey.cs" />
+ <Compile Include="Portable\Organization.cs" />
+ <Compile Include="Portable\OrganizationType.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Services\MapService.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\Apache.Ignite.Core\Apache.Ignite.Core.csproj">
+ <Project>{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}</Project>
+ <Name>Apache.Ignite.Core</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csprojrel
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csprojrel b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csprojrel
new file mode 100644
index 0000000..fa6b71c
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csprojrel
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{DFB08363-202E-412D-8812-349EF10A8702}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Apache.Ignite.ExamplesDll</RootNamespace>
+ <AssemblyName>Apache.Ignite.ExamplesDll</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Debug\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Release\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\x86\Debug\</OutputPath>
+ <PlatformTarget>x86</PlatformTarget>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+ <OutputPath>bin\x86\Release\</OutputPath>
+ <PlatformTarget>x86</PlatformTarget>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Apache.Ignite.Core">
+ <HintPath>..\..\Apache.Ignite\bin\$(Platform)\$(Configuration)\Apache.Ignite.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Compute\AverageSalaryJob.cs" />
+ <Compile Include="Compute\AverageSalaryTask.cs" />
+ <Compile Include="Compute\CharacterCountClosure.cs" />
+ <Compile Include="Compute\CharacterCountReducer.cs" />
+ <Compile Include="Datagrid\EmployeeStorePredicate.cs" />
+ <Compile Include="Datagrid\ContinuousQueryFilter.cs" />
+ <Compile Include="Datagrid\EmployeeStore.cs" />
+ <Compile Include="Events\LocalListener.cs" />
+ <Compile Include="Events\RemoteFilter.cs" />
+ <Compile Include="Messaging\LocalListener.cs" />
+ <Compile Include="Messaging\RemoteOrderedListener.cs" />
+ <Compile Include="Messaging\RemoteUnorderedListener.cs" />
+ <Compile Include="Messaging\Topic.cs" />
+ <Compile Include="Portable\Account.cs" />
+ <Compile Include="Portable\Address.cs" />
+ <Compile Include="Portable\Employee.cs" />
+ <Compile Include="Portable\EmployeeKey.cs" />
+ <Compile Include="Portable\Organization.cs" />
+ <Compile Include="Portable\OrganizationType.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Services\MapService.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs
new file mode 100644
index 0000000..e4713d4
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs
@@ -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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Apache.Ignite.Core.Compute;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.ExamplesDll.Compute
+{
+ /// <summary>
+ /// Average salary job.
+ /// </summary>
+ [Serializable]
+ public class AverageSalaryJob : ComputeJobAdapter<Tuple<long, int>>
+ {
+ /// <summary> Employees. </summary>
+ private readonly ICollection<Employee> _employees = new List<Employee>();
+
+ /// <summary>
+ /// Adds employee.
+ /// </summary>
+ /// <param name="employee">Employee.</param>
+ public void Add(Employee employee)
+ {
+ _employees.Add(employee);
+ }
+
+ /// <summary>
+ /// Execute the job.
+ /// </summary>
+ /// <returns>Job result: tuple with total salary in the first item and employees count in the second.</returns>
+ override public Tuple<long, int> Execute()
+ {
+ long sum = 0;
+ int count = 0;
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Executing salary job for " + _employees.Count + " employee(s) ...");
+ Console.WriteLine();
+
+ foreach (Employee emp in _employees)
+ {
+ sum += emp.Salary;
+ count++;
+ }
+
+ return new Tuple<long, int>(sum, count);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs
new file mode 100644
index 0000000..f8acb01
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Apache.Ignite.Core.Compute;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.ExamplesDll.Compute
+{
+ /// <summary>
+ /// Average salary task.
+ /// </summary>
+ public class AverageSalaryTask : ComputeTaskSplitAdapter<ICollection<Employee>, Tuple<long, int>, long>
+ {
+ /// <summary>
+ /// Split the task distributing employees between several jobs.
+ /// </summary>
+ /// <param name="gridSize">Number of available grid nodes.</param>
+ /// <param name="arg">Task execution argument.</param>
+ protected override ICollection<IComputeJob<Tuple<long, int>>> Split(int gridSize, ICollection<Employee> arg)
+ {
+ ICollection<Employee> employees = arg;
+
+ var jobs = new List<IComputeJob<Tuple<long, int>>>(gridSize);
+
+ int count = 0;
+
+ foreach (Employee employee in employees)
+ {
+ int idx = count++ % gridSize;
+
+ AverageSalaryJob job;
+
+ if (idx >= jobs.Count)
+ {
+ job = new AverageSalaryJob();
+
+ jobs.Add(job);
+ }
+ else
+ job = (AverageSalaryJob) jobs[idx];
+
+ job.Add(employee);
+ }
+
+ return jobs;
+ }
+
+ /// <summary>
+ /// Calculate average salary after all jobs are finished.
+ /// </summary>
+ /// <param name="results">Job results.</param>
+ /// <returns>Average salary.</returns>
+ public override long Reduce(IList<IComputeJobResult<Tuple<long, int>>> results)
+ {
+ long sum = 0;
+ int count = 0;
+
+ foreach (var t in results.Select(result => result.Data()))
+ {
+ sum += t.Item1;
+ count += t.Item2;
+ }
+
+ return sum / count;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/CharacterCountClosure.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/CharacterCountClosure.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/CharacterCountClosure.cs
new file mode 100644
index 0000000..2823221
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/CharacterCountClosure.cs
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+
+using System;
+using Apache.Ignite.Core.Compute;
+
+namespace Apache.Ignite.ExamplesDll.Compute
+{
+ /// <summary>
+ /// Closure counting characters in a string.
+ /// </summary>
+ [Serializable]
+ public class CharacterCountClosure : IComputeFunc<string, int>
+ {
+ /// <summary>
+ /// Calculate character count of the given word.
+ /// </summary>
+ /// <param name="arg">Word.</param>
+ /// <returns>Character count.</returns>
+ public int Invoke(string arg)
+ {
+ int len = arg.Length;
+
+ Console.WriteLine("Character count in word \"" + arg + "\": " + len);
+
+ return len;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/CharacterCountReducer.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/CharacterCountReducer.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/CharacterCountReducer.cs
new file mode 100644
index 0000000..6825046
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/CharacterCountReducer.cs
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using Apache.Ignite.Core.Compute;
+
+namespace Apache.Ignite.ExamplesDll.Compute
+{
+ /// <summary>
+ /// Character count reducer which collects individual string lengths and aggregate them.
+ /// </summary>
+ public class CharacterCountReducer : IComputeReducer<int, int>
+ {
+ /// <summary> Total length. </summary>
+ private int _length;
+
+ /// <summary>
+ /// Collect character counts of distinct words.
+ /// </summary>
+ /// <param name="res">Character count of a distinct word.</param>
+ /// <returns><c>True</c> to continue collecting results until all closures are finished.</returns>
+ public bool Collect(int res)
+ {
+ _length += res;
+
+ return true;
+ }
+
+ /// <summary>
+ /// Reduce all collected results.
+ /// </summary>
+ /// <returns>Total character count.</returns>
+ public int Reduce()
+ {
+ return _length;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Datagrid/ContinuousQueryFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Datagrid/ContinuousQueryFilter.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Datagrid/ContinuousQueryFilter.cs
new file mode 100644
index 0000000..8c05f42
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Datagrid/ContinuousQueryFilter.cs
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+using System;
+using Apache.Ignite.Core.Cache.Event;
+
+namespace Apache.Ignite.ExamplesDll.Datagrid
+{
+ /// <summary>
+ /// Filter for continuous query example.
+ /// </summary>
+ [Serializable]
+ public class ContinuousQueryFilter : ICacheEntryEventFilter<int, string>
+ {
+ /// <summary> Threshold. </summary>
+ private readonly int _threshold;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="threshold">Threshold.</param>
+ public ContinuousQueryFilter(int threshold)
+ {
+ _threshold = threshold;
+ }
+
+ /// <summary>
+ /// Evaluates cache entry event.
+ /// </summary>
+ /// <param name="evt">Event.</param>
+ public bool Evaluate(ICacheEntryEvent<int, string> evt)
+ {
+ return evt.Key >= _threshold;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs
new file mode 100644
index 0000000..742b048
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using Apache.Ignite.Core.Cache;
+using Apache.Ignite.Core.Cache.Store;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.ExamplesDll.Datagrid
+{
+ /// <summary>
+ /// Example cache store implementation.
+ /// </summary>
+ public class EmployeeStore : CacheStoreAdapter
+ {
+ /// <summary>
+ /// Dictionary representing the store.
+ /// </summary>
+ private readonly ConcurrentDictionary<object, object> _db = new ConcurrentDictionary<object, object>(
+ new List<KeyValuePair<object, object>>
+ {
+ new KeyValuePair<object, object>(1, new Employee(
+ "Allison Mathis",
+ 25300,
+ new Address("2702 Freedom Lane, San Francisco, CA", 94109),
+ new List<string> {"Development"}
+ )),
+
+ new KeyValuePair<object, object>(2, new Employee(
+ "Breana Robbin",
+ 6500,
+ new Address("3960 Sundown Lane, Austin, TX", 78130),
+ new List<string> {"Sales"}
+ ))
+ });
+
+ /// <summary>
+ /// Loads all values from underlying persistent storage.
+ /// This method gets called as a result of <see cref="ICache{TK,TV}.LoadCache"/> call.
+ /// </summary>
+ /// <param name="act">Action that loads a cache entry.</param>
+ /// <param name="args">Optional arguments.</param>
+ public override void LoadCache(Action<object, object> act, params object[] args)
+ {
+ // Iterate over whole underlying store and call act on each entry to load it into the cache.
+ foreach (var entry in _db)
+ act(entry.Key, entry.Value);
+ }
+
+ /// <summary>
+ /// Loads multiple objects from the cache store.
+ /// This method gets called as a result of <see cref="ICache{K,V}.GetAll"/> call.
+ /// </summary>
+ /// <param name="keys">Keys to load.</param>
+ /// <returns>
+ /// A map of key, values to be stored in the cache.
+ /// </returns>
+ public override IDictionary LoadAll(ICollection keys)
+ {
+ var result = new Dictionary<object, object>();
+
+ foreach (var key in keys)
+ result[key] = Load(key);
+
+ return result;
+ }
+
+ /// <summary>
+ /// Loads an object from the cache store.
+ /// This method gets called as a result of <see cref="ICache{K,V}.Get"/> call.
+ /// </summary>
+ /// <param name="key">Key to load.</param>
+ /// <returns>Loaded value</returns>
+ public override object Load(object key)
+ {
+ object val;
+
+ _db.TryGetValue(key, out val);
+
+ return val;
+ }
+
+ /// <summary>
+ /// Write key-value pair to store.
+ /// </summary>
+ /// <param name="key">Key to write.</param>
+ /// <param name="val">Value to write.</param>
+ public override void Write(object key, object val)
+ {
+ _db[key] = val;
+ }
+
+ /// <summary>
+ /// Delete cache entry form store.
+ /// </summary>
+ /// <param name="key">Key to delete.</param>
+ public override void Delete(object key)
+ {
+ object val;
+
+ _db.TryRemove(key, out val);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs
new file mode 100644
index 0000000..a585e5e
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+using System;
+using Apache.Ignite.Core.Cache;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.ExamplesDll.Datagrid
+{
+ /// <summary>
+ /// Example cache entry predicate.
+ /// </summary>
+ [Serializable]
+ public class EmployeeStorePredicate : ICacheEntryFilter<int, Employee>
+ {
+ /// <summary>
+ /// Returns a value indicating whether provided cache entry satisfies this predicate.
+ /// </summary>
+ /// <param name="entry">Cache entry.</param>
+ /// <returns>Value indicating whether provided cache entry satisfies this predicate.</returns>
+ public bool Invoke(ICacheEntry<int, Employee> entry)
+ {
+ return entry.Key == 1;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Events/LocalListener.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
new file mode 100644
index 0000000..8a28355
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Threading;
+using Apache.Ignite.Core.Events;
+
+namespace Apache.Ignite.ExamplesDll.Events
+{
+ /// <summary>
+ /// Local event listener.
+ /// </summary>
+ public class LocalListener : IEventFilter<IEvent>
+ {
+ /** Сount of received events. */
+ private int _eventsReceived;
+
+ /// <summary>
+ /// Gets the count of received events.
+ /// </summary>
+ public int EventsReceived
+ {
+ get { return _eventsReceived; }
+ }
+
+ /// <summary>
+ /// Determines whether specified event passes this filter.
+ /// </summary>
+ /// <param name="nodeId">Node identifier.</param>
+ /// <param name="evt">Event.</param>
+ /// <returns>Value indicating whether specified event passes this filter.</returns>
+ public bool Invoke(Guid nodeId, IEvent evt)
+ {
+ Interlocked.Increment(ref _eventsReceived);
+
+ Console.WriteLine("Local listener received an event [evt={0}]", evt.Name);
+
+ return true;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs
new file mode 100644
index 0000000..db3204a
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs
@@ -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.
+ */
+
+using System;
+using Apache.Ignite.Core.Events;
+
+namespace Apache.Ignite.ExamplesDll.Events
+{
+ /// <summary>
+ /// Remote event filter.
+ /// </summary>
+ [Serializable]
+ public class RemoteFilter : IEventFilter<IEvent>
+ {
+ /// <summary>
+ /// Determines whether specified event passes this filter.
+ /// </summary>
+ /// <param name="nodeId">Node identifier.</param>
+ /// <param name="evt">Event.</param>
+ /// <returns>Value indicating whether specified event passes this filter.</returns>
+ public bool Invoke(Guid nodeId, IEvent evt)
+ {
+ Console.WriteLine("Remote filter received event [evt={0}]", evt.Name);
+
+ return evt is JobEvent;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs
new file mode 100644
index 0000000..7659bb4
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Threading;
+using Apache.Ignite.Core.Messaging;
+
+namespace Apache.Ignite.ExamplesDll.Messaging
+{
+ /// <summary>
+ /// Local message listener which signals countdown event on each received message.
+ /// </summary>
+ public class LocalListener : IMessageFilter<int>
+ {
+ /** Countdown event. */
+ private readonly CountdownEvent _countdown;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="LocalListener"/> class.
+ /// </summary>
+ /// <param name="countdown">The countdown event.</param>
+ public LocalListener(CountdownEvent countdown)
+ {
+ if (countdown == null)
+ throw new ArgumentNullException("countdown");
+
+ _countdown = countdown;
+ }
+
+ /// <summary>
+ /// Receives a message and returns a value
+ /// indicating whether provided message and node id satisfy this predicate.
+ /// Returning false will unsubscribe this listener from future notifications.
+ /// </summary>
+ /// <param name="nodeId">Node identifier.</param>
+ /// <param name="message">Message.</param>
+ /// <returns>Value indicating whether provided message and node id satisfy this predicate.</returns>
+ public bool Invoke(Guid nodeId, int message)
+ {
+ _countdown.Signal();
+
+ return !_countdown.IsSet;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs
new file mode 100644
index 0000000..8ae5ac1
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+using System;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Messaging;
+using Apache.Ignite.Core.Resource;
+
+namespace Apache.Ignite.ExamplesDll.Messaging
+{
+ /// <summary>
+ /// Listener for Ordered topic.
+ /// </summary>
+ [Serializable]
+ public class RemoteOrderedListener : IMessageFilter<int>
+ {
+ /** Injected Ignite instance. */
+ [InstanceResource]
+#pragma warning disable 649
+ private readonly IIgnite _ignite;
+#pragma warning restore 649
+
+ /// <summary>
+ /// Receives a message and returns a value
+ /// indicating whether provided message and node id satisfy this predicate.
+ /// Returning false will unsubscribe this listener from future notifications.
+ /// </summary>
+ /// <param name="nodeId">Node identifier.</param>
+ /// <param name="message">Message.</param>
+ /// <returns>Value indicating whether provided message and node id satisfy this predicate.</returns>
+ public bool Invoke(Guid nodeId, int message)
+ {
+ Console.WriteLine("Received ordered message [msg={0}, fromNodeId={1}]", message, nodeId);
+
+ _ignite.GetCluster().ForNodeIds(nodeId).GetMessaging().Send(message, Topic.Ordered);
+
+ return true;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs
new file mode 100644
index 0000000..166dbd6
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+using System;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Messaging;
+using Apache.Ignite.Core.Resource;
+
+namespace Apache.Ignite.ExamplesDll.Messaging
+{
+ /// <summary>
+ /// Listener for Unordered topic.
+ /// </summary>
+ [Serializable]
+ public class RemoteUnorderedListener : IMessageFilter<int>
+ {
+ /** Injected Ignite instance. */
+ [InstanceResource]
+#pragma warning disable 649
+ private readonly IIgnite _ignite;
+#pragma warning restore 649
+
+ /// <summary>
+ /// Receives a message and returns a value
+ /// indicating whether provided message and node id satisfy this predicate.
+ /// Returning false will unsubscribe this listener from future notifications.
+ /// </summary>
+ /// <param name="nodeId">Node identifier.</param>
+ /// <param name="message">Message.</param>
+ /// <returns>Value indicating whether provided message and node id satisfy this predicate.</returns>
+ public bool Invoke(Guid nodeId, int message)
+ {
+ Console.WriteLine("Received unordered message [msg={0}, fromNodeId={1}]", message, nodeId);
+
+ _ignite.GetCluster().ForNodeIds(nodeId).GetMessaging().Send(message, Topic.Unordered);
+
+ return true;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/Topic.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/Topic.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/Topic.cs
new file mode 100644
index 0000000..bda0bfe
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/Topic.cs
@@ -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.
+ */
+
+namespace Apache.Ignite.ExamplesDll.Messaging
+{
+ /// <summary>
+ /// Message topics.
+ /// </summary>
+ public static class Topic
+ {
+ public const int Ordered = 1;
+ public const int Unordered = 2;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Account.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Account.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Account.cs
new file mode 100644
index 0000000..8e247e3
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Account.cs
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+
+using System;
+
+namespace Apache.Ignite.ExamplesDll.Portable
+{
+ /// <summary>
+ /// Account object. Used in transaction example.
+ /// </summary>
+ [Serializable]
+ public class Account
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="id">Account ID.</param>
+ /// <param name="balance">Account balance.</param>
+ public Account(int id, decimal balance)
+ {
+ Id = id;
+ Balance = balance;
+ }
+
+ /// <summary>
+ /// Account ID.
+ /// </summary>
+ public int Id { get; set; }
+
+ /// <summary>
+ /// Account balance.
+ /// </summary>
+ public decimal Balance { get; set; }
+
+ /// <summary>
+ /// Returns a string that represents the current object.
+ /// </summary>
+ /// <returns>
+ /// A string that represents the current object.
+ /// </returns>
+ override public String ToString()
+ {
+ return string.Format("{0} [id={1}, balance={2}]", typeof(Account).Name, Id, Balance);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Address.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Address.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Address.cs
new file mode 100644
index 0000000..ca069cb
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Address.cs
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+using System;
+using Apache.Ignite.Core.Portable;
+
+namespace Apache.Ignite.ExamplesDll.Portable
+{
+ /// <summary>
+ /// Address.
+ /// </summary>
+ [Serializable]
+ public class Address : IPortableMarshalAware
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="street">Street.</param>
+ /// <param name="zip">ZIP code.</param>
+ public Address(string street, int zip)
+ {
+ Street = street;
+ Zip = zip;
+ }
+
+ /// <summary>
+ /// Street.
+ /// </summary>
+ public string Street { get; set; }
+
+ /// <summary>
+ /// ZIP code.
+ /// </summary>
+ public int Zip { get; set; }
+
+ /// <summary>
+ /// Writes this object to the given writer.
+ /// </summary>
+ /// <param name="writer">Writer.</param>
+ public void WritePortable(IPortableWriter writer)
+ {
+ writer.WriteString("street", Street);
+ writer.WriteInt("zip", Zip);
+ }
+
+ /// <summary>
+ /// Reads this object from the given reader.
+ /// </summary>
+ /// <param name="reader">Reader.</param>
+ public void ReadPortable(IPortableReader reader)
+ {
+ Street = reader.ReadString("street");
+ Zip = reader.ReadInt("zip");
+ }
+
+ /// <summary>
+ /// Returns a string that represents the current object.
+ /// </summary>
+ /// <returns>
+ /// A string that represents the current object.
+ /// </returns>
+ override public string ToString()
+ {
+ return string.Format("{0} [street={1}, zip={2}]", typeof(Address).Name, Street, Zip);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Employee.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Employee.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Employee.cs
new file mode 100644
index 0000000..7f4388d
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Employee.cs
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Apache.Ignite.ExamplesDll.Portable
+{
+ /// <summary>
+ /// Employee.
+ /// </summary>
+ [Serializable]
+ public class Employee
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="name">Name.</param>
+ /// <param name="salary">Salary.</param>
+ /// <param name="address">Address.</param>
+ /// <param name="departments">Departments.</param>
+ public Employee(string name, long salary, Address address, ICollection<string> departments)
+ {
+ Name = name;
+ Salary = salary;
+ Address = address;
+ Departments = departments;
+ }
+
+ /// <summary>
+ /// Name.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Salary.
+ /// </summary>
+ public long Salary { get; set; }
+
+ /// <summary>
+ /// Address.
+ /// </summary>
+ public Address Address { get; set; }
+
+ /// <summary>
+ /// Departments.
+ /// </summary>
+ public ICollection<string> Departments { get; set; }
+
+ /// <summary>
+ /// Returns a string that represents the current object.
+ /// </summary>
+ /// <returns>
+ /// A string that represents the current object.
+ /// </returns>
+ override public string ToString()
+ {
+ return string.Format("{0} [name={1}, salary={2}, address={3}, departments={4}]", typeof(Employee).Name,
+ Name, Salary, Address, CollectionToString(Departments));
+ }
+
+ /// <summary>
+ /// Get string representation of collection.
+ /// </summary>
+ /// <returns></returns>
+ private static string CollectionToString<T>(ICollection<T> col)
+ {
+ if (col == null)
+ return "null";
+
+ var elements = col.Any()
+ ? col.Select(x => x.ToString()).Aggregate((x, y) => x + ", " + y)
+ : string.Empty;
+
+ return string.Format("[{0}]", elements);
+ }
+ }
+}
[36/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
new file mode 100644
index 0000000..ae00c91
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
@@ -0,0 +1,3252 @@
+/*
+ * 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.Cache
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
+ using System.Linq;
+ using System.Runtime.Serialization;
+ using System.Text;
+ using System.Threading;
+ using System.Threading.Tasks;
+ using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cache.Expiry;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Impl;
+ using Apache.Ignite.Core.Impl.Cache;
+ using Apache.Ignite.Core.Portable;
+ using Apache.Ignite.Core.Tests.Query;
+ using Apache.Ignite.Core.Transactions;
+ using NUnit.Framework;
+
+ /// <summary>
+ ///
+ /// </summary>
+ class CacheTestKey
+ {
+ /// <summary>
+ /// Default constructor.
+ /// </summary>
+ public CacheTestKey()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="id">ID.</param>
+ public CacheTestKey(int id)
+ {
+ Id = id;
+ }
+
+ /// <summary>
+ /// ID.
+ /// </summary>
+ public int Id
+ {
+ get;
+ set;
+ }
+
+ /** <inheritdoc /> */
+ public override bool Equals(object obj)
+ {
+ CacheTestKey other = obj as CacheTestKey;
+
+ return other != null && Id == other.Id;
+ }
+
+ /** <inheritdoc /> */
+ public override int GetHashCode()
+ {
+ return Id;
+ }
+
+ /** <inheritdoc /> */
+ public override string ToString()
+ {
+ return new StringBuilder()
+ .Append(typeof(CacheTestKey).Name)
+ .Append(" [id=").Append(Id)
+ .Append(']').ToString();
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ class TestReferenceObject
+ {
+ public TestReferenceObject Obj;
+
+ /// <summary>
+ /// Default constructor.
+ /// </summary>
+ public TestReferenceObject()
+ {
+ // No-op.
+ }
+
+ public TestReferenceObject(TestReferenceObject obj)
+ {
+ Obj = obj;
+ }
+ }
+
+ [Serializable]
+ public class TestSerializableObject
+ {
+ public string Name { get; set; }
+ public int Id { get; set; }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+
+ var other = (TestSerializableObject) obj;
+ return obj.GetType() == GetType() && (string.Equals(Name, other.Name) && Id == other.Id);
+ }
+
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return ((Name != null ? Name.GetHashCode() : 0) * 397) ^ Id;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Cache entry processor that adds argument value to the entry value.
+ /// </summary>
+ [Serializable]
+ public class AddArgCacheEntryProcessor : ICacheEntryProcessor<int, int, int, int>
+ {
+ // Expected exception text
+ public const string ExceptionText = "Exception from AddArgCacheEntryProcessor.";
+
+ // Error flag
+ public bool ThrowErr { get; set; }
+
+ // Error flag
+ public bool ThrowErrPortable { get; set; }
+
+ // Error flag
+ public bool ThrowErrNonSerializable { get; set; }
+
+ // Key value to throw error on
+ public int ThrowOnKey { get; set; }
+
+ // Remove flag
+ public bool Remove { get; set; }
+
+ // Exists flag
+ public bool Exists { get; set; }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AddArgCacheEntryProcessor"/> class.
+ /// </summary>
+ public AddArgCacheEntryProcessor()
+ {
+ Exists = true;
+ ThrowOnKey = -1;
+ }
+
+ /** <inheritdoc /> */
+ int ICacheEntryProcessor<int, int, int, int>.Process(IMutableCacheEntry<int, int> entry, int arg)
+ {
+ if (ThrowOnKey < 0 || ThrowOnKey == entry.Key)
+ {
+ if (ThrowErr)
+ throw new Exception(ExceptionText);
+
+ if (ThrowErrPortable)
+ throw new PortableTestException {Info = ExceptionText};
+
+ if (ThrowErrNonSerializable)
+ throw new NonSerializableException();
+ }
+
+ Assert.AreEqual(Exists, entry.Exists);
+
+ if (Remove)
+ entry.Remove();
+ else
+ entry.Value = entry.Value + arg;
+
+ return entry.Value;
+ }
+
+ /** <inheritdoc /> */
+ public int Process(IMutableCacheEntry<int, int> entry, int arg)
+ {
+ throw new Exception("Invalid method");
+ }
+ }
+
+ /// <summary>
+ /// Portable add processor.
+ /// </summary>
+ public class PortableAddArgCacheEntryProcessor : AddArgCacheEntryProcessor, IPortableMarshalAware
+ {
+ /** <inheritdoc /> */
+ public void WritePortable(IPortableWriter writer)
+ {
+ var w = writer.RawWriter();
+
+ w.WriteBoolean(ThrowErr);
+ w.WriteBoolean(ThrowErrPortable);
+ w.WriteBoolean(ThrowErrNonSerializable);
+ w.WriteInt(ThrowOnKey);
+ w.WriteBoolean(Remove);
+ w.WriteBoolean(Exists);
+ }
+
+ /** <inheritdoc /> */
+ public void ReadPortable(IPortableReader reader)
+ {
+ var r = reader.RawReader();
+
+ ThrowErr = r.ReadBoolean();
+ ThrowErrPortable = r.ReadBoolean();
+ ThrowErrNonSerializable = r.ReadBoolean();
+ ThrowOnKey = r.ReadInt();
+ Remove = r.ReadBoolean();
+ Exists = r.ReadBoolean();
+ }
+ }
+
+ /// <summary>
+ /// Non-serializable processor.
+ /// </summary>
+ public class NonSerializableCacheEntryProcessor : AddArgCacheEntryProcessor
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Portable exception.
+ /// </summary>
+ public class PortableTestException : Exception, IPortableMarshalAware
+ {
+ /// <summary>
+ /// Gets or sets exception info.
+ /// </summary>
+ public string Info { get; set; }
+
+ /** <inheritdoc /> */
+ public override string Message
+ {
+ get { return Info; }
+ }
+
+ /** <inheritdoc /> */
+ public void WritePortable(IPortableWriter writer)
+ {
+ writer.RawWriter().WriteString(Info);
+ }
+
+ /** <inheritdoc /> */
+ public void ReadPortable(IPortableReader reader)
+ {
+ Info = reader.RawReader().ReadString();
+ }
+ }
+
+ /// <summary>
+ /// Non-serializable exception.
+ /// </summary>
+ public class NonSerializableException : Exception
+ {
+ // No-op
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [SuppressMessage("ReSharper", "UnusedVariable")]
+ public abstract class CacheAbstractTest {
+ /// <summary>
+ ///
+ /// </summary>
+ [TestFixtureSetUp]
+ public virtual void StartGrids() {
+ TestUtils.KillProcesses();
+
+ IgniteConfigurationEx cfg = new IgniteConfigurationEx();
+
+ PortableConfiguration portCfg = new PortableConfiguration();
+
+ ICollection<PortableTypeConfiguration> portTypeCfgs = new List<PortableTypeConfiguration>();
+
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortablePerson)));
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(CacheTestKey)));
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(TestReferenceObject)));
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableAddArgCacheEntryProcessor)));
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableTestException)));
+
+ portCfg.TypeConfigurations = portTypeCfgs;
+
+ cfg.PortableConfiguration = portCfg;
+ cfg.JvmClasspath = TestUtils.CreateTestClasspath();
+ cfg.JvmOptions = TestUtils.TestJavaOptions();
+ cfg.SpringConfigUrl = "config\\native-client-test-cache.xml";
+
+ for (int i = 0; i < GridCount(); i++) {
+ cfg.GridName = "grid-" + i;
+
+ Ignition.Start(cfg);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [TestFixtureTearDown]
+ public virtual void StopGrids() {
+ for (int i = 0; i < GridCount(); i++)
+ Ignition.Stop("grid-" + i, true);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [SetUp]
+ public virtual void BeforeTest()
+ {
+ Console.WriteLine("Test started: " + TestContext.CurrentContext.Test.Name);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [TearDown]
+ public virtual void AfterTest() {
+ for (int i = 0; i < GridCount(); i++)
+ Cache(i).RemoveAll();
+
+ for (int i = 0; i < GridCount(); i++)
+ {
+ var cache = Cache(i);
+
+ if (!cache.IsEmpty())
+ {
+ var entries = Enumerable.Range(0, 2000)
+ .Select(x => new KeyValuePair<int, int>(x, cache.LocalPeek(x)))
+ .Where(x => x.Value != 0)
+ .Select(pair => pair.ToString() + GetKeyAffinity(cache, pair.Key))
+ .Aggregate((acc, val) => string.Format("{0}, {1}", acc, val));
+
+ Assert.Fail("Cache '{0}' is not empty in grid [{1}]: ({2})", CacheName(), i, entries);
+ }
+ }
+
+ Console.WriteLine("Test finished: " + TestContext.CurrentContext.Test.Name);
+ }
+
+ public IIgnite GetIgnite(int idx)
+ {
+ return Ignition.GetIgnite("grid-" + idx);
+ }
+
+ public ICache<int, int> Cache(int idx) {
+ return Cache<int, int>(idx);
+ }
+
+ public ICache<TK, TV> Cache<TK, TV>(int idx) {
+ return GetIgnite(idx).GetCache<TK, TV>(CacheName());
+ }
+
+ public ICache<int, int> Cache()
+ {
+ return Cache<int, int>(0);
+ }
+
+ public ICache<TK, TV> Cache<TK, TV>()
+ {
+ return Cache<TK, TV>(0);
+ }
+
+ public ICacheAffinity Affinity()
+ {
+ return GetIgnite(0).GetAffinity(CacheName());
+ }
+
+ public ITransactions Transactions
+ {
+ get { return GetIgnite(0).GetTransactions(); }
+ }
+
+ [Test]
+ public void TestCircularReference()
+ {
+ var cache = Cache().WithKeepPortable<int, object>();
+
+ TestReferenceObject obj1 = new TestReferenceObject();
+
+ obj1.Obj = new TestReferenceObject(obj1);
+
+ cache.Put(1, obj1);
+
+ var po = (IPortableObject) cache.Get(1);
+
+ Assert.IsNotNull(po);
+
+ TestReferenceObject objRef = po.Deserialize<TestReferenceObject>();
+
+ Assert.IsNotNull(objRef);
+ }
+
+ [Test]
+ public void TestName()
+ {
+ for (int i = 0; i < GridCount(); i++ )
+ Assert.AreEqual(CacheName(), Cache(i).Name);
+ }
+
+ [Test]
+ public void TestIsEmpty()
+ {
+ for (int i = 0; i < GridCount(); i++)
+ {
+ var cache = Cache(i);
+
+ Assert.IsTrue(cache.IsEmpty());
+ }
+
+ for (int i = 0; i < GridCount(); i++)
+ {
+ var cache = Cache(i);
+
+ cache.Put(PrimaryKeyForCache(cache), 1);
+ }
+
+ for (int i = 0; i < GridCount(); i++)
+ {
+ var cache = Cache(i);
+
+ Assert.IsFalse(cache.IsEmpty());
+ }
+ }
+
+ [Test]
+ public void TestContainsKey()
+ {
+ var cache = Cache();
+
+ int key = PrimaryKeyForCache(cache);
+
+ cache.Put(key, 1);
+
+ Assert.IsTrue(cache.ContainsKey(key));
+ Assert.IsFalse(cache.ContainsKey(-1));
+ }
+
+ [Test]
+ public void TestContainsKeys()
+ {
+ var cache = Cache();
+
+ var keys = PrimaryKeysForCache(cache, 5);
+
+ Assert.IsFalse(cache.ContainsKeys(keys));
+
+ cache.PutAll(keys.ToDictionary(k => k, k => k));
+
+ Assert.IsTrue(cache.ContainsKeys(keys));
+
+ Assert.IsFalse(cache.ContainsKeys(keys.Concat(new[] {int.MaxValue})));
+ }
+
+ [Test]
+ public void TestPeek()
+ {
+ var cache = Cache();
+
+ int key1 = PrimaryKeyForCache(cache);
+
+ cache.Put(key1, 1);
+
+ Assert.AreEqual(1, cache.LocalPeek(key1));
+ Assert.AreEqual(0, cache.LocalPeek(-1));
+
+ Assert.AreEqual(1, cache.LocalPeek(key1, CachePeekMode.All));
+ Assert.AreEqual(0, cache.LocalPeek(-1, CachePeekMode.All));
+ }
+
+ [Test]
+ public void TestGet()
+ {
+ var cache = Cache();
+
+ cache.Put(1, 1);
+ cache.Put(2, 2);
+
+ Assert.AreEqual(1, cache.Get(1));
+ Assert.AreEqual(2, cache.Get(2));
+ Assert.AreEqual(0, cache.Get(3));
+ }
+
+ [Test]
+ public void TestGetAsync()
+ {
+ var cache = Cache().WithAsync().WrapAsync();
+
+ cache.Put(1, 1);
+ cache.Put(2, 2);
+
+ Assert.AreEqual(1, cache.Get(1));
+ Assert.AreEqual(2, cache.Get(2));
+ Assert.AreEqual(0, cache.Get(3));
+ }
+
+ [Test]
+ public void TestGetAll()
+ {
+ var cache = Cache();
+
+ cache.Put(1, 1);
+ cache.Put(2, 2);
+ cache.Put(3, 3);
+ cache.Put(4, 4);
+ cache.Put(5, 5);
+
+ IDictionary<int, int> map = cache.GetAll(new List<int> { 0, 1, 2, 5 });
+
+ Assert.AreEqual(3, map.Count);
+
+ Assert.AreEqual(1, map[1]);
+ Assert.AreEqual(2, map[2]);
+ }
+
+ [Test]
+ public void TestGetAllAsync()
+ {
+ var cache = Cache().WithAsync().WrapAsync();
+
+ cache.Put(1, 1);
+ cache.Put(2, 2);
+ cache.Put(3, 3);
+
+ var map = cache.GetAll(new List<int> { 0, 1, 2 });
+
+ Assert.AreEqual(2, map.Count);
+
+ Assert.AreEqual(1, map[1]);
+ Assert.AreEqual(2, map[2]);
+ }
+
+ [Test]
+ public void TestGetAndPut()
+ {
+ var cache = Cache();
+
+ Assert.AreEqual(0, cache.Get(1));
+
+ int old = cache.GetAndPut(1, 1);
+
+ Assert.AreEqual(0, old);
+
+ Assert.AreEqual(1, cache.Get(1));
+
+ old = cache.GetAndPut(1, 2);
+
+ Assert.AreEqual(1, old);
+
+ Assert.AreEqual(2, cache.Get(1));
+ }
+
+ [Test]
+ public void TestGetAndReplace()
+ {
+ var cache = Cache();
+
+ cache.Put(1, 10);
+
+ Assert.AreEqual(10, cache.GetAndReplace(1, 100));
+
+ Assert.AreEqual(0, cache.GetAndReplace(2, 2));
+
+ Assert.AreEqual(0, cache.Get(2));
+
+ Assert.AreEqual(100, cache.Get(1));
+
+ Assert.IsTrue(cache.Remove(1));
+ }
+
+ [Test]
+ public void TestGetAndRemove()
+ {
+ var cache = Cache();
+
+ cache.Put(1, 1);
+
+ Assert.AreEqual(1, cache.Get(1));
+
+ Assert.AreEqual(0, cache.GetAndRemove(0));
+
+ Assert.AreEqual(1, cache.GetAndRemove(1));
+
+ Assert.AreEqual(0, cache.GetAndRemove(1));
+
+ Assert.AreEqual(0, cache.Get(1));
+ }
+
+ [Test]
+ public void TestGetAndPutAsync()
+ {
+ var cache = Cache().WithAsync().WrapAsync();
+
+ Assert.AreEqual(0, cache.Get(1));
+
+ int old = cache.GetAndPut(1, 1);
+
+ Assert.AreEqual(0, old);
+
+ Assert.AreEqual(1, cache.Get(1));
+
+ old = cache.GetAndPut(1, 2);
+
+ Assert.AreEqual(1, old);
+
+ Assert.AreEqual(2, cache.Get(1));
+ }
+
+ [Test]
+ public void TestPut()
+ {
+ var cache = Cache();
+
+ cache.Put(1, 1);
+
+ Assert.AreEqual(1, cache.Get(1));
+ }
+
+ [Test]
+ public void TestPutxAsync()
+ {
+ var cache = Cache().WithAsync().WrapAsync();
+
+ cache.Put(1, 1);
+
+ Assert.AreEqual(1, cache.Get(1));
+ }
+
+ [Test]
+ public void TestPutIfAbsent()
+ {
+ var cache = Cache();
+
+ Assert.AreEqual(0, cache.Get(1));
+
+ Assert.AreEqual(true, cache.PutIfAbsent(1, 1));
+
+ Assert.AreEqual(1, cache.Get(1));
+
+ Assert.AreEqual(false, cache.PutIfAbsent(1, 2));
+
+ Assert.AreEqual(1, cache.Get(1));
+ }
+
+ [Test]
+ public void TestGetAndPutIfAbsent()
+ {
+ var cache = Cache();
+
+ Assert.AreEqual(0, cache.Get(1));
+
+ Assert.AreEqual(0, cache.GetAndPutIfAbsent(1, 1));
+
+ Assert.AreEqual(1, cache.Get(1));
+
+ Assert.AreEqual(1, cache.GetAndPutIfAbsent(1, 2));
+
+ Assert.AreEqual(1, cache.Get(1));
+ }
+
+ [Test]
+ public void TestGetAndPutIfAbsentAsync()
+ {
+ var cache = Cache().WithAsync().WrapAsync();
+
+ Assert.AreEqual(0, cache.Get(1));
+
+ int old = cache.GetAndPutIfAbsent(1, 1);
+
+ Assert.AreEqual(0, old);
+
+ Assert.AreEqual(1, cache.Get(1));
+
+ old = cache.GetAndPutIfAbsent(1, 2);
+
+ Assert.AreEqual(1, old);
+
+ Assert.AreEqual(1, cache.Get(1));
+ }
+
+ [Test]
+ public void TestPutIfAbsentAsync()
+ {
+ var cache = Cache().WithAsync().WrapAsync();
+
+ Assert.AreEqual(0, cache.Get(1));
+
+ Assert.IsTrue(cache.PutIfAbsent(1, 1));
+
+ Assert.AreEqual(1, cache.Get(1));
+
+ Assert.IsFalse(cache.PutIfAbsent(1, 2));
+
+ Assert.AreEqual(1, cache.Get(1));
+ }
+
+ [Test]
+ public void TestReplace()
+ {
+ var cache = Cache();
+
+ Assert.AreEqual(0, cache.Get(1));
+
+ bool success = cache.Replace(1, 1);
+
+ Assert.AreEqual(false, success);
+
+ Assert.AreEqual(0, cache.Get(1));
+
+ cache.Put(1, 1);
+
+ Assert.AreEqual(1, cache.Get(1));
+
+ success = cache.Replace(1, 2);
+
+ Assert.AreEqual(true, success);
+
+ Assert.AreEqual(2, cache.Get(1));
+
+ Assert.IsFalse(cache.Replace(1, -1, 3));
+
+ Assert.AreEqual(2, cache.Get(1));
+
+ Assert.IsTrue(cache.Replace(1, 2, 3));
+
+ Assert.AreEqual(3, cache.Get(1));
+ }
+
+ [Test]
+ public void TestGetAndReplaceAsync()
+ {
+ var cache = Cache().WithAsync().WrapAsync();
+
+ Assert.AreEqual(0, cache.Get(1));
+
+ int old = cache.GetAndReplace(1, 1);
+
+ Assert.AreEqual(0, old);
+
+ Assert.AreEqual(0, cache.Get(1));
+
+ cache.Put(1, 1);
+
+ Assert.AreEqual(1, cache.Get(1));
+
+ old = cache.GetAndReplace(1, 2);
+
+ Assert.AreEqual(1, old);
+
+ Assert.AreEqual(2, cache.Get(1));
+
+ Assert.IsFalse(cache.Replace(1, -1, 3));
+
+ Assert.AreEqual(2, cache.Get(1));
+
+ Assert.IsTrue(cache.Replace(1, 2, 3));
+
+ Assert.AreEqual(3, cache.Get(1));
+ }
+
+ [Test]
+ public void TestReplacex()
+ {
+ var cache = Cache();
+
+ Assert.AreEqual(0, cache.Get(1));
+
+ Assert.IsFalse(cache.Replace(1, 1));
+
+ Assert.AreEqual(0, cache.Get(1));
+
+ cache.Put(1, 1);
+
+ Assert.AreEqual(1, cache.Get(1));
+
+ Assert.IsTrue(cache.Replace(1, 2));
+
+ Assert.AreEqual(2, cache.Get(1));
+ }
+
+ [Test]
+ public void TestReplaceAsync()
+ {
+ var cache = Cache().WithAsync().WrapAsync();
+
+ Assert.AreEqual(0, cache.Get(1));
+
+ Assert.IsFalse(cache.Replace(1, 1));
+
+ Assert.AreEqual(0, cache.Get(1));
+
+ cache.Put(1, 1);
+
+ Assert.AreEqual(1, cache.Get(1));
+
+ Assert.IsTrue(cache.Replace(1, 2));
+
+ Assert.AreEqual(2, cache.Get(1));
+ }
+
+ [Test]
+ public void TestPutAll()
+ {
+ var cache = Cache();
+
+ cache.PutAll(new Dictionary<int, int> { { 1, 1 }, { 2, 2 }, { 3, 3 } });
+
+ Assert.AreEqual(1, cache.Get(1));
+ Assert.AreEqual(2, cache.Get(2));
+ Assert.AreEqual(3, cache.Get(3));
+ }
+
+ [Test]
+ public void TestPutAllAsync()
+ {
+ var cache = Cache().WithAsync().WrapAsync();
+
+ cache.PutAll(new Dictionary<int, int> { { 1, 1 }, { 2, 2 }, { 3, 3 } });
+
+ Assert.AreEqual(1, cache.Get(1));
+ Assert.AreEqual(2, cache.Get(2));
+ Assert.AreEqual(3, cache.Get(3));
+ }
+
+ /// <summary>
+ /// Expiry policy tests.
+ /// </summary>
+ [Test]
+ public void TestWithExpiryPolicy()
+ {
+ ICache<int, int> cache0 = Cache(0);
+
+ int key0;
+ int key1;
+
+ if (LocalCache())
+ {
+ key0 = 0;
+ key1 = 1;
+ }
+ else
+ {
+ key0 = PrimaryKeyForCache(cache0);
+ key1 = PrimaryKeyForCache(Cache(1));
+ }
+
+ // Test unchanged expiration.
+ ICache<int, int> cache = cache0.WithExpiryPolicy(new ExpiryPolicy(null, null, null));
+
+ cache.Put(key0, key0);
+ cache.Put(key1, key1);
+ Thread.Sleep(200);
+ Assert.IsTrue(cache0.ContainsKey(key0));
+ Assert.IsTrue(cache0.ContainsKey(key1));
+
+ cache.Put(key0, key0 + 1);
+ cache.Put(key1, key1 + 1);
+ Thread.Sleep(200);
+ Assert.IsTrue(cache0.ContainsKey(key0));
+ Assert.IsTrue(cache0.ContainsKey(key1));
+
+ cache.Get(key0);
+ cache.Get(key1);
+ Thread.Sleep(200);
+ Assert.IsTrue(cache0.ContainsKey(key0));
+ Assert.IsTrue(cache0.ContainsKey(key1));
+
+ cache0.RemoveAll(new List<int> { key0, key1 });
+
+ // Test eternal expiration.
+ cache = cache0.WithExpiryPolicy(new ExpiryPolicy(TimeSpan.MaxValue, TimeSpan.MaxValue, TimeSpan.MaxValue));
+
+ cache.Put(key0, key0);
+ cache.Put(key1, key1);
+ Thread.Sleep(200);
+ Assert.IsTrue(cache0.ContainsKey(key0));
+ Assert.IsTrue(cache0.ContainsKey(key1));
+
+ cache.Put(key0, key0 + 1);
+ cache.Put(key1, key1 + 1);
+ Thread.Sleep(200);
+ Assert.IsTrue(cache0.ContainsKey(key0));
+ Assert.IsTrue(cache0.ContainsKey(key1));
+
+ cache.Get(key0);
+ cache.Get(key1);
+ Thread.Sleep(200);
+ Assert.IsTrue(cache0.ContainsKey(key0));
+ Assert.IsTrue(cache0.ContainsKey(key1));
+
+ cache0.RemoveAll(new List<int> { key0, key1 });
+
+ // Test zero expiration.
+ cache = cache0.WithExpiryPolicy(new ExpiryPolicy(TimeSpan.Zero, TimeSpan.Zero, TimeSpan.Zero));
+
+ cache.Put(key0, key0);
+ cache.Put(key1, key1);
+ Assert.IsFalse(cache0.ContainsKey(key0));
+ Assert.IsFalse(cache0.ContainsKey(key1));
+
+ cache0.Put(key0, key0);
+ cache0.Put(key1, key1);
+ Assert.IsTrue(cache0.ContainsKey(key0));
+ Assert.IsTrue(cache0.ContainsKey(key1));
+ cache.Put(key0, key0 + 1);
+ cache.Put(key1, key1 + 1);
+ Assert.IsFalse(cache0.ContainsKey(key0));
+ Assert.IsFalse(cache0.ContainsKey(key1));
+
+ cache0.Put(key0, key0);
+ cache0.Put(key1, key1);
+ cache.Get(key0);
+ cache.Get(key1);
+ Assert.IsFalse(cache0.ContainsKey(key0));
+ Assert.IsFalse(cache0.ContainsKey(key1));
+
+ cache0.RemoveAll(new List<int> { key0, key1 });
+
+ // Test negative expiration.
+ cache = cache0.WithExpiryPolicy(new ExpiryPolicy(TimeSpan.FromMilliseconds(-100),
+ TimeSpan.FromMilliseconds(-100), TimeSpan.FromMilliseconds(-100)));
+
+ cache.Put(key0, key0);
+ cache.Put(key1, key1);
+ Assert.IsFalse(cache0.ContainsKey(key0));
+ Assert.IsFalse(cache0.ContainsKey(key1));
+
+ cache0.Put(key0, key0);
+ cache0.Put(key1, key1);
+ Assert.IsTrue(cache0.ContainsKey(key0));
+ Assert.IsTrue(cache0.ContainsKey(key1));
+ cache.Put(key0, key0 + 1);
+ cache.Put(key1, key1 + 1);
+ Assert.IsFalse(cache0.ContainsKey(key0));
+ Assert.IsFalse(cache0.ContainsKey(key1));
+
+ cache0.Put(key0, key0);
+ cache0.Put(key1, key1);
+ cache.Get(key0);
+ cache.Get(key1);
+ Assert.IsFalse(cache0.ContainsKey(key0));
+ Assert.IsFalse(cache0.ContainsKey(key1));
+
+ cache0.RemoveAll(new List<int> { key0, key1 });
+
+ // Test regular expiration.
+ cache = cache0.WithExpiryPolicy(new ExpiryPolicy(TimeSpan.FromMilliseconds(100),
+ TimeSpan.FromMilliseconds(100), TimeSpan.FromMilliseconds(100)));
+
+ cache.Put(key0, key0);
+ cache.Put(key1, key1);
+ Assert.IsTrue(cache0.ContainsKey(key0));
+ Assert.IsTrue(cache0.ContainsKey(key1));
+ Thread.Sleep(200);
+ Assert.IsFalse(cache0.ContainsKey(key0));
+ Assert.IsFalse(cache0.ContainsKey(key1));
+
+ cache0.Put(key0, key0);
+ cache0.Put(key1, key1);
+ cache.Put(key0, key0 + 1);
+ cache.Put(key1, key1 + 1);
+ Assert.IsTrue(cache0.ContainsKey(key0));
+ Assert.IsTrue(cache0.ContainsKey(key1));
+ Thread.Sleep(200);
+ Assert.IsFalse(cache0.ContainsKey(key0));
+ Assert.IsFalse(cache0.ContainsKey(key1));
+
+ cache0.Put(key0, key0);
+ cache0.Put(key1, key1);
+ cache.Get(key0);
+ cache.Get(key1);
+ Assert.IsTrue(cache0.ContainsKey(key0));
+ Assert.IsTrue(cache0.ContainsKey(key1));
+ Thread.Sleep(200);
+ Assert.IsFalse(cache0.ContainsKey(key0));
+ Assert.IsFalse(cache0.ContainsKey(key1));
+ }
+
+ [Test]
+ public void TestEvict()
+ {
+ var cache = Cache();
+
+ int key = PrimaryKeyForCache(cache);
+
+ cache.Put(key, 1);
+
+ Assert.AreEqual(1, PeekInt(cache, key));
+
+ cache.LocalEvict(new[] {key});
+
+ Assert.AreEqual(0, cache.GetLocalSize(CachePeekMode.Onheap));
+
+ Assert.AreEqual(0, PeekInt(cache, key));
+
+ Assert.AreEqual(1, cache.Get(key));
+
+ Assert.AreEqual(1, cache.GetLocalSize(CachePeekMode.Onheap));
+
+ Assert.AreEqual(1, PeekInt(cache, key));
+ }
+
+ [Test]
+ public void TestEvictAllKeys()
+ {
+ var cache = Cache();
+
+ List<int> keys = PrimaryKeysForCache(cache, 3);
+
+ cache.Put(keys[0], 1);
+ cache.Put(keys[1], 2);
+ cache.Put(keys[2], 3);
+
+ Assert.AreEqual(1, PeekInt(cache, keys[0]));
+ Assert.AreEqual(2, PeekInt(cache, keys[1]));
+ Assert.AreEqual(3, PeekInt(cache, keys[2]));
+
+ cache.LocalEvict(new List<int> { -1, keys[0], keys[1] });
+
+ Assert.AreEqual(1, cache.GetLocalSize(CachePeekMode.Onheap));
+
+ Assert.AreEqual(0, PeekInt(cache, keys[0]));
+ Assert.AreEqual(0, PeekInt(cache, keys[1]));
+ Assert.AreEqual(3, PeekInt(cache, keys[2]));
+
+ Assert.AreEqual(1, cache.Get(keys[0]));
+ Assert.AreEqual(2, cache.Get(keys[1]));
+
+ Assert.AreEqual(3, cache.GetLocalSize());
+
+ Assert.AreEqual(1, PeekInt(cache, keys[0]));
+ Assert.AreEqual(2, PeekInt(cache, keys[1]));
+ Assert.AreEqual(3, PeekInt(cache, keys[2]));
+ }
+
+ [Test]
+ public void TestClear()
+ {
+ for (int i = 0; i < GridCount(); i++)
+ {
+ var cache = Cache(i);
+
+ cache.Put(PrimaryKeyForCache(cache, 500), 1);
+
+ Assert.IsFalse(cache.IsEmpty());
+ }
+
+ Cache().Clear();
+
+ for (int i = 0; i < GridCount(); i++)
+ Assert.IsTrue(Cache(i).IsEmpty());
+ }
+
+ [Test]
+ public void TestClearKey()
+ {
+ var cache = Cache();
+ var keys = PrimaryKeysForCache(cache, 10);
+
+ foreach (var key in keys)
+ cache.Put(key, 3);
+
+ var i = cache.GetSize();
+
+ foreach (var key in keys)
+ {
+ cache.Clear(key);
+
+ Assert.AreEqual(0, cache.Get(key));
+
+ Assert.Less(cache.GetSize(), i);
+
+ i = cache.GetSize();
+ }
+ }
+
+ [Test]
+ public void TestClearKeys()
+ {
+ var cache = Cache();
+ var keys = PrimaryKeysForCache(cache, 10);
+
+ foreach (var key in keys)
+ cache.Put(key, 3);
+
+ cache.ClearAll(keys);
+
+ foreach (var key in keys)
+ Assert.AreEqual(0, cache.Get(key));
+ }
+
+ [Test]
+ public void TestLocalClearKey()
+ {
+ var cache = Cache();
+ var keys = PrimaryKeysForCache(cache, 10);
+
+ foreach (var key in keys)
+ cache.Put(key, 3);
+
+ var i = cache.GetSize();
+
+ foreach (var key in keys)
+ {
+ cache.LocalClear(key);
+
+ Assert.AreEqual(0, cache.LocalPeek(key));
+
+ Assert.Less(cache.GetSize(), i);
+
+ i = cache.GetSize();
+ }
+
+ cache.Clear();
+ }
+
+ [Test]
+ public void TestLocalClearKeys()
+ {
+ var cache = Cache();
+ var keys = PrimaryKeysForCache(cache, 10);
+
+ foreach (var key in keys)
+ cache.Put(key, 3);
+
+ cache.LocalClearAll(keys);
+
+ foreach (var key in keys)
+ Assert.AreEqual(0, cache.LocalPeek(key));
+
+ cache.Clear();
+ }
+
+ [Test]
+ public void TestRemove()
+ {
+ var cache = Cache();
+
+ cache.Put(1, 1);
+
+ Assert.AreEqual(1, cache.Get(1));
+
+ Assert.AreEqual(true, cache.Remove(1));
+
+ Assert.AreEqual(0, cache.GetSize());
+
+ Assert.AreEqual(0, cache.Get(1));
+
+ cache.Put(1, 1);
+
+ Assert.AreEqual(1, cache.Get(1));
+
+ Assert.IsFalse(cache.Remove(1, -1));
+ Assert.IsTrue(cache.Remove(1, 1));
+
+ Assert.AreEqual(0, cache.GetSize());
+
+ Assert.AreEqual(0, cache.Get(1));
+ }
+
+ [Test]
+ public void TestGetAndRemoveAsync()
+ {
+ var cache = Cache().WithAsync().WrapAsync();
+
+ cache.Put(1, 1);
+
+ Assert.AreEqual(1, cache.Get(1));
+
+ Assert.AreEqual(1, cache.GetAndRemove(1));
+
+ Assert.AreEqual(0, cache.GetSize());
+
+ Assert.AreEqual(0, cache.Get(1));
+
+ cache.Put(1, 1);
+
+ Assert.AreEqual(1, cache.Get(1));
+
+ Assert.IsFalse(cache.Remove(1, -1));
+ Assert.IsTrue(cache.Remove(1, 1));
+
+ Assert.AreEqual(0, cache.GetSize());
+
+ Assert.AreEqual(0, cache.Get(1));
+ }
+
+ [Test]
+ public void TestRemovex()
+ {
+ var cache = Cache();
+
+ cache.Put(1, 1);
+
+ Assert.AreEqual(1, cache.Get(1));
+
+ Assert.IsFalse(cache.Remove(-1));
+ Assert.IsTrue(cache.Remove(1));
+
+ Assert.AreEqual(0, cache.GetSize());
+
+ Assert.AreEqual(0, cache.Get(1));
+ }
+
+ [Test]
+ public void TestRemoveAsync()
+ {
+ var cache = Cache().WithAsync().WrapAsync();
+
+ cache.Put(1, 1);
+
+ Assert.AreEqual(1, cache.Get(1));
+
+ Assert.IsFalse(cache.Remove(-1));
+ Assert.IsTrue(cache.Remove(1));
+
+ Assert.AreEqual(0, cache.GetSize());
+
+ Assert.AreEqual(0, cache.Get(1));
+ }
+
+ [Test]
+ public void TestRemoveAll()
+ {
+ var cache = Cache();
+
+ List<int> keys = PrimaryKeysForCache(cache, 2);
+
+ cache.Put(keys[0], 1);
+ cache.Put(keys[1], 2);
+
+ Assert.AreEqual(1, cache.Get(keys[0]));
+ Assert.AreEqual(2, cache.Get(keys[1]));
+
+ cache.RemoveAll();
+
+ Assert.AreEqual(0, cache.GetSize());
+
+ Assert.AreEqual(0, cache.Get(keys[0]));
+ Assert.AreEqual(0, cache.Get(keys[1]));
+ }
+
+ [Test]
+ public void TestRemoveAllAsync()
+ {
+ var cache = Cache().WithAsync().WrapAsync();
+
+ List<int> keys = PrimaryKeysForCache(cache, 2);
+
+ cache.Put(keys[0], 1);
+ cache.Put(keys[1], 2);
+
+ Assert.AreEqual(1, cache.Get(keys[0]));
+ Assert.AreEqual(2, cache.Get(keys[1]));
+
+ cache.RemoveAll();
+
+ Assert.AreEqual(0, cache.GetSize());
+
+ Assert.AreEqual(0, cache.Get(keys[0]));
+ Assert.AreEqual(0, cache.Get(keys[1]));
+ }
+
+ [Test]
+ public void TestRemoveAllKeys()
+ {
+ var cache = Cache();
+
+ Assert.AreEqual(0, cache.GetSize());
+
+ cache.Put(1, 1);
+ cache.Put(2, 2);
+ cache.Put(3, 3);
+
+ Assert.AreEqual(1, cache.Get(1));
+ Assert.AreEqual(2, cache.Get(2));
+ Assert.AreEqual(3, cache.Get(3));
+
+ cache.RemoveAll(new List<int> { 0, 1, 2 });
+
+ Assert.AreEqual(1, cache.GetSize(CachePeekMode.Primary));
+
+ Assert.AreEqual(0, cache.Get(1));
+ Assert.AreEqual(0, cache.Get(2));
+ Assert.AreEqual(3, cache.Get(3));
+ }
+
+ [Test]
+ public void TestRemoveAllKeysAsync()
+ {
+ var cache = Cache().WithAsync().WrapAsync();
+
+ Assert.AreEqual(0, cache.GetSize());
+
+ cache.Put(1, 1);
+ cache.Put(2, 2);
+ cache.Put(3, 3);
+
+ Assert.AreEqual(1, cache.Get(1));
+ Assert.AreEqual(2, cache.Get(2));
+ Assert.AreEqual(3, cache.Get(3));
+
+ cache.RemoveAll(new List<int> { 0, 1, 2 });
+
+ Assert.AreEqual(1, cache.GetSize(CachePeekMode.Primary));
+
+ Assert.AreEqual(0, cache.Get(1));
+ Assert.AreEqual(0, cache.Get(2));
+ Assert.AreEqual(3, cache.Get(3));
+ }
+
+ [Test]
+ public void TestSizes()
+ {
+ for (int i = 0; i < GridCount(); i++)
+ {
+ var cache = Cache(i);
+
+ List<int> keys = PrimaryKeysForCache(cache, 2);
+
+ foreach (int key in keys)
+ cache.Put(key, 1);
+
+ Assert.IsTrue(cache.GetSize() >= 2);
+ Assert.AreEqual(2, cache.GetLocalSize(CachePeekMode.Primary));
+ }
+
+ ICache<int, int> cache0 = Cache();
+
+ Assert.AreEqual(GridCount() * 2, cache0.GetSize(CachePeekMode.Primary));
+
+ if (!LocalCache() && !ReplicatedCache())
+ {
+ int nearKey = NearKeyForCache(cache0);
+
+ cache0.Put(nearKey, 1);
+
+ Assert.AreEqual(NearEnabled() ? 1 : 0, cache0.GetSize(CachePeekMode.Near));
+ }
+ }
+
+ [Test]
+ public void TestLocalSize()
+ {
+ var cache = Cache();
+ var keys = PrimaryKeysForCache(cache, 3);
+
+ cache.Put(keys[0], 1);
+ cache.Put(keys[1], 2);
+
+ var localSize = cache.GetLocalSize();
+
+ cache.LocalEvict(keys.Take(2).ToArray());
+
+ Assert.AreEqual(0, cache.GetLocalSize(CachePeekMode.Onheap));
+ Assert.AreEqual(localSize, cache.GetLocalSize(CachePeekMode.All));
+
+ cache.Put(keys[2], 3);
+
+ Assert.AreEqual(localSize + 1, cache.GetLocalSize(CachePeekMode.All));
+
+ cache.RemoveAll(keys.Take(2).ToArray());
+ }
+
+ /// <summary>
+ /// Test enumerators.
+ /// </summary>
+ [Test]
+ [SuppressMessage("ReSharper", "PossibleMultipleEnumeration")]
+ public void TestEnumerators()
+ {
+ var cache = Cache();
+ var keys = PrimaryKeysForCache(cache, 2);
+
+ cache.Put(keys[0], keys[0] + 1);
+ cache.Put(keys[1], keys[1] + 1);
+
+ // Check distributed enumerator.
+ IEnumerable<ICacheEntry<int, int>> e = cache;
+
+ CheckEnumerator(e.GetEnumerator(), keys);
+ CheckEnumerator(e.GetEnumerator(), keys);
+
+ // Check local enumerator.
+ e = cache.GetLocalEntries();
+
+ CheckEnumerator(e.GetEnumerator(), keys);
+ CheckEnumerator(e.GetEnumerator(), keys);
+
+ // Evict and check peek modes.
+ cache.LocalEvict(new List<int> { keys[0] } );
+
+ e = cache.GetLocalEntries(CachePeekMode.Onheap);
+ CheckEnumerator(e.GetEnumerator(), new List<int> { keys[1] });
+ CheckEnumerator(e.GetEnumerator(), new List<int> { keys[1] });
+
+ e = cache.GetLocalEntries(CachePeekMode.All);
+ CheckEnumerator(e.GetEnumerator(), keys);
+ CheckEnumerator(e.GetEnumerator(), keys);
+
+ e = cache.GetLocalEntries(CachePeekMode.Onheap, CachePeekMode.Swap);
+ CheckEnumerator(e.GetEnumerator(), keys);
+ CheckEnumerator(e.GetEnumerator(), keys);
+
+ cache.Remove(keys[0]);
+ }
+
+ /// <summary>
+ /// Check enumerator content.
+ /// </summary>
+ /// <param name="e">Enumerator.</param>
+ /// <param name="keys">Keys.</param>
+ private static void CheckEnumerator(IEnumerator<ICacheEntry<int, int>> e, IList<int> keys)
+ {
+ CheckEnumerator0(e, keys);
+
+ e.Reset();
+
+ CheckEnumerator0(e, keys);
+
+ e.Dispose();
+
+ Assert.Throws<ObjectDisposedException>(() => { e.MoveNext(); });
+ Assert.Throws<ObjectDisposedException>(() => { var entry = e.Current; });
+ Assert.Throws<ObjectDisposedException>(e.Reset);
+
+ e.Dispose();
+ }
+
+ /// <summary>
+ /// Check enumerator content.
+ /// </summary>
+ /// <param name="e">Enumerator.</param>
+ /// <param name="keys">Keys.</param>
+ private static void CheckEnumerator0(IEnumerator<ICacheEntry<int, int>> e, IList<int> keys)
+ {
+ Assert.Throws<InvalidOperationException>(() => { var entry = e.Current; });
+
+ int cnt = 0;
+
+ while (e.MoveNext())
+ {
+ ICacheEntry<int, int> entry = e.Current;
+
+ Assert.IsTrue(keys.Contains(entry.Key), "Unexpected entry: " + entry);
+
+ Assert.AreEqual(entry.Key + 1, entry.Value);
+
+ cnt++;
+ }
+
+ Assert.AreEqual(keys.Count, cnt);
+
+ Assert.IsFalse(e.MoveNext());
+
+ Assert.Throws<InvalidOperationException>(() => { var entry = e.Current; });
+ }
+
+ [Test]
+ public void TestPromote()
+ {
+ var cache = Cache();
+
+ int key = PrimaryKeyForCache(cache);
+
+ cache.Put(key, 1);
+
+ Assert.AreEqual(1, PeekInt(cache, key));
+
+ cache.LocalEvict(new[] {key});
+
+ Assert.AreEqual(0, cache.GetLocalSize(CachePeekMode.Onheap));
+
+ Assert.AreEqual(0, PeekInt(cache, key));
+
+ cache.LocalPromote(new[] { key });
+
+ Assert.AreEqual(1, cache.GetLocalSize(CachePeekMode.Onheap));
+
+ Assert.AreEqual(1, PeekInt(cache, key));
+ }
+
+ [Test]
+ public void TestPromoteAll()
+ {
+ var cache = Cache();
+
+ List<int> keys = PrimaryKeysForCache(cache, 3);
+
+ cache.Put(keys[0], 1);
+ cache.Put(keys[1], 2);
+ cache.Put(keys[2], 3);
+
+ Assert.AreEqual(1, PeekInt(cache, keys[0]));
+ Assert.AreEqual(2, PeekInt(cache, keys[1]));
+ Assert.AreEqual(3, PeekInt(cache, keys[2]));
+
+ cache.LocalEvict(new List<int> { -1, keys[0], keys[1] });
+
+ Assert.AreEqual(1, cache.GetLocalSize(CachePeekMode.Onheap));
+
+ Assert.AreEqual(0, PeekInt(cache, keys[0]));
+ Assert.AreEqual(0, PeekInt(cache, keys[1]));
+ Assert.AreEqual(3, PeekInt(cache, keys[2]));
+
+ cache.LocalPromote(new[] {keys[0], keys[1]});
+
+ Assert.AreEqual(3, cache.GetLocalSize(CachePeekMode.Onheap));
+
+ Assert.AreEqual(1, PeekInt(cache, keys[0]));
+ Assert.AreEqual(2, PeekInt(cache, keys[1]));
+ Assert.AreEqual(3, PeekInt(cache, keys[2]));
+ }
+
+ [Test]
+ public void TestPutGetPortable()
+ {
+ var cache = Cache<int, PortablePerson>();
+
+ PortablePerson obj1 = new PortablePerson("obj1", 1);
+
+ cache.Put(1, obj1);
+
+ obj1 = cache.Get(1);
+
+ Assert.AreEqual("obj1", obj1.Name);
+ Assert.AreEqual(1, obj1.Age);
+ }
+
+ [Test]
+ public void TestPutGetPortableAsync()
+ {
+ var cache = Cache<int, PortablePerson>().WithAsync().WrapAsync();
+
+ PortablePerson obj1 = new PortablePerson("obj1", 1);
+
+ cache.Put(1, obj1);
+
+ obj1 = cache.Get(1);
+
+ Assert.AreEqual("obj1", obj1.Name);
+ Assert.AreEqual(1, obj1.Age);
+ }
+
+ [Test]
+ public void TestPutGetPortableKey()
+ {
+ var cache = Cache<CacheTestKey, string>();
+
+ int cnt = 100;
+
+ for (int i = 0; i < cnt; i++)
+ cache.Put(new CacheTestKey(i), "val-" + i);
+
+ for (int i = 0; i < cnt; i++)
+ Assert.AreEqual("val-" + i, cache.Get(new CacheTestKey(i)));
+ }
+
+ [Test]
+ public void TestGetAsync2()
+ {
+ var cache = Cache().WithAsync();
+
+ for (int i = 0; i < 100; i++)
+ {
+ cache.Put(i, i);
+
+ cache.GetFuture<object>().Get();
+ }
+
+ var futs = new List<IFuture<int>>();
+
+ for (int i = 0; i < 1000; i++)
+ {
+ cache.Get(i % 100);
+
+ futs.Add(cache.GetFuture<int>());
+ }
+
+ for (int i = 0; i < 1000; i++) {
+ Assert.AreEqual(i % 100, futs[i].Get(), "Unexpected result: " + i);
+
+ Assert.IsTrue(futs[i].IsDone);
+ }
+ }
+
+ [Test]
+ [Category(TestUtils.CategoryIntensive)]
+ public void TestGetAsyncMultithreaded()
+ {
+ var cache = Cache().WithAsync();
+
+ for (int i = 0; i < 100; i++)
+ {
+ cache.Put(i, i);
+
+ cache.GetFuture<object>().Get();
+ }
+
+ TestUtils.RunMultiThreaded(() =>
+ {
+ for (int i = 0; i < 100; i++)
+ {
+ var futs = new List<IFuture<int>>();
+
+ for (int j = 0; j < 100; j++)
+ {
+ cache.Get(j);
+
+ futs.Add(cache.GetFuture<int>());
+ }
+
+ for (int j = 0; j < 100; j++)
+ Assert.AreEqual(j, futs[j].Get());
+ }
+ }, 10);
+ }
+
+ [Test]
+ [Category(TestUtils.CategoryIntensive)]
+ public void TestPutxAsyncMultithreaded()
+ {
+ var cache = Cache().WithAsync();
+
+ TestUtils.RunMultiThreaded(() =>
+ {
+ Random rnd = new Random();
+
+ for (int i = 0; i < 50; i++)
+ {
+ var futs = new List<IFuture<object>>();
+
+ for (int j = 0; j < 10; j++)
+ {
+ cache.Put(rnd.Next(1000), i);
+
+ futs.Add(cache.GetFuture<object>());
+ }
+
+ foreach (var fut in futs)
+ fut.Get();
+ }
+ }, 5);
+ }
+
+ [Test]
+ [Category(TestUtils.CategoryIntensive)]
+ public void TestPutGetAsyncMultithreaded()
+ {
+ var cache = Cache<CacheTestKey, PortablePerson>().WithAsync();
+
+ const int threads = 10;
+ const int objPerThread = 1000;
+
+ int cntr = 0;
+
+ TestUtils.RunMultiThreaded(() =>
+ {
+ // ReSharper disable once AccessToModifiedClosure
+ int threadIdx = Interlocked.Increment(ref cntr);
+
+ var futs = new List<IFuture<object>>();
+
+ for (int i = 0; i < objPerThread; i++)
+ {
+ int key = threadIdx * objPerThread + i;
+
+ cache.Put(new CacheTestKey(key), new PortablePerson("Person-" + key, key));
+
+ futs.Add(cache.GetFuture<object>());
+ }
+
+ foreach (var fut in futs)
+ {
+ fut.Get();
+
+ Assert.IsTrue(fut.IsDone);
+ }
+ }, threads);
+
+ for (int i = 0; i < threads; i++)
+ {
+ int threadIdx = i + 1;
+
+ for (int j = 0; j < objPerThread; j++)
+ {
+ int key = threadIdx * objPerThread + i;
+
+ cache.Get(new CacheTestKey(key));
+ var p = cache.GetFuture<PortablePerson>().Get();
+
+ Assert.IsNotNull(p);
+ Assert.AreEqual(key, p.Age);
+ Assert.AreEqual("Person-" + key, p.Name);
+ }
+ }
+
+ cntr = 0;
+
+ TestUtils.RunMultiThreaded(() =>
+ {
+ int threadIdx = Interlocked.Increment(ref cntr);
+
+ for (int i = 0; i < objPerThread; i++)
+ {
+ int key = threadIdx * objPerThread + i;
+
+ cache.Put(new CacheTestKey(key), new PortablePerson("Person-" + key, key));
+
+ cache.GetFuture<object>().Get();
+ }
+ }, threads);
+
+ cntr = 0;
+
+ TestUtils.RunMultiThreaded(() =>
+ {
+ int threadIdx = Interlocked.Increment(ref cntr);
+
+ var futs = new List<IFuture<PortablePerson>>();
+
+ for (int i = 0; i < objPerThread; i++)
+ {
+ int key = threadIdx * objPerThread + i;
+
+ cache.Get(new CacheTestKey(key));
+
+ futs.Add(cache.GetFuture<PortablePerson>());
+ }
+
+ for (int i = 0; i < objPerThread; i++)
+ {
+ var fut = futs[i];
+
+ int key = threadIdx * objPerThread + i;
+
+ var p = fut.Get();
+
+ Assert.IsNotNull(p);
+ Assert.AreEqual(key, p.Age);
+ Assert.AreEqual("Person-" + key, p.Name);
+ }
+ }, threads);
+ }
+
+ //[Test]
+ //[Category(TestUtils.CATEGORY_INTENSIVE)]
+ public void TestAsyncMultithreadedKeepPortable()
+ {
+ var cache = Cache().WithAsync().WithKeepPortable<CacheTestKey, PortablePerson>();
+ var portCache = Cache().WithAsync().WithKeepPortable<CacheTestKey, IPortableObject>();
+
+ const int threads = 10;
+ const int objPerThread = 1000;
+
+ int cntr = 0;
+
+ TestUtils.RunMultiThreaded(() =>
+ {
+ // ReSharper disable once AccessToModifiedClosure
+ int threadIdx = Interlocked.Increment(ref cntr);
+
+ var futs = new List<IFuture<object>>();
+
+ for (int i = 0; i < objPerThread; i++)
+ {
+ int key = threadIdx * objPerThread + i;
+
+ cache.Put(new CacheTestKey(key), new PortablePerson("Person-" + key, key));
+
+ futs.Add(cache.GetFuture<object>());
+ }
+
+ foreach (var fut in futs)
+ Assert.IsNull(fut.Get());
+ }, threads);
+
+ for (int i = 0; i < threads; i++)
+ {
+ int threadIdx = i + 1;
+
+ for (int j = 0; j < objPerThread; j++)
+ {
+ int key = threadIdx * objPerThread + i;
+
+ IPortableObject p = portCache.Get(new CacheTestKey(key));
+
+ Assert.IsNotNull(p);
+ Assert.AreEqual(key, p.GetField<int>("age"));
+ Assert.AreEqual("Person-" + key, p.GetField<string>("name"));
+ }
+ }
+
+ cntr = 0;
+
+ TestUtils.RunMultiThreaded(() =>
+ {
+ int threadIdx = Interlocked.Increment(ref cntr);
+
+ var futs = new List<IFuture<IPortableObject>>();
+
+ for (int i = 0; i < objPerThread; i++)
+ {
+ int key = threadIdx * objPerThread + i;
+
+ portCache.Get(new CacheTestKey(key));
+
+ futs.Add(cache.GetFuture<IPortableObject>());
+ }
+
+ for (int i = 0; i < objPerThread; i++)
+ {
+ var fut = futs[i];
+
+ int key = threadIdx * objPerThread + i;
+
+ var p = fut.Get();
+
+ Assert.IsNotNull(p);
+ Assert.AreEqual(key, p.GetField<int>("age"));
+ Assert.AreEqual("Person-" + key, p.GetField<string>("name"));
+ }
+ }, threads);
+
+ cntr = 0;
+
+ TestUtils.RunMultiThreaded(() =>
+ {
+ int threadIdx = Interlocked.Increment(ref cntr);
+
+ var futs = new List<IFuture<bool>>();
+
+ for (int i = 0; i < objPerThread; i++)
+ {
+ int key = threadIdx * objPerThread + i;
+
+ cache.Remove(new CacheTestKey(key));
+
+ futs.Add(cache.GetFuture<bool>());
+ }
+
+ for (int i = 0; i < objPerThread; i++)
+ {
+ var fut = futs[i];
+
+ Assert.AreEqual(true, fut.Get());
+ }
+ }, threads);
+ }
+
+ [Test]
+ [Ignore("IGNITE-835")]
+ public void TestLock()
+ {
+ if (!LockingEnabled())
+ return;
+
+ var cache = Cache();
+
+ const int key = 7;
+
+ // Lock
+ CheckLock(cache, key, () => cache.Lock(key));
+
+ // LockAll
+ CheckLock(cache, key, () => cache.LockAll(new[] { key, 2, 3, 4, 5 }));
+ }
+
+ /// <summary>
+ /// Internal lock test routine.
+ /// </summary>
+ /// <param name="cache">Cache.</param>
+ /// <param name="key">Key.</param>
+ /// <param name="getLock">Function to get the lock.</param>
+ private static void CheckLock(ICache<int, int> cache, int key, Func<ICacheLock> getLock)
+ {
+ var sharedLock = getLock();
+
+ using (sharedLock)
+ {
+ Assert.Throws<InvalidOperationException>(() => sharedLock.Exit()); // can't exit if not entered
+
+ sharedLock.Enter();
+
+ try
+ {
+ Assert.IsTrue(cache.IsLocalLocked(key, true));
+ Assert.IsTrue(cache.IsLocalLocked(key, false));
+
+ EnsureCannotLock(getLock, sharedLock);
+
+ sharedLock.Enter();
+
+ try
+ {
+ Assert.IsTrue(cache.IsLocalLocked(key, true));
+ Assert.IsTrue(cache.IsLocalLocked(key, false));
+
+ EnsureCannotLock(getLock, sharedLock);
+ }
+ finally
+ {
+ sharedLock.Exit();
+ }
+
+ Assert.IsTrue(cache.IsLocalLocked(key, true));
+ Assert.IsTrue(cache.IsLocalLocked(key, false));
+
+ EnsureCannotLock(getLock, sharedLock);
+
+ Assert.Throws<SynchronizationLockException>(() => sharedLock.Dispose()); // can't dispose while locked
+ }
+ finally
+ {
+ sharedLock.Exit();
+ }
+
+ Assert.IsFalse(cache.IsLocalLocked(key, true));
+ Assert.IsFalse(cache.IsLocalLocked(key, false));
+
+ var innerTask = new Task(() =>
+ {
+ Assert.IsTrue(sharedLock.TryEnter());
+ sharedLock.Exit();
+
+ using (var otherLock = getLock())
+ {
+ Assert.IsTrue(otherLock.TryEnter());
+ otherLock.Exit();
+ }
+ });
+
+ innerTask.Start();
+ innerTask.Wait();
+ }
+
+ Assert.IsFalse(cache.IsLocalLocked(key, true));
+ Assert.IsFalse(cache.IsLocalLocked(key, false));
+
+ var outerTask = new Task(() =>
+ {
+ using (var otherLock = getLock())
+ {
+ Assert.IsTrue(otherLock.TryEnter());
+ otherLock.Exit();
+ }
+ });
+
+ outerTask.Start();
+ outerTask.Wait();
+
+ Assert.Throws<ObjectDisposedException>(() => sharedLock.Enter()); // Can't enter disposed lock
+ }
+
+ /// <summary>
+ /// ENsure taht lock cannot be obtained by other threads.
+ /// </summary>
+ /// <param name="getLock">Get lock function.</param>
+ /// <param name="sharedLock">Shared lock.</param>
+ private static void EnsureCannotLock(Func<ICacheLock> getLock, ICacheLock sharedLock)
+ {
+ var task = new Task(() =>
+ {
+ Assert.IsFalse(sharedLock.TryEnter());
+ Assert.IsFalse(sharedLock.TryEnter(TimeSpan.FromMilliseconds(100)));
+
+ using (var otherLock = getLock())
+ {
+ Assert.IsFalse(otherLock.TryEnter());
+ Assert.IsFalse(otherLock.TryEnter(TimeSpan.FromMilliseconds(100)));
+ }
+ });
+
+ task.Start();
+ task.Wait();
+ }
+
+ [Test]
+ public void TestTxCommit()
+ {
+ TestTxCommit(false);
+ }
+
+ [Test]
+ public void TestTxCommitAsync()
+ {
+ TestTxCommit(true);
+ }
+
+ private void TestTxCommit(bool async)
+ {
+ if (!TxEnabled())
+ return;
+
+ var cache = Cache();
+
+ ITransaction tx = Transactions.Tx;
+
+ Assert.IsNull(tx);
+
+ tx = Transactions.TxStart();
+
+ try
+ {
+ cache.Put(1, 1);
+
+ cache.Put(2, 2);
+
+ if (async)
+ {
+ var asyncTx = tx.WithAsync();
+
+ asyncTx.Commit();
+
+ var fut = asyncTx.GetFuture();
+
+ fut.Get();
+
+ Assert.IsTrue(fut.IsDone);
+ Assert.AreEqual(fut.Get(), null);
+ }
+ else
+ tx.Commit();
+ }
+ finally
+ {
+ tx.Dispose();
+ }
+
+ Assert.AreEqual(1, cache.Get(1));
+
+ Assert.AreEqual(2, cache.Get(2));
+
+ tx = Transactions.Tx;
+
+ Assert.IsNull(tx);
+ }
+
+ [Test]
+ public void TestTxRollback()
+ {
+ if (!TxEnabled())
+ return;
+
+ var cache = Cache();
+
+ cache.Put(1, 1);
+
+ cache.Put(2, 2);
+
+ ITransaction tx = Transactions.Tx;
+
+ Assert.IsNull(tx);
+
+ tx = Transactions.TxStart();
+
+ try {
+ cache.Put(1, 10);
+
+ cache.Put(2, 20);
+ }
+ finally {
+ tx.Rollback();
+ }
+
+ Assert.AreEqual(1, cache.Get(1));
+
+ Assert.AreEqual(2, cache.Get(2));
+
+ Assert.IsNull(Transactions.Tx);
+ }
+
+ [Test]
+ public void TestTxClose()
+ {
+ if (!TxEnabled())
+ return;
+
+ var cache = Cache();
+
+ cache.Put(1, 1);
+
+ cache.Put(2, 2);
+
+ ITransaction tx = Transactions.Tx;
+
+ Assert.IsNull(tx);
+
+ tx = Transactions.TxStart();
+
+ try
+ {
+ cache.Put(1, 10);
+
+ cache.Put(2, 20);
+ }
+ finally
+ {
+ tx.Dispose();
+ }
+
+ Assert.AreEqual(1, cache.Get(1));
+
+ Assert.AreEqual(2, cache.Get(2));
+
+ tx = Transactions.Tx;
+
+ Assert.IsNull(tx);
+ }
+
+ [Test]
+ public void TestTxAllModes()
+ {
+ TestTxAllModes(false);
+
+ TestTxAllModes(true);
+
+ Console.WriteLine("Done");
+ }
+
+ protected void TestTxAllModes(bool withTimeout)
+ {
+ if (!TxEnabled())
+ return;
+
+ var cache = Cache();
+
+ int cntr = 0;
+
+ foreach (TransactionConcurrency concurrency in Enum.GetValues(typeof(TransactionConcurrency))) {
+ foreach (TransactionIsolation isolation in Enum.GetValues(typeof(TransactionIsolation))) {
+ Console.WriteLine("Test tx [concurrency=" + concurrency + ", isolation=" + isolation + "]");
+
+ ITransaction tx = Transactions.Tx;
+
+ Assert.IsNull(tx);
+
+ tx = withTimeout
+ ? Transactions.TxStart(concurrency, isolation, TimeSpan.FromMilliseconds(1100), 10)
+ : Transactions.TxStart(concurrency, isolation);
+
+ Assert.AreEqual(concurrency, tx.Concurrency);
+ Assert.AreEqual(isolation, tx.Isolation);
+
+ if (withTimeout)
+ Assert.AreEqual(1100, tx.Timeout.TotalMilliseconds);
+
+ try {
+ cache.Put(1, cntr);
+
+ tx.Commit();
+ }
+ finally {
+ tx.Dispose();
+ }
+
+ tx = Transactions.Tx;
+
+ Assert.IsNull(tx);
+
+ Assert.AreEqual(cntr, cache.Get(1));
+
+ cntr++;
+ }
+ }
+ }
+
+ [Test]
+ public void TestTxAttributes()
+ {
+ if (!TxEnabled())
+ return;
+
+ ITransaction tx = Transactions.TxStart(TransactionConcurrency.Optimistic,
+ TransactionIsolation.RepeatableRead, TimeSpan.FromMilliseconds(2500), 100);
+
+ Assert.IsFalse(tx.IsRollbackOnly);
+ Assert.AreEqual(TransactionConcurrency.Optimistic, tx.Concurrency);
+ Assert.AreEqual(TransactionIsolation.RepeatableRead, tx.Isolation);
+ Assert.AreEqual(2500, tx.Timeout.TotalMilliseconds);
+ Assert.AreEqual(TransactionState.Active, tx.State);
+ Assert.IsTrue(tx.StartTime.Ticks > 0);
+ Assert.AreEqual(tx.NodeId, GetIgnite(0).GetCluster().GetLocalNode().Id);
+
+ DateTime startTime1 = tx.StartTime;
+
+ tx.Commit();
+
+ Assert.IsFalse(tx.IsRollbackOnly);
+ Assert.AreEqual(TransactionState.Committed, tx.State);
+ Assert.AreEqual(TransactionConcurrency.Optimistic, tx.Concurrency);
+ Assert.AreEqual(TransactionIsolation.RepeatableRead, tx.Isolation);
+ Assert.AreEqual(2500, tx.Timeout.TotalMilliseconds);
+ Assert.AreEqual(startTime1, tx.StartTime);
+
+ Thread.Sleep(100);
+
+ tx = Transactions.TxStart(TransactionConcurrency.Pessimistic, TransactionIsolation.ReadCommitted,
+ TimeSpan.FromMilliseconds(3500), 200);
+
+ Assert.IsFalse(tx.IsRollbackOnly);
+ Assert.AreEqual(TransactionConcurrency.Pessimistic, tx.Concurrency);
+ Assert.AreEqual(TransactionIsolation.ReadCommitted, tx.Isolation);
+ Assert.AreEqual(3500, tx.Timeout.TotalMilliseconds);
+ Assert.AreEqual(TransactionState.Active, tx.State);
+ Assert.IsTrue(tx.StartTime.Ticks > 0);
+ Assert.IsTrue(tx.StartTime > startTime1);
+
+ DateTime startTime2 = tx.StartTime;
+
+ tx.Rollback();
+
+ Assert.AreEqual(TransactionState.RolledBack, tx.State);
+ Assert.AreEqual(TransactionConcurrency.Pessimistic, tx.Concurrency);
+ Assert.AreEqual(TransactionIsolation.ReadCommitted, tx.Isolation);
+ Assert.AreEqual(3500, tx.Timeout.TotalMilliseconds);
+ Assert.AreEqual(startTime2, tx.StartTime);
+
+ Thread.Sleep(100);
+
+ tx = Transactions.TxStart(TransactionConcurrency.Optimistic, TransactionIsolation.RepeatableRead,
+ TimeSpan.FromMilliseconds(2500), 100);
+
+ Assert.IsFalse(tx.IsRollbackOnly);
+ Assert.AreEqual(TransactionConcurrency.Optimistic, tx.Concurrency);
+ Assert.AreEqual(TransactionIsolation.RepeatableRead, tx.Isolation);
+ Assert.AreEqual(2500, tx.Timeout.TotalMilliseconds);
+ Assert.AreEqual(TransactionState.Active, tx.State);
+ Assert.IsTrue(tx.StartTime > startTime2);
+
+ DateTime startTime3 = tx.StartTime;
+
+ tx.Commit();
+
+ Assert.IsFalse(tx.IsRollbackOnly);
+ Assert.AreEqual(TransactionState.Committed, tx.State);
+ Assert.AreEqual(TransactionConcurrency.Optimistic, tx.Concurrency);
+ Assert.AreEqual(TransactionIsolation.RepeatableRead, tx.Isolation);
+ Assert.AreEqual(2500, tx.Timeout.TotalMilliseconds);
+ Assert.AreEqual(startTime3, tx.StartTime);
+ }
+
+ [Test]
+ public void TestTxRollbackOnly()
+ {
+ if (!TxEnabled())
+ return;
+
+ var cache = Cache();
+
+ cache.Put(1, 1);
+
+ cache.Put(2, 2);
+
+ ITransaction tx = Transactions.TxStart();
+
+ cache.Put(1, 10);
+
+ cache.Put(2, 20);
+
+ Assert.IsFalse(tx.IsRollbackOnly);
+
+ tx.SetRollbackonly();
+
+ Assert.IsTrue(tx.IsRollbackOnly);
+
+ Assert.AreEqual(TransactionState.MarkedRollback, tx.State);
+
+ try
+ {
+ tx.Commit();
+
+ Assert.Fail("Commit must fail.");
+ }
+ catch (IgniteException e)
+ {
+ Console.WriteLine("Expected exception: " + e);
+ }
+
+ tx.Dispose();
+
+ Assert.AreEqual(TransactionState.RolledBack, tx.State);
+
+ Assert.IsTrue(tx.IsRollbackOnly);
+
+ Assert.AreEqual(1, cache.Get(1));
+
+ Assert.AreEqual(2, cache.Get(2));
+
+ tx = Transactions.Tx;
+
+ Assert.IsNull(tx);
+ }
+
+ [Test]
+ public void TestTxMetrics()
+ {
+ if (!TxEnabled())
+ return;
+
+ var cache = Cache();
+
+ var startTime = DateTime.UtcNow.AddSeconds(-1);
+
+ Transactions.ResetMetrics();
+
+ var metrics = Transactions.GetMetrics();
+
+ Assert.AreEqual(0, metrics.TxCommits);
+ Assert.AreEqual(0, metrics.TxRollbacks);
+
+ using (Transactions.TxStart())
+ {
+ cache.Put(1, 1);
+ }
+
+ using (var tx = Transactions.TxStart())
+ {
+ cache.Put(1, 1);
+ tx.Commit();
+ }
+
+ metrics = Transactions.GetMetrics();
+
+ Assert.AreEqual(1, metrics.TxCommits);
+ Assert.AreEqual(1, metrics.TxRollbacks);
+
+ Assert.LessOrEqual(startTime, metrics.CommitTime);
+ Assert.LessOrEqual(startTime, metrics.RollbackTime);
+
+ Assert.GreaterOrEqual(DateTime.UtcNow, metrics.CommitTime);
+ Assert.GreaterOrEqual(DateTime.UtcNow, metrics.RollbackTime);
+ }
+
+ [Test]
+ public void TestTxStateAndExceptions()
+ {
+ if (!TxEnabled())
+ return;
+
+ var tx = Transactions.TxStart();
+
+ Assert.AreEqual(TransactionState.Active, tx.State);
+
+ tx.Rollback();
+
+ Assert.AreEqual(TransactionState.RolledBack, tx.State);
+
+ try
+ {
+ tx.Commit();
+ Assert.Fail();
+ }
+ catch (InvalidOperationException)
+ {
+ // Expected
+ }
+
+ tx = Transactions.TxStart().WithAsync();
+
+ Assert.AreEqual(TransactionState.Active, tx.State);
+
+ tx.Commit();
+
+ tx.GetFuture().Get();
+
+ Assert.AreEqual(TransactionState.Committed, tx.State);
+
+ tx.Rollback(); // Illegal, but should not fail here; will fail in future
+
+ try
+ {
+ tx.GetFuture<object>().Get();
+ Assert.Fail();
+ }
+ catch (InvalidOperationException)
+ {
+ // Expected
+ }
+ }
+
+ /// <summary>
+ /// Test thraed-locals leak.
+ /// </summary>
+ [Test]
+ [Category(TestUtils.CategoryIntensive)]
+ public void TestThreadLocalLeak()
+ {
+ var cache = Cache<string, string>();
+
+ Exception err = null;
+
+ const int threadCnt = 10;
+
+ Thread[] threads = new Thread[threadCnt];
+
+ ThreadStart[] threadStarts = new ThreadStart[threadCnt];
+
+ for (int j = 0; j < threadCnt; j++)
+ {
+ string key = "key" + j;
+
+ threadStarts[j] = () =>
+ {
+ try
+ {
+ cache.Put(key, key);
+
+ Assert.AreEqual(key, cache.Get(key));
+ }
+ catch (Exception e)
+ {
+ Interlocked.CompareExchange(ref err, e, null);
+
+ Assert.Fail("Unexpected error: " + e);
+ }
+ };
+ }
+
+ for (int i = 0; i < 100 && err == null; i++)
+ {
+ for (int j = 0 ; j < threadCnt; j++) {
+ Thread t = new Thread(threadStarts[j]);
+
+ threads[j] = t;
+ }
+
+ foreach (Thread t in threads)
+ t.Start();
+
+ foreach (Thread t in threads)
+ t.Join();
+
+ if (i % 500 == 0)
+ {
+ Console.WriteLine("Iteration: " + i);
+
+ GC.Collect();
+ }
+ }
+
+ Assert.IsNull(err);
+ }
+
+ /**
+ * Test tries to provoke garbage collection for .Net future before it was completed to verify
+ * futures pinning works.
+ */
+ [Test]
+ [Category(TestUtils.CategoryIntensive)]
+ public void TestFuturesGc()
+ {
+ var cache = Cache().WithAsync();
+
+ cache.Put(1, 1);
+
+ for (int i = 0; i < 10; i++)
+ {
+ TestUtils.RunMultiThreaded(() =>
+ {
+ for (int j = 0; j < 1000; j++)
+ cache.Get(1);
+ }, 5);
+
+ GC.Collect();
+
+ cache.Get(1);
+ Assert.AreEqual(1, cache.GetFuture<int>().Get());
+ }
+
+ Thread.Sleep(2000);
+ }
+
+ [Test]
+ public void TestPartitions()
+ {
+ ICacheAffinity aff = Affinity();
+
+ for (int i = 0; i < 5; i++ )
+ Assert.AreEqual(CachePartitions(), aff.Partitions);
+ }
+
+ [Test]
+ public void TestKeyPartition()
+ {
+ ICacheAffinity aff = Affinity();
+
+ {
+ ISet<int> parts = new HashSet<int>();
+
+ for (int i = 0; i < 1000; i++)
+ parts.Add(aff.GetPartition(i));
+
+ if (LocalCache())
+ Assert.AreEqual(1, parts.Count);
+ else
+ Assert.IsTrue(parts.Count > 10);
+ }
+
+ {
+ ISet<int> parts = new HashSet<int>();
+
+ for (int i = 0; i < 1000; i++)
+ parts.Add(aff.GetPartition("key" + i));
+
+ if (LocalCache())
+ Assert.AreEqual(1, parts.Count);
+ else
+ Assert.IsTrue(parts.Count > 10);
+ }
+ }
+
+ [Test]
+ public void TestIsPrimaryOrBackup()
+ {
+ ICacheAffinity aff = Affinity();
+
+ ICollection<IClusterNode> nodes = GetIgnite(0).GetCluster().GetNodes();
+
+ Assert.IsTrue(nodes.Count > 0);
+
+ IClusterNode node = nodes.First();
+
+ {
+ bool found = false;
+
+ for (int i = 0; i < 1000; i++)
+ {
+ if (aff.IsPrimary(node, i))
+ {
+ Assert.IsTrue(aff.IsPrimaryOrBackup(node, i));
+
+ found = true;
+
+ if (nodes.Count > 1)
+ Assert.IsFalse(aff.IsPrimary(nodes.Last(), i));
+
+ break;
+ }
+ }
+
+ Assert.IsTrue(found, "Failed to find primary key for node " + node);
+ }
+
+ if (nodes.Count > 1)
+ {
+ bool found = false;
+
+ for (int i = 0; i < 1000; i++)
+ {
+ if (aff.IsBackup(node, i))
+ {
+ Assert.IsTrue(aff.IsPrimaryOrBackup(node, i));
+
+ found = true;
+
+ break;
+ }
+ }
+
+ Assert.IsTrue(found, "Failed to find backup key for node " + node);
+ }
+ }
+
+ [Test]
+ public void TestNodePartitions()
+ {
+ ICacheAffinity aff = Affinity();
+
+ ICollection<IClusterNode> nodes = GetIgnite(0).GetCluster().GetNodes();
+
+ Assert.IsTrue(nodes.Count > 0);
+
+ if (nodes.Count == 1)
+ {
+ IClusterNode node = nodes.First();
+
+ int[] parts = aff.GetBackupPartitions(node);
+
+ Assert.AreEqual(0, parts.Length);
+
+ parts = aff.GetAllPartitions(node);
+
+ Assert.AreEqual(CachePartitions(), parts.Length);
+ }
+ else
+ {
+ IList<int> allPrimaryParts = new List<int>();
+ IList<int> allBackupParts = new List<int>();
+ IList<int> allParts = new List<int>();
+
+ foreach(IClusterNode node in nodes) {
+ int[] parts = aff.GetPrimaryPartitions(node);
+
+ foreach (int part in parts)
+ allPrimaryParts.Add(part);
+
+ parts = aff.GetBackupPartitions(node);
+
+ foreach (int part in parts)
+ allBackupParts.Add(part);
+
+ parts = aff.GetAllPartitions(node);
+
+ foreach (int part in parts)
+ allParts.Add(part);
+ }
+
+ Assert.AreEqual(CachePartitions(), allPrimaryParts.Count);
+ Assert.AreEqual(CachePartitions() * Backups(), allBackupParts.Count);
+ Assert.AreEqual(CachePartitions() * (Backups() + 1), allParts.Count);
+ }
+ }
+
+ [Test]
+ public void TestAffinityKey()
+ {
+ ICacheAffinity aff = Affinity();
+
+ Assert.AreEqual(10, aff.GetAffinityKey<int, int>(10));
+
+ Assert.AreEqual("string", aff.GetAffinityKey<string, string>("string"));
+ }
+
+ [Test]
+ public void TestMapToNode()
+ {
+ ICacheAffinity aff = Affinity();
+
+ const int key = 1;
+
+ IClusterNode node = aff.MapKeyToNode(key);
+
+ Assert.IsNotNull(node);
+
+ Assert.IsTrue(GetIgnite(0).GetCluster().GetNodes().Contains(node));
+
+ Assert.IsTrue(aff.IsPrimary(node, key));
+
+ Assert.IsTrue(aff.IsPrimaryOrBackup(node, key));
+
+ Assert.IsFalse(aff.IsBackup(node, key));
+
+ int part = aff.GetPartition(key);
+
+ IClusterNode partNode = aff.MapPartitionToNode(part);
+
+ Assert.AreEqual(node, partNode);
+ }
+
+ [Test]
+ public void TestMapToPrimaryAndBackups()
+ {
+ ICacheAffinity aff = Affinity();
+
+ const int key = 1;
+
+ IList<IClusterNode> nodes = aff.MapKeyToPrimaryAndBackups(key);
+
+ Assert.IsTrue(nodes.Count > 0);
+
+ for (int i = 0; i < nodes.Count; i++)
+ {
+ if (i == 0)
+ Assert.IsTrue(aff.IsPrimary(nodes[i], key));
+ else
+ Assert.IsTrue(aff.IsBackup(nodes[i], key));
+ }
+
+ int part = aff.GetPartition(key);
+
+ IList<IClusterNode> partNodes = aff.MapPartitionToPrimaryAndBackups(part);
+
+ Assert.AreEqual(nodes, partNodes);
+ }
+
+ [Test]
+ public void TestMapKeysToNodes()
+ {
+ ICacheAffinity aff = Affinity();
+
+ IList<int> keys = new List<int> {1, 2, 3};
+
+ IDictionary<IClusterNode, IList<int>> map = aff.MapKeysToNodes(keys);
+
+ Assert.IsTrue(map.Count > 0);
+
+ foreach (int key in keys)
+ {
+ IClusterNode primary = aff.MapKeyToNode(key);
+
+ Assert.IsTrue(map.ContainsKey(primary));
+
+ IList<int> nodeKeys = map[primary];
+
+ Assert.IsNotNull(nodeKeys);
+
+ Assert.IsTrue(nodeKeys.Contains(key));
+ }
+ }
+
+ [Test]
+ public void TestMapPartitionsToNodes()
+ {
+ ICacheAffinity aff = Affinity();
+
+ if (LocalCache())
+ {
+ IList<int> parts = new List<int> { 0 };
+
+ IDictionary<int, IClusterNode> map = aff.MapPartitionsToNodes(parts);
+
+ Assert.AreEqual(parts.Count, map.Count);
+
+ Assert.AreEqual(GetIgnite(0).GetCluster().GetLocalNode(), map[0]);
+ }
+ else
+ {
+ IList<int> parts = new List<int> { 1, 2, 3 };
+
+ IDictionary<int, IClusterNode> map = aff.MapPartitionsToNodes(parts);
+
+ Assert.AreEqual(parts.Count, map.Count);
+
+ foreach (int part in parts)
+ {
+ Assert.IsTrue(map.ContainsKey(part));
+
+ IClusterNode primary = aff.MapPartitionToNode(part);
+
+ Assert.AreEqual(primary, map[part], "Wrong node for partition: " + part);
+ }
+ }
+ }
+
+ [Test]
+ public void TestKeepPortableFlag()
+ {
+ TestKeepPortableFlag(false);
+ }
+
+ [Test]
+ public void TestKeepPortableFlagAsync()
+ {
+ TestKeepPortableFlag(true);
+ }
+
+ [Test]
+ public void TestNearKeys()
+ {
+ if (!NearEnabled())
+ return;
+
+ const int count = 20;
+
+ var cache = Cache();
+ var aff = cache.Ignite.GetAffinity(cache.Name);
+ var node = cache.Ignite.GetCluster().GetLocalNode();
+
+ for (int i = 0; i < count; i++)
+ cache.Put(i, -i - 1);
+
+ var nearKeys = Enumerable.Range(0, count).Where(x => !aff.IsPrimaryOrBackup(node, x)).ToArray();
+
+ var nearKeysString = nearKeys.Select(x => x.ToString()).Aggregate((x, y) => x + ", " + y);
+
+ Console.WriteLine("Near keys: " + nearKeysString);
+
+ foreach (var nearKey in nearKeys.Take(3))
+ Assert.AreNotEqual(0, cache.Get(nearKey));
+ }
+
+ [Test]
+ public void TestSerializable()
+ {
+ var cache = Cache<int, TestSerializableObject>();
+
+ var obj = new TestSerializableObject {Name = "Vasya", Id = 128};
+
+ cache.Put(1, obj);
+
+ var resultObj = cache.Get(1);
+
+ Assert.AreEqual(obj, resultObj);
+ }
+
+ [Test]
+ public void TestInvoke()
+ {
+ TestInvoke(false);
+ }
+
+ [Test]
+ public void TestInvokeAsync()
+ {
+ TestInvoke(true);
+ }
+
+ private void TestInvoke(bool async)
+ {
+ TestInvoke<AddArgCacheEntryProcessor>(async);
+ TestInvoke<PortableAddArgCacheEntryProcessor>(async);
+
+ try
+ {
+ TestInvoke<NonSerializableCacheEntryProcessor>(async);
+ Assert.Fail();
+ }
+ catch (SerializationException)
+ {
+ // Expected
+ }
+ }
+
+ private void TestInvoke<T>(bool async) where T: AddArgCacheEntryProcessor, new()
+ {
+ var cache = async ? Cache().WithAsync().WrapAsync() : Cache();
+
+ cache.Clear();
+
+ const int key = 1;
+ const int value = 3;
+ const int arg = 5;
+
+ cache.Put(key, value);
+
+ // Existing entry
+ Assert.AreEqual(value + arg, cache.Invoke(key, new T(), arg));
+ Assert.AreEqual(value + arg, cache.Get(key));
+
+ // Non-existing entry
+ Assert.AreEqual(arg, cache.Invoke(10, new T {Exists = false}, arg));
+ Assert.AreEqual(arg, cache.Get(10));
+
+ // Remove entry
+ Assert.AreEqual(0, cache.Invoke(key, new T {Remove = true}, arg));
+ Assert.AreEqual(0, cache.Get(key));
+
+ // Test exceptions
+ AssertThrowsCacheEntryProcessorException(() => cache.Invoke(key, new T {ThrowErr = true}, arg));
+ AssertThrowsCacheEntryProcessorException(
+ () => cache.Invoke(key, new T {ThrowErrPortable = true}, arg));
+ AssertThrowsCacheEntryProcessorException(
+ () => cache.Invoke(key, new T { ThrowErrNonSerializable = true }, arg), "SerializationException");
+ }
+
+ private static void AssertThrowsCacheEntryProcessorException(Action action, string containsText = null)
+ {
+ try
+ {
+ action();
+
+ Assert.Fail();
+ }
+ catch (Exception ex)
+ {
+ Assert.IsInstanceOf<CacheEntryProcessorException>(ex);
+
+ if (string.IsNullOrEmpty(containsText))
+ Assert.AreEqual(ex.InnerException.Message, AddArgCacheEntryProcessor.ExceptionText);
+ else
+ Assert.IsTrue(ex.ToString().Contains(containsText));
+ }
+ }
+
+ [Test]
+ public void TestInvokeAll()
+ {
+ TestInvokeAll(false);
+ }
+
+ [Test]
+ public void TestInvokeAllAsync()
+ {
+ TestInvokeAll(true);
+ }
+
+ private void TestInvokeAll(bool async)
+ {
+ for (var i = 1; i < 10; i++)
+ {
+ TestInvokeAll<AddArgCacheEntryProcessor>(async, i);
+ TestInvokeAll<PortableAddArgCacheEntryProcessor>(async, i);
+
+ try
+ {
+ TestInvokeAll<NonSerializableCacheEntryProcessor>(async, i);
+ Assert.Fail();
+ }
+ catch (SerializationException)
+ {
+ // Expected
+ }
+ }
+ }
+
+ public void TestInvokeAll<T>(bool async, int entryCount) where T : AddArgCacheEntryProcessor, new()
+ {
+ var cache = async ? Cache().WithAsync().WrapAsync() : Cache();
+
+ var entries = Enumerable.Range(1, entryCount).ToDictionary(x => x, x => x + 1);
+
+ cache.PutAll(entries);
+
+ const int arg = 5;
+
+ // Existing entries
+ var res = cache.InvokeAll(entries.Keys, new T(), arg);
+
+ var results = res.OrderBy(x => x.Key).Select(x => x.Value.Result);
+ var expectedResults = entries.OrderBy(x => x.Key).Select(x => x.Value + arg);
+
+ Assert.IsTrue(results.SequenceEqual(expectedResults));
+
+ var resultEntries = cache.GetAll(entries.Keys);
+
+ Assert.IsTrue(resultEntries.All(x => x.Value == x.Key + 1 + arg));
+
+ // Remove entries
+ res = cache.InvokeAll(entries.Keys, new T {Remove = true}, arg);
+
+ Assert.IsTrue(res.All(x => x.Value.Result == 0));
+ Assert.AreEqual(0, cache.GetAll(entries.Keys).Count);
+
+ // Non-existing entries
+ res = cache.InvokeAll(entries.Keys, new T {Exists = false}, arg);
+
+ Assert.IsTrue(res.All(x => x.Value.Result == arg));
+ Assert.IsTrue(cache.GetAll(entries.Keys).All(x => x.Value == arg));
+
+ // Test exceptions
+ var errKey = entries.Keys.Reverse().Take(5).Last();
+
+ TestInvokeAllException(cache, entries, new T { ThrowErr = true, ThrowOnKey = errKey }, arg, errKey);
+ TestInvokeAllException(cache, entries, new T { ThrowErrPortable = true, ThrowOnKey = errKey },
+ arg, errKey);
+ TestInvokeAllException(cache, entries, new T { ThrowErrNonSerializable = true, ThrowOnKey = errKey },
+ arg, errKey, "SerializationException");
+
+ }
+
+ private static void TestInvokeAllException<T>(ICache<int, int> cache, Dictionary<int, int> entries,
+ T processor, int arg, int errKey, string exceptionText = null) where T : AddArgCacheEntryProcessor
+ {
+ var res = cache.InvokeAll(entries.Keys, processor, arg);
+
+ foreach (var procRes in res)
+ {
+ if (procRes.Key == errKey)
+ // ReSharper disable once AccessToForEachVariableInClosure
+ AssertThrowsCacheEntryProcessorException(() => { var x = procRes.Value.Result; }, exceptionText);
+ else
+ Assert.Greater(procRes.Value.Result, 0);
+ }
+ }
+
+ /// <summary>
+ /// Test skip-store semantics.
+ /// </summary>
+ [Test]
+ public void TestSkipStore()
+ {
+ CacheProxyImpl<int, int> cache = (CacheProxyImpl<int, int>)Cache();
+
+ Assert.IsFalse(cache.SkipStore);
+
+ // Ensure correct flag set.
+ CacheProxyImpl<int, int> cacheSkipStore1 = (CacheProxyImpl<int, int>)cache.WithSkipStore();
+
+ Assert.AreNotSame(cache, cacheSkipStore1);
+ Assert.IsFalse(cache.SkipStore);
+ Assert.IsTrue(cacheSkipStore1.SkipStore);
+
+ // Ensure that the same instance is returned if flag is already set.
+ CacheProxyImpl<int, int> cacheSkipStore2 = (CacheProxyImpl<int, int>)cacheSkipStore1.WithSkipStore();
+
+ Assert.IsTrue(cacheSkipStore2.SkipStore);
+ Assert.AreSame(cacheSkipStore1, cacheSkipStore2);
+
+ // Ensure other flags are preserved.
+ Assert.IsTrue(((CacheProxyImpl<int, int>)cache.WithKeepPortable<int, int>().WithSkipStore()).IsKeepPortable);
+ Assert.IsTrue(cache.WithAsync().WithSkipStore().IsAsync);
+ }
+
+ [Test]
+ public void TestCacheMetrics()
+ {
+ var cache = Cache();
+
+ cache.Put(1, 1);
+
+ var m = cache.GetMetrics();
+
+ Assert.AreEqual(cache.Name, m.CacheName);
+
+ Assert.AreEqual(cache.GetSize(), m.Size);
+ }
+
+ [Test]
+ public void TestRebalance()
+ {
+ var cache = Cache();
+
+ var fut = cache.Rebalance();
+
+ Assert.IsNull(fut.Get());
+ }
+
+ [Test]
+ public void TestCreate()
+ {
+ // Create a cache with random name
+ var randomName = "template" + Guid.NewGuid();
+
+ // Can't get non-
<TRUNCATED>
[33/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
new file mode 100644
index 0000000..12c9992
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
@@ -0,0 +1,217 @@
+/*
+ * 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.Compute
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Threading;
+ using Apache.Ignite.Core.Portable;
+ using Apache.Ignite.Core.Tests.Process;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Base class for all task-related tests.
+ /// </summary>
+ public abstract class AbstractTaskTest
+ {
+ /** */
+ protected const string Grid1Name = "grid1";
+
+ /** */
+ protected const string Grid2Name = "grid2";
+
+ /** */
+ protected const string Grid3Name = "grid3";
+
+ /** */
+ protected const string Cache1Name = "cache1";
+
+ /** Whether this is a test with forked JVMs. */
+ private readonly bool _fork;
+
+ /** First node. */
+ [NonSerialized]
+ protected IIgnite Grid1;
+
+ /** Second node. */
+ [NonSerialized]
+ private IIgnite _grid2;
+
+ /** Third node. */
+ [NonSerialized]
+ private IIgnite _grid3;
+
+ /** Second process. */
+ [NonSerialized]
+ private IgniteProcess _proc2;
+
+ /** Third process. */
+ [NonSerialized]
+ private IgniteProcess _proc3;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="fork">Fork flag.</param>
+ protected AbstractTaskTest(bool fork)
+ {
+ _fork = fork;
+ }
+
+ /// <summary>
+ /// Initialization routine.
+ /// </summary>
+ [TestFixtureSetUp]
+ public void InitClient()
+ {
+ TestUtils.KillProcesses();
+
+ if (_fork)
+ {
+ Grid1 = Ignition.Start(Configuration("config\\compute\\compute-standalone.xml"));
+
+ _proc2 = Fork("config\\compute\\compute-standalone.xml");
+
+ while (true)
+ {
+ if (!_proc2.Alive)
+ throw new Exception("Process 2 died unexpectedly: " + _proc2.Join());
+
+ if (Grid1.GetCluster().GetNodes().Count < 2)
+ Thread.Sleep(100);
+ else
+ break;
+ }
+
+ _proc3 = Fork("config\\compute\\compute-standalone.xml");
+
+ while (true)
+ {
+ if (!_proc3.Alive)
+ throw new Exception("Process 3 died unexpectedly: " + _proc3.Join());
+
+ if (Grid1.GetCluster().GetNodes().Count < 3)
+ Thread.Sleep(100);
+ else
+ break;
+ }
+ }
+ else
+ {
+ Grid1 = Ignition.Start(Configuration("config\\compute\\compute-grid1.xml"));
+ _grid2 = Ignition.Start(Configuration("config\\compute\\compute-grid2.xml"));
+ _grid3 = Ignition.Start(Configuration("config\\compute\\compute-grid3.xml"));
+ }
+ }
+
+ [SetUp]
+ public void BeforeTest()
+ {
+ Console.WriteLine("Test started: " + TestContext.CurrentContext.Test.Name);
+ }
+
+ [TestFixtureTearDown]
+ public void StopClient()
+ {
+ if (Grid1 != null)
+ Ignition.Stop(Grid1.Name, true);
+
+ if (_fork)
+ {
+ if (_proc2 != null) {
+ _proc2.Kill();
+
+ _proc2.Join();
+ }
+
+ if (_proc3 != null)
+ {
+ _proc3.Kill();
+
+ _proc3.Join();
+ }
+ }
+ else
+ {
+ if (_grid2 != null)
+ Ignition.Stop(_grid2.Name, true);
+
+ if (_grid3 != null)
+ Ignition.Stop(_grid3.Name, true);
+ }
+ }
+
+ /// <summary>
+ /// Configuration for node.
+ /// </summary>
+ /// <param name="path">Path to Java XML configuration.</param>
+ /// <returns>Node configuration.</returns>
+ protected IgniteConfiguration Configuration(string path)
+ {
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ if (!_fork)
+ {
+ PortableConfiguration portCfg = new PortableConfiguration();
+
+ ICollection<PortableTypeConfiguration> portTypeCfgs = new List<PortableTypeConfiguration>();
+
+ PortableTypeConfigurations(portTypeCfgs);
+
+ portCfg.TypeConfigurations = portTypeCfgs;
+
+ cfg.PortableConfiguration = portCfg;
+ }
+
+ cfg.JvmClasspath = TestUtils.CreateTestClasspath();
+
+ cfg.JvmOptions = TestUtils.TestJavaOptions();
+
+ cfg.SpringConfigUrl = path;
+
+ return cfg;
+ }
+
+ /// <summary>
+ /// Create forked process with the following Spring config.
+ /// </summary>
+ /// <param name="path">Path to Java XML configuration.</param>
+ /// <returns>Forked process.</returns>
+ private static IgniteProcess Fork(string path)
+ {
+ return new IgniteProcess(
+ "-springConfigUrl=" + path,
+ "-J-ea",
+ "-J-Xcheck:jni",
+ "-J-Xms512m",
+ "-J-Xmx512m",
+ "-J-DIGNITE_QUIET=false"
+ //"-J-Xnoagent", "-J-Djava.compiler=NONE", "-J-Xdebug", "-J-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5006"
+ );
+ }
+
+ /// <summary>
+ /// Define portable types.
+ /// </summary>
+ /// <param name="portTypeCfgs">Portable type configurations.</param>
+ protected virtual void PortableTypeConfigurations(ICollection<PortableTypeConfiguration> portTypeCfgs)
+ {
+ // No-op.
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ClosureTaskTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ClosureTaskTest.cs
new file mode 100644
index 0000000..8664413
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ClosureTaskTest.cs
@@ -0,0 +1,390 @@
+/*
+ * 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.Compute
+{
+ using System;
+ using System.Collections.Generic;
+ using Apache.Ignite.Core.Compute;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests for distributed closure executions.
+ /// </summary>
+ public abstract class ClosureTaskTest : AbstractTaskTest
+ {
+ /** Amount of multiple clousres. */
+ private const int MultiCloCnt = 5;
+
+ /** */
+ protected const string ErrMsg = "An error has occurred.";
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="fork">Fork mode.</param>
+ protected ClosureTaskTest(bool fork) : base(fork) { }
+
+ /// <summary>
+ /// Test for single closure returning result.
+ /// </summary>
+ [Test]
+ public void TestExecuteSingle()
+ {
+ var res = Grid1.GetCompute().Call(OutFunc(false));
+
+ CheckResult(res);
+ }
+
+ /// <summary>
+ /// Test for single closure returning exception.
+ /// </summary>
+ [Test]
+ public void TestExecuteSingleException()
+ {
+ try
+ {
+ Grid1.GetCompute().Call(OutFunc(true));
+
+ Assert.Fail();
+ }
+ catch (Exception e)
+ {
+ CheckError(e);
+ }
+ }
+
+ /// <summary>
+ /// Test for multiple closures execution.
+ /// </summary>
+ [Test]
+ public void TestExecuteMultiple()
+ {
+ var clos = new List<IComputeFunc<object>>(MultiCloCnt);
+
+ for (int i = 0; i < MultiCloCnt; i++)
+ clos.Add(OutFunc(false));
+
+ ICollection<object> ress = Grid1.GetCompute().Call(clos);
+
+ foreach (object res in ress)
+ CheckResult(res);
+ }
+
+ /// <summary>
+ /// Test for multiple closures execution.
+ /// </summary>
+ [Test]
+ public void TestExecuteMultipleReduced()
+ {
+ var clos = new List<IComputeFunc<object>>(MultiCloCnt);
+
+ for (int i = 0; i < MultiCloCnt; i++)
+ clos.Add(OutFunc(false));
+
+ ICollection<object> ress = Grid1.GetCompute().Call(clos, new Reducer(false));
+
+ foreach (object res in ress)
+ CheckResult(res);
+ }
+
+ /// <summary>
+ /// Test for multiple closures execution with exceptions thrown from some of them.
+ /// </summary>
+ [Test]
+ public void TestExecuteMultipleException()
+ {
+ var clos = new List<IComputeFunc<object>>(MultiCloCnt);
+
+ for (int i = 0; i < MultiCloCnt; i++)
+ clos.Add(OutFunc(i % 2 == 0)); // Some closures will be faulty.
+
+ try
+ {
+ Grid1.GetCompute().Call(clos);
+
+ Assert.Fail();
+ }
+ catch (Exception e)
+ {
+ CheckError(e);
+ }
+ }
+
+ /// <summary>
+ /// Test broadcast out-closure execution.
+ /// </summary>
+ [Test]
+ public void TestBroadcastOut()
+ {
+ ICollection<object> ress = Grid1.GetCompute().Broadcast(OutFunc(false));
+
+ foreach (object res in ress)
+ CheckResult(res);
+ }
+
+ /// <summary>
+ /// Test broadcast out-closure execution with exception.
+ /// </summary>
+ [Test]
+ public void TestBroadcastOutException()
+ {
+ try
+ {
+ Grid1.GetCompute().Broadcast(OutFunc(true));
+
+ Assert.Fail();
+ }
+ catch (Exception e)
+ {
+ CheckError(e);
+ }
+ }
+
+ /// <summary>
+ /// Test broadcast in-out-closure execution.
+ /// </summary>
+ [Test]
+ public void TestBroadcastInOut()
+ {
+ ICollection<object> ress = Grid1.GetCompute().Broadcast(Func(false), 1);
+
+ foreach (object res in ress)
+ CheckResult(res);
+ }
+
+ /// <summary>
+ /// Test broadcast in-out-closure execution with exception.
+ /// </summary>
+ [Test]
+ public void TestBroadcastInOutException()
+ {
+ try
+ {
+ Grid1.GetCompute().Broadcast(Func(true), 1);
+
+ Assert.Fail();
+ }
+ catch (Exception e)
+ {
+ CheckError(e);
+ }
+ }
+
+ /// <summary>
+ /// Test apply in-out-closure execution.
+ /// </summary>
+ [Test]
+ public void TestApply()
+ {
+ object res = Grid1.GetCompute().Apply(Func(false), 1);
+
+ CheckResult(res);
+ }
+
+ /// <summary>
+ /// Test apply in-out-closure execution with exception.
+ /// </summary>
+ [Test]
+ public void TestApplyException()
+ {
+ try
+ {
+ Grid1.GetCompute().Apply(Func(true), 1);
+
+ Assert.Fail();
+ }
+ catch (Exception e)
+ {
+ CheckError(e);
+ }
+ }
+
+ /// <summary>
+ /// Test apply multiple in-out-closures execution.
+ /// </summary>
+ [Test]
+ public void TestApplyMultiple()
+ {
+ var args = new List<object>(MultiCloCnt);
+
+ for (int i = 0; i < MultiCloCnt; i++)
+ args.Add(1);
+
+ Console.WriteLine("START TASK");
+
+ var ress = Grid1.GetCompute().Apply(Func(false), args);
+
+ Console.WriteLine("END TASK.");
+
+ foreach (object res in ress)
+ CheckResult(res);
+ }
+
+ /// <summary>
+ /// Test apply multiple in-out-closures execution with exception.
+ /// </summary>
+ [Test]
+ public void TestApplyMultipleException()
+ {
+ ICollection<int> args = new List<int>(MultiCloCnt);
+
+ for (int i = 0; i < MultiCloCnt; i++)
+ args.Add(1);
+
+ try
+ {
+ Grid1.GetCompute().Apply(Func(true), args);
+
+ Assert.Fail();
+ }
+ catch (Exception e)
+ {
+ CheckError(e);
+ }
+ }
+
+ /// <summary>
+ /// Test apply multiple in-out-closures execution with reducer.
+ /// </summary>
+ [Test]
+ public void TestApplyMultipleReducer()
+ {
+ var args = new List<object>(MultiCloCnt);
+
+ for (int i = 0; i < MultiCloCnt; i++)
+ args.Add(1);
+
+ ICollection<object> ress =
+ Grid1.GetCompute().Apply(Func(false), args, new Reducer(false));
+
+ foreach (object res in ress)
+ CheckResult(res);
+ }
+
+ /// <summary>
+ /// Test apply multiple in-out-closures execution with reducer and exception thrown from closure.
+ /// </summary>
+ [Test]
+ public void TestAppylMultipleReducerJobException()
+ {
+ List<object> args = new List<object>(MultiCloCnt);
+
+ for (int i = 0; i < MultiCloCnt; i++)
+ args.Add(1);
+
+ try
+ {
+ Grid1.GetCompute().Apply(Func(true), args, new Reducer(false));
+
+ Assert.Fail();
+ }
+ catch (Exception e)
+ {
+ CheckError(e);
+ }
+ }
+
+ /// <summary>
+ /// Test apply multiple in-out-closures execution with reducer and exception thrown from reducer.
+ /// </summary>
+ [Test]
+ public void TestAppylMultipleReducerReduceException()
+ {
+ var args = new List<object>(MultiCloCnt);
+
+ for (int i = 0; i < MultiCloCnt; i++)
+ args.Add(1);
+
+ try
+ {
+ Grid1.GetCompute().Apply(Func(false), args, new Reducer(true));
+
+ Assert.Fail();
+ }
+ catch (Exception e)
+ {
+ Assert.AreEqual(typeof(Exception), e.GetType());
+
+ Assert.AreEqual(ErrMsg, e.Message);
+ }
+ }
+
+ /// <summary>
+ /// Create out-only closure.
+ /// </summary>
+ /// <param name="err">Error flag.</param>
+ /// <returns>Closure.</returns>
+ protected abstract IComputeFunc<object> OutFunc(bool err);
+
+ /// <summary>
+ /// Create in-out closure.
+ /// </summary>
+ /// <param name="err">Error flag.</param>
+ /// <returns>Closure.</returns>
+ protected abstract IComputeFunc<object, object> Func(bool err);
+
+ /// <summary>
+ /// Check result.
+ /// </summary>
+ /// <param name="res">Result.</param>
+ protected abstract void CheckResult(object res);
+
+ /// <summary>
+ /// Check error.
+ /// </summary>
+ /// <param name="err">Error.</param>
+ protected abstract void CheckError(Exception err);
+
+ /// <summary>
+ /// Test reducer.
+ /// </summary>
+ public class Reducer : IComputeReducer<object, ICollection<object>>
+ {
+ /** Whether to throw an error on reduce. */
+ private readonly bool _err;
+
+ /** Results. */
+ private readonly ICollection<object> _ress = new List<object>();
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="err">Error.</param>
+ public Reducer(bool err)
+ {
+ _err = err;
+ }
+
+ /** <inheritDoc /> */
+ public bool Collect(object res)
+ {
+ _ress.Add(res);
+
+ return true;
+ }
+
+ /** <inheritDoc /> */
+ public ICollection<object> Reduce()
+ {
+ if (_err)
+ throw new Exception(ErrMsg);
+ return _ress;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
new file mode 100644
index 0000000..039813b
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
@@ -0,0 +1,1281 @@
+/*
+ * 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.
+ */
+
+// ReSharper disable SpecifyACultureInStringConversionExplicitly
+namespace Apache.Ignite.Core.Tests.Compute
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Compute;
+ using Apache.Ignite.Core.Impl;
+ using Apache.Ignite.Core.Portable;
+ using Apache.Ignite.Core.Resource;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests for compute.
+ /// </summary>
+ public class ComputeApiTest
+ {
+ /** Echo task name. */
+ private const string EchoTask = "org.apache.ignite.platform.PlatformComputeEchoTask";
+
+ /** Portable argument task name. */
+ private const string PortableArgTask = "org.apache.ignite.platform.PlatformComputePortableArgTask";
+
+ /** Broadcast task name. */
+ private const string BroadcastTask = "org.apache.ignite.platform.PlatformComputeBroadcastTask";
+
+ /** Broadcast task name. */
+ private const string DecimalTask = "org.apache.ignite.platform.PlatformComputeDecimalTask";
+
+ /** Java portable class name. */
+ private const string JavaPortableCls = "GridInteropComputeJavaPortable";
+
+ /** Echo type: null. */
+ private const int EchoTypeNull = 0;
+
+ /** Echo type: byte. */
+ private const int EchoTypeByte = 1;
+
+ /** Echo type: bool. */
+ private const int EchoTypeBool = 2;
+
+ /** Echo type: short. */
+ private const int EchoTypeShort = 3;
+
+ /** Echo type: char. */
+ private const int EchoTypeChar = 4;
+
+ /** Echo type: int. */
+ private const int EchoTypeInt = 5;
+
+ /** Echo type: long. */
+ private const int EchoTypeLong = 6;
+
+ /** Echo type: float. */
+ private const int EchoTypeFloat = 7;
+
+ /** Echo type: double. */
+ private const int EchoTypeDouble = 8;
+
+ /** Echo type: array. */
+ private const int EchoTypeArray = 9;
+
+ /** Echo type: collection. */
+ private const int EchoTypeCollection = 10;
+
+ /** Echo type: map. */
+ private const int EchoTypeMap = 11;
+
+ /** Echo type: portable. */
+ private const int EchoTypePortable = 12;
+
+ /** Echo type: portable (Java only). */
+ private const int EchoTypePortableJava = 13;
+
+ /** Type: object array. */
+ private const int EchoTypeObjArray = 14;
+
+ /** Type: portable object array. */
+ private const int EchoTypePortableArray = 15;
+
+ /** Type: enum. */
+ private const int EchoTypeEnum = 16;
+
+ /** Type: enum array. */
+ private const int EchoTypeEnumArray = 17;
+
+ /** First node. */
+ private IIgnite _grid1;
+
+ /** Second node. */
+ private IIgnite _grid2;
+
+ /** Third node. */
+ private IIgnite _grid3;
+
+ /// <summary>
+ /// Initialization routine.
+ /// </summary>
+ [TestFixtureSetUp]
+ public void InitClient()
+ {
+ //TestUtils.JVM_DEBUG = true;
+ TestUtils.KillProcesses();
+
+ _grid1 = Ignition.Start(Configuration("config\\compute\\compute-grid1.xml"));
+ _grid2 = Ignition.Start(Configuration("config\\compute\\compute-grid2.xml"));
+ _grid3 = Ignition.Start(Configuration("config\\compute\\compute-grid3.xml"));
+ }
+
+ [TestFixtureTearDown]
+ public void StopClient()
+ {
+ if (_grid1 != null)
+ Ignition.Stop(_grid1.Name, true);
+
+ if (_grid2 != null)
+ Ignition.Stop(_grid2.Name, true);
+
+ if (_grid3 != null)
+ Ignition.Stop(_grid3.Name, true);
+ }
+
+ [TearDown]
+ public void AfterTest()
+ {
+ TestUtils.AssertHandleRegistryIsEmpty(1000, _grid1, _grid2, _grid3);
+ }
+
+ /// <summary>
+ /// Test that it is possible to get projection from grid.
+ /// </summary>
+ [Test]
+ public void TestProjection()
+ {
+ IClusterGroup prj = _grid1.GetCluster();
+
+ Assert.NotNull(prj);
+
+ Assert.IsTrue(prj == prj.Ignite);
+ }
+
+ /// <summary>
+ /// Test getting cache with default (null) name.
+ /// </summary>
+ [Test]
+ public void TestCacheDefaultName()
+ {
+ var cache = _grid1.GetCache<int, int>(null);
+
+ Assert.IsNotNull(cache);
+
+ cache.GetAndPut(1, 1);
+
+ Assert.AreEqual(1, cache.Get(1));
+ }
+
+ /// <summary>
+ /// Test non-existent cache.
+ /// </summary>
+ [Test]
+ public void TestNonExistentCache()
+ {
+ Assert.Catch(typeof(ArgumentException), () =>
+ {
+ _grid1.GetCache<int, int>("bad_name");
+ });
+ }
+
+ /// <summary>
+ /// Test node content.
+ /// </summary>
+ [Test]
+ public void TestNodeContent()
+ {
+ ICollection<IClusterNode> nodes = _grid1.GetCluster().GetNodes();
+
+ foreach (IClusterNode node in nodes)
+ {
+ Assert.NotNull(node.Addresses);
+ Assert.IsTrue(node.Addresses.Count > 0);
+ Assert.Throws<NotSupportedException>(() => node.Addresses.Add("addr"));
+
+ Assert.NotNull(node.GetAttributes());
+ Assert.IsTrue(node.GetAttributes().Count > 0);
+ Assert.Throws<NotSupportedException>(() => node.GetAttributes().Add("key", "val"));
+
+ Assert.NotNull(node.HostNames);
+ Assert.Throws<NotSupportedException>(() => node.HostNames.Add("h"));
+
+ Assert.IsTrue(node.Id != Guid.Empty);
+
+ Assert.IsTrue(node.Order > 0);
+
+ Assert.NotNull(node.GetMetrics());
+ }
+ }
+
+ /// <summary>
+ /// Test cluster metrics.
+ /// </summary>
+ [Test]
+ public void TestClusterMetrics()
+ {
+ var cluster = _grid1.GetCluster();
+
+ IClusterMetrics metrics = cluster.GetMetrics();
+
+ Assert.IsNotNull(metrics);
+
+ Assert.AreEqual(cluster.GetNodes().Count, metrics.TotalNodes);
+
+ Thread.Sleep(2000);
+
+ IClusterMetrics newMetrics = cluster.GetMetrics();
+
+ Assert.IsFalse(metrics == newMetrics);
+ Assert.IsTrue(metrics.LastUpdateTime < newMetrics.LastUpdateTime);
+ }
+
+ /// <summary>
+ /// Test cluster metrics.
+ /// </summary>
+ [Test]
+ public void TestNodeMetrics()
+ {
+ var node = _grid1.GetCluster().GetNode();
+
+ IClusterMetrics metrics = node.GetMetrics();
+
+ Assert.IsNotNull(metrics);
+
+ Assert.IsTrue(metrics == node.GetMetrics());
+
+ Thread.Sleep(2000);
+
+ IClusterMetrics newMetrics = node.GetMetrics();
+
+ Assert.IsFalse(metrics == newMetrics);
+ Assert.IsTrue(metrics.LastUpdateTime < newMetrics.LastUpdateTime);
+ }
+
+ /// <summary>
+ /// Test cluster metrics.
+ /// </summary>
+ [Test]
+ public void TestResetMetrics()
+ {
+ var cluster = _grid1.GetCluster();
+
+ Thread.Sleep(2000);
+
+ var metrics1 = cluster.GetMetrics();
+
+ cluster.ResetMetrics();
+
+ var metrics2 = cluster.GetMetrics();
+
+ Assert.IsNotNull(metrics1);
+ Assert.IsNotNull(metrics2);
+ }
+
+ /// <summary>
+ /// Test node ping.
+ /// </summary>
+ [Test]
+ public void TestPingNode()
+ {
+ var cluster = _grid1.GetCluster();
+
+ Assert.IsTrue(cluster.GetNodes().Select(node => node.Id).All(cluster.PingNode));
+
+ Assert.IsFalse(cluster.PingNode(Guid.NewGuid()));
+ }
+
+ /// <summary>
+ /// Tests the topology version.
+ /// </summary>
+ [Test]
+ public void TestTopologyVersion()
+ {
+ var cluster = _grid1.GetCluster();
+
+ var topVer = cluster.TopologyVersion;
+
+ Ignition.Stop(_grid3.Name, true);
+
+ Assert.AreEqual(topVer + 1, _grid1.GetCluster().TopologyVersion);
+
+ _grid3 = Ignition.Start(Configuration("config\\compute\\compute-grid3.xml"));
+
+ Assert.AreEqual(topVer + 2, _grid1.GetCluster().TopologyVersion);
+ }
+
+ /// <summary>
+ /// Tests the topology by version.
+ /// </summary>
+ [Test]
+ public void TestTopology()
+ {
+ var cluster = _grid1.GetCluster();
+
+ Assert.AreEqual(1, cluster.GetTopology(1).Count);
+
+ Assert.AreEqual(null, cluster.GetTopology(int.MaxValue));
+
+ // Check that Nodes and Topology return the same for current version
+ var topVer = cluster.TopologyVersion;
+
+ var top = cluster.GetTopology(topVer);
+
+ var nodes = cluster.GetNodes();
+
+ Assert.AreEqual(top.Count, nodes.Count);
+
+ Assert.IsTrue(top.All(nodes.Contains));
+
+ // Stop/start node to advance version and check that history is still correct
+ Assert.IsTrue(Ignition.Stop(_grid2.Name, true));
+
+ try
+ {
+ top = cluster.GetTopology(topVer);
+
+ Assert.AreEqual(top.Count, nodes.Count);
+
+ Assert.IsTrue(top.All(nodes.Contains));
+ }
+ finally
+ {
+ _grid2 = Ignition.Start(Configuration("config\\compute\\compute-grid2.xml"));
+ }
+ }
+
+ /// <summary>
+ /// Test nodes in full topology.
+ /// </summary>
+ [Test]
+ public void TestNodes()
+ {
+ Assert.IsNotNull(_grid1.GetCluster().GetNode());
+
+ ICollection<IClusterNode> nodes = _grid1.GetCluster().GetNodes();
+
+ Assert.IsTrue(nodes.Count == 3);
+
+ // Check subsequent call on the same topology.
+ nodes = _grid1.GetCluster().GetNodes();
+
+ Assert.IsTrue(nodes.Count == 3);
+
+ Assert.IsTrue(Ignition.Stop(_grid2.Name, true));
+
+ // Check subsequent calls on updating topologies.
+ nodes = _grid1.GetCluster().GetNodes();
+
+ Assert.IsTrue(nodes.Count == 2);
+
+ nodes = _grid1.GetCluster().GetNodes();
+
+ Assert.IsTrue(nodes.Count == 2);
+
+ _grid2 = Ignition.Start(Configuration("config\\compute\\compute-grid2.xml"));
+
+ nodes = _grid1.GetCluster().GetNodes();
+
+ Assert.IsTrue(nodes.Count == 3);
+ }
+
+ /// <summary>
+ /// Test "ForNodes" and "ForNodeIds".
+ /// </summary>
+ [Test]
+ public void TestForNodes()
+ {
+ ICollection<IClusterNode> nodes = _grid1.GetCluster().GetNodes();
+
+ IClusterNode first = nodes.ElementAt(0);
+ IClusterNode second = nodes.ElementAt(1);
+
+ IClusterGroup singleNodePrj = _grid1.GetCluster().ForNodeIds(first.Id);
+ Assert.AreEqual(1, singleNodePrj.GetNodes().Count);
+ Assert.AreEqual(first.Id, singleNodePrj.GetNodes().First().Id);
+
+ singleNodePrj = _grid1.GetCluster().ForNodeIds(new List<Guid> { first.Id });
+ Assert.AreEqual(1, singleNodePrj.GetNodes().Count);
+ Assert.AreEqual(first.Id, singleNodePrj.GetNodes().First().Id);
+
+ singleNodePrj = _grid1.GetCluster().ForNodes(first);
+ Assert.AreEqual(1, singleNodePrj.GetNodes().Count);
+ Assert.AreEqual(first.Id, singleNodePrj.GetNodes().First().Id);
+
+ singleNodePrj = _grid1.GetCluster().ForNodes(new List<IClusterNode> { first });
+ Assert.AreEqual(1, singleNodePrj.GetNodes().Count);
+ Assert.AreEqual(first.Id, singleNodePrj.GetNodes().First().Id);
+
+ IClusterGroup multiNodePrj = _grid1.GetCluster().ForNodeIds(first.Id, second.Id);
+ Assert.AreEqual(2, multiNodePrj.GetNodes().Count);
+ Assert.IsTrue(multiNodePrj.GetNodes().Contains(first));
+ Assert.IsTrue(multiNodePrj.GetNodes().Contains(second));
+
+ multiNodePrj = _grid1.GetCluster().ForNodeIds(new[] {first, second}.Select(x => x.Id));
+ Assert.AreEqual(2, multiNodePrj.GetNodes().Count);
+ Assert.IsTrue(multiNodePrj.GetNodes().Contains(first));
+ Assert.IsTrue(multiNodePrj.GetNodes().Contains(second));
+
+ multiNodePrj = _grid1.GetCluster().ForNodes(first, second);
+ Assert.AreEqual(2, multiNodePrj.GetNodes().Count);
+ Assert.IsTrue(multiNodePrj.GetNodes().Contains(first));
+ Assert.IsTrue(multiNodePrj.GetNodes().Contains(second));
+
+ multiNodePrj = _grid1.GetCluster().ForNodes(new List<IClusterNode> { first, second });
+ Assert.AreEqual(2, multiNodePrj.GetNodes().Count);
+ Assert.IsTrue(multiNodePrj.GetNodes().Contains(first));
+ Assert.IsTrue(multiNodePrj.GetNodes().Contains(second));
+ }
+
+ /// <summary>
+ /// Test "ForNodes" and "ForNodeIds". Make sure lazy enumerables are enumerated only once.
+ /// </summary>
+ [Test]
+ public void TestForNodesLaziness()
+ {
+ var nodes = _grid1.GetCluster().GetNodes().Take(2).ToArray();
+
+ var callCount = 0;
+
+ Func<IClusterNode, IClusterNode> nodeSelector = node =>
+ {
+ callCount++;
+ return node;
+ };
+
+ Func<IClusterNode, Guid> idSelector = node =>
+ {
+ callCount++;
+ return node.Id;
+ };
+
+ var projection = _grid1.GetCluster().ForNodes(nodes.Select(nodeSelector));
+ Assert.AreEqual(2, projection.GetNodes().Count);
+ Assert.AreEqual(2, callCount);
+
+ projection = _grid1.GetCluster().ForNodeIds(nodes.Select(idSelector));
+ Assert.AreEqual(2, projection.GetNodes().Count);
+ Assert.AreEqual(4, callCount);
+ }
+
+ /// <summary>
+ /// Test for local node projection.
+ /// </summary>
+ [Test]
+ public void TestForLocal()
+ {
+ IClusterGroup prj = _grid1.GetCluster().ForLocal();
+
+ Assert.AreEqual(1, prj.GetNodes().Count);
+ Assert.AreEqual(_grid1.GetCluster().GetLocalNode(), prj.GetNodes().First());
+ }
+
+ /// <summary>
+ /// Test for remote nodes projection.
+ /// </summary>
+ [Test]
+ public void TestForRemotes()
+ {
+ ICollection<IClusterNode> nodes = _grid1.GetCluster().GetNodes();
+
+ IClusterGroup prj = _grid1.GetCluster().ForRemotes();
+
+ Assert.AreEqual(2, prj.GetNodes().Count);
+ Assert.IsTrue(nodes.Contains(prj.GetNodes().ElementAt(0)));
+ Assert.IsTrue(nodes.Contains(prj.GetNodes().ElementAt(1)));
+ }
+
+ /// <summary>
+ /// Test for host nodes projection.
+ /// </summary>
+ [Test]
+ public void TestForHost()
+ {
+ ICollection<IClusterNode> nodes = _grid1.GetCluster().GetNodes();
+
+ IClusterGroup prj = _grid1.GetCluster().ForHost(nodes.First());
+
+ Assert.AreEqual(3, prj.GetNodes().Count);
+ Assert.IsTrue(nodes.Contains(prj.GetNodes().ElementAt(0)));
+ Assert.IsTrue(nodes.Contains(prj.GetNodes().ElementAt(1)));
+ Assert.IsTrue(nodes.Contains(prj.GetNodes().ElementAt(2)));
+ }
+
+ /// <summary>
+ /// Test for oldest, youngest and random projections.
+ /// </summary>
+ [Test]
+ public void TestForOldestYoungestRandom()
+ {
+ ICollection<IClusterNode> nodes = _grid1.GetCluster().GetNodes();
+
+ IClusterGroup prj = _grid1.GetCluster().ForYoungest();
+ Assert.AreEqual(1, prj.GetNodes().Count);
+ Assert.IsTrue(nodes.Contains(prj.GetNode()));
+
+ prj = _grid1.GetCluster().ForOldest();
+ Assert.AreEqual(1, prj.GetNodes().Count);
+ Assert.IsTrue(nodes.Contains(prj.GetNode()));
+
+ prj = _grid1.GetCluster().ForRandom();
+ Assert.AreEqual(1, prj.GetNodes().Count);
+ Assert.IsTrue(nodes.Contains(prj.GetNode()));
+ }
+
+ /// <summary>
+ /// Test for attribute projection.
+ /// </summary>
+ [Test]
+ public void TestForAttribute()
+ {
+ ICollection<IClusterNode> nodes = _grid1.GetCluster().GetNodes();
+
+ IClusterGroup prj = _grid1.GetCluster().ForAttribute("my_attr", "value1");
+ Assert.AreEqual(1, prj.GetNodes().Count);
+ Assert.IsTrue(nodes.Contains(prj.GetNode()));
+ Assert.AreEqual("value1", prj.GetNodes().First().GetAttribute<string>("my_attr"));
+ }
+
+ /// <summary>
+ /// Test for cache/data/client projections.
+ /// </summary>
+ [Test]
+ public void TestForCacheNodes()
+ {
+ ICollection<IClusterNode> nodes = _grid1.GetCluster().GetNodes();
+
+ // Cache nodes.
+ IClusterGroup prjCache = _grid1.GetCluster().ForCacheNodes("cache1");
+
+ Assert.AreEqual(2, prjCache.GetNodes().Count);
+
+ Assert.IsTrue(nodes.Contains(prjCache.GetNodes().ElementAt(0)));
+ Assert.IsTrue(nodes.Contains(prjCache.GetNodes().ElementAt(1)));
+
+ // Data nodes.
+ IClusterGroup prjData = _grid1.GetCluster().ForDataNodes("cache1");
+
+ Assert.AreEqual(2, prjData.GetNodes().Count);
+
+ Assert.IsTrue(prjCache.GetNodes().Contains(prjData.GetNodes().ElementAt(0)));
+ Assert.IsTrue(prjCache.GetNodes().Contains(prjData.GetNodes().ElementAt(1)));
+
+ // Client nodes.
+ IClusterGroup prjClient = _grid1.GetCluster().ForClientNodes("cache1");
+
+ Assert.AreEqual(0, prjClient.GetNodes().Count);
+ }
+
+ /// <summary>
+ /// Test for cache predicate.
+ /// </summary>
+ [Test]
+ public void TestForPredicate()
+ {
+ IClusterGroup prj1 = _grid1.GetCluster().ForPredicate(new NotAttributePredicate("value1").Apply);
+ Assert.AreEqual(2, prj1.GetNodes().Count);
+
+ IClusterGroup prj2 = prj1.ForPredicate(new NotAttributePredicate("value2").Apply);
+ Assert.AreEqual(1, prj2.GetNodes().Count);
+
+ string val;
+
+ prj2.GetNodes().First().TryGetAttribute("my_attr", out val);
+
+ Assert.IsTrue(val == null || (!val.Equals("value1") && !val.Equals("value2")));
+ }
+
+ /// <summary>
+ /// Attribute predicate.
+ /// </summary>
+ private class NotAttributePredicate
+ {
+ /** Required attribute value. */
+ private readonly string _attrVal;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="attrVal">Required attribute value.</param>
+ public NotAttributePredicate(string attrVal)
+ {
+ _attrVal = attrVal;
+ }
+
+ /** <inhreitDoc /> */
+ public bool Apply(IClusterNode node)
+ {
+ string val;
+
+ node.TryGetAttribute("my_attr", out val);
+
+ return val == null || !val.Equals(_attrVal);
+ }
+ }
+
+ /// <summary>
+ /// Test echo with decimals.
+ /// </summary>
+ [Test]
+ public void TestEchoDecimal()
+ {
+ decimal val;
+
+ Assert.AreEqual(val = decimal.Zero, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+
+ Assert.AreEqual(val = new decimal(0, 0, 1, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, 0, 1, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, 0, 1, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, 0, 1, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, 0, 1, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, 0, 1, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, 0, int.MinValue, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, 0, int.MinValue, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, 0, int.MinValue, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, 0, int.MinValue, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, 0, int.MinValue, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, 0, int.MinValue, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+
+ Assert.AreEqual(val = new decimal(0, 1, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, 1, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, 1, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, 1, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, 1, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, 1, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, int.MinValue, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, int.MinValue, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, int.MinValue, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, int.MinValue, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, int.MinValue, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, int.MinValue, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+
+ Assert.AreEqual(val = new decimal(1, 0, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(1, 0, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(1, 0, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(1, 0, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(1, 0, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(1, 0, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+
+ Assert.AreEqual(val = new decimal(1, 1, 1, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(1, 1, 1, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(1, 1, 1, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(1, 1, 1, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(1, 1, 1, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = new decimal(1, 1, 1, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+
+ Assert.AreEqual(val = decimal.Parse("65536"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("-65536"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("65536") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("-65536") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("65536") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("-65536") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+
+ Assert.AreEqual(val = decimal.Parse("4294967296"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("-4294967296"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("4294967296") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("-4294967296") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("4294967296") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("-4294967296") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+
+ Assert.AreEqual(val = decimal.Parse("281474976710656"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("-281474976710656"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("281474976710656") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("-281474976710656") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("281474976710656") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("-281474976710656") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+
+ Assert.AreEqual(val = decimal.Parse("18446744073709551616"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("-18446744073709551616"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("18446744073709551616") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("-18446744073709551616") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("18446744073709551616") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("-18446744073709551616") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+
+ Assert.AreEqual(val = decimal.Parse("1208925819614629174706176"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("-1208925819614629174706176"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("1208925819614629174706176") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("-1208925819614629174706176") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("1208925819614629174706176") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("-1208925819614629174706176") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+
+ Assert.AreEqual(val = decimal.MaxValue, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.MinValue, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.MaxValue - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.MinValue + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+
+ Assert.AreEqual(val = decimal.Parse("11,12"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+ Assert.AreEqual(val = decimal.Parse("-11,12"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+
+ // Test echo with overflow.
+ try
+ {
+ _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { null, decimal.MaxValue.ToString() + 1 });
+
+ Assert.Fail();
+ }
+ catch (IgniteException)
+ {
+ // No-op.
+ }
+ }
+
+ /// <summary>
+ /// Test echo task returning null.
+ /// </summary>
+ [Test]
+ public void TestEchoTaskNull()
+ {
+ Assert.IsNull(_grid1.GetCompute().ExecuteJavaTask<object>(EchoTask, EchoTypeNull));
+ }
+
+ /// <summary>
+ /// Test echo task returning various primitives.
+ /// </summary>
+ [Test]
+ public void TestEchoTaskPrimitives()
+ {
+ Assert.AreEqual(1, _grid1.GetCompute().ExecuteJavaTask<byte>(EchoTask, EchoTypeByte));
+ Assert.AreEqual(true, _grid1.GetCompute().ExecuteJavaTask<bool>(EchoTask, EchoTypeBool));
+ Assert.AreEqual(1, _grid1.GetCompute().ExecuteJavaTask<short>(EchoTask, EchoTypeShort));
+ Assert.AreEqual((char)1, _grid1.GetCompute().ExecuteJavaTask<char>(EchoTask, EchoTypeChar));
+ Assert.AreEqual(1, _grid1.GetCompute().ExecuteJavaTask<int>(EchoTask, EchoTypeInt));
+ Assert.AreEqual(1, _grid1.GetCompute().ExecuteJavaTask<long>(EchoTask, EchoTypeLong));
+ Assert.AreEqual((float)1, _grid1.GetCompute().ExecuteJavaTask<float>(EchoTask, EchoTypeFloat));
+ Assert.AreEqual((double)1, _grid1.GetCompute().ExecuteJavaTask<double>(EchoTask, EchoTypeDouble));
+ }
+
+ /// <summary>
+ /// Test echo task returning compound types.
+ /// </summary>
+ [Test]
+ public void TestEchoTaskCompound()
+ {
+ int[] res1 = _grid1.GetCompute().ExecuteJavaTask<int[]>(EchoTask, EchoTypeArray);
+
+ Assert.AreEqual(1, res1.Length);
+ Assert.AreEqual(1, res1[0]);
+
+ IList<int> res2 = _grid1.GetCompute().ExecuteJavaTask<IList<int>>(EchoTask, EchoTypeCollection);
+
+ Assert.AreEqual(1, res2.Count);
+ Assert.AreEqual(1, res2[0]);
+
+ IDictionary<int, int> res3 = _grid1.GetCompute().ExecuteJavaTask<IDictionary<int, int>>(EchoTask, EchoTypeMap);
+
+ Assert.AreEqual(1, res3.Count);
+ Assert.AreEqual(1, res3[1]);
+ }
+
+ /// <summary>
+ /// Test echo task returning portable object.
+ /// </summary>
+ [Test]
+ public void TestEchoTaskPortable()
+ {
+ PlatformComputePortable res = _grid1.GetCompute().ExecuteJavaTask<PlatformComputePortable>(EchoTask, EchoTypePortable);
+
+ Assert.AreEqual(1, res.Field);
+ }
+
+ /// <summary>
+ /// Test echo task returning portable object with no corresponding class definition.
+ /// </summary>
+ [Test]
+ public void TestEchoTaskPortableNoClass()
+ {
+ ICompute compute = _grid1.GetCompute();
+
+ compute.WithKeepPortable();
+
+ IPortableObject res = compute.ExecuteJavaTask<IPortableObject>(EchoTask, EchoTypePortableJava);
+
+ Assert.AreEqual(1, res.GetField<int>("field"));
+
+ // This call must fail because "keepPortable" flag is reset.
+ Assert.Catch(typeof(PortableException), () =>
+ {
+ compute.ExecuteJavaTask<IPortableObject>(EchoTask, EchoTypePortableJava);
+ });
+ }
+
+ /// <summary>
+ /// Tests the echo task returning object array.
+ /// </summary>
+ [Test]
+ public void TestEchoTaskObjectArray()
+ {
+ var res = _grid1.GetCompute().ExecuteJavaTask<string[]>(EchoTask, EchoTypeObjArray);
+
+ Assert.AreEqual(new[] {"foo", "bar", "baz"}, res);
+ }
+
+ /// <summary>
+ /// Tests the echo task returning portable array.
+ /// </summary>
+ [Test]
+ public void TestEchoTaskPortableArray()
+ {
+ var res = _grid1.GetCompute().ExecuteJavaTask<PlatformComputePortable[]>(EchoTask, EchoTypePortableArray);
+
+ Assert.AreEqual(3, res.Length);
+
+ for (var i = 0; i < res.Length; i++)
+ Assert.AreEqual(i + 1, res[i].Field);
+ }
+
+ /// <summary>
+ /// Tests the echo task returning enum.
+ /// </summary>
+ [Test]
+ public void TestEchoTaskEnum()
+ {
+ var res = _grid1.GetCompute().ExecuteJavaTask<InteropComputeEnum>(EchoTask, EchoTypeEnum);
+
+ Assert.AreEqual(InteropComputeEnum.Bar, res);
+ }
+
+ /// <summary>
+ /// Tests the echo task returning enum.
+ /// </summary>
+ [Test]
+ public void TestEchoTaskEnumArray()
+ {
+ var res = _grid1.GetCompute().ExecuteJavaTask<InteropComputeEnum[]>(EchoTask, EchoTypeEnumArray);
+
+ Assert.AreEqual(new[]
+ {
+ InteropComputeEnum.Bar,
+ InteropComputeEnum.Baz,
+ InteropComputeEnum.Foo
+ }, res);
+ }
+
+ /// <summary>
+ /// Test for portable argument in Java.
+ /// </summary>
+ [Test]
+ public void TestPortableArgTask()
+ {
+ ICompute compute = _grid1.GetCompute();
+
+ compute.WithKeepPortable();
+
+ PlatformComputeNetPortable arg = new PlatformComputeNetPortable();
+
+ arg.Field = 100;
+
+ int res = compute.ExecuteJavaTask<int>(PortableArgTask, arg);
+
+ Assert.AreEqual(arg.Field, res);
+ }
+
+ /// <summary>
+ /// Test running broadcast task.
+ /// </summary>
+ [Test]
+ public void TestBroadcastTask()
+ {
+ ICollection<Guid> res = _grid1.GetCompute().ExecuteJavaTask<ICollection<Guid>>(BroadcastTask, null);
+
+ Assert.AreEqual(3, res.Count);
+ Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(0)).GetNodes().Count);
+ Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(1)).GetNodes().Count);
+ Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(2)).GetNodes().Count);
+
+ var prj = _grid1.GetCluster().ForPredicate(node => res.Take(2).Contains(node.Id));
+
+ Assert.AreEqual(2, prj.GetNodes().Count);
+
+ ICollection<Guid> filteredRes = prj.GetCompute().ExecuteJavaTask<ICollection<Guid>>(BroadcastTask, null);
+
+ Assert.AreEqual(2, filteredRes.Count);
+ Assert.IsTrue(filteredRes.Contains(res.ElementAt(0)));
+ Assert.IsTrue(filteredRes.Contains(res.ElementAt(1)));
+ }
+
+ /// <summary>
+ /// Test running broadcast task in async mode.
+ /// </summary>
+ [Test]
+ public void TestBroadcastTaskAsync()
+ {
+ var gridCompute = _grid1.GetCompute().WithAsync();
+ Assert.IsNull(gridCompute.ExecuteJavaTask<ICollection<Guid>>(BroadcastTask, null));
+ ICollection<Guid> res = gridCompute.GetFuture<ICollection<Guid>>().Get();
+
+ Assert.AreEqual(3, res.Count);
+ Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(0)).GetNodes().Count);
+ Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(1)).GetNodes().Count);
+ Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(2)).GetNodes().Count);
+
+ var prj = _grid1.GetCluster().ForPredicate(node => res.Take(2).Contains(node.Id));
+
+ Assert.AreEqual(2, prj.GetNodes().Count);
+
+ var compute = prj.GetCompute().WithAsync();
+ Assert.IsNull(compute.ExecuteJavaTask<ICollection<Guid>>(BroadcastTask, null));
+ ICollection<Guid> filteredRes = compute.GetFuture<ICollection<Guid>>().Get();
+
+ Assert.AreEqual(2, filteredRes.Count);
+ Assert.IsTrue(filteredRes.Contains(res.ElementAt(0)));
+ Assert.IsTrue(filteredRes.Contains(res.ElementAt(1)));
+ }
+
+ /// <summary>
+ /// Tests the action broadcast.
+ /// </summary>
+ [Test]
+ public void TestBroadcastAction()
+ {
+ ComputeAction.InvokeCount = 0;
+
+ _grid1.GetCompute().Broadcast(new ComputeAction());
+
+ Assert.AreEqual(_grid1.GetCluster().GetNodes().Count, ComputeAction.InvokeCount);
+ }
+
+ /// <summary>
+ /// Tests single action run.
+ /// </summary>
+ [Test]
+ public void TestRunAction()
+ {
+ ComputeAction.InvokeCount = 0;
+
+ _grid1.GetCompute().Run(new ComputeAction());
+
+ Assert.AreEqual(1, ComputeAction.InvokeCount);
+ }
+
+ /// <summary>
+ /// Tests multiple actions run.
+ /// </summary>
+ [Test]
+ public void TestRunActions()
+ {
+ ComputeAction.InvokeCount = 0;
+
+ var actions = Enumerable.Range(0, 10).Select(x => new ComputeAction());
+
+ _grid1.GetCompute().Run(actions);
+
+ Assert.AreEqual(10, ComputeAction.InvokeCount);
+ }
+
+ /// <summary>
+ /// Tests affinity run.
+ /// </summary>
+ [Test]
+ public void TestAffinityRun()
+ {
+ const string cacheName = null;
+
+ // Test keys for non-client nodes
+ var nodes = new[] {_grid1, _grid2}.Select(x => x.GetCluster().GetLocalNode());
+
+ var aff = _grid1.GetAffinity(cacheName);
+
+ foreach (var node in nodes)
+ {
+ var primaryKey = Enumerable.Range(1, int.MaxValue).First(x => aff.IsPrimary(node, x));
+
+ var affinityKey = _grid1.GetAffinity(cacheName).GetAffinityKey<int, int>(primaryKey);
+
+ _grid1.GetCompute().AffinityRun(cacheName, affinityKey, new ComputeAction());
+
+ Assert.AreEqual(node.Id, ComputeAction.LastNodeId);
+ }
+ }
+
+ /// <summary>
+ /// Tests affinity call.
+ /// </summary>
+ [Test]
+ public void TestAffinityCall()
+ {
+ const string cacheName = null;
+
+ // Test keys for non-client nodes
+ var nodes = new[] { _grid1, _grid2 }.Select(x => x.GetCluster().GetLocalNode());
+
+ var aff = _grid1.GetAffinity(cacheName);
+
+ foreach (var node in nodes)
+ {
+ var primaryKey = Enumerable.Range(1, int.MaxValue).First(x => aff.IsPrimary(node, x));
+
+ var affinityKey = _grid1.GetAffinity(cacheName).GetAffinityKey<int, int>(primaryKey);
+
+ var result = _grid1.GetCompute().AffinityCall(cacheName, affinityKey, new ComputeFunc());
+
+ Assert.AreEqual(result, ComputeFunc.InvokeCount);
+
+ Assert.AreEqual(node.Id, ComputeFunc.LastNodeId);
+ }
+ }
+
+ /// <summary>
+ /// Test "withNoFailover" feature.
+ /// </summary>
+ [Test]
+ public void TestWithNoFailover()
+ {
+ ICollection<Guid> res = _grid1.GetCompute().WithNoFailover().ExecuteJavaTask<ICollection<Guid>>(BroadcastTask, null);
+
+ Assert.AreEqual(3, res.Count);
+ Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(0)).GetNodes().Count);
+ Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(1)).GetNodes().Count);
+ Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(2)).GetNodes().Count);
+ }
+
+ /// <summary>
+ /// Test "withTimeout" feature.
+ /// </summary>
+ [Test]
+ public void TestWithTimeout()
+ {
+ ICollection<Guid> res = _grid1.GetCompute().WithTimeout(1000).ExecuteJavaTask<ICollection<Guid>>(BroadcastTask, null);
+
+ Assert.AreEqual(3, res.Count);
+ Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(0)).GetNodes().Count);
+ Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(1)).GetNodes().Count);
+ Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(2)).GetNodes().Count);
+ }
+
+ /// <summary>
+ /// Test simple dotNet task execution.
+ /// </summary>
+ [Test]
+ public void TestNetTaskSimple()
+ {
+ int res = _grid1.GetCompute().Execute<NetSimpleJobArgument, NetSimpleJobResult, NetSimpleTaskResult>(
+ typeof(NetSimpleTask), new NetSimpleJobArgument(1)).Res;
+
+ Assert.AreEqual(_grid1.GetCompute().ClusterGroup.GetNodes().Count, res);
+ }
+
+ /// <summary>
+ /// Create configuration.
+ /// </summary>
+ /// <param name="path">XML config path.</param>
+ private IgniteConfiguration Configuration(string path)
+ {
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ PortableConfiguration portCfg = new PortableConfiguration();
+
+ ICollection<PortableTypeConfiguration> portTypeCfgs = new List<PortableTypeConfiguration>();
+
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PlatformComputePortable)));
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PlatformComputeNetPortable)));
+ portTypeCfgs.Add(new PortableTypeConfiguration(JavaPortableCls));
+
+ portCfg.TypeConfigurations = portTypeCfgs;
+
+ cfg.PortableConfiguration = portCfg;
+
+ cfg.JvmClasspath = IgniteManager.CreateClasspath(cfg, true);
+
+ cfg.JvmOptions = TestUtils.TestJavaOptions();
+
+ cfg.SpringConfigUrl = path;
+
+ return cfg;
+ }
+ }
+
+ class PlatformComputePortable
+ {
+ public int Field
+ {
+ get;
+ set;
+ }
+ }
+
+ class PlatformComputeNetPortable : PlatformComputePortable
+ {
+
+ }
+
+ [Serializable]
+ class NetSimpleTask : IComputeTask<NetSimpleJobArgument, NetSimpleJobResult, NetSimpleTaskResult>
+ {
+ /** <inheritDoc /> */
+
+ public IDictionary<IComputeJob<NetSimpleJobResult>, IClusterNode> Map(IList<IClusterNode> subgrid,
+ NetSimpleJobArgument arg)
+ {
+ var jobs = new Dictionary<IComputeJob<NetSimpleJobResult>, IClusterNode>();
+
+ for (int i = 0; i < subgrid.Count; i++)
+ {
+ NetSimpleJob job = new NetSimpleJob {Arg = arg};
+
+ jobs[job] = subgrid[i];
+ }
+
+ return jobs;
+ }
+
+ /** <inheritDoc /> */
+ public ComputeJobResultPolicy Result(IComputeJobResult<NetSimpleJobResult> res,
+ IList<IComputeJobResult<NetSimpleJobResult>> rcvd)
+ {
+ return ComputeJobResultPolicy.Wait;
+ }
+
+ /** <inheritDoc /> */
+ public NetSimpleTaskResult Reduce(IList<IComputeJobResult<NetSimpleJobResult>> results)
+ {
+ return new NetSimpleTaskResult(results.Sum(res => res.Data().Res));
+ }
+ }
+
+ [Serializable]
+ class NetSimpleJob : IComputeJob<NetSimpleJobResult>
+ {
+ public NetSimpleJobArgument Arg;
+
+ /** <inheritDoc /> */
+ public NetSimpleJobResult Execute()
+ {
+ return new NetSimpleJobResult(Arg.Arg);
+ }
+
+ /** <inheritDoc /> */
+ public void Cancel()
+ {
+ // No-op.
+ }
+ }
+
+ [Serializable]
+ class NetSimpleJobArgument
+ {
+ public int Arg;
+
+ public NetSimpleJobArgument(int arg)
+ {
+ Arg = arg;
+ }
+ }
+
+ [Serializable]
+ class NetSimpleTaskResult
+ {
+ public int Res;
+
+ public NetSimpleTaskResult(int res)
+ {
+ Res = res;
+ }
+ }
+
+ [Serializable]
+ class NetSimpleJobResult
+ {
+ public int Res;
+
+ public NetSimpleJobResult(int res)
+ {
+ Res = res;
+ }
+ }
+
+ [Serializable]
+ class ComputeAction : IComputeAction
+ {
+ [InstanceResource]
+ #pragma warning disable 649
+ private IIgnite _grid;
+
+ public static int InvokeCount;
+
+ public static Guid LastNodeId;
+
+ public void Invoke()
+ {
+ Interlocked.Increment(ref InvokeCount);
+ LastNodeId = _grid.GetCluster().GetLocalNode().Id;
+ }
+ }
+
+ interface IUserInterface<out T>
+ {
+ T Invoke();
+ }
+
+ interface INestedComputeFunc : IComputeFunc<int>
+ {
+
+ }
+
+ [Serializable]
+ class ComputeFunc : INestedComputeFunc, IUserInterface<int>
+ {
+ [InstanceResource]
+ private IIgnite _grid;
+
+ public static int InvokeCount;
+
+ public static Guid LastNodeId;
+
+ int IComputeFunc<int>.Invoke()
+ {
+ InvokeCount++;
+ LastNodeId = _grid.GetCluster().GetLocalNode().Id;
+ return InvokeCount;
+ }
+
+ int IUserInterface<int>.Invoke()
+ {
+ // Same signature as IComputeFunc<int>, but from different interface
+ throw new Exception("Invalid method");
+ }
+
+ public int Invoke()
+ {
+ // Same signature as IComputeFunc<int>, but due to explicit interface implementation this is a wrong method
+ throw new Exception("Invalid method");
+ }
+ }
+
+ public enum InteropComputeEnum
+ {
+ Foo,
+ Bar,
+ Baz
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeMultithreadedTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeMultithreadedTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeMultithreadedTest.cs
new file mode 100644
index 0000000..5b6874f
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeMultithreadedTest.cs
@@ -0,0 +1,269 @@
+/*
+ * 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.Compute
+{
+ using System;
+ using System.Collections.Generic;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Compute;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests class.
+ /// </summary>
+ [Category(TestUtils.CategoryIntensive)]
+ public class ComputeMultithreadedTest : AbstractTaskTest
+ {
+ /** */
+ private static IList<Action<ICompute>> _actions;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public ComputeMultithreadedTest() : base(false) { }
+
+ /// <summary>
+ /// Set-up routine.
+ /// </summary>
+ [SetUp]
+ public void SetUp()
+ {
+ _actions = new List<Action<ICompute>>
+ {
+ compute => { compute.Apply(new My1ArgClosure(), "zzzz"); },
+ compute => { compute.Broadcast(new My1ArgClosure(), "zzzz"); },
+ compute => { compute.Broadcast(new MyNoArgClosure("zzzz")); },
+ compute => { compute.Call(new MyNoArgClosure("zzzz")); },
+ compute => { compute.Execute(new StringLengthEmptyTask(), "zzzz"); },
+ compute =>
+ {
+ compute.Apply(new My1ArgClosure(), new List<string> {"zzzz", "a", "b"}, new MyReducer());
+ }
+ };
+
+ }
+
+ /// <summary>
+ /// Tear-down routine.
+ /// </summary>
+ [TearDown]
+ public void TearDown()
+ {
+ _actions.Clear();
+ }
+
+ /// <summary>
+ /// Test not-marshalable error occurred during map step.
+ /// </summary>
+ [Test]
+ public void TestAllTaskTypeAtSameTime()
+ {
+ Assert.AreEqual(_actions.Count, 6);
+
+ var compute = Grid1.GetCompute();
+
+ TestUtils.RunMultiThreaded(() =>
+ {
+ _actions[TestUtils.Random.Next(_actions.Count)](compute);
+ }, 4, 60);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Test]
+ public void TestSingleTaskType0()
+ {
+ Assert.AreEqual(_actions.Count, 6);
+
+ TestUtils.RunMultiThreaded(() => _actions[0](Grid1.GetCompute()), 4, 20);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Test]
+ public void TestSingleTaskType1()
+ {
+ Assert.AreEqual(_actions.Count, 6);
+
+ TestUtils.RunMultiThreaded(() => _actions[1](Grid1.GetCompute()), 4, 20);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Test]
+ public void TestSingleTaskType2()
+ {
+ Assert.AreEqual(_actions.Count, 6);
+
+ TestUtils.RunMultiThreaded(() => _actions[2](Grid1.GetCompute()), 4, 20);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Test]
+ public void TestSingleTaskType3()
+ {
+ Assert.AreEqual(_actions.Count, 6);
+
+ TestUtils.RunMultiThreaded(() => _actions[3](Grid1.GetCompute()), 4, 20);
+ }
+ /// <summary>
+ ///
+ /// </summary>
+ [Test]
+ public void TestSingleTaskType4()
+ {
+ Assert.AreEqual(_actions.Count, 6);
+
+ TestUtils.RunMultiThreaded(() => _actions[4](Grid1.GetCompute()), 4, 20);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Test]
+ public void TestSingleTaskType5()
+ {
+ Assert.AreEqual(_actions.Count, 6);
+
+ TestUtils.RunMultiThreaded(() => _actions[5](Grid1.GetCompute()), 4, 20);
+ }
+ }
+
+ /// <summary>
+ /// Test class.
+ /// </summary>
+ [Serializable]
+ public class My1ArgClosure : IComputeFunc<string, int>
+ {
+ /** <inheritDoc /> */
+ public int Invoke(string s)
+ {
+ return s.Length;
+ }
+ }
+
+ /// <summary>
+ /// Test class.
+ /// </summary>
+ [Serializable]
+ public class MyNoArgClosure : IComputeFunc<int>
+ {
+ /** */
+ private readonly string _s;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="s"></param>
+ public MyNoArgClosure(string s)
+ {
+ _s = s;
+ }
+
+ /** <inheritDoc /> */
+ public int Invoke()
+ {
+ return _s.Length;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public class StringLengthEmptyTask : IComputeTask<string, int, int>
+ {
+ /** <inheritDoc /> */
+ public IDictionary<IComputeJob<int>, IClusterNode> Map(IList<IClusterNode> subgrid, string arg)
+ {
+ var res = new Dictionary<IComputeJob<int>, IClusterNode>();
+
+ var job = new StringLengthEmptyJob(arg);
+
+ IClusterNode node = subgrid[TestUtils.Random.Next(subgrid.Count)];
+
+ res.Add(job, node);
+
+ return res;
+ }
+
+ /** <inheritDoc /> */
+ public ComputeJobResultPolicy Result(IComputeJobResult<int> res, IList<IComputeJobResult<int>> rcvd)
+ {
+ return ComputeJobResultPolicy.Wait;
+ }
+
+ /** <inheritDoc /> */
+ public int Reduce(IList<IComputeJobResult<int>> results)
+ {
+ return results.Count == 0 ? 0 : results[0].Data();
+ }
+ }
+
+ /// <summary>
+ /// Test class.
+ /// </summary>
+ [Serializable]
+ public class StringLengthEmptyJob: IComputeJob<int>
+ {
+ /** */
+ private string _s;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="s"></param>
+ public StringLengthEmptyJob(string s)
+ {
+ _s = s;
+ }
+
+ /** <inheritDoc /> */
+ public int Execute()
+ {
+ return _s.Length;
+ }
+
+ /** <inheritDoc /> */
+ public void Cancel()
+ {
+ // No-op
+ }
+ }
+
+ public class MyReducer : IComputeReducer<int, int>
+ {
+ /** */
+ private int _res;
+
+ public bool Collect(int res)
+ {
+ _res += res;
+ return true;
+ }
+
+ public int Reduce()
+ {
+ return _res;
+ }
+ }
+}
[13/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
deleted file mode 100644
index ae114f3..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
+++ /dev/null
@@ -1,2078 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// ReSharper disable NonReadonlyMemberInGetHashCode
-// ReSharper disable CompareOfFloatsByEqualityOperator
-// ReSharper disable PossibleInvalidOperationException
-// ReSharper disable UnusedAutoPropertyAccessor.Global
-// ReSharper disable MemberCanBePrivate.Global
-namespace Apache.Ignite.Core.Tests.Portable
-{
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Apache.Ignite.Core.Impl.Portable;
- using Apache.Ignite.Core.Impl.Portable.IO;
- using Apache.Ignite.Core.Portable;
- using NUnit.Framework;
-
- /// <summary>
- ///
- /// </summary>
- [TestFixture]
- public class PortableSelfTest {
- /** */
- private PortableMarshaller _marsh;
-
- /// <summary>
- ///
- /// </summary>
- [TestFixtureSetUp]
- public void BeforeTest()
- {
- _marsh = new PortableMarshaller(null);
- }
-
- /**
- * <summary>Check write of primitive boolean.</summary>
- */
- [Test]
- public void TestWritePrimitiveBool()
- {
- Assert.AreEqual(_marsh.Unmarshal<bool>(_marsh.Marshal(false)), false);
- Assert.AreEqual(_marsh.Unmarshal<bool>(_marsh.Marshal(true)), true);
-
- Assert.AreEqual(_marsh.Unmarshal<bool?>(_marsh.Marshal((bool?)false)), false);
- Assert.AreEqual(_marsh.Unmarshal<bool?>(_marsh.Marshal(null)), null);
- }
-
- /**
- * <summary>Check write of primitive boolean array.</summary>
- */
- [Test]
- public void TestWritePrimitiveBoolArray()
- {
- bool[] vals = { true, false };
-
- Assert.AreEqual(_marsh.Unmarshal<bool[]>(_marsh.Marshal(vals)), vals);
- }
-
- /**
- * <summary>Check write of primitive sbyte.</summary>
- */
- [Test]
- public void TestWritePrimitiveSbyte()
- {
- Assert.AreEqual(_marsh.Unmarshal<sbyte>(_marsh.Marshal((sbyte)1)), 1);
- Assert.AreEqual(_marsh.Unmarshal<sbyte>(_marsh.Marshal(sbyte.MinValue)), sbyte.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<sbyte>(_marsh.Marshal(sbyte.MaxValue)), sbyte.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<sbyte?>(_marsh.Marshal((sbyte?)1)), (sbyte?)1);
- Assert.AreEqual(_marsh.Unmarshal<sbyte?>(_marsh.Marshal(null)), null);
- }
-
- /**
- * <summary>Check write of primitive sbyte array.</summary>
- */
- [Test]
- public void TestWritePrimitiveSbyteArray()
- {
- sbyte[] vals = { sbyte.MinValue, 0, 1, sbyte.MaxValue };
- sbyte[] newVals = _marsh.Unmarshal<sbyte[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive byte.</summary>
- */
- [Test]
- public void TestWritePrimitiveByte()
- {
- Assert.AreEqual(_marsh.Unmarshal<byte>(_marsh.Marshal((byte)1)), 1);
- Assert.AreEqual(_marsh.Unmarshal<byte>(_marsh.Marshal(byte.MinValue)), byte.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<byte>(_marsh.Marshal(byte.MaxValue)), byte.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<byte?>(_marsh.Marshal((byte?)1)), (byte?)1);
- Assert.AreEqual(_marsh.Unmarshal<byte?>(_marsh.Marshal(null)), null);
- }
-
- /**
- * <summary>Check write of primitive byte array.</summary>
- */
- [Test]
- public void TestWritePrimitiveByteArray()
- {
- byte[] vals = { byte.MinValue, 0, 1, byte.MaxValue };
- byte[] newVals = _marsh.Unmarshal<byte[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive short.</summary>
- */
- [Test]
- public void TestWritePrimitiveShort()
- {
- Assert.AreEqual(_marsh.Unmarshal<short>(_marsh.Marshal((short)1)), 1);
- Assert.AreEqual(_marsh.Unmarshal<short>(_marsh.Marshal(short.MinValue)), short.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<short>(_marsh.Marshal(short.MaxValue)), short.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<short?>(_marsh.Marshal((short?)1)), (short?)1);
- Assert.AreEqual(_marsh.Unmarshal<short?>(_marsh.Marshal(null)), null);
- }
-
- /**
- * <summary>Check write of primitive short array.</summary>
- */
- [Test]
- public void TestWritePrimitiveShortArray()
- {
- short[] vals = { short.MinValue, 0, 1, short.MaxValue };
- short[] newVals = _marsh.Unmarshal<short[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive ushort.</summary>
- */
- [Test]
- public void TestWritePrimitiveUshort()
- {
- Assert.AreEqual(_marsh.Unmarshal<ushort>(_marsh.Marshal((ushort)1)), 1);
- Assert.AreEqual(_marsh.Unmarshal<ushort>(_marsh.Marshal(ushort.MinValue)), ushort.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<ushort>(_marsh.Marshal(ushort.MaxValue)), ushort.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<ushort?>(_marsh.Marshal((ushort?)1)), (ushort?)1);
- Assert.AreEqual(_marsh.Unmarshal<ushort?>(_marsh.Marshal(null)), null);
- }
-
- /**
- * <summary>Check write of primitive short array.</summary>
- */
- [Test]
- public void TestWritePrimitiveUshortArray()
- {
- ushort[] vals = { ushort.MinValue, 0, 1, ushort.MaxValue };
- ushort[] newVals = _marsh.Unmarshal<ushort[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive char.</summary>
- */
- [Test]
- public void TestWritePrimitiveChar()
- {
- Assert.AreEqual(_marsh.Unmarshal<char>(_marsh.Marshal((char)1)), (char)1);
- Assert.AreEqual(_marsh.Unmarshal<char>(_marsh.Marshal(char.MinValue)), char.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<char>(_marsh.Marshal(char.MaxValue)), char.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<char?>(_marsh.Marshal((char?)1)), (char?)1);
- Assert.AreEqual(_marsh.Unmarshal<char?>(_marsh.Marshal(null)), null);
- }
-
- /**
- * <summary>Check write of primitive uint array.</summary>
- */
- [Test]
- public void TestWritePrimitiveCharArray()
- {
- char[] vals = { char.MinValue, (char)0, (char)1, char.MaxValue };
- char[] newVals = _marsh.Unmarshal<char[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive int.</summary>
- */
- [Test]
- public void TestWritePrimitiveInt()
- {
- Assert.AreEqual(_marsh.Unmarshal<int>(_marsh.Marshal(1)), 1);
- Assert.AreEqual(_marsh.Unmarshal<int>(_marsh.Marshal(int.MinValue)), int.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<int>(_marsh.Marshal(int.MaxValue)), int.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<int?>(_marsh.Marshal((int?)1)), (int?)1);
- Assert.AreEqual(_marsh.Unmarshal<int?>(_marsh.Marshal(null)), null);
- }
-
- /**
- * <summary>Check write of primitive uint array.</summary>
- */
- [Test]
- public void TestWritePrimitiveIntArray()
- {
- int[] vals = { int.MinValue, 0, 1, int.MaxValue };
- int[] newVals = _marsh.Unmarshal<int[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive uint.</summary>
- */
- [Test]
- public void TestWritePrimitiveUint()
- {
- Assert.AreEqual(_marsh.Unmarshal<uint>(_marsh.Marshal((uint)1)), 1);
- Assert.AreEqual(_marsh.Unmarshal<uint>(_marsh.Marshal(uint.MinValue)), uint.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<uint>(_marsh.Marshal(uint.MaxValue)), uint.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<uint?>(_marsh.Marshal((uint?)1)), (int?)1);
- Assert.AreEqual(_marsh.Unmarshal<uint?>(_marsh.Marshal(null)), null);
- }
-
- /**
- * <summary>Check write of primitive uint array.</summary>
- */
- [Test]
- public void TestWritePrimitiveUintArray()
- {
- uint[] vals = { uint.MinValue, 0, 1, uint.MaxValue };
- uint[] newVals = _marsh.Unmarshal<uint[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive long.</summary>
- */
- [Test]
- public void TestWritePrimitiveLong()
- {
- Assert.AreEqual(_marsh.Unmarshal<long>(_marsh.Marshal((long)1)), 1);
- Assert.AreEqual(_marsh.Unmarshal<long>(_marsh.Marshal(long.MinValue)), long.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<long>(_marsh.Marshal(long.MaxValue)), long.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<long?>(_marsh.Marshal((long?)1)), (long?)1);
- Assert.AreEqual(_marsh.Unmarshal<long?>(_marsh.Marshal(null)), null);
- }
-
- /**
- * <summary>Check write of primitive long array.</summary>
- */
- [Test]
- public void TestWritePrimitiveLongArray()
- {
- long[] vals = { long.MinValue, 0, 1, long.MaxValue };
- long[] newVals = _marsh.Unmarshal<long[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive ulong.</summary>
- */
- [Test]
- public void TestWritePrimitiveUlong()
- {
- Assert.AreEqual(_marsh.Unmarshal<ulong>(_marsh.Marshal((ulong)1)), 1);
- Assert.AreEqual(_marsh.Unmarshal<ulong>(_marsh.Marshal(ulong.MinValue)), ulong.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<ulong>(_marsh.Marshal(ulong.MaxValue)), ulong.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<ulong?>(_marsh.Marshal((ulong?)1)), (ulong?)1);
- Assert.AreEqual(_marsh.Unmarshal<ulong?>(_marsh.Marshal(null)), null);
- }
-
- /**
- * <summary>Check write of primitive ulong array.</summary>
- */
- [Test]
- public void TestWritePrimitiveUlongArray()
- {
- ulong[] vals = { ulong.MinValue, 0, 1, ulong.MaxValue };
- ulong[] newVals = _marsh.Unmarshal<ulong[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive float.</summary>
- */
- [Test]
- public void TestWritePrimitiveFloat()
- {
- Assert.AreEqual(_marsh.Unmarshal<float>(_marsh.Marshal((float)1)), (float)1);
- Assert.AreEqual(_marsh.Unmarshal<float>(_marsh.Marshal(float.MinValue)), float.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<float>(_marsh.Marshal(float.MaxValue)), float.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<float?>(_marsh.Marshal((float?)1)), (float?)1);
- Assert.AreEqual(_marsh.Unmarshal<float?>(_marsh.Marshal(null)), null);
- }
-
- /**
- * <summary>Check write of primitive float array.</summary>
- */
- [Test]
- public void TestWritePrimitiveFloatArray()
- {
- float[] vals = { float.MinValue, 0, 1, float.MaxValue };
- float[] newVals = _marsh.Unmarshal<float[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive double.</summary>
- */
- [Test]
- public void TestWritePrimitiveDouble()
- {
- Assert.AreEqual(_marsh.Unmarshal<double>(_marsh.Marshal((double)1)), (double)1);
- Assert.AreEqual(_marsh.Unmarshal<double>(_marsh.Marshal(double.MinValue)), double.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<double>(_marsh.Marshal(double.MaxValue)), double.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<double?>(_marsh.Marshal((double?)1)), (double?)1);
- Assert.AreEqual(_marsh.Unmarshal<double?>(_marsh.Marshal(null)), null);
- }
-
- /**
- * <summary>Check write of primitive double array.</summary>
- */
- [Test]
- public void TestWritePrimitiveDoubleArray()
- {
- double[] vals = { double.MinValue, 0, 1, double.MaxValue };
- double[] newVals = _marsh.Unmarshal<double[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of decimal.</summary>
- */
- [Test]
- public void TestWritePrimitiveDecimal()
- {
- decimal val;
-
- // Test positibe and negative.
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Zero)), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(1, 0, 0, false, 0))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(1, 0, 0, true, 0))), val);
-
- // Test 32, 64 and 96 bits + mixed.
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(0, 1, 0, false, 0))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(0, 1, 0, true, 0))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(0, 0, 1, false, 0))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(0, 0, 1, true, 0))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(1, 1, 1, false, 0))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(1, 1, 1, true, 0))), val);
-
- // Test extremes.
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("65536"))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-65536"))), val);
-
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("4294967296"))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-4294967296"))), val);
-
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("281474976710656"))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-281474976710656"))), val);
-
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("18446744073709551616"))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-18446744073709551616"))), val);
-
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("1208925819614629174706176"))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-1208925819614629174706176"))), val);
-
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.MaxValue)), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.MinValue)), val);
-
- // Test scale.
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("11,12"))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-11,12"))), val);
-
- // Test null.
- Assert.AreEqual(_marsh.Unmarshal<decimal?>(_marsh.Marshal(null)), null);
- }
-
- /**
- * <summary>Check write of decimal array.</summary>
- */
- [Test]
- public void TestWritePrimitiveDecimalArray()
- {
- decimal[] vals = { decimal.One, decimal.Parse("11,12") };
- decimal[] newVals = _marsh.Unmarshal<decimal[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of string.</summary>
- */
- [Test]
- public void TestWriteString()
- {
- Assert.AreEqual(_marsh.Unmarshal<string>(_marsh.Marshal("str")), "str");
- Assert.AreEqual(_marsh.Unmarshal<string>(_marsh.Marshal(null)), null);
- }
-
- /**
- * <summary>Check write of string array.</summary>
- */
- [Test]
- public void TestWriteStringArray()
- {
- string[] vals = { "str1", null, "", "str2", null};
- string[] newVals = _marsh.Unmarshal<string[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of Guid.</summary>
- */
- [Test]
- public void TestWriteGuid()
- {
- Guid guid = Guid.NewGuid();
- Guid? nGuid = guid;
-
- Assert.AreEqual(_marsh.Unmarshal<Guid>(_marsh.Marshal(guid)), guid);
- Assert.AreEqual(_marsh.Unmarshal<Guid?>(_marsh.Marshal(nGuid)), nGuid);
-
- nGuid = null;
-
- // ReSharper disable once ExpressionIsAlwaysNull
- Assert.AreEqual(_marsh.Unmarshal<Guid?>(_marsh.Marshal(nGuid)), null);
- }
-
- /**
- * <summary>Check write of string array.</summary>
- */
- [Test]
- public void TestWriteGuidArray()
- {
- Guid?[] vals = { Guid.NewGuid(), null, Guid.Empty, Guid.NewGuid(), null };
- Guid?[] newVals = _marsh.Unmarshal<Guid?[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of enum.</summary>
- */
- [Test]
- public void TestWriteEnum()
- {
- TestEnum val = TestEnum.Val1;
-
- Assert.AreEqual(_marsh.Unmarshal<TestEnum>(_marsh.Marshal(val)), val);
- }
-
- /**
- * <summary>Check write of enum.</summary>
- */
- [Test]
- public void TestWriteEnumArray()
- {
- TestEnum[] vals = { TestEnum.Val2, TestEnum.Val3 };
- TestEnum[] newVals = _marsh.Unmarshal<TestEnum[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of date.</summary>
- */
- [Test]
- public void TestWriteDate() {
- DateTime time = DateTime.Now.ToUniversalTime();
-
- Assert.AreEqual(_marsh.Unmarshal<DateTime>(_marsh.Marshal(time)), time);
- }
-
- /// <summary>
- /// Test object with dates.
- /// </summary>
- [Test]
- public void TestDateObject()
- {
- ICollection<PortableTypeConfiguration> typeCfgs =
- new List<PortableTypeConfiguration>();
-
- typeCfgs.Add(new PortableTypeConfiguration(typeof(DateTimeType)));
-
- PortableConfiguration cfg = new PortableConfiguration {TypeConfigurations = typeCfgs};
-
- PortableMarshaller marsh = new PortableMarshaller(cfg);
-
- DateTime now = DateTime.Now;
-
- DateTimeType obj = new DateTimeType(now);
-
- DateTimeType otherObj = marsh.Unmarshal<DateTimeType>(marsh.Marshal(obj));
-
- Assert.AreEqual(obj.Loc, otherObj.Loc);
- Assert.AreEqual(obj.Utc, otherObj.Utc);
- Assert.AreEqual(obj.LocNull, otherObj.LocNull);
- Assert.AreEqual(obj.UtcNull, otherObj.UtcNull);
- Assert.AreEqual(obj.LocArr, otherObj.LocArr);
- Assert.AreEqual(obj.UtcArr, otherObj.UtcArr);
-
- Assert.AreEqual(obj.LocRaw, otherObj.LocRaw);
- Assert.AreEqual(obj.UtcRaw, otherObj.UtcRaw);
- Assert.AreEqual(obj.LocNullRaw, otherObj.LocNullRaw);
- Assert.AreEqual(obj.UtcNullRaw, otherObj.UtcNullRaw);
- Assert.AreEqual(obj.LocArrRaw, otherObj.LocArrRaw);
- Assert.AreEqual(obj.UtcArrRaw, otherObj.UtcArrRaw);
- }
-
- /**
- * <summary>Check generic collections.</summary>
- */
- [Test]
- public void TestGenericCollections()
- {
- ICollection<string> list = new List<string>();
-
- list.Add("1");
-
- byte[] data = _marsh.Marshal(list);
-
- ICollection<object> newObjList = _marsh.Unmarshal<List<object>>(data);
-
- Assert.NotNull(newObjList);
-
- ICollection<string> newList = new List<string>();
-
- foreach (object obj in newObjList)
- newList.Add((string)obj);
-
- CollectionAssert.AreEquivalent(list, newList);
- }
-
- /**
- * <summary>Check property read.</summary>
- */
- [Test]
- public void TestProperty()
- {
- ICollection<PortableTypeConfiguration> typeCfgs =
- new List<PortableTypeConfiguration>();
-
- typeCfgs.Add(new PortableTypeConfiguration(typeof(PropertyType)));
-
- PortableConfiguration cfg = new PortableConfiguration {TypeConfigurations = typeCfgs};
-
- PortableMarshaller marsh = new PortableMarshaller(cfg);
-
- PropertyType obj = new PropertyType
- {
- Field1 = 1,
- Field2 = 2
- };
-
- byte[] data = marsh.Marshal(obj);
-
- PropertyType newObj = marsh.Unmarshal<PropertyType>(data);
-
- Assert.AreEqual(obj.Field1, newObj.Field1);
- Assert.AreEqual(obj.Field2, newObj.Field2);
-
- IPortableObject portNewObj = marsh.Unmarshal<IPortableObject>(data, PortableMode.ForcePortable);
-
- Assert.AreEqual(obj.Field1, portNewObj.GetField<int>("field1"));
- Assert.AreEqual(obj.Field2, portNewObj.GetField<int>("Field2"));
- }
-
- /**
- * <summary>Check write of primitive fields through reflection.</summary>
- */
- [Test]
- public void TestPrimitiveFieldsReflective()
- {
- ICollection<PortableTypeConfiguration> typeCfgs =
- new List<PortableTypeConfiguration>();
-
- typeCfgs.Add(new PortableTypeConfiguration(typeof(PrimitiveFieldType)));
-
- PortableConfiguration cfg = new PortableConfiguration {TypeConfigurations = typeCfgs};
-
- PortableMarshaller marsh = new PortableMarshaller(cfg);
-
- PrimitiveFieldType obj = new PrimitiveFieldType();
-
- CheckPrimitiveFields(marsh, obj);
- }
-
- /**
- * <summary>Check write of primitive fields through portable interface.</summary>
- */
- [Test]
- public void TestPrimitiveFieldsPortable()
- {
- ICollection<PortableTypeConfiguration> typeCfgs =
- new List<PortableTypeConfiguration>();
-
- typeCfgs.Add(new PortableTypeConfiguration(typeof(PrimitiveFieldPortableType)));
-
- PortableConfiguration cfg = new PortableConfiguration();
-
- cfg.TypeConfigurations = typeCfgs;
-
- PortableMarshaller marsh = new PortableMarshaller(cfg);
-
- PrimitiveFieldPortableType obj = new PrimitiveFieldPortableType();
-
- CheckPrimitiveFields(marsh, obj);
- }
-
- /**
- * <summary>Check write of primitive fields through portable interface.</summary>
- */
- [Test]
- public void TestPrimitiveFieldsRawPortable()
- {
- ICollection<PortableTypeConfiguration> typeCfgs =
- new List<PortableTypeConfiguration>();
-
- typeCfgs.Add(new PortableTypeConfiguration(typeof(PrimitiveFieldRawPortableType)));
-
- PortableConfiguration cfg = new PortableConfiguration();
-
- cfg.TypeConfigurations = typeCfgs;
-
- PortableMarshaller marsh = new PortableMarshaller(cfg);
-
- PrimitiveFieldRawPortableType obj = new PrimitiveFieldRawPortableType();
-
- CheckPrimitiveFields(marsh, obj);
- }
-
- /**
- * <summary>Check write of primitive fields through portable interface.</summary>
- */
- [Test]
- public void TestPrimitiveFieldsSerializer()
- {
- var typeCfgs = new List<PortableTypeConfiguration>
- {
- new PortableTypeConfiguration(typeof (PrimitiveFieldType))
- {
- Serializer = new PrimitiveFieldsSerializer()
- }
- };
-
- PortableConfiguration cfg = new PortableConfiguration {TypeConfigurations = typeCfgs};
-
- PortableMarshaller marsh = new PortableMarshaller(cfg);
-
- PrimitiveFieldType obj = new PrimitiveFieldType();
-
- CheckPrimitiveFields(marsh, obj);
- }
-
- /**
- * <summary>Check decimals.</summary>
- */
- [Test]
- public void TestDecimalFields()
- {
- PortableConfiguration cfg = new PortableConfiguration
- {
- TypeConfigurations = new List<PortableTypeConfiguration>
- {
- new PortableTypeConfiguration(typeof (DecimalReflective)),
- new PortableTypeConfiguration(typeof (DecimalMarshalAware))
- }
- };
-
- PortableMarshaller marsh = new PortableMarshaller(cfg);
-
- // 1. Test reflective stuff.
- DecimalReflective obj1 = new DecimalReflective
- {
- Val = decimal.Zero,
- ValArr = new[] {decimal.One, decimal.MinusOne}
- };
-
- IPortableObject portObj = marsh.Unmarshal<IPortableObject>(marsh.Marshal(obj1), PortableMode.ForcePortable);
-
- Assert.AreEqual(obj1.Val, portObj.GetField<decimal>("val"));
- Assert.AreEqual(obj1.ValArr, portObj.GetField<decimal[]>("valArr"));
-
- Assert.AreEqual(obj1.Val, portObj.Deserialize<DecimalReflective>().Val);
- Assert.AreEqual(obj1.ValArr, portObj.Deserialize<DecimalReflective>().ValArr);
-
- // 2. Test marshal aware stuff.
- DecimalMarshalAware obj2 = new DecimalMarshalAware();
-
- obj2.Val = decimal.Zero;
- obj2.ValArr = new[] { decimal.One, decimal.MinusOne };
- obj2.RawVal = decimal.MaxValue;
- obj2.RawValArr = new[] { decimal.MinusOne, decimal.One} ;
-
- portObj = marsh.Unmarshal<IPortableObject>(marsh.Marshal(obj2), PortableMode.ForcePortable);
-
- Assert.AreEqual(obj2.Val, portObj.GetField<decimal>("val"));
- Assert.AreEqual(obj2.ValArr, portObj.GetField<decimal[]>("valArr"));
-
- Assert.AreEqual(obj2.Val, portObj.Deserialize<DecimalMarshalAware>().Val);
- Assert.AreEqual(obj2.ValArr, portObj.Deserialize<DecimalMarshalAware>().ValArr);
- Assert.AreEqual(obj2.RawVal, portObj.Deserialize<DecimalMarshalAware>().RawVal);
- Assert.AreEqual(obj2.RawValArr, portObj.Deserialize<DecimalMarshalAware>().RawValArr);
- }
-
- /**
- * <summary>Check write of primitive fields through raw serializer.</summary>
- */
- [Test]
- public void TestPrimitiveFieldsRawSerializer()
- {
- ICollection<PortableTypeConfiguration> typeCfgs =
- new List<PortableTypeConfiguration>();
-
- PortableTypeConfiguration typeCfg =
- new PortableTypeConfiguration(typeof(PrimitiveFieldType));
-
- typeCfg.Serializer = new PrimitiveFieldsRawSerializer();
-
- typeCfgs.Add(typeCfg);
-
- PortableConfiguration cfg = new PortableConfiguration();
-
- cfg.TypeConfigurations = typeCfgs;
-
- PortableMarshaller marsh = new PortableMarshaller(cfg);
-
- PrimitiveFieldType obj = new PrimitiveFieldType();
-
- CheckPrimitiveFields(marsh, obj);
- }
-
- private void CheckPrimitiveFields(PortableMarshaller marsh, PrimitiveFieldType obj)
- {
- obj.PBool = true;
- obj.PByte = 2;
- obj.PSbyte = 3;
- obj.PShort = 4;
- obj.PUshort = 5;
- obj.PInt = 6;
- obj.PUint = 7;
- obj.PLong = 8;
- obj.PUlong = 9;
- obj.PChar = 'a';
- obj.PFloat = 10;
- obj.PDouble = 11;
- obj.PString = "abc";
- obj.PGuid = Guid.NewGuid();
- obj.PnGuid = Guid.NewGuid();
-
- //CheckPrimitiveFieldsSerialization(marsh, obj);
-
- //obj.PString = "";
-
- //CheckPrimitiveFieldsSerialization(marsh, obj);
-
- //obj.PString = null;
-
- //CheckPrimitiveFieldsSerialization(marsh, obj);
-
- //obj.PString = null;
- //obj.PNGuid = null;
-
- CheckPrimitiveFieldsSerialization(marsh, obj);
- }
-
- private void CheckPrimitiveFieldsSerialization(PortableMarshaller marsh, PrimitiveFieldType obj)
- {
- byte[] bytes = marsh.Marshal(obj);
-
- IPortableObject portObj = marsh.Unmarshal<IPortableObject>(bytes, PortableMode.ForcePortable);
-
- Assert.AreEqual(obj.GetHashCode(), portObj.GetHashCode());
-
- PrimitiveFieldType newObj = portObj.Deserialize<PrimitiveFieldType>();
-
- Assert.AreEqual(obj, newObj);
- }
-
- /**
- * <summary>Check write of object with enums.</summary>
- */
- [Test]
- public void TestEnumsReflective()
- {
- PortableMarshaller marsh =
- new PortableMarshaller(new PortableConfiguration
- {
- TypeConfigurations =
- new List<PortableTypeConfiguration> {new PortableTypeConfiguration(typeof (EnumType))}
- });
-
- EnumType obj = new EnumType
- {
- PEnum = TestEnum.Val1,
- PEnumArray = new[] {TestEnum.Val2, TestEnum.Val3}
- };
-
- byte[] bytes = marsh.Marshal(obj);
-
- IPortableObject portObj = marsh.Unmarshal<IPortableObject>(bytes, PortableMode.ForcePortable);
-
- Assert.AreEqual(obj.GetHashCode(), portObj.GetHashCode());
-
- EnumType newObj = portObj.Deserialize<EnumType>();
-
- Assert.AreEqual(obj.PEnum, newObj.PEnum);
- Assert.AreEqual(obj.PEnumArray, newObj.PEnumArray);
- }
-
- /**
- * <summary>Check write of object with collections.</summary>
- */
- [Test]
- public void TestCollectionsReflective()
- {
- ICollection<PortableTypeConfiguration> typeCfgs =
- new List<PortableTypeConfiguration>();
-
- typeCfgs.Add(new PortableTypeConfiguration(typeof(CollectionsType)));
- typeCfgs.Add(new PortableTypeConfiguration(typeof(InnerObjectType)));
-
- PortableConfiguration cfg = new PortableConfiguration();
-
- cfg.TypeConfigurations = typeCfgs;
-
- PortableMarshaller marsh = new PortableMarshaller(cfg);
-
- CollectionsType obj = new CollectionsType();
-
- ArrayList list = new ArrayList();
-
- list.Add(true);
- list.Add((byte)1);
- list.Add((short)2);
- list.Add('a');
- list.Add(3);
- list.Add((long)4);
- list.Add((float)5);
- list.Add((double)6);
-
- list.Add("string");
- list.Add(Guid.NewGuid());
-
- InnerObjectType innerObj = new InnerObjectType();
-
- innerObj.PInt1 = 1;
- innerObj.PInt2 = 2;
-
- list.Add(innerObj);
-
- obj.Col1 = list;
-
- byte[] bytes = marsh.Marshal(obj);
-
- IPortableObject portObj = marsh.Unmarshal<IPortableObject>(bytes, PortableMode.ForcePortable);
-
- Assert.AreEqual(obj.GetHashCode(), portObj.GetHashCode());
-
- CollectionsType newObj = portObj.Deserialize<CollectionsType>();
-
- Assert.AreEqual(obj, newObj);
-
- obj.Col1 = null;
-
- Assert.AreEqual(obj, marsh.Unmarshal<CollectionsType>(marsh.Marshal(obj)));
-
- obj.Col1 = list;
- obj.Col2 = list;
-
- Assert.AreEqual(obj, marsh.Unmarshal<CollectionsType>(marsh.Marshal(obj)));
-
- obj.Col2 = new TestList();
-
- Assert.AreEqual(obj, marsh.Unmarshal<CollectionsType>(marsh.Marshal(obj)));
- }
-
- /**
- * <summary>Check write of object fields through reflective serializer.</summary>
- */
- [Test]
- public void TestObjectReflective()
- {
- ICollection<PortableTypeConfiguration> typeCfgs =
- new List<PortableTypeConfiguration>();
-
- typeCfgs.Add(new PortableTypeConfiguration(typeof(OuterObjectType)));
- typeCfgs.Add(new PortableTypeConfiguration(typeof(InnerObjectType)));
-
- PortableConfiguration cfg = new PortableConfiguration();
-
- cfg.TypeConfigurations = typeCfgs;
-
- PortableMarshaller marsh = new PortableMarshaller(cfg);
-
- CheckObject(marsh, new OuterObjectType(), new InnerObjectType());
- }
-
- /**
- * <summary>Test handles.</summary>
- */
- [Test]
- public void TestHandles()
- {
- ICollection<PortableTypeConfiguration> typeCfgs =
- new List<PortableTypeConfiguration>();
-
- typeCfgs.Add(new PortableTypeConfiguration(typeof(HandleInner)));
- typeCfgs.Add(new PortableTypeConfiguration(typeof(HandleOuter)));
-
- PortableConfiguration cfg = new PortableConfiguration();
-
- cfg.TypeConfigurations = typeCfgs;
-
- PortableMarshaller marsh = new PortableMarshaller(cfg);
-
- HandleOuter outer = new HandleOuter();
-
- outer.Before = "outBefore";
- outer.After = "outAfter";
- outer.RawBefore = "outRawBefore";
- outer.RawAfter = "outRawAfter";
-
- HandleInner inner = new HandleInner();
-
- inner.Before = "inBefore";
- inner.After = "inAfter";
- inner.RawBefore = "inRawBefore";
- inner.RawAfter = "inRawAfter";
-
- outer.Inner = inner;
- outer.RawInner = inner;
-
- inner.Outer = outer;
- inner.RawOuter = outer;
-
- byte[] bytes = marsh.Marshal(outer);
-
- IPortableObject outerObj = marsh.Unmarshal<IPortableObject>(bytes, PortableMode.ForcePortable);
-
- HandleOuter newOuter = outerObj.Deserialize<HandleOuter>();
- HandleInner newInner = newOuter.Inner;
-
- CheckHandlesConsistency(outer, inner, newOuter, newInner);
-
- // Get inner object by field.
- IPortableObject innerObj = outerObj.GetField<IPortableObject>("inner");
-
- newInner = innerObj.Deserialize<HandleInner>();
- newOuter = newInner.Outer;
-
- CheckHandlesConsistency(outer, inner, newOuter, newInner);
-
- // Get outer object from inner object by handle.
- outerObj = innerObj.GetField<IPortableObject>("outer");
-
- newOuter = outerObj.Deserialize<HandleOuter>();
- newInner = newOuter.Inner;
-
- CheckHandlesConsistency(outer, inner, newOuter, newInner);
- }
-
- /**
- * <summary>Test handles with exclusive writes.</summary>
- */
- [Test]
- public void TestHandlesExclusive([Values(true, false)] bool detached, [Values(true, false)] bool asPortable)
- {
- var marsh = new PortableMarshaller(new PortableConfiguration
- {
- TypeConfigurations = new List<PortableTypeConfiguration>
- {
- new PortableTypeConfiguration(typeof (HandleInner)),
- new PortableTypeConfiguration(typeof (HandleOuterExclusive))
- }
- });
-
- var inner = new HandleInner
- {
- Before = "inBefore",
- After = "inAfter",
- RawBefore = "inRawBefore",
- RawAfter = "inRawAfter"
- };
-
- var outer = new HandleOuterExclusive
- {
- Before = "outBefore",
- After = "outAfter",
- RawBefore = "outRawBefore",
- RawAfter = "outRawAfter",
- Inner = inner,
- RawInner = inner
- };
-
- inner.Outer = outer;
- inner.RawOuter = outer;
-
- var bytes = asPortable
- ? marsh.Marshal(new PortablesImpl(marsh).ToPortable<IPortableObject>(outer))
- : marsh.Marshal(outer);
-
- IPortableObject outerObj;
-
- if (detached)
- {
- var reader = new PortableReaderImpl(marsh, new Dictionary<long, IPortableTypeDescriptor>(),
- new PortableHeapStream(bytes), PortableMode.ForcePortable, null);
-
- reader.DetachNext();
-
- outerObj = reader.Deserialize<IPortableObject>();
- }
- else
- outerObj = marsh.Unmarshal<IPortableObject>(bytes, PortableMode.ForcePortable);
-
- HandleOuter newOuter = outerObj.Deserialize<HandleOuter>();
-
- Assert.IsFalse(newOuter == newOuter.Inner.Outer);
- Assert.IsFalse(newOuter == newOuter.Inner.RawOuter);
- Assert.IsFalse(newOuter == newOuter.RawInner.RawOuter);
- Assert.IsFalse(newOuter == newOuter.RawInner.RawOuter);
-
- Assert.IsFalse(newOuter.Inner == newOuter.RawInner);
-
- Assert.IsTrue(newOuter.Inner.Outer == newOuter.Inner.RawOuter);
- Assert.IsTrue(newOuter.RawInner.Outer == newOuter.RawInner.RawOuter);
-
- Assert.IsTrue(newOuter.Inner == newOuter.Inner.Outer.Inner);
- Assert.IsTrue(newOuter.Inner == newOuter.Inner.Outer.RawInner);
- Assert.IsTrue(newOuter.RawInner == newOuter.RawInner.Outer.Inner);
- Assert.IsTrue(newOuter.RawInner == newOuter.RawInner.Outer.RawInner);
- }
-
- ///
- /// <summary>Test KeepSerialized property</summary>
- ///
- [Test]
- public void TestKeepSerializedDefault()
- {
- CheckKeepSerialized(new PortableConfiguration(), true);
- }
-
- ///
- /// <summary>Test KeepSerialized property</summary>
- ///
- [Test]
- public void TestKeepSerializedDefaultFalse()
- {
- PortableConfiguration cfg = new PortableConfiguration();
-
- cfg.DefaultKeepDeserialized = false;
-
- CheckKeepSerialized(cfg, false);
- }
-
- ///
- /// <summary>Test KeepSerialized property</summary>
- ///
- [Test]
- public void TestKeepSerializedTypeCfgFalse()
- {
- PortableTypeConfiguration typeCfg = new PortableTypeConfiguration(typeof(PropertyType));
-
- typeCfg.KeepDeserialized = false;
-
- PortableConfiguration cfg = new PortableConfiguration();
-
- cfg.TypeConfigurations = new List<PortableTypeConfiguration> { typeCfg };
-
- CheckKeepSerialized(cfg, false);
- }
-
- ///
- /// <summary>Test KeepSerialized property</summary>
- ///
- [Test]
- public void TestKeepSerializedTypeCfgTrue()
- {
- PortableTypeConfiguration typeCfg = new PortableTypeConfiguration(typeof(PropertyType));
- typeCfg.KeepDeserialized = true;
-
- PortableConfiguration cfg = new PortableConfiguration();
- cfg.DefaultKeepDeserialized = false;
-
- cfg.TypeConfigurations = new List<PortableTypeConfiguration> { typeCfg };
-
- CheckKeepSerialized(cfg, true);
- }
-
- /// <summary>
- /// Test correct serialization/deserialization of arrays of special types.
- /// </summary>
- [Test]
- public void TestSpecialArrays()
- {
- ICollection<PortableTypeConfiguration> typeCfgs =
- new List<PortableTypeConfiguration>();
-
- typeCfgs.Add(new PortableTypeConfiguration(typeof(SpecialArray)));
- typeCfgs.Add(new PortableTypeConfiguration(typeof(SpecialArrayMarshalAware)));
-
- PortableConfiguration cfg = new PortableConfiguration();
-
- cfg.TypeConfigurations = typeCfgs;
-
- PortableMarshaller marsh = new PortableMarshaller(cfg);
-
- Guid[] guidArr = { Guid.NewGuid() };
- Guid?[] nGuidArr = { Guid.NewGuid() };
- DateTime[] dateArr = { DateTime.Now.ToUniversalTime() };
- DateTime?[] nDateArr = { DateTime.Now.ToUniversalTime() };
-
- // Use special object.
- SpecialArray obj1 = new SpecialArray();
-
- obj1.GuidArr = guidArr;
- obj1.NGuidArr = nGuidArr;
- obj1.DateArr = dateArr;
- obj1.NDateArr = nDateArr;
-
- byte[] bytes = marsh.Marshal(obj1);
-
- IPortableObject portObj = marsh.Unmarshal<IPortableObject>(bytes, PortableMode.ForcePortable);
-
- Assert.AreEqual(guidArr, portObj.GetField<Guid[]>("guidArr"));
- Assert.AreEqual(nGuidArr, portObj.GetField<Guid?[]>("nGuidArr"));
- Assert.AreEqual(dateArr, portObj.GetField<DateTime[]>("dateArr"));
- Assert.AreEqual(nDateArr, portObj.GetField<DateTime?[]>("nDateArr"));
-
- obj1 = portObj.Deserialize<SpecialArray>();
-
- Assert.AreEqual(guidArr, obj1.GuidArr);
- Assert.AreEqual(nGuidArr, obj1.NGuidArr);
- Assert.AreEqual(dateArr, obj1.DateArr);
- Assert.AreEqual(nDateArr, obj1.NDateArr);
-
- // Use special with IGridPortableMarshalAware.
- SpecialArrayMarshalAware obj2 = new SpecialArrayMarshalAware();
-
- obj2.GuidArr = guidArr;
- obj2.NGuidArr = nGuidArr;
- obj2.DateArr = dateArr;
- obj2.NDateArr = nDateArr;
-
- bytes = marsh.Marshal(obj2);
-
- portObj = marsh.Unmarshal<IPortableObject>(bytes, PortableMode.ForcePortable);
-
- Assert.AreEqual(guidArr, portObj.GetField<Guid[]>("a"));
- Assert.AreEqual(nGuidArr, portObj.GetField<Guid?[]>("b"));
- Assert.AreEqual(dateArr, portObj.GetField<DateTime[]>("c"));
- Assert.AreEqual(nDateArr, portObj.GetField<DateTime?[]>("d"));
-
- obj2 = portObj.Deserialize<SpecialArrayMarshalAware>();
-
- Assert.AreEqual(guidArr, obj2.GuidArr);
- Assert.AreEqual(nGuidArr, obj2.NGuidArr);
- Assert.AreEqual(dateArr, obj2.DateArr);
- Assert.AreEqual(nDateArr, obj2.NDateArr);
- }
-
- private static void CheckKeepSerialized(PortableConfiguration cfg, bool expKeep)
- {
- if (cfg.TypeConfigurations == null)
- {
- cfg.TypeConfigurations = new List<PortableTypeConfiguration>
- {
- new PortableTypeConfiguration(typeof(PropertyType))
- };
- }
-
- PortableMarshaller marsh = new PortableMarshaller(cfg);
-
- byte[] data = marsh.Marshal(new PropertyType());
-
- IPortableObject portNewObj = marsh.Unmarshal<IPortableObject>(data, PortableMode.ForcePortable);
-
- PropertyType deserialized1 = portNewObj.Deserialize<PropertyType>();
- PropertyType deserialized2 = portNewObj.Deserialize<PropertyType>();
-
- Assert.NotNull(deserialized1);
-
- Assert.AreEqual(expKeep, deserialized1 == deserialized2);
- }
-
- private void CheckHandlesConsistency(HandleOuter outer, HandleInner inner, HandleOuter newOuter,
- HandleInner newInner)
- {
- Assert.True(newOuter != null);
- Assert.AreEqual(outer.Before, newOuter.Before);
- Assert.True(newOuter.Inner == newInner);
- Assert.AreEqual(outer.After, newOuter.After);
- Assert.AreEqual(outer.RawBefore, newOuter.RawBefore);
- Assert.True(newOuter.RawInner == newInner);
- Assert.AreEqual(outer.RawAfter, newOuter.RawAfter);
-
- Assert.True(newInner != null);
- Assert.AreEqual(inner.Before, newInner.Before);
- Assert.True(newInner.Outer == newOuter);
- Assert.AreEqual(inner.After, newInner.After);
- Assert.AreEqual(inner.RawBefore, newInner.RawBefore);
- Assert.True(newInner.RawOuter == newOuter);
- Assert.AreEqual(inner.RawAfter, newInner.RawAfter);
- }
-
- private static void CheckObject(PortableMarshaller marsh, OuterObjectType outObj, InnerObjectType inObj)
- {
- inObj.PInt1 = 1;
- inObj.PInt2 = 2;
-
- outObj.InObj = inObj;
-
- byte[] bytes = marsh.Marshal(outObj);
-
- IPortableObject portOutObj = marsh.Unmarshal<IPortableObject>(bytes, PortableMode.ForcePortable);
-
- Assert.AreEqual(outObj.GetHashCode(), portOutObj.GetHashCode());
-
- OuterObjectType newOutObj = portOutObj.Deserialize<OuterObjectType>();
-
- Assert.AreEqual(outObj, newOutObj);
- }
-
- public class OuterObjectType
- {
- public InnerObjectType InObj { get; set; }
-
- /** <inheritdoc /> */
- public override bool Equals(object obj)
- {
- if (this == obj)
- return true;
-
- var type = obj as OuterObjectType;
-
- return type != null && Equals(InObj, type.InObj);
- }
-
- /** <inheritdoc /> */
- public override int GetHashCode()
- {
- return InObj != null ? InObj.GetHashCode() : 0;
- }
- }
-
- public class InnerObjectType
- {
- public int PInt1 { get; set; }
-
- public int PInt2 { get; set; }
-
- /** <inheritdoc /> */
- public override bool Equals(object obj)
- {
- if (this == obj)
- return true;
-
- var that = obj as InnerObjectType;
-
- return that != null && (PInt1 == that.PInt1 && PInt2 == that.PInt2);
- }
-
- /** <inheritdoc /> */
- public override int GetHashCode()
- {
- return 31 * PInt1 + PInt2;
- }
-
- /** <inheritdoc /> */
- public override string ToString()
- {
- return "InnerObjectType[pInt1=" + PInt1 + ", pInt2=" + PInt2 + ']';
- }
- }
-
- public class CollectionsType
- {
- public ICollection Col1 { get; set; }
-
- public ArrayList Col2 { get; set; }
-
- /** <inheritdoc /> */
- public override bool Equals(object obj)
- {
- if (this == obj)
- return true;
-
- if (obj != null && obj is CollectionsType)
- {
- CollectionsType that = (CollectionsType)obj;
-
- return CompareCollections(Col1, that.Col1) && CompareCollections(Col2, that.Col2);
- }
- return false;
- }
-
- /** <inheritdoc /> */
- public override int GetHashCode()
- {
- int res = Col1 != null ? Col1.GetHashCode() : 0;
-
- res = 31 * res + (Col2 != null ? Col2.GetHashCode() : 0);
-
- return res;
- }
-
- /** <inheritdoc /> */
- public override string ToString()
- {
- return "CollectoinsType[col1=" + CollectionAsString(Col1) +
- ", col2=" + CollectionAsString(Col2) + ']';
- }
- }
-
- private static string CollectionAsString(ICollection col)
- {
- if (col == null)
- return null;
- StringBuilder sb = new StringBuilder("[");
-
- bool first = true;
-
- foreach (object elem in col)
- {
- if (first)
- first = false;
- else
- sb.Append(", ");
-
- sb.Append(elem);
- }
-
- sb.Append("]");
-
- return sb.ToString();
- }
-
- public class TestList : ArrayList
- {
-
- }
-
- private static bool CompareCollections(ICollection col1, ICollection col2)
- {
- if (col1 == null && col2 == null)
- return true;
- if (col1 == null || col2 == null)
- return false;
-
- return col1.OfType<object>().SequenceEqual(col2.OfType<object>());
- }
-
- public class PrimitiveArrayFieldType
- {
- public bool[] PBool { get; set; }
-
- public sbyte[] PSbyte { get; set; }
-
- public byte[] PByte { get; set; }
-
- public short[] PShort { get; set; }
-
- public ushort[] PUshort { get; set; }
-
- public char[] PChar { get; set; }
-
- public int[] PInt { get; set; }
-
- public uint[] PUint { get; set; }
-
- public long[] PLong { get; set; }
-
- public ulong[] PUlong { get; set; }
-
- public float[] PFloat { get; set; }
-
- public double[] PDouble { get; set; }
-
- public string[] PString { get; set; }
-
- public Guid?[] PGuid { get; set; }
-
- /** <inheritdoc /> */
- public override bool Equals(object obj)
- {
- if (this == obj)
- return true;
-
- var other = obj as PrimitiveArrayFieldType;
-
- return other != null && (PBool == other.PBool &&
- PByte == other.PByte &&
- PSbyte == other.PSbyte &&
- PShort == other.PShort &&
- PUshort == other.PUshort &&
- PInt == other.PInt &&
- PUint == other.PUint &&
- PLong == other.PLong &&
- PUlong == other.PUlong &&
- PChar == other.PChar &&
- PFloat == other.PFloat &&
- PDouble == other.PDouble &&
- PString == other.PString &&
- PGuid == other.PGuid);
- }
-
- /** <inheritdoc /> */
- public override int GetHashCode()
- {
- return PInt != null && PInt.Length > 0 ? PInt[0].GetHashCode() : 0;
- }
- }
-
- public class SpecialArray
- {
- public Guid[] GuidArr;
- public Guid?[] NGuidArr;
- public DateTime[] DateArr;
- public DateTime?[] NDateArr;
- }
-
- public class SpecialArrayMarshalAware : SpecialArray, IPortableMarshalAware
- {
- public void WritePortable(IPortableWriter writer)
- {
- writer.WriteObjectArray("a", GuidArr);
- writer.WriteObjectArray("b", NGuidArr);
- writer.WriteObjectArray("c", DateArr);
- writer.WriteObjectArray("d", NDateArr);
- }
-
- public void ReadPortable(IPortableReader reader)
- {
- GuidArr = reader.ReadObjectArray<Guid>("a");
- NGuidArr = reader.ReadObjectArray<Guid?>("b");
- DateArr = reader.ReadObjectArray<DateTime>("c");
- NDateArr = reader.ReadObjectArray<DateTime?>("d");
- }
- }
-
- public class EnumType
- {
- public TestEnum PEnum { get; set; }
-
- public TestEnum[] PEnumArray { get; set; }
- }
-
- public class PrimitiveFieldType
- {
- private Guid _pGuid;
-
- public bool PBool { get; set; }
-
- public sbyte PSbyte { get; set; }
-
- public byte PByte { get; set; }
-
- public short PShort { get; set; }
-
- public ushort PUshort { get; set; }
-
- public char PChar { get; set; }
-
- public int PInt { get; set; }
-
- public uint PUint { get; set; }
-
- public long PLong { get; set; }
-
- public ulong PUlong { get; set; }
-
- public float PFloat { get; set; }
-
- public double PDouble { get; set; }
-
- public string PString { get; set; }
-
- public Guid PGuid
- {
- get { return _pGuid; }
- set { _pGuid = value; }
- }
-
- public Guid? PnGuid { get; set; }
-
- /** <inheritdoc /> */
- public override bool Equals(object obj)
- {
- if (this == obj)
- return true;
-
- if (obj != null && obj is PrimitiveFieldType)
- {
- PrimitiveFieldType that = (PrimitiveFieldType)obj;
-
- return PBool == that.PBool &&
- PByte == that.PByte &&
- PSbyte == that.PSbyte &&
- PShort == that.PShort &&
- PUshort == that.PUshort &&
- PInt == that.PInt &&
- PUint == that.PUint &&
- PLong == that.PLong &&
- PUlong == that.PUlong &&
- PChar == that.PChar &&
- PFloat == that.PFloat &&
- PDouble == that.PDouble &&
- (PString == null && that.PString == null || PString != null && PString.Equals(that.PString)) &&
- _pGuid.Equals(that._pGuid) &&
- (PnGuid == null && that.PnGuid == null || PnGuid != null && PnGuid.Equals(that.PnGuid));
- }
- return false;
- }
-
- /** <inheritdoc /> */
- public override int GetHashCode()
- {
- return PInt;
- }
- }
-
- public class PrimitiveFieldPortableType : PrimitiveFieldType, IPortableMarshalAware
- {
- public unsafe void WritePortable(IPortableWriter writer)
- {
- writer.WriteBoolean("bool", PBool);
- writer.WriteByte("byte", PByte);
- writer.WriteShort("short", PShort);
- writer.WriteInt("int", PInt);
- writer.WriteLong("long", PLong);
- writer.WriteChar("char", PChar);
- writer.WriteFloat("float", PFloat);
- writer.WriteDouble("double", PDouble);
-
- sbyte sByte = PSbyte;
- ushort uShort = PUshort;
- uint uInt = PUint;
- ulong uLong = PUlong;
-
- writer.WriteByte("sbyte", *(byte*)&sByte);
- writer.WriteShort("ushort", *(short*)&uShort);
- writer.WriteInt("uint", *(int*)&uInt);
- writer.WriteLong("ulong", *(long*)&uLong);
-
- writer.WriteString("string", PString);
- writer.WriteGuid("guid", PGuid);
- writer.WriteGuid("nguid", PnGuid);
- }
-
- public unsafe void ReadPortable(IPortableReader reader)
- {
- PBool = reader.ReadBoolean("bool");
- PByte = reader.ReadByte("byte");
- PShort = reader.ReadShort("short");
- PInt = reader.ReadInt("int");
-
- PLong = reader.ReadLong("long");
- PChar = reader.ReadChar("char");
- PFloat = reader.ReadFloat("float");
- PDouble = reader.ReadDouble("double");
-
- byte sByte = reader.ReadByte("sbyte");
- short uShort = reader.ReadShort("ushort");
- int uInt = reader.ReadInt("uint");
- long uLong = reader.ReadLong("ulong");
-
- PSbyte = *(sbyte*)&sByte;
- PUshort = *(ushort*)&uShort;
- PUint = *(uint*)&uInt;
- PUlong = *(ulong*)&uLong;
-
- PString = reader.ReadString("string");
- PGuid = reader.ReadGuid("guid").Value;
- PnGuid = reader.ReadGuid("nguid");
- }
- }
-
- public class PrimitiveFieldRawPortableType : PrimitiveFieldType, IPortableMarshalAware
- {
- public unsafe void WritePortable(IPortableWriter writer)
- {
- IPortableRawWriter rawWriter = writer.RawWriter();
-
- rawWriter.WriteBoolean(PBool);
- rawWriter.WriteByte(PByte);
- rawWriter.WriteShort(PShort);
- rawWriter.WriteInt(PInt);
- rawWriter.WriteLong(PLong);
- rawWriter.WriteChar(PChar);
- rawWriter.WriteFloat(PFloat);
- rawWriter.WriteDouble(PDouble);
-
- sbyte sByte = PSbyte;
- ushort uShort = PUshort;
- uint uInt = PUint;
- ulong uLong = PUlong;
-
- rawWriter.WriteByte(*(byte*)&sByte);
- rawWriter.WriteShort(*(short*)&uShort);
- rawWriter.WriteInt(*(int*)&uInt);
- rawWriter.WriteLong(*(long*)&uLong);
-
- rawWriter.WriteString(PString);
- rawWriter.WriteGuid(PGuid);
- rawWriter.WriteGuid(PnGuid);
- }
-
- public unsafe void ReadPortable(IPortableReader reader)
- {
- IPortableRawReader rawReader = reader.RawReader();
-
- PBool = rawReader.ReadBoolean();
- PByte = rawReader.ReadByte();
- PShort = rawReader.ReadShort();
- PInt = rawReader.ReadInt();
-
- PLong = rawReader.ReadLong();
- PChar = rawReader.ReadChar();
- PFloat = rawReader.ReadFloat();
- PDouble = rawReader.ReadDouble();
-
- byte sByte = rawReader.ReadByte();
- short uShort = rawReader.ReadShort();
- int uInt = rawReader.ReadInt();
- long uLong = rawReader.ReadLong();
-
- PSbyte = *(sbyte*)&sByte;
- PUshort = *(ushort*)&uShort;
- PUint = *(uint*)&uInt;
- PUlong = *(ulong*)&uLong;
-
- PString = rawReader.ReadString();
- PGuid = rawReader.ReadGuid().Value;
- PnGuid = rawReader.ReadGuid();
- }
- }
-
- public class PrimitiveFieldsSerializer : IPortableSerializer
- {
- public unsafe void WritePortable(object obj, IPortableWriter writer)
- {
- PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
-
- writer.WriteBoolean("bool", obj0.PBool);
- writer.WriteByte("byte", obj0.PByte);
- writer.WriteShort("short", obj0.PShort);
- writer.WriteInt("int", obj0.PInt);
- writer.WriteLong("long", obj0.PLong);
- writer.WriteChar("char", obj0.PChar);
- writer.WriteFloat("float", obj0.PFloat);
- writer.WriteDouble("double", obj0.PDouble);
-
- sbyte sByte = obj0.PSbyte;
- ushort uShort = obj0.PUshort;
- uint uInt = obj0.PUint;
- ulong uLong = obj0.PUlong;
-
- writer.WriteByte("sbyte", *(byte*)&sByte);
- writer.WriteShort("ushort", *(short*)&uShort);
- writer.WriteInt("uint", *(int*)&uInt);
- writer.WriteLong("ulong", *(long*)&uLong);
-
- writer.WriteString("string", obj0.PString);
- writer.WriteGuid("guid", obj0.PGuid);
- writer.WriteGuid("nguid", obj0.PnGuid);
- }
-
- public unsafe void ReadPortable(object obj, IPortableReader reader)
- {
- PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
-
- obj0.PBool = reader.ReadBoolean("bool");
- obj0.PByte = reader.ReadByte("byte");
- obj0.PShort = reader.ReadShort("short");
- obj0.PInt = reader.ReadInt("int");
-
- obj0.PLong = reader.ReadLong("long");
- obj0.PChar = reader.ReadChar("char");
- obj0.PFloat = reader.ReadFloat("float");
- obj0.PDouble = reader.ReadDouble("double");
-
- byte sByte = reader.ReadByte("sbyte");
- short uShort = reader.ReadShort("ushort");
- int uInt = reader.ReadInt("uint");
- long uLong = reader.ReadLong("ulong");
-
- obj0.PSbyte = *(sbyte*)&sByte;
- obj0.PUshort = *(ushort*)&uShort;
- obj0.PUint = *(uint*)&uInt;
- obj0.PUlong = *(ulong*)&uLong;
-
- obj0.PString = reader.ReadString("string");
- obj0.PGuid = reader.ReadGuid("guid").Value;
- obj0.PnGuid = reader.ReadGuid("nguid");
- }
- }
-
- public class PrimitiveFieldsRawSerializer : IPortableSerializer
- {
- public unsafe void WritePortable(object obj, IPortableWriter writer)
- {
- PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
-
- IPortableRawWriter rawWriter = writer.RawWriter();
-
- rawWriter.WriteBoolean(obj0.PBool);
- rawWriter.WriteByte(obj0.PByte);
- rawWriter.WriteShort( obj0.PShort);
- rawWriter.WriteInt( obj0.PInt);
- rawWriter.WriteLong( obj0.PLong);
- rawWriter.WriteChar(obj0.PChar);
- rawWriter.WriteFloat(obj0.PFloat);
- rawWriter.WriteDouble( obj0.PDouble);
-
- sbyte sByte = obj0.PSbyte;
- ushort uShort = obj0.PUshort;
- uint uInt = obj0.PUint;
- ulong uLong = obj0.PUlong;
-
- rawWriter.WriteByte(*(byte*)&sByte);
- rawWriter.WriteShort(*(short*)&uShort);
- rawWriter.WriteInt(*(int*)&uInt);
- rawWriter.WriteLong(*(long*)&uLong);
-
- rawWriter.WriteString(obj0.PString);
- rawWriter.WriteGuid(obj0.PGuid);
- rawWriter.WriteGuid(obj0.PnGuid);
- }
-
- public unsafe void ReadPortable(object obj, IPortableReader reader)
- {
- PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
-
- IPortableRawReader rawReader = reader.RawReader();
-
- obj0.PBool = rawReader.ReadBoolean();
- obj0.PByte = rawReader.ReadByte();
- obj0.PShort = rawReader.ReadShort();
- obj0.PInt = rawReader.ReadInt();
- obj0.PLong = rawReader.ReadLong();
- obj0.PChar = rawReader.ReadChar();
- obj0.PFloat = rawReader.ReadFloat();
- obj0.PDouble = rawReader.ReadDouble();
-
- byte sByte = rawReader.ReadByte();
- short uShort = rawReader.ReadShort();
- int uInt = rawReader.ReadInt();
- long uLong = rawReader.ReadLong();
-
- obj0.PSbyte = *(sbyte*)&sByte;
- obj0.PUshort = *(ushort*)&uShort;
- obj0.PUint = *(uint*)&uInt;
- obj0.PUlong = *(ulong*)&uLong;
-
- obj0.PString = rawReader.ReadString();
- obj0.PGuid = rawReader.ReadGuid().Value;
- obj0.PnGuid = rawReader.ReadGuid();
- }
- }
-
- public static string PrintBytes(byte[] bytes)
- {
- StringBuilder sb = new StringBuilder();
-
- foreach (byte b in bytes)
- sb.Append(b + " ");
-
- return sb.ToString();
- }
-
- public class HandleOuter : IPortableMarshalAware
- {
- public string Before;
- public HandleInner Inner;
- public string After;
-
- public string RawBefore;
- public HandleInner RawInner;
- public string RawAfter;
-
- /** <inheritdoc /> */
- virtual public void WritePortable(IPortableWriter writer)
- {
- writer.WriteString("before", Before);
- writer.WriteObject("inner", Inner);
- writer.WriteString("after", After);
-
- IPortableRawWriter rawWriter = writer.RawWriter();
-
- rawWriter.WriteString(RawBefore);
- rawWriter.WriteObject(RawInner);
- rawWriter.WriteString(RawAfter);
- }
-
- /** <inheritdoc /> */
- virtual public void ReadPortable(IPortableReader reader)
- {
- Before = reader.ReadString("before");
- Inner = reader.ReadObject<HandleInner>("inner");
- After = reader.ReadString("after");
-
- IPortableRawReader rawReader = reader.RawReader();
-
- RawBefore = rawReader.ReadString();
- RawInner = rawReader.ReadObject<HandleInner>();
- RawAfter = rawReader.ReadString();
- }
- }
-
- public class HandleInner : IPortableMarshalAware
- {
- public string Before;
- public HandleOuter Outer;
- public string After;
-
- public string RawBefore;
- public HandleOuter RawOuter;
- public string RawAfter;
-
- /** <inheritdoc /> */
- virtual public void WritePortable(IPortableWriter writer)
- {
- writer.WriteString("before", Before);
- writer.WriteObject("outer", Outer);
- writer.WriteString("after", After);
-
- IPortableRawWriter rawWriter = writer.RawWriter();
-
- rawWriter.WriteString(RawBefore);
- rawWriter.WriteObject(RawOuter);
- rawWriter.WriteString(RawAfter);
- }
-
- /** <inheritdoc /> */
- virtual public void ReadPortable(IPortableReader reader)
- {
- Before = reader.ReadString("before");
- Outer = reader.ReadObject<HandleOuter>("outer");
- After = reader.ReadString("after");
-
- IPortableRawReader rawReader = reader.RawReader();
-
- RawBefore = rawReader.ReadString();
- RawOuter = rawReader.ReadObject<HandleOuter>();
- RawAfter = rawReader.ReadString();
- }
- }
-
-
- public class HandleOuterExclusive : HandleOuter
- {
- /** <inheritdoc /> */
- override public void WritePortable(IPortableWriter writer)
- {
- PortableWriterImpl writer0 = (PortableWriterImpl)writer;
-
- writer.WriteString("before", Before);
-
- writer0.DetachNext();
- writer.WriteObject("inner", Inner);
-
- writer.WriteString("after", After);
-
- IPortableRawWriter rawWriter = writer.RawWriter();
-
- rawWriter.WriteString(RawBefore);
-
- writer0.DetachNext();
- rawWriter.WriteObject(RawInner);
-
- rawWriter.WriteString(RawAfter);
- }
-
- /** <inheritdoc /> */
- override public void ReadPortable(IPortableReader reader)
- {
- var reader0 = (PortableReaderImpl) reader;
-
- Before = reader0.ReadString("before");
-
- reader0.DetachNext();
- Inner = reader0.ReadObject<HandleInner>("inner");
-
- After = reader0.ReadString("after");
-
- var rawReader = (PortableReaderImpl) reader.RawReader();
-
- RawBefore = rawReader.ReadString();
-
- reader0.DetachNext();
- RawInner = rawReader.ReadObject<HandleInner>();
-
- RawAfter = rawReader.ReadString();
- }
- }
-
- public class PropertyType
- {
- public int Field1;
-
- public int Field2
- {
- get;
- set;
- }
- }
-
- public enum TestEnum
- {
- Val1, Val2, Val3 = 10
- }
-
- public class DecimalReflective
- {
- /** */
- public decimal Val;
-
- /** */
- public decimal[] ValArr;
- }
-
- public class DecimalMarshalAware : DecimalReflective, IPortableMarshalAware
- {
- /** */
- public decimal RawVal;
-
- /** */
- public decimal[] RawValArr;
-
- /** <inheritDoc /> */
- public void WritePortable(IPortableWriter writer)
- {
- writer.WriteDecimal("val", Val);
- writer.WriteDecimalArray("valArr", ValArr);
-
- IPortableRawWriter rawWriter = writer.RawWriter();
-
- rawWriter.WriteDecimal(RawVal);
- rawWriter.WriteDecimalArray(RawValArr);
- }
-
- /** <inheritDoc /> */
- public void ReadPortable(IPortableReader reader)
- {
- Val = reader.ReadDecimal("val");
- ValArr = reader.ReadDecimalArray("valArr");
-
- IPortableRawReader rawReader = reader.RawReader();
-
- RawVal = rawReader.ReadDecimal();
- RawValArr = rawReader.ReadDecimalArray();
- }
- }
-
- /// <summary>
- /// Date time type.
- /// </summary>
- public class DateTimeType : IPortableMarshalAware
- {
- public DateTime Loc;
- public DateTime Utc;
-
- public DateTime? LocNull;
- public DateTime? UtcNull;
-
- public DateTime?[] LocArr;
- public DateTime?[] UtcArr;
-
- public DateTime LocRaw;
- public DateTime UtcRaw;
-
- public DateTime? LocNullRaw;
- public DateTime? UtcNullRaw;
-
- public DateTime?[] LocArrRaw;
- public DateTime?[] UtcArrRaw;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="now">Current local time.</param>
- public DateTimeType(DateTime now)
- {
- Loc = now;
- Utc = now.ToUniversalTime();
-
- LocNull = Loc;
- UtcNull = Utc;
-
- LocArr = new DateTime?[] { Loc };
- UtcArr = new DateTime?[] { Utc };
-
- LocRaw = Loc;
- UtcRaw = Utc;
-
- LocNullRaw = LocNull;
- UtcNullRaw = UtcNull;
-
- LocArrRaw = new[] { LocArr[0] };
- UtcArrRaw = new[] { UtcArr[0] };
- }
-
- /** <inheritDoc /> */
- public void WritePortable(IPortableWriter writer)
- {
- writer.WriteDate("loc", Loc);
- writer.WriteDate("utc", Utc);
- writer.WriteDate("locNull", LocNull);
- writer.WriteDate("utcNull", UtcNull);
- writer.WriteDateArray("locArr", LocArr);
- writer.WriteDateArray("utcArr", UtcArr);
-
- IPortableRawWriter rawWriter = writer.RawWriter();
-
- rawWriter.WriteDate(LocRaw);
- rawWriter.WriteDate(UtcRaw);
- rawWriter.WriteDate(LocNullRaw);
- rawWriter.WriteDate(UtcNullRaw);
- rawWriter.WriteDateArray(LocArrRaw);
- rawWriter.WriteDateArray(UtcArrRaw);
- }
-
- /** <inheritDoc /> */
- public void ReadPortable(IPortableReader reader)
- {
- Loc = reader.ReadDate("loc", true).Value;
- Utc = reader.ReadDate("utc", false).Value;
- LocNull = reader.ReadDate("loc", true).Value;
- UtcNull = reader.ReadDate("utc", false).Value;
- LocArr = reader.ReadDateArray("locArr", true);
- UtcArr = reader.ReadDateArray("utcArr", false);
-
- IPortableRawReader rawReader = reader.RawReader();
-
- LocRaw = rawReader.ReadDate(true).Value;
- UtcRaw = rawReader.ReadDate(false).Value;
- LocNullRaw = rawReader.ReadDate(true).Value;
- UtcNullRaw = rawReader.ReadDate(false).Value;
- LocArrRaw = rawReader.ReadDateArray(true);
- UtcArrRaw = rawReader.ReadDateArray(false);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/PortableConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/PortableConfigurationTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/PortableConfigurationTest.cs
deleted file mode 100644
index 26c9122..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/PortableConfigurationTest.cs
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Apache.Ignite.Core.Cache;
- using Apache.Ignite.Core.Portable;
- using NUnit.Framework;
-
- /// <summary>
- /// Portable configuration tests.
- /// </summary>
- public class PortableConfigurationTest
- {
- /** Cache. */
- private ICache<int, TestGenericPortableBase> _cache;
-
- /** Random generator. */
- private static readonly Random Rnd = new Random();
-
- /** Test types for code config */
- private static readonly Type[] TestTypes = {
- typeof (TestGenericPortable<int>),
- typeof (TestGenericPortable<string>),
- typeof (TestGenericPortable<TestGenericPortable<int>>),
- typeof (TestGenericPortable<List<Tuple<int, string>>>),
- typeof (TestGenericPortable<int, string>),
- typeof (TestGenericPortable<int, TestGenericPortable<string>>),
- typeof (TestGenericPortable<int, string, Type>),
- typeof (TestGenericPortable<int, string, TestGenericPortable<int, string, Type>>)
- };
-
- /** Test types for xml config */
- private static readonly Type[] TestTypesXml = {
- typeof (TestGenericPortable<long>),
- typeof (TestGenericPortable<Type>),
- typeof (TestGenericPortable<TestGenericPortable<long>>),
- typeof (TestGenericPortable<List<Tuple<long, string>>>),
- typeof (TestGenericPortable<long, string>),
- typeof (TestGenericPortable<long, TestGenericPortable<string>>),
- typeof (TestGenericPortable<long, string, Type>),
- typeof (TestGenericPortable<long, string, TestGenericPortable<long, string, Type>>)
- };
-
- /// <summary>
- /// Starts the grid with provided config.
- /// </summary>
- /// <param name="portableConfiguration">The portable configuration.</param>
- private void StartGrid(PortableConfiguration portableConfiguration)
- {
- Ignition.StopAll(true);
-
- var grid = Ignition.Start(new IgniteConfiguration
- {
- SpringConfigUrl = "config\\cache-portables.xml",
- JvmClasspath = TestUtils.CreateTestClasspath(),
- JvmOptions = TestUtils.TestJavaOptions(),
- PortableConfiguration = portableConfiguration
- });
-
- _cache = grid.GetCache<int, TestGenericPortableBase>(null);
- }
-
- /// <summary>
- /// Test fixture tear-down routine.
- /// </summary>
- [TestFixtureTearDown]
- public void TestFixtureTearDown()
- {
- TestUtils.KillProcesses();
- }
-
- /// <summary>
- /// Tests the configuration set in code.
- /// </summary>
- [Test]
- public void TestCodeConfiguration()
- {
- StartGrid(new PortableConfiguration
- {
- TypeConfigurations = TestTypes.Select(x => new PortableTypeConfiguration(x)).ToList()
- });
-
- CheckPortableTypes(TestTypes);
- }
-
- /// <summary>
- /// Tests the configuration set in xml.
- /// </summary>
- [Test]
- public void TestXmlConfiguration()
- {
- StartGrid(null);
-
- CheckPortableTypes(TestTypesXml);
- }
-
- /// <summary>
- /// Checks that specified types are portable and can be successfully used in cache.
- /// </summary>
- private void CheckPortableTypes(IEnumerable<Type> testTypes)
- {
- int key = 0;
-
- foreach (var typ in testTypes)
- {
- key += 1;
-
- var inst = CreateInstance(typ);
-
- _cache.Put(key, inst);
-
- var result = _cache.Get(key);
-
- Assert.AreEqual(inst.Prop, result.Prop);
-
- Assert.AreEqual(typ, result.GetType());
- }
- }
-
- /// <summary>
- /// Creates the instance of specified test portable type and sets a value on it.
- /// </summary>
- private static TestGenericPortableBase CreateInstance(Type type)
- {
- var inst = (TestGenericPortableBase)Activator.CreateInstance(type);
-
- inst.Prop = Rnd.Next(int.MaxValue);
-
- return inst;
- }
- }
-
- public abstract class TestGenericPortableBase
- {
- public object Prop { get; set; }
- }
-
- public class TestGenericPortable<T> : TestGenericPortableBase
- {
- public T Prop1 { get; set; }
- }
-
- public class TestGenericPortable<T1, T2> : TestGenericPortableBase
- {
- public T1 Prop1 { get; set; }
- public T2 Prop2 { get; set; }
- }
-
- public class TestGenericPortable<T1, T2, T3> : TestGenericPortableBase
- {
- public T1 Prop1 { get; set; }
- public T2 Prop2 { get; set; }
- public T3 Prop3 { get; set; }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Process/IIgniteProcessOutputReader.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Process/IIgniteProcessOutputReader.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Process/IIgniteProcessOutputReader.cs
deleted file mode 100644
index d910c78..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Process/IIgniteProcessOutputReader.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Process
-{
- using System.Diagnostics;
-
- /// <summary>
- /// Process output reader.
- /// </summary>
- public interface IIgniteProcessOutputReader
- {
- /// <summary>
- /// Callback invoked when output data appear.
- /// </summary>
- /// <param name="proc">Process produced data.</param>
- /// <param name="data">Data.</param>
- /// <param name="err">Error flag.</param>
- void OnOutput(Process proc, string data, bool err);
- }
-}
[37/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
IGNITE-1513: WIP on .Net.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/65bb69da
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/65bb69da
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/65bb69da
Branch: refs/heads/ignite-1513-final
Commit: 65bb69da2ba7a2b7961da070ce8726adf23c6b0a
Parents: a958801
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Sep 22 10:19:29 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Sep 22 10:19:30 2015 +0300
----------------------------------------------------------------------
.../Apache.Ignite.Core.Tests.TestDll.csproj | 52 +
.../Properties/AssemblyInfo.cs | 49 +
.../TestClass.cs | 35 +
.../Apache.Ignite.Core.Tests.csproj | 242 ++
.../Cache/CacheAbstractTest.cs | 3252 ++++++++++++++++++
.../Cache/CacheAffinityTest.cs | 139 +
.../Cache/CacheDynamicStartTest.cs | 281 ++
.../Cache/CacheEntryTest.cs | 69 +
.../Cache/CacheForkedTest.cs | 81 +
.../Cache/CacheLocalAtomicTest.cs | 57 +
.../Cache/CacheLocalTest.cs | 56 +
.../CachePartitionedAtomicNearEnabledTest.cs | 50 +
.../Cache/CachePartitionedAtomicTest.cs | 50 +
.../Cache/CachePartitionedNearEnabledTest.cs | 50 +
.../Cache/CachePartitionedTest.cs | 50 +
.../Cache/CacheReplicatedAtomicTest.cs | 60 +
.../Cache/CacheReplicatedTest.cs | 60 +
.../Cache/CacheTestAsyncWrapper.cs | 437 +++
.../Cache/Query/CacheQueriesTest.cs | 928 +++++
.../Continuous/ContinuousQueryAbstractTest.cs | 1181 +++++++
.../ContinuousQueryAtomicBackupTest.cs | 33 +
.../ContinuousQueryAtomicNoBackupTest.cs | 34 +
.../ContinuousQueryNoBackupAbstractTest.cs | 72 +
.../ContinuousQueryTransactionalBackupTest.cs | 34 +
.../ContinuousQueryTransactionalNoBackupTest.cs | 33 +
.../Cache/Store/CacheParallelLoadStoreTest.cs | 110 +
.../Cache/Store/CacheStoreSessionTest.cs | 285 ++
.../Cache/Store/CacheStoreTest.cs | 510 +++
.../Cache/Store/CacheTestParallelLoadStore.cs | 91 +
.../Cache/Store/CacheTestStore.cs | 155 +
.../Compute/AbstractTaskTest.cs | 217 ++
.../Compute/ClosureTaskTest.cs | 390 +++
.../Compute/ComputeApiTest.cs | 1281 +++++++
.../Compute/ComputeMultithreadedTest.cs | 269 ++
.../Compute/FailoverTaskSelfTest.cs | 246 ++
.../Forked/ForkedPortableClosureTaskTest.cs | 30 +
.../Compute/Forked/ForkedResourceTaskTest.cs | 33 +
.../Forked/ForkedSerializableClosureTaskTest.cs | 33 +
.../Compute/Forked/ForkedTaskAdapterTest.cs | 30 +
.../Compute/IgniteExceptionTaskSelfTest.cs | 753 ++++
.../Compute/PortableClosureTaskTest.cs | 217 ++
.../Compute/PortableTaskTest.cs | 253 ++
.../Compute/ResourceTaskTest.cs | 568 +++
.../Compute/SerializableClosureTaskTest.cs | 217 ++
.../Compute/TaskAdapterTest.cs | 274 ++
.../Compute/TaskResultTest.cs | 437 +++
.../Config/Apache.Ignite.exe.config.test | 41 +
.../Config/Cache/Store/cache-store-session.xml | 80 +
.../Config/Compute/compute-grid1.xml | 90 +
.../Config/Compute/compute-grid2.xml | 63 +
.../Config/Compute/compute-grid3.xml | 52 +
.../Config/Compute/compute-standalone.xml | 87 +
.../Config/Dynamic/dynamic-client.xml | 51 +
.../Config/Dynamic/dynamic-data-no-cfg.xml | 47 +
.../Config/Dynamic/dynamic-data.xml | 65 +
.../Config/Lifecycle/lifecycle-beans.xml | 66 +
.../Config/Lifecycle/lifecycle-no-beans.xml | 44 +
.../Config/cache-portables.xml | 78 +
.../Config/cache-query-continuous.xml | 171 +
.../Config/cache-query.xml | 100 +
.../Config/marshaller-default.xml | 43 +
.../Config/marshaller-invalid.xml | 46 +
.../Config/marshaller-portable.xml | 43 +
.../native-client-test-cache-affinity.xml | 70 +
.../native-client-test-cache-parallel-store.xml | 69 +
.../Config/native-client-test-cache-store.xml | 125 +
.../Config/native-client-test-cache.xml | 194 ++
.../Config/portable.xml | 56 +
.../Config/start-test-grid1.xml | 54 +
.../Config/start-test-grid2.xml | 45 +
.../Config/start-test-grid3.xml | 43 +
.../Dataload/DataStreamerTest.cs | 592 ++++
.../Apache.Ignite.Core.Tests/EventsTest.cs | 961 ++++++
.../Examples/Example.cs | 137 +
.../Examples/ExamplesTest.cs | 137 +
.../Examples/PathUtil.cs | 51 +
.../Examples/ProjectFilesTest.cs | 45 +
.../Apache.Ignite.Core.Tests/ExceptionsTest.cs | 352 ++
.../Apache.Ignite.Core.Tests/ExecutableTest.cs | 443 +++
.../Apache.Ignite.Core.Tests/FutureTest.cs | 278 ++
.../IgniteManagerTest.cs | 51 +
.../IgniteStartStopTest.cs | 422 +++
.../Apache.Ignite.Core.Tests/LifecycleTest.cs | 288 ++
.../Apache.Ignite.Core.Tests/LoadDllTest.cs | 243 ++
.../Apache.Ignite.Core.Tests/MarshallerTest.cs | 71 +
.../Memory/InteropMemoryTest.cs | 213 ++
.../Apache.Ignite.Core.Tests/MessagingTest.cs | 646 ++++
.../Portable/PortableApiSelfTest.cs | 1787 ++++++++++
.../Portable/PortableSelfTest.cs | 2078 +++++++++++
.../PortableConfigurationTest.cs | 173 +
.../Process/IIgniteProcessOutputReader.cs | 35 +
.../Process/IgniteProcess.cs | 283 ++
.../Process/IgniteProcessConsoleOutputReader.cs | 40 +
.../Properties/AssemblyInfo.cs | 35 +
.../Query/ImplicitPortablePerson.cs | 46 +
.../Query/NoDefPortablePerson.cs | 35 +
.../Query/PortablePerson.cs | 69 +
.../SerializationTest.cs | 240 ++
.../Services/ServiceProxyTest.cs | 741 ++++
.../Services/ServicesAsyncWrapper.cs | 174 +
.../Services/ServicesTest.cs | 823 +++++
.../Services/ServicesTestAsync.cs | 33 +
.../Apache.Ignite.Core.Tests/TestRunner.cs | 71 +
.../Apache.Ignite.Core.Tests/TestUtils.cs | 292 ++
.../TypeResolverTest.cs | 107 +
modules/platform/dotnet/Apache.Ignite.sln | 4 +-
.../dotnet/Apache.Ignite/Apache.Ignite.csproj | 4 +-
.../Apache.Ignite.Core.Tests.TestDll.csproj | 52 -
.../Properties/AssemblyInfo.cs | 49 -
.../TestClass.cs | 35 -
.../Apache.Ignite.Core.Tests.csproj | 242 --
.../Cache/CacheAbstractTest.cs | 3252 ------------------
.../Cache/CacheAffinityTest.cs | 139 -
.../Cache/CacheDynamicStartTest.cs | 281 --
.../Cache/CacheEntryTest.cs | 69 -
.../Cache/CacheForkedTest.cs | 81 -
.../Cache/CacheLocalAtomicTest.cs | 57 -
.../Cache/CacheLocalTest.cs | 56 -
.../CachePartitionedAtomicNearEnabledTest.cs | 50 -
.../Cache/CachePartitionedAtomicTest.cs | 50 -
.../Cache/CachePartitionedNearEnabledTest.cs | 50 -
.../Cache/CachePartitionedTest.cs | 50 -
.../Cache/CacheReplicatedAtomicTest.cs | 60 -
.../Cache/CacheReplicatedTest.cs | 60 -
.../Cache/CacheTestAsyncWrapper.cs | 437 ---
.../Cache/Query/CacheQueriesTest.cs | 928 -----
.../Continuous/ContinuousQueryAbstractTest.cs | 1181 -------
.../ContinuousQueryAtomicBackupTest.cs | 33 -
.../ContinuousQueryAtomicNoBackupTest.cs | 34 -
.../ContinuousQueryNoBackupAbstractTest.cs | 72 -
.../ContinuousQueryTransactionalBackupTest.cs | 34 -
.../ContinuousQueryTransactionalNoBackupTest.cs | 33 -
.../Cache/Store/CacheParallelLoadStoreTest.cs | 110 -
.../Cache/Store/CacheStoreSessionTest.cs | 285 --
.../Cache/Store/CacheStoreTest.cs | 510 ---
.../Cache/Store/CacheTestParallelLoadStore.cs | 91 -
.../Cache/Store/CacheTestStore.cs | 155 -
.../Compute/AbstractTaskTest.cs | 217 --
.../Compute/ClosureTaskTest.cs | 390 ---
.../Compute/ComputeApiTest.cs | 1281 -------
.../Compute/ComputeMultithreadedTest.cs | 269 --
.../Compute/FailoverTaskSelfTest.cs | 246 --
.../Forked/ForkedPortableClosureTaskTest.cs | 30 -
.../Compute/Forked/ForkedResourceTaskTest.cs | 33 -
.../Forked/ForkedSerializableClosureTaskTest.cs | 33 -
.../Compute/Forked/ForkedTaskAdapterTest.cs | 30 -
.../Compute/IgniteExceptionTaskSelfTest.cs | 753 ----
.../Compute/PortableClosureTaskTest.cs | 217 --
.../Compute/PortableTaskTest.cs | 253 --
.../Compute/ResourceTaskTest.cs | 568 ---
.../Compute/SerializableClosureTaskTest.cs | 217 --
.../Compute/TaskAdapterTest.cs | 274 --
.../Compute/TaskResultTest.cs | 437 ---
.../Config/Apache.Ignite.exe.config.test | 41 -
.../Config/Cache/Store/cache-store-session.xml | 80 -
.../Config/Compute/compute-grid1.xml | 90 -
.../Config/Compute/compute-grid2.xml | 63 -
.../Config/Compute/compute-grid3.xml | 52 -
.../Config/Compute/compute-standalone.xml | 87 -
.../Config/Dynamic/dynamic-client.xml | 51 -
.../Config/Dynamic/dynamic-data-no-cfg.xml | 47 -
.../Config/Dynamic/dynamic-data.xml | 65 -
.../Config/Lifecycle/lifecycle-beans.xml | 66 -
.../Config/Lifecycle/lifecycle-no-beans.xml | 44 -
.../Config/cache-portables.xml | 78 -
.../Config/cache-query-continuous.xml | 171 -
.../Config/cache-query.xml | 100 -
.../Config/marshaller-default.xml | 43 -
.../Config/marshaller-invalid.xml | 46 -
.../Config/marshaller-portable.xml | 43 -
.../native-client-test-cache-affinity.xml | 70 -
.../native-client-test-cache-parallel-store.xml | 69 -
.../Config/native-client-test-cache-store.xml | 125 -
.../Config/native-client-test-cache.xml | 194 --
.../Config/portable.xml | 56 -
.../Config/start-test-grid1.xml | 54 -
.../Config/start-test-grid2.xml | 45 -
.../Config/start-test-grid3.xml | 43 -
.../Dataload/DataStreamerTest.cs | 592 ----
.../Apache.Ignite.Core.Tests/EventsTest.cs | 961 ------
.../Examples/Example.cs | 137 -
.../Examples/ExamplesTest.cs | 137 -
.../Examples/PathUtil.cs | 51 -
.../Examples/ProjectFilesTest.cs | 45 -
.../Apache.Ignite.Core.Tests/ExceptionsTest.cs | 352 --
.../Apache.Ignite.Core.Tests/ExecutableTest.cs | 443 ---
.../Apache.Ignite.Core.Tests/FutureTest.cs | 278 --
.../IgniteManagerTest.cs | 51 -
.../IgniteStartStopTest.cs | 422 ---
.../Apache.Ignite.Core.Tests/LifecycleTest.cs | 288 --
.../Apache.Ignite.Core.Tests/LoadDllTest.cs | 243 --
.../Apache.Ignite.Core.Tests/MarshallerTest.cs | 71 -
.../Memory/InteropMemoryTest.cs | 213 --
.../Apache.Ignite.Core.Tests/MessagingTest.cs | 646 ----
.../Portable/PortableApiSelfTest.cs | 1787 ----------
.../Portable/PortableSelfTest.cs | 2078 -----------
.../PortableConfigurationTest.cs | 173 -
.../Process/IIgniteProcessOutputReader.cs | 35 -
.../Process/IgniteProcess.cs | 283 --
.../Process/IgniteProcessConsoleOutputReader.cs | 40 -
.../Properties/AssemblyInfo.cs | 35 -
.../Query/ImplicitPortablePerson.cs | 46 -
.../Query/NoDefPortablePerson.cs | 35 -
.../Query/PortablePerson.cs | 69 -
.../SerializationTest.cs | 240 --
.../Services/ServiceProxyTest.cs | 741 ----
.../Services/ServicesAsyncWrapper.cs | 174 -
.../Services/ServicesTest.cs | 823 -----
.../Services/ServicesTestAsync.cs | 33 -
.../Apache.Ignite.Core.Tests/TestRunner.cs | 71 -
.../Apache.Ignite.Core.Tests/TestUtils.cs | 292 --
.../TypeResolverTest.cs | 107 -
212 files changed, 27603 insertions(+), 27603 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests.TestDll/Apache.Ignite.Core.Tests.TestDll.csproj
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests.TestDll/Apache.Ignite.Core.Tests.TestDll.csproj b/modules/platform/dotnet/Apache.Ignite.Core.Tests.TestDll/Apache.Ignite.Core.Tests.TestDll.csproj
new file mode 100644
index 0000000..f213b34
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests.TestDll/Apache.Ignite.Core.Tests.TestDll.csproj
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{F4A69E2D-908E-4F0F-A794-84D508D60E5F}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Apache.Ignite.Core.Tests.TestDll</RootNamespace>
+ <AssemblyName>Apache.Ignite.Core.Tests.TestDll</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+ <PlatformTarget>x86</PlatformTarget>
+ <OutputPath>bin\x86\Debug\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+ <PlatformTarget>x86</PlatformTarget>
+ <OutputPath>bin\x86\Release\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Debug\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Release\</OutputPath>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="TestClass.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..22d74c9
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("Apache.Ignite.Core.Tests.TestDll")]
+[assembly: AssemblyDescription("Apache Ignite .NET Core Tests Testing Library")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("Apache.Ignite.Core.Tests.TestDll")]
+[assembly: AssemblyCopyright("Copyright © 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("086e5873-013b-4ffb-93d2-d67881f75bc2")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.5.0")]
+[assembly: AssemblyFileVersion("1.5.0")]
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests.TestDll/TestClass.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests.TestDll/TestClass.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests.TestDll/TestClass.cs
new file mode 100644
index 0000000..1199f2c
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests.TestDll/TestClass.cs
@@ -0,0 +1,35 @@
+/*
+ * 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.TestDll
+{
+ /// <summary>
+ /// Test class.
+ /// </summary>
+ public class TestClass
+ {
+ /// <summary>
+ /// Gets or sets the Id.
+ /// </summary>
+ public int Id { get; set; }
+
+ /// <summary>
+ /// Gets or sets the Name.
+ /// </summary>
+ public string Name { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
new file mode 100644
index 0000000..239898e
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -0,0 +1,242 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{6A62F66C-DA5B-4FBB-8CE7-A95F740FDC7A}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Apache.Ignite.Core.Tests</RootNamespace>
+ <AssemblyName>Apache.Ignite.Core.Tests</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup>
+ <StartupObject />
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Debug\</OutputPath>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <DefineConstants>DEBUG</DefineConstants>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Release\</OutputPath>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+ <PlatformTarget>x86</PlatformTarget>
+ <OutputPath>bin\x86\Debug\</OutputPath>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <DefineConstants>DEBUG</DefineConstants>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+ <PlatformTarget>x86</PlatformTarget>
+ <OutputPath>bin\x86\Release\</OutputPath>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="nunit-console-runner">
+ <HintPath>..\libs\nunit-console-runner.dll</HintPath>
+ </Reference>
+ <Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\libs\nunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Runtime.Serialization" />
+ <Reference Include="System.XML" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Cache\CacheDynamicStartTest.cs" />
+ <Compile Include="Cache\CacheTestAsyncWrapper.cs" />
+ <Compile Include="Cache\CacheAbstractTest.cs" />
+ <Compile Include="Cache\CacheAffinityTest.cs" />
+ <Compile Include="Cache\CacheEntryTest.cs" />
+ <Compile Include="Cache\CacheForkedTest.cs" />
+ <Compile Include="Cache\CacheLocalAtomicTest.cs" />
+ <Compile Include="Cache\CacheLocalTest.cs" />
+ <Compile Include="Cache\CachePartitionedAtomicNearEnabledTest.cs" />
+ <Compile Include="Cache\CachePartitionedAtomicTest.cs" />
+ <Compile Include="Cache\CachePartitionedNearEnabledTest.cs" />
+ <Compile Include="Cache\CachePartitionedTest.cs" />
+ <Compile Include="Cache\CacheReplicatedAtomicTest.cs" />
+ <Compile Include="Cache\CacheReplicatedTest.cs" />
+ <Compile Include="Cache\Query\Continuous\ContinuousQueryAbstractTest.cs" />
+ <Compile Include="Cache\Query\Continuous\ContinuousQueryAtomicBackupTest.cs" />
+ <Compile Include="Cache\Query\Continuous\ContinuousQueryAtomicNoBackupTest.cs" />
+ <Compile Include="Cache\Query\Continuous\ContinuousQueryNoBackupAbstractTest.cs" />
+ <Compile Include="Cache\Query\Continuous\ContinuousQueryTransactionalBackupTest.cs" />
+ <Compile Include="Cache\Query\Continuous\ContinuousQueryTransactionalNoBackupTest.cs" />
+ <Compile Include="Cache\Query\CacheQueriesTest.cs" />
+ <Compile Include="Cache\Store\CacheParallelLoadStoreTest.cs" />
+ <Compile Include="Cache\Store\CacheStoreSessionTest.cs" />
+ <Compile Include="Cache\Store\CacheStoreTest.cs" />
+ <Compile Include="Cache\Store\CacheTestParallelLoadStore.cs" />
+ <Compile Include="Cache\Store\CacheTestStore.cs" />
+ <Compile Include="Compute\Forked\ForkedPortableClosureTaskTest.cs" />
+ <Compile Include="Compute\Forked\ForkedResourceTaskTest.cs" />
+ <Compile Include="Compute\Forked\ForkedSerializableClosureTaskTest.cs" />
+ <Compile Include="Compute\Forked\ForkedTaskAdapterTest.cs" />
+ <Compile Include="Compute\AbstractTaskTest.cs" />
+ <Compile Include="Compute\ClosureTaskTest.cs" />
+ <Compile Include="Compute\ComputeApiTest.cs" />
+ <Compile Include="Compute\ComputeMultithreadedTest.cs" />
+ <Compile Include="Compute\IgniteExceptionTaskSelfTest.cs" />
+ <Compile Include="Compute\FailoverTaskSelfTest.cs" />
+ <Compile Include="Compute\PortableClosureTaskTest.cs" />
+ <Compile Include="Compute\PortableTaskTest.cs" />
+ <Compile Include="Compute\ResourceTaskTest.cs" />
+ <Compile Include="Compute\SerializableClosureTaskTest.cs" />
+ <Compile Include="Compute\TaskAdapterTest.cs" />
+ <Compile Include="Compute\TaskResultTest.cs" />
+ <Compile Include="Dataload\DataStreamerTest.cs" />
+ <Compile Include="EventsTest.cs" />
+ <Compile Include="Examples\Example.cs" />
+ <Compile Include="Examples\ExamplesTest.cs" />
+ <Compile Include="Examples\PathUtil.cs" />
+ <Compile Include="Examples\ProjectFilesTest.cs" />
+ <Compile Include="ExceptionsTest.cs" />
+ <Compile Include="ExecutableTest.cs" />
+ <Compile Include="FutureTest.cs" />
+ <Compile Include="LifecycleTest.cs" />
+ <Compile Include="LoadDllTest.cs" />
+ <Compile Include="IgniteManagerTest.cs" />
+ <Compile Include="MarshallerTest.cs" />
+ <Compile Include="MessagingTest.cs" />
+ <Compile Include="PortableConfigurationTest.cs" />
+ <Compile Include="SerializationTest.cs" />
+ <Compile Include="IgniteStartStopTest.cs" />
+ <Compile Include="TestUtils.cs" />
+ <Compile Include="Memory\InteropMemoryTest.cs" />
+ <Compile Include="Portable\PortableApiSelfTest.cs" />
+ <Compile Include="Portable\PortableSelfTest.cs" />
+ <Compile Include="Process\IgniteProcess.cs" />
+ <Compile Include="Process\IgniteProcessConsoleOutputReader.cs" />
+ <Compile Include="Process\IIgniteProcessOutputReader.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Query\ImplicitPortablePerson.cs" />
+ <Compile Include="Query\NoDefPortablePerson.cs" />
+ <Compile Include="Query\PortablePerson.cs" />
+ <Compile Include="Services\ServicesTest.cs" />
+ <Compile Include="Services\ServicesTestAsync.cs" />
+ <Compile Include="Services\ServiceProxyTest.cs" />
+ <Compile Include="Services\ServicesAsyncWrapper.cs" />
+ <Compile Include="TestRunner.cs" />
+ <Compile Include="TypeResolverTest.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Apache.Ignite.Core\Apache.Ignite.Core.csproj">
+ <Project>{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}</Project>
+ <Name>Apache.Ignite.Core</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Apache.Ignite\Apache.Ignite.csproj">
+ <Project>{27F7F3C6-BDDE-43A9-B565-856F8395A04B}</Project>
+ <Name>Apache.Ignite</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Examples\Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj">
+ <Project>{dfb08363-202e-412d-8812-349ef10a8702}</Project>
+ <Name>Apache.Ignite.ExamplesDll</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Examples\Apache.Ignite.Examples\Apache.Ignite.Examples.csproj">
+ <Project>{069fa680-3c4d-43a9-b84f-e67513b87827}</Project>
+ <Name>Apache.Ignite.Examples</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Apache.Ignite.Core.Tests.TestDll\Apache.Ignite.Core.Tests.TestDll.csproj">
+ <Project>{F4A69E2D-908E-4F0F-A794-84D508D60E5F}</Project>
+ <Name>Apache.Ignite.Core.Tests.TestDll</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="Config\cache-portables.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Config\cache-query-continuous.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Config\cache-query.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ <SubType>Designer</SubType>
+ </Content>
+ <Content Include="Config\Cache\Store\cache-store-session.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Config\Compute\compute-grid1.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Config\Compute\compute-grid2.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Config\Compute\compute-grid3.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Config\Compute\compute-standalone.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Config\Dynamic\dynamic-client.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Config\Dynamic\dynamic-data-no-cfg.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Config\Dynamic\dynamic-data.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Config\Lifecycle\lifecycle-beans.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Config\Lifecycle\lifecycle-no-beans.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Config\marshaller-default.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Config\marshaller-invalid.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Config\marshaller-portable.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Config\native-client-test-cache-affinity.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Config\native-client-test-cache-parallel-store.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Config\native-client-test-cache-store.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Config\native-client-test-cache.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Config\portable.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Config\start-test-grid1.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Config\start-test-grid2.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Config\start-test-grid3.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="Config\Apache.Ignite.exe.config.test">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
[10/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
IGNITE-1513: WIP on .Net.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a958801c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a958801c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a958801c
Branch: refs/heads/ignite-1513-final
Commit: a958801c98b9fd68d70f43d409dfd80fbc96c9c2
Parents: 525d66d
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Sep 22 10:11:52 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Sep 22 10:11:52 2015 +0300
----------------------------------------------------------------------
.../dotnet/Examples2/Apache.Ignite.Examples.sln | 72 ------
.../Examples2/Apache.Ignite.Examples.slnrel | 38 ----
.../Apache.Ignite.Examples.csproj | 80 -------
.../Apache.Ignite.Examples.csprojrel | 79 -------
.../Examples2/Apache.Ignite.Examples/App.config | 24 --
.../Compute/ClosureExample.cs | 84 -------
.../Compute/TaskExample.cs | 140 ------------
.../Datagrid/ContinuousQueryExample.cs | 103 ---------
.../Datagrid/CrossPlatformExample.cs | 208 -----------------
.../Datagrid/DataStreamerExample.cs | 101 ---------
.../Datagrid/PutGetExample.cs | 219 ------------------
.../Datagrid/QueryExample.cs | 226 -------------------
.../Datagrid/StoreExample.cs | 114 ----------
.../Datagrid/TransactionExample.cs | 104 ---------
.../Events/EventsExample.cs | 118 ----------
.../Messaging/MessagingExample.cs | 112 ---------
.../Misc/LifecycleExample.cs | 109 ---------
.../Properties/AssemblyInfo.cs | 35 ---
.../Services/IMapService.cs | 56 -----
.../Services/ServicesExample.cs | 77 -------
.../Apache.Ignite.ExamplesDll.csproj | 75 ------
.../Apache.Ignite.ExamplesDll.csprojrel | 72 ------
.../Compute/AverageSalaryJob.cs | 65 ------
.../Compute/AverageSalaryTask.cs | 84 -------
.../Compute/CharacterCountClosure.cs | 43 ----
.../Compute/CharacterCountReducer.cs | 51 -----
.../Datagrid/ContinuousQueryFilter.cs | 50 ----
.../Datagrid/EmployeeStore.cs | 121 ----------
.../Datagrid/EmployeeStorePredicate.cs | 40 ----
.../Events/LocalListener.cs | 55 -----
.../Events/RemoteFilter.cs | 42 ----
.../Messaging/LocalListener.cs | 59 -----
.../Messaging/RemoteOrderedListener.cs | 54 -----
.../Messaging/RemoteUnorderedListener.cs | 54 -----
.../Messaging/Topic.cs | 28 ---
.../Portable/Account.cs | 60 -----
.../Portable/Address.cs | 81 -------
.../Portable/Employee.cs | 93 --------
.../Portable/EmployeeKey.cs | 86 -------
.../Portable/Organization.cs | 84 -------
.../Portable/OrganizationType.cs | 43 ----
.../Properties/AssemblyInfo.cs | 35 ---
.../Services/MapService.cs | 119 ----------
.../Examples2/Config/example-cache-query.xml | 111 ---------
.../Examples2/Config/example-cache-store.xml | 60 -----
.../dotnet/Examples2/Config/example-cache.xml | 83 -------
.../dotnet/Examples2/Config/example-compute.xml | 70 ------
modules/platform/dotnet/Examples2/README.txt | 14 --
.../dotnet/examples/Apache.Ignite.Examples.sln | 72 ++++++
.../examples/Apache.Ignite.Examples.slnrel | 38 ++++
.../Apache.Ignite.Examples.csproj | 80 +++++++
.../Apache.Ignite.Examples.csprojrel | 79 +++++++
.../examples/Apache.Ignite.Examples/App.config | 24 ++
.../Compute/ClosureExample.cs | 84 +++++++
.../Compute/TaskExample.cs | 140 ++++++++++++
.../Datagrid/ContinuousQueryExample.cs | 103 +++++++++
.../Datagrid/CrossPlatformExample.cs | 208 +++++++++++++++++
.../Datagrid/DataStreamerExample.cs | 101 +++++++++
.../Datagrid/PutGetExample.cs | 219 ++++++++++++++++++
.../Datagrid/QueryExample.cs | 226 +++++++++++++++++++
.../Datagrid/StoreExample.cs | 114 ++++++++++
.../Datagrid/TransactionExample.cs | 104 +++++++++
.../Events/EventsExample.cs | 118 ++++++++++
.../Messaging/MessagingExample.cs | 112 +++++++++
.../Misc/LifecycleExample.cs | 109 +++++++++
.../Properties/AssemblyInfo.cs | 35 +++
.../Services/IMapService.cs | 56 +++++
.../Services/ServicesExample.cs | 77 +++++++
.../Apache.Ignite.ExamplesDll.csproj | 75 ++++++
.../Apache.Ignite.ExamplesDll.csprojrel | 72 ++++++
.../Compute/AverageSalaryJob.cs | 65 ++++++
.../Compute/AverageSalaryTask.cs | 84 +++++++
.../Compute/CharacterCountClosure.cs | 43 ++++
.../Compute/CharacterCountReducer.cs | 51 +++++
.../Datagrid/ContinuousQueryFilter.cs | 50 ++++
.../Datagrid/EmployeeStore.cs | 121 ++++++++++
.../Datagrid/EmployeeStorePredicate.cs | 40 ++++
.../Events/LocalListener.cs | 55 +++++
.../Events/RemoteFilter.cs | 42 ++++
.../Messaging/LocalListener.cs | 59 +++++
.../Messaging/RemoteOrderedListener.cs | 54 +++++
.../Messaging/RemoteUnorderedListener.cs | 54 +++++
.../Messaging/Topic.cs | 28 +++
.../Portable/Account.cs | 60 +++++
.../Portable/Address.cs | 81 +++++++
.../Portable/Employee.cs | 93 ++++++++
.../Portable/EmployeeKey.cs | 86 +++++++
.../Portable/Organization.cs | 84 +++++++
.../Portable/OrganizationType.cs | 43 ++++
.../Properties/AssemblyInfo.cs | 35 +++
.../Services/MapService.cs | 119 ++++++++++
.../examples/Config/example-cache-query.xml | 111 +++++++++
.../examples/Config/example-cache-store.xml | 60 +++++
.../dotnet/examples/Config/example-cache.xml | 83 +++++++
.../dotnet/examples/Config/example-compute.xml | 70 ++++++
modules/platform/dotnet/examples/README.txt | 14 ++
96 files changed, 3931 insertions(+), 3931 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.Examples.sln
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples.sln b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples.sln
deleted file mode 100644
index c1337f3..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples.sln
+++ /dev/null
@@ -1,72 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2013
-VisualStudioVersion = 12.0.31101.0
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Core", "..\Apache.Ignite.Core\Apache.Ignite.Core.csproj", "{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "..\..\cpp\common\project\vs\common.vcxproj", "{4F7E4917-4612-4B96-9838-025711ADE391}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Examples", "Apache.Ignite.Examples\Apache.Ignite.Examples.csproj", "{069FA680-3C4D-43A9-B84F-E67513B87827}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.ExamplesDll", "Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj", "{DFB08363-202E-412D-8812-349EF10A8702}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{F1491682-C798-4C23-8239-16C5BC2C5A02}"
- ProjectSection(SolutionItems) = preProject
- Config\example-cache-query.xml = Config\example-cache-query.xml
- Config\example-cache-store.xml = Config\example-cache-store.xml
- Config\example-cache.xml = Config\example-cache.xml
- Config\example-compute.xml = Config\example-compute.xml
- EndProjectSection
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite", "..\Apache.Ignite\Apache.Ignite.csproj", "{27F7F3C6-BDDE-43A9-B565-856F8395A04B}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x64.ActiveCfg = Debug|x64
- {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x64.Build.0 = Debug|x64
- {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x86.ActiveCfg = Debug|x86
- {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x86.Build.0 = Debug|x86
- {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x64.ActiveCfg = Release|x64
- {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x64.Build.0 = Release|x64
- {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x86.ActiveCfg = Release|x86
- {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x86.Build.0 = Release|x86
- {4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x64.ActiveCfg = Debug|x64
- {4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x64.Build.0 = Debug|x64
- {4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x86.ActiveCfg = Debug|Win32
- {4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x86.Build.0 = Debug|Win32
- {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x64.ActiveCfg = Release|x64
- {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x64.Build.0 = Release|x64
- {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x86.ActiveCfg = Release|Win32
- {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x86.Build.0 = Release|Win32
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.ActiveCfg = Debug|x64
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.Build.0 = Debug|x64
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.ActiveCfg = Debug|x86
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.Build.0 = Debug|x86
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.ActiveCfg = Release|x64
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.Build.0 = Release|x64
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.ActiveCfg = Release|x86
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.Build.0 = Release|x86
- {DFB08363-202E-412D-8812-349EF10A8702}.Debug|x64.ActiveCfg = Debug|x64
- {DFB08363-202E-412D-8812-349EF10A8702}.Debug|x86.ActiveCfg = Debug|x86
- {DFB08363-202E-412D-8812-349EF10A8702}.Release|x64.ActiveCfg = Release|x64
- {DFB08363-202E-412D-8812-349EF10A8702}.Release|x86.ActiveCfg = Release|x86
- {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x64.ActiveCfg = Debug|x64
- {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x64.Build.0 = Debug|x64
- {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x86.ActiveCfg = Debug|x86
- {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x86.Build.0 = Debug|x86
- {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x64.ActiveCfg = Release|x64
- {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x64.Build.0 = Release|x64
- {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x86.ActiveCfg = Release|x86
- {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x86.Build.0 = Release|x86
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.Examples.slnrel
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples.slnrel b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples.slnrel
deleted file mode 100644
index d898abc..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples.slnrel
+++ /dev/null
@@ -1,38 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Examples", "Apache.Ignite.Examples\Apache.Ignite.Examples.csproj", "{069FA680-3C4D-43A9-B84F-E67513B87827}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.ExamplesDll", "Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj", "{DFB08363-202E-412D-8812-349EF10A8702}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{F1491682-C798-4C23-8239-16C5BC2C5A02}"
- ProjectSection(SolutionItems) = preProject
- Config\example-cache-query.xml = Config\example-cache-query.xml
- Config\example-cache-store.xml = Config\example-cache-store.xml
- Config\example-cache.xml = Config\example-cache.xml
- Config\example-compute.xml = Config\example-compute.xml
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.ActiveCfg = Debug|x64
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.Build.0 = Debug|x64
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.ActiveCfg = Debug|x86
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.Build.0 = Debug|x86
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.ActiveCfg = Release|x64
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.Build.0 = Release|x64
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.ActiveCfg = Release|x86
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.Build.0 = Release|x86
- {DFB08363-202E-412D-8812-349EF10A8702}.Debug|x64.ActiveCfg = Debug|x64
- {DFB08363-202E-412D-8812-349EF10A8702}.Debug|x86.ActiveCfg = Debug|x86
- {DFB08363-202E-412D-8812-349EF10A8702}.Release|x64.ActiveCfg = Release|x64
- {DFB08363-202E-412D-8812-349EF10A8702}.Release|x86.ActiveCfg = Release|x86
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
deleted file mode 100644
index 8ee90d9..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
+++ /dev/null
@@ -1,80 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{069FA680-3C4D-43A9-B84F-E67513B87827}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>Apache.Ignite.Examples</RootNamespace>
- <AssemblyName>Apache.Ignite.Examples</AssemblyName>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
- <PlatformTarget>x64</PlatformTarget>
- <OutputPath>bin\x64\Debug\</OutputPath>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
- <PlatformTarget>x64</PlatformTarget>
- <OutputPath>bin\x64\Release\</OutputPath>
- </PropertyGroup>
- <PropertyGroup>
- <StartupObject>Apache.Ignite.Examples.Compute.TaskExample</StartupObject>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
- <DebugSymbols>true</DebugSymbols>
- <OutputPath>bin\x86\Debug\</OutputPath>
- <PlatformTarget>x86</PlatformTarget>
- <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
- <OutputPath>bin\x86\Release\</OutputPath>
- <PlatformTarget>x86</PlatformTarget>
- <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Compute\ClosureExample.cs" />
- <Compile Include="Compute\TaskExample.cs" />
- <Compile Include="Datagrid\ContinuousQueryExample.cs" />
- <Compile Include="Datagrid\CrossPlatformExample.cs" />
- <Compile Include="Datagrid\DataStreamerExample.cs" />
- <Compile Include="Datagrid\PutGetExample.cs" />
- <Compile Include="Datagrid\QueryExample.cs" />
- <Compile Include="Datagrid\StoreExample.cs" />
- <Compile Include="Datagrid\TransactionExample.cs" />
- <Compile Include="Events\EventsExample.cs" />
- <Compile Include="Messaging\MessagingExample.cs" />
- <Compile Include="Misc\LifecycleExample.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Services\IMapService.cs" />
- <Compile Include="Services\ServicesExample.cs" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\Apache.Ignite.Core\Apache.Ignite.Core.csproj">
- <Project>{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}</Project>
- <Name>Apache.Ignite.Core</Name>
- </ProjectReference>
- <ProjectReference Include="..\Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj">
- <Project>{dfb08363-202e-412d-8812-349ef10a8702}</Project>
- <Name>Apache.Ignite.ExamplesDll</Name>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <None Include="App.config" />
- </ItemGroup>
- <ItemGroup />
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Apache.Ignite.Examples.csprojrel
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Apache.Ignite.Examples.csprojrel b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Apache.Ignite.Examples.csprojrel
deleted file mode 100644
index ff13ddc..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Apache.Ignite.Examples.csprojrel
+++ /dev/null
@@ -1,79 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{069FA680-3C4D-43A9-B84F-E67513B87827}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>Apache.Ignite.Examples</RootNamespace>
- <AssemblyName>Apache.Ignite.Examples</AssemblyName>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
- <PlatformTarget>x64</PlatformTarget>
- <OutputPath>bin\x64\Debug\</OutputPath>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
- <PlatformTarget>x64</PlatformTarget>
- <OutputPath>bin\x64\Release\</OutputPath>
- </PropertyGroup>
- <PropertyGroup>
- <StartupObject>Apache.Ignite.Examples.Compute.TaskExample</StartupObject>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
- <DebugSymbols>true</DebugSymbols>
- <OutputPath>bin\x86\Debug\</OutputPath>
- <PlatformTarget>x86</PlatformTarget>
- <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
- <OutputPath>bin\x86\Release\</OutputPath>
- <PlatformTarget>x86</PlatformTarget>
- <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="Apache.Ignite.Core">
- <HintPath>..\..\Apache.Ignite\bin\$(Platform)\$(Configuration)\Apache.Ignite.Core.dll</HintPath>
- </Reference>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Compute\ClosureExample.cs" />
- <Compile Include="Compute\TaskExample.cs" />
- <Compile Include="Datagrid\ContinuousQueryExample.cs" />
- <Compile Include="Datagrid\CrossPlatformExample.cs" />
- <Compile Include="Datagrid\DataStreamerExample.cs" />
- <Compile Include="Datagrid\PutGetExample.cs" />
- <Compile Include="Datagrid\QueryExample.cs" />
- <Compile Include="Datagrid\StoreExample.cs" />
- <Compile Include="Datagrid\TransactionExample.cs" />
- <Compile Include="Events\EventsExample.cs" />
- <Compile Include="Messaging\MessagingExample.cs" />
- <Compile Include="Misc\LifecycleExample.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Services\IMapService.cs" />
- <Compile Include="Services\ServicesExample.cs" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj">
- <Project>{dfb08363-202e-412d-8812-349ef10a8702}</Project>
- <Name>Apache.Ignite.ExamplesDll</Name>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <None Include="App.config" />
- </ItemGroup>
- <ItemGroup />
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/App.config
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/App.config b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/App.config
deleted file mode 100644
index 8e69aeb..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/App.config
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-
-<!--
- 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.
--->
-
-<configuration>
- <runtime>
- <gcServer enabled="true" />
- </runtime>
-</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Compute/ClosureExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Compute/ClosureExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Compute/ClosureExample.cs
deleted file mode 100644
index 7d0128d..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Compute/ClosureExample.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Apache.Ignite.Core;
-using Apache.Ignite.ExamplesDll.Compute;
-
-namespace Apache.Ignite.Examples.Compute
-{
- /// <summary>
- /// Example demonstrating closure execution.
- /// <para />
- /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
- /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
- /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 3) Start example (F5 or Ctrl+F5).
- /// <para />
- /// This example can be run with standalone Apache Ignite .Net node:
- /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
- /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-compute.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
- /// 2) Start example.
- /// </summary>
- public class ClosureExample
- {
- /// <summary>
- /// Runs the example.
- /// </summary>
- [STAThread]
- public static void Main()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
- };
-
- using (var ignite = Ignition.Start(cfg))
- {
- Console.WriteLine();
- Console.WriteLine(">>> Closure execution example started.");
-
- // Split the string by spaces to count letters in each word in parallel.
- ICollection<string> words = "Count characters using closure".Split().ToList();
-
- Console.WriteLine();
- Console.WriteLine(">>> Calculating character count with manual reducing:");
-
- var res = ignite.GetCompute().Apply(new CharacterCountClosure(), words);
-
- int totalLen = res.Sum();
-
- Console.WriteLine(">>> Total character count: " + totalLen);
- Console.WriteLine();
- Console.WriteLine(">>> Calculating character count with reducer:");
-
- totalLen = ignite.GetCompute().Apply(new CharacterCountClosure(), words, new CharacterCountReducer());
-
- Console.WriteLine(">>> Total character count: " + totalLen);
- Console.WriteLine();
- }
-
- Console.WriteLine();
- Console.WriteLine(">>> Example finished, press any key to exit ...");
- Console.ReadKey();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Compute/TaskExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Compute/TaskExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Compute/TaskExample.cs
deleted file mode 100644
index 47fee9e..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Compute/TaskExample.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using Apache.Ignite.Core;
-using Apache.Ignite.ExamplesDll.Compute;
-using Apache.Ignite.ExamplesDll.Portable;
-
-namespace Apache.Ignite.Examples.Compute
-{
- /// <summary>
- /// Example demonstrating task execution.
- /// <para />
- /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
- /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
- /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 3) Start example (F5 or Ctrl+F5).
- /// <para />
- /// This example can be run with standalone Apache Ignite .Net node:
- /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
- /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-compute.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
- /// 2) Start example.
- /// </summary>
- public class TaskExample
- {
- /// <summary>
- /// Runs the example.
- /// </summary>
- [STAThread]
- public static void Main()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
- };
-
- using (var ignite = Ignition.Start(cfg))
- {
- Console.WriteLine();
- Console.WriteLine(">>> Task execution example started.");
-
- // Generate employees to calculate average salary for.
- ICollection<Employee> employees = Employees();
-
- Console.WriteLine();
- Console.WriteLine(">>> Calculating average salary for employees:");
-
- foreach (Employee employee in employees)
- Console.WriteLine(">>> " + employee);
-
- // Execute task and get average salary.
- var avgSalary = ignite.GetCompute().Execute(new AverageSalaryTask(), employees);
-
- Console.WriteLine();
- Console.WriteLine(">>> Average salary for all employees: " + avgSalary);
- Console.WriteLine();
- }
-
- Console.WriteLine();
- Console.WriteLine(">>> Example finished, press any key to exit ...");
- Console.ReadKey();
- }
-
- /// <summary>
- /// Generates collection of employees for example.
- /// </summary>
- /// <returns>Collection of employees.</returns>
- private static ICollection<Employee> Employees()
- {
- return new []
- {
- new Employee(
- "James Wilson",
- 12500,
- new Address("1096 Eddy Street, San Francisco, CA", 94109),
- new List<string> {"Human Resources", "Customer Service"}
- ),
- new Employee(
- "Daniel Adams",
- 11000,
- new Address("184 Fidler Drive, San Antonio, TX", 78205),
- new List<string> {"Development", "QA"}
- ),
- new Employee(
- "Cristian Moss",
- 12500,
- new Address("667 Jerry Dove Drive, Florence, SC", 29501),
- new List<string> {"Logistics"}
- ),
- new Employee(
- "Allison Mathis",
- 25300,
- new Address("2702 Freedom Lane, Hornitos, CA", 95325),
- new List<string> {"Development"}
- ),
- new Employee(
- "Breana Robbin",
- 6500,
- new Address("3960 Sundown Lane, Austin, TX", 78758),
- new List<string> {"Sales"}
- ),
- new Employee(
- "Philip Horsley",
- 19800,
- new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
- new List<string> {"Sales"}
- ),
- new Employee(
- "Brian Peters",
- 10600,
- new Address("1407 Pearlman Avenue, Boston, MA", 02110),
- new List<string> {"Development", "QA"}
- ),
- new Employee(
- "Jack Yang",
- 12900,
- new Address("4425 Parrish Avenue Smithsons Valley, TX", 78130),
- new List<string> {"Sales"}
- )
- };
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
deleted file mode 100644
index c61b45d..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Threading;
-using Apache.Ignite.Core;
-using Apache.Ignite.Core.Cache.Event;
-using Apache.Ignite.Core.Cache.Query.Continuous;
-using Apache.Ignite.ExamplesDll.Datagrid;
-
-namespace Apache.Ignite.Examples.Datagrid
-{
- /// <summary>
- /// This example demonstrates continuous query API.
- /// <para />
- /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
- /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
- /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 3) Start example (F5 or Ctrl+F5).
- /// <para />
- /// This example can be run with standalone Apache Ignite .Net node:
- /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
- /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
- /// 2) Start example.
- /// </summary>
- public class ContinuousQueryExample
- {
- /// <summary>
- /// Runs the example.
- /// </summary>
- [STAThread]
- public static void Main()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
- JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
- };
-
- using (var ignite = Ignition.Start(cfg))
- {
- Console.WriteLine();
- Console.WriteLine(">>> Cache continuous query example started.");
-
- var cache = ignite.GetOrCreateCache<int, string>("cache_continuous_query");
-
- // Clean up caches on all nodes before run.
- cache.Clear();
-
- const int keyCnt = 20;
-
- for (int i = 0; i < keyCnt; i++)
- cache.Put(i, i.ToString());
-
- var qry = new ContinuousQuery<int, string>(new Listener<string>(), new ContinuousQueryFilter(15));
-
-
- // Create new continuous query.
- using (cache.QueryContinuous(qry))
- {
- // Add a few more keys and watch more query notifications.
- for (var i = keyCnt; i < keyCnt + 5; i++)
- cache.Put(i, i.ToString());
-
- // Wait for a while while callback is notified about remaining puts.
- Thread.Sleep(2000);
- }
- }
-
- Console.WriteLine();
- Console.WriteLine(">>> Example finished, press any key to exit ...");
- Console.ReadKey();
- }
-
- /// <summary>
- /// Callback for continuous query example.
- /// </summary>
- private class Listener<T> : ICacheEntryEventListener<int, T>
- {
- public void OnEvent(IEnumerable<ICacheEntryEvent<int, T>> events)
- {
- foreach (var e in events)
- Console.WriteLine("Queried entry [key=" + e.Key + ", val=" + e.Value + ']');
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
deleted file mode 100644
index e23d615..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using Apache.Ignite.Core;
-using Apache.Ignite.Core.Portable;
-using Apache.Ignite.ExamplesDll.Portable;
-
-namespace Apache.Ignite.Examples.Datagrid
-{
- /// <summary>
- /// This example demonstrates use of portable objects between different platforms.
- /// <para/>
- /// This example must be run with standalone Java node. To achieve this start a node from %IGNITE_HOME%
- /// using "ignite.bat" with proper configuration:
- /// <example>'bin\ignite.bat examples\config\example-server.xml'</example>.
- /// <para />
- /// Once remote node is started, launch this example as follows:
- /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build);
- /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 3) Start application (F5 or Ctrl+F5).
- /// <para />
- /// To see how objects can be transferred between platforms, start cross-platform Java example
- /// without restarting remote node.
- /// </summary>
- public class CrossPlatformExample
- {
- /// <summary>Key for Java object.</summary>
- private const int KeyJava = 100;
-
- /// <summary>Key for .Net object.</summary>
- private const int KeyDotnet = 200;
-
- /// <summary>Key for C++ object.</summary>
- private const int KeyCpp = 300;
-
- /// <summary>Cache Name.</summary>
- private const string CacheName = "cacheCrossPlatform";
-
- /// <summary>
- /// Runs the example.
- /// </summary>
- [STAThread]
- public static void Main()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
- };
-
- using (var ignite = Ignition.Start(cfg))
- {
- Console.WriteLine();
- Console.WriteLine(">>> Cross-platform example started.");
-
- if (ignite.GetCluster().ForRemotes().GetNodes().Count == 0)
- {
- Console.WriteLine();
- Console.WriteLine(">>> This example requires remote nodes to be started.");
- Console.WriteLine(">>> Please start at least 1 remote node.");
- Console.WriteLine(">>> Refer to example's documentation for details on configuration.");
- Console.WriteLine();
- }
- else
- {
- var cache = ignite.GetOrCreateCache<int, Organization>(CacheName);
-
- // Create new Organization object to store in cache.
- Organization org = new Organization(
- "Apache",
- new Address("1065 East Hillsdale Blvd, Foster City, CA", 94404),
- OrganizationType.Private,
- DateTime.Now
- );
-
- // Put created data entry to cache.
- cache.Put(KeyDotnet, org);
-
- // Retrieve value stored by Java client.
- GetFromJava(ignite);
-
- // Retrieve value stored by C++ client.
- GetFromCpp(ignite);
-
- // Gets portable value from cache in portable format, without de-serializing it.
- GetDotNetPortableInstance(ignite);
-
- // Gets portable value form cache as a strongly-typed fully de-serialized instance.
- GetDotNetTypedInstance(ignite);
-
- Console.WriteLine();
- }
- }
-
- Console.WriteLine();
- Console.WriteLine(">>> Example finished, press any key to exit ...");
- Console.ReadKey();
- }
-
- /// <summary>
- /// Gets entry put by Java client. In order for entry to be in cache, Java client example
- /// must be run before this example.
- /// </summary>
- /// <param name="Ignite">Ignite instance.</param>
- private static void GetFromJava(IIgnite ignite)
- {
- var cache = ignite.GetOrCreateCache<int, IPortableObject>(CacheName)
- .WithKeepPortable<int, IPortableObject>().WithAsync();
-
- cache.Get(KeyJava);
-
- var orgPortable = cache.GetFuture<IPortableObject>().ToTask().Result;
-
- if (orgPortable == null)
- {
- Console.WriteLine(">>> Java client hasn't put entry to cache. Run Java example before this example " +
- "to see the output.");
- }
- else
- {
- Console.WriteLine(">>> Entry from Java client:");
- Console.WriteLine(">>> Portable: " + orgPortable);
- Console.WriteLine(">>> Deserialized: " + orgPortable.Deserialize<Organization>());
- }
- }
-
- /// <summary>
- /// Gets entry put by C++ client. In order for entry to be in cache, C++ client example
- /// must be run before this example.
- /// </summary>
- /// <param name="ignite">Ignite instance.</param>
- private static void GetFromCpp(IIgnite ignite)
- {
- var cache = ignite.GetOrCreateCache<int, IPortableObject>(CacheName)
- .WithKeepPortable<int, IPortableObject>().WithAsync();
-
- cache.Get(KeyCpp);
-
- var orgPortable = cache.GetFuture<IPortableObject>().Get();
-
- Console.WriteLine();
-
- if (orgPortable == null)
- {
- Console.WriteLine(">>> CPP client hasn't put entry to cache. Run CPP example before this example " +
- "to see the output.");
- }
- else
- {
- Console.WriteLine(">>> Entry from CPP client:");
- Console.WriteLine(">>> Portable: " + orgPortable);
- Console.WriteLine(">>> Deserialized: " + orgPortable.Deserialize<Organization>());
- }
- }
-
- /// <summary>
- /// Gets portable value from cache in portable format, without de-serializing it.
- /// </summary>
- /// <param name="ignite">Ignite instance.</param>
- private static void GetDotNetPortableInstance(IIgnite ignite)
- {
- // Apply "KeepPortable" flag on data projection.
- var cache = ignite.GetOrCreateCache<int, IPortableObject>(CacheName)
- .WithKeepPortable<int, IPortableObject>();
-
- var org = cache.Get(KeyDotnet);
-
- string name = org.GetField<string>("name");
-
- Console.WriteLine();
- Console.WriteLine(">>> Retrieved organization name from portable field: " + name);
- }
-
- /// <summary>
- /// Gets portable value form cache as a strongly-typed fully de-serialized instance.
- /// </summary>
- /// <param name="ignite">Ignite instance.</param>
- private static void GetDotNetTypedInstance(IIgnite ignite)
- {
- var cache = ignite.GetOrCreateCache<int, Organization>(CacheName);
-
- // Get recently created employee as a strongly-typed fully de-serialized instance.
- Organization emp = cache.Get(KeyDotnet);
-
- string name = emp.Name;
-
- Console.WriteLine();
- Console.WriteLine(">>> Retrieved organization name from deserialized Organization instance: " + name);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
deleted file mode 100644
index ee9e200..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using Apache.Ignite.Core;
-using Apache.Ignite.Core.Datastream;
-using Apache.Ignite.ExamplesDll.Portable;
-
-namespace Apache.Ignite.Examples.Datagrid
-{
- /// <summary>
- /// Demonstrates how cache can be populated with data utilizing <see cref="IDataStreamer{TK,TV}"/>.
- /// Data streamer is a lot more efficient to use than standard cache put operation
- /// as it properly buffers cache requests together and properly manages load on remote nodes.
- /// <para />
- /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
- /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
- /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 3) Start example (F5 or Ctrl+F5).
- /// <para />
- /// This example can be run with standalone Apache Ignite .Net node:
- /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
- /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
- /// 2) Start example.
- /// </summary>
- public class DataStreamerExample
- {
- /// <summary>Number of entries to load.</summary>
- private const int EntryCount = 500000;
-
- /// <summary>Cache name.</summary>
- private const string CacheName = "cache_data_streamer";
-
- /// <summary>
- /// Runs the example.
- /// </summary>
- [STAThread]
- public static void Main()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
- JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
- };
-
- using (var ignite = Ignition.Start(cfg))
- {
- Console.WriteLine();
- Console.WriteLine(">>> Cache data streamer example started.");
-
- // Clean up caches on all nodes before run.
- ignite.GetOrCreateCache<int, Account>(CacheName).Clear();
-
- Stopwatch timer = new Stopwatch();
-
- timer.Start();
-
- using (var ldr = ignite.GetDataStreamer<int, Account>(CacheName))
- {
- ldr.PerNodeBufferSize = 1024;
-
- for (int i = 0; i < EntryCount; i++)
- {
- ldr.AddData(i, new Account(i, i));
-
- // Print out progress while loading cache.
- if (i > 0 && i % 10000 == 0)
- Console.WriteLine("Loaded " + i + " accounts.");
- }
- }
-
- timer.Stop();
-
- long dur = timer.ElapsedMilliseconds;
-
- Console.WriteLine(">>> Loaded " + EntryCount + " accounts in " + dur + "ms.");
- }
-
- Console.WriteLine();
- Console.WriteLine(">>> Example finished, press any key to exit ...");
- Console.ReadKey();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/PutGetExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
deleted file mode 100644
index c1146f1..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using Apache.Ignite.Core;
-using Apache.Ignite.Core.Portable;
-using Apache.Ignite.ExamplesDll.Portable;
-
-namespace Apache.Ignite.Examples.Datagrid
-{
- /// <summary>
- /// This example demonstrates several put-get operations on Ignite cache
- /// with portable values. Note that portable object can be retrieved in
- /// fully-deserialized form or in portable object format using special
- /// cache projection.
- /// <para />
- /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
- /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
- /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 3) Start example (F5 or Ctrl+F5).
- /// <para />
- /// This example can be run with standalone Apache Ignite .Net node:
- /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
- /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
- /// 2) Start example.
- /// </summary>
- public class PutGetExample
- {
- /// <summary>Cache name.</summary>
- private const string CacheName = "cache_put_get";
-
- /// <summary>
- /// Runs the example.
- /// </summary>
- [STAThread]
- public static void Main()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
- };
-
- using (var ignite = Ignition.Start(cfg))
- {
- Console.WriteLine();
- Console.WriteLine(">>> Cache put-get example started.");
-
- // Clean up caches on all nodes before run.
- ignite.GetOrCreateCache<object, object>(CacheName).Clear();
-
- PutGet(ignite);
- PutGetPortable(ignite);
- PutAllGetAll(ignite);
- PutAllGetAllPortable(ignite);
-
- Console.WriteLine();
- }
-
- Console.WriteLine();
- Console.WriteLine(">>> Example finished, press any key to exit ...");
- Console.ReadKey();
- }
-
- /// <summary>
- /// Execute individual Put and Get.
- /// </summary>
- /// <param name="ignite">Ignite instance.</param>
- private static void PutGet(IIgnite ignite)
- {
- var cache = ignite.GetCache<int, Organization>(CacheName);
-
- // Create new Organization to store in cache.
- Organization org = new Organization(
- "Microsoft",
- new Address("1096 Eddy Street, San Francisco, CA", 94109),
- OrganizationType.Private,
- DateTime.Now
- );
-
- // Put created data entry to cache.
- cache.Put(1, org);
-
- // Get recently created employee as a strongly-typed fully de-serialized instance.
- Organization orgFromCache = cache.Get(1);
-
- Console.WriteLine();
- Console.WriteLine(">>> Retrieved organization instance from cache: " + orgFromCache);
- }
-
- /// <summary>
- /// Execute individual Put and Get, getting value in portable format, without de-serializing it.
- /// </summary>
- /// <param name="ignite">Ignite instance.</param>
- private static void PutGetPortable(IIgnite ignite)
- {
- var cache = ignite.GetCache<int, Organization>(CacheName);
-
- // Create new Organization to store in cache.
- Organization org = new Organization(
- "Microsoft",
- new Address("1096 Eddy Street, San Francisco, CA", 94109),
- OrganizationType.Private,
- DateTime.Now
- );
-
- // Put created data entry to cache.
- cache.Put(1, org);
-
- // Create projection that will get values as portable objects.
- var portableCache = cache.WithKeepPortable<int, IPortableObject>();
-
- // Get recently created organization as a portable object.
- var portableOrg = portableCache.Get(1);
-
- // Get organization's name from portable object (note that object doesn't need to be fully deserialized).
- string name = portableOrg.GetField<string>("name");
-
- Console.WriteLine();
- Console.WriteLine(">>> Retrieved organization name from portable object: " + name);
- }
-
- /// <summary>
- /// Execute bulk Put and Get operations.
- /// </summary>
- /// <param name="ignite">Ignite instance.</param>
- private static void PutAllGetAll(IIgnite ignite)
- {
- var cache = ignite.GetCache<int, Organization>(CacheName);
-
- // Create new Organizations to store in cache.
- Organization org1 = new Organization(
- "Microsoft",
- new Address("1096 Eddy Street, San Francisco, CA", 94109),
- OrganizationType.Private,
- DateTime.Now
- );
-
- Organization org2 = new Organization(
- "Red Cross",
- new Address("184 Fidler Drive, San Antonio, TX", 78205),
- OrganizationType.NonProfit,
- DateTime.Now
- );
-
- var map = new Dictionary<int, Organization> { { 1, org1 }, { 2, org2 } };
-
- // Put created data entries to cache.
- cache.PutAll(map);
-
- // Get recently created organizations as a strongly-typed fully de-serialized instances.
- IDictionary<int, Organization> mapFromCache = cache.GetAll(new List<int> { 1, 2 });
-
- Console.WriteLine();
- Console.WriteLine(">>> Retrieved organization instances from cache:");
-
- foreach (Organization org in mapFromCache.Values)
- Console.WriteLine(">>> " + org);
- }
-
- /// <summary>
- /// Execute bulk Put and Get operations getting values in portable format, without de-serializing it.
- /// </summary>
- /// <param name="ignite">Ignite instance.</param>
- private static void PutAllGetAllPortable(IIgnite ignite)
- {
- var cache = ignite.GetCache<int, Organization>(CacheName);
-
- // Create new Organizations to store in cache.
- Organization org1 = new Organization(
- "Microsoft",
- new Address("1096 Eddy Street, San Francisco, CA", 94109),
- OrganizationType.Private,
- DateTime.Now
- );
-
- Organization org2 = new Organization(
- "Red Cross",
- new Address("184 Fidler Drive, San Antonio, TX", 78205),
- OrganizationType.NonProfit,
- DateTime.Now
- );
-
- var map = new Dictionary<int, Organization> { { 1, org1 }, { 2, org2 } };
-
- // Put created data entries to cache.
- cache.PutAll(map);
-
- // Create projection that will get values as portable objects.
- var portableCache = cache.WithKeepPortable<int, IPortableObject>();
-
- // Get recently created organizations as portable objects.
- IDictionary<int, IPortableObject> portableMap =
- portableCache.GetAll(new List<int> { 1, 2 });
-
- Console.WriteLine();
- Console.WriteLine(">>> Retrieved organization names from portable objects:");
-
- foreach (IPortableObject poratbleOrg in portableMap.Values)
- Console.WriteLine(">>> " + poratbleOrg.GetField<string>("name"));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/QueryExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/QueryExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/QueryExample.cs
deleted file mode 100644
index 523b83f..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/QueryExample.cs
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using Apache.Ignite.Core;
-using Apache.Ignite.Core.Cache;
-using Apache.Ignite.Core.Cache.Query;
-using Apache.Ignite.ExamplesDll.Portable;
-
-namespace Apache.Ignite.Examples.Datagrid
-{
- /// <summary>
- /// This example populates cache with sample data and runs several SQL and
- /// full text queries over this data.
- /// <para />
- /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
- /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
- /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 3) Start example (F5 or Ctrl+F5).
- /// <para />
- /// This example can be run with standalone Apache Ignite .Net node:
- /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
- /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache-query.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
- /// 2) Start example.
- /// </summary>
- public class QueryExample
- {
- [STAThread]
- public static void Main()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache-query.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
- };
-
- using (var ignite = Ignition.Start(cfg))
- {
- Console.WriteLine();
- Console.WriteLine(">>> Cache query example started.");
-
- var cache = ignite.GetCache<object, object>(null);
-
- // Clean up caches on all nodes before run.
- cache.Clear();
-
- // Populate cache with sample data entries.
- PopulateCache(cache);
-
- // Create cache that will work with specific types.
- var employeeCache = ignite.GetCache<EmployeeKey, Employee>(null);
-
- // Run SQL query example.
- SqlQueryExample(employeeCache);
-
- // Run SQL query with join example.
- SqlJoinQueryExample(employeeCache);
-
- // Run SQL fields query example.
- SqlFieldsQueryExample(employeeCache);
-
- // Run full text query example.
- FullTextQueryExample(employeeCache);
-
- Console.WriteLine();
- }
-
- Console.WriteLine();
- Console.WriteLine(">>> Example finished, press any key to exit ...");
- Console.ReadKey();
- }
-
- /// <summary>
- /// Queries employees that have provided ZIP code in address.
- /// </summary>
- /// <param name="cache">Cache.</param>
- private static void SqlQueryExample(ICache<EmployeeKey, Employee> cache)
- {
- const int zip = 94109;
-
- var qry = cache.Query(new SqlQuery(typeof(Employee), "zip = ?", zip));
-
- Console.WriteLine();
- Console.WriteLine(">>> Employees with zipcode " + zip + ":");
-
- foreach (var entry in qry)
- Console.WriteLine(">>> " + entry.Value);
- }
-
- /// <summary>
- /// Queries employees that work for organization with provided name.
- /// </summary>
- /// <param name="cache">Cache.</param>
- private static void SqlJoinQueryExample(ICache<EmployeeKey, Employee> cache)
- {
- const string orgName = "Apache";
-
- var qry = cache.Query(new SqlQuery("Employee",
- "from Employee, Organization " +
- "where Employee.organizationId = Organization._key and Organization.name = ?", orgName));
-
- Console.WriteLine();
- Console.WriteLine(">>> Employees working for " + orgName + ":");
-
- foreach (var entry in qry)
- Console.WriteLine(">>> " + entry.Value);
- }
-
- /// <summary>
- /// Queries names and salaries for all employees.
- /// </summary>
- /// <param name="cache">Cache.</param>
- private static void SqlFieldsQueryExample(ICache<EmployeeKey, Employee> cache)
- {
- var qry = cache.QueryFields(new SqlFieldsQuery("select name, salary from Employee"));
-
- Console.WriteLine();
- Console.WriteLine(">>> Employee names and their salaries:");
-
- foreach (IList row in qry)
- Console.WriteLine(">>> [Name=" + row[0] + ", salary=" + row[1] + ']');
- }
-
- /// <summary>
- /// Queries employees that live in Texas using full-text query API.
- /// </summary>
- /// <param name="cache">Cache.</param>
- private static void FullTextQueryExample(ICache<EmployeeKey, Employee> cache)
- {
- var qry = cache.Query(new TextQuery("Employee", "TX"));
-
- Console.WriteLine();
- Console.WriteLine(">>> Employees living in Texas:");
-
- foreach (var entry in qry)
- Console.WriteLine(">>> " + entry.Value);
- }
-
- /// <summary>
- /// Populate cache with data for this example.
- /// </summary>
- /// <param name="cache">Cache.</param>
- private static void PopulateCache(ICache<object, object> cache)
- {
- cache.Put(1, new Organization(
- "Apache",
- new Address("1065 East Hillsdale Blvd, Foster City, CA", 94404),
- OrganizationType.Private,
- DateTime.Now
- ));
-
- cache.Put(2, new Organization(
- "Microsoft",
- new Address("1096 Eddy Street, San Francisco, CA", 94109),
- OrganizationType.Private,
- DateTime.Now
- ));
-
- cache.Put(new EmployeeKey(1, 1), new Employee(
- "James Wilson",
- 12500,
- new Address("1096 Eddy Street, San Francisco, CA", 94109),
- new List<string> { "Human Resources", "Customer Service" }
- ));
-
- cache.Put(new EmployeeKey(2, 1), new Employee(
- "Daniel Adams",
- 11000,
- new Address("184 Fidler Drive, San Antonio, TX", 78130),
- new List<string> { "Development", "QA" }
- ));
-
- cache.Put(new EmployeeKey(3, 1), new Employee(
- "Cristian Moss",
- 12500,
- new Address("667 Jerry Dove Drive, Florence, SC", 29501),
- new List<string> { "Logistics" }
- ));
-
- cache.Put(new EmployeeKey(4, 2), new Employee(
- "Allison Mathis",
- 25300,
- new Address("2702 Freedom Lane, San Francisco, CA", 94109),
- new List<string> { "Development" }
- ));
-
- cache.Put(new EmployeeKey(5, 2), new Employee(
- "Breana Robbin",
- 6500,
- new Address("3960 Sundown Lane, Austin, TX", 78130),
- new List<string> { "Sales" }
- ));
-
- cache.Put(new EmployeeKey(6, 2), new Employee(
- "Philip Horsley",
- 19800,
- new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
- new List<string> { "Sales" }
- ));
-
- cache.Put(new EmployeeKey(7, 2), new Employee(
- "Brian Peters",
- 10600,
- new Address("1407 Pearlman Avenue, Boston, MA", 12110),
- new List<string> { "Development", "QA" }
- ));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/StoreExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/StoreExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/StoreExample.cs
deleted file mode 100644
index 6c2b40d..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/StoreExample.cs
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using Apache.Ignite.Core;
-using Apache.Ignite.ExamplesDll.Datagrid;
-using Apache.Ignite.ExamplesDll.Portable;
-
-namespace Apache.Ignite.Examples.Datagrid
-{
- /// <summary>
- /// Example demonstrating cache store.
- /// <para />
- /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
- /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
- /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 3) Start example (F5 or Ctrl+F5).
- /// <para />
- /// This example can be run with standalone Apache Ignite .Net node:
- /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
- /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache-store.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
- /// 2) Start example.
- /// </summary>
- class StoreExample
- {
- /// <summary>
- /// Runs the example.
- /// </summary>
- [STAThread]
- public static void Main()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache-store.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
- };
-
- using (var ignite = Ignition.Start(cfg))
- {
- Console.WriteLine();
- Console.WriteLine(">>> Cache store example started.");
-
- var cache = ignite.GetCache<int, Employee>(null);
-
- // Clean up caches on all nodes before run.
- cache.Clear();
-
- Console.WriteLine();
- Console.WriteLine(">>> Cleared values from cache.");
- Console.WriteLine(">>> Current cache size: " + cache.GetSize());
-
- // Load entries from store which pass provided filter.
- cache.LoadCache(new EmployeeStorePredicate());
-
- Console.WriteLine();
- Console.WriteLine(">>> Loaded entry from store through ICache.LoadCache().");
- Console.WriteLine(">>> Current cache size: " + cache.GetSize());
-
- // Load entry from store calling ICache.Get() method.
- Employee emp = cache.Get(2);
-
- Console.WriteLine();
- Console.WriteLine(">>> Loaded entry from store through ICache.Get(): " + emp);
- Console.WriteLine(">>> Current cache size: " + cache.GetSize());
-
- // Put an entry to the cache
- cache.Put(3, new Employee(
- "James Wilson",
- 12500,
- new Address("1096 Eddy Street, San Francisco, CA", 94109),
- new List<string> { "Human Resources", "Customer Service" }
- ));
-
- Console.WriteLine();
- Console.WriteLine(">>> Put entry to cache. ");
- Console.WriteLine(">>> Current cache size: " + cache.GetSize());
-
- // Clear values again.
- cache.Clear();
-
- Console.WriteLine();
- Console.WriteLine(">>> Cleared values from cache again.");
- Console.WriteLine(">>> Current cache size: " + cache.GetSize());
-
- // Read values from cache after clear.
- Console.WriteLine();
- Console.WriteLine(">>> Read values after clear:");
-
- for (int i = 1; i <= 3; i++)
- Console.WriteLine(">>> Key=" + i + ", value=" + cache.Get(i));
- }
-
- Console.WriteLine();
- Console.WriteLine(">>> Example finished, press any key to exit ...");
- Console.ReadKey();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/TransactionExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
deleted file mode 100644
index 6be3523..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using Apache.Ignite.Core;
-using Apache.Ignite.Core.Transactions;
-using Apache.Ignite.ExamplesDll.Portable;
-
-namespace Apache.Ignite.Examples.Datagrid
-{
- /// <summary>
- /// This example demonstrates how to use transactions on Apache cache.
- /// <para />
- /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
- /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
- /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 3) Start example (F5 or Ctrl+F5).
- /// <para />
- /// This example can be run with standalone Apache Ignite .Net node:
- /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
- /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
- /// 2) Start example.
- /// </summary>
- class TransactionExample
- {
- /// <summary>
- /// Runs the example.
- /// </summary>
- [STAThread]
- public static void Main()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
- };
-
- using (var ignite = Ignition.Start(cfg))
- {
- Console.WriteLine();
- Console.WriteLine(">>> Transaction example started.");
-
- var cache = ignite.GetCache<int, Account>("tx");
-
- // Clean up caches on all nodes before run.
- cache.Clear();
-
- // Initialize.
- cache.Put(1, new Account(1, 100));
- cache.Put(2, new Account(2, 200));
-
- Console.WriteLine();
- Console.WriteLine(">>> Accounts before transfer: ");
- Console.WriteLine(">>> " + cache.Get(1));
- Console.WriteLine(">>> " + cache.Get(2));
- Console.WriteLine();
-
- // Transfer money between accounts in a single transaction.
- using (var tx = cache.Ignite.GetTransactions().TxStart(TransactionConcurrency.Pessimistic,
- TransactionIsolation.RepeatableRead))
- {
- Account acc1 = cache.Get(1);
- Account acc2 = cache.Get(2);
-
- acc1.Balance += 100;
- acc2.Balance -= 100;
-
- cache.Put(1, acc1);
- cache.Put(2, acc2);
-
- tx.Commit();
- }
-
- Console.WriteLine(">>> Transfer finished.");
-
- Console.WriteLine();
- Console.WriteLine(">>> Accounts after transfer: ");
- Console.WriteLine(">>> " + cache.Get(1));
- Console.WriteLine(">>> " + cache.Get(2));
- Console.WriteLine();
- }
-
- Console.WriteLine();
- Console.WriteLine(">>> Example finished, press any key to exit ...");
- Console.ReadKey();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Events/EventsExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Events/EventsExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Events/EventsExample.cs
deleted file mode 100644
index 83802cc..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Events/EventsExample.cs
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Apache.Ignite.Core;
-using Apache.Ignite.Core.Events;
-using Apache.Ignite.ExamplesDll.Compute;
-using Apache.Ignite.ExamplesDll.Events;
-using Apache.Ignite.ExamplesDll.Portable;
-
-namespace Apache.Ignite.Examples.Events
-{
- /// <summary>
- /// Example demonstrating Ignite events.
- /// <para />
- /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
- /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
- /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 3) Start example (F5 or Ctrl+F5).
- /// <para />
- /// This example can be run with standalone Apache Ignite .Net node:
- /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
- /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-compute.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
- /// 2) Start example.
- /// </summary>
- public class EventsExample
- {
- /// <summary>
- /// Runs the example.
- /// </summary>
- [STAThread]
- public static void Main()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
- JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
- };
-
- using (var ignite = Ignition.Start(cfg))
- {
- Console.WriteLine(">>> Events example started.");
- Console.WriteLine();
-
- // Local listen example
- Console.WriteLine(">>> Listening for a local event...");
-
- var listener = new LocalListener();
- ignite.GetEvents().LocalListen(listener, EventType.EvtsTaskExecution);
-
- ExecuteTask(ignite);
-
- ignite.GetEvents().StopLocalListen(listener);
-
- Console.WriteLine(">>> Received events count: " + listener.EventsReceived);
- Console.WriteLine();
-
- // Remote listen example (start standalone nodes for better demonstration)
- Console.WriteLine(">>> Listening for remote events...");
-
- var localListener = new LocalListener();
- var remoteFilter = new RemoteFilter();
-
- var listenId = ignite.GetEvents().RemoteListen(localListener: localListener,
- remoteFilter: remoteFilter, types: EventType.EvtsJobExecution);
-
- ExecuteTask(ignite);
-
- ignite.GetEvents().StopRemoteListen(listenId);
-
- Console.WriteLine(">>> Received events count: " + localListener.EventsReceived);
- }
-
- Console.WriteLine();
- Console.WriteLine(">>> Example finished, press any key to exit ...");
- Console.ReadKey();
- }
-
- /// <summary>
- /// Executes a task to generate events.
- /// </summary>
- /// <param name="ignite">Ignite instance.</param>
- private static void ExecuteTask(IIgnite ignite)
- {
- var employees = Enumerable.Range(1, 10).SelectMany(x => new[]
- {
- new Employee("Allison Mathis",
- 25300,
- new Address("2702 Freedom Lane, San Francisco, CA", 94109),
- new[] {"Development"}),
-
- new Employee("Breana Robbin",
- 6500,
- new Address("3960 Sundown Lane, Austin, TX", 78130),
- new[] {"Sales"})
- }).ToArray();
-
- ignite.GetCompute().Execute(new AverageSalaryTask(), employees);
- }
- }
-}
[05/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
IGNITE-1513: WIP on .Net.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/525d66df
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/525d66df
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/525d66df
Branch: refs/heads/ignite-1513-final
Commit: 525d66df2b2a342332d2cc056cf3a7fab6a24384
Parents: 524f565
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Sep 22 10:11:43 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Sep 22 10:11:43 2015 +0300
----------------------------------------------------------------------
.../dotnet/Examples/Apache.Ignite.Examples.sln | 72 ------
.../Examples/Apache.Ignite.Examples.slnrel | 38 ----
.../Apache.Ignite.Examples.csproj | 80 -------
.../Apache.Ignite.Examples.csprojrel | 79 -------
.../Examples/Apache.Ignite.Examples/App.config | 24 --
.../Compute/ClosureExample.cs | 84 -------
.../Compute/TaskExample.cs | 140 ------------
.../Datagrid/ContinuousQueryExample.cs | 103 ---------
.../Datagrid/CrossPlatformExample.cs | 208 -----------------
.../Datagrid/DataStreamerExample.cs | 101 ---------
.../Datagrid/PutGetExample.cs | 219 ------------------
.../Datagrid/QueryExample.cs | 226 -------------------
.../Datagrid/StoreExample.cs | 114 ----------
.../Datagrid/TransactionExample.cs | 104 ---------
.../Events/EventsExample.cs | 118 ----------
.../Messaging/MessagingExample.cs | 112 ---------
.../Misc/LifecycleExample.cs | 109 ---------
.../Properties/AssemblyInfo.cs | 35 ---
.../Services/IMapService.cs | 56 -----
.../Services/ServicesExample.cs | 77 -------
.../Apache.Ignite.ExamplesDll.csproj | 75 ------
.../Apache.Ignite.ExamplesDll.csprojrel | 72 ------
.../Compute/AverageSalaryJob.cs | 65 ------
.../Compute/AverageSalaryTask.cs | 84 -------
.../Compute/CharacterCountClosure.cs | 43 ----
.../Compute/CharacterCountReducer.cs | 51 -----
.../Datagrid/ContinuousQueryFilter.cs | 50 ----
.../Datagrid/EmployeeStore.cs | 121 ----------
.../Datagrid/EmployeeStorePredicate.cs | 40 ----
.../Events/LocalListener.cs | 55 -----
.../Events/RemoteFilter.cs | 42 ----
.../Messaging/LocalListener.cs | 59 -----
.../Messaging/RemoteOrderedListener.cs | 54 -----
.../Messaging/RemoteUnorderedListener.cs | 54 -----
.../Messaging/Topic.cs | 28 ---
.../Portable/Account.cs | 60 -----
.../Portable/Address.cs | 81 -------
.../Portable/Employee.cs | 93 --------
.../Portable/EmployeeKey.cs | 86 -------
.../Portable/Organization.cs | 84 -------
.../Portable/OrganizationType.cs | 43 ----
.../Properties/AssemblyInfo.cs | 35 ---
.../Services/MapService.cs | 119 ----------
.../Examples/Config/example-cache-query.xml | 111 ---------
.../Examples/Config/example-cache-store.xml | 60 -----
.../dotnet/Examples/Config/example-cache.xml | 83 -------
.../dotnet/Examples/Config/example-compute.xml | 70 ------
modules/platform/dotnet/Examples/README.txt | 14 --
.../dotnet/Examples2/Apache.Ignite.Examples.sln | 72 ++++++
.../Examples2/Apache.Ignite.Examples.slnrel | 38 ++++
.../Apache.Ignite.Examples.csproj | 80 +++++++
.../Apache.Ignite.Examples.csprojrel | 79 +++++++
.../Examples2/Apache.Ignite.Examples/App.config | 24 ++
.../Compute/ClosureExample.cs | 84 +++++++
.../Compute/TaskExample.cs | 140 ++++++++++++
.../Datagrid/ContinuousQueryExample.cs | 103 +++++++++
.../Datagrid/CrossPlatformExample.cs | 208 +++++++++++++++++
.../Datagrid/DataStreamerExample.cs | 101 +++++++++
.../Datagrid/PutGetExample.cs | 219 ++++++++++++++++++
.../Datagrid/QueryExample.cs | 226 +++++++++++++++++++
.../Datagrid/StoreExample.cs | 114 ++++++++++
.../Datagrid/TransactionExample.cs | 104 +++++++++
.../Events/EventsExample.cs | 118 ++++++++++
.../Messaging/MessagingExample.cs | 112 +++++++++
.../Misc/LifecycleExample.cs | 109 +++++++++
.../Properties/AssemblyInfo.cs | 35 +++
.../Services/IMapService.cs | 56 +++++
.../Services/ServicesExample.cs | 77 +++++++
.../Apache.Ignite.ExamplesDll.csproj | 75 ++++++
.../Apache.Ignite.ExamplesDll.csprojrel | 72 ++++++
.../Compute/AverageSalaryJob.cs | 65 ++++++
.../Compute/AverageSalaryTask.cs | 84 +++++++
.../Compute/CharacterCountClosure.cs | 43 ++++
.../Compute/CharacterCountReducer.cs | 51 +++++
.../Datagrid/ContinuousQueryFilter.cs | 50 ++++
.../Datagrid/EmployeeStore.cs | 121 ++++++++++
.../Datagrid/EmployeeStorePredicate.cs | 40 ++++
.../Events/LocalListener.cs | 55 +++++
.../Events/RemoteFilter.cs | 42 ++++
.../Messaging/LocalListener.cs | 59 +++++
.../Messaging/RemoteOrderedListener.cs | 54 +++++
.../Messaging/RemoteUnorderedListener.cs | 54 +++++
.../Messaging/Topic.cs | 28 +++
.../Portable/Account.cs | 60 +++++
.../Portable/Address.cs | 81 +++++++
.../Portable/Employee.cs | 93 ++++++++
.../Portable/EmployeeKey.cs | 86 +++++++
.../Portable/Organization.cs | 84 +++++++
.../Portable/OrganizationType.cs | 43 ++++
.../Properties/AssemblyInfo.cs | 35 +++
.../Services/MapService.cs | 119 ++++++++++
.../Examples2/Config/example-cache-query.xml | 111 +++++++++
.../Examples2/Config/example-cache-store.xml | 60 +++++
.../dotnet/Examples2/Config/example-cache.xml | 83 +++++++
.../dotnet/Examples2/Config/example-compute.xml | 70 ++++++
modules/platform/dotnet/Examples2/README.txt | 14 ++
96 files changed, 3931 insertions(+), 3931 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.Examples.sln
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples.sln b/modules/platform/dotnet/Examples/Apache.Ignite.Examples.sln
deleted file mode 100644
index c1337f3..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.Examples.sln
+++ /dev/null
@@ -1,72 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2013
-VisualStudioVersion = 12.0.31101.0
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Core", "..\Apache.Ignite.Core\Apache.Ignite.Core.csproj", "{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "..\..\cpp\common\project\vs\common.vcxproj", "{4F7E4917-4612-4B96-9838-025711ADE391}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Examples", "Apache.Ignite.Examples\Apache.Ignite.Examples.csproj", "{069FA680-3C4D-43A9-B84F-E67513B87827}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.ExamplesDll", "Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj", "{DFB08363-202E-412D-8812-349EF10A8702}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{F1491682-C798-4C23-8239-16C5BC2C5A02}"
- ProjectSection(SolutionItems) = preProject
- Config\example-cache-query.xml = Config\example-cache-query.xml
- Config\example-cache-store.xml = Config\example-cache-store.xml
- Config\example-cache.xml = Config\example-cache.xml
- Config\example-compute.xml = Config\example-compute.xml
- EndProjectSection
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite", "..\Apache.Ignite\Apache.Ignite.csproj", "{27F7F3C6-BDDE-43A9-B565-856F8395A04B}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x64.ActiveCfg = Debug|x64
- {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x64.Build.0 = Debug|x64
- {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x86.ActiveCfg = Debug|x86
- {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x86.Build.0 = Debug|x86
- {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x64.ActiveCfg = Release|x64
- {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x64.Build.0 = Release|x64
- {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x86.ActiveCfg = Release|x86
- {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x86.Build.0 = Release|x86
- {4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x64.ActiveCfg = Debug|x64
- {4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x64.Build.0 = Debug|x64
- {4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x86.ActiveCfg = Debug|Win32
- {4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x86.Build.0 = Debug|Win32
- {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x64.ActiveCfg = Release|x64
- {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x64.Build.0 = Release|x64
- {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x86.ActiveCfg = Release|Win32
- {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x86.Build.0 = Release|Win32
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.ActiveCfg = Debug|x64
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.Build.0 = Debug|x64
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.ActiveCfg = Debug|x86
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.Build.0 = Debug|x86
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.ActiveCfg = Release|x64
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.Build.0 = Release|x64
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.ActiveCfg = Release|x86
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.Build.0 = Release|x86
- {DFB08363-202E-412D-8812-349EF10A8702}.Debug|x64.ActiveCfg = Debug|x64
- {DFB08363-202E-412D-8812-349EF10A8702}.Debug|x86.ActiveCfg = Debug|x86
- {DFB08363-202E-412D-8812-349EF10A8702}.Release|x64.ActiveCfg = Release|x64
- {DFB08363-202E-412D-8812-349EF10A8702}.Release|x86.ActiveCfg = Release|x86
- {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x64.ActiveCfg = Debug|x64
- {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x64.Build.0 = Debug|x64
- {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x86.ActiveCfg = Debug|x86
- {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x86.Build.0 = Debug|x86
- {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x64.ActiveCfg = Release|x64
- {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x64.Build.0 = Release|x64
- {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x86.ActiveCfg = Release|x86
- {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x86.Build.0 = Release|x86
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.Examples.slnrel
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples.slnrel b/modules/platform/dotnet/Examples/Apache.Ignite.Examples.slnrel
deleted file mode 100644
index d898abc..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.Examples.slnrel
+++ /dev/null
@@ -1,38 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Examples", "Apache.Ignite.Examples\Apache.Ignite.Examples.csproj", "{069FA680-3C4D-43A9-B84F-E67513B87827}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.ExamplesDll", "Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj", "{DFB08363-202E-412D-8812-349EF10A8702}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{F1491682-C798-4C23-8239-16C5BC2C5A02}"
- ProjectSection(SolutionItems) = preProject
- Config\example-cache-query.xml = Config\example-cache-query.xml
- Config\example-cache-store.xml = Config\example-cache-store.xml
- Config\example-cache.xml = Config\example-cache.xml
- Config\example-compute.xml = Config\example-compute.xml
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.ActiveCfg = Debug|x64
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.Build.0 = Debug|x64
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.ActiveCfg = Debug|x86
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.Build.0 = Debug|x86
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.ActiveCfg = Release|x64
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.Build.0 = Release|x64
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.ActiveCfg = Release|x86
- {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.Build.0 = Release|x86
- {DFB08363-202E-412D-8812-349EF10A8702}.Debug|x64.ActiveCfg = Debug|x64
- {DFB08363-202E-412D-8812-349EF10A8702}.Debug|x86.ActiveCfg = Debug|x86
- {DFB08363-202E-412D-8812-349EF10A8702}.Release|x64.ActiveCfg = Release|x64
- {DFB08363-202E-412D-8812-349EF10A8702}.Release|x86.ActiveCfg = Release|x86
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
deleted file mode 100644
index 8ee90d9..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
+++ /dev/null
@@ -1,80 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{069FA680-3C4D-43A9-B84F-E67513B87827}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>Apache.Ignite.Examples</RootNamespace>
- <AssemblyName>Apache.Ignite.Examples</AssemblyName>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
- <PlatformTarget>x64</PlatformTarget>
- <OutputPath>bin\x64\Debug\</OutputPath>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
- <PlatformTarget>x64</PlatformTarget>
- <OutputPath>bin\x64\Release\</OutputPath>
- </PropertyGroup>
- <PropertyGroup>
- <StartupObject>Apache.Ignite.Examples.Compute.TaskExample</StartupObject>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
- <DebugSymbols>true</DebugSymbols>
- <OutputPath>bin\x86\Debug\</OutputPath>
- <PlatformTarget>x86</PlatformTarget>
- <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
- <OutputPath>bin\x86\Release\</OutputPath>
- <PlatformTarget>x86</PlatformTarget>
- <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Compute\ClosureExample.cs" />
- <Compile Include="Compute\TaskExample.cs" />
- <Compile Include="Datagrid\ContinuousQueryExample.cs" />
- <Compile Include="Datagrid\CrossPlatformExample.cs" />
- <Compile Include="Datagrid\DataStreamerExample.cs" />
- <Compile Include="Datagrid\PutGetExample.cs" />
- <Compile Include="Datagrid\QueryExample.cs" />
- <Compile Include="Datagrid\StoreExample.cs" />
- <Compile Include="Datagrid\TransactionExample.cs" />
- <Compile Include="Events\EventsExample.cs" />
- <Compile Include="Messaging\MessagingExample.cs" />
- <Compile Include="Misc\LifecycleExample.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Services\IMapService.cs" />
- <Compile Include="Services\ServicesExample.cs" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\Apache.Ignite.Core\Apache.Ignite.Core.csproj">
- <Project>{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}</Project>
- <Name>Apache.Ignite.Core</Name>
- </ProjectReference>
- <ProjectReference Include="..\Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj">
- <Project>{dfb08363-202e-412d-8812-349ef10a8702}</Project>
- <Name>Apache.Ignite.ExamplesDll</Name>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <None Include="App.config" />
- </ItemGroup>
- <ItemGroup />
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csprojrel
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csprojrel b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csprojrel
deleted file mode 100644
index ff13ddc..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csprojrel
+++ /dev/null
@@ -1,79 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{069FA680-3C4D-43A9-B84F-E67513B87827}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>Apache.Ignite.Examples</RootNamespace>
- <AssemblyName>Apache.Ignite.Examples</AssemblyName>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
- <PlatformTarget>x64</PlatformTarget>
- <OutputPath>bin\x64\Debug\</OutputPath>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
- <PlatformTarget>x64</PlatformTarget>
- <OutputPath>bin\x64\Release\</OutputPath>
- </PropertyGroup>
- <PropertyGroup>
- <StartupObject>Apache.Ignite.Examples.Compute.TaskExample</StartupObject>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
- <DebugSymbols>true</DebugSymbols>
- <OutputPath>bin\x86\Debug\</OutputPath>
- <PlatformTarget>x86</PlatformTarget>
- <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
- <OutputPath>bin\x86\Release\</OutputPath>
- <PlatformTarget>x86</PlatformTarget>
- <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="Apache.Ignite.Core">
- <HintPath>..\..\Apache.Ignite\bin\$(Platform)\$(Configuration)\Apache.Ignite.Core.dll</HintPath>
- </Reference>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Compute\ClosureExample.cs" />
- <Compile Include="Compute\TaskExample.cs" />
- <Compile Include="Datagrid\ContinuousQueryExample.cs" />
- <Compile Include="Datagrid\CrossPlatformExample.cs" />
- <Compile Include="Datagrid\DataStreamerExample.cs" />
- <Compile Include="Datagrid\PutGetExample.cs" />
- <Compile Include="Datagrid\QueryExample.cs" />
- <Compile Include="Datagrid\StoreExample.cs" />
- <Compile Include="Datagrid\TransactionExample.cs" />
- <Compile Include="Events\EventsExample.cs" />
- <Compile Include="Messaging\MessagingExample.cs" />
- <Compile Include="Misc\LifecycleExample.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Services\IMapService.cs" />
- <Compile Include="Services\ServicesExample.cs" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj">
- <Project>{dfb08363-202e-412d-8812-349ef10a8702}</Project>
- <Name>Apache.Ignite.ExamplesDll</Name>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <None Include="App.config" />
- </ItemGroup>
- <ItemGroup />
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.Examples/App.config
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/App.config b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/App.config
deleted file mode 100644
index 8e69aeb..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/App.config
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-
-<!--
- 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.
--->
-
-<configuration>
- <runtime>
- <gcServer enabled="true" />
- </runtime>
-</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Compute/ClosureExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Compute/ClosureExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Compute/ClosureExample.cs
deleted file mode 100644
index 7d0128d..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Compute/ClosureExample.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Apache.Ignite.Core;
-using Apache.Ignite.ExamplesDll.Compute;
-
-namespace Apache.Ignite.Examples.Compute
-{
- /// <summary>
- /// Example demonstrating closure execution.
- /// <para />
- /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
- /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
- /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 3) Start example (F5 or Ctrl+F5).
- /// <para />
- /// This example can be run with standalone Apache Ignite .Net node:
- /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
- /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-compute.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
- /// 2) Start example.
- /// </summary>
- public class ClosureExample
- {
- /// <summary>
- /// Runs the example.
- /// </summary>
- [STAThread]
- public static void Main()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
- };
-
- using (var ignite = Ignition.Start(cfg))
- {
- Console.WriteLine();
- Console.WriteLine(">>> Closure execution example started.");
-
- // Split the string by spaces to count letters in each word in parallel.
- ICollection<string> words = "Count characters using closure".Split().ToList();
-
- Console.WriteLine();
- Console.WriteLine(">>> Calculating character count with manual reducing:");
-
- var res = ignite.GetCompute().Apply(new CharacterCountClosure(), words);
-
- int totalLen = res.Sum();
-
- Console.WriteLine(">>> Total character count: " + totalLen);
- Console.WriteLine();
- Console.WriteLine(">>> Calculating character count with reducer:");
-
- totalLen = ignite.GetCompute().Apply(new CharacterCountClosure(), words, new CharacterCountReducer());
-
- Console.WriteLine(">>> Total character count: " + totalLen);
- Console.WriteLine();
- }
-
- Console.WriteLine();
- Console.WriteLine(">>> Example finished, press any key to exit ...");
- Console.ReadKey();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Compute/TaskExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Compute/TaskExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Compute/TaskExample.cs
deleted file mode 100644
index 47fee9e..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Compute/TaskExample.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using Apache.Ignite.Core;
-using Apache.Ignite.ExamplesDll.Compute;
-using Apache.Ignite.ExamplesDll.Portable;
-
-namespace Apache.Ignite.Examples.Compute
-{
- /// <summary>
- /// Example demonstrating task execution.
- /// <para />
- /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
- /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
- /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 3) Start example (F5 or Ctrl+F5).
- /// <para />
- /// This example can be run with standalone Apache Ignite .Net node:
- /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
- /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-compute.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
- /// 2) Start example.
- /// </summary>
- public class TaskExample
- {
- /// <summary>
- /// Runs the example.
- /// </summary>
- [STAThread]
- public static void Main()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
- };
-
- using (var ignite = Ignition.Start(cfg))
- {
- Console.WriteLine();
- Console.WriteLine(">>> Task execution example started.");
-
- // Generate employees to calculate average salary for.
- ICollection<Employee> employees = Employees();
-
- Console.WriteLine();
- Console.WriteLine(">>> Calculating average salary for employees:");
-
- foreach (Employee employee in employees)
- Console.WriteLine(">>> " + employee);
-
- // Execute task and get average salary.
- var avgSalary = ignite.GetCompute().Execute(new AverageSalaryTask(), employees);
-
- Console.WriteLine();
- Console.WriteLine(">>> Average salary for all employees: " + avgSalary);
- Console.WriteLine();
- }
-
- Console.WriteLine();
- Console.WriteLine(">>> Example finished, press any key to exit ...");
- Console.ReadKey();
- }
-
- /// <summary>
- /// Generates collection of employees for example.
- /// </summary>
- /// <returns>Collection of employees.</returns>
- private static ICollection<Employee> Employees()
- {
- return new []
- {
- new Employee(
- "James Wilson",
- 12500,
- new Address("1096 Eddy Street, San Francisco, CA", 94109),
- new List<string> {"Human Resources", "Customer Service"}
- ),
- new Employee(
- "Daniel Adams",
- 11000,
- new Address("184 Fidler Drive, San Antonio, TX", 78205),
- new List<string> {"Development", "QA"}
- ),
- new Employee(
- "Cristian Moss",
- 12500,
- new Address("667 Jerry Dove Drive, Florence, SC", 29501),
- new List<string> {"Logistics"}
- ),
- new Employee(
- "Allison Mathis",
- 25300,
- new Address("2702 Freedom Lane, Hornitos, CA", 95325),
- new List<string> {"Development"}
- ),
- new Employee(
- "Breana Robbin",
- 6500,
- new Address("3960 Sundown Lane, Austin, TX", 78758),
- new List<string> {"Sales"}
- ),
- new Employee(
- "Philip Horsley",
- 19800,
- new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
- new List<string> {"Sales"}
- ),
- new Employee(
- "Brian Peters",
- 10600,
- new Address("1407 Pearlman Avenue, Boston, MA", 02110),
- new List<string> {"Development", "QA"}
- ),
- new Employee(
- "Jack Yang",
- 12900,
- new Address("4425 Parrish Avenue Smithsons Valley, TX", 78130),
- new List<string> {"Sales"}
- )
- };
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
deleted file mode 100644
index c61b45d..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Threading;
-using Apache.Ignite.Core;
-using Apache.Ignite.Core.Cache.Event;
-using Apache.Ignite.Core.Cache.Query.Continuous;
-using Apache.Ignite.ExamplesDll.Datagrid;
-
-namespace Apache.Ignite.Examples.Datagrid
-{
- /// <summary>
- /// This example demonstrates continuous query API.
- /// <para />
- /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
- /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
- /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 3) Start example (F5 or Ctrl+F5).
- /// <para />
- /// This example can be run with standalone Apache Ignite .Net node:
- /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
- /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
- /// 2) Start example.
- /// </summary>
- public class ContinuousQueryExample
- {
- /// <summary>
- /// Runs the example.
- /// </summary>
- [STAThread]
- public static void Main()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
- JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
- };
-
- using (var ignite = Ignition.Start(cfg))
- {
- Console.WriteLine();
- Console.WriteLine(">>> Cache continuous query example started.");
-
- var cache = ignite.GetOrCreateCache<int, string>("cache_continuous_query");
-
- // Clean up caches on all nodes before run.
- cache.Clear();
-
- const int keyCnt = 20;
-
- for (int i = 0; i < keyCnt; i++)
- cache.Put(i, i.ToString());
-
- var qry = new ContinuousQuery<int, string>(new Listener<string>(), new ContinuousQueryFilter(15));
-
-
- // Create new continuous query.
- using (cache.QueryContinuous(qry))
- {
- // Add a few more keys and watch more query notifications.
- for (var i = keyCnt; i < keyCnt + 5; i++)
- cache.Put(i, i.ToString());
-
- // Wait for a while while callback is notified about remaining puts.
- Thread.Sleep(2000);
- }
- }
-
- Console.WriteLine();
- Console.WriteLine(">>> Example finished, press any key to exit ...");
- Console.ReadKey();
- }
-
- /// <summary>
- /// Callback for continuous query example.
- /// </summary>
- private class Listener<T> : ICacheEntryEventListener<int, T>
- {
- public void OnEvent(IEnumerable<ICacheEntryEvent<int, T>> events)
- {
- foreach (var e in events)
- Console.WriteLine("Queried entry [key=" + e.Key + ", val=" + e.Value + ']');
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
deleted file mode 100644
index e23d615..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using Apache.Ignite.Core;
-using Apache.Ignite.Core.Portable;
-using Apache.Ignite.ExamplesDll.Portable;
-
-namespace Apache.Ignite.Examples.Datagrid
-{
- /// <summary>
- /// This example demonstrates use of portable objects between different platforms.
- /// <para/>
- /// This example must be run with standalone Java node. To achieve this start a node from %IGNITE_HOME%
- /// using "ignite.bat" with proper configuration:
- /// <example>'bin\ignite.bat examples\config\example-server.xml'</example>.
- /// <para />
- /// Once remote node is started, launch this example as follows:
- /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build);
- /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 3) Start application (F5 or Ctrl+F5).
- /// <para />
- /// To see how objects can be transferred between platforms, start cross-platform Java example
- /// without restarting remote node.
- /// </summary>
- public class CrossPlatformExample
- {
- /// <summary>Key for Java object.</summary>
- private const int KeyJava = 100;
-
- /// <summary>Key for .Net object.</summary>
- private const int KeyDotnet = 200;
-
- /// <summary>Key for C++ object.</summary>
- private const int KeyCpp = 300;
-
- /// <summary>Cache Name.</summary>
- private const string CacheName = "cacheCrossPlatform";
-
- /// <summary>
- /// Runs the example.
- /// </summary>
- [STAThread]
- public static void Main()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
- };
-
- using (var ignite = Ignition.Start(cfg))
- {
- Console.WriteLine();
- Console.WriteLine(">>> Cross-platform example started.");
-
- if (ignite.GetCluster().ForRemotes().GetNodes().Count == 0)
- {
- Console.WriteLine();
- Console.WriteLine(">>> This example requires remote nodes to be started.");
- Console.WriteLine(">>> Please start at least 1 remote node.");
- Console.WriteLine(">>> Refer to example's documentation for details on configuration.");
- Console.WriteLine();
- }
- else
- {
- var cache = ignite.GetOrCreateCache<int, Organization>(CacheName);
-
- // Create new Organization object to store in cache.
- Organization org = new Organization(
- "Apache",
- new Address("1065 East Hillsdale Blvd, Foster City, CA", 94404),
- OrganizationType.Private,
- DateTime.Now
- );
-
- // Put created data entry to cache.
- cache.Put(KeyDotnet, org);
-
- // Retrieve value stored by Java client.
- GetFromJava(ignite);
-
- // Retrieve value stored by C++ client.
- GetFromCpp(ignite);
-
- // Gets portable value from cache in portable format, without de-serializing it.
- GetDotNetPortableInstance(ignite);
-
- // Gets portable value form cache as a strongly-typed fully de-serialized instance.
- GetDotNetTypedInstance(ignite);
-
- Console.WriteLine();
- }
- }
-
- Console.WriteLine();
- Console.WriteLine(">>> Example finished, press any key to exit ...");
- Console.ReadKey();
- }
-
- /// <summary>
- /// Gets entry put by Java client. In order for entry to be in cache, Java client example
- /// must be run before this example.
- /// </summary>
- /// <param name="Ignite">Ignite instance.</param>
- private static void GetFromJava(IIgnite ignite)
- {
- var cache = ignite.GetOrCreateCache<int, IPortableObject>(CacheName)
- .WithKeepPortable<int, IPortableObject>().WithAsync();
-
- cache.Get(KeyJava);
-
- var orgPortable = cache.GetFuture<IPortableObject>().ToTask().Result;
-
- if (orgPortable == null)
- {
- Console.WriteLine(">>> Java client hasn't put entry to cache. Run Java example before this example " +
- "to see the output.");
- }
- else
- {
- Console.WriteLine(">>> Entry from Java client:");
- Console.WriteLine(">>> Portable: " + orgPortable);
- Console.WriteLine(">>> Deserialized: " + orgPortable.Deserialize<Organization>());
- }
- }
-
- /// <summary>
- /// Gets entry put by C++ client. In order for entry to be in cache, C++ client example
- /// must be run before this example.
- /// </summary>
- /// <param name="ignite">Ignite instance.</param>
- private static void GetFromCpp(IIgnite ignite)
- {
- var cache = ignite.GetOrCreateCache<int, IPortableObject>(CacheName)
- .WithKeepPortable<int, IPortableObject>().WithAsync();
-
- cache.Get(KeyCpp);
-
- var orgPortable = cache.GetFuture<IPortableObject>().Get();
-
- Console.WriteLine();
-
- if (orgPortable == null)
- {
- Console.WriteLine(">>> CPP client hasn't put entry to cache. Run CPP example before this example " +
- "to see the output.");
- }
- else
- {
- Console.WriteLine(">>> Entry from CPP client:");
- Console.WriteLine(">>> Portable: " + orgPortable);
- Console.WriteLine(">>> Deserialized: " + orgPortable.Deserialize<Organization>());
- }
- }
-
- /// <summary>
- /// Gets portable value from cache in portable format, without de-serializing it.
- /// </summary>
- /// <param name="ignite">Ignite instance.</param>
- private static void GetDotNetPortableInstance(IIgnite ignite)
- {
- // Apply "KeepPortable" flag on data projection.
- var cache = ignite.GetOrCreateCache<int, IPortableObject>(CacheName)
- .WithKeepPortable<int, IPortableObject>();
-
- var org = cache.Get(KeyDotnet);
-
- string name = org.GetField<string>("name");
-
- Console.WriteLine();
- Console.WriteLine(">>> Retrieved organization name from portable field: " + name);
- }
-
- /// <summary>
- /// Gets portable value form cache as a strongly-typed fully de-serialized instance.
- /// </summary>
- /// <param name="ignite">Ignite instance.</param>
- private static void GetDotNetTypedInstance(IIgnite ignite)
- {
- var cache = ignite.GetOrCreateCache<int, Organization>(CacheName);
-
- // Get recently created employee as a strongly-typed fully de-serialized instance.
- Organization emp = cache.Get(KeyDotnet);
-
- string name = emp.Name;
-
- Console.WriteLine();
- Console.WriteLine(">>> Retrieved organization name from deserialized Organization instance: " + name);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
deleted file mode 100644
index ee9e200..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using Apache.Ignite.Core;
-using Apache.Ignite.Core.Datastream;
-using Apache.Ignite.ExamplesDll.Portable;
-
-namespace Apache.Ignite.Examples.Datagrid
-{
- /// <summary>
- /// Demonstrates how cache can be populated with data utilizing <see cref="IDataStreamer{TK,TV}"/>.
- /// Data streamer is a lot more efficient to use than standard cache put operation
- /// as it properly buffers cache requests together and properly manages load on remote nodes.
- /// <para />
- /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
- /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
- /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 3) Start example (F5 or Ctrl+F5).
- /// <para />
- /// This example can be run with standalone Apache Ignite .Net node:
- /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
- /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
- /// 2) Start example.
- /// </summary>
- public class DataStreamerExample
- {
- /// <summary>Number of entries to load.</summary>
- private const int EntryCount = 500000;
-
- /// <summary>Cache name.</summary>
- private const string CacheName = "cache_data_streamer";
-
- /// <summary>
- /// Runs the example.
- /// </summary>
- [STAThread]
- public static void Main()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
- JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
- };
-
- using (var ignite = Ignition.Start(cfg))
- {
- Console.WriteLine();
- Console.WriteLine(">>> Cache data streamer example started.");
-
- // Clean up caches on all nodes before run.
- ignite.GetOrCreateCache<int, Account>(CacheName).Clear();
-
- Stopwatch timer = new Stopwatch();
-
- timer.Start();
-
- using (var ldr = ignite.GetDataStreamer<int, Account>(CacheName))
- {
- ldr.PerNodeBufferSize = 1024;
-
- for (int i = 0; i < EntryCount; i++)
- {
- ldr.AddData(i, new Account(i, i));
-
- // Print out progress while loading cache.
- if (i > 0 && i % 10000 == 0)
- Console.WriteLine("Loaded " + i + " accounts.");
- }
- }
-
- timer.Stop();
-
- long dur = timer.ElapsedMilliseconds;
-
- Console.WriteLine(">>> Loaded " + EntryCount + " accounts in " + dur + "ms.");
- }
-
- Console.WriteLine();
- Console.WriteLine(">>> Example finished, press any key to exit ...");
- Console.ReadKey();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
deleted file mode 100644
index c1146f1..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using Apache.Ignite.Core;
-using Apache.Ignite.Core.Portable;
-using Apache.Ignite.ExamplesDll.Portable;
-
-namespace Apache.Ignite.Examples.Datagrid
-{
- /// <summary>
- /// This example demonstrates several put-get operations on Ignite cache
- /// with portable values. Note that portable object can be retrieved in
- /// fully-deserialized form or in portable object format using special
- /// cache projection.
- /// <para />
- /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
- /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
- /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 3) Start example (F5 or Ctrl+F5).
- /// <para />
- /// This example can be run with standalone Apache Ignite .Net node:
- /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
- /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
- /// 2) Start example.
- /// </summary>
- public class PutGetExample
- {
- /// <summary>Cache name.</summary>
- private const string CacheName = "cache_put_get";
-
- /// <summary>
- /// Runs the example.
- /// </summary>
- [STAThread]
- public static void Main()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
- };
-
- using (var ignite = Ignition.Start(cfg))
- {
- Console.WriteLine();
- Console.WriteLine(">>> Cache put-get example started.");
-
- // Clean up caches on all nodes before run.
- ignite.GetOrCreateCache<object, object>(CacheName).Clear();
-
- PutGet(ignite);
- PutGetPortable(ignite);
- PutAllGetAll(ignite);
- PutAllGetAllPortable(ignite);
-
- Console.WriteLine();
- }
-
- Console.WriteLine();
- Console.WriteLine(">>> Example finished, press any key to exit ...");
- Console.ReadKey();
- }
-
- /// <summary>
- /// Execute individual Put and Get.
- /// </summary>
- /// <param name="ignite">Ignite instance.</param>
- private static void PutGet(IIgnite ignite)
- {
- var cache = ignite.GetCache<int, Organization>(CacheName);
-
- // Create new Organization to store in cache.
- Organization org = new Organization(
- "Microsoft",
- new Address("1096 Eddy Street, San Francisco, CA", 94109),
- OrganizationType.Private,
- DateTime.Now
- );
-
- // Put created data entry to cache.
- cache.Put(1, org);
-
- // Get recently created employee as a strongly-typed fully de-serialized instance.
- Organization orgFromCache = cache.Get(1);
-
- Console.WriteLine();
- Console.WriteLine(">>> Retrieved organization instance from cache: " + orgFromCache);
- }
-
- /// <summary>
- /// Execute individual Put and Get, getting value in portable format, without de-serializing it.
- /// </summary>
- /// <param name="ignite">Ignite instance.</param>
- private static void PutGetPortable(IIgnite ignite)
- {
- var cache = ignite.GetCache<int, Organization>(CacheName);
-
- // Create new Organization to store in cache.
- Organization org = new Organization(
- "Microsoft",
- new Address("1096 Eddy Street, San Francisco, CA", 94109),
- OrganizationType.Private,
- DateTime.Now
- );
-
- // Put created data entry to cache.
- cache.Put(1, org);
-
- // Create projection that will get values as portable objects.
- var portableCache = cache.WithKeepPortable<int, IPortableObject>();
-
- // Get recently created organization as a portable object.
- var portableOrg = portableCache.Get(1);
-
- // Get organization's name from portable object (note that object doesn't need to be fully deserialized).
- string name = portableOrg.GetField<string>("name");
-
- Console.WriteLine();
- Console.WriteLine(">>> Retrieved organization name from portable object: " + name);
- }
-
- /// <summary>
- /// Execute bulk Put and Get operations.
- /// </summary>
- /// <param name="ignite">Ignite instance.</param>
- private static void PutAllGetAll(IIgnite ignite)
- {
- var cache = ignite.GetCache<int, Organization>(CacheName);
-
- // Create new Organizations to store in cache.
- Organization org1 = new Organization(
- "Microsoft",
- new Address("1096 Eddy Street, San Francisco, CA", 94109),
- OrganizationType.Private,
- DateTime.Now
- );
-
- Organization org2 = new Organization(
- "Red Cross",
- new Address("184 Fidler Drive, San Antonio, TX", 78205),
- OrganizationType.NonProfit,
- DateTime.Now
- );
-
- var map = new Dictionary<int, Organization> { { 1, org1 }, { 2, org2 } };
-
- // Put created data entries to cache.
- cache.PutAll(map);
-
- // Get recently created organizations as a strongly-typed fully de-serialized instances.
- IDictionary<int, Organization> mapFromCache = cache.GetAll(new List<int> { 1, 2 });
-
- Console.WriteLine();
- Console.WriteLine(">>> Retrieved organization instances from cache:");
-
- foreach (Organization org in mapFromCache.Values)
- Console.WriteLine(">>> " + org);
- }
-
- /// <summary>
- /// Execute bulk Put and Get operations getting values in portable format, without de-serializing it.
- /// </summary>
- /// <param name="ignite">Ignite instance.</param>
- private static void PutAllGetAllPortable(IIgnite ignite)
- {
- var cache = ignite.GetCache<int, Organization>(CacheName);
-
- // Create new Organizations to store in cache.
- Organization org1 = new Organization(
- "Microsoft",
- new Address("1096 Eddy Street, San Francisco, CA", 94109),
- OrganizationType.Private,
- DateTime.Now
- );
-
- Organization org2 = new Organization(
- "Red Cross",
- new Address("184 Fidler Drive, San Antonio, TX", 78205),
- OrganizationType.NonProfit,
- DateTime.Now
- );
-
- var map = new Dictionary<int, Organization> { { 1, org1 }, { 2, org2 } };
-
- // Put created data entries to cache.
- cache.PutAll(map);
-
- // Create projection that will get values as portable objects.
- var portableCache = cache.WithKeepPortable<int, IPortableObject>();
-
- // Get recently created organizations as portable objects.
- IDictionary<int, IPortableObject> portableMap =
- portableCache.GetAll(new List<int> { 1, 2 });
-
- Console.WriteLine();
- Console.WriteLine(">>> Retrieved organization names from portable objects:");
-
- foreach (IPortableObject poratbleOrg in portableMap.Values)
- Console.WriteLine(">>> " + poratbleOrg.GetField<string>("name"));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
deleted file mode 100644
index 523b83f..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using Apache.Ignite.Core;
-using Apache.Ignite.Core.Cache;
-using Apache.Ignite.Core.Cache.Query;
-using Apache.Ignite.ExamplesDll.Portable;
-
-namespace Apache.Ignite.Examples.Datagrid
-{
- /// <summary>
- /// This example populates cache with sample data and runs several SQL and
- /// full text queries over this data.
- /// <para />
- /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
- /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
- /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 3) Start example (F5 or Ctrl+F5).
- /// <para />
- /// This example can be run with standalone Apache Ignite .Net node:
- /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
- /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache-query.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
- /// 2) Start example.
- /// </summary>
- public class QueryExample
- {
- [STAThread]
- public static void Main()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache-query.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
- };
-
- using (var ignite = Ignition.Start(cfg))
- {
- Console.WriteLine();
- Console.WriteLine(">>> Cache query example started.");
-
- var cache = ignite.GetCache<object, object>(null);
-
- // Clean up caches on all nodes before run.
- cache.Clear();
-
- // Populate cache with sample data entries.
- PopulateCache(cache);
-
- // Create cache that will work with specific types.
- var employeeCache = ignite.GetCache<EmployeeKey, Employee>(null);
-
- // Run SQL query example.
- SqlQueryExample(employeeCache);
-
- // Run SQL query with join example.
- SqlJoinQueryExample(employeeCache);
-
- // Run SQL fields query example.
- SqlFieldsQueryExample(employeeCache);
-
- // Run full text query example.
- FullTextQueryExample(employeeCache);
-
- Console.WriteLine();
- }
-
- Console.WriteLine();
- Console.WriteLine(">>> Example finished, press any key to exit ...");
- Console.ReadKey();
- }
-
- /// <summary>
- /// Queries employees that have provided ZIP code in address.
- /// </summary>
- /// <param name="cache">Cache.</param>
- private static void SqlQueryExample(ICache<EmployeeKey, Employee> cache)
- {
- const int zip = 94109;
-
- var qry = cache.Query(new SqlQuery(typeof(Employee), "zip = ?", zip));
-
- Console.WriteLine();
- Console.WriteLine(">>> Employees with zipcode " + zip + ":");
-
- foreach (var entry in qry)
- Console.WriteLine(">>> " + entry.Value);
- }
-
- /// <summary>
- /// Queries employees that work for organization with provided name.
- /// </summary>
- /// <param name="cache">Cache.</param>
- private static void SqlJoinQueryExample(ICache<EmployeeKey, Employee> cache)
- {
- const string orgName = "Apache";
-
- var qry = cache.Query(new SqlQuery("Employee",
- "from Employee, Organization " +
- "where Employee.organizationId = Organization._key and Organization.name = ?", orgName));
-
- Console.WriteLine();
- Console.WriteLine(">>> Employees working for " + orgName + ":");
-
- foreach (var entry in qry)
- Console.WriteLine(">>> " + entry.Value);
- }
-
- /// <summary>
- /// Queries names and salaries for all employees.
- /// </summary>
- /// <param name="cache">Cache.</param>
- private static void SqlFieldsQueryExample(ICache<EmployeeKey, Employee> cache)
- {
- var qry = cache.QueryFields(new SqlFieldsQuery("select name, salary from Employee"));
-
- Console.WriteLine();
- Console.WriteLine(">>> Employee names and their salaries:");
-
- foreach (IList row in qry)
- Console.WriteLine(">>> [Name=" + row[0] + ", salary=" + row[1] + ']');
- }
-
- /// <summary>
- /// Queries employees that live in Texas using full-text query API.
- /// </summary>
- /// <param name="cache">Cache.</param>
- private static void FullTextQueryExample(ICache<EmployeeKey, Employee> cache)
- {
- var qry = cache.Query(new TextQuery("Employee", "TX"));
-
- Console.WriteLine();
- Console.WriteLine(">>> Employees living in Texas:");
-
- foreach (var entry in qry)
- Console.WriteLine(">>> " + entry.Value);
- }
-
- /// <summary>
- /// Populate cache with data for this example.
- /// </summary>
- /// <param name="cache">Cache.</param>
- private static void PopulateCache(ICache<object, object> cache)
- {
- cache.Put(1, new Organization(
- "Apache",
- new Address("1065 East Hillsdale Blvd, Foster City, CA", 94404),
- OrganizationType.Private,
- DateTime.Now
- ));
-
- cache.Put(2, new Organization(
- "Microsoft",
- new Address("1096 Eddy Street, San Francisco, CA", 94109),
- OrganizationType.Private,
- DateTime.Now
- ));
-
- cache.Put(new EmployeeKey(1, 1), new Employee(
- "James Wilson",
- 12500,
- new Address("1096 Eddy Street, San Francisco, CA", 94109),
- new List<string> { "Human Resources", "Customer Service" }
- ));
-
- cache.Put(new EmployeeKey(2, 1), new Employee(
- "Daniel Adams",
- 11000,
- new Address("184 Fidler Drive, San Antonio, TX", 78130),
- new List<string> { "Development", "QA" }
- ));
-
- cache.Put(new EmployeeKey(3, 1), new Employee(
- "Cristian Moss",
- 12500,
- new Address("667 Jerry Dove Drive, Florence, SC", 29501),
- new List<string> { "Logistics" }
- ));
-
- cache.Put(new EmployeeKey(4, 2), new Employee(
- "Allison Mathis",
- 25300,
- new Address("2702 Freedom Lane, San Francisco, CA", 94109),
- new List<string> { "Development" }
- ));
-
- cache.Put(new EmployeeKey(5, 2), new Employee(
- "Breana Robbin",
- 6500,
- new Address("3960 Sundown Lane, Austin, TX", 78130),
- new List<string> { "Sales" }
- ));
-
- cache.Put(new EmployeeKey(6, 2), new Employee(
- "Philip Horsley",
- 19800,
- new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
- new List<string> { "Sales" }
- ));
-
- cache.Put(new EmployeeKey(7, 2), new Employee(
- "Brian Peters",
- 10600,
- new Address("1407 Pearlman Avenue, Boston, MA", 12110),
- new List<string> { "Development", "QA" }
- ));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs
deleted file mode 100644
index 6c2b40d..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using Apache.Ignite.Core;
-using Apache.Ignite.ExamplesDll.Datagrid;
-using Apache.Ignite.ExamplesDll.Portable;
-
-namespace Apache.Ignite.Examples.Datagrid
-{
- /// <summary>
- /// Example demonstrating cache store.
- /// <para />
- /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
- /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
- /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 3) Start example (F5 or Ctrl+F5).
- /// <para />
- /// This example can be run with standalone Apache Ignite .Net node:
- /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
- /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache-store.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
- /// 2) Start example.
- /// </summary>
- class StoreExample
- {
- /// <summary>
- /// Runs the example.
- /// </summary>
- [STAThread]
- public static void Main()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache-store.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
- };
-
- using (var ignite = Ignition.Start(cfg))
- {
- Console.WriteLine();
- Console.WriteLine(">>> Cache store example started.");
-
- var cache = ignite.GetCache<int, Employee>(null);
-
- // Clean up caches on all nodes before run.
- cache.Clear();
-
- Console.WriteLine();
- Console.WriteLine(">>> Cleared values from cache.");
- Console.WriteLine(">>> Current cache size: " + cache.GetSize());
-
- // Load entries from store which pass provided filter.
- cache.LoadCache(new EmployeeStorePredicate());
-
- Console.WriteLine();
- Console.WriteLine(">>> Loaded entry from store through ICache.LoadCache().");
- Console.WriteLine(">>> Current cache size: " + cache.GetSize());
-
- // Load entry from store calling ICache.Get() method.
- Employee emp = cache.Get(2);
-
- Console.WriteLine();
- Console.WriteLine(">>> Loaded entry from store through ICache.Get(): " + emp);
- Console.WriteLine(">>> Current cache size: " + cache.GetSize());
-
- // Put an entry to the cache
- cache.Put(3, new Employee(
- "James Wilson",
- 12500,
- new Address("1096 Eddy Street, San Francisco, CA", 94109),
- new List<string> { "Human Resources", "Customer Service" }
- ));
-
- Console.WriteLine();
- Console.WriteLine(">>> Put entry to cache. ");
- Console.WriteLine(">>> Current cache size: " + cache.GetSize());
-
- // Clear values again.
- cache.Clear();
-
- Console.WriteLine();
- Console.WriteLine(">>> Cleared values from cache again.");
- Console.WriteLine(">>> Current cache size: " + cache.GetSize());
-
- // Read values from cache after clear.
- Console.WriteLine();
- Console.WriteLine(">>> Read values after clear:");
-
- for (int i = 1; i <= 3; i++)
- Console.WriteLine(">>> Key=" + i + ", value=" + cache.Get(i));
- }
-
- Console.WriteLine();
- Console.WriteLine(">>> Example finished, press any key to exit ...");
- Console.ReadKey();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
deleted file mode 100644
index 6be3523..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using Apache.Ignite.Core;
-using Apache.Ignite.Core.Transactions;
-using Apache.Ignite.ExamplesDll.Portable;
-
-namespace Apache.Ignite.Examples.Datagrid
-{
- /// <summary>
- /// This example demonstrates how to use transactions on Apache cache.
- /// <para />
- /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
- /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
- /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 3) Start example (F5 or Ctrl+F5).
- /// <para />
- /// This example can be run with standalone Apache Ignite .Net node:
- /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
- /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
- /// 2) Start example.
- /// </summary>
- class TransactionExample
- {
- /// <summary>
- /// Runs the example.
- /// </summary>
- [STAThread]
- public static void Main()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
- };
-
- using (var ignite = Ignition.Start(cfg))
- {
- Console.WriteLine();
- Console.WriteLine(">>> Transaction example started.");
-
- var cache = ignite.GetCache<int, Account>("tx");
-
- // Clean up caches on all nodes before run.
- cache.Clear();
-
- // Initialize.
- cache.Put(1, new Account(1, 100));
- cache.Put(2, new Account(2, 200));
-
- Console.WriteLine();
- Console.WriteLine(">>> Accounts before transfer: ");
- Console.WriteLine(">>> " + cache.Get(1));
- Console.WriteLine(">>> " + cache.Get(2));
- Console.WriteLine();
-
- // Transfer money between accounts in a single transaction.
- using (var tx = cache.Ignite.GetTransactions().TxStart(TransactionConcurrency.Pessimistic,
- TransactionIsolation.RepeatableRead))
- {
- Account acc1 = cache.Get(1);
- Account acc2 = cache.Get(2);
-
- acc1.Balance += 100;
- acc2.Balance -= 100;
-
- cache.Put(1, acc1);
- cache.Put(2, acc2);
-
- tx.Commit();
- }
-
- Console.WriteLine(">>> Transfer finished.");
-
- Console.WriteLine();
- Console.WriteLine(">>> Accounts after transfer: ");
- Console.WriteLine(">>> " + cache.Get(1));
- Console.WriteLine(">>> " + cache.Get(2));
- Console.WriteLine();
- }
-
- Console.WriteLine();
- Console.WriteLine(">>> Example finished, press any key to exit ...");
- Console.ReadKey();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Events/EventsExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Events/EventsExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Events/EventsExample.cs
deleted file mode 100644
index 83802cc..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Events/EventsExample.cs
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Apache.Ignite.Core;
-using Apache.Ignite.Core.Events;
-using Apache.Ignite.ExamplesDll.Compute;
-using Apache.Ignite.ExamplesDll.Events;
-using Apache.Ignite.ExamplesDll.Portable;
-
-namespace Apache.Ignite.Examples.Events
-{
- /// <summary>
- /// Example demonstrating Ignite events.
- /// <para />
- /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
- /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
- /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 3) Start example (F5 or Ctrl+F5).
- /// <para />
- /// This example can be run with standalone Apache Ignite .Net node:
- /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
- /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-compute.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
- /// 2) Start example.
- /// </summary>
- public class EventsExample
- {
- /// <summary>
- /// Runs the example.
- /// </summary>
- [STAThread]
- public static void Main()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
- JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
- };
-
- using (var ignite = Ignition.Start(cfg))
- {
- Console.WriteLine(">>> Events example started.");
- Console.WriteLine();
-
- // Local listen example
- Console.WriteLine(">>> Listening for a local event...");
-
- var listener = new LocalListener();
- ignite.GetEvents().LocalListen(listener, EventType.EvtsTaskExecution);
-
- ExecuteTask(ignite);
-
- ignite.GetEvents().StopLocalListen(listener);
-
- Console.WriteLine(">>> Received events count: " + listener.EventsReceived);
- Console.WriteLine();
-
- // Remote listen example (start standalone nodes for better demonstration)
- Console.WriteLine(">>> Listening for remote events...");
-
- var localListener = new LocalListener();
- var remoteFilter = new RemoteFilter();
-
- var listenId = ignite.GetEvents().RemoteListen(localListener: localListener,
- remoteFilter: remoteFilter, types: EventType.EvtsJobExecution);
-
- ExecuteTask(ignite);
-
- ignite.GetEvents().StopRemoteListen(listenId);
-
- Console.WriteLine(">>> Received events count: " + localListener.EventsReceived);
- }
-
- Console.WriteLine();
- Console.WriteLine(">>> Example finished, press any key to exit ...");
- Console.ReadKey();
- }
-
- /// <summary>
- /// Executes a task to generate events.
- /// </summary>
- /// <param name="ignite">Ignite instance.</param>
- private static void ExecuteTask(IIgnite ignite)
- {
- var employees = Enumerable.Range(1, 10).SelectMany(x => new[]
- {
- new Employee("Allison Mathis",
- 25300,
- new Address("2702 Freedom Lane, San Francisco, CA", 94109),
- new[] {"Development"}),
-
- new Employee("Breana Robbin",
- 6500,
- new Address("3960 Sundown Lane, Austin, TX", 78130),
- new[] {"Sales"})
- }).ToArray();
-
- ignite.GetCompute().Execute(new AverageSalaryTask(), employees);
- }
- }
-}
[09/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Messaging/MessagingExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Messaging/MessagingExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Messaging/MessagingExample.cs
deleted file mode 100644
index a24c47c..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Messaging/MessagingExample.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Threading;
-using Apache.Ignite.Core;
-using Apache.Ignite.ExamplesDll.Messaging;
-
-namespace Apache.Ignite.Examples.Messaging
-{
- /// <summary>
- /// Example demonstrating Ignite messaging. Should be run with standalone Apache Ignite .Net node.
- /// <para />
- /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
- /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-compute.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
- /// 2) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
- /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
- /// 3) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 4) Start example (F5 or Ctrl+F5).
- /// </summary>
- public class MessagingExample
- {
- /// <summary>
- /// Runs the example.
- /// </summary>
- [STAThread]
- public static void Main()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
- };
-
- using (var ignite = Ignition.Start(cfg))
- {
- var remotes = ignite.GetCluster().ForRemotes();
-
- if (remotes.GetNodes().Count == 0)
- {
- Console.WriteLine(">>> This example requires remote nodes to be started.");
- Console.WriteLine(">>> Please start at least 1 remote node.");
- Console.WriteLine(">>> Refer to example's documentation for details on configuration.");
- }
- else
- {
- Console.WriteLine(">>> Messaging example started.");
- Console.WriteLine();
-
- // Set up local listeners
- var localMessaging = ignite.GetCluster().ForLocal().GetMessaging();
-
- var msgCount = remotes.GetNodes().Count * 10;
-
- var orderedCounter = new CountdownEvent(msgCount);
- var unorderedCounter = new CountdownEvent(msgCount);
-
- localMessaging.LocalListen(new LocalListener(unorderedCounter), Topic.Unordered);
- localMessaging.LocalListen(new LocalListener(orderedCounter), Topic.Ordered);
-
- // Set up remote listeners
- var remoteMessaging = remotes.GetMessaging();
-
- remoteMessaging.RemoteListen(new RemoteUnorderedListener(), Topic.Unordered);
- remoteMessaging.RemoteListen(new RemoteOrderedListener(), Topic.Ordered);
-
- // Send unordered
- Console.WriteLine(">>> Sending unordered messages...");
-
- for (var i = 0; i < 10; i++)
- remoteMessaging.Send(i, Topic.Unordered);
-
- Console.WriteLine(">>> Finished sending unordered messages.");
-
- // Send ordered
- Console.WriteLine(">>> Sending ordered messages...");
-
- for (var i = 0; i < 10; i++)
- remoteMessaging.SendOrdered(i, Topic.Ordered);
-
- Console.WriteLine(">>> Finished sending ordered messages.");
-
- Console.WriteLine(">>> Check output on all nodes for message printouts.");
- Console.WriteLine(">>> Waiting for messages acknowledgements from all remote nodes...");
-
- unorderedCounter.Wait();
- orderedCounter.Wait();
- }
- }
-
- Console.WriteLine();
- Console.WriteLine(">>> Example finished, press any key to exit ...");
- Console.ReadKey();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Misc/LifecycleExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Misc/LifecycleExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Misc/LifecycleExample.cs
deleted file mode 100644
index 2d319e8..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Misc/LifecycleExample.cs
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using Apache.Ignite.Core;
-using Apache.Ignite.Core.Lifecycle;
-using Apache.Ignite.Core.Resource;
-
-namespace Apache.Ignite.Examples.Misc
-{
- /// <summary>
- /// This example shows how to provide your own <see cref="ILifecycleBean"/> implementation
- /// to be able to hook into Apache lifecycle. Example bean will output occurred lifecycle
- /// events to the console.
- /// <para />
- /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
- /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
- /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 3) Start example (F5 or Ctrl+F5).
- /// </summary>
- public class LifecycleExample
- {
- /// <summary>
- /// Runs the example.
- /// </summary>
- [STAThread]
- public static void Main()
- {
- Console.WriteLine();
- Console.WriteLine(">>> Lifecycle example started.");
-
- // Create new configuration.
- var lifecycleExampleBean = new LifecycleExampleBean();
-
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" },
- LifecycleBeans = new List<ILifecycleBean> { lifecycleExampleBean }
- };
-
- // Provide lifecycle bean to configuration.
- using (Ignition.Start(cfg))
- {
- // Make sure that lifecycle bean was notified about Ignite startup.
- Console.WriteLine();
- Console.WriteLine(">>> Started (should be true): " + lifecycleExampleBean.Started);
- }
-
- // Make sure that lifecycle bean was notified about Ignite stop.
- Console.WriteLine();
- Console.WriteLine(">>> Started (should be false): " + lifecycleExampleBean.Started);
-
- Console.WriteLine();
- Console.WriteLine(">>> Example finished, press any key to exit ...");
- Console.ReadKey();
- }
-
- /// <summary>
- /// Sample lifecycle bean implementation.
- /// </summary>
- private class LifecycleExampleBean : ILifecycleBean
- {
- /** Auto-injected Ignite instance. */
- [InstanceResource]
-#pragma warning disable 649
- private IIgnite _ignite;
-#pragma warning restore 649
-
- /** <inheritDoc /> */
- public void OnLifecycleEvent(LifecycleEventType evt)
- {
- Console.WriteLine();
- Console.WriteLine(">>> Ignite lifecycle event occurred: " + evt);
- Console.WriteLine(">>> Ignite name: " + (_ignite != null ? _ignite.Name : "not available"));
-
- if (evt == LifecycleEventType.AfterNodeStart)
- Started = true;
- else if (evt == LifecycleEventType.AfterNodeStop)
- Started = false;
- }
-
- /// <summary>
- /// Started flag.
- /// </summary>
- public bool Started
- {
- get;
- private set;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Properties/AssemblyInfo.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Properties/AssemblyInfo.cs
deleted file mode 100644
index 555a35f..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-[assembly: AssemblyTitle("Apache Ignite Examples")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Apache Software Foundation")]
-[assembly: AssemblyProduct("Apache Ignite")]
-[assembly: AssemblyCopyright("Copyright © 2015")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-[assembly: ComVisible(false)]
-
-[assembly: Guid("41a0cb95-3435-4c78-b867-900b28e2c9ee")]
-
-[assembly: AssemblyVersion("1.5.0")]
-[assembly: AssemblyFileVersion("1.5.0")]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Services/IMapService.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Services/IMapService.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Services/IMapService.cs
deleted file mode 100644
index 7253a0b..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Services/IMapService.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using Apache.Ignite.ExamplesDll.Services;
-
-namespace Apache.Ignite.Examples.Services
-{
- /// <summary>
- /// Interface for service proxy interaction.
- /// Actual service class (<see cref="MapService{TK,TV}"/>) does not have to implement this interface.
- /// Target method/property will be searched by signature (name, arguments).
- /// </summary>
- public interface IMapService<TK, TV>
- {
- /// <summary>
- /// Puts an entry to the map.
- /// </summary>
- /// <param name="key">The key.</param>
- /// <param name="value">The value.</param>
- void Put(TK key, TV value);
-
- /// <summary>
- /// Gets an entry from the map.
- /// </summary>
- /// <param name="key">The key.</param>
- /// <returns>Entry value.</returns>
- TV Get(TK key);
-
- /// <summary>
- /// Clears the map.
- /// </summary>
- void Clear();
-
- /// <summary>
- /// Gets the size of the map.
- /// </summary>
- /// <value>
- /// The size.
- /// </value>
- int Size { get; }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Services/ServicesExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Services/ServicesExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Services/ServicesExample.cs
deleted file mode 100644
index 6d0ddd0..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Services/ServicesExample.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using Apache.Ignite.Core;
-using Apache.Ignite.ExamplesDll.Services;
-
-namespace Apache.Ignite.Examples.Services
-{
- /// <summary>
- /// Example demonstrating Ignite services.
- /// <para />
- /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
- /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
- /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 3) Start example (F5 or Ctrl+F5).
- /// <para />
- /// This example can be run with standalone Apache Ignite .Net node:
- /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
- /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
- /// 2) Start example.
- /// </summary>
- public class ServicesExample
- {
- /// <summary>
- /// Runs the example.
- /// </summary>
- [STAThread]
- public static void Main()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
- JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
- };
-
- using (var ignite = Ignition.Start(cfg))
- {
- Console.WriteLine(">>> Services example started.");
- Console.WriteLine();
-
- // Deploy a service
- var svc = new MapService<int, string>();
- Console.WriteLine(">>> Deploying service to all nodes...");
- ignite.GetServices().DeployNodeSingleton("service", svc);
-
- // Get a sticky service proxy so that we will always be contacting the same remote node.
- var prx = ignite.GetServices().GetServiceProxy<IMapService<int, string>>("service", true);
-
- for (var i = 0; i < 10; i++)
- prx.Put(i, i.ToString());
-
- var mapSize = prx.Size;
-
- Console.WriteLine(">>> Map service size: " + mapSize);
-
- ignite.GetServices().CancelAll();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
deleted file mode 100644
index cb2ff6f..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
+++ /dev/null
@@ -1,75 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{DFB08363-202E-412D-8812-349EF10A8702}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>Apache.Ignite.ExamplesDll</RootNamespace>
- <AssemblyName>Apache.Ignite.ExamplesDll</AssemblyName>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
- <PlatformTarget>x64</PlatformTarget>
- <OutputPath>bin\x64\Debug\</OutputPath>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
- <PlatformTarget>x64</PlatformTarget>
- <OutputPath>bin\x64\Release\</OutputPath>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
- <DebugSymbols>true</DebugSymbols>
- <OutputPath>bin\x86\Debug\</OutputPath>
- <PlatformTarget>x86</PlatformTarget>
- <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
- <OutputPath>bin\x86\Release\</OutputPath>
- <PlatformTarget>x86</PlatformTarget>
- <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Compute\AverageSalaryJob.cs" />
- <Compile Include="Compute\AverageSalaryTask.cs" />
- <Compile Include="Compute\CharacterCountClosure.cs" />
- <Compile Include="Compute\CharacterCountReducer.cs" />
- <Compile Include="Datagrid\EmployeeStorePredicate.cs" />
- <Compile Include="Datagrid\ContinuousQueryFilter.cs" />
- <Compile Include="Datagrid\EmployeeStore.cs" />
- <Compile Include="Events\LocalListener.cs" />
- <Compile Include="Events\RemoteFilter.cs" />
- <Compile Include="Messaging\LocalListener.cs" />
- <Compile Include="Messaging\RemoteOrderedListener.cs" />
- <Compile Include="Messaging\RemoteUnorderedListener.cs" />
- <Compile Include="Messaging\Topic.cs" />
- <Compile Include="Portable\Account.cs" />
- <Compile Include="Portable\Address.cs" />
- <Compile Include="Portable\Employee.cs" />
- <Compile Include="Portable\EmployeeKey.cs" />
- <Compile Include="Portable\Organization.cs" />
- <Compile Include="Portable\OrganizationType.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Services\MapService.cs" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\Apache.Ignite.Core\Apache.Ignite.Core.csproj">
- <Project>{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}</Project>
- <Name>Apache.Ignite.Core</Name>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csprojrel
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csprojrel b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csprojrel
deleted file mode 100644
index fa6b71c..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csprojrel
+++ /dev/null
@@ -1,72 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{DFB08363-202E-412D-8812-349EF10A8702}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>Apache.Ignite.ExamplesDll</RootNamespace>
- <AssemblyName>Apache.Ignite.ExamplesDll</AssemblyName>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
- <PlatformTarget>x64</PlatformTarget>
- <OutputPath>bin\x64\Debug\</OutputPath>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
- <PlatformTarget>x64</PlatformTarget>
- <OutputPath>bin\x64\Release\</OutputPath>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
- <DebugSymbols>true</DebugSymbols>
- <OutputPath>bin\x86\Debug\</OutputPath>
- <PlatformTarget>x86</PlatformTarget>
- <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
- <OutputPath>bin\x86\Release\</OutputPath>
- <PlatformTarget>x86</PlatformTarget>
- <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="Apache.Ignite.Core">
- <HintPath>..\..\Apache.Ignite\bin\$(Platform)\$(Configuration)\Apache.Ignite.Core.dll</HintPath>
- </Reference>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Compute\AverageSalaryJob.cs" />
- <Compile Include="Compute\AverageSalaryTask.cs" />
- <Compile Include="Compute\CharacterCountClosure.cs" />
- <Compile Include="Compute\CharacterCountReducer.cs" />
- <Compile Include="Datagrid\EmployeeStorePredicate.cs" />
- <Compile Include="Datagrid\ContinuousQueryFilter.cs" />
- <Compile Include="Datagrid\EmployeeStore.cs" />
- <Compile Include="Events\LocalListener.cs" />
- <Compile Include="Events\RemoteFilter.cs" />
- <Compile Include="Messaging\LocalListener.cs" />
- <Compile Include="Messaging\RemoteOrderedListener.cs" />
- <Compile Include="Messaging\RemoteUnorderedListener.cs" />
- <Compile Include="Messaging\Topic.cs" />
- <Compile Include="Portable\Account.cs" />
- <Compile Include="Portable\Address.cs" />
- <Compile Include="Portable\Employee.cs" />
- <Compile Include="Portable\EmployeeKey.cs" />
- <Compile Include="Portable\Organization.cs" />
- <Compile Include="Portable\OrganizationType.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Services\MapService.cs" />
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs
deleted file mode 100644
index e4713d4..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using Apache.Ignite.Core.Compute;
-using Apache.Ignite.ExamplesDll.Portable;
-
-namespace Apache.Ignite.ExamplesDll.Compute
-{
- /// <summary>
- /// Average salary job.
- /// </summary>
- [Serializable]
- public class AverageSalaryJob : ComputeJobAdapter<Tuple<long, int>>
- {
- /// <summary> Employees. </summary>
- private readonly ICollection<Employee> _employees = new List<Employee>();
-
- /// <summary>
- /// Adds employee.
- /// </summary>
- /// <param name="employee">Employee.</param>
- public void Add(Employee employee)
- {
- _employees.Add(employee);
- }
-
- /// <summary>
- /// Execute the job.
- /// </summary>
- /// <returns>Job result: tuple with total salary in the first item and employees count in the second.</returns>
- override public Tuple<long, int> Execute()
- {
- long sum = 0;
- int count = 0;
-
- Console.WriteLine();
- Console.WriteLine(">>> Executing salary job for " + _employees.Count + " employee(s) ...");
- Console.WriteLine();
-
- foreach (Employee emp in _employees)
- {
- sum += emp.Salary;
- count++;
- }
-
- return new Tuple<long, int>(sum, count);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs
deleted file mode 100644
index f8acb01..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Apache.Ignite.Core.Compute;
-using Apache.Ignite.ExamplesDll.Portable;
-
-namespace Apache.Ignite.ExamplesDll.Compute
-{
- /// <summary>
- /// Average salary task.
- /// </summary>
- public class AverageSalaryTask : ComputeTaskSplitAdapter<ICollection<Employee>, Tuple<long, int>, long>
- {
- /// <summary>
- /// Split the task distributing employees between several jobs.
- /// </summary>
- /// <param name="gridSize">Number of available grid nodes.</param>
- /// <param name="arg">Task execution argument.</param>
- protected override ICollection<IComputeJob<Tuple<long, int>>> Split(int gridSize, ICollection<Employee> arg)
- {
- ICollection<Employee> employees = arg;
-
- var jobs = new List<IComputeJob<Tuple<long, int>>>(gridSize);
-
- int count = 0;
-
- foreach (Employee employee in employees)
- {
- int idx = count++ % gridSize;
-
- AverageSalaryJob job;
-
- if (idx >= jobs.Count)
- {
- job = new AverageSalaryJob();
-
- jobs.Add(job);
- }
- else
- job = (AverageSalaryJob) jobs[idx];
-
- job.Add(employee);
- }
-
- return jobs;
- }
-
- /// <summary>
- /// Calculate average salary after all jobs are finished.
- /// </summary>
- /// <param name="results">Job results.</param>
- /// <returns>Average salary.</returns>
- public override long Reduce(IList<IComputeJobResult<Tuple<long, int>>> results)
- {
- long sum = 0;
- int count = 0;
-
- foreach (var t in results.Select(result => result.Data()))
- {
- sum += t.Item1;
- count += t.Item2;
- }
-
- return sum / count;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/CharacterCountClosure.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/CharacterCountClosure.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/CharacterCountClosure.cs
deleted file mode 100644
index 2823221..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/CharacterCountClosure.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using Apache.Ignite.Core.Compute;
-
-namespace Apache.Ignite.ExamplesDll.Compute
-{
- /// <summary>
- /// Closure counting characters in a string.
- /// </summary>
- [Serializable]
- public class CharacterCountClosure : IComputeFunc<string, int>
- {
- /// <summary>
- /// Calculate character count of the given word.
- /// </summary>
- /// <param name="arg">Word.</param>
- /// <returns>Character count.</returns>
- public int Invoke(string arg)
- {
- int len = arg.Length;
-
- Console.WriteLine("Character count in word \"" + arg + "\": " + len);
-
- return len;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/CharacterCountReducer.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/CharacterCountReducer.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/CharacterCountReducer.cs
deleted file mode 100644
index 6825046..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Compute/CharacterCountReducer.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using Apache.Ignite.Core.Compute;
-
-namespace Apache.Ignite.ExamplesDll.Compute
-{
- /// <summary>
- /// Character count reducer which collects individual string lengths and aggregate them.
- /// </summary>
- public class CharacterCountReducer : IComputeReducer<int, int>
- {
- /// <summary> Total length. </summary>
- private int _length;
-
- /// <summary>
- /// Collect character counts of distinct words.
- /// </summary>
- /// <param name="res">Character count of a distinct word.</param>
- /// <returns><c>True</c> to continue collecting results until all closures are finished.</returns>
- public bool Collect(int res)
- {
- _length += res;
-
- return true;
- }
-
- /// <summary>
- /// Reduce all collected results.
- /// </summary>
- /// <returns>Total character count.</returns>
- public int Reduce()
- {
- return _length;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Datagrid/ContinuousQueryFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Datagrid/ContinuousQueryFilter.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Datagrid/ContinuousQueryFilter.cs
deleted file mode 100644
index 8c05f42..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Datagrid/ContinuousQueryFilter.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using Apache.Ignite.Core.Cache.Event;
-
-namespace Apache.Ignite.ExamplesDll.Datagrid
-{
- /// <summary>
- /// Filter for continuous query example.
- /// </summary>
- [Serializable]
- public class ContinuousQueryFilter : ICacheEntryEventFilter<int, string>
- {
- /// <summary> Threshold. </summary>
- private readonly int _threshold;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="threshold">Threshold.</param>
- public ContinuousQueryFilter(int threshold)
- {
- _threshold = threshold;
- }
-
- /// <summary>
- /// Evaluates cache entry event.
- /// </summary>
- /// <param name="evt">Event.</param>
- public bool Evaluate(ICacheEntryEvent<int, string> evt)
- {
- return evt.Key >= _threshold;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs
deleted file mode 100644
index 742b048..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
-using Apache.Ignite.Core.Cache;
-using Apache.Ignite.Core.Cache.Store;
-using Apache.Ignite.ExamplesDll.Portable;
-
-namespace Apache.Ignite.ExamplesDll.Datagrid
-{
- /// <summary>
- /// Example cache store implementation.
- /// </summary>
- public class EmployeeStore : CacheStoreAdapter
- {
- /// <summary>
- /// Dictionary representing the store.
- /// </summary>
- private readonly ConcurrentDictionary<object, object> _db = new ConcurrentDictionary<object, object>(
- new List<KeyValuePair<object, object>>
- {
- new KeyValuePair<object, object>(1, new Employee(
- "Allison Mathis",
- 25300,
- new Address("2702 Freedom Lane, San Francisco, CA", 94109),
- new List<string> {"Development"}
- )),
-
- new KeyValuePair<object, object>(2, new Employee(
- "Breana Robbin",
- 6500,
- new Address("3960 Sundown Lane, Austin, TX", 78130),
- new List<string> {"Sales"}
- ))
- });
-
- /// <summary>
- /// Loads all values from underlying persistent storage.
- /// This method gets called as a result of <see cref="ICache{TK,TV}.LoadCache"/> call.
- /// </summary>
- /// <param name="act">Action that loads a cache entry.</param>
- /// <param name="args">Optional arguments.</param>
- public override void LoadCache(Action<object, object> act, params object[] args)
- {
- // Iterate over whole underlying store and call act on each entry to load it into the cache.
- foreach (var entry in _db)
- act(entry.Key, entry.Value);
- }
-
- /// <summary>
- /// Loads multiple objects from the cache store.
- /// This method gets called as a result of <see cref="ICache{K,V}.GetAll"/> call.
- /// </summary>
- /// <param name="keys">Keys to load.</param>
- /// <returns>
- /// A map of key, values to be stored in the cache.
- /// </returns>
- public override IDictionary LoadAll(ICollection keys)
- {
- var result = new Dictionary<object, object>();
-
- foreach (var key in keys)
- result[key] = Load(key);
-
- return result;
- }
-
- /// <summary>
- /// Loads an object from the cache store.
- /// This method gets called as a result of <see cref="ICache{K,V}.Get"/> call.
- /// </summary>
- /// <param name="key">Key to load.</param>
- /// <returns>Loaded value</returns>
- public override object Load(object key)
- {
- object val;
-
- _db.TryGetValue(key, out val);
-
- return val;
- }
-
- /// <summary>
- /// Write key-value pair to store.
- /// </summary>
- /// <param name="key">Key to write.</param>
- /// <param name="val">Value to write.</param>
- public override void Write(object key, object val)
- {
- _db[key] = val;
- }
-
- /// <summary>
- /// Delete cache entry form store.
- /// </summary>
- /// <param name="key">Key to delete.</param>
- public override void Delete(object key)
- {
- object val;
-
- _db.TryRemove(key, out val);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs
deleted file mode 100644
index a585e5e..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using Apache.Ignite.Core.Cache;
-using Apache.Ignite.ExamplesDll.Portable;
-
-namespace Apache.Ignite.ExamplesDll.Datagrid
-{
- /// <summary>
- /// Example cache entry predicate.
- /// </summary>
- [Serializable]
- public class EmployeeStorePredicate : ICacheEntryFilter<int, Employee>
- {
- /// <summary>
- /// Returns a value indicating whether provided cache entry satisfies this predicate.
- /// </summary>
- /// <param name="entry">Cache entry.</param>
- /// <returns>Value indicating whether provided cache entry satisfies this predicate.</returns>
- public bool Invoke(ICacheEntry<int, Employee> entry)
- {
- return entry.Key == 1;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Events/LocalListener.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
deleted file mode 100644
index 8a28355..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Threading;
-using Apache.Ignite.Core.Events;
-
-namespace Apache.Ignite.ExamplesDll.Events
-{
- /// <summary>
- /// Local event listener.
- /// </summary>
- public class LocalListener : IEventFilter<IEvent>
- {
- /** Сount of received events. */
- private int _eventsReceived;
-
- /// <summary>
- /// Gets the count of received events.
- /// </summary>
- public int EventsReceived
- {
- get { return _eventsReceived; }
- }
-
- /// <summary>
- /// Determines whether specified event passes this filter.
- /// </summary>
- /// <param name="nodeId">Node identifier.</param>
- /// <param name="evt">Event.</param>
- /// <returns>Value indicating whether specified event passes this filter.</returns>
- public bool Invoke(Guid nodeId, IEvent evt)
- {
- Interlocked.Increment(ref _eventsReceived);
-
- Console.WriteLine("Local listener received an event [evt={0}]", evt.Name);
-
- return true;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs
deleted file mode 100644
index db3204a..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using Apache.Ignite.Core.Events;
-
-namespace Apache.Ignite.ExamplesDll.Events
-{
- /// <summary>
- /// Remote event filter.
- /// </summary>
- [Serializable]
- public class RemoteFilter : IEventFilter<IEvent>
- {
- /// <summary>
- /// Determines whether specified event passes this filter.
- /// </summary>
- /// <param name="nodeId">Node identifier.</param>
- /// <param name="evt">Event.</param>
- /// <returns>Value indicating whether specified event passes this filter.</returns>
- public bool Invoke(Guid nodeId, IEvent evt)
- {
- Console.WriteLine("Remote filter received event [evt={0}]", evt.Name);
-
- return evt is JobEvent;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs
deleted file mode 100644
index 7659bb4..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Threading;
-using Apache.Ignite.Core.Messaging;
-
-namespace Apache.Ignite.ExamplesDll.Messaging
-{
- /// <summary>
- /// Local message listener which signals countdown event on each received message.
- /// </summary>
- public class LocalListener : IMessageFilter<int>
- {
- /** Countdown event. */
- private readonly CountdownEvent _countdown;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="LocalListener"/> class.
- /// </summary>
- /// <param name="countdown">The countdown event.</param>
- public LocalListener(CountdownEvent countdown)
- {
- if (countdown == null)
- throw new ArgumentNullException("countdown");
-
- _countdown = countdown;
- }
-
- /// <summary>
- /// Receives a message and returns a value
- /// indicating whether provided message and node id satisfy this predicate.
- /// Returning false will unsubscribe this listener from future notifications.
- /// </summary>
- /// <param name="nodeId">Node identifier.</param>
- /// <param name="message">Message.</param>
- /// <returns>Value indicating whether provided message and node id satisfy this predicate.</returns>
- public bool Invoke(Guid nodeId, int message)
- {
- _countdown.Signal();
-
- return !_countdown.IsSet;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs
deleted file mode 100644
index 8ae5ac1..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using Apache.Ignite.Core;
-using Apache.Ignite.Core.Messaging;
-using Apache.Ignite.Core.Resource;
-
-namespace Apache.Ignite.ExamplesDll.Messaging
-{
- /// <summary>
- /// Listener for Ordered topic.
- /// </summary>
- [Serializable]
- public class RemoteOrderedListener : IMessageFilter<int>
- {
- /** Injected Ignite instance. */
- [InstanceResource]
-#pragma warning disable 649
- private readonly IIgnite _ignite;
-#pragma warning restore 649
-
- /// <summary>
- /// Receives a message and returns a value
- /// indicating whether provided message and node id satisfy this predicate.
- /// Returning false will unsubscribe this listener from future notifications.
- /// </summary>
- /// <param name="nodeId">Node identifier.</param>
- /// <param name="message">Message.</param>
- /// <returns>Value indicating whether provided message and node id satisfy this predicate.</returns>
- public bool Invoke(Guid nodeId, int message)
- {
- Console.WriteLine("Received ordered message [msg={0}, fromNodeId={1}]", message, nodeId);
-
- _ignite.GetCluster().ForNodeIds(nodeId).GetMessaging().Send(message, Topic.Ordered);
-
- return true;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs
deleted file mode 100644
index 166dbd6..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using Apache.Ignite.Core;
-using Apache.Ignite.Core.Messaging;
-using Apache.Ignite.Core.Resource;
-
-namespace Apache.Ignite.ExamplesDll.Messaging
-{
- /// <summary>
- /// Listener for Unordered topic.
- /// </summary>
- [Serializable]
- public class RemoteUnorderedListener : IMessageFilter<int>
- {
- /** Injected Ignite instance. */
- [InstanceResource]
-#pragma warning disable 649
- private readonly IIgnite _ignite;
-#pragma warning restore 649
-
- /// <summary>
- /// Receives a message and returns a value
- /// indicating whether provided message and node id satisfy this predicate.
- /// Returning false will unsubscribe this listener from future notifications.
- /// </summary>
- /// <param name="nodeId">Node identifier.</param>
- /// <param name="message">Message.</param>
- /// <returns>Value indicating whether provided message and node id satisfy this predicate.</returns>
- public bool Invoke(Guid nodeId, int message)
- {
- Console.WriteLine("Received unordered message [msg={0}, fromNodeId={1}]", message, nodeId);
-
- _ignite.GetCluster().ForNodeIds(nodeId).GetMessaging().Send(message, Topic.Unordered);
-
- return true;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/Topic.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/Topic.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/Topic.cs
deleted file mode 100644
index bda0bfe..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Messaging/Topic.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.ExamplesDll.Messaging
-{
- /// <summary>
- /// Message topics.
- /// </summary>
- public static class Topic
- {
- public const int Ordered = 1;
- public const int Unordered = 2;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Account.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Account.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Account.cs
deleted file mode 100644
index 8e247e3..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Account.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-
-namespace Apache.Ignite.ExamplesDll.Portable
-{
- /// <summary>
- /// Account object. Used in transaction example.
- /// </summary>
- [Serializable]
- public class Account
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="id">Account ID.</param>
- /// <param name="balance">Account balance.</param>
- public Account(int id, decimal balance)
- {
- Id = id;
- Balance = balance;
- }
-
- /// <summary>
- /// Account ID.
- /// </summary>
- public int Id { get; set; }
-
- /// <summary>
- /// Account balance.
- /// </summary>
- public decimal Balance { get; set; }
-
- /// <summary>
- /// Returns a string that represents the current object.
- /// </summary>
- /// <returns>
- /// A string that represents the current object.
- /// </returns>
- override public String ToString()
- {
- return string.Format("{0} [id={1}, balance={2}]", typeof(Account).Name, Id, Balance);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Address.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Address.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Address.cs
deleted file mode 100644
index ca069cb..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Address.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using Apache.Ignite.Core.Portable;
-
-namespace Apache.Ignite.ExamplesDll.Portable
-{
- /// <summary>
- /// Address.
- /// </summary>
- [Serializable]
- public class Address : IPortableMarshalAware
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="street">Street.</param>
- /// <param name="zip">ZIP code.</param>
- public Address(string street, int zip)
- {
- Street = street;
- Zip = zip;
- }
-
- /// <summary>
- /// Street.
- /// </summary>
- public string Street { get; set; }
-
- /// <summary>
- /// ZIP code.
- /// </summary>
- public int Zip { get; set; }
-
- /// <summary>
- /// Writes this object to the given writer.
- /// </summary>
- /// <param name="writer">Writer.</param>
- public void WritePortable(IPortableWriter writer)
- {
- writer.WriteString("street", Street);
- writer.WriteInt("zip", Zip);
- }
-
- /// <summary>
- /// Reads this object from the given reader.
- /// </summary>
- /// <param name="reader">Reader.</param>
- public void ReadPortable(IPortableReader reader)
- {
- Street = reader.ReadString("street");
- Zip = reader.ReadInt("zip");
- }
-
- /// <summary>
- /// Returns a string that represents the current object.
- /// </summary>
- /// <returns>
- /// A string that represents the current object.
- /// </returns>
- override public string ToString()
- {
- return string.Format("{0} [street={1}, zip={2}]", typeof(Address).Name, Street, Zip);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Employee.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Employee.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Employee.cs
deleted file mode 100644
index 7f4388d..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Employee.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace Apache.Ignite.ExamplesDll.Portable
-{
- /// <summary>
- /// Employee.
- /// </summary>
- [Serializable]
- public class Employee
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="name">Name.</param>
- /// <param name="salary">Salary.</param>
- /// <param name="address">Address.</param>
- /// <param name="departments">Departments.</param>
- public Employee(string name, long salary, Address address, ICollection<string> departments)
- {
- Name = name;
- Salary = salary;
- Address = address;
- Departments = departments;
- }
-
- /// <summary>
- /// Name.
- /// </summary>
- public string Name { get; set; }
-
- /// <summary>
- /// Salary.
- /// </summary>
- public long Salary { get; set; }
-
- /// <summary>
- /// Address.
- /// </summary>
- public Address Address { get; set; }
-
- /// <summary>
- /// Departments.
- /// </summary>
- public ICollection<string> Departments { get; set; }
-
- /// <summary>
- /// Returns a string that represents the current object.
- /// </summary>
- /// <returns>
- /// A string that represents the current object.
- /// </returns>
- override public string ToString()
- {
- return string.Format("{0} [name={1}, salary={2}, address={3}, departments={4}]", typeof(Employee).Name,
- Name, Salary, Address, CollectionToString(Departments));
- }
-
- /// <summary>
- /// Get string representation of collection.
- /// </summary>
- /// <returns></returns>
- private static string CollectionToString<T>(ICollection<T> col)
- {
- if (col == null)
- return "null";
-
- var elements = col.Any()
- ? col.Select(x => x.ToString()).Aggregate((x, y) => x + ", " + y)
- : string.Empty;
-
- return string.Format("[{0}]", elements);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs
deleted file mode 100644
index 2267154..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-
-namespace Apache.Ignite.ExamplesDll.Portable
-{
- /// <summary>
- /// Employee key. Used in query example to co-locate employees with their organizations.
- /// </summary>
- [Serializable]
- public class EmployeeKey
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="id">ID.</param>
- /// <param name="orgId">Organization ID.</param>
- public EmployeeKey(int id, int orgId)
- {
- Id = id;
- OrganizationId = orgId;
- }
-
- /// <summary>
- /// ID.
- /// </summary>
- public int Id { get; private set; }
-
- /// <summary>
- /// Organization ID.
- /// </summary>
- public int OrganizationId { get; private set; }
-
- /// <summary>
- /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
- /// </summary>
- /// <returns>
- /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
- /// </returns>
- /// <param name="obj">The object to compare with the current object. </param><filterpriority>2</filterpriority>
- public override bool Equals(object obj)
- {
- EmployeeKey other = obj as EmployeeKey;
-
- return other != null && Id == other.Id && OrganizationId == other.OrganizationId;
- }
-
- /// <summary>
- /// Serves as a hash function for a particular type.
- /// </summary>
- /// <returns>
- /// A hash code for the current <see cref="T:System.Object"/>.
- /// </returns>
- /// <filterpriority>2</filterpriority>
- public override int GetHashCode()
- {
- return 31 * Id + OrganizationId;
- }
-
- /// <summary>
- /// Returns a string that represents the current object.
- /// </summary>
- /// <returns>
- /// A string that represents the current object.
- /// </returns>
- public override string ToString()
- {
- return string.Format("{0} [id={1}, organizationId={2}]", typeof (EmployeeKey).Name, Id, OrganizationId);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Organization.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Organization.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Organization.cs
deleted file mode 100644
index e23c3c1..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/Organization.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-
-namespace Apache.Ignite.ExamplesDll.Portable
-{
- /// <summary>
- /// Organization.
- /// </summary>
- [Serializable]
- public class Organization
- {
- /// <summary>
- /// Default constructor.
- /// </summary>
- public Organization()
- {
- // No-op.
- }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="name">Name.</param>
- /// <param name="address">Address.</param>
- /// <param name="type">Type.</param>
- /// <param name="lastUpdated">Last update time.</param>
- public Organization(string name, Address address, OrganizationType type, DateTime lastUpdated)
- {
- Name = name;
- Address = address;
- Type = type;
- LastUpdated = lastUpdated;
- }
-
- /// <summary>
- /// Name.
- /// </summary>
- public string Name { get; set; }
-
- /// <summary>
- /// Address.
- /// </summary>
- public Address Address { get; set; }
-
- /// <summary>
- /// Type.
- /// </summary>
- public OrganizationType Type { get; set; }
-
- /// <summary>
- /// Last update time.
- /// </summary>
- public DateTime LastUpdated { get; set; }
-
- /// <summary>
- /// Returns a string that represents the current object.
- /// </summary>
- /// <returns>
- /// A string that represents the current object.
- /// </returns>
- /// <filterpriority>2</filterpriority>
- public override string ToString()
- {
- return string.Format("{0} [name={1}, address={2}, type={3}, lastUpdated={4}]", typeof (Organization).Name,
- Name, Address, Type, LastUpdated);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs
deleted file mode 100644
index 198edb1..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-
-namespace Apache.Ignite.ExamplesDll.Portable
-{
- /// <summary>
- /// Organization type.
- /// </summary>
- [Serializable]
- public enum OrganizationType
- {
- /// <summary>
- /// Non-profit organization.
- /// </summary>
- NonProfit,
-
- /// <summary>
- /// Private organization.
- /// </summary>
- Private,
-
- /// <summary>
- /// Government organization.
- /// </summary>
- Government
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs
deleted file mode 100644
index f149d64..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-[assembly: AssemblyTitle("Apache Ignite Examples Dll")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Apache Software Foundation")]
-[assembly: AssemblyProduct("Apache Ignite")]
-[assembly: AssemblyCopyright("Copyright © 2015")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-[assembly: ComVisible(false)]
-
-[assembly: Guid("ce65ec7c-d3cf-41ad-8f45-f90d5af68d77")]
-
-[assembly: AssemblyVersion("1.5.0")]
-[assembly: AssemblyFileVersion("1.5.0")]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Services/MapService.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Services/MapService.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Services/MapService.cs
deleted file mode 100644
index d577ff7..0000000
--- a/modules/platform/dotnet/Examples2/Apache.Ignite.ExamplesDll/Services/MapService.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using Apache.Ignite.Core;
-using Apache.Ignite.Core.Cache;
-using Apache.Ignite.Core.Resource;
-using Apache.Ignite.Core.Services;
-
-namespace Apache.Ignite.ExamplesDll.Services
-{
- /// <summary>
- /// Service implementation.
- /// </summary>
- [Serializable]
- public class MapService<TK, TV> : IService
- {
- /** Injected Ignite instance. */
-#pragma warning disable 649
- [InstanceResource] private readonly IIgnite _ignite;
-#pragma warning restore 649
-
- /** Cache. */
- private ICache<TK, TV> _cache;
-
- /// <summary>
- /// Initializes this instance before execution.
- /// </summary>
- /// <param name="context">Service execution context.</param>
- public void Init(IServiceContext context)
- {
- // Create a new cache for every service deployment.
- // Note that we use service name as cache name, which allows
- // for each service deployment to use its own isolated cache.
- _cache = _ignite.GetOrCreateCache<TK, TV>("MapService_" + context.Name);
-
- Console.WriteLine("Service initialized: " + context.Name);
- }
-
- /// <summary>
- /// Starts execution of this service. This method is automatically invoked whenever an instance of the service
- /// is deployed on an Ignite node. Note that service is considered deployed even after it exits the Execute
- /// method and can be cancelled (or undeployed) only by calling any of the Cancel methods on
- /// <see cref="IServices"/> API. Also note that service is not required to exit from Execute method until
- /// Cancel method was called.
- /// </summary>
- /// <param name="context">Service execution context.</param>
- public void Execute(IServiceContext context)
- {
- Console.WriteLine("Service started: " + context.Name);
- }
-
- /// <summary>
- /// Cancels this instance.
- /// <para/>
- /// Note that Ignite cannot guarantee that the service exits from <see cref="IService.Execute"/>
- /// method whenever <see cref="IService.Cancel"/> is called. It is up to the user to
- /// make sure that the service code properly reacts to cancellations.
- /// </summary>
- /// <param name="context">Service execution context.</param>
- public void Cancel(IServiceContext context)
- {
- Console.WriteLine("Service cancelled: " + context.Name);
- }
-
- /// <summary>
- /// Puts an entry to the map.
- /// </summary>
- /// <param name="key">The key.</param>
- /// <param name="value">The value.</param>
- public void Put(TK key, TV value)
- {
- _cache.Put(key, value);
- }
-
- /// <summary>
- /// Gets an entry from the map.
- /// </summary>
- /// <param name="key">The key.</param>
- /// <returns>Entry value.</returns>
- public TV Get(TK key)
- {
- return _cache.Get(key);
- }
-
- /// <summary>
- /// Clears the map.
- /// </summary>
- public void Clear()
- {
- _cache.Clear();
- }
-
- /// <summary>
- /// Gets the size of the map.
- /// </summary>
- /// <value>
- /// The size.
- /// </value>
- public int Size
- {
- get { return _cache.GetSize(); }
- }
- }
-}
[18/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
deleted file mode 100644
index e7c5ac9..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Compute
-{
- using System;
- using System.Collections.Generic;
- using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Compute;
- using Apache.Ignite.Core.Portable;
- using Apache.Ignite.Core.Resource;
- using NUnit.Framework;
-
- /// <summary>
- /// Tests task result.
- /// </summary>
- public class TaskResultTest : AbstractTaskTest
- {
- /** Grid name. */
- private static volatile string _gridName;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- public TaskResultTest() : base(false) { }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="forked">Fork flag.</param>
- protected TaskResultTest(bool forked) : base(forked) { }
-
- /// <summary>
- /// Test for task result.
- /// </summary>
- [Test]
- public void TestTaskResultInt()
- {
- TestTask<int> task = new TestTask<int>();
-
- int res = Grid1.GetCompute().Execute(task, new Tuple<bool, int>(true, 10));
-
- Assert.AreEqual(10, res);
-
- res = Grid1.GetCompute().Execute(task, new Tuple<bool, int>(false, 11));
-
- Assert.AreEqual(11, res);
- }
-
- /// <summary>
- /// Test for task result.
- /// </summary>
- [Test]
- public void TestTaskResultLong()
- {
- TestTask<long> task = new TestTask<long>();
-
- long res = Grid1.GetCompute().Execute(task, new Tuple<bool, long>(true, 10000000000));
-
- Assert.AreEqual(10000000000, res);
-
- res = Grid1.GetCompute().Execute(task, new Tuple<bool, long>(false, 10000000001));
-
- Assert.AreEqual(10000000001, res);
- }
-
- /// <summary>
- /// Test for task result.
- /// </summary>
- [Test]
- public void TestTaskResultFloat()
- {
- TestTask<float> task = new TestTask<float>();
-
- float res = Grid1.GetCompute().Execute(task, new Tuple<bool, float>(true, 1.1f));
-
- Assert.AreEqual(1.1f, res);
-
- res = Grid1.GetCompute().Execute(task, new Tuple<bool, float>(false, -1.1f));
-
- Assert.AreEqual(-1.1f, res);
- }
-
- /// <summary>
- /// Test for task result.
- /// </summary>
- [Test]
- public void TestTaskResultPortable()
- {
- TestTask<PortableResult> task = new TestTask<PortableResult>();
-
- PortableResult val = new PortableResult(100);
-
- PortableResult res = Grid1.GetCompute().Execute(task, new Tuple<bool, PortableResult>(true, val));
-
- Assert.AreEqual(val.Val, res.Val);
-
- val.Val = 101;
-
- res = Grid1.GetCompute().Execute(task, new Tuple<bool, PortableResult>(false, val));
-
- Assert.AreEqual(val.Val, res.Val);
- }
-
- /// <summary>
- /// Test for task result.
- /// </summary>
- [Test]
- public void TestTaskResultSerializable()
- {
- TestTask<SerializableResult> task = new TestTask<SerializableResult>();
-
- SerializableResult val = new SerializableResult(100);
-
- SerializableResult res = Grid1.GetCompute().Execute(task, new Tuple<bool, SerializableResult>(true, val));
-
- Assert.AreEqual(val.Val, res.Val);
-
- val.Val = 101;
-
- res = Grid1.GetCompute().Execute(task, new Tuple<bool, SerializableResult>(false, val));
-
- Assert.AreEqual(val.Val, res.Val);
- }
-
- /// <summary>
- /// Test for task result.
- /// </summary>
- [Test]
- public void TestTaskResultLarge()
- {
- TestTask<byte[]> task = new TestTask<byte[]>();
-
- byte[] res = Grid1.GetCompute().Execute(task,
- new Tuple<bool, byte[]>(true, new byte[100 * 1024]));
-
- Assert.AreEqual(100 * 1024, res.Length);
-
- res = Grid1.GetCompute().Execute(task, new Tuple<bool, byte[]>(false, new byte[101 * 1024]));
-
- Assert.AreEqual(101 * 1024, res.Length);
- }
-
- /** <inheritDoc /> */
- override protected void PortableTypeConfigurations(ICollection<PortableTypeConfiguration> portTypeCfgs)
- {
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableResult)));
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(TestPortableJob)));
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableOutFunc)));
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableFunc)));
- }
-
- [Test]
- public void TestOutFuncResultPrimitive1()
- {
- ICollection<int> res = Grid1.GetCompute().Broadcast(new PortableOutFunc());
-
- Assert.AreEqual(3, res.Count);
-
- foreach (int r in res)
- Assert.AreEqual(10, r);
- }
-
- [Test]
- public void TestOutFuncResultPrimitive2()
- {
- ICollection<int> res = Grid1.GetCompute().Broadcast(new SerializableOutFunc());
-
- Assert.AreEqual(3, res.Count);
-
- foreach (int r in res)
- Assert.AreEqual(10, r);
- }
-
- [Test]
- public void TestFuncResultPrimitive1()
- {
- ICollection<int> res = Grid1.GetCompute().Broadcast(new PortableFunc(), 10);
-
- Assert.AreEqual(3, res.Count);
-
- foreach (int r in res)
- Assert.AreEqual(11, r);
- }
-
- [Test]
- public void TestFuncResultPrimitive2()
- {
- ICollection<int> res = Grid1.GetCompute().Broadcast(new SerializableFunc(), 10);
-
- Assert.AreEqual(3, res.Count);
-
- foreach (int r in res)
- Assert.AreEqual(11, r);
- }
-
- interface IUserInterface<in T, out TR>
- {
- TR Invoke(T arg);
- }
-
- /// <summary>
- /// Test function.
- /// </summary>
- public class PortableFunc : IComputeFunc<int, int>, IUserInterface<int, int>
- {
- int IComputeFunc<int, int>.Invoke(int arg)
- {
- return arg + 1;
- }
-
- int IUserInterface<int, int>.Invoke(int arg)
- {
- // Same signature as IComputeFunc<int, int>, but from different interface
- throw new Exception("Invalid method");
- }
-
- public int Invoke(int arg)
- {
- // Same signature as IComputeFunc<int, int>,
- // but due to explicit interface implementation this is a wrong method
- throw new Exception("Invalid method");
- }
- }
-
- /// <summary>
- /// Test function.
- /// </summary>
- [Serializable]
- public class SerializableFunc : IComputeFunc<int, int>
- {
- public int Invoke(int arg)
- {
- return arg + 1;
- }
- }
-
- /// <summary>
- /// Test function.
- /// </summary>
- public class PortableOutFunc : IComputeFunc<int>
- {
- public int Invoke()
- {
- return 10;
- }
- }
-
- /// <summary>
- /// Test function.
- /// </summary>
- [Serializable]
- public class SerializableOutFunc : IComputeFunc<int>
- {
- public int Invoke()
- {
- return 10;
- }
- }
-
- /// <summary>
- /// Test task.
- /// </summary>
- public class TestTask<T> : ComputeTaskAdapter<Tuple<bool, T>, T, T>
- {
- /** <inheritDoc /> */
- override public IDictionary<IComputeJob<T>, IClusterNode> Map(IList<IClusterNode> subgrid, Tuple<bool, T> arg)
- {
- _gridName = null;
-
- Assert.AreEqual(3, subgrid.Count);
-
- bool local = arg.Item1;
- T res = arg.Item2;
-
- var jobs = new Dictionary<IComputeJob<T>, IClusterNode>();
-
- IComputeJob<T> job;
-
- if (res is PortableResult)
- {
- TestPortableJob job0 = new TestPortableJob();
-
- job0.SetArguments(res);
-
- job = (IComputeJob<T>) job0;
- }
- else
- {
- TestJob<T> job0 = new TestJob<T>();
-
- job0.SetArguments(res);
-
- job = job0;
- }
-
- foreach (IClusterNode node in subgrid)
- {
- bool add = local ? node.IsLocal : !node.IsLocal;
-
- if (add)
- {
- jobs.Add(job, node);
-
- break;
- }
- }
-
- Assert.AreEqual(1, jobs.Count);
-
- return jobs;
- }
-
- /** <inheritDoc /> */
- override public T Reduce(IList<IComputeJobResult<T>> results)
- {
- Assert.AreEqual(1, results.Count);
-
- var res = results[0];
-
- Assert.IsNull(res.Exception());
-
- Assert.IsFalse(res.Cancelled);
-
- Assert.IsNotNull(_gridName);
-
- Assert.AreEqual(GridId(_gridName), res.NodeId);
-
- var job = res.Job();
-
- Assert.IsNotNull(job);
-
- return res.Data();
- }
- }
-
- private static Guid GridId(string gridName)
- {
- if (gridName.Equals(Grid1Name))
- return Ignition.GetIgnite(Grid1Name).GetCluster().GetLocalNode().Id;
- if (gridName.Equals(Grid2Name))
- return Ignition.GetIgnite(Grid2Name).GetCluster().GetLocalNode().Id;
- if (gridName.Equals(Grid3Name))
- return Ignition.GetIgnite(Grid3Name).GetCluster().GetLocalNode().Id;
-
- Assert.Fail("Failed to find grid " + gridName);
-
- return new Guid();
- }
-
- /// <summary>
- ///
- /// </summary>
- class PortableResult
- {
- /** */
- public int Val;
-
- public PortableResult(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- [Serializable]
- class SerializableResult
- {
- /** */
- public int Val;
-
- public SerializableResult(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- [Serializable]
- class TestJob<T> : ComputeJobAdapter<T>
- {
- [InstanceResource]
- private IIgnite _grid = null;
-
- /** <inheritDoc /> */
- override public T Execute()
- {
- Assert.IsNotNull(_grid);
-
- _gridName = _grid.Name;
-
- T res = Argument<T>(0);
-
- return res;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- class TestPortableJob : ComputeJobAdapter<PortableResult>
- {
- [InstanceResource]
- private IIgnite _grid = null;
-
- /** <inheritDoc /> */
- override public PortableResult Execute()
- {
- Assert.IsNotNull(_grid);
-
- _gridName = _grid.Name;
-
- PortableResult res = Argument<PortableResult>(0);
-
- return res;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test
deleted file mode 100644
index 2bda365..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
- 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.
--->
-
-<configuration>
- <startup>
- <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
- </startup>
-
- <runtime>
- <gcServer enabled="true" />
- </runtime>
-
- <appSettings>
- <add key="Ignite.SpringConfigUrl" value="config\compute\compute-standalone.xml" />
- <add key="Ignite.Assembly.1" value="test-1.dll" />
- <add key="Ignite.Assembly.2" value="test-2.dll" />
- <add key="Ignite.JvmOption.1" value="-DOPT1" />
- <add key="Ignite.JvmOption.2" value="-DOPT2" />
- <add key="Ignite.JvmOption.3" value="-Xms601m" />
- <add key="Ignite.JvmOption.4" value="-Xmx702m" />
- <add key="Ignite.JvmInitialMemoryMB" value="601" />
- <add key="Ignite.JvmMaxMemoryMB" value="702" />
- </appSettings>
-
-</configuration>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Cache/Store/cache-store-session.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Cache/Store/cache-store-session.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Cache/Store/cache-store-session.xml
deleted file mode 100644
index 00837a9..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Cache/Store/cache-store-session.xml
+++ /dev/null
@@ -1,80 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
- <bean id="storeFactory" class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
- <property name="assemblyName" value="Apache.Ignite.Core.Tests"/>
- <property name="className" value="Apache.Ignite.Core.Tests.Cache.Store.CacheStoreSessionTest+Store"/>
- </bean>
-
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="includeEventTypes">
- <util:constant static-field="org.apache.ignite.events.EventType.EVTS_CACHE"/>
- </property>
-
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="cache1"/>
- <property name="cacheMode" value="LOCAL"/>
- <property name="atomicityMode" value="TRANSACTIONAL"/>
- <property name="writeThrough" value="true"/>
- <property name="readThrough" value="true"/>
-
- <property name="cacheStoreFactory" ref="storeFactory" />
- </bean>
-
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="cache2"/>
- <property name="cacheMode" value="LOCAL"/>
- <property name="atomicityMode" value="TRANSACTIONAL"/>
- <property name="writeThrough" value="true"/>
- <property name="readThrough" value="true"/>
-
- <property name="cacheStoreFactory" ref="storeFactory" />
- </bean>
- </list>
- </property>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47501</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
deleted file mode 100644
index 183676b..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
+++ /dev/null
@@ -1,90 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="gridName" value="grid1"/>
-
- <property name="metricsUpdateFrequency" value="1000"/>
- <property name="metricsLogFrequency" value="0"/>
-
- <property name="userAttributes">
- <map>
- <entry key="my_attr" value="value1"/>
- </map>
- </property>
-
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="startSize" value="10"/>
- </bean>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="cache1"/>
- <property name="startSize" value="10"/>
- </bean>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="cache2"/>
- <property name="startSize" value="10"/>
- </bean>
- </list>
- </property>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47502</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
-
- <!-- Portable marshaller configuration -->
- <property name="marshaller">
- <bean class="org.apache.ignite.marshaller.portable.PortableMarshaller">
- <property name="typeConfigurations">
- <list>
- <bean class="org.apache.ignite.portable.PortableTypeConfiguration">
- <property name="className" value="org.apache.ignite.platform.PlatformComputePortable"/>
- </bean>
- <bean class="org.apache.ignite.portable.PortableTypeConfiguration">
- <property name="className" value="org.apache.ignite.platform.PlatformComputeJavaPortable"/>
- </bean>
- <bean class="org.apache.ignite.portable.PortableTypeConfiguration">
- <property name="className" value="org.apache.ignite.platform.PlatformComputeEnum"/>
- </bean>
- </list>
- </property>
- </bean>
- </property>
-
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid2.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid2.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid2.xml
deleted file mode 100644
index 434f468..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid2.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="gridName" value="grid2"/>
-
- <property name="metricsUpdateFrequency" value="1000"/>
- <property name="metricsLogFrequency" value="0"/>
-
- <property name="userAttributes">
- <map>
- <entry key="my_attr" value="value2"/>
- </map>
- </property>
-
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="cache1"/>
- <property name="startSize" value="10"/>
- </bean>
- </list>
- </property>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47502</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid3.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid3.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid3.xml
deleted file mode 100644
index 31ccdf0..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid3.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="clientMode" value="true"/>
-
- <property name="gridName" value="grid3"/>
-
- <property name="metricsUpdateFrequency" value="1000"/>
- <property name="metricsLogFrequency" value="0"/>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="forceServerMode" value="true"/>
-
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47502</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml
deleted file mode 100644
index bd34958..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="metricsLogFrequency" value="0"/>
-
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration" />
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="cache1"/>
- </bean>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="cache2"/>
- </bean>
- </list>
- </property>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <value>127.0.0.1:47500..47502</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
-
- <property name="platformConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
- <property name="portableConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
- <property name="types">
- <list>
- <value>Apache.Ignite.Core.Tests.ExecutableTest+RemoteConfiguration</value>
- <value>Apache.Ignite.Core.Tests.ExecutableTest+RemoteConfigurationClosure</value>
- <value>Apache.Ignite.Core.Tests.Compute.TaskAdapterTest+PortableJob</value>
- <value>Apache.Ignite.Core.Tests.Compute.PortableClosureTaskTest+PortableOutFunc</value>
- <value>Apache.Ignite.Core.Tests.Compute.PortableClosureTaskTest+PortableFunc</value>
- <value>Apache.Ignite.Core.Tests.Compute.PortableClosureTaskTest+PortableResult</value>
- <value>Apache.Ignite.Core.Tests.Compute.PortableClosureTaskTest+PortableException</value>
- </list>
- </property>
- <property name="typesConfiguration">
- <list>
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableTypeConfiguration">
- <property name="typeName" value="org.apache.ignite.platform.PlatformComputePortable"/>
- </bean>
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableTypeConfiguration">
- <property name="typeName" value="org.apache.ignite.platform.PlatformComputeJavaPortable"/>
- </bean>
- </list>
- </property>
- </bean>
- </property>
- </bean>
-
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Dynamic/dynamic-client.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Dynamic/dynamic-client.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Dynamic/dynamic-client.xml
deleted file mode 100644
index 8f8893f..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Dynamic/dynamic-client.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="clientMode" value="true"/>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="forceServerMode" value="true"/>
-
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47502</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Dynamic/dynamic-data-no-cfg.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Dynamic/dynamic-data-no-cfg.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Dynamic/dynamic-data-no-cfg.xml
deleted file mode 100644
index 83c6642..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Dynamic/dynamic-data-no-cfg.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47502</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Dynamic/dynamic-data.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Dynamic/dynamic-data.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Dynamic/dynamic-data.xml
deleted file mode 100644
index dbbae90..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Dynamic/dynamic-data.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="p"/>
- <property name="cacheMode" value="PARTITIONED"/>
- <property name="atomicityMode" value="TRANSACTIONAL"/>
- <property name="startSize" value="10"/>
- </bean>
-
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="pa"/>
- <property name="cacheMode" value="PARTITIONED"/>
- <property name="atomicityMode" value="ATOMIC"/>
- <property name="startSize" value="10"/>
- </bean>
- </list>
- </property>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47502</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Lifecycle/lifecycle-beans.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Lifecycle/lifecycle-beans.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Lifecycle/lifecycle-beans.xml
deleted file mode 100644
index da36032..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Lifecycle/lifecycle-beans.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="gridName" value="grid"/>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <value>127.0.0.1:47500..47502</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
-
- <property name="lifecycleBeans">
- <list>
- <bean class="org.apache.ignite.platform.lifecycle.PlatformJavaLifecycleBean" />
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetLifecycleBean">
- <property name="className" value="Apache.Ignite.Core.Tests.Bean" />
- </bean>
- <bean class="org.apache.ignite.platform.lifecycle.PlatformJavaLifecycleBean" />
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetLifecycleBean">
- <property name="className" value="Apache.Ignite.Core.Tests.Bean" />
- <property name="properties">
- <map>
- <entry key="Property1">
- <value type="java.lang.Integer">1</value>
- </entry>
- <entry key="Property2" value="1"/>
- </map>
- </property>
- </bean>
- <bean class="org.apache.ignite.platform.lifecycle.PlatformJavaLifecycleBean" />
- </list>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Lifecycle/lifecycle-no-beans.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Lifecycle/lifecycle-no-beans.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Lifecycle/lifecycle-no-beans.xml
deleted file mode 100644
index 4063e6e..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Lifecycle/lifecycle-no-beans.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="gridName" value="grid"/>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <value>127.0.0.1:47500..47502</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml
deleted file mode 100644
index 84f9e5a..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="platformConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
- <property name="portableConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
- <property name="types">
- <list>
- <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64]</value>
- <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Type]</value>
- <value>Apache.Ignite.Core.Tests.TestGenericPortable[Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64]]</value>
- <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Collections.Generic.List[System.Tuple[System.Int64,System.String]]]</value>
- <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64,System.String]</value>
- <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64,Apache.Ignite.Core.Tests.TestGenericPortable[System.String]]</value>
- <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64,System.String,System.Type]</value>
- <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64,System.String,Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64,System.String,System.Type]]</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
-
- <property name="includeEventTypes">
- <util:constant static-field="org.apache.ignite.events.EventType.EVTS_CACHE"/>
- </property>
-
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration" />
- </list>
- </property>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47501</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml
deleted file mode 100644
index 7f9ce40..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml
+++ /dev/null
@@ -1,171 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="transactional_no_backup"/>
- <property name="cacheMode" value="PARTITIONED"/>
- <property name="atomicityMode" value="TRANSACTIONAL"/>
- <property name="writeSynchronizationMode" value="FULL_SYNC"/>
- <property name="backups" value="0"/>
- <property name="startSize" value="10"/>
- <property name="typeMetadata">
- <list>
- <bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="valueType" value="PortableEntry"/>
- <property name="ascendingFields">
- <map>
- <entry key="val" value="java.lang.Integer"/>
- </map>
- </property>
- <property name="queryFields">
- <map>
- <entry key="val" value="java.lang.Integer"/>
- </map>
- </property>
- <property name="textFields">
- <list>
- <value>val</value>
- </list>
- </property>
- </bean>
- </list>
- </property>
- </bean>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="transactional_backup"/>
- <property name="cacheMode" value="PARTITIONED"/>
- <property name="atomicityMode" value="TRANSACTIONAL"/>
- <property name="writeSynchronizationMode" value="FULL_SYNC"/>
- <property name="backups" value="1"/>
- <property name="startSize" value="10"/>
- <property name="typeMetadata">
- <list>
- <bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="valueType" value="PortableEntry"/>
- <property name="ascendingFields">
- <map>
- <entry key="val" value="java.lang.Integer"/>
- </map>
- </property>
- <property name="queryFields">
- <map>
- <entry key="val" value="java.lang.Integer"/>
- </map>
- </property>
- <property name="textFields">
- <list>
- <value>val</value>
- </list>
- </property>
- </bean>
- </list>
- </property>
- </bean>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="atomic_no_backup"/>
- <property name="cacheMode" value="PARTITIONED"/>
- <property name="atomicityMode" value="ATOMIC"/>
- <property name="writeSynchronizationMode" value="FULL_SYNC"/>
- <property name="backups" value="0"/>
- <property name="startSize" value="10"/>
- <property name="typeMetadata">
- <list>
- <bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="valueType" value="PortableEntry"/>
- <property name="ascendingFields">
- <map>
- <entry key="val" value="java.lang.Integer"/>
- </map>
- </property>
- <property name="queryFields">
- <map>
- <entry key="val" value="java.lang.Integer"/>
- </map>
- </property>
- <property name="textFields">
- <list>
- <value>val</value>
- </list>
- </property>
- </bean>
- </list>
- </property>
- </bean>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="atomic_backup"/>
- <property name="cacheMode" value="PARTITIONED"/>
- <property name="atomicityMode" value="ATOMIC"/>
- <property name="writeSynchronizationMode" value="FULL_SYNC"/>
- <property name="backups" value="1"/>
- <property name="startSize" value="10"/>
- <property name="typeMetadata">
- <list>
- <bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="valueType" value="PortableEntry"/>
- <property name="ascendingFields">
- <map>
- <entry key="val" value="java.lang.Integer"/>
- </map>
- </property>
- <property name="queryFields">
- <map>
- <entry key="val" value="java.lang.Integer"/>
- </map>
- </property>
- <property name="textFields">
- <list>
- <value>val</value>
- </list>
- </property>
- </bean>
- </list>
- </property>
- </bean>
- </list>
- </property>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47501</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/cache-query.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/cache-query.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/cache-query.xml
deleted file mode 100644
index 787a921..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/cache-query.xml
+++ /dev/null
@@ -1,100 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="platformConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
- <property name="portableConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
- <property name="types">
- <list>
- <value>Apache.Ignite.Core.Tests.Cache.Query.QueryPerson</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
-
- <property name="includeEventTypes">
- <util:constant static-field="org.apache.ignite.events.EventType.EVTS_CACHE"/>
- </property>
-
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="cache"/>
- <property name="cacheMode" value="PARTITIONED"/>
- <property name="atomicityMode" value="TRANSACTIONAL"/>
- <property name="writeSynchronizationMode" value="FULL_SYNC"/>
-
- <property name="typeMetadata">
- <list>
- <bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="valueType" value="QueryPerson"/>
- <property name="ascendingFields">
- <map>
- <entry key="age" value="java.lang.Integer"/>
- </map>
- </property>
- <property name="queryFields">
- <map>
- <entry key="name" value="java.lang.String"/>
- <entry key="age" value="java.lang.Integer"/>
- </map>
- </property>
- <property name="textFields">
- <list>
- <value>name</value>
- </list>
- </property>
- </bean>
- </list>
- </property>
- </bean>
- </list>
- </property>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47501</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-default.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-default.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-default.xml
deleted file mode 100644
index 753fad1..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-default.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47502</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-invalid.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-invalid.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-invalid.xml
deleted file mode 100644
index 188781d..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-invalid.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="marshaller">
- <bean class="org.apache.ignite.marshaller.optimized.OptimizedMarshaller" />
- </property>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47502</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-portable.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-portable.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-portable.xml
deleted file mode 100644
index 753fad1..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-portable.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47502</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-affinity.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-affinity.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-affinity.xml
deleted file mode 100644
index f08018d..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-affinity.xml
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
-
- <property name="connectorConfiguration"><null/></property>
-
- <property name="platformConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
- <property name="portableConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
- <property name="typesConfiguration">
- <list>
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableTypeConfiguration">
- <property name="typeName"
- value="Apache.Ignite.Core.Tests.Cache.CacheAffinityTest+AffinityTestKey"/>
- <property name="affinityKeyFieldName" value="_affKey"/>
- </bean>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
-
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="cacheMode" value="PARTITIONED"/>
- </bean>
- </list>
- </property>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47501</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-parallel-store.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-parallel-store.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-parallel-store.xml
deleted file mode 100644
index 00e8e45..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-parallel-store.xml
+++ /dev/null
@@ -1,69 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="includeEventTypes">
- <util:constant static-field="org.apache.ignite.events.EventType.EVTS_CACHE"/>
- </property>
-
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="object_store_parallel"/>
- <property name="cacheMode" value="LOCAL"/>
- <property name="atomicityMode" value="TRANSACTIONAL"/>
- <property name="keepPortableInStore" value="false"/>
-
- <property name="cacheStoreFactory">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
- <property name="assemblyName" value="Apache.Ignite.Core.Tests"/>
- <property name="className" value="Apache.Ignite.Core.Tests.Cache.Store.CacheTestParallelLoadStore"/>
- </bean>
- </property>
- </bean>
- </list>
- </property>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47501</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
[35/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
new file mode 100644
index 0000000..469887d
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
@@ -0,0 +1,139 @@
+/*
+ * 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.Cache
+{
+ using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Impl;
+ using Apache.Ignite.Core.Portable;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Affinity key tests.
+ /// </summary>
+ public class CacheAffinityTest
+ {
+ /// <summary>
+ ///
+ /// </summary>
+ [TestFixtureSetUp]
+ public virtual void StartGrids()
+ {
+ TestUtils.KillProcesses();
+
+ IgniteConfigurationEx cfg = new IgniteConfigurationEx();
+
+ cfg.JvmClasspath = TestUtils.CreateTestClasspath();
+ cfg.JvmOptions = TestUtils.TestJavaOptions();
+ cfg.SpringConfigUrl = "config\\native-client-test-cache-affinity.xml";
+
+ for (int i = 0; i < 3; i++)
+ {
+ cfg.GridName = "grid-" + i;
+
+ Ignition.Start(cfg);
+ }
+ }
+
+ /// <summary>
+ /// Tear-down routine.
+ /// </summary>
+ [TestFixtureTearDown]
+ public virtual void StopGrids()
+ {
+ for (int i = 0; i < 3; i++)
+ Ignition.Stop("grid-" + i, true);
+ }
+
+ /// <summary>
+ /// Test affinity key.
+ /// </summary>
+ [Test]
+ public void TestAffinity()
+ {
+ IIgnite g = Ignition.GetIgnite("grid-0");
+
+ ICacheAffinity aff = g.GetAffinity(null);
+
+ IClusterNode node = aff.MapKeyToNode(new AffinityTestKey(0, 1));
+
+ for (int i = 0; i < 10; i++)
+ Assert.AreEqual(node.Id, aff.MapKeyToNode(new AffinityTestKey(i, 1)).Id);
+ }
+
+ /// <summary>
+ /// Test affinity with portable flag.
+ /// </summary>
+ [Test]
+ public void TestAffinityPortable()
+ {
+ IIgnite g = Ignition.GetIgnite("grid-0");
+
+ ICacheAffinity aff = g.GetAffinity(null);
+
+ IPortableObject affKey = g.GetPortables().ToPortable<IPortableObject>(new AffinityTestKey(0, 1));
+
+ IClusterNode node = aff.MapKeyToNode(affKey);
+
+ for (int i = 0; i < 10; i++)
+ {
+ IPortableObject otherAffKey =
+ g.GetPortables().ToPortable<IPortableObject>(new AffinityTestKey(i, 1));
+
+ Assert.AreEqual(node.Id, aff.MapKeyToNode(otherAffKey).Id);
+ }
+ }
+
+ /// <summary>
+ /// Affinity key.
+ /// </summary>
+ public class AffinityTestKey
+ {
+ /** ID. */
+ private int _id;
+
+ /** Affinity key. */
+ private int _affKey;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="id">ID.</param>
+ /// <param name="affKey">Affinity key.</param>
+ public AffinityTestKey(int id, int affKey)
+ {
+ _id = id;
+ _affKey = affKey;
+ }
+
+ /** <inheritdoc /> */
+ public override bool Equals(object obj)
+ {
+ AffinityTestKey other = obj as AffinityTestKey;
+
+ return other != null && _id == other._id;
+ }
+
+ /** <inheritdoc /> */
+ public override int GetHashCode()
+ {
+ return _id;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
new file mode 100644
index 0000000..abef473
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
@@ -0,0 +1,281 @@
+/*
+ * 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.Cache
+{
+ using System;
+ using System.Collections.Generic;
+ using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Impl;
+ using Apache.Ignite.Core.Portable;
+ using Apache.Ignite.Core.Tests.Query;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests for dynamic a cache start.
+ /// </summary>
+ public class CacheDynamicStartTest
+ {
+ /** Grid name: data. */
+ private const string GridData = "d";
+
+ /** Grid name: data, no configuration. */
+ private const string GridDataNoCfg = "dnc";
+
+ /** Grid name: client. */
+ private const string GridClient = "c";
+
+ /** Cache name: partitioned, transactional. */
+ private const string CacheTx = "p";
+
+ /** Cache name: atomic. */
+ private const string CacheAtomic = "pa";
+
+ /** Cache name: dummy. */
+ private const string CacheDummy = "dummy";
+
+ /// <summary>
+ /// Set up routine.
+ /// </summary>
+ [SetUp]
+ public void SetUp()
+ {
+ TestUtils.KillProcesses();
+
+ Ignition.Start(CreateConfiguration(GridData, @"config/dynamic/dynamic-data.xml"));
+ Ignition.Start(CreateConfiguration(GridDataNoCfg, @"config/dynamic/dynamic-data-no-cfg.xml"));
+ Ignition.Start(CreateConfiguration(GridClient, @"config/dynamic/dynamic-client.xml"));
+ }
+
+ /// <summary>
+ /// Tear down routine.
+ /// </summary>
+ [TearDown]
+ public void StopGrids()
+ {
+ Ignition.Stop(GridData, true);
+ Ignition.Stop(GridDataNoCfg, true);
+ Ignition.Stop(GridClient, true);
+ }
+
+ /// <summary>
+ /// Create configuration.
+ /// </summary>
+ /// <param name="name">Grid name.</param>
+ /// <param name="springCfg">Spring configuration.</param>
+ /// <returns>Configuration.</returns>
+ private static IgniteConfigurationEx CreateConfiguration(string name, string springCfg)
+ {
+ IgniteConfigurationEx cfg = new IgniteConfigurationEx();
+
+ PortableConfiguration portCfg = new PortableConfiguration();
+
+ ICollection<PortableTypeConfiguration> portTypeCfgs = new List<PortableTypeConfiguration>();
+
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(DynamicTestKey)));
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(DynamicTestValue)));
+
+ portCfg.TypeConfigurations = portTypeCfgs;
+
+ cfg.GridName = name;
+ cfg.PortableConfiguration = portCfg;
+ cfg.JvmClasspath = TestUtils.CreateTestClasspath();
+ cfg.JvmOptions = TestUtils.TestJavaOptions();
+ cfg.SpringConfigUrl = springCfg;
+
+ return cfg;
+ }
+
+ /// <summary>
+ /// Try getting not configured cache.
+ /// </summary>
+ [Test]
+ public void TestNoStarted()
+ {
+ Assert.Throws<ArgumentException>(() =>
+ {
+ Ignition.GetIgnite(GridData).GetCache<CacheTestKey, PortablePerson>(CacheDummy);
+ });
+
+ Assert.Throws<ArgumentException>(() =>
+ {
+ Ignition.GetIgnite(GridDataNoCfg).GetCache<CacheTestKey, PortablePerson>(CacheDummy);
+ });
+
+ Assert.Throws<ArgumentException>(() =>
+ {
+ Ignition.GetIgnite(GridClient).GetCache<CacheTestKey, PortablePerson>(CacheDummy);
+ });
+ }
+
+ /// <summary>
+ /// Test TX cache.
+ /// </summary>
+ [Test]
+ public void TestTransactional()
+ {
+ Check(CacheTx);
+ }
+
+ /// <summary>
+ /// Test ATOMIC cache.
+ /// </summary>
+ [Test]
+ public void TestAtomic()
+ {
+ Check(CacheAtomic);
+ }
+
+ /// <summary>
+ /// Check routine.
+ /// </summary>
+ /// <param name="cacheName">Cache name.</param>
+ private void Check(string cacheName)
+ {
+ ICache<DynamicTestKey, DynamicTestValue> cacheData =
+ Ignition.GetIgnite(GridData).GetCache<DynamicTestKey, DynamicTestValue>(cacheName);
+
+ ICache<DynamicTestKey, DynamicTestValue> cacheDataNoCfg =
+ Ignition.GetIgnite(GridDataNoCfg).GetCache<DynamicTestKey, DynamicTestValue>(cacheName);
+
+ ICache<DynamicTestKey, DynamicTestValue> cacheClient =
+ Ignition.GetIgnite(GridClient).GetCache<DynamicTestKey, DynamicTestValue>(cacheName);
+
+ DynamicTestKey key1 = new DynamicTestKey(1);
+ DynamicTestKey key2 = new DynamicTestKey(2);
+ DynamicTestKey key3 = new DynamicTestKey(3);
+
+ DynamicTestValue val1 = new DynamicTestValue(1);
+ DynamicTestValue val2 = new DynamicTestValue(2);
+ DynamicTestValue val3 = new DynamicTestValue(3);
+
+ cacheData.Put(key1, val1);
+ Assert.AreEqual(val1, cacheData.Get(key1));
+ Assert.AreEqual(val1, cacheDataNoCfg.Get(key1));
+ Assert.AreEqual(val1, cacheClient.Get(key1));
+
+ cacheDataNoCfg.Put(key2, val2);
+ Assert.AreEqual(val2, cacheData.Get(key2));
+ Assert.AreEqual(val2, cacheDataNoCfg.Get(key2));
+ Assert.AreEqual(val2, cacheClient.Get(key2));
+
+ cacheClient.Put(key3, val3);
+ Assert.AreEqual(val3, cacheData.Get(key3));
+ Assert.AreEqual(val3, cacheDataNoCfg.Get(key3));
+ Assert.AreEqual(val3, cacheClient.Get(key3));
+
+ for (int i = 0; i < 10000; i++)
+ cacheClient.Put(new DynamicTestKey(i), new DynamicTestValue(1));
+
+ int sizeClient = cacheClient.GetLocalSize();
+
+ Assert.AreEqual(0, sizeClient);
+ }
+ }
+
+ /// <summary>
+ /// Key for dynamic cache start tests.
+ /// </summary>
+ class DynamicTestKey
+ {
+ /// <summary>
+ /// Default constructor.
+ /// </summary>
+ public DynamicTestKey()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="id">ID.</param>
+ public DynamicTestKey(int id)
+ {
+ Id = id;
+ }
+
+ /// <summary>
+ /// ID.
+ /// </summary>
+ public int Id
+ {
+ get;
+ set;
+ }
+
+ /** <inheritdoc /> */
+ public override bool Equals(object obj)
+ {
+ DynamicTestKey other = obj as DynamicTestKey;
+
+ return other != null && Id == other.Id;
+ }
+
+ /** <inheritdoc /> */
+ public override int GetHashCode()
+ {
+ return Id;
+ }
+ }
+
+ /// <summary>
+ /// Value for dynamic cache start tests.
+ /// </summary>
+ class DynamicTestValue
+ {
+ /// <summary>
+ /// Default constructor.
+ /// </summary>
+ public DynamicTestValue()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="id">ID.</param>
+ public DynamicTestValue(int id)
+ {
+ Id = id;
+ }
+
+ /// <summary>
+ /// ID.
+ /// </summary>
+ public int Id
+ {
+ get;
+ set;
+ }
+
+ /** <inheritdoc /> */
+ public override bool Equals(object obj)
+ {
+ DynamicTestValue other = obj as DynamicTestValue;
+
+ return other != null && Id == other.Id;
+ }
+
+ /** <inheritdoc /> */
+ public override int GetHashCode()
+ {
+ return Id;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheEntryTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheEntryTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheEntryTest.cs
new file mode 100644
index 0000000..8464b8e
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheEntryTest.cs
@@ -0,0 +1,69 @@
+/*
+ * 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.Cache
+{
+ using System.Collections.Generic;
+ using Apache.Ignite.Core.Impl.Cache;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// <see cref="CacheEntry{TK,TV}"/> tests.
+ /// </summary>
+ public class CacheEntryTest
+ {
+ /// <summary>
+ /// Tests equality members.
+ /// </summary>
+ [Test]
+ public void TestEquality()
+ {
+ var entry1 = new CacheEntry<int, int>(1, 2);
+ var entry2 = new CacheEntry<int, int>(1, 2);
+ var entry3 = new CacheEntry<int, int>(1, 3);
+
+ Assert.AreEqual(entry1, entry2);
+ Assert.AreNotEqual(entry1, entry3);
+
+ var boxedEntry1 = (object) entry1;
+ var boxedEntry2 = (object) entry2;
+ var boxedEntry3 = (object) entry3;
+
+ Assert.IsFalse(ReferenceEquals(boxedEntry1, boxedEntry2));
+
+ Assert.AreEqual(boxedEntry1, boxedEntry2);
+ Assert.AreNotEqual(boxedEntry1, boxedEntry3);
+ }
+
+ /// <summary>
+ /// Tests with hash data structures.
+ /// </summary>
+ [Test]
+ public void TestHashCode()
+ {
+ var entry1 = new CacheEntry<int, int>(1, 2);
+ var entry2 = new CacheEntry<int, int>(1, 2);
+ var entry3 = new CacheEntry<int, int>(1, 3);
+
+ var set = new HashSet<object> {entry1};
+
+ Assert.IsTrue(set.Contains(entry1));
+ Assert.IsTrue(set.Contains(entry2));
+ Assert.IsFalse(set.Contains(entry3));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheForkedTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheForkedTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheForkedTest.cs
new file mode 100644
index 0000000..46c54e6
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheForkedTest.cs
@@ -0,0 +1,81 @@
+/*
+ * 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.Cache
+{
+ using System.IO;
+ using Apache.Ignite.Core.Tests.Process;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests cache with a standalone process.
+ /// </summary>
+ public class CacheForkedTest
+ {
+ /** */
+ private IIgnite _grid;
+
+ /// <summary>
+ /// Set up.
+ /// </summary>
+ [TestFixtureSetUp]
+ public void SetUp()
+ {
+ const string springConfigUrl = "config\\compute\\compute-grid1.xml";
+
+ // ReSharper disable once UnusedVariable
+ var proc = new IgniteProcess(
+ "-jvmClasspath=" + TestUtils.CreateTestClasspath(),
+ "-springConfigUrl=" + Path.GetFullPath(springConfigUrl),
+ "-J-ea",
+ "-J-Xcheck:jni",
+ "-J-Xms512m",
+ "-J-Xmx512m",
+ "-J-DIGNITE_QUIET=false"
+ );
+
+ _grid = Ignition.Start(new IgniteConfiguration
+ {
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = TestUtils.TestJavaOptions(),
+ SpringConfigUrl = springConfigUrl
+ });
+
+ Assert.IsTrue(_grid.WaitTopology(2, 30000));
+ }
+
+ /// <summary>
+ /// Tear down.
+ /// </summary>
+ [TestFixtureTearDown]
+ public void TearDown()
+ {
+ IgniteProcess.KillAll();
+
+ Ignition.StopAll(true);
+ }
+
+ /// <summary>
+ /// Tests cache clear.
+ /// </summary>
+ [Test]
+ public void TestClearCache()
+ {
+ _grid.GetCache<object, object>(null).Clear();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheLocalAtomicTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheLocalAtomicTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheLocalAtomicTest.cs
new file mode 100644
index 0000000..b60c254
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheLocalAtomicTest.cs
@@ -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.
+ */
+
+namespace Apache.Ignite.Core.Tests.Cache
+{
+ public class CacheLocalAtomicTest : CacheAbstractTest
+ {
+ protected override int CachePartitions()
+ {
+ return 1;
+ }
+
+ protected override int GridCount()
+ {
+ return 1;
+ }
+
+ protected override string CacheName()
+ {
+ return "local_atomic";
+ }
+
+ protected override bool NearEnabled()
+ {
+ return false;
+ }
+
+ protected override bool TxEnabled()
+ {
+ return false;
+ }
+
+ protected override bool LocalCache()
+ {
+ return true;
+ }
+
+ protected override int Backups()
+ {
+ return 0;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheLocalTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheLocalTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheLocalTest.cs
new file mode 100644
index 0000000..02cb987
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheLocalTest.cs
@@ -0,0 +1,56 @@
+/*
+ * 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.Cache
+{
+ public class CacheLocalTest : CacheAbstractTest
+ {
+ protected override int CachePartitions()
+ {
+ return 1;
+ }
+
+ protected override int GridCount()
+ {
+ return 1;
+ }
+
+ protected override string CacheName()
+ {
+ return "local";
+ }
+
+ protected override bool NearEnabled()
+ {
+ return false;
+ }
+
+ protected override bool TxEnabled()
+ {
+ return true;
+ }
+ protected override bool LocalCache()
+ {
+ return true;
+ }
+
+ protected override int Backups()
+ {
+ return 0;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedAtomicNearEnabledTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedAtomicNearEnabledTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedAtomicNearEnabledTest.cs
new file mode 100644
index 0000000..4f6e7a0
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedAtomicNearEnabledTest.cs
@@ -0,0 +1,50 @@
+/*
+ * 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.Cache
+{
+ using NUnit.Framework;
+
+ [Category(TestUtils.CategoryIntensive)]
+ public class CachePartitionedAtomicNearEnabledTest : CacheAbstractTest
+ {
+ protected override int GridCount()
+ {
+ return 3;
+ }
+
+ protected override string CacheName()
+ {
+ return "partitioned_atomic_near";
+ }
+
+ protected override bool NearEnabled()
+ {
+ return true;
+ }
+
+ protected override bool TxEnabled()
+ {
+ return false;
+ }
+
+ protected override int Backups()
+ {
+ return 1;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedAtomicTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedAtomicTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedAtomicTest.cs
new file mode 100644
index 0000000..ab59c64
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedAtomicTest.cs
@@ -0,0 +1,50 @@
+/*
+ * 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.Cache
+{
+ using NUnit.Framework;
+
+ [Category(TestUtils.CategoryIntensive)]
+ public class CachePartitionedAtomicTest : CacheAbstractTest
+ {
+ protected override int GridCount()
+ {
+ return 3;
+ }
+
+ protected override string CacheName()
+ {
+ return "partitioned_atomic";
+ }
+
+ protected override bool NearEnabled()
+ {
+ return false;
+ }
+
+ protected override bool TxEnabled()
+ {
+ return false;
+ }
+
+ protected override int Backups()
+ {
+ return 1;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedNearEnabledTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedNearEnabledTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedNearEnabledTest.cs
new file mode 100644
index 0000000..830698b
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedNearEnabledTest.cs
@@ -0,0 +1,50 @@
+/*
+ * 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.Cache
+{
+ using NUnit.Framework;
+
+ [Category(TestUtils.CategoryIntensive)]
+ public class CachePartitionedNearEnabledTest : CacheAbstractTest
+ {
+ protected override int GridCount()
+ {
+ return 3;
+ }
+
+ protected override string CacheName()
+ {
+ return "partitioned_near";
+ }
+
+ protected override bool NearEnabled()
+ {
+ return true;
+ }
+
+ protected override bool TxEnabled()
+ {
+ return true;
+ }
+
+ protected override int Backups()
+ {
+ return 1;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedTest.cs
new file mode 100644
index 0000000..02d3208
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedTest.cs
@@ -0,0 +1,50 @@
+/*
+ * 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.Cache
+{
+ using NUnit.Framework;
+
+ [Category(TestUtils.CategoryIntensive)]
+ public class CachePartitionedTest : CacheAbstractTest
+ {
+ protected override int GridCount()
+ {
+ return 3;
+ }
+
+ protected override string CacheName()
+ {
+ return "partitioned";
+ }
+
+ protected override bool NearEnabled()
+ {
+ return false;
+ }
+
+ protected override bool TxEnabled()
+ {
+ return true;
+ }
+
+ protected override int Backups()
+ {
+ return 1;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheReplicatedAtomicTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheReplicatedAtomicTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheReplicatedAtomicTest.cs
new file mode 100644
index 0000000..db6f5a5
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheReplicatedAtomicTest.cs
@@ -0,0 +1,60 @@
+/*
+ * 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.Cache
+{
+ using NUnit.Framework;
+
+ [Category(TestUtils.CategoryIntensive)]
+ public class CacheReplicatedAtomicTest : CacheAbstractTest
+ {
+ protected override int CachePartitions()
+ {
+ return 512;
+ }
+
+ protected override int GridCount()
+ {
+ return 3;
+ }
+
+ protected override string CacheName()
+ {
+ return "replicated_atomic";
+ }
+
+ protected override bool NearEnabled()
+ {
+ return false;
+ }
+
+ protected override bool TxEnabled()
+ {
+ return false;
+ }
+
+ protected override int Backups()
+ {
+ return GridCount() - 1;
+ }
+
+ protected override bool ReplicatedCache()
+ {
+ return true;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheReplicatedTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheReplicatedTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheReplicatedTest.cs
new file mode 100644
index 0000000..7c70222
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheReplicatedTest.cs
@@ -0,0 +1,60 @@
+/*
+ * 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.Cache
+{
+ using NUnit.Framework;
+
+ [Category(TestUtils.CategoryIntensive)]
+ public class CacheReplicatedTest : CacheAbstractTest
+ {
+ protected override int CachePartitions()
+ {
+ return 512;
+ }
+
+ protected override int GridCount()
+ {
+ return 3;
+ }
+
+ protected override string CacheName()
+ {
+ return "replicated";
+ }
+
+ protected override bool NearEnabled()
+ {
+ return false;
+ }
+
+ protected override bool TxEnabled()
+ {
+ return true;
+ }
+
+ protected override int Backups()
+ {
+ return GridCount() - 1;
+ }
+
+ protected override bool ReplicatedCache()
+ {
+ return true;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
new file mode 100644
index 0000000..52a856a
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
@@ -0,0 +1,437 @@
+/*
+ * 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.Cache
+{
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Diagnostics;
+ using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cache.Expiry;
+ using Apache.Ignite.Core.Cache.Query;
+ using Apache.Ignite.Core.Cache.Query.Continuous;
+ using Apache.Ignite.Core.Common;
+
+ /// <summary>
+ /// Wraps IGridCache implementation to simplify async mode testing.
+ /// </summary>
+ internal class CacheTestAsyncWrapper<TK, TV> : ICache<TK, TV>
+ {
+ private readonly ICache<TK, TV> _cache;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="CacheTestAsyncWrapper{K, V}"/> class.
+ /// </summary>
+ /// <param name="cache">The cache to be wrapped.</param>
+ public CacheTestAsyncWrapper(ICache<TK, TV> cache)
+ {
+ Debug.Assert(cache.IsAsync, "GridCacheTestAsyncWrapper only works with async caches.");
+
+ _cache = cache;
+ }
+
+ /** <inheritDoc /> */
+ public ICache<TK, TV> WithAsync()
+ {
+ return this;
+ }
+
+ /** <inheritDoc /> */
+ public bool IsAsync
+ {
+ get { return true; }
+ }
+
+ /** <inheritDoc /> */
+ public IFuture GetFuture()
+ {
+ Debug.Fail("GridCacheTestAsyncWrapper.Future() should not be called. It always returns null.");
+ return null;
+ }
+
+ /** <inheritDoc /> */
+ public IFuture<TResult> GetFuture<TResult>()
+ {
+ Debug.Fail("GridCacheTestAsyncWrapper.Future() should not be called. It always returns null.");
+ return null;
+ }
+
+ /** <inheritDoc /> */
+ public string Name
+ {
+ get { return _cache.Name; }
+ }
+
+ /** <inheritDoc /> */
+ public IIgnite Ignite
+ {
+ get { return _cache.Ignite; }
+ }
+
+ /** <inheritDoc /> */
+
+ public bool IsEmpty()
+ {
+ return _cache.IsEmpty();
+ }
+
+ /** <inheritDoc /> */
+ public bool IsKeepPortable
+ {
+ get { return _cache.IsKeepPortable; }
+ }
+
+ /** <inheritDoc /> */
+ public ICache<TK, TV> WithSkipStore()
+ {
+ return _cache.WithSkipStore().WrapAsync();
+ }
+
+ /** <inheritDoc /> */
+ public ICache<TK, TV> WithExpiryPolicy(IExpiryPolicy plc)
+ {
+ return _cache.WithExpiryPolicy(plc).WrapAsync();
+ }
+
+ /** <inheritDoc /> */
+ public ICache<TK1, TV1> WithKeepPortable<TK1, TV1>()
+ {
+ return _cache.WithKeepPortable<TK1, TV1>().WrapAsync();
+ }
+
+ /** <inheritDoc /> */
+ public void LoadCache(ICacheEntryFilter<TK, TV> p, params object[] args)
+ {
+ _cache.LoadCache(p, args);
+ WaitResult();
+ }
+
+ /** <inheritDoc /> */
+ public void LocalLoadCache(ICacheEntryFilter<TK, TV> p, params object[] args)
+ {
+ _cache.LocalLoadCache(p, args);
+ WaitResult();
+ }
+
+ /** <inheritDoc /> */
+ public bool ContainsKey(TK key)
+ {
+ _cache.ContainsKey(key);
+ return GetResult<bool>();
+ }
+
+ /** <inheritDoc /> */
+ public bool ContainsKeys(IEnumerable<TK> keys)
+ {
+ _cache.ContainsKeys(keys);
+ return GetResult<bool>();
+ }
+
+ /** <inheritDoc /> */
+ public TV LocalPeek(TK key, params CachePeekMode[] modes)
+ {
+ _cache.LocalPeek(key, modes);
+ return GetResult<TV>();
+ }
+
+ /** <inheritDoc /> */
+ public TV Get(TK key)
+ {
+ _cache.Get(key);
+ return GetResult<TV>();
+ }
+
+ /** <inheritDoc /> */
+ public IDictionary<TK, TV> GetAll(IEnumerable<TK> keys)
+ {
+ _cache.GetAll(keys);
+ return GetResult<IDictionary<TK, TV>>();
+ }
+
+ /** <inheritDoc /> */
+ public void Put(TK key, TV val)
+ {
+ _cache.Put(key, val);
+ WaitResult();
+ }
+
+ /** <inheritDoc /> */
+ public TV GetAndPut(TK key, TV val)
+ {
+ _cache.GetAndPut(key, val);
+ return GetResult<TV>();
+ }
+
+ /** <inheritDoc /> */
+ public TV GetAndReplace(TK key, TV val)
+ {
+ _cache.GetAndReplace(key, val);
+ return GetResult<TV>();
+ }
+
+ /** <inheritDoc /> */
+ public TV GetAndRemove(TK key)
+ {
+ _cache.GetAndRemove(key);
+ return GetResult<TV>();
+ }
+
+ /** <inheritDoc /> */
+ public bool PutIfAbsent(TK key, TV val)
+ {
+ _cache.PutIfAbsent(key, val);
+ return GetResult<bool>();
+ }
+
+ /** <inheritDoc /> */
+ public TV GetAndPutIfAbsent(TK key, TV val)
+ {
+ _cache.GetAndPutIfAbsent(key, val);
+ return GetResult<TV>();
+ }
+
+ /** <inheritDoc /> */
+ public bool Replace(TK key, TV val)
+ {
+ _cache.Replace(key, val);
+ return GetResult<bool>();
+ }
+
+ /** <inheritDoc /> */
+ public bool Replace(TK key, TV oldVal, TV newVal)
+ {
+ _cache.Replace(key, oldVal, newVal);
+ return GetResult<bool>();
+ }
+
+ /** <inheritDoc /> */
+ public void PutAll(IDictionary<TK, TV> vals)
+ {
+ _cache.PutAll(vals);
+ WaitResult();
+ }
+
+ /** <inheritDoc /> */
+ public void LocalEvict(IEnumerable<TK> keys)
+ {
+ _cache.LocalEvict(keys);
+ }
+
+ /** <inheritDoc /> */
+ public void Clear()
+ {
+ _cache.Clear();
+ WaitResult();
+ }
+
+ /** <inheritDoc /> */
+ public void Clear(TK key)
+ {
+ _cache.Clear(key);
+ }
+
+ /** <inheritDoc /> */
+ public void ClearAll(IEnumerable<TK> keys)
+ {
+ _cache.ClearAll(keys);
+ }
+
+ /** <inheritDoc /> */
+ public void LocalClear(TK key)
+ {
+ _cache.LocalClear(key);
+ }
+
+ /** <inheritDoc /> */
+ public void LocalClearAll(IEnumerable<TK> keys)
+ {
+ _cache.LocalClearAll(keys);
+ }
+
+ /** <inheritDoc /> */
+ public bool Remove(TK key)
+ {
+ _cache.Remove(key);
+ return GetResult<bool>();
+ }
+
+ /** <inheritDoc /> */
+ public bool Remove(TK key, TV val)
+ {
+ _cache.Remove(key, val);
+ return GetResult<bool>();
+ }
+
+ /** <inheritDoc /> */
+ public void RemoveAll(IEnumerable<TK> keys)
+ {
+ _cache.RemoveAll(keys);
+ WaitResult();
+ }
+
+ /** <inheritDoc /> */
+ public void RemoveAll()
+ {
+ _cache.RemoveAll();
+ WaitResult();
+ }
+
+ /** <inheritDoc /> */
+ public int GetLocalSize(params CachePeekMode[] modes)
+ {
+ return _cache.GetLocalSize(modes);
+ }
+
+ /** <inheritDoc /> */
+ public int GetSize(params CachePeekMode[] modes)
+ {
+ _cache.GetSize(modes);
+ return GetResult<int>();
+ }
+
+ /** <inheritDoc /> */
+ public void LocalPromote(IEnumerable<TK> keys)
+ {
+ _cache.LocalPromote(keys);
+ }
+
+ /** <inheritDoc /> */
+ public IQueryCursor<ICacheEntry<TK, TV>> Query(QueryBase qry)
+ {
+ return _cache.Query(qry);
+ }
+
+ /** <inheritDoc /> */
+ public IQueryCursor<IList> QueryFields(SqlFieldsQuery qry)
+ {
+ return _cache.QueryFields(qry);
+ }
+
+ /** <inheritDoc /> */
+ IContinuousQueryHandle ICache<TK, TV>.QueryContinuous(ContinuousQuery<TK, TV> qry)
+ {
+ return _cache.QueryContinuous(qry);
+ }
+
+ /** <inheritDoc /> */
+ public IContinuousQueryHandle<ICacheEntry<TK, TV>> QueryContinuous(ContinuousQuery<TK, TV> qry, QueryBase initialQry)
+ {
+ return _cache.QueryContinuous(qry, initialQry);
+ }
+
+ /** <inheritDoc /> */
+ public IEnumerable<ICacheEntry<TK, TV>> GetLocalEntries(params CachePeekMode[] peekModes)
+ {
+ return _cache.GetLocalEntries(peekModes);
+ }
+
+ /** <inheritDoc /> */
+ public TR Invoke<TR, TA>(TK key, ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg)
+ {
+ _cache.Invoke(key, processor, arg);
+
+ return GetResult<TR>();
+ }
+
+ /** <inheritDoc /> */
+ public IDictionary<TK, ICacheEntryProcessorResult<TR>> InvokeAll<TR, TA>(IEnumerable<TK> keys,
+ ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg)
+ {
+ _cache.InvokeAll(keys, processor, arg);
+
+ return GetResult<IDictionary<TK, ICacheEntryProcessorResult<TR>>>();
+ }
+
+ /** <inheritDoc /> */
+ public ICacheLock Lock(TK key)
+ {
+ return _cache.Lock(key);
+ }
+
+ /** <inheritDoc /> */
+ public ICacheLock LockAll(IEnumerable<TK> keys)
+ {
+ return _cache.LockAll(keys);
+ }
+
+ /** <inheritDoc /> */
+ public bool IsLocalLocked(TK key, bool byCurrentThread)
+ {
+ return _cache.IsLocalLocked(key, byCurrentThread);
+ }
+
+ /** <inheritDoc /> */
+ public ICacheMetrics GetMetrics()
+ {
+ return _cache.GetMetrics();
+ }
+
+ /** <inheritDoc /> */
+ public IFuture Rebalance()
+ {
+ return _cache.Rebalance();
+ }
+
+ /** <inheritDoc /> */
+ public ICache<TK, TV> WithNoRetries()
+ {
+ return _cache.WithNoRetries();
+ }
+
+ /** <inheritDoc /> */
+ public IEnumerator<ICacheEntry<TK, TV>> GetEnumerator()
+ {
+ return _cache.GetEnumerator();
+ }
+
+ /** <inheritDoc /> */
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+
+ /// <summary>
+ /// Waits for the async result.
+ /// </summary>
+ private void WaitResult()
+ {
+ GetResult<object>();
+ }
+
+ /// <summary>
+ /// Gets the async result.
+ /// </summary>
+ private T GetResult<T>()
+ {
+ return _cache.GetFuture<T>().Get();
+ }
+ }
+
+ /// <summary>
+ /// Extension methods for IGridCache.
+ /// </summary>
+ public static class CacheExtensions
+ {
+ /// <summary>
+ /// Wraps specified instance into GridCacheTestAsyncWrapper.
+ /// </summary>
+ public static ICache<TK, TV> WrapAsync<TK, TV>(this ICache<TK, TV> cache)
+ {
+ return new CacheTestAsyncWrapper<TK, TV>(cache);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
new file mode 100644
index 0000000..18f04ef
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
@@ -0,0 +1,928 @@
+/*
+ * 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.Cache.Query
+{
+ using System;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
+ using System.Text;
+ using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cache.Query;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Impl;
+ using Apache.Ignite.Core.Impl.Portable;
+ using Apache.Ignite.Core.Portable;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Queries tests.
+ /// </summary>
+ public class CacheQueriesTest
+ {
+ /** Grid count. */
+ private const int GridCnt = 2;
+
+ /** Cache name. */
+ private const string CacheName = "cache";
+
+ /** Path to XML configuration. */
+ private const string CfgPath = "config\\cache-query.xml";
+
+ /** Maximum amount of items in cache. */
+ private const int MaxItemCnt = 100;
+
+ /// <summary>
+ ///
+ /// </summary>
+ [TestFixtureSetUp]
+ public virtual void StartGrids()
+ {
+ TestUtils.JvmDebug = true;
+ TestUtils.KillProcesses();
+
+ IgniteConfigurationEx cfg = new IgniteConfigurationEx
+ {
+ PortableConfiguration = new PortableConfiguration
+ {
+ TypeConfigurations = new[]
+ {
+ new PortableTypeConfiguration(typeof (QueryPerson)),
+ new PortableTypeConfiguration(typeof (PortableScanQueryFilter<QueryPerson>)),
+ new PortableTypeConfiguration(typeof (PortableScanQueryFilter<PortableUserObject>))
+ }
+ },
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = TestUtils.TestJavaOptions(),
+ SpringConfigUrl = CfgPath
+ };
+
+ for (int i = 0; i < GridCnt; i++)
+ {
+ cfg.GridName = "grid-" + i;
+
+ Ignition.Start(cfg);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [TestFixtureTearDown]
+ public virtual void StopGrids()
+ {
+ for (int i = 0; i < GridCnt; i++)
+ Ignition.Stop("grid-" + i, true);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [SetUp]
+ public virtual void BeforeTest()
+ {
+ Console.WriteLine("Test started: " + TestContext.CurrentContext.Test.Name);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [TearDown]
+ public virtual void AfterTest()
+ {
+ var cache = Cache();
+
+ for (int i = 0; i < GridCnt; i++)
+ {
+ for (int j = 0; j < MaxItemCnt; j++)
+ cache.Remove(j);
+
+ Assert.IsTrue(cache.IsEmpty());
+ }
+
+ Console.WriteLine("Test finished: " + TestContext.CurrentContext.Test.Name);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="idx"></param>
+ /// <returns></returns>
+ public IIgnite GetIgnite(int idx)
+ {
+ return Ignition.GetIgnite("grid-" + idx);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="idx"></param>
+ /// <returns></returns>
+ public ICache<int, QueryPerson> Cache(int idx)
+ {
+ return GetIgnite(idx).GetCache<int, QueryPerson>(CacheName);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <returns></returns>
+ public ICache<int, QueryPerson> Cache()
+ {
+ return Cache(0);
+ }
+
+ /// <summary>
+ /// Test arguments validation for SQL queries.
+ /// </summary>
+ [Test]
+ public void TestValidationSql()
+ {
+ // 1. No sql.
+ Assert.Throws<ArgumentException>(() =>
+ { Cache().Query(new SqlQuery(typeof(QueryPerson), null)); });
+
+ // 2. No type.
+ Assert.Throws<ArgumentException>(() =>
+ { Cache().Query(new SqlQuery((string)null, "age >= 50")); });
+ }
+
+ /// <summary>
+ /// Test arguments validation for SQL fields queries.
+ /// </summary>
+ [Test]
+ public void TestValidationSqlFields()
+ {
+ // 1. No sql.
+ Assert.Throws<ArgumentException>(() => { Cache().QueryFields(new SqlFieldsQuery(null)); });
+ }
+
+ /// <summary>
+ /// Test arguments validation for TEXT queries.
+ /// </summary>
+ [Test]
+ public void TestValidationText()
+ {
+ // 1. No text.
+ Assert.Throws<ArgumentException>(() =>
+ { Cache().Query(new TextQuery(typeof(QueryPerson), null)); });
+
+ // 2. No type.
+ Assert.Throws<ArgumentException>(() =>
+ { Cache().Query(new TextQuery((string)null, "Ivanov")); });
+ }
+
+ /// <summary>
+ /// Cursor tests.
+ /// </summary>
+ [Test]
+ [SuppressMessage("ReSharper", "ReturnValueOfPureMethodIsNotUsed")]
+ public void TestCursor()
+ {
+ var cache0 = Cache().WithAsync();
+
+ cache0.WithAsync().Put(1, new QueryPerson("Ivanov", 30));
+
+ IFuture<object> res = cache0.GetFuture<object>();
+
+ res.Get();
+
+ Cache().Put(1, new QueryPerson("Ivanov", 30));
+ Cache().Put(1, new QueryPerson("Petrov", 40));
+ Cache().Put(1, new QueryPerson("Sidorov", 50));
+
+ SqlQuery qry = new SqlQuery(typeof(QueryPerson), "age >= 20");
+
+ // 1. Test GetAll().
+ using (IQueryCursor<ICacheEntry<int, QueryPerson>> cursor = Cache().Query(qry))
+ {
+ cursor.GetAll();
+
+ Assert.Throws<InvalidOperationException>(() => { cursor.GetAll(); });
+ Assert.Throws<InvalidOperationException>(() => { cursor.GetEnumerator(); });
+ }
+
+ // 2. Test GetEnumerator.
+ using (IQueryCursor<ICacheEntry<int, QueryPerson>> cursor = Cache().Query(qry))
+ {
+ cursor.GetEnumerator();
+
+ Assert.Throws<InvalidOperationException>(() => { cursor.GetAll(); });
+ Assert.Throws<InvalidOperationException>(() => { cursor.GetEnumerator(); });
+ }
+ }
+
+ /// <summary>
+ /// Test enumerator.
+ /// </summary>
+ [Test]
+ [SuppressMessage("ReSharper", "UnusedVariable")]
+ public void TestEnumerator()
+ {
+ Cache().Put(1, new QueryPerson("Ivanov", 30));
+ Cache().Put(2, new QueryPerson("Petrov", 40));
+ Cache().Put(3, new QueryPerson("Sidorov", 50));
+ Cache().Put(4, new QueryPerson("Unknown", 60));
+
+ // 1. Empty result set.
+ using (
+ IQueryCursor<ICacheEntry<int, QueryPerson>> cursor =
+ Cache().Query(new SqlQuery(typeof(QueryPerson), "age = 100")))
+ {
+ IEnumerator<ICacheEntry<int, QueryPerson>> e = cursor.GetEnumerator();
+
+ Assert.Throws<InvalidOperationException>(() =>
+ { ICacheEntry<int, QueryPerson> entry = e.Current; });
+
+ Assert.IsFalse(e.MoveNext());
+
+ Assert.Throws<InvalidOperationException>(() =>
+ { ICacheEntry<int, QueryPerson> entry = e.Current; });
+
+ Assert.Throws<NotSupportedException>(() => e.Reset());
+ }
+
+ SqlQuery qry = new SqlQuery(typeof (QueryPerson), "age < 60");
+
+ // 2. Page size is bigger than result set.
+ qry.PageSize = 4;
+ CheckEnumeratorQuery(qry);
+
+ // 3. Page size equal to result set.
+ qry.PageSize = 3;
+ CheckEnumeratorQuery(qry);
+
+ // 4. Page size if less than result set.
+ qry.PageSize = 2;
+ CheckEnumeratorQuery(qry);
+ }
+
+ /// <summary>
+ /// Test SQL query arguments passing.
+ /// </summary>
+ public void TestSqlQueryArguments()
+ {
+ Cache().Put(1, new QueryPerson("Ivanov", 30));
+ Cache().Put(2, new QueryPerson("Petrov", 40));
+ Cache().Put(3, new QueryPerson("Sidorov", 50));
+
+ // 1. Empty result set.
+ using (
+ IQueryCursor<ICacheEntry<int, QueryPerson>> cursor =
+ Cache().Query(new SqlQuery(typeof(QueryPerson), "age < ?", 50)))
+ {
+ foreach (ICacheEntry<int, QueryPerson> entry in cursor.GetAll())
+ Assert.IsTrue(entry.Key == 1 || entry.Key == 2);
+ }
+ }
+
+ /// <summary>
+ /// Test SQL fields query arguments passing.
+ /// </summary>
+ public void TestSqlFieldsQueryArguments()
+ {
+ Cache().Put(1, new QueryPerson("Ivanov", 30));
+ Cache().Put(2, new QueryPerson("Petrov", 40));
+ Cache().Put(3, new QueryPerson("Sidorov", 50));
+
+ // 1. Empty result set.
+ using (
+ IQueryCursor<IList> cursor = Cache().QueryFields(
+ new SqlFieldsQuery("SELECT age FROM QueryPerson WHERE age < ?", 50)))
+ {
+ foreach (IList entry in cursor.GetAll())
+ Assert.IsTrue((int) entry[0] < 50);
+ }
+ }
+
+ /// <summary>
+ /// Check query result for enumerator test.
+ /// </summary>
+ /// <param name="qry">QUery.</param>
+ private void CheckEnumeratorQuery(SqlQuery qry)
+ {
+ using (IQueryCursor<ICacheEntry<int, QueryPerson>> cursor = Cache().Query(qry))
+ {
+ bool first = false;
+ bool second = false;
+ bool third = false;
+
+ foreach (var entry in cursor)
+ {
+ if (entry.Key == 1)
+ {
+ first = true;
+
+ Assert.AreEqual("Ivanov", entry.Value.Name);
+ Assert.AreEqual(30, entry.Value.Age);
+ }
+ else if (entry.Key == 2)
+ {
+ second = true;
+
+ Assert.AreEqual("Petrov", entry.Value.Name);
+ Assert.AreEqual(40, entry.Value.Age);
+ }
+ else if (entry.Key == 3)
+ {
+ third = true;
+
+ Assert.AreEqual("Sidorov", entry.Value.Name);
+ Assert.AreEqual(50, entry.Value.Age);
+ }
+ else
+ Assert.Fail("Unexpected value: " + entry);
+ }
+
+ Assert.IsTrue(first && second && third);
+ }
+ }
+
+ /// <summary>
+ /// Check SQL query.
+ /// </summary>
+ [Test]
+ public void TestSqlQuery()
+ {
+ CheckSqlQuery(MaxItemCnt, false, false);
+ }
+
+ /// <summary>
+ /// Check SQL query in portable mode.
+ /// </summary>
+ [Test]
+ public void TestSqlQueryPortable()
+ {
+ CheckSqlQuery(MaxItemCnt, false, true);
+ }
+
+ /// <summary>
+ /// Check local SQL query.
+ /// </summary>
+ [Test]
+ public void TestSqlQueryLocal()
+ {
+ CheckSqlQuery(MaxItemCnt, true, false);
+ }
+
+ /// <summary>
+ /// Check local SQL query in portable mode.
+ /// </summary>
+ [Test]
+ public void TestSqlQueryLocalPortable()
+ {
+ CheckSqlQuery(MaxItemCnt, true, true);
+ }
+
+ /// <summary>
+ /// Check SQL query.
+ /// </summary>
+ /// <param name="cnt">Amount of cache entries to create.</param>
+ /// <param name="loc">Local query flag.</param>
+ /// <param name="keepPortable">Keep portable flag.</param>
+ private void CheckSqlQuery(int cnt, bool loc, bool keepPortable)
+ {
+ var cache = Cache();
+
+ // 1. Populate cache with data, calculating expected count in parallel.
+ var exp = PopulateCache(cache, loc, cnt, x => x < 50);
+
+ // 2. Validate results.
+ SqlQuery qry = loc ? new SqlQuery(typeof(QueryPerson), "age < 50", true) :
+ new SqlQuery(typeof(QueryPerson), "age < 50");
+
+ ValidateQueryResults(cache, qry, exp, keepPortable);
+ }
+
+ /// <summary>
+ /// Check SQL fields query.
+ /// </summary>
+ [Test]
+ public void TestSqlFieldsQuery()
+ {
+ CheckSqlFieldsQuery(MaxItemCnt, false);
+ }
+
+ /// <summary>
+ /// Check local SQL fields query.
+ /// </summary>
+ [Test]
+ public void TestSqlFieldsQueryLocal()
+ {
+ CheckSqlFieldsQuery(MaxItemCnt, true);
+ }
+
+ /// <summary>
+ /// Check SQL fields query.
+ /// </summary>
+ /// <param name="cnt">Amount of cache entries to create.</param>
+ /// <param name="loc">Local query flag.</param>
+ private void CheckSqlFieldsQuery(int cnt, bool loc)
+ {
+ var cache = Cache();
+
+ // 1. Populate cache with data, calculating expected count in parallel.
+ var exp = PopulateCache(cache, loc, cnt, x => x < 50);
+
+ // 2. Vlaidate results.
+ SqlFieldsQuery qry = loc ? new SqlFieldsQuery("SELECT name, age FROM QueryPerson WHERE age < 50", true) :
+ new SqlFieldsQuery("SELECT name, age FROM QueryPerson WHERE age < 50");
+
+ using (IQueryCursor<IList> cursor = cache.QueryFields(qry))
+ {
+ HashSet<int> exp0 = new HashSet<int>(exp);
+
+ foreach (var entry in cursor.GetAll())
+ {
+ Assert.AreEqual(2, entry.Count);
+ Assert.AreEqual(entry[0].ToString(), entry[1].ToString());
+
+ exp0.Remove((int)entry[1]);
+ }
+
+ Assert.AreEqual(0, exp0.Count);
+ }
+
+ using (IQueryCursor<IList> cursor = cache.QueryFields(qry))
+ {
+ HashSet<int> exp0 = new HashSet<int>(exp);
+
+ foreach (var entry in cursor)
+ {
+ Assert.AreEqual(entry[0].ToString(), entry[1].ToString());
+
+ exp0.Remove((int)entry[1]);
+ }
+
+ Assert.AreEqual(0, exp0.Count);
+ }
+ }
+
+ /// <summary>
+ /// Check text query.
+ /// </summary>
+ [Test]
+ public void TestTextQuery()
+ {
+ CheckTextQuery(MaxItemCnt, false, false);
+ }
+
+ /// <summary>
+ /// Check SQL query in portable mode.
+ /// </summary>
+ [Test]
+ public void TestTextQueryPortable()
+ {
+ CheckTextQuery(MaxItemCnt, false, true);
+ }
+
+ /// <summary>
+ /// Check local SQL query.
+ /// </summary>
+ [Test]
+ public void TestTextQueryLocal()
+ {
+ CheckTextQuery(MaxItemCnt, true, false);
+ }
+
+ /// <summary>
+ /// Check local SQL query in portable mode.
+ /// </summary>
+ [Test]
+ public void TestTextQueryLocalPortable()
+ {
+ CheckTextQuery(MaxItemCnt, true, true);
+ }
+
+ /// <summary>
+ /// Check text query.
+ /// </summary>
+ /// <param name="cnt">Amount of cache entries to create.</param>
+ /// <param name="loc">Local query flag.</param>
+ /// <param name="keepPortable">Keep portable flag.</param>
+ private void CheckTextQuery(int cnt, bool loc, bool keepPortable)
+ {
+ var cache = Cache();
+
+ // 1. Populate cache with data, calculating expected count in parallel.
+ var exp = PopulateCache(cache, loc, cnt, x => x.ToString().StartsWith("1"));
+
+ // 2. Validate results.
+ TextQuery qry = loc ? new TextQuery(typeof(QueryPerson), "1*", true) :
+ new TextQuery(typeof(QueryPerson), "1*");
+
+ ValidateQueryResults(cache, qry, exp, keepPortable);
+ }
+
+ /// <summary>
+ /// Check scan query.
+ /// </summary>
+ [Test]
+ public void TestScanQuery()
+ {
+ CheckScanQuery<QueryPerson>(MaxItemCnt, false, false);
+ }
+
+ /// <summary>
+ /// Check scan query in portable mode.
+ /// </summary>
+ [Test]
+ public void TestScanQueryPortable()
+ {
+ CheckScanQuery<PortableUserObject>(MaxItemCnt, false, true);
+ }
+
+ /// <summary>
+ /// Check local scan query.
+ /// </summary>
+ [Test]
+ public void TestScanQueryLocal()
+ {
+ CheckScanQuery<QueryPerson>(MaxItemCnt, true, false);
+ }
+
+ /// <summary>
+ /// Check local scan query in portable mode.
+ /// </summary>
+ [Test]
+ public void TestScanQueryLocalPortable()
+ {
+ CheckScanQuery<PortableUserObject>(MaxItemCnt, true, true);
+ }
+
+ /// <summary>
+ /// Check scan query with partitions.
+ /// </summary>
+ [Test]
+ [Ignore("IGNITE-1012")]
+ public void TestScanQueryPartitions([Values(true, false)] bool loc)
+ {
+ CheckScanQueryPartitions<QueryPerson>(MaxItemCnt, loc, false);
+ }
+
+ /// <summary>
+ /// Check scan query with partitions in portable mode.
+ /// </summary>
+ [Test]
+ [Ignore("IGNITE-1012")]
+ public void TestScanQueryPartitionsPortable([Values(true, false)] bool loc)
+ {
+ CheckScanQueryPartitions<PortableUserObject>(MaxItemCnt, loc, true);
+ }
+
+ /// <summary>
+ /// Tests that query attempt on non-indexed cache causes an exception.
+ /// </summary>
+ [Test]
+ public void TestIndexingDisabledError()
+ {
+ var cache = GetIgnite(0).GetOrCreateCache<int, QueryPerson>("nonindexed_cache");
+
+ var queries = new QueryBase[]
+ {
+ new TextQuery(typeof (QueryPerson), "1*"),
+ new SqlQuery(typeof (QueryPerson), "age < 50")
+ };
+
+ foreach (var qry in queries)
+ {
+ var err = Assert.Throws<IgniteException>(() => cache.Query(qry));
+
+ Assert.AreEqual("Indexing is disabled for cache: nonindexed_cache. " +
+ "Use setIndexedTypes or setTypeMetadata methods on CacheConfiguration to enable.", err.Message);
+ }
+ }
+
+ /// <summary>
+ /// Check scan query.
+ /// </summary>
+ /// <param name="cnt">Amount of cache entries to create.</param>
+ /// <param name="loc">Local query flag.</param>
+ /// <param name="keepPortable">Keep portable flag.</param>
+ private void CheckScanQuery<TV>(int cnt, bool loc, bool keepPortable)
+ {
+ var cache = Cache();
+
+ // No predicate
+ var exp = PopulateCache(cache, loc, cnt, x => true);
+ var qry = new ScanQuery<int, TV>();
+ ValidateQueryResults(cache, qry, exp, keepPortable);
+
+ // Serializable
+ exp = PopulateCache(cache, loc, cnt, x => x < 50);
+ qry = new ScanQuery<int, TV>(new ScanQueryFilter<TV>());
+ ValidateQueryResults(cache, qry, exp, keepPortable);
+
+ // Portable
+ exp = PopulateCache(cache, loc, cnt, x => x < 50);
+ qry = new ScanQuery<int, TV>(new PortableScanQueryFilter<TV>());
+ ValidateQueryResults(cache, qry, exp, keepPortable);
+
+ // Exception
+ exp = PopulateCache(cache, loc, cnt, x => x < 50);
+ qry = new ScanQuery<int, TV>(new ScanQueryFilter<TV> {ThrowErr = true});
+
+ var ex = Assert.Throws<IgniteException>(() => ValidateQueryResults(cache, qry, exp, keepPortable));
+ Assert.AreEqual(ScanQueryFilter<TV>.ErrMessage, ex.Message);
+ }
+
+ /// <summary>
+ /// Checks scan query with partitions.
+ /// </summary>
+ /// <param name="cnt">Amount of cache entries to create.</param>
+ /// <param name="loc">Local query flag.</param>
+ /// <param name="keepPortable">Keep portable flag.</param>
+ private void CheckScanQueryPartitions<TV>(int cnt, bool loc, bool keepPortable)
+ {
+ StopGrids();
+ StartGrids();
+
+ var cache = Cache();
+
+ var aff = cache.Ignite.GetAffinity(CacheName);
+ var exp = PopulateCache(cache, loc, cnt, x => true); // populate outside the loop (slow)
+
+ for (var part = 0; part < aff.Partitions; part++)
+ {
+ //var exp0 = new HashSet<int>(exp.Where(x => aff.Partition(x) == part)); // filter expected keys
+ var exp0 = new HashSet<int>();
+ foreach (var x in exp)
+ if (aff.GetPartition(x) == part)
+ exp0.Add(x);
+
+ var qry = new ScanQuery<int, TV> { Partition = part };
+
+ Console.WriteLine("Checking query on partition " + part);
+ ValidateQueryResults(cache, qry, exp0, keepPortable);
+ }
+
+ // Partitions with predicate
+ exp = PopulateCache(cache, loc, cnt, x => x < 50); // populate outside the loop (slow)
+
+ for (var part = 0; part < aff.Partitions; part++)
+ {
+ //var exp0 = new HashSet<int>(exp.Where(x => aff.Partition(x) == part)); // filter expected keys
+ var exp0 = new HashSet<int>();
+ foreach (var x in exp)
+ if (aff.GetPartition(x) == part)
+ exp0.Add(x);
+
+ var qry = new ScanQuery<int, TV>(new ScanQueryFilter<TV>()) { Partition = part };
+
+ Console.WriteLine("Checking predicate query on partition " + part);
+ ValidateQueryResults(cache, qry, exp0, keepPortable);
+ }
+
+ }
+
+ /// <summary>
+ /// Validates the query results.
+ /// </summary>
+ /// <param name="cache">Cache.</param>
+ /// <param name="qry">Query.</param>
+ /// <param name="exp">Expected keys.</param>
+ /// <param name="keepPortable">Keep portable flag.</param>
+ private static void ValidateQueryResults(ICache<int, QueryPerson> cache, QueryBase qry, HashSet<int> exp,
+ bool keepPortable)
+ {
+ if (keepPortable)
+ {
+ var cache0 = cache.WithKeepPortable<int, IPortableObject>();
+
+ using (var cursor = cache0.Query(qry))
+ {
+ HashSet<int> exp0 = new HashSet<int>(exp);
+ var all = new List<ICacheEntry<int, object>>();
+
+ foreach (var entry in cursor.GetAll())
+ {
+ all.Add(entry);
+
+ Assert.AreEqual(entry.Key.ToString(), entry.Value.GetField<string>("name"));
+ Assert.AreEqual(entry.Key, entry.Value.GetField<int>("age"));
+
+ exp0.Remove(entry.Key);
+ }
+
+ AssertMissingExpectedKeys(exp0, cache, all);
+ }
+
+ using (var cursor = cache0.Query(qry))
+ {
+ HashSet<int> exp0 = new HashSet<int>(exp);
+ var all = new List<ICacheEntry<int, object>>();
+
+ foreach (var entry in cursor)
+ {
+ all.Add(entry);
+
+ Assert.AreEqual(entry.Key.ToString(), entry.Value.GetField<string>("name"));
+ Assert.AreEqual(entry.Key, entry.Value.GetField<int>("age"));
+
+ exp0.Remove(entry.Key);
+ }
+
+ AssertMissingExpectedKeys(exp0, cache, all);
+ }
+ }
+ else
+ {
+ using (var cursor = cache.Query(qry))
+ {
+ HashSet<int> exp0 = new HashSet<int>(exp);
+ var all = new List<ICacheEntry<int, object>>();
+
+ foreach (var entry in cursor.GetAll())
+ {
+ all.Add(entry);
+
+ Assert.AreEqual(entry.Key.ToString(), entry.Value.Name);
+ Assert.AreEqual(entry.Key, entry.Value.Age);
+
+ exp0.Remove(entry.Key);
+ }
+
+ AssertMissingExpectedKeys(exp0, cache, all);
+ }
+
+ using (var cursor = cache.Query(qry))
+ {
+ HashSet<int> exp0 = new HashSet<int>(exp);
+ var all = new List<ICacheEntry<int, object>>();
+
+ foreach (var entry in cursor)
+ {
+ all.Add(entry);
+
+ Assert.AreEqual(entry.Key.ToString(), entry.Value.Name);
+ Assert.AreEqual(entry.Key, entry.Value.Age);
+
+ exp0.Remove(entry.Key);
+ }
+
+ AssertMissingExpectedKeys(exp0, cache, all);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Asserts that all expected entries have been received.
+ /// </summary>
+ private static void AssertMissingExpectedKeys(ICollection<int> exp, ICache<int, QueryPerson> cache,
+ IList<ICacheEntry<int, object>> all)
+ {
+ if (exp.Count == 0)
+ return;
+
+ var sb = new StringBuilder();
+ var aff = cache.Ignite.GetAffinity(cache.Name);
+
+ foreach (var key in exp)
+ {
+ var part = aff.GetPartition(key);
+ sb.AppendFormat(
+ "Query did not return expected key '{0}' (exists: {1}), partition '{2}', partition nodes: ",
+ key, cache.Get(key) != null, part);
+
+ var partNodes = aff.MapPartitionToPrimaryAndBackups(part);
+
+ foreach (var node in partNodes)
+ sb.Append(node).Append(" ");
+
+ sb.AppendLine(";");
+ }
+
+ sb.Append("Returned keys: ");
+
+ foreach (var e in all)
+ sb.Append(e.Key).Append(" ");
+
+ sb.AppendLine(";");
+
+ Assert.Fail(sb.ToString());
+ }
+
+ /// <summary>
+ /// Populates the cache with random entries and returns expected results set according to filter.
+ /// </summary>
+ /// <param name="cache">The cache.</param>
+ /// <param name="cnt">Amount of cache entries to create.</param>
+ /// <param name="loc">Local query flag.</param>
+ /// <param name="expectedEntryFilter">The expected entry filter.</param>
+ /// <returns>Expected results set.</returns>
+ private static HashSet<int> PopulateCache(ICache<int, QueryPerson> cache, bool loc, int cnt,
+ Func<int, bool> expectedEntryFilter)
+ {
+ var rand = new Random();
+
+ var exp = new HashSet<int>();
+
+ for (var i = 0; i < cnt; i++)
+ {
+ var val = rand.Next(100);
+
+ cache.Put(val, new QueryPerson(val.ToString(), val));
+
+ if (expectedEntryFilter(val) && (!loc || cache.Ignite.GetAffinity(cache.Name)
+ .IsPrimary(cache.Ignite.GetCluster().GetLocalNode(), val)))
+ exp.Add(val);
+ }
+
+ return exp;
+ }
+ }
+
+ /// <summary>
+ /// Person.
+ /// </summary>
+ public class QueryPerson
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public QueryPerson()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="name">Name.</param>
+ /// <param name="age">Age.</param>
+ public QueryPerson(string name, int age)
+ {
+ Name = name;
+ Age = age;
+ }
+
+ /// <summary>
+ /// Name.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Age.
+ /// </summary>
+ public int Age { get; set; }
+ }
+
+ /// <summary>
+ /// Query filter.
+ /// </summary>
+ [Serializable]
+ public class ScanQueryFilter<TV> : ICacheEntryFilter<int, TV>
+ {
+ // Error message
+ public const string ErrMessage = "Error in ScanQueryFilter.Invoke";
+
+ // Error flag
+ public bool ThrowErr { get; set; }
+
+ /** <inheritdoc /> */
+ public bool Invoke(ICacheEntry<int, TV> entry)
+ {
+ if (ThrowErr)
+ throw new Exception(ErrMessage);
+
+ return entry.Key < 50;
+ }
+ }
+
+ /// <summary>
+ /// Portable query filter.
+ /// </summary>
+ public class PortableScanQueryFilter<TV> : ScanQueryFilter<TV>, IPortableMarshalAware
+ {
+ /** <inheritdoc /> */
+ public void WritePortable(IPortableWriter writer)
+ {
+ var w = writer.RawWriter();
+
+ w.WriteBoolean(ThrowErr);
+ }
+
+ /** <inheritdoc /> */
+ public void ReadPortable(IPortableReader reader)
+ {
+ var r = reader.RawReader();
+
+ ThrowErr = r.ReadBoolean();
+ }
+ }
+}
[16/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
deleted file mode 100644
index 0f4ba5e..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Examples
-{
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using Apache.Ignite.Core.Tests.Process;
- using Apache.Ignite.ExamplesDll.Compute;
- using NUnit.Framework;
-
- /// <summary>
- /// Tests all examples in various modes.
- /// </summary>
- [Category(TestUtils.CategoryIntensive)]
- public class ExamplesTest
- {
- /// <summary>
- /// Tests the example in a single node mode.
- /// </summary>
- /// <param name="example">The example to run.</param>
- [Test, TestCaseSource("TestCases")]
- public void TestLocalNode(Example example)
- {
- example.Run();
- }
-
- /// <summary>
- /// Tests the example with standalone Apache.Ignite.exe nodes.
- /// </summary>
- /// <param name="example">The example to run.</param>
- [Test, TestCaseSource("TestCases")]
- public void TestRemoteNodes(Example example)
- {
- TestRemoteNodes(example, false);
- }
-
- /// <summary>
- /// Tests the example with standalone Apache.Ignite.exe nodes while local node is in client mode.
- /// </summary>
- /// <param name="example">The example to run.</param>
- [Test, TestCaseSource("TestCases")]
- public void TestRemoteNodesClientMode(Example example)
- {
- TestRemoteNodes(example, true);
- }
-
- /// <summary>
- /// Tests the example with standalone Apache.Ignite.exe nodes.
- /// </summary>
- /// <param name="example">The example to run.</param>
- /// <param name="clientMode">Client mode flag.</param>
- private static void TestRemoteNodes(Example example, bool clientMode)
- {
- // Exclude CrossPlatformExample and LifecycleExample
- if (string.IsNullOrEmpty(example.SpringConfigUrl))
- {
- Assert.IsTrue(new[] {"CrossPlatformExample", "LifecycleExample"}.Contains(example.Name));
-
- return;
- }
-
- Assert.IsTrue(File.Exists(example.SpringConfigUrl));
-
- var gridConfig = new IgniteConfiguration {SpringConfigUrl = example.SpringConfigUrl};
-
- // Try with multiple standalone nodes
- for (var i = 0; i < 2; i++)
- {
- // Start a grid to monitor topology
- // Stop it after topology check so we don't interfere with example
- Ignition.ClientMode = false;
-
- using (var ignite = Ignition.Start(gridConfig))
- {
- var args = new List<string> {"-springConfigUrl=" + example.SpringConfigUrl};
-
- if (example.NeedsTestDll)
- args.Add(" -assembly=" + typeof(AverageSalaryJob).Assembly.Location);
-
- // ReSharper disable once UnusedVariable
- var proc = new IgniteProcess(args.ToArray());
-
- Assert.IsTrue(ignite.WaitTopology(i + 2, 30000));
- }
-
- Ignition.ClientMode = clientMode;
- example.Run();
- }
- }
-
- /// <summary>
- /// Fixture setup.
- /// </summary>
- [TestFixtureSetUp]
- public void FixtureSetUp()
- {
- Environment.SetEnvironmentVariable("IGNITE_NATIVE_TEST_CLASSPATH", "true");
-
- Directory.SetCurrentDirectory(PathUtil.IgniteHome);
- }
-
- /// <summary>
- /// Test teardown.
- /// </summary>
- [TearDown]
- public void TearDown()
- {
- Ignition.ClientMode = false;
- IgniteProcess.KillAll();
- }
-
- /// <summary>
- /// Gets the test cases.
- /// </summary>
- public IEnumerable<Example> TestCases
- {
- get { return Example.All; }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/PathUtil.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/PathUtil.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/PathUtil.cs
deleted file mode 100644
index 4f9625f..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/PathUtil.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Examples
-{
- using System.IO;
- using Apache.Ignite.Core.Impl;
-
- /// <summary>
- /// Grid path resolver.
- /// </summary>
- public static class PathUtil
- {
- public static readonly string IgniteHome = IgniteManager.GetIgniteHome(null);
-
- /// <summary>
- /// Full Apache.Ignite.exe path.
- /// </summary>
- public static readonly string IgniteExePath = typeof(IgniteRunner).Assembly.Location;
-
- /// <summary>
- /// Examples source code path.
- /// </summary>
- public static readonly string ExamplesSourcePath = Path.Combine(IgniteHome, @"platforms\dotnet\Examples");
-
- /// <summary>
- /// Gets the full configuration path.
- /// </summary>
- public static string GetFullConfigPath(string springConfigUrl)
- {
- if (string.IsNullOrEmpty(springConfigUrl))
- return springConfigUrl;
-
- return Path.GetFullPath(Path.Combine(IgniteHome, springConfigUrl));
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/ProjectFilesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/ProjectFilesTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/ProjectFilesTest.cs
deleted file mode 100644
index 24bd663..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/ProjectFilesTest.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Examples
-{
- using System.IO;
- using System.Linq;
- using System.Text.RegularExpressions;
- using NUnit.Framework;
-
- /// <summary>
- /// Tests project files.
- /// </summary>
- public class ProjectFilesTest
- {
- /// <summary>
- /// Checks config files in examples comments for existence.
- /// </summary>
- [Test]
- public void CheckConfigFilesExist()
- {
- Directory.GetFiles(PathUtil.ExamplesSourcePath, "*.cs", SearchOption.AllDirectories)
- .Select(File.ReadAllText)
- .SelectMany(src => Regex.Matches(src, @"modules\\platform[^\s]+.xml").OfType<Match>())
- .Where(match => match.Success)
- .Select(match => Path.Combine(PathUtil.IgniteHome, match.Value))
- .ToList()
- .ForEach(path => Assert.IsTrue(File.Exists(path), "Config file does not exist: " + path));
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
deleted file mode 100644
index 7a5a725..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests
-{
- using System;
- using System.IO;
- using System.Linq;
- using System.Runtime.Serialization.Formatters.Binary;
- using System.Threading.Tasks;
- using Apache.Ignite.Core.Cache;
- using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Impl;
- using Apache.Ignite.Core.Portable;
- using NUnit.Framework;
-
- /// <summary>
- /// Tests grid exceptions propagation.
- /// </summary>
- public class ExceptionsTest
- {
- /// <summary>
- /// Before test.
- /// </summary>
- [SetUp]
- public void SetUp()
- {
- TestUtils.KillProcesses();
- }
-
- /// <summary>
- /// After test.
- /// </summary>
- [TearDown]
- public void TearDown()
- {
- Ignition.StopAll(true);
- }
-
- /// <summary>
- /// Tests exceptions.
- /// </summary>
- [Test]
- public void TestExceptions()
- {
- var grid = StartGrid();
-
- try
- {
- grid.GetCache<object, object>("invalidCacheName");
-
- Assert.Fail();
- }
- catch (Exception e)
- {
- Assert.IsTrue(e is ArgumentException);
- }
-
- try
- {
- grid.GetCluster().ForRemotes().GetMetrics();
-
- Assert.Fail();
- }
- catch (Exception e)
- {
- Assert.IsTrue(e is ClusterGroupEmptyException);
- }
-
- grid.Dispose();
-
- try
- {
- grid.GetCache<object, object>("cache1");
-
- Assert.Fail();
- }
- catch (Exception e)
- {
- Assert.IsTrue(e is InvalidOperationException);
- }
- }
-
- /// <summary>
- /// Tests CachePartialUpdateException keys propagation.
- /// </summary>
- [Test]
- [Category(TestUtils.CategoryIntensive)]
- public void TestPartialUpdateException()
- {
- // Primitive type
- TestPartialUpdateException(false, (x, g) => x);
-
- // User type
- TestPartialUpdateException(false, (x, g) => new PortableEntry(x));
- }
-
- /// <summary>
- /// Tests CachePartialUpdateException keys propagation in portable mode.
- /// </summary>
- [Test]
- [Category(TestUtils.CategoryIntensive)]
- public void TestPartialUpdateExceptionPortable()
- {
- // User type
- TestPartialUpdateException(false, (x, g) => g.GetPortables().ToPortable<IPortableObject>(new PortableEntry(x)));
- }
-
- /// <summary>
- /// Tests CachePartialUpdateException serialization.
- /// </summary>
- [Test]
- public void TestPartialUpdateExceptionSerialization()
- {
- // Inner exception
- TestPartialUpdateExceptionSerialization(new CachePartialUpdateException("Msg",
- new IgniteException("Inner msg")));
-
- // Primitive keys
- TestPartialUpdateExceptionSerialization(new CachePartialUpdateException("Msg", new object[] {1, 2, 3}));
-
- // User type keys
- TestPartialUpdateExceptionSerialization(new CachePartialUpdateException("Msg",
- new object[]
- {
- new SerializableEntry(1),
- new SerializableEntry(2),
- new SerializableEntry(3)
- }));
- }
-
- /// <summary>
- /// Tests CachePartialUpdateException serialization.
- /// </summary>
- private static void TestPartialUpdateExceptionSerialization(Exception ex)
- {
- var formatter = new BinaryFormatter();
-
- var stream = new MemoryStream();
-
- formatter.Serialize(stream, ex);
-
- stream.Seek(0, SeekOrigin.Begin);
-
- var ex0 = (Exception) formatter.Deserialize(stream);
-
- var updateEx = ((CachePartialUpdateException) ex);
-
- try
- {
- Assert.AreEqual(updateEx.GetFailedKeys<object>(),
- ((CachePartialUpdateException)ex0).GetFailedKeys<object>());
- }
- catch (Exception e)
- {
- if (typeof (IgniteException) != e.GetType())
- throw;
- }
-
- while (ex != null && ex0 != null)
- {
- Assert.AreEqual(ex0.GetType(), ex.GetType());
- Assert.AreEqual(ex.Message, ex0.Message);
-
- ex = ex.InnerException;
- ex0 = ex0.InnerException;
- }
-
- Assert.AreEqual(ex, ex0);
- }
-
- /// <summary>
- /// Tests CachePartialUpdateException keys propagation.
- /// </summary>
- [Test]
- [Category(TestUtils.CategoryIntensive)]
- public void TestPartialUpdateExceptionAsync()
- {
- // Primitive type
- TestPartialUpdateException(true, (x, g) => x);
-
- // User type
- TestPartialUpdateException(true, (x, g) => new PortableEntry(x));
- }
-
- /// <summary>
- /// Tests CachePartialUpdateException keys propagation in portable mode.
- /// </summary>
- [Test]
- [Category(TestUtils.CategoryIntensive)]
- public void TestPartialUpdateExceptionAsyncPortable()
- {
- TestPartialUpdateException(true, (x, g) => g.GetPortables().ToPortable<IPortableObject>(new PortableEntry(x)));
- }
-
- /// <summary>
- /// Tests CachePartialUpdateException keys propagation.
- /// </summary>
- private static void TestPartialUpdateException<TK>(bool async, Func<int, IIgnite, TK> keyFunc)
- {
- using (var grid = StartGrid())
- {
- var cache = grid.GetCache<TK, int>("partitioned_atomic").WithNoRetries();
-
- if (async)
- cache = cache.WithAsync();
-
- if (typeof (TK) == typeof (IPortableObject))
- cache = cache.WithKeepPortable<TK, int>();
-
- // Do cache puts in parallel
- var putTask = Task.Factory.StartNew(() =>
- {
- try
- {
- // Do a lot of puts so that one fails during Ignite stop
- for (var i = 0; i < 1000000; i++)
- {
- cache.PutAll(Enumerable.Range(1, 100).ToDictionary(k => keyFunc(k, grid), k => i));
-
- if (async)
- cache.GetFuture().Get();
- }
- }
- catch (CachePartialUpdateException ex)
- {
- var failedKeys = ex.GetFailedKeys<TK>();
-
- Assert.IsTrue(failedKeys.Any());
-
- var failedKeysObj = ex.GetFailedKeys<object>();
-
- Assert.IsTrue(failedKeysObj.Any());
-
- return;
- }
-
- Assert.Fail("CachePartialUpdateException has not been thrown.");
- });
-
- while (true)
- {
- Ignition.Stop("grid_2", true);
- StartGrid("grid_2");
-
- if (putTask.Exception != null)
- throw putTask.Exception;
-
- if (putTask.IsCompleted)
- return;
- }
- }
- }
-
- /// <summary>
- /// Starts the grid.
- /// </summary>
- private static IIgnite StartGrid(string gridName = null)
- {
- return Ignition.Start(new IgniteConfigurationEx
- {
- SpringConfigUrl = "config\\native-client-test-cache.xml",
- JvmOptions = TestUtils.TestJavaOptions(),
- JvmClasspath = TestUtils.CreateTestClasspath(),
- GridName = gridName,
- PortableConfiguration = new PortableConfiguration
- {
- TypeConfigurations = new[]
- {
- new PortableTypeConfiguration(typeof (PortableEntry))
- }
- }
- });
- }
-
- /// <summary>
- /// Portable entry.
- /// </summary>
- private class PortableEntry
- {
- /** Value. */
- private readonly int _val;
-
- /** <inheritDot /> */
- public override int GetHashCode()
- {
- return _val;
- }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="val">Value.</param>
- public PortableEntry(int val)
- {
- _val = val;
- }
-
- /** <inheritDoc /> */
- public override bool Equals(object obj)
- {
- return obj is PortableEntry && ((PortableEntry)obj)._val == _val;
- }
- }
-
- /// <summary>
- /// Portable entry.
- /// </summary>
- [Serializable]
- private class SerializableEntry
- {
- /** Value. */
- private readonly int _val;
-
- /** <inheritDot /> */
- public override int GetHashCode()
- {
- return _val;
- }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="val">Value.</param>
- public SerializableEntry(int val)
- {
- _val = val;
- }
-
- /** <inheritDoc /> */
- public override bool Equals(object obj)
- {
- return obj is SerializableEntry && ((SerializableEntry)obj)._val == _val;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs
deleted file mode 100644
index abb296c..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs
+++ /dev/null
@@ -1,443 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// ReSharper disable UnusedVariable
-// ReSharper disable UnusedAutoPropertyAccessor.Global
-namespace Apache.Ignite.Core.Tests
-{
- using System;
- using System.CodeDom.Compiler;
- using System.Collections.Generic;
- using Apache.Ignite.Core.Compute;
- using Apache.Ignite.Core.Impl;
- using Apache.Ignite.Core.Portable;
- using Apache.Ignite.Core.Resource;
- using Apache.Ignite.Core.Tests.Process;
- using Microsoft.CSharp;
- using NUnit.Framework;
-
- /// <summary>
- /// Tests for executable.
- /// </summary>
- public class ExecutableTest
- {
- /** Spring configuration path. */
- private static readonly string SpringCfgPath = "config\\compute\\compute-standalone.xml";
-
- /** Min memory Java task. */
- private const string MinMemTask = "org.apache.ignite.platform.PlatformMinMemoryTask";
-
- /** Max memory Java task. */
- private const string MaxMemTask = "org.apache.ignite.platform.PlatformMaxMemoryTask";
-
- /** Grid. */
- private IIgnite _grid;
-
- /// <summary>
- /// Test fixture set-up routine.
- /// </summary>
- [TestFixtureSetUp]
- public void TestFixtureSetUp()
- {
- TestUtils.KillProcesses();
-
- _grid = Ignition.Start(Configuration(SpringCfgPath));
- }
-
- /// <summary>
- /// Test fixture tear-down routine.
- /// </summary>
- [TestFixtureTearDown]
- public void TestFixtureTearDown()
- {
- Ignition.StopAll(true);
-
- TestUtils.KillProcesses();
- }
-
- /// <summary>
- /// Set-up routine.
- /// </summary>
- [SetUp]
- public void SetUp()
- {
- TestUtils.KillProcesses();
-
- Assert.IsTrue(_grid.WaitTopology(1, 30000));
-
- IgniteProcess.SaveConfigurationBackup();
- }
-
- /// <summary>
- /// Tear-down routine.
- /// </summary>
- [TearDown]
- public void TearDown()
- {
- IgniteProcess.RestoreConfigurationBackup();
- }
-
- /// <summary>
- /// Test data pass through configuration file.
- /// </summary>
- [Test]
- public void TestConfig()
- {
- IgniteProcess.ReplaceConfiguration("config\\Apache.Ignite.exe.config.test");
-
- GenerateDll("test-1.dll");
- GenerateDll("test-2.dll");
-
- var proc = new IgniteProcess(
- "-jvmClasspath=" + TestUtils.CreateTestClasspath()
- );
-
- Assert.IsTrue(_grid.WaitTopology(2, 30000));
-
- var cfg = RemoteConfig();
-
- Assert.AreEqual(SpringCfgPath, cfg.SpringConfigUrl);
- Assert.IsTrue(cfg.JvmOptions.Contains("-DOPT1") && cfg.JvmOptions.Contains("-DOPT2"));
- Assert.IsTrue(cfg.Assemblies.Contains("test-1.dll") && cfg.Assemblies.Contains("test-2.dll"));
- Assert.AreEqual(601, cfg.JvmInitialMemoryMb);
- Assert.AreEqual(702, cfg.JvmMaxMemoryMb);
- }
-
- /// <summary>
- /// Test assemblies passing through command-line.
- /// </summary>
- [Test]
- public void TestAssemblyCmd()
- {
- GenerateDll("test-1.dll");
- GenerateDll("test-2.dll");
-
- var proc = new IgniteProcess(
- "-jvmClasspath=" + TestUtils.CreateTestClasspath(),
- "-springConfigUrl=" + SpringCfgPath,
- "-assembly=test-1.dll",
- "-assembly=test-2.dll"
- );
-
- Assert.IsTrue(_grid.WaitTopology(2, 30000));
-
- var cfg = RemoteConfig();
-
- Assert.IsTrue(cfg.Assemblies.Contains("test-1.dll") && cfg.Assemblies.Contains("test-2.dll"));
- }
-
- /// <summary>
- /// Test JVM options passing through command-line.
- /// </summary>
- [Test]
- public void TestJvmOptsCmd()
- {
- var proc = new IgniteProcess(
- "-jvmClasspath=" + TestUtils.CreateTestClasspath(),
- "-springConfigUrl=" + SpringCfgPath,
- "-J-DOPT1",
- "-J-DOPT2"
- );
-
- Assert.IsTrue(_grid.WaitTopology(2, 30000));
-
- var cfg = RemoteConfig();
-
- Assert.IsTrue(cfg.JvmOptions.Contains("-DOPT1") && cfg.JvmOptions.Contains("-DOPT2"));
- }
-
- /// <summary>
- /// Test JVM memory options passing through command-line: raw java options.
- /// </summary>
- [Test]
- public void TestJvmMemoryOptsCmdRaw()
- {
- var proc = new IgniteProcess(
- "-jvmClasspath=" + TestUtils.CreateTestClasspath(),
- "-springConfigUrl=" + SpringCfgPath,
- "-J-Xms506m",
- "-J-Xmx607m"
- );
-
- Assert.IsTrue(_grid.WaitTopology(2, 30000));
-
- var minMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MinMemTask, null);
- Assert.AreEqual((long) 506*1024*1024, minMem);
-
- var maxMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MaxMemTask, null);
- AssertJvmMaxMemory((long) 607*1024*1024, maxMem);
- }
-
- /// <summary>
- /// Test JVM memory options passing through command-line: custom options.
- /// </summary>
- [Test]
- public void TestJvmMemoryOptsCmdCustom()
- {
- var proc = new IgniteProcess(
- "-jvmClasspath=" + TestUtils.CreateTestClasspath(),
- "-springConfigUrl=" + SpringCfgPath,
- "-JvmInitialMemoryMB=615",
- "-JvmMaxMemoryMB=863"
- );
-
- Assert.IsTrue(_grid.WaitTopology(2, 30000));
-
- var minMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MinMemTask, null);
- Assert.AreEqual((long) 615*1024*1024, minMem);
-
- var maxMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MaxMemTask, null);
- AssertJvmMaxMemory((long) 863*1024*1024, maxMem);
- }
-
- /// <summary>
- /// Test JVM memory options passing from application configuration.
- /// </summary>
- [Test]
- public void TestJvmMemoryOptsAppConfig()
- {
- IgniteProcess.ReplaceConfiguration("config\\Apache.Ignite.exe.config.test");
-
- GenerateDll("test-1.dll");
- GenerateDll("test-2.dll");
-
- var proc = new IgniteProcess("-jvmClasspath=" + TestUtils.CreateTestClasspath());
-
- Assert.IsTrue(_grid.WaitTopology(2, 30000));
-
- var minMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MinMemTask, null);
- Assert.AreEqual((long) 601*1024*1024, minMem);
-
- var maxMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MaxMemTask, null);
- AssertJvmMaxMemory((long) 702*1024*1024, maxMem);
-
- proc.Kill();
-
- Assert.IsTrue(_grid.WaitTopology(1, 30000));
-
- // Command line options overwrite config file options
- // ReSharper disable once RedundantAssignment
- proc = new IgniteProcess("-jvmClasspath=" + TestUtils.CreateTestClasspath(),
- "-J-Xms605m", "-J-Xmx706m");
-
- Assert.IsTrue(_grid.WaitTopology(2, 30000));
-
- minMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MinMemTask, null);
- Assert.AreEqual((long) 605*1024*1024, minMem);
-
- maxMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MaxMemTask, null);
- AssertJvmMaxMemory((long) 706*1024*1024, maxMem);
- }
-
- /// <summary>
- /// Test JVM memory options passing through command-line: custom options + raw options.
- /// </summary>
- [Test]
- public void TestJvmMemoryOptsCmdCombined()
- {
- var proc = new IgniteProcess(
- "-jvmClasspath=" + TestUtils.CreateTestClasspath(),
- "-springConfigUrl=" + SpringCfgPath,
- "-J-Xms555m",
- "-J-Xmx666m",
- "-JvmInitialMemoryMB=128",
- "-JvmMaxMemoryMB=256"
- );
-
- Assert.IsTrue(_grid.WaitTopology(2, 30000));
-
- // Raw JVM options (Xms/Xmx) should override custom options
- var minMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MinMemTask, null);
- Assert.AreEqual((long) 555*1024*1024, minMem);
-
- var maxMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MaxMemTask, null);
- AssertJvmMaxMemory((long) 666*1024*1024, maxMem);
- }
-
- /// <summary>
- /// Get remote node configuration.
- /// </summary>
- /// <returns>Configuration.</returns>
- private RemoteConfiguration RemoteConfig()
- {
- return _grid.GetCluster().ForRemotes().GetCompute().Call(new RemoteConfigurationClosure());
- }
-
- /// <summary>
- /// Configuration for node.
- /// </summary>
- /// <param name="path">Path to Java XML configuration.</param>
- /// <returns>Node configuration.</returns>
- private static IgniteConfiguration Configuration(string path)
- {
- var cfg = new IgniteConfiguration();
-
-
- var portCfg = new PortableConfiguration();
-
- ICollection<PortableTypeConfiguration> portTypeCfgs = new List<PortableTypeConfiguration>();
-
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof (RemoteConfiguration)));
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof (RemoteConfigurationClosure)));
-
- portCfg.TypeConfigurations = portTypeCfgs;
-
- cfg.PortableConfiguration = portCfg;
-
- cfg.JvmClasspath = TestUtils.CreateTestClasspath();
-
- cfg.JvmOptions = new List<string>
- {
- "-ea",
- "-Xcheck:jni",
- "-Xms4g",
- "-Xmx4g",
- "-DIGNITE_QUIET=false",
- "-Xnoagent",
- "-Djava.compiler=NONE",
- "-Xdebug",
- "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005",
- "-XX:+HeapDumpOnOutOfMemoryError"
- };
-
- cfg.SpringConfigUrl = path;
-
- return cfg;
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="outputPath"></param>
- private static void GenerateDll(string outputPath)
- {
- var codeProvider = new CSharpCodeProvider();
-
-#pragma warning disable 0618
-
- var icc = codeProvider.CreateCompiler();
-
-#pragma warning restore 0618
-
- var parameters = new CompilerParameters();
- parameters.GenerateExecutable = false;
- parameters.OutputAssembly = outputPath;
-
- var src = "namespace Apache.Ignite.Client.Test { public class Foo {}}";
-
- var results = icc.CompileAssemblyFromSource(parameters, src);
-
- Assert.False(results.Errors.HasErrors);
- }
-
- /// <summary>
- /// Asserts that JVM maximum memory corresponds to Xmx parameter value.
- /// </summary>
- private static void AssertJvmMaxMemory(long expected, long actual)
- {
- // allow 20% tolerance because max memory in Java is not exactly equal to Xmx parameter value
- Assert.LessOrEqual(actual, expected);
- Assert.Greater(actual, expected/5*4);
- }
-
- /// <summary>
- /// Closure which extracts configuration and passes it back.
- /// </summary>
- public class RemoteConfigurationClosure : IComputeFunc<RemoteConfiguration>
- {
-
-#pragma warning disable 0649
-
- /** Grid. */
- [InstanceResource] private IIgnite _grid;
-
-#pragma warning restore 0649
-
- /** <inheritDoc /> */
-
- public RemoteConfiguration Invoke()
- {
- var grid0 = (Ignite) ((IgniteProxy) _grid).Target;
-
- var cfg = grid0.Configuration;
-
- var res = new RemoteConfiguration
- {
- IgniteHome = cfg.IgniteHome,
- SpringConfigUrl = cfg.SpringConfigUrl,
- JvmDll = cfg.JvmDllPath,
- JvmClasspath = cfg.JvmClasspath,
- JvmOptions = cfg.JvmOptions,
- Assemblies = cfg.Assemblies,
- JvmInitialMemoryMb = cfg.JvmInitialMemoryMb,
- JvmMaxMemoryMb = cfg.JvmMaxMemoryMb
- };
-
- Console.WriteLine("RETURNING CFG: " + cfg);
-
- return res;
- }
- }
-
- /// <summary>
- /// Configuration.
- /// </summary>
- public class RemoteConfiguration
- {
- /// <summary>
- /// GG home.
- /// </summary>
- public string IgniteHome { get; set; }
-
- /// <summary>
- /// Spring config URL.
- /// </summary>
- public string SpringConfigUrl { get; set; }
-
- /// <summary>
- /// JVM DLL.
- /// </summary>
- public string JvmDll { get; set; }
-
- /// <summary>
- /// JVM classpath.
- /// </summary>
- public string JvmClasspath { get; set; }
-
- /// <summary>
- /// JVM options.
- /// </summary>
- public ICollection<string> JvmOptions { get; set; }
-
- /// <summary>
- /// Assemblies.
- /// </summary>
- public ICollection<string> Assemblies { get; set; }
-
- /// <summary>
- /// Minimum JVM memory (Xms).
- /// </summary>
- public int JvmInitialMemoryMb { get; set; }
-
- /// <summary>
- /// Maximum JVM memory (Xms).
- /// </summary>
- public int JvmMaxMemoryMb { get; set; }
-
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
deleted file mode 100644
index 993c604..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests
-{
- using System;
- using System.Collections.Generic;
- using System.Threading;
- using Apache.Ignite.Core.Cache;
- using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Compute;
- using Apache.Ignite.Core.Portable;
- using NUnit.Framework;
-
- /// <summary>
- /// Future tests.
- /// </summary>
- public class FutureTest
- {
- /** */
- private ICache<object, object> _cache;
-
- /** */
- private ICompute _compute;
-
- /// <summary>
- /// Test fixture set-up routine.
- /// </summary>
- [TestFixtureSetUp]
- public void TestFixtureSetUp()
- {
- TestUtils.KillProcesses();
-
- var grid = Ignition.Start(new IgniteConfiguration
- {
- SpringConfigUrl = "config\\compute\\compute-standalone.xml",
- JvmClasspath = TestUtils.CreateTestClasspath(),
- JvmOptions = TestUtils.TestJavaOptions(),
- PortableConfiguration = new PortableConfiguration
- {
- TypeConfigurations =
- new List<PortableTypeConfiguration> { new PortableTypeConfiguration(typeof(Portable)) }
- }
- });
-
- _cache = grid.GetCache<object, object>(null).WithAsync();
-
- _compute = grid.GetCompute().WithAsync();
- }
-
- /// <summary>
- /// Test fixture tear-down routine.
- /// </summary>
- [TestFixtureTearDown]
- public void TestFixtureTearDown()
- {
- TestUtils.KillProcesses();
- }
-
- [Test]
- public void TestListen()
- {
- // Listen(Action callback)
- TestListen((fut, act) => fut.Listen(act));
-
- // Listen(Action<IFuture> callback)
- TestListen((fut, act) => ((IFuture)fut).Listen(f =>
- {
- Assert.AreEqual(f, fut);
- act();
- }));
-
- // Listen(Action<IFuture<T>> callback)
- TestListen((fut, act) => fut.Listen(f =>
- {
- Assert.AreEqual(f, fut);
- act();
- }));
- }
-
- private void TestListen(Action<IFuture<object>, Action> listenAction)
- {
- _compute.Broadcast(new SleepAction());
-
- var fut = _compute.GetFuture<object>();
-
- var listenCount = 0;
-
- // Multiple subscribers before completion
- for (var i = 0; i < 10; i++)
- listenAction(fut, () => Interlocked.Increment(ref listenCount));
-
- Assert.IsFalse(fut.IsDone);
-
- Assert.IsNull(fut.Get());
-
- Thread.Sleep(100); // wait for future completion thread
-
- Assert.AreEqual(10, listenCount);
-
- // Multiple subscribers after completion
- for (var i = 0; i < 10; i++)
- listenAction(fut, () => Interlocked.Decrement(ref listenCount));
-
- Assert.AreEqual(0, listenCount);
- }
-
- [Test]
- public void TestToTask()
- {
- _cache.Put(1, 1);
-
- _cache.GetFuture().ToTask().Wait();
-
- _cache.Get(1);
-
- var task1 = _cache.GetFuture<int>().ToTask();
-
- Assert.AreEqual(1, task1.Result);
-
- Assert.IsTrue(task1.IsCompleted);
-
- _compute.Broadcast(new SleepAction());
-
- var task2 = _compute.GetFuture().ToTask();
-
- Assert.IsFalse(task2.IsCompleted);
-
- Assert.IsFalse(task2.Wait(100));
-
- task2.Wait();
-
- Assert.IsTrue(task2.IsCompleted);
-
- Assert.AreEqual(null, task2.Result);
- }
-
- [Test]
- public void TestGetWithTimeout()
- {
- _compute.Broadcast(new SleepAction());
-
- var fut = _compute.GetFuture();
-
- Assert.Throws<TimeoutException>(() => fut.Get(TimeSpan.FromMilliseconds(100)));
-
- fut.Get(TimeSpan.FromSeconds(1));
-
- Assert.IsTrue(fut.IsDone);
- }
-
- [Test]
- public void TestToAsyncResult()
- {
- _compute.Broadcast(new SleepAction());
-
- IFuture fut = _compute.GetFuture();
-
- var asyncRes = fut.ToAsyncResult();
-
- Assert.IsFalse(asyncRes.IsCompleted);
-
- Assert.IsTrue(asyncRes.AsyncWaitHandle.WaitOne(1000));
-
- Assert.IsTrue(asyncRes.IsCompleted);
- }
-
- [Test]
- public void TestFutureTypes()
- {
- TestType(false);
- TestType((byte)11);
- TestType('x'); // char
- TestType(2.7d); // double
- TestType(3.14f); // float
- TestType(16); // int
- TestType(17L); // long
- TestType((short)18);
-
- TestType(18m); // decimal
-
- TestType(new Portable { A = 10, B = "foo" });
- }
-
- /// <summary>
- /// Tests future type.
- /// </summary>
- private void TestType<T>(T value)
- {
- var key = typeof(T).Name;
-
- _cache.Put(key, value);
-
- _cache.GetFuture().Get();
-
- _cache.Get(key);
-
- Assert.AreEqual(value, _cache.GetFuture<T>().Get());
- }
-
- /// <summary>
- /// Portable test class.
- /// </summary>
- private class Portable : IPortableMarshalAware
- {
- public int A;
- public string B;
-
- /** <inheritDoc /> */
- public void WritePortable(IPortableWriter writer)
- {
- writer.WriteInt("a", A);
- writer.RawWriter().WriteString(B);
- }
-
- /** <inheritDoc /> */
- public void ReadPortable(IPortableReader reader)
- {
- A = reader.ReadInt("a");
- B = reader.RawReader().ReadString();
- }
-
- /** <inheritDoc /> */
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj))
- return false;
-
- if (ReferenceEquals(this, obj))
- return true;
-
- if (obj.GetType() != GetType())
- return false;
-
- var other = (Portable)obj;
-
- return A == other.A && string.Equals(B, other.B);
- }
-
- /** <inheritDoc /> */
- public override int GetHashCode()
- {
- unchecked
- {
- // ReSharper disable NonReadonlyMemberInGetHashCode
- return (A * 397) ^ (B != null ? B.GetHashCode() : 0);
- // ReSharper restore NonReadonlyMemberInGetHashCode
- }
- }
- }
-
- /// <summary>
- /// Compute action with a delay to ensure lengthy future execution.
- /// </summary>
- [Serializable]
- private class SleepAction : IComputeAction
- {
- public void Invoke()
- {
- Thread.Sleep(500);
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/IgniteManagerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/IgniteManagerTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/IgniteManagerTest.cs
deleted file mode 100644
index 5a90c20..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/IgniteManagerTest.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests
-{
- using System;
- using System.IO;
- using Apache.Ignite.Core.Impl;
- using NUnit.Framework;
-
- /// <summary>
- /// Tests IgniteManager class.
- /// </summary>
- public class IgniteManagerTest
- {
- /// <summary>
- /// Tests home dir resolver.
- /// </summary>
- [Test]
- public void TestIgniteHome()
- {
- var env = Environment.GetEnvironmentVariable(IgniteManager.EnvIgniteHome);
-
- Environment.SetEnvironmentVariable(IgniteManager.EnvIgniteHome, null);
-
- try
- {
- Assert.IsTrue(Directory.Exists(IgniteManager.GetIgniteHome(null)));
- }
- finally
- {
- // Restore
- Environment.SetEnvironmentVariable(IgniteManager.EnvIgniteHome, env);
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
deleted file mode 100644
index bd776ce..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
+++ /dev/null
@@ -1,422 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests
-{
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Threading;
- using System.Threading.Tasks;
- using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Messaging;
- using Apache.Ignite.Core.Tests.Process;
- using NUnit.Framework;
-
- /// <summary>
- /// Ignite start/stop tests.
- /// </summary>
- [Category(TestUtils.CategoryIntensive)]
- public class IgniteStartStopTest
- {
- /// <summary>
- ///
- /// </summary>
- [SetUp]
- public void SetUp()
- {
- TestUtils.KillProcesses();
- }
-
- /// <summary>
- ///
- /// </summary>
- [TearDown]
- public void TearDown()
- {
- TestUtils.KillProcesses();
- Ignition.StopAll(true);
- }
-
- /// <summary>
- ///
- /// </summary>
- [Test]
- public void TestStartDefault()
- {
- var cfg = new IgniteConfiguration {JvmClasspath = TestUtils.CreateTestClasspath()};
-
- var grid = Ignition.Start(cfg);
-
- Assert.IsNotNull(grid);
-
- Assert.AreEqual(1, grid.GetCluster().GetNodes().Count);
- }
-
- /// <summary>
- ///
- /// </summary>
- [Test]
- public void TestStartWithConfigPath()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = "config/default-config.xml",
- JvmClasspath = TestUtils.CreateTestClasspath()
- };
-
- var grid = Ignition.Start(cfg);
-
- Assert.IsNotNull(grid);
-
- Assert.AreEqual(1, grid.GetCluster().GetNodes().Count);
- }
-
- /// <summary>
- ///
- /// </summary>
- [Test]
- public void TestStartGetStop()
- {
- var cfgs = new List<string> { "config\\start-test-grid1.xml", "config\\start-test-grid2.xml", "config\\start-test-grid3.xml" };
-
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = cfgs[0],
- JvmOptions = TestUtils.TestJavaOptions(),
- JvmClasspath = TestUtils.CreateTestClasspath()
- };
-
- var grid1 = Ignition.Start(cfg);
-
- Assert.AreEqual("grid1", grid1.Name);
-
- cfg.SpringConfigUrl = cfgs[1];
-
- var grid2 = Ignition.Start(cfg);
-
- Assert.AreEqual("grid2", grid2.Name);
-
- cfg.SpringConfigUrl = cfgs[2];
-
- var grid3 = Ignition.Start(cfg);
-
- Assert.IsNull(grid3.Name);
-
- Assert.AreSame(grid1, Ignition.GetIgnite("grid1"));
-
- Assert.AreSame(grid2, Ignition.GetIgnite("grid2"));
-
- Assert.AreSame(grid3, Ignition.GetIgnite(null));
-
- try
- {
- Ignition.GetIgnite("invalid_name");
- }
- catch (IgniteException e)
- {
- Console.WriteLine("Expected exception: " + e);
- }
-
- Assert.IsTrue(Ignition.Stop("grid1", true));
-
- try
- {
- Ignition.GetIgnite("grid1");
- }
- catch (IgniteException e)
- {
- Console.WriteLine("Expected exception: " + e);
- }
-
- grid2.Dispose();
-
- try
- {
- Ignition.GetIgnite("grid2");
- }
- catch (IgniteException e)
- {
- Console.WriteLine("Expected exception: " + e);
- }
-
- grid3.Dispose();
-
- try
- {
- Ignition.GetIgnite(null);
- }
- catch (IgniteException e)
- {
- Console.WriteLine("Expected exception: " + e);
- }
-
- foreach (var cfgName in cfgs)
- {
- cfg.SpringConfigUrl = cfgName;
- cfg.JvmOptions = TestUtils.TestJavaOptions();
-
- Ignition.Start(cfg);
- }
-
- foreach (var gridName in new List<string> { "grid1", "grid2", null })
- Assert.IsNotNull(Ignition.GetIgnite(gridName));
-
- Ignition.StopAll(true);
-
- foreach (var gridName in new List<string> { "grid1", "grid2", null })
- {
- try
- {
- Ignition.GetIgnite(gridName);
- }
- catch (IgniteException e)
- {
- Console.WriteLine("Expected exception: " + e);
- }
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- [Test]
- public void TestStartTheSameName()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = "config\\start-test-grid1.xml",
- JvmOptions = TestUtils.TestJavaOptions(),
- JvmClasspath = TestUtils.CreateTestClasspath()
- };
-
- var grid1 = Ignition.Start(cfg);
-
- Assert.AreEqual("grid1", grid1.Name);
-
- try
- {
- Ignition.Start(cfg);
-
- Assert.Fail("Start should fail.");
- }
- catch (IgniteException e)
- {
- Console.WriteLine("Expected exception: " + e);
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- [Test]
- public void TestUsageAfterStop()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = "config\\start-test-grid1.xml",
- JvmOptions = TestUtils.TestJavaOptions(),
- JvmClasspath = TestUtils.CreateTestClasspath()
- };
-
- var grid = Ignition.Start(cfg);
-
- Assert.IsNotNull(grid.GetCache<int, int>("cache1"));
-
- grid.Dispose();
-
- try
- {
- grid.GetCache<int, int>("cache1");
-
- Assert.Fail();
- }
- catch (InvalidOperationException e)
- {
- Console.WriteLine("Expected exception: " + e);
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- [Test]
- public void TestStartStopLeak()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = "config\\start-test-grid1.xml",
- JvmOptions = new List<string> {"-Xcheck:jni", "-Xms256m", "-Xmx256m", "-XX:+HeapDumpOnOutOfMemoryError"},
- JvmClasspath = TestUtils.CreateTestClasspath()
- };
-
- for (var i = 0; i < 20; i++)
- {
- Console.WriteLine("Iteration: " + i);
-
- var grid = Ignition.Start(cfg);
-
- UseIgnite(grid);
-
- if (i % 2 == 0) // Try to stop ignite from another thread.
- {
- var t = new Thread(() => {
- grid.Dispose();
- });
-
- t.Start();
-
- t.Join();
- }
- else
- grid.Dispose();
-
- GC.Collect(); // At the time of writing java references are cleaned from finalizer, so GC is needed.
- }
- }
-
- /// <summary>
- /// Tests the client mode flag.
- /// </summary>
- [Test]
- public void TestClientMode()
- {
- var servCfg = new IgniteConfiguration
- {
- SpringConfigUrl = "config\\start-test-grid1.xml",
- JvmOptions = TestUtils.TestJavaOptions(),
- JvmClasspath = TestUtils.CreateTestClasspath()
- };
-
- var clientCfg = new IgniteConfiguration
- {
- SpringConfigUrl = "config\\start-test-grid2.xml",
- JvmOptions = TestUtils.TestJavaOptions(),
- JvmClasspath = TestUtils.CreateTestClasspath()
- };
-
- try
- {
- using (Ignition.Start(servCfg)) // start server-mode ignite first
- {
- Ignition.ClientMode = true;
-
- using (var grid = Ignition.Start(clientCfg))
- {
- UseIgnite(grid);
- }
- }
- }
- finally
- {
- Ignition.ClientMode = false;
- }
- }
-
- /// <summary>
- /// Uses the ignite.
- /// </summary>
- /// <param name="ignite">The ignite.</param>
- private static void UseIgnite(IIgnite ignite)
- {
- // Create objects holding references to java objects.
- var comp = ignite.GetCompute();
-
- // ReSharper disable once RedundantAssignment
- comp = comp.WithKeepPortable();
-
- var prj = ignite.GetCluster().ForOldest();
-
- Assert.IsTrue(prj.GetNodes().Count > 0);
-
- Assert.IsNotNull(prj.GetCompute());
-
- var cache = ignite.GetCache<int, int>("cache1");
-
- Assert.IsNotNull(cache);
-
- cache.GetAndPut(1, 1);
-
- Assert.AreEqual(1, cache.Get(1));
- }
-
- /// <summary>
- /// Tests the processor initialization and grid usage right after topology enter.
- /// </summary>
- [Test]
- public void TestProcessorInit()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = "config\\start-test-grid1.xml",
- JvmOptions = TestUtils.TestJavaOptions(),
- JvmClasspath = TestUtils.CreateTestClasspath()
- };
-
- // Start local node
- var grid = Ignition.Start(cfg);
-
- // Start remote node in a separate process
- // ReSharper disable once UnusedVariable
- var proc = new IgniteProcess(
- "-jvmClasspath=" + TestUtils.CreateTestClasspath(),
- "-springConfigUrl=" + Path.GetFullPath(cfg.SpringConfigUrl),
- "-J-Xms512m", "-J-Xmx512m");
-
- var cts = new CancellationTokenSource();
- var token = cts.Token;
-
- // Spam message subscriptions on a separate thread
- // to test race conditions during processor init on remote node
- var listenTask = Task.Factory.StartNew(() =>
- {
- var filter = new MessageFilter();
-
- while (!token.IsCancellationRequested)
- {
- var listenId = grid.GetMessaging().RemoteListen(filter);
-
- grid.GetMessaging().StopRemoteListen(listenId);
- }
- // ReSharper disable once FunctionNeverReturns
- });
-
- // Wait for remote node to join
- Assert.IsTrue(grid.WaitTopology(2, 30000));
-
- // Wait some more for initialization
- Thread.Sleep(1000);
-
- // Cancel listen task and check that it finishes
- cts.Cancel();
- Assert.IsTrue(listenTask.Wait(5000));
- }
-
- /// <summary>
- /// Noop message filter.
- /// </summary>
- [Serializable]
- private class MessageFilter : IMessageFilter<int>
- {
- /** <inheritdoc /> */
- public bool Invoke(Guid nodeId, int message)
- {
- return true;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/LifecycleTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/LifecycleTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/LifecycleTest.cs
deleted file mode 100644
index 84f446c..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/LifecycleTest.cs
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests
-{
- using System;
- using System.Collections.Generic;
- using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Impl;
- using Apache.Ignite.Core.Lifecycle;
- using Apache.Ignite.Core.Resource;
- using NUnit.Framework;
-
- /// <summary>
- /// Lifecycle beans test.
- /// </summary>
- public class LifecycleTest
- {
- /** Configuration: without Java beans. */
- private const string CfgNoBeans = "config//lifecycle//lifecycle-no-beans.xml";
-
- /** Configuration: with Java beans. */
- private const string CfgBeans = "config//lifecycle//lifecycle-beans.xml";
-
- /** Whether to throw an error on lifecycle event. */
- internal static bool ThrowErr;
-
- /** Events: before start. */
- internal static IList<Event> BeforeStartEvts;
-
- /** Events: after start. */
- internal static IList<Event> AfterStartEvts;
-
- /** Events: before stop. */
- internal static IList<Event> BeforeStopEvts;
-
- /** Events: after stop. */
- internal static IList<Event> AfterStopEvts;
-
- /// <summary>
- /// Set up routine.
- /// </summary>
- [SetUp]
- public void SetUp()
- {
- ThrowErr = false;
-
- BeforeStartEvts = new List<Event>();
- AfterStartEvts = new List<Event>();
- BeforeStopEvts = new List<Event>();
- AfterStopEvts = new List<Event>();
- }
-
- /// <summary>
- /// Tear down routine.
- /// </summary>
- [TearDown]
- public void TearDown()
- {
- Ignition.StopAll(true);
- }
-
- /// <summary>
- /// Test without Java beans.
- /// </summary>
- [Test]
- public void TestWithoutBeans()
- {
- // 1. Test start events.
- IIgnite grid = Start(CfgNoBeans);
-
- Assert.AreEqual(2, BeforeStartEvts.Count);
- CheckEvent(BeforeStartEvts[0], null, null, 0, null);
- CheckEvent(BeforeStartEvts[1], null, null, 0, null);
-
- Assert.AreEqual(2, AfterStartEvts.Count);
- CheckEvent(AfterStartEvts[0], grid, grid, 0, null);
- CheckEvent(AfterStartEvts[1], grid, grid, 0, null);
-
- // 2. Test stop events.
- Ignition.Stop(grid.Name, false);
-
- Assert.AreEqual(2, BeforeStartEvts.Count);
- Assert.AreEqual(2, AfterStartEvts.Count);
-
- Assert.AreEqual(2, BeforeStopEvts.Count);
- CheckEvent(BeforeStopEvts[0], grid, grid, 0, null);
- CheckEvent(BeforeStopEvts[1], grid, grid, 0, null);
-
- Assert.AreEqual(2, AfterStopEvts.Count);
- CheckEvent(AfterStopEvts[0], grid, grid, 0, null);
- CheckEvent(AfterStopEvts[1], grid, grid, 0, null);
- }
-
- /// <summary>
- /// Test with Java beans.
- /// </summary>
- [Test]
- public void TestWithBeans()
- {
- // 1. Test .Net start events.
- IIgnite grid = Start(CfgBeans);
-
- Assert.AreEqual(4, BeforeStartEvts.Count);
- CheckEvent(BeforeStartEvts[0], null, null, 0, null);
- CheckEvent(BeforeStartEvts[1], null, null, 1, "1");
- CheckEvent(BeforeStartEvts[2], null, null, 0, null);
- CheckEvent(BeforeStartEvts[3], null, null, 0, null);
-
- Assert.AreEqual(4, AfterStartEvts.Count);
- CheckEvent(AfterStartEvts[0], grid, grid, 0, null);
- CheckEvent(AfterStartEvts[1], grid, grid, 1, "1");
- CheckEvent(AfterStartEvts[2], grid, grid, 0, null);
- CheckEvent(AfterStartEvts[3], grid, grid, 0, null);
-
- // 2. Test Java start events.
- IList<int> res = grid.GetCompute().ExecuteJavaTask<IList<int>>(
- "org.apache.ignite.platform.lifecycle.PlatformJavaLifecycleTask", null);
-
- Assert.AreEqual(2, res.Count);
- Assert.AreEqual(3, res[0]);
- Assert.AreEqual(3, res[1]);
-
- // 3. Test .Net stop events.
- Ignition.Stop(grid.Name, false);
-
- Assert.AreEqual(4, BeforeStartEvts.Count);
- Assert.AreEqual(4, AfterStartEvts.Count);
-
- Assert.AreEqual(4, BeforeStopEvts.Count);
- CheckEvent(BeforeStopEvts[0], grid, grid, 0, null);
- CheckEvent(BeforeStopEvts[1], grid, grid, 1, "1");
- CheckEvent(BeforeStopEvts[2], grid, grid, 0, null);
- CheckEvent(BeforeStopEvts[3], grid, grid, 0, null);
-
- Assert.AreEqual(4, AfterStopEvts.Count);
- CheckEvent(AfterStopEvts[0], grid, grid, 0, null);
- CheckEvent(AfterStopEvts[1], grid, grid, 1, "1");
- CheckEvent(AfterStopEvts[2], grid, grid, 0, null);
- CheckEvent(AfterStopEvts[3], grid, grid, 0, null);
- }
-
- /// <summary>
- /// Test behavior when error is thrown from lifecycle beans.
- /// </summary>
- [Test]
- public void TestError()
- {
- ThrowErr = true;
-
- try
- {
- Start(CfgNoBeans);
-
- Assert.Fail("Should not reach this place.");
- }
- catch (Exception e)
- {
- Assert.AreEqual(typeof(IgniteException), e.GetType());
- }
- }
-
- /// <summary>
- /// Start grid.
- /// </summary>
- /// <param name="cfgPath">Spring configuration path.</param>
- /// <returns>Grid.</returns>
- private static IIgnite Start(string cfgPath)
- {
- TestUtils.JvmDebug = true;
-
- IgniteConfiguration cfg = new IgniteConfiguration();
-
- cfg.JvmClasspath = TestUtils.CreateTestClasspath();
- cfg.JvmOptions = TestUtils.TestJavaOptions();
- cfg.SpringConfigUrl = cfgPath;
-
- cfg.LifecycleBeans = new List<ILifecycleBean> { new Bean(), new Bean() };
-
- return Ignition.Start(cfg);
- }
-
- /// <summary>
- /// Check event.
- /// </summary>
- /// <param name="evt">Event.</param>
- /// <param name="expGrid1">Expected grid 1.</param>
- /// <param name="expGrid2">Expected grid 2.</param>
- /// <param name="expProp1">Expected property 1.</param>
- /// <param name="expProp2">Expected property 2.</param>
- private static void CheckEvent(Event evt, IIgnite expGrid1, IIgnite expGrid2, int expProp1, string expProp2)
- {
- if (evt.Grid1 != null && evt.Grid1 is IgniteProxy)
- evt.Grid1 = (evt.Grid1 as IgniteProxy).Target;
-
- if (evt.Grid2 != null && evt.Grid2 is IgniteProxy)
- evt.Grid2 = (evt.Grid2 as IgniteProxy).Target;
-
- Assert.AreEqual(expGrid1, evt.Grid1);
- Assert.AreEqual(expGrid2, evt.Grid2);
- Assert.AreEqual(expProp1, evt.Prop1);
- Assert.AreEqual(expProp2, evt.Prop2);
- }
- }
-
- public abstract class AbstractBean
- {
- [InstanceResource]
- public IIgnite Grid1;
-
- public int Property1
- {
- get;
- set;
- }
- }
-
- public class Bean : AbstractBean, ILifecycleBean
- {
- [InstanceResource]
- public IIgnite Grid2;
-
- public string Property2
- {
- get;
- set;
- }
-
- /** <inheritDoc /> */
- public void OnLifecycleEvent(LifecycleEventType evtType)
- {
- if (LifecycleTest.ThrowErr)
- throw new Exception("Lifecycle exception.");
-
- Event evt = new Event();
-
- evt.Grid1 = Grid1;
- evt.Grid2 = Grid2;
- evt.Prop1 = Property1;
- evt.Prop2 = Property2;
-
- switch (evtType)
- {
- case LifecycleEventType.BeforeNodeStart:
- LifecycleTest.BeforeStartEvts.Add(evt);
-
- break;
-
- case LifecycleEventType.AfterNodeStart:
- LifecycleTest.AfterStartEvts.Add(evt);
-
- break;
-
- case LifecycleEventType.BeforeNodeStop:
- LifecycleTest.BeforeStopEvts.Add(evt);
-
- break;
-
- case LifecycleEventType.AfterNodeStop:
- LifecycleTest.AfterStopEvts.Add(evt);
-
- break;
- }
- }
- }
-
- public class Event
- {
- public IIgnite Grid1;
- public IIgnite Grid2;
- public int Prop1;
- public string Prop2;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/LoadDllTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/LoadDllTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/LoadDllTest.cs
deleted file mode 100644
index 25ffab3..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/LoadDllTest.cs
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests
-{
- using System;
- using System.CodeDom.Compiler;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using Apache.Ignite.Core.Common;
- using Microsoft.CSharp;
- using NUnit.Framework;
-
- /// <summary>
- /// Dll loading test.
- /// </summary>
- public class LoadDllTest
- {
- /// <summary>
- ///
- /// </summary>
- [SetUp]
- public void SetUp()
- {
- TestUtils.KillProcesses();
- }
-
- /// <summary>
- ///
- /// </summary>
- [TearDown]
- public void TearDown()
- {
- Ignition.StopAll(true);
- }
-
- /// <summary>
- ///
- /// </summary>
- [Test]
- public void TestLoadFromGac()
- {
- Assert.False(IsLoaded("System.Data.Linq"));
-
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = "config\\start-test-grid3.xml",
- Assemblies =
- new List<string>
- {
- "System.Data.Linq,Culture=neutral,Version=1.0.0.0,PublicKeyToken=b77a5c561934e089"
- },
- JvmClasspath = TestUtils.CreateTestClasspath()
- };
-
-
- var grid = Ignition.Start(cfg);
-
- Assert.IsNotNull(grid);
-
- Assert.True(IsLoaded("System.Data.Linq"));
- }
-
- /// <summary>
- ///
- /// </summary>
- [Test]
- public void TestLoadFromCurrentDir()
- {
- Assert.False(IsLoaded("testDll"));
-
- GenerateDll("testDll.dll");
-
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = "config\\start-test-grid3.xml",
- Assemblies = new List<string> {"testDll.dll"},
- JvmClasspath = TestUtils.CreateTestClasspath()
- };
-
- var grid = Ignition.Start(cfg);
-
- Assert.IsNotNull(grid);
-
- Assert.True(IsLoaded("testDll"));
- }
-
- /// <summary>
- ///
- /// </summary>
- [Test]
- public void TestLoadAllDllInDir()
- {
- var dirInfo = Directory.CreateDirectory(Path.GetTempPath() + "/testDlls");
-
- Assert.False(IsLoaded("dllFromDir1"));
- Assert.False(IsLoaded("dllFromDir2"));
-
- GenerateDll(dirInfo.FullName + "/dllFromDir1.dll");
- GenerateDll(dirInfo.FullName + "/dllFromDir2.dll");
- File.WriteAllText(dirInfo.FullName + "/notADll.txt", "notADll");
-
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = "config\\start-test-grid3.xml",
- Assemblies = new List<string> {dirInfo.FullName},
- JvmClasspath = TestUtils.CreateTestClasspath()
- };
-
- var grid = Ignition.Start(cfg);
-
- Assert.IsNotNull(grid);
-
- Assert.True(IsLoaded("dllFromDir1"));
- Assert.True(IsLoaded("dllFromDir2"));
- }
-
- /// <summary>
- ///
- /// </summary>
- [Test]
- public void TestLoadFromCurrentDirByName()
- {
- Assert.False(IsLoaded("testDllByName"));
-
- GenerateDll("testDllByName.dll");
-
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = "config\\start-test-grid3.xml",
- Assemblies = new List<string> {"testDllByName"},
- JvmClasspath = TestUtils.CreateTestClasspath()
- };
-
- var grid = Ignition.Start(cfg);
-
- Assert.IsNotNull(grid);
-
- Assert.True(IsLoaded("testDllByName"));
- }
-
- /// <summary>
- ///
- /// </summary>
- [Test]
- public void TestLoadByAbsoluteUri()
- {
- var dllPath = Path.GetTempPath() + "/tempDll.dll";
- Assert.False(IsLoaded("tempDll"));
-
- GenerateDll(dllPath);
-
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = "config\\start-test-grid3.xml",
- Assemblies = new List<string> {dllPath},
- JvmClasspath = TestUtils.CreateTestClasspath()
- };
-
- var grid = Ignition.Start(cfg);
-
- Assert.IsNotNull(grid);
-
- Assert.True(IsLoaded("tempDll"));
- }
-
- /// <summary>
- ///
- /// </summary>
- [Test]
- public void TestLoadUnexistingLibrary()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = "config\\start-test-grid3.xml",
- Assemblies = new List<string> {"unexistingAssembly.820482.dll"},
- JvmClasspath = TestUtils.CreateTestClasspath()
- };
-
- try
- {
- Ignition.Start(cfg);
-
- Assert.Fail("Grid has been started with broken configuration.");
- }
- catch (IgniteException)
- {
-
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="outputPath"></param>
- private void GenerateDll(string outputPath)
- {
- var codeProvider = new CSharpCodeProvider();
-
-#pragma warning disable 0618
-
- var icc = codeProvider.CreateCompiler();
-
-#pragma warning restore 0618
-
- var parameters = new CompilerParameters
- {
- GenerateExecutable = false,
- OutputAssembly = outputPath
- };
-
- var src = "namespace Apache.Ignite.Client.Test { public class Foo {}}";
-
- var results = icc.CompileAssemblyFromSource(parameters, src);
-
- Assert.False(results.Errors.HasErrors);
- }
-
- /// <summary>
- /// Determines whether the specified assembly is loaded.
- /// </summary>
- /// <param name="asmName">Name of the assembly.</param>
- private static bool IsLoaded(string asmName)
- {
- return AppDomain.CurrentDomain.GetAssemblies().Any(a => a.GetName().Name == asmName);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
deleted file mode 100644
index d3af288..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests
-{
- using Apache.Ignite.Core.Common;
- using NUnit.Framework;
-
- /// <summary>
- /// Test marshaller initialization.
- /// </summary>
- public class MarshallerTest
- {
- /// <summary>
- /// Tests the default marhsaller.
- /// By default, portable marshaller is used.
- /// </summary>
- [Test]
- public void TestDefaultMarhsaller()
- {
- using (var grid = Ignition.Start("config\\marshaller-default.xml"))
- {
- var cache = grid.GetOrCreateCache<int, int>(null);
-
- cache.Put(1, 1);
-
- Assert.AreEqual(1, cache.Get(1));
- }
- }
-
- /// <summary>
- /// Tests the portable marhsaller.
- /// PortableMarshaller can be specified explicitly in config.
- /// </summary>
- [Test]
- public void TestPortableMarhsaller()
- {
- using (var grid = Ignition.Start("config\\marshaller-portable.xml"))
- {
- var cache = grid.GetOrCreateCache<int, int>(null);
-
- cache.Put(1, 1);
-
- Assert.AreEqual(1, cache.Get(1));
- }
- }
-
- /// <summary>
- /// Tests the invalid marshaller.
- /// </summary>
- [Test]
- public void TestInvalidMarshaller()
- {
- Assert.Throws<IgniteException>(() => Ignition.Start("config\\marshaller-invalid.xml"));
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Memory/InteropMemoryTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Memory/InteropMemoryTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Memory/InteropMemoryTest.cs
deleted file mode 100644
index e32e622..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Memory/InteropMemoryTest.cs
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Memory
-{
- using System;
- using Apache.Ignite.Core.Impl.Memory;
- using NUnit.Framework;
-
- /// <summary>
- /// Tests for interop memory.
- /// </summary>
- public class InteropMemoryTest
- {
- /// <summary>
- /// Test pooled memory.
- /// </summary>
- [Test]
- public void TestPooled()
- {
- PlatformMemoryManager mgr = new PlatformMemoryManager(256);
-
- var mem1 = mgr.Allocate();
- Assert.IsTrue(mem1 is PlatformPooledMemory);
- Assert.IsTrue(mem1.Capacity >= 256);
- Assert.IsTrue(mem1.Pointer > 0);
- Assert.IsTrue(mem1.Data > 0);
- Assert.AreEqual(0, mem1.Length);
-
- mem1.Reallocate(512);
-
- Assert.IsTrue(mem1.Capacity >= 512);
- Assert.IsTrue(mem1.Pointer > 0);
- Assert.IsTrue(mem1.Data > 0);
- Assert.AreEqual(0, mem1.Length);
-
- mem1.Length = 128;
- Assert.AreEqual(128, mem1.Length);
-
- mem1.Release();
-
- Assert.AreSame(mem1, mgr.Allocate());
- Assert.IsTrue(mem1.Capacity >= 512);
- Assert.IsTrue(mem1.Pointer > 0);
- Assert.IsTrue(mem1.Data > 0);
- Assert.AreEqual(128, mem1.Length);
-
- IPlatformMemory mem2 = mgr.Allocate();
- Assert.IsTrue(mem2 is PlatformPooledMemory);
-
- IPlatformMemory mem3 = mgr.Allocate();
- Assert.IsTrue(mem3 is PlatformPooledMemory);
-
- mem1.Release();
- Assert.AreSame(mem1, mgr.Allocate());
-
- mem2.Release();
- Assert.AreSame(mem2, mgr.Allocate());
-
- mem3.Release();
- Assert.AreSame(mem3, mgr.Allocate());
-
- mem1.Release();
- mem2.Release();
-
- Assert.AreSame(mem1, mgr.Allocate());
- Assert.AreSame(mem2, mgr.Allocate());
-
- IPlatformMemory unpooled = mgr.Allocate();
-
- try
- {
- Assert.IsTrue(unpooled is PlatformUnpooledMemory);
- }
- finally
- {
- unpooled.Release();
- }
- }
-
- /// <summary>
- /// Test unpooled memory.
- /// </summary>
- [Test]
- public void TestUnpooled()
- {
- PlatformMemoryManager mgr = new PlatformMemoryManager(256);
-
- for (int i = 0; i < 3; i++)
- mgr.Allocate();
-
- IPlatformMemory mem1 = mgr.Allocate();
- Assert.IsTrue(mem1 is PlatformUnpooledMemory);
- Assert.IsTrue(mem1.Capacity >= 256);
- Assert.IsTrue(mem1.Pointer > 0);
- Assert.IsTrue(mem1.Data > 0);
- Assert.AreEqual(0, mem1.Length);
-
- mem1.Reallocate(512);
- Assert.IsTrue(mem1.Capacity >= 512);
- Assert.IsTrue(mem1.Pointer > 0);
- Assert.IsTrue(mem1.Data > 0);
- Assert.AreEqual(0, mem1.Length);
-
- mem1.Length = 128;
- Assert.AreEqual(128, mem1.Length);
-
- mem1.Release();
-
- IPlatformMemory mem2 = mgr.Allocate();
- Assert.AreNotSame(mem1, mem2);
- Assert.IsTrue(mem2.Capacity >= 256);
- Assert.IsTrue(mem2.Pointer > 0);
- Assert.IsTrue(mem2.Data > 0);
- Assert.AreEqual(0, mem2.Length);
-
- mem2.Release();
- }
-
- /// <summary>
- /// Test pooled memory stream reallocation initiated from stream.
- /// </summary>
- [Test]
- public void TestPooledStreamReallocate()
- {
- IPlatformMemory mem = new PlatformMemoryManager(256).Allocate();
-
- try
- {
- Assert.IsTrue(mem is PlatformPooledMemory);
-
- CheckStreamReallocate(mem);
- }
- finally
- {
- mem.Release();
- }
- }
-
- /// <summary>
- /// Test unpooled memory stream reallocation initiated from stream.
- /// </summary>
- [Test]
- public void TestUnpooledStreamReallocate()
- {
- PlatformMemoryManager mgr = new PlatformMemoryManager(256);
-
- for (int i = 0; i < 3; i++)
- mgr.Allocate();
-
- IPlatformMemory mem = mgr.Allocate();
-
- try
- {
- Assert.IsTrue(mem is PlatformUnpooledMemory);
-
- CheckStreamReallocate(mem);
- }
- finally
- {
- mem.Release();
- }
- }
-
- /// <summary>
- /// Check stream reallocation.
- /// </summary>
- /// <param name="mem">Memory.</param>
- private void CheckStreamReallocate(IPlatformMemory mem)
- {
- Assert.IsTrue(mem.Capacity >= 256);
-
- int dataLen = 2048 + 13;
-
- Random rand = new Random();
-
- byte[] data = new byte[dataLen];
-
- for (int i = 0; i < data.Length; i++)
- data[i] = (byte)rand.Next(0, 255);
-
- PlatformMemoryStream stream = mem.Stream();
-
- stream.WriteByteArray(data);
-
- stream.SynchronizeOutput();
-
- Assert.IsTrue(mem.Capacity >= dataLen);
-
- stream.Reset();
-
- stream.SynchronizeInput();
-
- byte[] data0 = stream.ReadByteArray(dataLen);
-
- Assert.AreEqual(data, data0);
- }
- }
-}
[17/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml
deleted file mode 100644
index 9af4611..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml
+++ /dev/null
@@ -1,125 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="includeEventTypes">
- <util:constant static-field="org.apache.ignite.events.EventType.EVTS_CACHE"/>
- </property>
-
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="portable_store"/>
- <property name="cacheMode" value="LOCAL"/>
- <property name="atomicityMode" value="TRANSACTIONAL"/>
- <property name="writeThrough" value="true"/>
- <property name="readThrough" value="true"/>
-
- <property name="cacheStoreFactory">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
- <property name="assemblyName" value="Apache.Ignite.Core.Tests"/>
- <property name="className" value="Apache.Ignite.Core.Tests.Cache.Store.CacheTestStore"/>
- </bean>
- </property>
- </bean>
-
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="object_store"/>
- <property name="cacheMode" value="LOCAL"/>
- <property name="atomicityMode" value="TRANSACTIONAL"/>
- <property name="writeThrough" value="true"/>
- <property name="readThrough" value="true"/>
- <property name="keepPortableInStore" value="false"/>
-
- <property name="cacheStoreFactory">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
- <property name="assemblyName" value="Apache.Ignite.Core.Tests"/>
- <property name="className" value="Apache.Ignite.Core.Tests.Cache.Store.CacheTestStore"/>
- </bean>
- </property>
- </bean>
-
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="template_store*"/>
- <property name="cacheMode" value="LOCAL"/>
- <property name="atomicityMode" value="TRANSACTIONAL"/>
- <property name="writeThrough" value="true"/>
- <property name="readThrough" value="true"/>
- <property name="keepPortableInStore" value="false"/>
-
- <property name="cacheStoreFactory">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
- <property name="assemblyName" value="Apache.Ignite.Core.Tests"/>
- <property name="className" value="Apache.Ignite.Core.Tests.Cache.Store.CacheTestStore"/>
- </bean>
- </property>
- </bean>
-
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="custom_store"/>
- <property name="cacheMode" value="LOCAL"/>
- <property name="atomicityMode" value="TRANSACTIONAL"/>
- <property name="writeThrough" value="true"/>
- <property name="readThrough" value="true"/>
-
- <property name="cacheStoreFactory">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
- <property name="assemblyName" value="Apache.Ignite.Core.Tests"/>
- <property name="className" value="Apache.Ignite.Core.Tests.Cache.Store.CacheTestStore"/>
- <property name="properties">
- <map>
- <entry key="IntProperty">
- <value type="java.lang.Integer">42</value>
- </entry>
- <entry key="StringProperty" value="String value"/>
- </map>
- </property>
- </bean>
- </property>
- </bean>
- </list>
- </property>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47501</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache.xml
deleted file mode 100644
index c48e867..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache.xml
+++ /dev/null
@@ -1,194 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="includeEventTypes">
- <util:constant static-field="org.apache.ignite.events.EventType.EVTS_CACHE"/>
- </property>
-
- <property name="cacheConfiguration">
- <list>
- <bean parent="cache-template">
- <property name="name" value="local"/>
- <property name="cacheMode" value="LOCAL"/>
- <property name="atomicityMode" value="TRANSACTIONAL"/>
- <property name="startSize" value="10"/>
- </bean>
-
- <bean parent="cache-template">
- <property name="name" value="local_atomic"/>
- <property name="cacheMode" value="LOCAL"/>
- <property name="atomicityMode" value="ATOMIC"/>
- <property name="startSize" value="10"/>
- </bean>
-
- <bean parent="cache-template">
- <property name="name" value="partitioned"/>
- <property name="cacheMode" value="PARTITIONED"/>
- <property name="atomicityMode" value="TRANSACTIONAL"/>
- <property name="startSize" value="10"/>
- </bean>
-
- <bean parent="cache-template">
- <property name="name" value="partitioned_atomic"/>
- <property name="cacheMode" value="PARTITIONED"/>
- <property name="atomicityMode" value="ATOMIC"/>
- <property name="atomicWriteOrderMode" value="PRIMARY"/>
- <property name="startSize" value="10"/>
- </bean>
-
- <bean parent="cache-template">
- <property name="name" value="partitioned_near"/>
- <property name="cacheMode" value="PARTITIONED"/>
- <property name="atomicityMode" value="TRANSACTIONAL"/>
- <property name="nearConfiguration">
- <bean class="org.apache.ignite.configuration.NearCacheConfiguration" />
- </property>
- <property name="startSize" value="10"/>
- </bean>
-
- <bean parent="cache-template">
- <property name="name" value="partitioned_atomic_near"/>
- <property name="cacheMode" value="PARTITIONED"/>
- <property name="atomicityMode" value="ATOMIC"/>
- <property name="atomicWriteOrderMode" value="PRIMARY"/>
- <property name="nearConfiguration">
- <bean class="org.apache.ignite.configuration.NearCacheConfiguration" />
- </property>
- <property name="startSize" value="10"/>
- </bean>
-
- <bean parent="cache-template">
- <property name="name" value="replicated"/>
- <property name="cacheMode" value="REPLICATED"/>
- <property name="atomicityMode" value="TRANSACTIONAL"/>
- <property name="startSize" value="10"/>
- </bean>
-
- <bean parent="cache-template">
- <property name="name" value="replicated_atomic"/>
- <property name="cacheMode" value="REPLICATED"/>
- <property name="atomicityMode" value="ATOMIC"/>
- <property name="atomicWriteOrderMode" value="PRIMARY"/>
- <property name="startSize" value="10"/>
- </bean>
-
- <bean parent="cache-template">
- <property name="name" value="template*"/>
- <property name="startSize" value="10"/>
- </bean>
- </list>
- </property>
-
- <property name="swapSpaceSpi">
- <bean class="org.apache.ignite.spi.swapspace.inmemory.GridTestSwapSpaceSpi"/>
- </property>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47501</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
-
- <property name="transactionConfiguration">
- <bean class="org.apache.ignite.configuration.TransactionConfiguration">
- <property name="txSerializableEnabled" value="true"/>
- </bean>
- </property>
- </bean>
-
- <bean id="cache-template" abstract="true" class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="rebalanceMode" value="SYNC"/>
- <property name="writeSynchronizationMode" value="FULL_SYNC"/>
- <property name="swapEnabled" value="true"/>
- <property name="backups" value="1"/>
- <property name="eagerTtl" value="true"/>
-
- <!--
- <property name="typeMetadata">
- <list>
- <bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="valueType" value="GridPortablePerson"/>
- <property name="ascendingFields">
- <map>
- <entry key="age" value="java.lang.Integer"/>
- </map>
- </property>
- <property name="queryFields">
- <map>
- <entry key="name" value="java.lang.String"/>
- </map>
- </property>
- <property name="textFields">
- <list>
- <value>address</value>
- </list>
- </property>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="valueType" value="GridImplicitPortablePerson"/>
- <property name="ascendingFields">
- <map>
- <entry key="age" value="java.lang.Integer"/>
- </map>
- </property>
- <property name="queryFields">
- <map>
- <entry key="name" value="java.lang.String"/>
- </map>
- </property>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="valueType" value="GridNoDefPortablePerson"/>
- <property name="ascendingFields">
- <map>
- <entry key="age" value="java.lang.Integer"/>
- </map>
- </property>
- <property name="queryFields">
- <map>
- <entry key="name" value="java.lang.String"/>
- </map>
- </property>
- </bean>
- </list>
- </property>
- -->
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/portable.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/portable.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/portable.xml
deleted file mode 100644
index f013749..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/portable.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="gridName" value="grid"/>
-
- <property name="metricsUpdateFrequency" value="1000"/>
- <property name="metricsLogFrequency" value="0"/>
-
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="cache"/>
- </bean>
- </list>
- </property>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47502</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/start-test-grid1.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/start-test-grid1.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/start-test-grid1.xml
deleted file mode 100644
index 8559173..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/start-test-grid1.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="gridName" value="grid1"/>
-
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="cache1"/>
- <property name="rebalanceMode" value="SYNC"/>
- </bean>
- </list>
- </property>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47502</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/start-test-grid2.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/start-test-grid2.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/start-test-grid2.xml
deleted file mode 100644
index cb628fe..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/start-test-grid2.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="gridName" value="grid2"/>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47502</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/start-test-grid3.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/start-test-grid3.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/start-test-grid3.xml
deleted file mode 100644
index 753fad1..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/start-test-grid3.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47502</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
deleted file mode 100644
index 245ed5f..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
+++ /dev/null
@@ -1,592 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Dataload
-{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Threading;
- using Apache.Ignite.Core.Cache;
- using Apache.Ignite.Core.Datastream;
- using Apache.Ignite.Core.Impl;
- using Apache.Ignite.Core.Portable;
- using Apache.Ignite.Core.Tests.Cache;
- using NUnit.Framework;
-
- /// <summary>
- /// Data streamer tests.
- /// </summary>
- public class DataStreamerTest
- {
- /** Node name. */
- protected const string GridName = "grid";
-
- /** Cache name. */
- protected const string CacheName = "partitioned";
-
- /** Node. */
- private IIgnite _grid;
-
- /** Cache. */
- private ICache<int, int?> _cache;
-
- /// <summary>
- /// Initialization routine.
- /// </summary>
- [TestFixtureSetUp]
- public virtual void InitClient()
- {
- _grid = Ignition.Start(GetIgniteConfiguration(GridName));
-
- Ignition.Start(GetIgniteConfiguration(GridName + "_1"));
-
- _cache = _grid.GetCache<int, int?>(CacheName);
- }
-
- /// <summary>
- ///
- /// </summary>
- [TestFixtureTearDown]
- public virtual void StopGrids()
- {
- Ignition.StopAll(true);
- }
-
- /// <summary>
- ///
- /// </summary>
- [SetUp]
- public virtual void BeforeTest()
- {
- Console.WriteLine("Test started: " + TestContext.CurrentContext.Test.Name);
-
- for (int i = 0; i < 100; i++)
- _cache.Remove(i);
- }
-
- [TearDown]
- public void AfterTest()
- {
- TestUtils.AssertHandleRegistryIsEmpty(_grid, 1000);
- }
-
- /// <summary>
- /// Test data streamer property configuration. Ensures that at least no exceptions are thrown.
- /// </summary>
- [Test]
- public void TestPropertyPropagation()
- {
- using (IDataStreamer<int, int> ldr = _grid.GetDataStreamer<int, int>(CacheName))
- {
- ldr.AllowOverwrite = true;
- Assert.IsTrue(ldr.AllowOverwrite);
- ldr.AllowOverwrite = false;
- Assert.IsFalse(ldr.AllowOverwrite);
-
- ldr.SkipStore = true;
- Assert.IsTrue(ldr.SkipStore);
- ldr.SkipStore = false;
- Assert.IsFalse(ldr.SkipStore);
-
- ldr.PerNodeBufferSize = 1;
- Assert.AreEqual(1, ldr.PerNodeBufferSize);
- ldr.PerNodeBufferSize = 2;
- Assert.AreEqual(2, ldr.PerNodeBufferSize);
-
- ldr.PerNodeParallelOperations = 1;
- Assert.AreEqual(1, ldr.PerNodeParallelOperations);
- ldr.PerNodeParallelOperations = 2;
- Assert.AreEqual(2, ldr.PerNodeParallelOperations);
- }
- }
-
- /// <summary>
- /// Test data add/remove.
- /// </summary>
- [Test]
- public void TestAddRemove()
- {
- using (IDataStreamer<int, int> ldr = _grid.GetDataStreamer<int, int>(CacheName))
- {
- ldr.AllowOverwrite = true;
-
- // Additions.
- ldr.AddData(1, 1);
- ldr.Flush();
- Assert.AreEqual(1, _cache.Get(1));
-
- ldr.AddData(new KeyValuePair<int, int>(2, 2));
- ldr.Flush();
- Assert.AreEqual(2, _cache.Get(2));
-
- ldr.AddData(new List<KeyValuePair<int, int>> { new KeyValuePair<int, int>(3, 3), new KeyValuePair<int, int>(4, 4) });
- ldr.Flush();
- Assert.AreEqual(3, _cache.Get(3));
- Assert.AreEqual(4, _cache.Get(4));
-
- // Removal.
- ldr.RemoveData(1);
- ldr.Flush();
- Assert.IsNull(_cache.Get(1));
-
- // Mixed.
- ldr.AddData(5, 5);
- ldr.RemoveData(2);
- ldr.AddData(new KeyValuePair<int, int>(7, 7));
- ldr.AddData(6, 6);
- ldr.RemoveData(4);
- ldr.AddData(new List<KeyValuePair<int, int>> { new KeyValuePair<int, int>(9, 9), new KeyValuePair<int, int>(10, 10) });
- ldr.AddData(new KeyValuePair<int, int>(8, 8));
- ldr.RemoveData(3);
- ldr.AddData(new List<KeyValuePair<int, int>> { new KeyValuePair<int, int>(11, 11), new KeyValuePair<int, int>(12, 12) });
-
- ldr.Flush();
-
- for (int i = 2; i < 5; i++)
- Assert.IsNull(_cache.Get(i));
-
- for (int i = 5; i < 13; i++)
- Assert.AreEqual(i, _cache.Get(i));
- }
- }
-
- /// <summary>
- /// Test "tryFlush".
- /// </summary>
- [Test]
- public void TestTryFlush()
- {
- using (IDataStreamer<int, int> ldr = _grid.GetDataStreamer<int, int>(CacheName))
- {
- var fut = ldr.AddData(1, 1);
-
- ldr.TryFlush();
-
- fut.Get();
-
- Assert.AreEqual(1, _cache.Get(1));
- }
- }
-
- /// <summary>
- /// Test buffer size adjustments.
- /// </summary>
- [Test]
- public void TestBufferSize()
- {
- using (IDataStreamer<int, int> ldr = _grid.GetDataStreamer<int, int>(CacheName))
- {
- var fut = ldr.AddData(1, 1);
-
- Thread.Sleep(100);
-
- Assert.IsFalse(fut.IsDone);
-
- ldr.PerNodeBufferSize = 2;
-
- ldr.AddData(2, 2);
- ldr.AddData(3, 3);
- ldr.AddData(4, 4).Get();
- fut.Get();
-
- Assert.AreEqual(1, _cache.Get(1));
- Assert.AreEqual(2, _cache.Get(2));
- Assert.AreEqual(3, _cache.Get(3));
- Assert.AreEqual(4, _cache.Get(4));
-
- ldr.AddData(new List<KeyValuePair<int, int>>
- {
- new KeyValuePair<int, int>(5, 5),
- new KeyValuePair<int, int>(6, 6),
- new KeyValuePair<int, int>(7, 7),
- new KeyValuePair<int, int>(8, 8)
- }).Get();
-
- Assert.AreEqual(5, _cache.Get(5));
- Assert.AreEqual(6, _cache.Get(6));
- Assert.AreEqual(7, _cache.Get(7));
- Assert.AreEqual(8, _cache.Get(8));
- }
- }
-
- /// <summary>
- /// Test close.
- /// </summary>
- [Test]
- public void TestClose()
- {
- using (IDataStreamer<int, int> ldr = _grid.GetDataStreamer<int, int>(CacheName))
- {
- var fut = ldr.AddData(1, 1);
-
- ldr.Close(false);
-
- fut.Get();
-
- Assert.AreEqual(1, _cache.Get(1));
- }
- }
-
- /// <summary>
- /// Test close with cancellation.
- /// </summary>
- [Test]
- public void TestCancel()
- {
- using (IDataStreamer<int, int> ldr = _grid.GetDataStreamer<int, int>(CacheName))
- {
- var fut = ldr.AddData(1, 1);
-
- ldr.Close(true);
-
- fut.Get();
-
- Assert.IsNull(_cache.Get(1));
- }
- }
-
- /// <summary>
- /// Tests that streamer gets collected when there are no references to it.
- /// </summary>
- [Test]
- public void TestFinalizer()
- {
- var streamer = _grid.GetDataStreamer<int, int>(CacheName);
- var streamerRef = new WeakReference(streamer);
-
- Assert.IsNotNull(streamerRef.Target);
-
- // ReSharper disable once RedundantAssignment
- streamer = null;
-
- GC.Collect();
- GC.WaitForPendingFinalizers();
-
- Assert.IsNull(streamerRef.Target);
- }
-
- /// <summary>
- /// Test auto-flush feature.
- /// </summary>
- [Test]
- public void TestAutoFlush()
- {
- using (IDataStreamer<int, int> ldr = _grid.GetDataStreamer<int, int>(CacheName))
- {
- // Test auto flush turning on.
- var fut = ldr.AddData(1, 1);
- Thread.Sleep(100);
- Assert.IsFalse(fut.IsDone);
- ldr.AutoFlushFrequency = 1000;
- fut.Get();
-
- // Test forced flush after frequency change.
- fut = ldr.AddData(2, 2);
- ldr.AutoFlushFrequency = long.MaxValue;
- fut.Get();
-
- // Test another forced flush after frequency change.
- fut = ldr.AddData(3, 3);
- ldr.AutoFlushFrequency = 1000;
- fut.Get();
-
- // Test flush before stop.
- fut = ldr.AddData(4, 4);
- ldr.AutoFlushFrequency = 0;
- fut.Get();
-
- // Test flush after second turn on.
- fut = ldr.AddData(5, 5);
- ldr.AutoFlushFrequency = 1000;
- fut.Get();
-
- Assert.AreEqual(1, _cache.Get(1));
- Assert.AreEqual(2, _cache.Get(2));
- Assert.AreEqual(3, _cache.Get(3));
- Assert.AreEqual(4, _cache.Get(4));
- Assert.AreEqual(5, _cache.Get(5));
- }
- }
-
- /// <summary>
- /// Test multithreaded behavior.
- /// </summary>
- [Test]
- [Category(TestUtils.CategoryIntensive)]
- public void TestMultithreaded()
- {
- int entriesPerThread = 100000;
- int threadCnt = 8;
-
- for (int i = 0; i < 5; i++)
- {
- _cache.Clear();
-
- Assert.AreEqual(0, _cache.GetSize());
-
- Stopwatch watch = new Stopwatch();
-
- watch.Start();
-
- using (IDataStreamer<int, int> ldr = _grid.GetDataStreamer<int, int>(CacheName))
- {
- ldr.PerNodeBufferSize = 1024;
-
- int ctr = 0;
-
- TestUtils.RunMultiThreaded(() =>
- {
- int threadIdx = Interlocked.Increment(ref ctr);
-
- int startIdx = (threadIdx - 1) * entriesPerThread;
- int endIdx = startIdx + entriesPerThread;
-
- for (int j = startIdx; j < endIdx; j++)
- {
- // ReSharper disable once AccessToDisposedClosure
- ldr.AddData(j, j);
-
- if (j % 100000 == 0)
- Console.WriteLine("Put [thread=" + threadIdx + ", cnt=" + j + ']');
- }
- }, threadCnt);
- }
-
- Console.WriteLine("Iteration " + i + ": " + watch.ElapsedMilliseconds);
-
- watch.Reset();
-
- for (int j = 0; j < threadCnt * entriesPerThread; j++)
- Assert.AreEqual(j, j);
- }
- }
-
- /// <summary>
- /// Tests custom receiver.
- /// </summary>
- [Test]
- public void TestStreamReceiver()
- {
- TestStreamReceiver(new StreamReceiverPortable());
- TestStreamReceiver(new StreamReceiverSerializable());
- }
-
- /// <summary>
- /// Tests StreamVisitor.
- /// </summary>
- [Test]
- public void TestStreamVisitor()
- {
- TestStreamReceiver(new StreamVisitor<int, int>((c, e) => c.Put(e.Key, e.Value + 1)));
- }
-
- /// <summary>
- /// Tests StreamTransformer.
- /// </summary>
- [Test]
- public void TestStreamTransformer()
- {
- TestStreamReceiver(new StreamTransformer<int, int, int, int>(new EntryProcessorSerializable()));
- TestStreamReceiver(new StreamTransformer<int, int, int, int>(new EntryProcessorPortable()));
- }
-
- /// <summary>
- /// Tests specified receiver.
- /// </summary>
- private void TestStreamReceiver(IStreamReceiver<int, int> receiver)
- {
- using (var ldr = _grid.GetDataStreamer<int, int>(CacheName))
- {
- ldr.AllowOverwrite = true;
-
- ldr.Receiver = new StreamReceiverPortable();
-
- ldr.Receiver = receiver; // check double assignment
-
- Assert.AreEqual(ldr.Receiver, receiver);
-
- for (var i = 0; i < 100; i++)
- ldr.AddData(i, i);
-
- ldr.Flush();
-
- for (var i = 0; i < 100; i++)
- Assert.AreEqual(i + 1, _cache.Get(i));
- }
- }
-
- /// <summary>
- /// Tests the stream receiver in keepPortable mode.
- /// </summary>
- [Test]
- public void TestStreamReceiverKeepPortable()
- {
- // ReSharper disable once LocalVariableHidesMember
- var cache = _grid.GetCache<int, PortableEntry>(CacheName);
-
- using (var ldr0 = _grid.GetDataStreamer<int, int>(CacheName))
- using (var ldr = ldr0.WithKeepPortable<int, IPortableObject>())
- {
- ldr.Receiver = new StreamReceiverKeepPortable();
-
- ldr.AllowOverwrite = true;
-
- for (var i = 0; i < 100; i++)
- ldr.AddData(i, _grid.GetPortables().ToPortable<IPortableObject>(new PortableEntry {Val = i}));
-
- ldr.Flush();
-
- for (var i = 0; i < 100; i++)
- Assert.AreEqual(i + 1, cache.Get(i).Val);
- }
- }
-
- /// <summary>
- /// Gets the Ignite configuration.
- /// </summary>
- /// <param name="gridName">Grid name.</param>
- private static IgniteConfigurationEx GetIgniteConfiguration(string gridName)
- {
- return new IgniteConfigurationEx
- {
- GridName = gridName,
- SpringConfigUrl = "config\\native-client-test-cache.xml",
- JvmClasspath = TestUtils.CreateTestClasspath(),
- PortableConfiguration = new PortableConfiguration
- {
- TypeConfigurations = new List<PortableTypeConfiguration>
- {
- new PortableTypeConfiguration(typeof (CacheTestKey)),
- new PortableTypeConfiguration(typeof (TestReferenceObject)),
- new PortableTypeConfiguration(typeof (StreamReceiverPortable)),
- new PortableTypeConfiguration(typeof (EntryProcessorPortable)),
- new PortableTypeConfiguration(typeof (PortableEntry))
- }
- },
- JvmOptions = TestUtils.TestJavaOptions().Concat(new[]
- {
- "-Xms3096m",
- "-Xmx3096m",
- "-XX:+UseParNewGC",
- "-XX:+UseConcMarkSweepGC",
- "-XX:+UseTLAB",
- "-XX:NewSize=128m",
- "-XX:MaxNewSize=128m",
- "-XX:MaxTenuringThreshold=0",
- "-XX:SurvivorRatio=1024",
- "-XX:+UseCMSInitiatingOccupancyOnly",
- "-XX:CMSInitiatingOccupancyFraction=60"
- }).ToArray()
- };
- }
-
- /// <summary>
- /// Test portable receiver.
- /// </summary>
- private class StreamReceiverPortable : IStreamReceiver<int, int>
- {
- /** <inheritdoc /> */
- public void Receive(ICache<int, int> cache, ICollection<ICacheEntry<int, int>> entries)
- {
- cache.PutAll(entries.ToDictionary(x => x.Key, x => x.Value + 1));
- }
- }
-
- /// <summary>
- /// Test portable receiver.
- /// </summary>
- [Serializable]
- private class StreamReceiverKeepPortable : IStreamReceiver<int, IPortableObject>
- {
- /** <inheritdoc /> */
- public void Receive(ICache<int, IPortableObject> cache, ICollection<ICacheEntry<int, IPortableObject>> entries)
- {
- var portables = cache.Ignite.GetPortables();
-
- cache.PutAll(entries.ToDictionary(x => x.Key, x =>
- portables.ToPortable<IPortableObject>(new PortableEntry
- {
- Val = x.Value.Deserialize<PortableEntry>().Val + 1
- })));
- }
- }
-
- /// <summary>
- /// Test serializable receiver.
- /// </summary>
- [Serializable]
- private class StreamReceiverSerializable : IStreamReceiver<int, int>
- {
- /** <inheritdoc /> */
- public void Receive(ICache<int, int> cache, ICollection<ICacheEntry<int, int>> entries)
- {
- cache.PutAll(entries.ToDictionary(x => x.Key, x => x.Value + 1));
- }
- }
-
- /// <summary>
- /// Test entry processor.
- /// </summary>
- [Serializable]
- private class EntryProcessorSerializable : ICacheEntryProcessor<int, int, int, int>
- {
- /** <inheritdoc /> */
- public int Process(IMutableCacheEntry<int, int> entry, int arg)
- {
- entry.Value = entry.Key + 1;
-
- return 0;
- }
- }
-
- /// <summary>
- /// Test entry processor.
- /// </summary>
- private class EntryProcessorPortable : ICacheEntryProcessor<int, int, int, int>, IPortableMarshalAware
- {
- /** <inheritdoc /> */
- public int Process(IMutableCacheEntry<int, int> entry, int arg)
- {
- entry.Value = entry.Key + 1;
-
- return 0;
- }
-
- /** <inheritdoc /> */
- public void WritePortable(IPortableWriter writer)
- {
- // No-op.
- }
-
- /** <inheritdoc /> */
- public void ReadPortable(IPortableReader reader)
- {
- // No-op.
- }
- }
-
- /// <summary>
- /// Portablecache entry.
- /// </summary>
- private class PortableEntry
- {
- public int Val { get; set; }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
deleted file mode 100644
index aa103d4..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
+++ /dev/null
@@ -1,961 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests
-{
- using System;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading;
- using System.Threading.Tasks;
- using Apache.Ignite.Core.Cache.Query;
- using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Events;
- using Apache.Ignite.Core.Impl;
- using Apache.Ignite.Core.Impl.Events;
- using Apache.Ignite.Core.Portable;
- using Apache.Ignite.Core.Tests.Compute;
- using NUnit.Framework;
-
- /// <summary>
- /// <see cref="IEvents"/> tests.
- /// </summary>
- public class EventsTest
- {
- /** */
- private IIgnite _grid1;
-
- /** */
- private IIgnite _grid2;
-
- /** */
- private IIgnite _grid3;
-
- /** */
- private IIgnite[] _grids;
-
- /** */
- public static int IdGen;
-
- [TestFixtureTearDown]
- public void FixtureTearDown()
- {
- StopGrids();
- }
-
- /// <summary>
- /// Executes before each test.
- /// </summary>
- [SetUp]
- public void SetUp()
- {
- StartGrids();
- EventsTestHelper.ListenResult = true;
- }
-
- /// <summary>
- /// Executes after each test.
- /// </summary>
- [TearDown]
- public virtual void TearDown()
- {
- try
- {
- TestUtils.AssertHandleRegistryIsEmpty(1000, _grid1, _grid2, _grid3);
- }
- catch (Exception)
- {
- // Restart grids to cleanup
- StopGrids();
-
- throw;
- }
- finally
- {
- EventsTestHelper.AssertFailures();
-
- if (TestContext.CurrentContext.Test.Name.StartsWith("TestEventTypes"))
- StopGrids(); // clean events for other tests
- }
- }
-
- /// <summary>
- /// Tests enable/disable of event types.
- /// </summary>
- [Test]
- public void TestEnableDisable()
- {
- var events = _grid1.GetEvents();
-
- Assert.AreEqual(0, events.GetEnabledEvents().Length);
-
- Assert.IsFalse(EventType.EvtsCache.Any(events.IsEnabled));
-
- events.EnableLocal(EventType.EvtsCache);
-
- Assert.AreEqual(EventType.EvtsCache, events.GetEnabledEvents());
-
- Assert.IsTrue(EventType.EvtsCache.All(events.IsEnabled));
-
- events.EnableLocal(EventType.EvtsTaskExecution);
-
- events.DisableLocal(EventType.EvtsCache);
-
- Assert.AreEqual(EventType.EvtsTaskExecution, events.GetEnabledEvents());
- }
-
- /// <summary>
- /// Tests LocalListen.
- /// </summary>
- [Test]
- public void TestLocalListen()
- {
- var events = _grid1.GetEvents();
- var listener = EventsTestHelper.GetListener();
- var eventType = EventType.EvtsTaskExecution;
-
- events.EnableLocal(eventType);
-
- events.LocalListen(listener, eventType);
-
- CheckSend(3); // 3 events per task * 3 grids
-
- // Check unsubscription for specific event
- events.StopLocalListen(listener, EventType.EvtTaskReduced);
-
- CheckSend(2);
-
- // Unsubscribe from all events
- events.StopLocalListen(listener);
-
- CheckNoEvent();
-
- // Check unsubscription by filter
- events.LocalListen(listener, EventType.EvtTaskReduced);
-
- CheckSend();
-
- EventsTestHelper.ListenResult = false;
-
- CheckSend(); // one last event will be received for each listener
-
- CheckNoEvent();
- }
-
- /// <summary>
- /// Tests LocalListen.
- /// </summary>
- [Test]
- [Ignore("IGNITE-879")]
- public void TestLocalListenRepeatedSubscription()
- {
- var events = _grid1.GetEvents();
- var listener = EventsTestHelper.GetListener();
- var eventType = EventType.EvtsTaskExecution;
-
- events.EnableLocal(eventType);
-
- events.LocalListen(listener, eventType);
-
- CheckSend(3); // 3 events per task * 3 grids
-
- events.LocalListen(listener, eventType);
- events.LocalListen(listener, eventType);
-
- CheckSend(9);
-
- events.StopLocalListen(listener, eventType);
-
- CheckSend(6);
-
- events.StopLocalListen(listener, eventType);
-
- CheckSend(3);
-
- events.StopLocalListen(listener, eventType);
-
- CheckNoEvent();
- }
-
- /// <summary>
- /// Tests all available event types/classes.
- /// </summary>
- [Test, TestCaseSource("TestCases")]
- public void TestEventTypes(EventTestCase testCase)
- {
- var events = _grid1.GetEvents();
-
- events.EnableLocal(testCase.EventType);
-
- var listener = EventsTestHelper.GetListener();
-
- events.LocalListen(listener, testCase.EventType);
-
- EventsTestHelper.ClearReceived(testCase.EventCount);
-
- testCase.GenerateEvent(_grid1);
-
- EventsTestHelper.VerifyReceive(testCase.EventCount, testCase.EventObjectType, testCase.EventType);
-
- if (testCase.VerifyEvents != null)
- testCase.VerifyEvents(EventsTestHelper.ReceivedEvents.Reverse(), _grid1);
-
- // Check stop
- events.StopLocalListen(listener);
-
- EventsTestHelper.ClearReceived(0);
-
- testCase.GenerateEvent(_grid1);
-
- Thread.Sleep(EventsTestHelper.Timeout);
- }
-
- /// <summary>
- /// Test cases for TestEventTypes: type id + type + event generator.
- /// </summary>
- public IEnumerable<EventTestCase> TestCases
- {
- get
- {
- yield return new EventTestCase
- {
- EventType = EventType.EvtsCache,
- EventObjectType = typeof (CacheEvent),
- GenerateEvent = g => g.GetCache<int, int>(null).Put(1, 1),
- VerifyEvents = (e, g) => VerifyCacheEvents(e, g),
- EventCount = 1
- };
-
- yield return new EventTestCase
- {
- EventType = EventType.EvtsTaskExecution,
- EventObjectType = typeof (TaskEvent),
- GenerateEvent = g => GenerateTaskEvent(g),
- VerifyEvents = (e, g) => VerifyTaskEvents(e),
- EventCount = 3
- };
-
- yield return new EventTestCase
- {
- EventType = EventType.EvtsJobExecution,
- EventObjectType = typeof (JobEvent),
- GenerateEvent = g => GenerateTaskEvent(g),
- EventCount = 9
- };
-
- yield return new EventTestCase
- {
- EventType = new[] {EventType.EvtCacheQueryExecuted},
- EventObjectType = typeof (CacheQueryExecutedEvent),
- GenerateEvent = g => GenerateCacheQueryEvent(g),
- EventCount = 1
- };
-
- yield return new EventTestCase
- {
- EventType = new[] { EventType.EvtCacheQueryObjectRead },
- EventObjectType = typeof (CacheQueryReadEvent),
- GenerateEvent = g => GenerateCacheQueryEvent(g),
- EventCount = 1
- };
- }
- }
-
- /// <summary>
- /// Tests the LocalQuery.
- /// </summary>
- [Test]
- public void TestLocalQuery()
- {
- var events = _grid1.GetEvents();
-
- var eventType = EventType.EvtsTaskExecution;
-
- events.EnableLocal(eventType);
-
- var oldEvents = events.LocalQuery();
-
- GenerateTaskEvent();
-
- // "Except" works because of overridden equality
- var qryResult = events.LocalQuery(eventType).Except(oldEvents).ToList();
-
- Assert.AreEqual(3, qryResult.Count);
- }
-
- /// <summary>
- /// Tests the WaitForLocal.
- /// </summary>
- [Test]
- public void TestWaitForLocal([Values(true, false)] bool async)
- {
- var events = _grid1.GetEvents();
-
- var timeout = TimeSpan.FromSeconds(3);
-
- if (async)
- events = events.WithAsync();
-
- var eventType = EventType.EvtsTaskExecution;
-
- events.EnableLocal(eventType);
-
- Func<Func<IEvent>, Task<IEvent>> getWaitTask;
-
- if (async)
- getWaitTask = func =>
- {
- Assert.IsNull(func());
- var task = events.GetFuture<IEvent>().ToTask();
- GenerateTaskEvent();
- return task;
- };
- else
- getWaitTask = func =>
- {
- var task = Task.Factory.StartNew(func);
- Thread.Sleep(500); // allow task to start and begin waiting for events
- GenerateTaskEvent();
- return task;
- };
-
- // No params
- var waitTask = getWaitTask(() => events.WaitForLocal());
-
- waitTask.Wait(timeout);
-
- // Event types
- waitTask = getWaitTask(() => events.WaitForLocal(EventType.EvtTaskReduced));
-
- Assert.IsTrue(waitTask.Wait(timeout));
- Assert.IsInstanceOf(typeof(TaskEvent), waitTask.Result);
- Assert.AreEqual(EventType.EvtTaskReduced, waitTask.Result.Type);
-
- // Filter
- waitTask = getWaitTask(() => events.WaitForLocal(
- new EventFilter<IEvent>((g, e) => e.Type == EventType.EvtTaskReduced)));
-
- Assert.IsTrue(waitTask.Wait(timeout));
- Assert.IsInstanceOf(typeof(TaskEvent), waitTask.Result);
- Assert.AreEqual(EventType.EvtTaskReduced, waitTask.Result.Type);
-
- // Filter & types
- waitTask = getWaitTask(() => events.WaitForLocal(
- new EventFilter<IEvent>((g, e) => e.Type == EventType.EvtTaskReduced), EventType.EvtTaskReduced));
-
- Assert.IsTrue(waitTask.Wait(timeout));
- Assert.IsInstanceOf(typeof(TaskEvent), waitTask.Result);
- Assert.AreEqual(EventType.EvtTaskReduced, waitTask.Result.Type);
- }
-
- /// <summary>
- /// Tests RemoteListen.
- /// </summary>
- [Test]
- public void TestRemoteListen(
- [Values(true, false)] bool async,
- [Values(true, false)] bool portable,
- [Values(true, false)] bool autoUnsubscribe)
- {
- foreach (var g in _grids)
- {
- g.GetEvents().EnableLocal(EventType.EvtsJobExecution);
- g.GetEvents().EnableLocal(EventType.EvtsTaskExecution);
- }
-
- var events = _grid1.GetEvents();
-
- var expectedType = EventType.EvtJobStarted;
-
- var remoteFilter = portable
- ? (IEventFilter<IEvent>) new RemoteEventPortableFilter(expectedType)
- : new RemoteEventFilter(expectedType);
-
- var localListener = EventsTestHelper.GetListener();
-
- if (async)
- events = events.WithAsync();
-
- var listenId = events.RemoteListen(localListener: localListener, remoteFilter: remoteFilter,
- autoUnsubscribe: autoUnsubscribe);
-
- if (async)
- listenId = events.GetFuture<Guid>().Get();
-
- CheckSend(3, typeof(JobEvent), expectedType);
-
- _grid3.GetEvents().DisableLocal(EventType.EvtsJobExecution);
-
- CheckSend(2, typeof(JobEvent), expectedType);
-
- events.StopRemoteListen(listenId);
-
- if (async)
- events.GetFuture().Get();
-
- CheckNoEvent();
-
- // Check unsubscription with listener
- events.RemoteListen(localListener: localListener, remoteFilter: remoteFilter,
- autoUnsubscribe: autoUnsubscribe);
-
- if (async)
- events.GetFuture<Guid>().Get();
-
- CheckSend(2, typeof(JobEvent), expectedType);
-
- EventsTestHelper.ListenResult = false;
-
- CheckSend(1, typeof(JobEvent), expectedType); // one last event
-
- CheckNoEvent();
- }
-
- /// <summary>
- /// Tests RemoteQuery.
- /// </summary>
- [Test]
- public void TestRemoteQuery([Values(true, false)] bool async)
- {
- foreach (var g in _grids)
- g.GetEvents().EnableLocal(EventType.EvtsJobExecution);
-
- var events = _grid1.GetEvents();
-
- var eventFilter = new RemoteEventFilter(EventType.EvtJobStarted);
-
- var oldEvents = events.RemoteQuery(eventFilter);
-
- if (async)
- events = events.WithAsync();
-
- GenerateTaskEvent();
-
- var remoteQuery = events.RemoteQuery(eventFilter, EventsTestHelper.Timeout, EventType.EvtsJobExecution);
-
- if (async)
- {
- Assert.IsNull(remoteQuery);
-
- remoteQuery = events.GetFuture<List<IEvent>>().Get().ToList();
- }
-
- var qryResult = remoteQuery.Except(oldEvents).Cast<JobEvent>().ToList();
-
- Assert.AreEqual(_grids.Length, qryResult.Count);
-
- Assert.IsTrue(qryResult.All(x => x.Type == EventType.EvtJobStarted));
- }
-
- /// <summary>
- /// Tests serialization.
- /// </summary>
- [Test]
- public void TestSerialization()
- {
- var grid = (Ignite) _grid1;
- var comp = (Impl.Compute.Compute) grid.GetCluster().ForLocal().GetCompute();
- var locNode = grid.GetCluster().GetLocalNode();
-
- var expectedGuid = Guid.Parse("00000000-0000-0001-0000-000000000002");
- var expectedGridGuid = new IgniteGuid(expectedGuid, 3);
-
- using (var inStream = IgniteManager.Memory.Allocate().Stream())
- {
- var result = comp.ExecuteJavaTask<bool>("org.apache.ignite.platform.PlatformEventsWriteEventTask",
- inStream.MemoryPointer);
-
- Assert.IsTrue(result);
-
- inStream.SynchronizeInput();
-
- var reader = grid.Marshaller.StartUnmarshal(inStream);
-
- var cacheEvent = EventReader.Read<CacheEvent>(reader);
- CheckEventBase(cacheEvent);
- Assert.AreEqual("cacheName", cacheEvent.CacheName);
- Assert.AreEqual(locNode, cacheEvent.EventNode);
- Assert.AreEqual(1, cacheEvent.Partition);
- Assert.AreEqual(true, cacheEvent.IsNear);
- Assert.AreEqual(2, cacheEvent.Key);
- Assert.AreEqual(expectedGridGuid, cacheEvent.Xid);
- Assert.AreEqual(3, cacheEvent.LockId);
- Assert.AreEqual(4, cacheEvent.NewValue);
- Assert.AreEqual(true, cacheEvent.HasNewValue);
- Assert.AreEqual(5, cacheEvent.OldValue);
- Assert.AreEqual(true, cacheEvent.HasOldValue);
- Assert.AreEqual(expectedGuid, cacheEvent.SubjectId);
- Assert.AreEqual("cloClsName", cacheEvent.ClosureClassName);
- Assert.AreEqual("taskName", cacheEvent.TaskName);
-
- var qryExecEvent = EventReader.Read<CacheQueryExecutedEvent>(reader);
- CheckEventBase(qryExecEvent);
- Assert.AreEqual("qryType", qryExecEvent.QueryType);
- Assert.AreEqual("cacheName", qryExecEvent.CacheName);
- Assert.AreEqual("clsName", qryExecEvent.ClassName);
- Assert.AreEqual("clause", qryExecEvent.Clause);
- Assert.AreEqual(expectedGuid, qryExecEvent.SubjectId);
- Assert.AreEqual("taskName", qryExecEvent.TaskName);
-
- var qryReadEvent = EventReader.Read<CacheQueryReadEvent>(reader);
- CheckEventBase(qryReadEvent);
- Assert.AreEqual("qryType", qryReadEvent.QueryType);
- Assert.AreEqual("cacheName", qryReadEvent.CacheName);
- Assert.AreEqual("clsName", qryReadEvent.ClassName);
- Assert.AreEqual("clause", qryReadEvent.Clause);
- Assert.AreEqual(expectedGuid, qryReadEvent.SubjectId);
- Assert.AreEqual("taskName", qryReadEvent.TaskName);
- Assert.AreEqual(1, qryReadEvent.Key);
- Assert.AreEqual(2, qryReadEvent.Value);
- Assert.AreEqual(3, qryReadEvent.OldValue);
- Assert.AreEqual(4, qryReadEvent.Row);
-
- var cacheRebalancingEvent = EventReader.Read<CacheRebalancingEvent>(reader);
- CheckEventBase(cacheRebalancingEvent);
- Assert.AreEqual("cacheName", cacheRebalancingEvent.CacheName);
- Assert.AreEqual(1, cacheRebalancingEvent.Partition);
- Assert.AreEqual(locNode, cacheRebalancingEvent.DiscoveryNode);
- Assert.AreEqual(2, cacheRebalancingEvent.DiscoveryEventType);
- Assert.AreEqual(3, cacheRebalancingEvent.DiscoveryTimestamp);
-
- var checkpointEvent = EventReader.Read<CheckpointEvent>(reader);
- CheckEventBase(checkpointEvent);
- Assert.AreEqual("cpKey", checkpointEvent.Key);
-
- var discoEvent = EventReader.Read<DiscoveryEvent>(reader);
- CheckEventBase(discoEvent);
- Assert.AreEqual(grid.TopologyVersion, discoEvent.TopologyVersion);
- Assert.AreEqual(grid.GetNodes(), discoEvent.TopologyNodes);
-
- var jobEvent = EventReader.Read<JobEvent>(reader);
- CheckEventBase(jobEvent);
- Assert.AreEqual(expectedGridGuid, jobEvent.JobId);
- Assert.AreEqual("taskClsName", jobEvent.TaskClassName);
- Assert.AreEqual("taskName", jobEvent.TaskName);
- Assert.AreEqual(locNode, jobEvent.TaskNode);
- Assert.AreEqual(expectedGridGuid, jobEvent.TaskSessionId);
- Assert.AreEqual(expectedGuid, jobEvent.TaskSubjectId);
-
- var spaceEvent = EventReader.Read<SwapSpaceEvent>(reader);
- CheckEventBase(spaceEvent);
- Assert.AreEqual("space", spaceEvent.Space);
-
- var taskEvent = EventReader.Read<TaskEvent>(reader);
- CheckEventBase(taskEvent);
- Assert.AreEqual(true,taskEvent.Internal);
- Assert.AreEqual(expectedGuid, taskEvent.SubjectId);
- Assert.AreEqual("taskClsName", taskEvent.TaskClassName);
- Assert.AreEqual("taskName", taskEvent.TaskName);
- Assert.AreEqual(expectedGridGuid, taskEvent.TaskSessionId);
- }
- }
-
- /// <summary>
- /// Checks base event fields serialization.
- /// </summary>
- /// <param name="evt">The evt.</param>
- private void CheckEventBase(IEvent evt)
- {
- var locNode = _grid1.GetCluster().GetLocalNode();
-
- Assert.AreEqual(locNode, evt.Node);
- Assert.AreEqual("msg", evt.Message);
- Assert.AreEqual(EventType.EvtSwapSpaceCleared, evt.Type);
- Assert.IsNotNullOrEmpty(evt.Name);
- Assert.AreNotEqual(Guid.Empty, evt.Id.GlobalId);
- Assert.IsTrue((evt.TimeStamp - DateTime.Now).TotalSeconds < 10);
- }
-
- /// <summary>
- /// Sends events in various ways and verifies correct receive.
- /// </summary>
- /// <param name="repeat">Expected event count multiplier.</param>
- /// <param name="eventObjectType">Expected event object type.</param>
- /// <param name="eventType">Type of the event.</param>
- private void CheckSend(int repeat = 1, Type eventObjectType = null, params int[] eventType)
- {
- EventsTestHelper.ClearReceived(repeat);
-
- GenerateTaskEvent();
-
- EventsTestHelper.VerifyReceive(repeat, eventObjectType ?? typeof (TaskEvent),
- eventType.Any() ? eventType : EventType.EvtsTaskExecution);
- }
-
- /// <summary>
- /// Checks that no event has arrived.
- /// </summary>
- private void CheckNoEvent()
- {
- // this will result in an exception in case of a event
- EventsTestHelper.ClearReceived(0);
-
- GenerateTaskEvent();
-
- Thread.Sleep(EventsTestHelper.Timeout);
-
- EventsTestHelper.AssertFailures();
- }
-
- /// <summary>
- /// Gets the Ignite configuration.
- /// </summary>
- private static IgniteConfiguration Configuration(string springConfigUrl)
- {
- return new IgniteConfiguration
- {
- SpringConfigUrl = springConfigUrl,
- JvmClasspath = TestUtils.CreateTestClasspath(),
- JvmOptions = TestUtils.TestJavaOptions(),
- PortableConfiguration = new PortableConfiguration
- {
- TypeConfigurations = new List<PortableTypeConfiguration>
- {
- new PortableTypeConfiguration(typeof (RemoteEventPortableFilter))
- }
- }
- };
- }
-
- /// <summary>
- /// Generates the task event.
- /// </summary>
- private void GenerateTaskEvent(IIgnite grid = null)
- {
- (grid ?? _grid1).GetCompute().Broadcast(new ComputeAction());
- }
-
- /// <summary>
- /// Verifies the task events.
- /// </summary>
- private static void VerifyTaskEvents(IEnumerable<IEvent> events)
- {
- var e = events.Cast<TaskEvent>().ToArray();
-
- // started, reduced, finished
- Assert.AreEqual(
- new[] {EventType.EvtTaskStarted, EventType.EvtTaskReduced, EventType.EvtTaskFinished},
- e.Select(x => x.Type).ToArray());
- }
-
- /// <summary>
- /// Generates the cache query event.
- /// </summary>
- private static void GenerateCacheQueryEvent(IIgnite g)
- {
- var cache = g.GetCache<int, int>(null);
-
- cache.Clear();
-
- cache.Put(1, 1);
-
- cache.Query(new ScanQuery<int, int>()).GetAll();
- }
-
- /// <summary>
- /// Verifies the cache events.
- /// </summary>
- private static void VerifyCacheEvents(IEnumerable<IEvent> events, IIgnite grid)
- {
- var e = events.Cast<CacheEvent>().ToArray();
-
- foreach (var cacheEvent in e)
- {
- Assert.AreEqual(null, cacheEvent.CacheName);
- Assert.AreEqual(null, cacheEvent.ClosureClassName);
- Assert.AreEqual(null, cacheEvent.TaskName);
- Assert.AreEqual(grid.GetCluster().GetLocalNode(), cacheEvent.EventNode);
- Assert.AreEqual(grid.GetCluster().GetLocalNode(), cacheEvent.Node);
-
- Assert.AreEqual(false, cacheEvent.HasOldValue);
- Assert.AreEqual(null, cacheEvent.OldValue);
-
- if (cacheEvent.Type == EventType.EvtCacheObjectPut)
- {
- Assert.AreEqual(true, cacheEvent.HasNewValue);
- Assert.AreEqual(1, cacheEvent.NewValue);
- }
- else if (cacheEvent.Type == EventType.EvtCacheEntryCreated)
- {
- Assert.AreEqual(false, cacheEvent.HasNewValue);
- Assert.AreEqual(null, cacheEvent.NewValue);
- }
- else
- {
- Assert.Fail("Unexpected event type");
- }
- }
- }
-
- /// <summary>
- /// Starts the grids.
- /// </summary>
- private void StartGrids()
- {
- if (_grid1 != null)
- return;
-
- _grid1 = Ignition.Start(Configuration("config\\compute\\compute-grid1.xml"));
- _grid2 = Ignition.Start(Configuration("config\\compute\\compute-grid2.xml"));
- _grid3 = Ignition.Start(Configuration("config\\compute\\compute-grid3.xml"));
-
- _grids = new[] {_grid1, _grid2, _grid3};
- }
-
- /// <summary>
- /// Stops the grids.
- /// </summary>
- private void StopGrids()
- {
- _grid1 = _grid2 = _grid3 = null;
- _grids = null;
-
- Ignition.StopAll(true);
- }
- }
-
- /// <summary>
- /// Event test helper class.
- /// </summary>
- [Serializable]
- public static class EventsTestHelper
- {
- /** */
- public static readonly ConcurrentStack<IEvent> ReceivedEvents = new ConcurrentStack<IEvent>();
-
- /** */
- public static readonly ConcurrentStack<string> Failures = new ConcurrentStack<string>();
-
- /** */
- public static readonly CountdownEvent ReceivedEvent = new CountdownEvent(0);
-
- /** */
- public static readonly ConcurrentStack<Guid> LastNodeIds = new ConcurrentStack<Guid>();
-
- /** */
- public static volatile bool ListenResult = true;
-
- /** */
- public static readonly TimeSpan Timeout = TimeSpan.FromMilliseconds(800);
-
- /// <summary>
- /// Clears received event information.
- /// </summary>
- /// <param name="expectedCount">The expected count of events to be received.</param>
- public static void ClearReceived(int expectedCount)
- {
- ReceivedEvents.Clear();
- ReceivedEvent.Reset(expectedCount);
- LastNodeIds.Clear();
- }
-
- /// <summary>
- /// Verifies received events against events events.
- /// </summary>
- public static void VerifyReceive(int count, Type eventObjectType, params int[] eventTypes)
- {
- // check if expected event count has been received; Wait returns false if there were none.
- Assert.IsTrue(ReceivedEvent.Wait(Timeout),
- "Failed to receive expected number of events. Remaining count: " + ReceivedEvent.CurrentCount);
-
- Assert.AreEqual(count, ReceivedEvents.Count);
-
- Assert.IsTrue(ReceivedEvents.All(x => x.GetType() == eventObjectType));
-
- Assert.IsTrue(ReceivedEvents.All(x => eventTypes.Contains(x.Type)));
-
- AssertFailures();
- }
-
- /// <summary>
- /// Gets the event listener.
- /// </summary>
- /// <returns>New instance of event listener.</returns>
- public static IEventFilter<IEvent> GetListener()
- {
- return new EventFilter<IEvent>(Listen);
- }
-
- /// <summary>
- /// Combines accumulated failures and throws an assertion, if there are any.
- /// Clears accumulated failures.
- /// </summary>
- public static void AssertFailures()
- {
- try
- {
- if (Failures.Any())
- Assert.Fail(Failures.Reverse().Aggregate((x, y) => string.Format("{0}\n{1}", x, y)));
- }
- finally
- {
- Failures.Clear();
- }
- }
-
- /// <summary>
- /// Listen method.
- /// </summary>
- /// <param name="id">Originating node ID.</param>
- /// <param name="evt">Event.</param>
- private static bool Listen(Guid id, IEvent evt)
- {
- try
- {
- LastNodeIds.Push(id);
- ReceivedEvents.Push(evt);
-
- ReceivedEvent.Signal();
-
- return ListenResult;
- }
- catch (Exception ex)
- {
- // When executed on remote nodes, these exceptions will not go to sender,
- // so we have to accumulate them.
- Failures.Push(string.Format("Exception in Listen (msg: {0}, id: {1}): {2}", evt, id, ex));
- throw;
- }
- }
- }
-
- /// <summary>
- /// Test event filter.
- /// </summary>
- [Serializable]
- public class EventFilter<T> : IEventFilter<T> where T : IEvent
- {
- /** */
- private readonly Func<Guid, T, bool> _invoke;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="RemoteListenEventFilter"/> class.
- /// </summary>
- /// <param name="invoke">The invoke delegate.</param>
- public EventFilter(Func<Guid, T, bool> invoke)
- {
- _invoke = invoke;
- }
-
- /** <inheritdoc /> */
- bool IEventFilter<T>.Invoke(Guid nodeId, T evt)
- {
- return _invoke(nodeId, evt);
- }
-
- /** <inheritdoc /> */
- public bool Invoke(Guid nodeId, T evt)
- {
- throw new Exception("Invalid method");
- }
- }
-
- /// <summary>
- /// Remote event filter.
- /// </summary>
- [Serializable]
- public class RemoteEventFilter : IEventFilter<IEvent>
- {
- /** */
- private readonly int _type;
-
- public RemoteEventFilter(int type)
- {
- _type = type;
- }
-
- /** <inheritdoc /> */
- public bool Invoke(Guid nodeId, IEvent evt)
- {
- return evt.Type == _type;
- }
- }
-
- /// <summary>
- /// Portable remote event filter.
- /// </summary>
- public class RemoteEventPortableFilter : IEventFilter<IEvent>, IPortableMarshalAware
- {
- /** */
- private int _type;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="RemoteEventPortableFilter"/> class.
- /// </summary>
- /// <param name="type">The event type.</param>
- public RemoteEventPortableFilter(int type)
- {
- _type = type;
- }
-
- /** <inheritdoc /> */
- public bool Invoke(Guid nodeId, IEvent evt)
- {
- return evt.Type == _type;
- }
-
- /** <inheritdoc /> */
- public void WritePortable(IPortableWriter writer)
- {
- writer.RawWriter().WriteInt(_type);
- }
-
- /** <inheritdoc /> */
- public void ReadPortable(IPortableReader reader)
- {
- _type = reader.RawReader().ReadInt();
- }
- }
-
- /// <summary>
- /// Event test case.
- /// </summary>
- public class EventTestCase
- {
- /// <summary>
- /// Gets or sets the type of the event.
- /// </summary>
- public int[] EventType { get; set; }
-
- /// <summary>
- /// Gets or sets the type of the event object.
- /// </summary>
- public Type EventObjectType { get; set; }
-
- /// <summary>
- /// Gets or sets the generate event action.
- /// </summary>
- public Action<IIgnite> GenerateEvent { get; set; }
-
- /// <summary>
- /// Gets or sets the verify events action.
- /// </summary>
- public Action<IEnumerable<IEvent>, IIgnite> VerifyEvents { get; set; }
-
- /// <summary>
- /// Gets or sets the event count.
- /// </summary>
- public int EventCount { get; set; }
-
- /** <inheritdoc /> */
- public override string ToString()
- {
- return EventObjectType.ToString();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/Example.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/Example.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/Example.cs
deleted file mode 100644
index edb04cb..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/Example.cs
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Examples
-{
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text.RegularExpressions;
- using Apache.Ignite.Examples.Compute;
- using Apache.Ignite.ExamplesDll.Compute;
- using NUnit.Framework;
-
- /// <summary>
- /// Represents an Example to be tested.
- /// </summary>
- public class Example
- {
- /** All examples */
- private static readonly Example[] Examples = GetExamples().ToArray();
-
- /** Execute action */
- private Action _runAction;
-
- /** Config url */
- public string SpringConfigUrl { get; private set; }
-
- /** Source path */
- public string SourceFilePath { get; private set; }
-
- /** Dll load flag */
- public bool NeedsTestDll { get; private set; }
-
- /** Name */
- public string Name { get; private set; }
-
- /// <summary>
- /// Runs this example.
- /// </summary>
- public void Run()
- {
- try
- {
- _runAction();
- }
- catch (InvalidOperationException ex)
- {
- // Each example has a ReadKey at the end, which throws an exception in test environment.
- if (ex.Message != "Cannot read keys when either application does not have a console or " +
- "when console input has been redirected from a file. Try Console.Read.")
- throw;
- }
- }
-
- /// <summary>
- /// Gets all examples.
- /// </summary>
- public static IEnumerable<Example> All
- {
- get { return Examples; }
- }
-
- /// <summary>
- /// Gets all examples.
- /// </summary>
- private static IEnumerable<Example> GetExamples()
- {
- var examplesAsm = typeof (ClosureExample).Assembly;
-
- var sourceFiles = Directory.GetFiles(PathUtil.ExamplesSourcePath, "*.cs", SearchOption.AllDirectories);
-
- Assert.IsTrue(sourceFiles.Any());
-
- var types = examplesAsm.GetTypes().Where(x => x.GetMethod("Main") != null).ToArray();
-
- Assert.IsTrue(types.Any());
-
- var examplesDllName = typeof(AverageSalaryJob).Assembly.GetName().Name;
-
- foreach (var type in types)
- {
- var sourceFile = sourceFiles.Single(x => x.EndsWith(string.Format("\\{0}.cs", type.Name)));
-
- var sourceCode = File.ReadAllText(sourceFile);
-
- yield return new Example
- {
- SourceFilePath = sourceFile,
- SpringConfigUrl = PathUtil.GetFullConfigPath(GetSpringConfigUrl(sourceCode)),
- NeedsTestDll = sourceCode.Contains(examplesDllName),
- _runAction = GetRunAction(type),
- Name = type.Name
- };
- }
- }
-
- /// <summary>
- /// Gets the run action.
- /// </summary>
- private static Action GetRunAction(Type type)
- {
- return (Action) Delegate.CreateDelegate(typeof (Action), type.GetMethod("Main"));
- }
-
- /// <summary>
- /// Gets the spring configuration URL.
- /// </summary>
- private static string GetSpringConfigUrl(string code)
- {
- var match = Regex.Match(code, "-springConfigUrl=(.*?.xml)");
-
- return match.Success ? match.Groups[1].Value : null;
- }
-
- /** <inheritdoc /> */
- public override string ToString()
- {
- // This will be displayed in TeamCity and R# test runner
- return Name;
- }
- }
-}
\ No newline at end of file
[34/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
new file mode 100644
index 0000000..e0dcdaa
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
@@ -0,0 +1,1181 @@
+/*
+ * 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.Cache.Query.Continuous
+{
+ using System;
+ using System.Collections.Concurrent;
+ using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
+ using System.Linq;
+ using System.Runtime.Serialization;
+ using System.Threading;
+ using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cache.Event;
+ using Apache.Ignite.Core.Cache.Query;
+ using Apache.Ignite.Core.Cache.Query.Continuous;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Impl;
+ using Apache.Ignite.Core.Portable;
+ using Apache.Ignite.Core.Resource;
+ using NUnit.Framework;
+ using CQU = Apache.Ignite.Core.Impl.Cache.Query.Continuous.ContinuousQueryUtils;
+
+ /// <summary>
+ /// Tests for continuous query.
+ /// </summary>
+ [SuppressMessage("ReSharper", "InconsistentNaming")]
+ [SuppressMessage("ReSharper", "PossibleNullReferenceException")]
+ [SuppressMessage("ReSharper", "StaticMemberInGenericType")]
+ public abstract class ContinuousQueryAbstractTest
+ {
+ /** Cache name: ATOMIC, backup. */
+ protected const string CACHE_ATOMIC_BACKUP = "atomic_backup";
+
+ /** Cache name: ATOMIC, no backup. */
+ protected const string CACHE_ATOMIC_NO_BACKUP = "atomic_no_backup";
+
+ /** Cache name: TRANSACTIONAL, backup. */
+ protected const string CACHE_TX_BACKUP = "transactional_backup";
+
+ /** Cache name: TRANSACTIONAL, no backup. */
+ protected const string CACHE_TX_NO_BACKUP = "transactional_no_backup";
+
+ /** Listener events. */
+ public static BlockingCollection<CallbackEvent> CB_EVTS = new BlockingCollection<CallbackEvent>();
+
+ /** Listener events. */
+ public static BlockingCollection<FilterEvent> FILTER_EVTS = new BlockingCollection<FilterEvent>();
+
+ /** First node. */
+ private IIgnite grid1;
+
+ /** Second node. */
+ private IIgnite grid2;
+
+ /** Cache on the first node. */
+ private ICache<int, PortableEntry> cache1;
+
+ /** Cache on the second node. */
+ private ICache<int, PortableEntry> cache2;
+
+ /** Cache name. */
+ private readonly string cacheName;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="cacheName">Cache name.</param>
+ protected ContinuousQueryAbstractTest(string cacheName)
+ {
+ this.cacheName = cacheName;
+ }
+
+ /// <summary>
+ /// Set-up routine.
+ /// </summary>
+ [TestFixtureSetUp]
+ public void SetUp()
+ {
+ GC.Collect();
+ TestUtils.JvmDebug = true;
+
+ IgniteConfigurationEx cfg = new IgniteConfigurationEx();
+
+ PortableConfiguration portCfg = new PortableConfiguration();
+
+ ICollection<PortableTypeConfiguration> portTypeCfgs = new List<PortableTypeConfiguration>();
+
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableEntry)));
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableFilter)));
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(KeepPortableFilter)));
+
+ portCfg.TypeConfigurations = portTypeCfgs;
+
+ cfg.PortableConfiguration = portCfg;
+ cfg.JvmClasspath = TestUtils.CreateTestClasspath();
+ cfg.JvmOptions = TestUtils.TestJavaOptions();
+ cfg.SpringConfigUrl = "config\\cache-query-continuous.xml";
+
+ cfg.GridName = "grid-1";
+ grid1 = Ignition.Start(cfg);
+ cache1 = grid1.GetCache<int, PortableEntry>(cacheName);
+
+ cfg.GridName = "grid-2";
+ grid2 = Ignition.Start(cfg);
+ cache2 = grid2.GetCache<int, PortableEntry>(cacheName);
+ }
+
+ /// <summary>
+ /// Tear-down routine.
+ /// </summary>
+ [TestFixtureTearDown]
+ public void TearDown()
+ {
+ Ignition.StopAll(true);
+ }
+
+ /// <summary>
+ /// Before-test routine.
+ /// </summary>
+ [SetUp]
+ public void BeforeTest()
+ {
+ CB_EVTS = new BlockingCollection<CallbackEvent>();
+ FILTER_EVTS = new BlockingCollection<FilterEvent>();
+
+ AbstractFilter<PortableEntry>.res = true;
+ AbstractFilter<PortableEntry>.err = false;
+ AbstractFilter<PortableEntry>.marshErr = false;
+ AbstractFilter<PortableEntry>.unmarshErr = false;
+
+ cache1.Remove(PrimaryKey(cache1));
+ cache1.Remove(PrimaryKey(cache2));
+
+ Assert.AreEqual(0, cache1.GetSize());
+ Assert.AreEqual(0, cache2.GetSize());
+
+ Console.WriteLine("Test started: " + TestContext.CurrentContext.Test.Name);
+ }
+
+ /// <summary>
+ /// Test arguments validation.
+ /// </summary>
+ [Test]
+ public void TestValidation()
+ {
+ Assert.Throws<ArgumentException>(() => { cache1.QueryContinuous(new ContinuousQuery<int, PortableEntry>(null)); });
+ }
+
+ /// <summary>
+ /// Test multiple closes.
+ /// </summary>
+ [Test]
+ public void TestMultipleClose()
+ {
+ int key1 = PrimaryKey(cache1);
+ int key2 = PrimaryKey(cache2);
+
+ ContinuousQuery<int, PortableEntry> qry =
+ new ContinuousQuery<int, PortableEntry>(new Listener<PortableEntry>());
+
+ IDisposable qryHnd;
+
+ using (qryHnd = cache1.QueryContinuous(qry))
+ {
+ // Put from local node.
+ cache1.GetAndPut(key1, Entry(key1));
+ CheckCallbackSingle(key1, null, Entry(key1));
+
+ // Put from remote node.
+ cache2.GetAndPut(key2, Entry(key2));
+ CheckCallbackSingle(key2, null, Entry(key2));
+ }
+
+ qryHnd.Dispose();
+ }
+
+ /// <summary>
+ /// Test regular callback operations.
+ /// </summary>
+ [Test]
+ public void TestCallback()
+ {
+ CheckCallback(false);
+ }
+
+ /// <summary>
+ /// Check regular callback execution.
+ /// </summary>
+ /// <param name="loc"></param>
+ protected void CheckCallback(bool loc)
+ {
+ int key1 = PrimaryKey(cache1);
+ int key2 = PrimaryKey(cache2);
+
+ ContinuousQuery<int, PortableEntry> qry = loc ?
+ new ContinuousQuery<int, PortableEntry>(new Listener<PortableEntry>(), true) :
+ new ContinuousQuery<int, PortableEntry>(new Listener<PortableEntry>());
+
+ using (cache1.QueryContinuous(qry))
+ {
+ // Put from local node.
+ cache1.GetAndPut(key1, Entry(key1));
+ CheckCallbackSingle(key1, null, Entry(key1));
+
+ cache1.GetAndPut(key1, Entry(key1 + 1));
+ CheckCallbackSingle(key1, Entry(key1), Entry(key1 + 1));
+
+ cache1.Remove(key1);
+ CheckCallbackSingle(key1, Entry(key1 + 1), null);
+
+ // Put from remote node.
+ cache2.GetAndPut(key2, Entry(key2));
+
+ if (loc)
+ CheckNoCallback(100);
+ else
+ CheckCallbackSingle(key2, null, Entry(key2));
+
+ cache1.GetAndPut(key2, Entry(key2 + 1));
+
+ if (loc)
+ CheckNoCallback(100);
+ else
+ CheckCallbackSingle(key2, Entry(key2), Entry(key2 + 1));
+
+ cache1.Remove(key2);
+
+ if (loc)
+ CheckNoCallback(100);
+ else
+ CheckCallbackSingle(key2, Entry(key2 + 1), null);
+ }
+
+ cache1.Put(key1, Entry(key1));
+ CheckNoCallback(100);
+
+ cache1.Put(key2, Entry(key2));
+ CheckNoCallback(100);
+ }
+
+ /// <summary>
+ /// Test Ignite injection into callback.
+ /// </summary>
+ [Test]
+ public void TestCallbackInjection()
+ {
+ Listener<PortableEntry> cb = new Listener<PortableEntry>();
+
+ Assert.IsNull(cb.ignite);
+
+ using (cache1.QueryContinuous(new ContinuousQuery<int, PortableEntry>(cb)))
+ {
+ Assert.IsNotNull(cb.ignite);
+ }
+ }
+
+ /// <summary>
+ /// Test portable filter logic.
+ /// </summary>
+ [Test]
+ public void TestFilterPortable()
+ {
+ CheckFilter(true, false);
+ }
+
+ /// <summary>
+ /// Test serializable filter logic.
+ /// </summary>
+ [Test]
+ public void TestFilterSerializable()
+ {
+ CheckFilter(false, false);
+ }
+
+ /// <summary>
+ /// Check filter.
+ /// </summary>
+ /// <param name="portable">Portable.</param>
+ /// <param name="loc">Local cache flag.</param>
+ protected void CheckFilter(bool portable, bool loc)
+ {
+ ICacheEntryEventListener<int, PortableEntry> lsnr = new Listener<PortableEntry>();
+ ICacheEntryEventFilter<int, PortableEntry> filter =
+ portable ? (AbstractFilter<PortableEntry>)new PortableFilter() : new SerializableFilter();
+
+ ContinuousQuery<int, PortableEntry> qry = loc ?
+ new ContinuousQuery<int, PortableEntry>(lsnr, filter, true) :
+ new ContinuousQuery<int, PortableEntry>(lsnr, filter);
+
+ using (cache1.QueryContinuous(qry))
+ {
+ // Put from local node.
+ int key1 = PrimaryKey(cache1);
+ cache1.GetAndPut(key1, Entry(key1));
+ CheckFilterSingle(key1, null, Entry(key1));
+ CheckCallbackSingle(key1, null, Entry(key1));
+
+ // Put from remote node.
+ int key2 = PrimaryKey(cache2);
+ cache1.GetAndPut(key2, Entry(key2));
+
+ if (loc)
+ {
+ CheckNoFilter(key2);
+ CheckNoCallback(key2);
+ }
+ else
+ {
+ CheckFilterSingle(key2, null, Entry(key2));
+ CheckCallbackSingle(key2, null, Entry(key2));
+ }
+
+ AbstractFilter<PortableEntry>.res = false;
+
+ // Ignored put from local node.
+ cache1.GetAndPut(key1, Entry(key1 + 1));
+ CheckFilterSingle(key1, Entry(key1), Entry(key1 + 1));
+ CheckNoCallback(100);
+
+ // Ignored put from remote node.
+ cache1.GetAndPut(key2, Entry(key2 + 1));
+
+ if (loc)
+ CheckNoFilter(100);
+ else
+ CheckFilterSingle(key2, Entry(key2), Entry(key2 + 1));
+
+ CheckNoCallback(100);
+ }
+ }
+
+ /// <summary>
+ /// Test portable filter error during invoke.
+ /// </summary>
+ [Ignore("IGNITE-521")]
+ [Test]
+ public void TestFilterInvokeErrorPortable()
+ {
+ CheckFilterInvokeError(true);
+ }
+
+ /// <summary>
+ /// Test serializable filter error during invoke.
+ /// </summary>
+ [Ignore("IGNITE-521")]
+ [Test]
+ public void TestFilterInvokeErrorSerializable()
+ {
+ CheckFilterInvokeError(false);
+ }
+
+ /// <summary>
+ /// Check filter error handling logic during invoke.
+ /// </summary>
+ private void CheckFilterInvokeError(bool portable)
+ {
+ AbstractFilter<PortableEntry>.err = true;
+
+ ICacheEntryEventListener<int, PortableEntry> lsnr = new Listener<PortableEntry>();
+ ICacheEntryEventFilter<int, PortableEntry> filter =
+ portable ? (AbstractFilter<PortableEntry>) new PortableFilter() : new SerializableFilter();
+
+ ContinuousQuery<int, PortableEntry> qry = new ContinuousQuery<int, PortableEntry>(lsnr, filter);
+
+ using (cache1.QueryContinuous(qry))
+ {
+ // Put from local node.
+ try
+ {
+ cache1.GetAndPut(PrimaryKey(cache1), Entry(1));
+
+ Assert.Fail("Should not reach this place.");
+ }
+ catch (IgniteException)
+ {
+ // No-op.
+ }
+ catch (Exception)
+ {
+ Assert.Fail("Unexpected error.");
+ }
+
+ // Put from remote node.
+ try
+ {
+ cache1.GetAndPut(PrimaryKey(cache2), Entry(1));
+
+ Assert.Fail("Should not reach this place.");
+ }
+ catch (IgniteException)
+ {
+ // No-op.
+ }
+ catch (Exception)
+ {
+ Assert.Fail("Unexpected error.");
+ }
+ }
+ }
+
+ /// <summary>
+ /// Test portable filter marshalling error.
+ /// </summary>
+ [Test]
+ public void TestFilterMarshalErrorPortable()
+ {
+ CheckFilterMarshalError(true);
+ }
+
+ /// <summary>
+ /// Test serializable filter marshalling error.
+ /// </summary>
+ [Test]
+ public void TestFilterMarshalErrorSerializable()
+ {
+ CheckFilterMarshalError(false);
+ }
+
+ /// <summary>
+ /// Check filter marshal error handling.
+ /// </summary>
+ /// <param name="portable">Portable flag.</param>
+ private void CheckFilterMarshalError(bool portable)
+ {
+ AbstractFilter<PortableEntry>.marshErr = true;
+
+ ICacheEntryEventListener<int, PortableEntry> lsnr = new Listener<PortableEntry>();
+ ICacheEntryEventFilter<int, PortableEntry> filter =
+ portable ? (AbstractFilter<PortableEntry>)new PortableFilter() : new SerializableFilter();
+
+ ContinuousQuery<int, PortableEntry> qry = new ContinuousQuery<int, PortableEntry>(lsnr, filter);
+
+ Assert.Throws<Exception>(() =>
+ {
+ using (cache1.QueryContinuous(qry))
+ {
+ // No-op.
+ }
+ });
+ }
+
+ /// <summary>
+ /// Test non-serializable filter error.
+ /// </summary>
+ [Test]
+ public void TestFilterNonSerializable()
+ {
+ CheckFilterNonSerializable(false);
+ }
+
+ /// <summary>
+ /// Test non-serializable filter behavior.
+ /// </summary>
+ /// <param name="loc"></param>
+ protected void CheckFilterNonSerializable(bool loc)
+ {
+ AbstractFilter<PortableEntry>.unmarshErr = true;
+
+ ICacheEntryEventListener<int, PortableEntry> lsnr = new Listener<PortableEntry>();
+ ICacheEntryEventFilter<int, PortableEntry> filter = new LocalFilter();
+
+ ContinuousQuery<int, PortableEntry> qry = loc
+ ? new ContinuousQuery<int, PortableEntry>(lsnr, filter, true)
+ : new ContinuousQuery<int, PortableEntry>(lsnr, filter);
+
+ if (loc)
+ {
+ using (cache1.QueryContinuous(qry))
+ {
+ // Local put must be fine.
+ int key1 = PrimaryKey(cache1);
+ cache1.GetAndPut(key1, Entry(key1));
+ CheckFilterSingle(key1, null, Entry(key1));
+ }
+ }
+ else
+ {
+ Assert.Throws<SerializationException>(() =>
+ {
+ using (cache1.QueryContinuous(qry))
+ {
+ // No-op.
+ }
+ });
+ }
+ }
+
+ /// <summary>
+ /// Test portable filter unmarshalling error.
+ /// </summary>
+ [Ignore("IGNITE-521")]
+ [Test]
+ public void TestFilterUnmarshalErrorPortable()
+ {
+ CheckFilterUnmarshalError(true);
+ }
+
+ /// <summary>
+ /// Test serializable filter unmarshalling error.
+ /// </summary>
+ [Ignore("IGNITE-521")]
+ [Test]
+ public void TestFilterUnmarshalErrorSerializable()
+ {
+ CheckFilterUnmarshalError(false);
+ }
+
+ /// <summary>
+ /// Check filter unmarshal error handling.
+ /// </summary>
+ /// <param name="portable">Portable flag.</param>
+ private void CheckFilterUnmarshalError(bool portable)
+ {
+ AbstractFilter<PortableEntry>.unmarshErr = true;
+
+ ICacheEntryEventListener<int, PortableEntry> lsnr = new Listener<PortableEntry>();
+ ICacheEntryEventFilter<int, PortableEntry> filter =
+ portable ? (AbstractFilter<PortableEntry>)new PortableFilter() : new SerializableFilter();
+
+ ContinuousQuery<int, PortableEntry> qry = new ContinuousQuery<int, PortableEntry>(lsnr, filter);
+
+ using (cache1.QueryContinuous(qry))
+ {
+ // Local put must be fine.
+ int key1 = PrimaryKey(cache1);
+ cache1.GetAndPut(key1, Entry(key1));
+ CheckFilterSingle(key1, null, Entry(key1));
+
+ // Remote put must fail.
+ try
+ {
+ cache1.GetAndPut(PrimaryKey(cache2), Entry(1));
+
+ Assert.Fail("Should not reach this place.");
+ }
+ catch (IgniteException)
+ {
+ // No-op.
+ }
+ catch (Exception)
+ {
+ Assert.Fail("Unexpected error.");
+ }
+ }
+ }
+
+ /// <summary>
+ /// Test Ignite injection into filters.
+ /// </summary>
+ [Test]
+ public void TestFilterInjection()
+ {
+ Listener<PortableEntry> cb = new Listener<PortableEntry>();
+ PortableFilter filter = new PortableFilter();
+
+ Assert.IsNull(filter.ignite);
+
+ using (cache1.QueryContinuous(new ContinuousQuery<int, PortableEntry>(cb, filter)))
+ {
+ // Local injection.
+ Assert.IsNotNull(filter.ignite);
+
+ // Remote injection.
+ cache1.GetAndPut(PrimaryKey(cache2), Entry(1));
+
+ FilterEvent evt;
+
+ Assert.IsTrue(FILTER_EVTS.TryTake(out evt, 500));
+
+ Assert.IsNotNull(evt.ignite);
+ }
+ }
+
+
+ /// <summary>
+ /// Test "keep-portable" scenario.
+ /// </summary>
+ [Test]
+ public void TestKeepPortable()
+ {
+ var cache = cache1.WithKeepPortable<int, IPortableObject>();
+
+ ContinuousQuery<int, IPortableObject> qry = new ContinuousQuery<int, IPortableObject>(
+ new Listener<IPortableObject>(), new KeepPortableFilter());
+
+ using (cache.QueryContinuous(qry))
+ {
+ // 1. Local put.
+ cache1.GetAndPut(PrimaryKey(cache1), Entry(1));
+
+ CallbackEvent cbEvt;
+ FilterEvent filterEvt;
+
+ Assert.IsTrue(FILTER_EVTS.TryTake(out filterEvt, 500));
+ Assert.AreEqual(PrimaryKey(cache1), filterEvt.entry.Key);
+ Assert.AreEqual(null, filterEvt.entry.OldValue);
+ Assert.AreEqual(Entry(1), (filterEvt.entry.Value as IPortableObject)
+ .Deserialize<PortableEntry>());
+
+ Assert.IsTrue(CB_EVTS.TryTake(out cbEvt, 500));
+ Assert.AreEqual(1, cbEvt.entries.Count);
+ Assert.AreEqual(PrimaryKey(cache1), cbEvt.entries.First().Key);
+ Assert.AreEqual(null, cbEvt.entries.First().OldValue);
+ Assert.AreEqual(Entry(1), (cbEvt.entries.First().Value as IPortableObject)
+ .Deserialize<PortableEntry>());
+
+ // 2. Remote put.
+ cache1.GetAndPut(PrimaryKey(cache2), Entry(2));
+
+ Assert.IsTrue(FILTER_EVTS.TryTake(out filterEvt, 500));
+ Assert.AreEqual(PrimaryKey(cache2), filterEvt.entry.Key);
+ Assert.AreEqual(null, filterEvt.entry.OldValue);
+ Assert.AreEqual(Entry(2), (filterEvt.entry.Value as IPortableObject)
+ .Deserialize<PortableEntry>());
+
+ Assert.IsTrue(CB_EVTS.TryTake(out cbEvt, 500));
+ Assert.AreEqual(1, cbEvt.entries.Count);
+ Assert.AreEqual(PrimaryKey(cache2), cbEvt.entries.First().Key);
+ Assert.AreEqual(null, cbEvt.entries.First().OldValue);
+ Assert.AreEqual(Entry(2),
+ (cbEvt.entries.First().Value as IPortableObject).Deserialize<PortableEntry>());
+ }
+ }
+
+ /// <summary>
+ /// Test whether buffer size works fine.
+ /// </summary>
+ [Test]
+ public void TestBufferSize()
+ {
+ // Put two remote keys in advance.
+ List<int> rmtKeys = PrimaryKeys(cache2, 2);
+
+ ContinuousQuery<int, PortableEntry> qry = new ContinuousQuery<int, PortableEntry>(new Listener<PortableEntry>());
+
+ qry.BufferSize = 2;
+ qry.TimeInterval = TimeSpan.FromMilliseconds(1000000);
+
+ using (cache1.QueryContinuous(qry))
+ {
+ qry.BufferSize = 2;
+
+ cache1.GetAndPut(rmtKeys[0], Entry(rmtKeys[0]));
+
+ CheckNoCallback(100);
+
+ cache1.GetAndPut(rmtKeys[1], Entry(rmtKeys[1]));
+
+ CallbackEvent evt;
+
+ Assert.IsTrue(CB_EVTS.TryTake(out evt, 1000));
+
+ Assert.AreEqual(2, evt.entries.Count);
+
+ var entryRmt0 = evt.entries.Single(entry => { return entry.Key.Equals(rmtKeys[0]); });
+ var entryRmt1 = evt.entries.Single(entry => { return entry.Key.Equals(rmtKeys[1]); });
+
+ Assert.AreEqual(rmtKeys[0], entryRmt0.Key);
+ Assert.IsNull(entryRmt0.OldValue);
+ Assert.AreEqual(Entry(rmtKeys[0]), entryRmt0.Value);
+
+ Assert.AreEqual(rmtKeys[1], entryRmt1.Key);
+ Assert.IsNull(entryRmt1.OldValue);
+ Assert.AreEqual(Entry(rmtKeys[1]), entryRmt1.Value);
+ }
+
+ cache1.Remove(rmtKeys[0]);
+ cache1.Remove(rmtKeys[1]);
+ }
+
+ /// <summary>
+ /// Test whether timeout works fine.
+ /// </summary>
+ [Test]
+ public void TestTimeout()
+ {
+ int key1 = PrimaryKey(cache1);
+ int key2 = PrimaryKey(cache2);
+
+ ContinuousQuery<int, PortableEntry> qry =
+ new ContinuousQuery<int, PortableEntry>(new Listener<PortableEntry>());
+
+ qry.BufferSize = 2;
+ qry.TimeInterval = TimeSpan.FromMilliseconds(500);
+
+ using (cache1.QueryContinuous(qry))
+ {
+ // Put from local node.
+ cache1.GetAndPut(key1, Entry(key1));
+ CheckCallbackSingle(key1, null, Entry(key1));
+
+ // Put from remote node.
+ cache1.GetAndPut(key2, Entry(key2));
+ CheckNoCallback(100);
+ CheckCallbackSingle(key2, null, Entry(key2), 1000);
+ }
+ }
+
+ /// <summary>
+ /// Test whether nested Ignite API call from callback works fine.
+ /// </summary>
+ [Test]
+ public void TestNestedCallFromCallback()
+ {
+ var cache = cache1.WithKeepPortable<int, IPortableObject>();
+
+ int key = PrimaryKey(cache1);
+
+ NestedCallListener cb = new NestedCallListener();
+
+ using (cache.QueryContinuous(new ContinuousQuery<int, IPortableObject>(cb)))
+ {
+ cache1.GetAndPut(key, Entry(key));
+
+ cb.countDown.Wait();
+ }
+
+ cache.Remove(key);
+ }
+
+ /// <summary>
+ /// Tests the initial query.
+ /// </summary>
+ [Test]
+ public void TestInitialQuery()
+ {
+ // Scan query, GetAll
+ TestInitialQuery(new ScanQuery<int, PortableEntry>(new InitialQueryScanFilter()), cur => cur.GetAll());
+
+ // Scan query, iterator
+ TestInitialQuery(new ScanQuery<int, PortableEntry>(new InitialQueryScanFilter()), cur => cur.ToList());
+
+ // Sql query, GetAll
+ TestInitialQuery(new SqlQuery(typeof(PortableEntry), "val < 33"), cur => cur.GetAll());
+
+ // Sql query, iterator
+ TestInitialQuery(new SqlQuery(typeof(PortableEntry), "val < 33"), cur => cur.ToList());
+
+ // Text query, GetAll
+ TestInitialQuery(new TextQuery(typeof(PortableEntry), "1*"), cur => cur.GetAll());
+
+ // Text query, iterator
+ TestInitialQuery(new TextQuery(typeof(PortableEntry), "1*"), cur => cur.ToList());
+
+ // Test exception: invalid initial query
+ var ex = Assert.Throws<IgniteException>(
+ () => TestInitialQuery(new TextQuery(typeof (PortableEntry), "*"), cur => cur.GetAll()));
+
+ Assert.AreEqual("Cannot parse '*': '*' or '?' not allowed as first character in WildcardQuery", ex.Message);
+ }
+
+ /// <summary>
+ /// Tests the initial query.
+ /// </summary>
+ private void TestInitialQuery(QueryBase initialQry, Func<IQueryCursor<ICacheEntry<int, PortableEntry>>,
+ IEnumerable<ICacheEntry<int, PortableEntry>>> getAllFunc)
+ {
+ var qry = new ContinuousQuery<int, PortableEntry>(new Listener<PortableEntry>());
+
+ cache1.Put(11, Entry(11));
+ cache1.Put(12, Entry(12));
+ cache1.Put(33, Entry(33));
+
+ try
+ {
+ IContinuousQueryHandle<ICacheEntry<int, PortableEntry>> contQry;
+
+ using (contQry = cache1.QueryContinuous(qry, initialQry))
+ {
+ // Check initial query
+ var initialEntries =
+ getAllFunc(contQry.GetInitialQueryCursor()).Distinct().OrderBy(x => x.Key).ToList();
+
+ Assert.Throws<InvalidOperationException>(() => contQry.GetInitialQueryCursor());
+
+ Assert.AreEqual(2, initialEntries.Count);
+
+ for (int i = 0; i < initialEntries.Count; i++)
+ {
+ Assert.AreEqual(i + 11, initialEntries[i].Key);
+ Assert.AreEqual(i + 11, initialEntries[i].Value.val);
+ }
+
+ // Check continuous query
+ cache1.Put(44, Entry(44));
+ CheckCallbackSingle(44, null, Entry(44));
+ }
+
+ Assert.Throws<ObjectDisposedException>(() => contQry.GetInitialQueryCursor());
+
+ contQry.Dispose(); // multiple dispose calls are ok
+ }
+ finally
+ {
+ cache1.Clear();
+ }
+ }
+
+ /// <summary>
+ /// Check single filter event.
+ /// </summary>
+ /// <param name="expKey">Expected key.</param>
+ /// <param name="expOldVal">Expected old value.</param>
+ /// <param name="expVal">Expected value.</param>
+ private void CheckFilterSingle(int expKey, PortableEntry expOldVal, PortableEntry expVal)
+ {
+ CheckFilterSingle(expKey, expOldVal, expVal, 1000);
+ }
+
+ /// <summary>
+ /// Check single filter event.
+ /// </summary>
+ /// <param name="expKey">Expected key.</param>
+ /// <param name="expOldVal">Expected old value.</param>
+ /// <param name="expVal">Expected value.</param>
+ /// <param name="timeout">Timeout.</param>
+ private void CheckFilterSingle(int expKey, PortableEntry expOldVal, PortableEntry expVal, int timeout)
+ {
+ FilterEvent evt;
+
+ Assert.IsTrue(FILTER_EVTS.TryTake(out evt, timeout));
+
+ Assert.AreEqual(expKey, evt.entry.Key);
+ Assert.AreEqual(expOldVal, evt.entry.OldValue);
+ Assert.AreEqual(expVal, evt.entry.Value);
+ }
+
+ /// <summary>
+ /// Ensure that no filter events are logged.
+ /// </summary>
+ /// <param name="timeout">Timeout.</param>
+ private void CheckNoFilter(int timeout)
+ {
+ FilterEvent evt;
+
+ Assert.IsFalse(FILTER_EVTS.TryTake(out evt, timeout));
+ }
+
+ /// <summary>
+ /// Check single callback event.
+ /// </summary>
+ /// <param name="expKey">Expected key.</param>
+ /// <param name="expOldVal">Expected old value.</param>
+ /// <param name="expVal">Expected new value.</param>
+ private void CheckCallbackSingle(int expKey, PortableEntry expOldVal, PortableEntry expVal)
+ {
+ CheckCallbackSingle(expKey, expOldVal, expVal, 1000);
+ }
+
+ /// <summary>
+ /// Check single callback event.
+ /// </summary>
+ /// <param name="expKey">Expected key.</param>
+ /// <param name="expOldVal">Expected old value.</param>
+ /// <param name="expVal">Expected new value.</param>
+ /// <param name="timeout">Timeout.</param>
+ private void CheckCallbackSingle(int expKey, PortableEntry expOldVal, PortableEntry expVal, int timeout)
+ {
+ CallbackEvent evt;
+
+ Assert.IsTrue(CB_EVTS.TryTake(out evt, timeout));
+
+ Assert.AreEqual(1, evt.entries.Count);
+
+ Assert.AreEqual(expKey, evt.entries.First().Key);
+ Assert.AreEqual(expOldVal, evt.entries.First().OldValue);
+ Assert.AreEqual(expVal, evt.entries.First().Value);
+ }
+
+ /// <summary>
+ /// Ensure that no callback events are logged.
+ /// </summary>
+ /// <param name="timeout">Timeout.</param>
+ private void CheckNoCallback(int timeout)
+ {
+ CallbackEvent evt;
+
+ Assert.IsFalse(CB_EVTS.TryTake(out evt, timeout));
+ }
+
+ /// <summary>
+ /// Craate entry.
+ /// </summary>
+ /// <param name="val">Value.</param>
+ /// <returns>Entry.</returns>
+ private static PortableEntry Entry(int val)
+ {
+ return new PortableEntry(val);
+ }
+
+ /// <summary>
+ /// Get primary key for cache.
+ /// </summary>
+ /// <param name="cache">Cache.</param>
+ /// <returns>Primary key.</returns>
+ private static int PrimaryKey<T>(ICache<int, T> cache)
+ {
+ return PrimaryKeys(cache, 1)[0];
+ }
+
+ /// <summary>
+ /// Get primary keys for cache.
+ /// </summary>
+ /// <param name="cache">Cache.</param>
+ /// <param name="cnt">Amount of keys.</param>
+ /// <param name="startFrom">Value to start from.</param>
+ /// <returns></returns>
+ private static List<int> PrimaryKeys<T>(ICache<int, T> cache, int cnt, int startFrom = 0)
+ {
+ IClusterNode node = cache.Ignite.GetCluster().GetLocalNode();
+
+ ICacheAffinity aff = cache.Ignite.GetAffinity(cache.Name);
+
+ List<int> keys = new List<int>(cnt);
+
+ for (int i = startFrom; i < startFrom + 100000; i++)
+ {
+ if (aff.IsPrimary(node, i))
+ {
+ keys.Add(i);
+
+ if (keys.Count == cnt)
+ return keys;
+ }
+ }
+
+ Assert.Fail("Failed to find " + cnt + " primary keys.");
+
+ return null;
+ }
+
+ /// <summary>
+ /// Portable entry.
+ /// </summary>
+ public class PortableEntry
+ {
+ /** Value. */
+ public readonly int val;
+
+ /** <inheritDot /> */
+ public override int GetHashCode()
+ {
+ return val;
+ }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="val">Value.</param>
+ public PortableEntry(int val)
+ {
+ this.val = val;
+ }
+
+ /** <inheritDoc /> */
+ public override bool Equals(object obj)
+ {
+ return obj != null && obj is PortableEntry && ((PortableEntry)obj).val == val;
+ }
+ }
+
+ /// <summary>
+ /// Abstract filter.
+ /// </summary>
+ [Serializable]
+ public abstract class AbstractFilter<V> : ICacheEntryEventFilter<int, V>
+ {
+ /** Result. */
+ public static volatile bool res = true;
+
+ /** Throw error on invocation. */
+ public static volatile bool err;
+
+ /** Throw error during marshalling. */
+ public static volatile bool marshErr;
+
+ /** Throw error during unmarshalling. */
+ public static volatile bool unmarshErr;
+
+ /** Grid. */
+ [InstanceResource]
+ public IIgnite ignite;
+
+ /** <inheritDoc /> */
+ public bool Evaluate(ICacheEntryEvent<int, V> evt)
+ {
+ if (err)
+ throw new Exception("Filter error.");
+
+ FILTER_EVTS.Add(new FilterEvent(ignite,
+ CQU.CreateEvent<object, object>(evt.Key, evt.OldValue, evt.Value)));
+
+ return res;
+ }
+ }
+
+ /// <summary>
+ /// Filter which cannot be serialized.
+ /// </summary>
+ public class LocalFilter : AbstractFilter<PortableEntry>
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Portable filter.
+ /// </summary>
+ public class PortableFilter : AbstractFilter<PortableEntry>, IPortableMarshalAware
+ {
+ /** <inheritDoc /> */
+ public void WritePortable(IPortableWriter writer)
+ {
+ if (marshErr)
+ throw new Exception("Filter marshalling error.");
+ }
+
+ /** <inheritDoc /> */
+ public void ReadPortable(IPortableReader reader)
+ {
+ if (unmarshErr)
+ throw new Exception("Filter unmarshalling error.");
+ }
+ }
+
+ /// <summary>
+ /// Serializable filter.
+ /// </summary>
+ [Serializable]
+ public class SerializableFilter : AbstractFilter<PortableEntry>, ISerializable
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public SerializableFilter()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Serialization constructor.
+ /// </summary>
+ /// <param name="info">Info.</param>
+ /// <param name="context">Context.</param>
+ protected SerializableFilter(SerializationInfo info, StreamingContext context)
+ {
+ if (unmarshErr)
+ throw new Exception("Filter unmarshalling error.");
+ }
+
+ /** <inheritDoc /> */
+ public void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ if (marshErr)
+ throw new Exception("Filter marshalling error.");
+ }
+ }
+
+ /// <summary>
+ /// Filter for "keep-portable" scenario.
+ /// </summary>
+ public class KeepPortableFilter : AbstractFilter<IPortableObject>
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Listener.
+ /// </summary>
+ public class Listener<V> : ICacheEntryEventListener<int, V>
+ {
+ [InstanceResource]
+ public IIgnite ignite;
+
+ /** <inheritDoc /> */
+ public void OnEvent(IEnumerable<ICacheEntryEvent<int, V>> evts)
+ {
+ ICollection<ICacheEntryEvent<object, object>> entries0 =
+ new List<ICacheEntryEvent<object, object>>();
+
+ foreach (ICacheEntryEvent<int, V> evt in evts)
+ entries0.Add(CQU.CreateEvent<object, object>(evt.Key, evt.OldValue, evt.Value));
+
+ CB_EVTS.Add(new CallbackEvent(entries0));
+ }
+ }
+
+ /// <summary>
+ /// Listener with nested Ignite API call.
+ /// </summary>
+ public class NestedCallListener : ICacheEntryEventListener<int, IPortableObject>
+ {
+ /** Event. */
+ public readonly CountdownEvent countDown = new CountdownEvent(1);
+
+ public void OnEvent(IEnumerable<ICacheEntryEvent<int, IPortableObject>> evts)
+ {
+ foreach (ICacheEntryEvent<int, IPortableObject> evt in evts)
+ {
+ IPortableObject val = evt.Value;
+
+ IPortableMetadata meta = val.GetMetadata();
+
+ Assert.AreEqual(typeof(PortableEntry).Name, meta.TypeName);
+ }
+
+ countDown.Signal();
+ }
+ }
+
+ /// <summary>
+ /// Filter event.
+ /// </summary>
+ public class FilterEvent
+ {
+ /** Grid. */
+ public IIgnite ignite;
+
+ /** Entry. */
+ public ICacheEntryEvent<object, object> entry;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="ignite">Grid.</param>
+ /// <param name="entry">Entry.</param>
+ public FilterEvent(IIgnite ignite, ICacheEntryEvent<object, object> entry)
+ {
+ this.ignite = ignite;
+ this.entry = entry;
+ }
+ }
+
+ /// <summary>
+ /// Callbakc event.
+ /// </summary>
+ public class CallbackEvent
+ {
+ /** Entries. */
+ public ICollection<ICacheEntryEvent<object, object>> entries;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="entries">Entries.</param>
+ public CallbackEvent(ICollection<ICacheEntryEvent<object, object>> entries)
+ {
+ this.entries = entries;
+ }
+ }
+
+ /// <summary>
+ /// ScanQuery filter for InitialQuery test.
+ /// </summary>
+ [Serializable]
+ private class InitialQueryScanFilter : ICacheEntryFilter<int, PortableEntry>
+ {
+ /** <inheritdoc /> */
+ public bool Invoke(ICacheEntry<int, PortableEntry> entry)
+ {
+ return entry.Key < 33;
+ }
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAtomicBackupTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAtomicBackupTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAtomicBackupTest.cs
new file mode 100644
index 0000000..ac44f10
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAtomicBackupTest.cs
@@ -0,0 +1,33 @@
+/*
+ * 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.Cache.Query.Continuous
+{
+ /// <summary>
+ /// Continuous query tests for ATOMIC cache with backups.
+ /// </summary>
+ public class ContinuousQueryAtomiclBackupTest : ContinuousQueryAbstractTest
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public ContinuousQueryAtomiclBackupTest() : base(CACHE_ATOMIC_BACKUP)
+ {
+ // No-op.
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAtomicNoBackupTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAtomicNoBackupTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAtomicNoBackupTest.cs
new file mode 100644
index 0000000..8e1a18f
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAtomicNoBackupTest.cs
@@ -0,0 +1,34 @@
+/*
+ * 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.Cache.Query.Continuous
+{
+ /// <summary>
+ /// Continuous query tests for ATOMIC cache with no backups.
+ /// </summary>
+ public class ContinuousQueryAtomiclNoBackupTest : ContinuousQueryNoBackupAbstractTest
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public ContinuousQueryAtomiclNoBackupTest()
+ : base(CACHE_ATOMIC_NO_BACKUP)
+ {
+ // No-op.
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryNoBackupAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryNoBackupAbstractTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryNoBackupAbstractTest.cs
new file mode 100644
index 0000000..aa7d627
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryNoBackupAbstractTest.cs
@@ -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.
+ */
+
+namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
+{
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests for ocntinuous query when there are no backups.
+ /// </summary>
+ public abstract class ContinuousQueryNoBackupAbstractTest : ContinuousQueryAbstractTest
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="cacheName">Cache name.</param>
+ protected ContinuousQueryNoBackupAbstractTest(string cacheName) : base(cacheName)
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Test regular callback operations for local query.
+ /// </summary>
+ [Test]
+ public void TestCallbackLocal()
+ {
+ CheckCallback(true);
+ }
+
+ /// <summary>
+ /// Test portable filter logic.
+ /// </summary>
+ [Test]
+ public void TestFilterPortableLocal()
+ {
+ CheckFilter(true, true);
+ }
+
+ /// <summary>
+ /// Test serializable filter logic.
+ /// </summary>
+ [Test]
+ public void TestFilterSerializableLocal()
+ {
+ CheckFilter(false, true);
+ }
+
+ /// <summary>
+ /// Test non-serializable filter for local query.
+ /// </summary>
+ [Test]
+ public void TestFilterNonSerializableLocal()
+ {
+ CheckFilterNonSerializable(true);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTransactionalBackupTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTransactionalBackupTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTransactionalBackupTest.cs
new file mode 100644
index 0000000..08ae88c
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTransactionalBackupTest.cs
@@ -0,0 +1,34 @@
+/*
+ * 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.Cache.Query.Continuous
+{
+ /// <summary>
+ /// Continuous query tests for TRANSACTIONAL cache with backups.
+ /// </summary>
+ public class ContinuousQueryTransactionalBackupTest : ContinuousQueryAbstractTest
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public ContinuousQueryTransactionalBackupTest()
+ : base(CACHE_TX_BACKUP)
+ {
+ // No-op.
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTransactionalNoBackupTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTransactionalNoBackupTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTransactionalNoBackupTest.cs
new file mode 100644
index 0000000..685f7b4
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTransactionalNoBackupTest.cs
@@ -0,0 +1,33 @@
+/*
+ * 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.Cache.Query.Continuous
+{
+ /// <summary>
+ /// Continuous query tests for TRANSACTIONAL cache with no backups.
+ /// </summary>
+ public class ContinuousQueryTransactionalNoBackupTest : ContinuousQueryNoBackupAbstractTest
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public ContinuousQueryTransactionalNoBackupTest() : base(CACHE_TX_NO_BACKUP)
+ {
+ // No-op.
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheParallelLoadStoreTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheParallelLoadStoreTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheParallelLoadStoreTest.cs
new file mode 100644
index 0000000..a7d9adb
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheParallelLoadStoreTest.cs
@@ -0,0 +1,110 @@
+/*
+ * 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.Cache.Store
+{
+ using System;
+ using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Portable;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests for GridCacheParallelLoadStoreAdapter.
+ /// </summary>
+ public class CacheParallelLoadStoreTest
+ {
+ // object store name
+ private const string ObjectStoreCacheName = "object_store_parallel";
+
+ /// <summary>
+ /// Set up test class.
+ /// </summary>
+ [TestFixtureSetUp]
+ public virtual void BeforeTests()
+ {
+ TestUtils.KillProcesses();
+ TestUtils.JvmDebug = true;
+
+ Ignition.Start(new IgniteConfiguration
+ {
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = TestUtils.TestJavaOptions(),
+ SpringConfigUrl = "config\\native-client-test-cache-parallel-store.xml",
+ PortableConfiguration = new PortableConfiguration
+ {
+ Types = new[] {typeof (CacheTestParallelLoadStore.Record).FullName}
+ }
+ });
+ }
+
+ /// <summary>
+ /// Tear down test class.
+ /// </summary>
+ [TestFixtureTearDown]
+ public virtual void AfterTests()
+ {
+ Ignition.StopAll(true);
+ }
+
+ /// <summary>
+ /// Test setup.
+ /// </summary>
+ [SetUp]
+ public void BeforeTest()
+ {
+ Console.WriteLine("Test started: " + TestContext.CurrentContext.Test.Name);
+ }
+
+ /// <summary>
+ /// Tests the LoadCache.
+ /// </summary>
+ [Test]
+ public void TestLoadCache()
+ {
+ var cache = GetCache();
+
+ Assert.AreEqual(0, cache.GetSize());
+
+ const int minId = 113;
+ const int expectedItemCount = CacheTestParallelLoadStore.InputDataLength - minId;
+
+ CacheTestParallelLoadStore.ResetCounters();
+
+ cache.LocalLoadCache(null, minId);
+
+ Assert.AreEqual(expectedItemCount, cache.GetSize());
+
+ // check items presence; increment by 100 to speed up the test
+ for (var i = minId; i < expectedItemCount; i += 100)
+ {
+ var rec = cache.Get(i);
+ Assert.AreEqual(i, rec.Id);
+ }
+
+ // check that items were processed in parallel
+ Assert.GreaterOrEqual(CacheTestParallelLoadStore.UniqueThreadCount, Environment.ProcessorCount);
+ }
+
+ /// <summary>
+ /// Gets the cache.
+ /// </summary>
+ private static ICache<int, CacheTestParallelLoadStore.Record> GetCache()
+ {
+ return Ignition.GetIgnite().GetCache<int, CacheTestParallelLoadStore.Record>(ObjectStoreCacheName);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs
new file mode 100644
index 0000000..137215e
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs
@@ -0,0 +1,285 @@
+/*
+ * 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.Cache.Store
+{
+ using System;
+ using System.Collections.Concurrent;
+ using System.Collections.Generic;
+ using System.Linq;
+ using Apache.Ignite.Core.Cache.Store;
+ using Apache.Ignite.Core.Impl;
+ using Apache.Ignite.Core.Resource;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests for store session.
+ /// </summary>
+ public class CacheStoreSessionTest
+ {
+ /** Grid name. */
+ private const string IgniteName = "grid";
+
+ /** Cache 1 name. */
+ private const string Cache1 = "cache1";
+
+ /** Cache 2 name. */
+ private const string Cache2 = "cache2";
+
+ /** Operations. */
+ private static ConcurrentBag<ICollection<Operation>> _dumps;
+
+ /// <summary>
+ /// Set up routine.
+ /// </summary>
+ [TestFixtureSetUp]
+ public virtual void BeforeTests()
+ {
+ //TestUtils.JVM_DEBUG = true;
+
+ TestUtils.KillProcesses();
+
+ TestUtils.JvmDebug = true;
+
+ IgniteConfigurationEx cfg = new IgniteConfigurationEx
+ {
+ GridName = IgniteName,
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = TestUtils.TestJavaOptions(),
+ SpringConfigUrl = @"config\cache\store\cache-store-session.xml"
+ };
+
+
+ Ignition.Start(cfg);
+ }
+
+ /// <summary>
+ /// Tear down routine.
+ /// </summary>
+ [TestFixtureTearDown]
+ public virtual void AfterTests()
+ {
+ Ignition.StopAll(true);
+ }
+
+ /// <summary>
+ /// Test basic session API.
+ /// </summary>
+ [Test]
+ public void TestSession()
+ {
+ _dumps = new ConcurrentBag<ICollection<Operation>>();
+
+ var ignite = Ignition.GetIgnite(IgniteName);
+
+ var cache1 = Ignition.GetIgnite(IgniteName).GetCache<int, int>(Cache1);
+ var cache2 = Ignition.GetIgnite(IgniteName).GetCache<int, int>(Cache2);
+
+ // 1. Test rollback.
+ using (var tx = ignite.GetTransactions().TxStart())
+ {
+ cache1.Put(1, 1);
+ cache2.Put(2, 2);
+
+ tx.Rollback();
+ }
+
+ Assert.AreEqual(1, _dumps.Count);
+ var ops = _dumps.First();
+ Assert.AreEqual(1, ops.Count);
+
+ Assert.AreEqual(1, ops.Count(op => op.Type == OperationType.SesEnd && !op.Commit));
+
+ _dumps = new ConcurrentBag<ICollection<Operation>>();
+
+ // 2. Test puts.
+ using (var tx = ignite.GetTransactions().TxStart())
+ {
+ cache1.Put(1, 1);
+ cache2.Put(2, 2);
+
+ tx.Commit();
+ }
+
+ Assert.AreEqual(1, _dumps.Count);
+ ops = _dumps.First();
+ Assert.AreEqual(3, ops.Count);
+
+ Assert.AreEqual(1, ops.Count(op => op.Type == OperationType.Write && Cache1.Equals(op.CacheName) && 1.Equals(op.Key) && 1.Equals(op.Value)));
+ Assert.AreEqual(1, ops.Count(op => op.Type == OperationType.Write && Cache2.Equals(op.CacheName) && 2.Equals(op.Key) && 2.Equals(op.Value)));
+ Assert.AreEqual(1, ops.Count(op => op.Type == OperationType.SesEnd && op.Commit));
+
+ _dumps = new ConcurrentBag<ICollection<Operation>>();
+
+ // 3. Test removes.
+ using (var tx = ignite.GetTransactions().TxStart())
+ {
+ cache1.Remove(1);
+ cache2.Remove(2);
+
+ tx.Commit();
+ }
+
+ Assert.AreEqual(1, _dumps.Count);
+ ops = _dumps.First();
+ Assert.AreEqual(3, ops.Count);
+
+ Assert.AreEqual(1, ops.Count(op => op.Type == OperationType.Delete && Cache1.Equals(op.CacheName) && 1.Equals(op.Key)));
+ Assert.AreEqual(1, ops.Count(op => op.Type == OperationType.Delete && Cache2.Equals(op.CacheName) && 2.Equals(op.Key)));
+ Assert.AreEqual(1, ops.Count(op => op.Type == OperationType.SesEnd && op.Commit));
+ }
+
+ /// <summary>
+ /// Dump operations.
+ /// </summary>
+ /// <param name="dump">Dump.</param>
+ internal static void DumpOperations(ICollection<Operation> dump)
+ {
+ _dumps.Add(dump);
+ }
+
+ /// <summary>
+ /// Test store implementation.
+ /// </summary>
+ public class Store : CacheStoreAdapter
+ {
+ /** Store session. */
+ [StoreSessionResource]
+#pragma warning disable 649
+ private ICacheStoreSession _ses;
+#pragma warning restore 649
+
+ /** <inheritdoc /> */
+ public override object Load(object key)
+ {
+ throw new NotImplementedException();
+ }
+
+ /** <inheritdoc /> */
+ public override void Write(object key, object val)
+ {
+ GetOperations().Add(new Operation(_ses.CacheName, OperationType.Write, (int)key, (int)val));
+ }
+
+ /** <inheritdoc /> */
+ public override void Delete(object key)
+ {
+ GetOperations().Add(new Operation(_ses.CacheName, OperationType.Delete, (int)key, 0));
+ }
+
+ /** <inheritdoc /> */
+ public override void SessionEnd(bool commit)
+ {
+ Operation op = new Operation(_ses.CacheName, OperationType.SesEnd) { Commit = commit };
+
+ ICollection<Operation> ops = GetOperations();
+
+ ops.Add(op);
+
+ DumpOperations(ops);
+ }
+
+ /// <summary>
+ /// Get collection with operations.
+ /// </summary>
+ /// <returns>Operations.</returns>
+ private ICollection<Operation> GetOperations()
+ {
+ object ops;
+
+ if (!_ses.Properties.TryGetValue("ops", out ops))
+ {
+ ops = new List<Operation>();
+
+ _ses.Properties["ops"] = ops;
+ }
+
+ return (ICollection<Operation>) ops;
+ }
+ }
+
+ /// <summary>
+ /// Logged operation.
+ /// </summary>
+ internal class Operation
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="cacheName">Cache name.</param>
+ /// <param name="type">Operation type.</param>
+ public Operation(string cacheName, OperationType type)
+ {
+ CacheName = cacheName;
+ Type = type;
+ }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="cacheName">Cache name.</param>
+ /// <param name="type">Operation type.</param>
+ /// <param name="key">Key.</param>
+ /// <param name="val">Value.</param>
+ public Operation(string cacheName, OperationType type, int key, int val) : this(cacheName, type)
+ {
+ Key = key;
+ Value = val;
+ }
+
+ /// <summary>
+ /// Cache name.
+ /// </summary>
+ public string CacheName { get; set; }
+
+ /// <summary>
+ /// Operation type.
+ /// </summary>
+ public OperationType Type { get; set; }
+
+ /// <summary>
+ /// Key.
+ /// </summary>
+ public int Key { get; set; }
+
+ /// <summary>
+ /// Value.
+ /// </summary>
+ public int Value { get; set; }
+
+ /// <summary>
+ /// Commit flag.
+ /// </summary>
+ public bool Commit { get; set; }
+ }
+
+ /// <summary>
+ /// Operation types.
+ /// </summary>
+ internal enum OperationType
+ {
+ /** Write. */
+ Write,
+
+ /** Delete. */
+ Delete,
+
+ /** Session end. */
+ SesEnd
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
new file mode 100644
index 0000000..bfafcf4
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
@@ -0,0 +1,510 @@
+/*
+ * 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.Cache.Store
+{
+ using System;
+ using System.Collections;
+ using System.Collections.Generic;
+ using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Impl;
+ using Apache.Ignite.Core.Portable;
+ using NUnit.Framework;
+
+ /// <summary>
+ ///
+ /// </summary>
+ class Key
+ {
+ private readonly int _idx;
+
+ public Key(int idx)
+ {
+ _idx = idx;
+ }
+
+ public int Index()
+ {
+ return _idx;
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (obj == null || obj.GetType() != GetType())
+ return false;
+
+ Key key = (Key)obj;
+
+ return key._idx == _idx;
+ }
+
+ public override int GetHashCode()
+ {
+ return _idx;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ class Value
+ {
+ private int _idx;
+
+ public Value(int idx)
+ {
+ _idx = idx;
+ }
+
+ public int Index()
+ {
+ return _idx;
+ }
+ }
+
+ /// <summary>
+ /// Cache entry predicate.
+ /// </summary>
+ [Serializable]
+ public class CacheEntryFilter : ICacheEntryFilter<int, string>
+ {
+ /** <inheritdoc /> */
+ public bool Invoke(ICacheEntry<int, string> entry)
+ {
+ return entry.Key >= 105;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public class CacheStoreTest
+ {
+ /** */
+ private const string PortableStoreCacheName = "portable_store";
+
+ /** */
+ private const string ObjectStoreCacheName = "object_store";
+
+ /** */
+ private const string CustomStoreCacheName = "custom_store";
+
+ /** */
+ private const string TemplateStoreCacheName = "template_store*";
+
+ /// <summary>
+ ///
+ /// </summary>
+ [TestFixtureSetUp]
+ public void BeforeTests()
+ {
+ //TestUtils.JVM_DEBUG = true;
+
+ TestUtils.KillProcesses();
+
+ TestUtils.JvmDebug = true;
+
+ IgniteConfigurationEx cfg = new IgniteConfigurationEx();
+
+ cfg.GridName = GridName();
+ cfg.JvmClasspath = TestUtils.CreateTestClasspath();
+ cfg.JvmOptions = TestUtils.TestJavaOptions();
+ cfg.SpringConfigUrl = "config\\native-client-test-cache-store.xml";
+
+ PortableConfiguration portCfg = new PortableConfiguration();
+
+ portCfg.Types = new List<string> { typeof(Key).FullName, typeof(Value).FullName };
+
+ cfg.PortableConfiguration = portCfg;
+
+ Ignition.Start(cfg);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [TestFixtureTearDown]
+ public virtual void AfterTests()
+ {
+ Ignition.StopAll(true);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [SetUp]
+ public void BeforeTest()
+ {
+ Console.WriteLine("Test started: " + TestContext.CurrentContext.Test.Name);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [TearDown]
+ public void AfterTest()
+ {
+ var cache = Cache();
+
+ cache.Clear();
+
+ Assert.IsTrue(cache.IsEmpty(), "Cache is not empty: " + cache.GetSize());
+
+ CacheTestStore.Reset();
+
+ Console.WriteLine("Test finished: " + TestContext.CurrentContext.Test.Name);
+ }
+
+ [Test]
+ public void TestLoadCache()
+ {
+ var cache = Cache();
+
+ Assert.AreEqual(0, cache.GetSize());
+
+ cache.LoadCache(new CacheEntryFilter(), 100, 10);
+
+ Assert.AreEqual(5, cache.GetSize());
+
+ for (int i = 105; i < 110; i++)
+ Assert.AreEqual("val_" + i, cache.Get(i));
+ }
+
+ [Test]
+ public void TestLocalLoadCache()
+ {
+ var cache = Cache();
+
+ Assert.AreEqual(0, cache.GetSize());
+
+ cache.LocalLoadCache(new CacheEntryFilter(), 100, 10);
+
+ Assert.AreEqual(5, cache.GetSize());
+
+ for (int i = 105; i < 110; i++)
+ Assert.AreEqual("val_" + i, cache.Get(i));
+ }
+
+ [Test]
+ public void TestLoadCacheMetadata()
+ {
+ CacheTestStore.LoadObjects = true;
+
+ var cache = Cache();
+
+ Assert.AreEqual(0, cache.GetSize());
+
+ cache.LocalLoadCache(null, 0, 3);
+
+ Assert.AreEqual(3, cache.GetSize());
+
+ var meta = cache.WithKeepPortable<Key, IPortableObject>().Get(new Key(0)).GetMetadata();
+
+ Assert.NotNull(meta);
+
+ Assert.AreEqual("Value", meta.TypeName);
+ }
+
+ [Test]
+ public void TestLoadCacheAsync()
+ {
+ var cache = Cache().WithAsync();
+
+ Assert.AreEqual(0, cache.GetSize());
+
+ cache.LocalLoadCache(new CacheEntryFilter(), 100, 10);
+
+ var fut = cache.GetFuture<object>();
+
+ fut.Get();
+
+ Assert.IsTrue(fut.IsDone);
+
+ cache.GetSize();
+ Assert.AreEqual(5, cache.GetFuture<int>().ToTask().Result);
+
+ for (int i = 105; i < 110; i++)
+ {
+ cache.Get(i);
+
+ Assert.AreEqual("val_" + i, cache.GetFuture<string>().ToTask().Result);
+ }
+ }
+
+ [Test]
+ public void TestPutLoad()
+ {
+ var cache = Cache();
+
+ cache.Put(1, "val");
+
+ IDictionary map = StoreMap();
+
+ Assert.AreEqual(1, map.Count);
+
+ cache.LocalEvict(new[] { 1 });
+
+ Assert.AreEqual(0, cache.GetSize());
+
+ Assert.AreEqual("val", cache.Get(1));
+
+ Assert.AreEqual(1, cache.GetSize());
+ }
+
+ [Test]
+ public void TestPutLoadPortables()
+ {
+ var cache = PortableStoreCache<int, Value>();
+
+ cache.Put(1, new Value(1));
+
+ IDictionary map = StoreMap();
+
+ Assert.AreEqual(1, map.Count);
+
+ IPortableObject v = (IPortableObject)map[1];
+
+ Assert.AreEqual(1, v.GetField<int>("_idx"));
+
+ cache.LocalEvict(new[] { 1 });
+
+ Assert.AreEqual(0, cache.GetSize());
+
+ Assert.AreEqual(1, cache.Get(1).Index());
+
+ Assert.AreEqual(1, cache.GetSize());
+ }
+
+ [Test]
+ public void TestPutLoadObjects()
+ {
+ var cache = ObjectStoreCache<int, Value>();
+
+ cache.Put(1, new Value(1));
+
+ IDictionary map = StoreMap();
+
+ Assert.AreEqual(1, map.Count);
+
+ Value v = (Value)map[1];
+
+ Assert.AreEqual(1, v.Index());
+
+ cache.LocalEvict(new[] { 1 });
+
+ Assert.AreEqual(0, cache.GetSize());
+
+ Assert.AreEqual(1, cache.Get(1).Index());
+
+ Assert.AreEqual(1, cache.GetSize());
+ }
+
+ [Test]
+ public void TestPutLoadAll()
+ {
+ var putMap = new Dictionary<int, string>();
+
+ for (int i = 0; i < 10; i++)
+ putMap.Add(i, "val_" + i);
+
+ var cache = Cache();
+
+ cache.PutAll(putMap);
+
+ IDictionary map = StoreMap();
+
+ Assert.AreEqual(10, map.Count);
+
+ for (int i = 0; i < 10; i++)
+ Assert.AreEqual("val_" + i, map[i]);
+
+ cache.Clear();
+
+ Assert.AreEqual(0, cache.GetSize());
+
+ ICollection<int> keys = new List<int>();
+
+ for (int i = 0; i < 10; i++)
+ keys.Add(i);
+
+ IDictionary<int, string> loaded = cache.GetAll(keys);
+
+ Assert.AreEqual(10, loaded.Count);
+
+ for (int i = 0; i < 10; i++)
+ Assert.AreEqual("val_" + i, loaded[i]);
+
+ Assert.AreEqual(10, cache.GetSize());
+ }
+
+ [Test]
+ public void TestRemove()
+ {
+ var cache = Cache();
+
+ for (int i = 0; i < 10; i++)
+ cache.Put(i, "val_" + i);
+
+ IDictionary map = StoreMap();
+
+ Assert.AreEqual(10, map.Count);
+
+ for (int i = 0; i < 5; i++)
+ cache.Remove(i);
+
+ Assert.AreEqual(5, map.Count);
+
+ for (int i = 5; i < 10; i++)
+ Assert.AreEqual("val_" + i, map[i]);
+ }
+
+ [Test]
+ public void TestRemoveAll()
+ {
+ var cache = Cache();
+
+ for (int i = 0; i < 10; i++)
+ cache.Put(i, "val_" + i);
+
+ IDictionary map = StoreMap();
+
+ Assert.AreEqual(10, map.Count);
+
+ cache.RemoveAll(new List<int> { 0, 1, 2, 3, 4 });
+
+ Assert.AreEqual(5, map.Count);
+
+ for (int i = 5; i < 10; i++)
+ Assert.AreEqual("val_" + i, map[i]);
+ }
+
+ [Test]
+ public void TestTx()
+ {
+ var cache = Cache();
+
+ using (var tx = cache.Ignite.GetTransactions().TxStart())
+ {
+ CacheTestStore.ExpCommit = true;
+
+ tx.AddMeta("meta", 100);
+
+ cache.Put(1, "val");
+
+ tx.Commit();
+ }
+
+ IDictionary map = StoreMap();
+
+ Assert.AreEqual(1, map.Count);
+
+ Assert.AreEqual("val", map[1]);
+ }
+
+ [Test]
+ public void TestLoadCacheMultithreaded()
+ {
+ CacheTestStore.LoadMultithreaded = true;
+
+ var cache = Cache();
+
+ Assert.AreEqual(0, cache.GetSize());
+
+ cache.LocalLoadCache(null, 0, null);
+
+ Assert.AreEqual(1000, cache.GetSize());
+
+ for (int i = 0; i < 1000; i++)
+ Assert.AreEqual("val_" + i, cache.Get(i));
+ }
+
+ [Test]
+ public void TestCustomStoreProperties()
+ {
+ var cache = CustomStoreCache();
+ Assert.IsNotNull(cache);
+
+ Assert.AreEqual(42, CacheTestStore.intProperty);
+ Assert.AreEqual("String value", CacheTestStore.stringProperty);
+ }
+
+ [Test]
+ public void TestDynamicStoreStart()
+ {
+ var cache = TemplateStoreCache();
+
+ Assert.IsNotNull(cache);
+
+ cache.Put(1, cache.Name);
+
+ Assert.AreEqual(cache.Name, CacheTestStore.Map[1]);
+ }
+
+ /// <summary>
+ /// Get's grid name for this test.
+ /// </summary>
+ /// <returns>Grid name.</returns>
+ protected virtual string GridName()
+ {
+ return null;
+ }
+
+ private IDictionary StoreMap()
+ {
+ return CacheTestStore.Map;
+ }
+
+ private ICache<int, string> Cache()
+ {
+ return PortableStoreCache<int, string>();
+ }
+
+ private ICache<TK, TV> PortableStoreCache<TK, TV>()
+ {
+ return Ignition.GetIgnite(GridName()).GetCache<TK, TV>(PortableStoreCacheName);
+ }
+
+ private ICache<TK, TV> ObjectStoreCache<TK, TV>()
+ {
+ return Ignition.GetIgnite(GridName()).GetCache<TK, TV>(ObjectStoreCacheName);
+ }
+
+ private ICache<int, string> CustomStoreCache()
+ {
+ return Ignition.GetIgnite(GridName()).GetCache<int, string>(CustomStoreCacheName);
+ }
+
+ private ICache<int, string> TemplateStoreCache()
+ {
+ var cacheName = TemplateStoreCacheName.Replace("*", Guid.NewGuid().ToString());
+
+ return Ignition.GetIgnite(GridName()).GetOrCreateCache<int, string>(cacheName);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public class NamedNodeCacheStoreTest : CacheStoreTest
+ {
+ /** <inheritDoc /> */
+ protected override string GridName()
+ {
+ return "name";
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheTestParallelLoadStore.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheTestParallelLoadStore.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheTestParallelLoadStore.cs
new file mode 100644
index 0000000..770ca83
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheTestParallelLoadStore.cs
@@ -0,0 +1,91 @@
+/*
+ * 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.Cache.Store
+{
+ using System.Collections;
+ using System.Collections.Concurrent;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading;
+ using Apache.Ignite.Core.Cache.Store;
+
+ /// <summary>
+ /// Test cache store with parallel load.
+ /// </summary>
+ public class CacheTestParallelLoadStore : CacheParallelLoadStoreAdapter
+ {
+ /** Length of input data sequence */
+ public const int InputDataLength = 10000;
+
+ /** list of thread ids where Parse has been executed */
+ private static readonly ConcurrentDictionary<int, int> ThreadIds = new ConcurrentDictionary<int, int>();
+
+ /// <summary>
+ /// Gets the count of unique threads that entered Parse method.
+ /// </summary>
+ public static int UniqueThreadCount
+ {
+ get { return ThreadIds.Count; }
+ }
+
+ /// <summary>
+ /// Resets the test counters.
+ /// </summary>
+ public static void ResetCounters()
+ {
+ ThreadIds.Clear();
+ }
+
+ /** <inheritdoc /> */
+ protected override IEnumerable GetInputData()
+ {
+ return Enumerable.Range(0, InputDataLength).Select(x => new Record {Id = x, Name = "Test Record " + x});
+ }
+
+ /** <inheritdoc /> */
+ protected override KeyValuePair<object, object>? Parse(object inputRecord, params object[] args)
+ {
+ var threadId = Thread.CurrentThread.ManagedThreadId;
+ ThreadIds.GetOrAdd(threadId, threadId);
+
+ var minId = (int)args[0];
+
+ var rec = (Record)inputRecord;
+
+ return rec.Id >= minId
+ ? new KeyValuePair<object, object>(rec.Id, rec)
+ : (KeyValuePair<object, object>?) null;
+ }
+
+ /// <summary>
+ /// Test store record.
+ /// </summary>
+ public class Record
+ {
+ /// <summary>
+ /// Gets or sets the identifier.
+ /// </summary>
+ public int Id { get; set; }
+
+ /// <summary>
+ /// Gets or sets the name.
+ /// </summary>
+ public string Name { get; set; }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheTestStore.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheTestStore.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheTestStore.cs
new file mode 100644
index 0000000..9c381cb
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheTestStore.cs
@@ -0,0 +1,155 @@
+/*
+ * 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.Cache.Store
+{
+ using System;
+ using System.Collections;
+ using System.Collections.Concurrent;
+ using System.Diagnostics;
+ using System.Diagnostics.CodeAnalysis;
+ using System.Linq;
+ using System.Threading;
+ using Apache.Ignite.Core.Cache.Store;
+ using Apache.Ignite.Core.Resource;
+
+ [SuppressMessage("ReSharper", "FieldCanBeMadeReadOnly.Local")]
+ public class CacheTestStore : ICacheStore
+ {
+ public static readonly IDictionary Map = new ConcurrentDictionary<object, object>();
+
+ public static bool ExpCommit;
+
+ public static bool LoadMultithreaded;
+
+ public static bool LoadObjects;
+
+ [InstanceResource]
+ private IIgnite _grid = null;
+
+ [StoreSessionResource]
+#pragma warning disable 649
+ private ICacheStoreSession _ses;
+#pragma warning restore 649
+
+ public static int intProperty;
+
+ public static string stringProperty;
+
+ public static void Reset()
+ {
+ Map.Clear();
+
+ ExpCommit = false;
+ LoadMultithreaded = false;
+ LoadObjects = false;
+ }
+
+ public void LoadCache(Action<object, object> act, params object[] args)
+ {
+ Debug.Assert(_grid != null);
+
+ if (LoadMultithreaded)
+ {
+ int cnt = 0;
+
+ TestUtils.RunMultiThreaded(() => {
+ int i;
+
+ while ((i = Interlocked.Increment(ref cnt) - 1) < 1000)
+ act(i, "val_" + i);
+ }, 8);
+ }
+ else
+ {
+ int start = (int)args[0];
+ int cnt = (int)args[1];
+
+ for (int i = start; i < start + cnt; i++)
+ {
+ if (LoadObjects)
+ act(new Key(i), new Value(i));
+ else
+ act(i, "val_" + i);
+ }
+ }
+ }
+
+ public object Load(object key)
+ {
+ Debug.Assert(_grid != null);
+
+ return Map[key];
+ }
+
+ public IDictionary LoadAll(ICollection keys)
+ {
+ Debug.Assert(_grid != null);
+
+ return keys.OfType<object>().ToDictionary(key => key, Load);
+ }
+
+ public void Write(object key, object val)
+ {
+ Debug.Assert(_grid != null);
+
+ Map[key] = val;
+ }
+
+ public void WriteAll(IDictionary map)
+ {
+ Debug.Assert(_grid != null);
+
+ foreach (DictionaryEntry e in map)
+ Map[e.Key] = e.Value;
+ }
+
+ public void Delete(object key)
+ {
+ Debug.Assert(_grid != null);
+
+ Map.Remove(key);
+ }
+
+ public void DeleteAll(ICollection keys)
+ {
+ Debug.Assert(_grid != null);
+
+ foreach (object key in keys)
+ Map.Remove(key);
+ }
+
+ public void SessionEnd(bool commit)
+ {
+ Debug.Assert(_grid != null);
+
+ Debug.Assert(_ses != null);
+ }
+
+ public int IntProperty
+ {
+ get { return intProperty; }
+ set { intProperty = value; }
+ }
+
+ public string StringProperty
+ {
+ get { return stringProperty; }
+ set { stringProperty = value; }
+ }
+ }
+}
[11/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTestAsync.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTestAsync.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTestAsync.cs
deleted file mode 100644
index b0e507a..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTestAsync.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Services
-{
- using Apache.Ignite.Core.Services;
-
- /// <summary>
- /// Services async tests.
- /// </summary>
- public class ServicesTestAsync : ServicesTest
- {
- /** <inheritdoc /> */
- protected override IServices Services
- {
- get { return new ServicesAsyncWrapper(Grid1.GetServices()); }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/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
deleted file mode 100644
index 2b0ab8e..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-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
- {
- [STAThread]
- static void Main()
- {
- Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
- Debug.AutoFlush = true;
-
- //TestOne(typeof(ContinuousQueryAtomiclBackupTest), "TestInitialQuery");
-
- TestAll(typeof (ExecutableTest));
- //TestAllInAssembly();
- }
-
- private static void TestOne(Type testClass, string method)
- {
- string[] args = { "/run:" + testClass.FullName + "." + method, Assembly.GetAssembly(testClass).Location };
-
- int returnCode = Runner.Main(args);
-
- if (returnCode != 0)
- Console.Beep();
- }
-
- private static void TestAll(Type testClass)
- {
- string[] args = { "/run:" + testClass.FullName, Assembly.GetAssembly(testClass).Location };
-
- int returnCode = Runner.Main(args);
-
- if (returnCode != 0)
- Console.Beep();
- }
-
- private static void TestAllInAssembly()
- {
- string[] args = { Assembly.GetAssembly(typeof(InteropMemoryTest)).Location };
-
- int returnCode = Runner.Main(args);
-
- if (returnCode != 0)
- Console.Beep();
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/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
deleted file mode 100644
index 3287e2f..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-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;
-
- /// <summary>
- /// Test utility methods.
- /// </summary>
- 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<string> TestJvmOpts = Environment.Is64BitProcess
- ? new List<string>
- {
- "-XX:+HeapDumpOnOutOfMemoryError",
- "-Xms1g",
- "-Xmx4g",
- "-ea"
- }
- : new List<string>
- {
- "-XX:+HeapDumpOnOutOfMemoryError",
- "-Xms512m",
- "-Xmx512m",
- "-ea",
- "-DIGNITE_ATOMIC_CACHE_DELETE_HISTORY_SIZE=1000"
- };
-
- /** */
- private static readonly IList<string> JvmDebugOpts =
- new List<string> { "-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;
-
- /// <summary>
- /// Kill Ignite processes.
- /// </summary>
- public static void KillProcesses()
- {
- IgniteProcess.KillAll();
- }
-
- /// <summary>
- ///
- /// </summary>
- public static Random Random
- {
- get { return _random ?? (_random = new Random(Interlocked.Increment(ref _seed))); }
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- public static IList<string> TestJavaOptions()
- {
- IList<string> ops = new List<string>(TestJvmOpts);
-
- if (JvmDebug)
- {
- foreach (string opt in JvmDebugOpts)
- ops.Add(opt);
- }
-
- return ops;
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- public static string CreateTestClasspath()
- {
- return IgniteManager.CreateClasspath(forceTestClasspath: true);
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="action"></param>
- /// <param name="threadNum"></param>
- public static void RunMultiThreaded(Action action, int threadNum)
- {
- List<Thread> threads = new List<Thread>(threadNum);
-
- var errors = new ConcurrentBag<Exception>();
-
- 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);
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="action"></param>
- /// <param name="threadNum"></param>
- /// <param name="duration">Duration of test execution in seconds</param>
- public static void RunMultiThreaded(Action action, int threadNum, int duration)
- {
- List<Thread> threads = new List<Thread>(threadNum);
-
- var errors = new ConcurrentBag<Exception>();
-
- 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);
- }
-
- /// <summary>
- /// Wait for particular topology size.
- /// </summary>
- /// <param name="grid">Grid.</param>
- /// <param name="size">Size.</param>
- /// <param name="timeout">Timeout.</param>
- /// <returns>
- /// <c>True</c> if topology took required size.
- /// </returns>
- public static bool WaitTopology(this IIgnite grid, int size, int timeout)
- {
- int left = timeout;
-
- while (true)
- {
- if (grid.GetCluster().GetNodes().Count != size)
- {
- if (left > 0)
- {
- Thread.Sleep(100);
-
- left -= 100;
- }
- else
- break;
- }
- else
- return true;
- }
-
- return false;
- }
-
- /// <summary>
- /// Asserts that the handle registry is empty.
- /// </summary>
- /// <param name="timeout">Timeout, in milliseconds.</param>
- /// <param name="grids">Grids to check.</param>
- public static void AssertHandleRegistryIsEmpty(int timeout, params IIgnite[] grids)
- {
- foreach (var g in grids)
- AssertHandleRegistryIsEmpty(g, timeout);
- }
-
- /// <summary>
- /// Asserts that the handle registry is empty.
- /// </summary>
- /// <param name="grid">The grid to check.</param>
- /// <param name="timeout">Timeout, in milliseconds.</param>
- 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));
- }
-
- /// <summary>
- /// Waits for condition, polling in busy wait loop.
- /// </summary>
- /// <param name="cond">Condition.</param>
- /// <param name="timeout">Timeout, in milliseconds.</param>
- /// <returns>True if condition predicate returned true within interval; false otherwise.</returns>
- public static bool WaitForCondition(Func<bool> 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/65bb69da/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
deleted file mode 100644
index a49ee1b..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-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;
-
- /// <summary>
- /// <see cref="TypeResolver"/> tests.
- /// </summary>
- public class TypeResolverTest
- {
- /// <summary>
- /// Tests generic type resolve.
- /// </summary>
- [Test]
- public void TestGenerics()
- {
- var testTypes = new[]
- {
- typeof (TestGenericPortable<int>),
- typeof (TestGenericPortable<string>),
- typeof (TestGenericPortable<TestGenericPortable<int>>),
- typeof (TestGenericPortable<List<Tuple<int, string>>>),
- typeof (TestGenericPortable<List<TestGenericPortable<List<Tuple<int, string>>>>>),
- typeof (List<TestGenericPortable<List<TestGenericPortable<List<Tuple<int, string>>>>>>),
- typeof (TestGenericPortable<int, string>),
- typeof (TestGenericPortable<int, TestGenericPortable<string>>),
- typeof (TestGenericPortable<int, string, Type>),
- typeof (TestGenericPortable<int, string, TestGenericPortable<int, string, Type>>)
- };
-
- 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);
- }
- }
-
- /// <summary>
- /// Tests loading a type from referenced assembly that is not yet loaded.
- /// </summary>
- [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)));
- }
-
- /// <summary>
- /// 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.
- /// </summary>
- public void UnusedMethod()
- {
- Assert.IsNotNull(typeof(TestClass));
- }
- }
-}
\ No newline at end of file
[07/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs
new file mode 100644
index 0000000..6c2b40d
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs
@@ -0,0 +1,114 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.ExamplesDll.Datagrid;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+ /// <summary>
+ /// Example demonstrating cache store.
+ /// <para />
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+ /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start example (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run with standalone Apache Ignite .Net node:
+ /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+ /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache-store.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// 2) Start example.
+ /// </summary>
+ class StoreExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache-store.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Cache store example started.");
+
+ var cache = ignite.GetCache<int, Employee>(null);
+
+ // Clean up caches on all nodes before run.
+ cache.Clear();
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Cleared values from cache.");
+ Console.WriteLine(">>> Current cache size: " + cache.GetSize());
+
+ // Load entries from store which pass provided filter.
+ cache.LoadCache(new EmployeeStorePredicate());
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Loaded entry from store through ICache.LoadCache().");
+ Console.WriteLine(">>> Current cache size: " + cache.GetSize());
+
+ // Load entry from store calling ICache.Get() method.
+ Employee emp = cache.Get(2);
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Loaded entry from store through ICache.Get(): " + emp);
+ Console.WriteLine(">>> Current cache size: " + cache.GetSize());
+
+ // Put an entry to the cache
+ cache.Put(3, new Employee(
+ "James Wilson",
+ 12500,
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ new List<string> { "Human Resources", "Customer Service" }
+ ));
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Put entry to cache. ");
+ Console.WriteLine(">>> Current cache size: " + cache.GetSize());
+
+ // Clear values again.
+ cache.Clear();
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Cleared values from cache again.");
+ Console.WriteLine(">>> Current cache size: " + cache.GetSize());
+
+ // Read values from cache after clear.
+ Console.WriteLine();
+ Console.WriteLine(">>> Read values after clear:");
+
+ for (int i = 1; i <= 3; i++)
+ Console.WriteLine(">>> Key=" + i + ", value=" + cache.Get(i));
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
new file mode 100644
index 0000000..6be3523
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
@@ -0,0 +1,104 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Transactions;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+ /// <summary>
+ /// This example demonstrates how to use transactions on Apache cache.
+ /// <para />
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+ /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start example (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run with standalone Apache Ignite .Net node:
+ /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+ /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// 2) Start example.
+ /// </summary>
+ class TransactionExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Transaction example started.");
+
+ var cache = ignite.GetCache<int, Account>("tx");
+
+ // Clean up caches on all nodes before run.
+ cache.Clear();
+
+ // Initialize.
+ cache.Put(1, new Account(1, 100));
+ cache.Put(2, new Account(2, 200));
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Accounts before transfer: ");
+ Console.WriteLine(">>> " + cache.Get(1));
+ Console.WriteLine(">>> " + cache.Get(2));
+ Console.WriteLine();
+
+ // Transfer money between accounts in a single transaction.
+ using (var tx = cache.Ignite.GetTransactions().TxStart(TransactionConcurrency.Pessimistic,
+ TransactionIsolation.RepeatableRead))
+ {
+ Account acc1 = cache.Get(1);
+ Account acc2 = cache.Get(2);
+
+ acc1.Balance += 100;
+ acc2.Balance -= 100;
+
+ cache.Put(1, acc1);
+ cache.Put(2, acc2);
+
+ tx.Commit();
+ }
+
+ Console.WriteLine(">>> Transfer finished.");
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Accounts after transfer: ");
+ Console.WriteLine(">>> " + cache.Get(1));
+ Console.WriteLine(">>> " + cache.Get(2));
+ Console.WriteLine();
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
new file mode 100644
index 0000000..83802cc
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
@@ -0,0 +1,118 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Events;
+using Apache.Ignite.ExamplesDll.Compute;
+using Apache.Ignite.ExamplesDll.Events;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Events
+{
+ /// <summary>
+ /// Example demonstrating Ignite events.
+ /// <para />
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+ /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start example (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run with standalone Apache Ignite .Net node:
+ /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+ /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-compute.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// 2) Start example.
+ /// </summary>
+ public class EventsExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
+ JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine(">>> Events example started.");
+ Console.WriteLine();
+
+ // Local listen example
+ Console.WriteLine(">>> Listening for a local event...");
+
+ var listener = new LocalListener();
+ ignite.GetEvents().LocalListen(listener, EventType.EvtsTaskExecution);
+
+ ExecuteTask(ignite);
+
+ ignite.GetEvents().StopLocalListen(listener);
+
+ Console.WriteLine(">>> Received events count: " + listener.EventsReceived);
+ Console.WriteLine();
+
+ // Remote listen example (start standalone nodes for better demonstration)
+ Console.WriteLine(">>> Listening for remote events...");
+
+ var localListener = new LocalListener();
+ var remoteFilter = new RemoteFilter();
+
+ var listenId = ignite.GetEvents().RemoteListen(localListener: localListener,
+ remoteFilter: remoteFilter, types: EventType.EvtsJobExecution);
+
+ ExecuteTask(ignite);
+
+ ignite.GetEvents().StopRemoteListen(listenId);
+
+ Console.WriteLine(">>> Received events count: " + localListener.EventsReceived);
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+
+ /// <summary>
+ /// Executes a task to generate events.
+ /// </summary>
+ /// <param name="ignite">Ignite instance.</param>
+ private static void ExecuteTask(IIgnite ignite)
+ {
+ var employees = Enumerable.Range(1, 10).SelectMany(x => new[]
+ {
+ new Employee("Allison Mathis",
+ 25300,
+ new Address("2702 Freedom Lane, San Francisco, CA", 94109),
+ new[] {"Development"}),
+
+ new Employee("Breana Robbin",
+ 6500,
+ new Address("3960 Sundown Lane, Austin, TX", 78130),
+ new[] {"Sales"})
+ }).ToArray();
+
+ ignite.GetCompute().Execute(new AverageSalaryTask(), employees);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs
new file mode 100644
index 0000000..a24c47c
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs
@@ -0,0 +1,112 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using Apache.Ignite.Core;
+using Apache.Ignite.ExamplesDll.Messaging;
+
+namespace Apache.Ignite.Examples.Messaging
+{
+ /// <summary>
+ /// Example demonstrating Ignite messaging. Should be run with standalone Apache Ignite .Net node.
+ /// <para />
+ /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+ /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-compute.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// 2) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+ /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+ /// 3) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 4) Start example (F5 or Ctrl+F5).
+ /// </summary>
+ public class MessagingExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ var remotes = ignite.GetCluster().ForRemotes();
+
+ if (remotes.GetNodes().Count == 0)
+ {
+ Console.WriteLine(">>> This example requires remote nodes to be started.");
+ Console.WriteLine(">>> Please start at least 1 remote node.");
+ Console.WriteLine(">>> Refer to example's documentation for details on configuration.");
+ }
+ else
+ {
+ Console.WriteLine(">>> Messaging example started.");
+ Console.WriteLine();
+
+ // Set up local listeners
+ var localMessaging = ignite.GetCluster().ForLocal().GetMessaging();
+
+ var msgCount = remotes.GetNodes().Count * 10;
+
+ var orderedCounter = new CountdownEvent(msgCount);
+ var unorderedCounter = new CountdownEvent(msgCount);
+
+ localMessaging.LocalListen(new LocalListener(unorderedCounter), Topic.Unordered);
+ localMessaging.LocalListen(new LocalListener(orderedCounter), Topic.Ordered);
+
+ // Set up remote listeners
+ var remoteMessaging = remotes.GetMessaging();
+
+ remoteMessaging.RemoteListen(new RemoteUnorderedListener(), Topic.Unordered);
+ remoteMessaging.RemoteListen(new RemoteOrderedListener(), Topic.Ordered);
+
+ // Send unordered
+ Console.WriteLine(">>> Sending unordered messages...");
+
+ for (var i = 0; i < 10; i++)
+ remoteMessaging.Send(i, Topic.Unordered);
+
+ Console.WriteLine(">>> Finished sending unordered messages.");
+
+ // Send ordered
+ Console.WriteLine(">>> Sending ordered messages...");
+
+ for (var i = 0; i < 10; i++)
+ remoteMessaging.SendOrdered(i, Topic.Ordered);
+
+ Console.WriteLine(">>> Finished sending ordered messages.");
+
+ Console.WriteLine(">>> Check output on all nodes for message printouts.");
+ Console.WriteLine(">>> Waiting for messages acknowledgements from all remote nodes...");
+
+ unorderedCounter.Wait();
+ orderedCounter.Wait();
+ }
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs
new file mode 100644
index 0000000..2d319e8
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs
@@ -0,0 +1,109 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Lifecycle;
+using Apache.Ignite.Core.Resource;
+
+namespace Apache.Ignite.Examples.Misc
+{
+ /// <summary>
+ /// This example shows how to provide your own <see cref="ILifecycleBean"/> implementation
+ /// to be able to hook into Apache lifecycle. Example bean will output occurred lifecycle
+ /// events to the console.
+ /// <para />
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+ /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start example (F5 or Ctrl+F5).
+ /// </summary>
+ public class LifecycleExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Lifecycle example started.");
+
+ // Create new configuration.
+ var lifecycleExampleBean = new LifecycleExampleBean();
+
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" },
+ LifecycleBeans = new List<ILifecycleBean> { lifecycleExampleBean }
+ };
+
+ // Provide lifecycle bean to configuration.
+ using (Ignition.Start(cfg))
+ {
+ // Make sure that lifecycle bean was notified about Ignite startup.
+ Console.WriteLine();
+ Console.WriteLine(">>> Started (should be true): " + lifecycleExampleBean.Started);
+ }
+
+ // Make sure that lifecycle bean was notified about Ignite stop.
+ Console.WriteLine();
+ Console.WriteLine(">>> Started (should be false): " + lifecycleExampleBean.Started);
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+
+ /// <summary>
+ /// Sample lifecycle bean implementation.
+ /// </summary>
+ private class LifecycleExampleBean : ILifecycleBean
+ {
+ /** Auto-injected Ignite instance. */
+ [InstanceResource]
+#pragma warning disable 649
+ private IIgnite _ignite;
+#pragma warning restore 649
+
+ /** <inheritDoc /> */
+ public void OnLifecycleEvent(LifecycleEventType evt)
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Ignite lifecycle event occurred: " + evt);
+ Console.WriteLine(">>> Ignite name: " + (_ignite != null ? _ignite.Name : "not available"));
+
+ if (evt == LifecycleEventType.AfterNodeStart)
+ Started = true;
+ else if (evt == LifecycleEventType.AfterNodeStop)
+ Started = false;
+ }
+
+ /// <summary>
+ /// Started flag.
+ /// </summary>
+ public bool Started
+ {
+ get;
+ private set;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..555a35f
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("Apache Ignite Examples")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("Apache Ignite")]
+[assembly: AssemblyCopyright("Copyright © 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+[assembly: ComVisible(false)]
+
+[assembly: Guid("41a0cb95-3435-4c78-b867-900b28e2c9ee")]
+
+[assembly: AssemblyVersion("1.5.0")]
+[assembly: AssemblyFileVersion("1.5.0")]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.Examples/Services/IMapService.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.Examples/Services/IMapService.cs b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Services/IMapService.cs
new file mode 100644
index 0000000..7253a0b
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Services/IMapService.cs
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+
+using Apache.Ignite.ExamplesDll.Services;
+
+namespace Apache.Ignite.Examples.Services
+{
+ /// <summary>
+ /// Interface for service proxy interaction.
+ /// Actual service class (<see cref="MapService{TK,TV}"/>) does not have to implement this interface.
+ /// Target method/property will be searched by signature (name, arguments).
+ /// </summary>
+ public interface IMapService<TK, TV>
+ {
+ /// <summary>
+ /// Puts an entry to the map.
+ /// </summary>
+ /// <param name="key">The key.</param>
+ /// <param name="value">The value.</param>
+ void Put(TK key, TV value);
+
+ /// <summary>
+ /// Gets an entry from the map.
+ /// </summary>
+ /// <param name="key">The key.</param>
+ /// <returns>Entry value.</returns>
+ TV Get(TK key);
+
+ /// <summary>
+ /// Clears the map.
+ /// </summary>
+ void Clear();
+
+ /// <summary>
+ /// Gets the size of the map.
+ /// </summary>
+ /// <value>
+ /// The size.
+ /// </value>
+ int Size { get; }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.Examples/Services/ServicesExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.Examples/Services/ServicesExample.cs b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Services/ServicesExample.cs
new file mode 100644
index 0000000..6d0ddd0
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Services/ServicesExample.cs
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.ExamplesDll.Services;
+
+namespace Apache.Ignite.Examples.Services
+{
+ /// <summary>
+ /// Example demonstrating Ignite services.
+ /// <para />
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+ /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start example (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run with standalone Apache Ignite .Net node:
+ /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+ /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// 2) Start example.
+ /// </summary>
+ public class ServicesExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
+ JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine(">>> Services example started.");
+ Console.WriteLine();
+
+ // Deploy a service
+ var svc = new MapService<int, string>();
+ Console.WriteLine(">>> Deploying service to all nodes...");
+ ignite.GetServices().DeployNodeSingleton("service", svc);
+
+ // Get a sticky service proxy so that we will always be contacting the same remote node.
+ var prx = ignite.GetServices().GetServiceProxy<IMapService<int, string>>("service", true);
+
+ for (var i = 0; i < 10; i++)
+ prx.Put(i, i.ToString());
+
+ var mapSize = prx.Size;
+
+ Console.WriteLine(">>> Map service size: " + mapSize);
+
+ ignite.GetServices().CancelAll();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
new file mode 100644
index 0000000..cb2ff6f
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{DFB08363-202E-412D-8812-349EF10A8702}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Apache.Ignite.ExamplesDll</RootNamespace>
+ <AssemblyName>Apache.Ignite.ExamplesDll</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Debug\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Release\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\x86\Debug\</OutputPath>
+ <PlatformTarget>x86</PlatformTarget>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+ <OutputPath>bin\x86\Release\</OutputPath>
+ <PlatformTarget>x86</PlatformTarget>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Compute\AverageSalaryJob.cs" />
+ <Compile Include="Compute\AverageSalaryTask.cs" />
+ <Compile Include="Compute\CharacterCountClosure.cs" />
+ <Compile Include="Compute\CharacterCountReducer.cs" />
+ <Compile Include="Datagrid\EmployeeStorePredicate.cs" />
+ <Compile Include="Datagrid\ContinuousQueryFilter.cs" />
+ <Compile Include="Datagrid\EmployeeStore.cs" />
+ <Compile Include="Events\LocalListener.cs" />
+ <Compile Include="Events\RemoteFilter.cs" />
+ <Compile Include="Messaging\LocalListener.cs" />
+ <Compile Include="Messaging\RemoteOrderedListener.cs" />
+ <Compile Include="Messaging\RemoteUnorderedListener.cs" />
+ <Compile Include="Messaging\Topic.cs" />
+ <Compile Include="Portable\Account.cs" />
+ <Compile Include="Portable\Address.cs" />
+ <Compile Include="Portable\Employee.cs" />
+ <Compile Include="Portable\EmployeeKey.cs" />
+ <Compile Include="Portable\Organization.cs" />
+ <Compile Include="Portable\OrganizationType.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Services\MapService.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\Apache.Ignite.Core\Apache.Ignite.Core.csproj">
+ <Project>{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}</Project>
+ <Name>Apache.Ignite.Core</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csprojrel
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csprojrel b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csprojrel
new file mode 100644
index 0000000..fa6b71c
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csprojrel
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{DFB08363-202E-412D-8812-349EF10A8702}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Apache.Ignite.ExamplesDll</RootNamespace>
+ <AssemblyName>Apache.Ignite.ExamplesDll</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Debug\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Release\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\x86\Debug\</OutputPath>
+ <PlatformTarget>x86</PlatformTarget>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+ <OutputPath>bin\x86\Release\</OutputPath>
+ <PlatformTarget>x86</PlatformTarget>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Apache.Ignite.Core">
+ <HintPath>..\..\Apache.Ignite\bin\$(Platform)\$(Configuration)\Apache.Ignite.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Compute\AverageSalaryJob.cs" />
+ <Compile Include="Compute\AverageSalaryTask.cs" />
+ <Compile Include="Compute\CharacterCountClosure.cs" />
+ <Compile Include="Compute\CharacterCountReducer.cs" />
+ <Compile Include="Datagrid\EmployeeStorePredicate.cs" />
+ <Compile Include="Datagrid\ContinuousQueryFilter.cs" />
+ <Compile Include="Datagrid\EmployeeStore.cs" />
+ <Compile Include="Events\LocalListener.cs" />
+ <Compile Include="Events\RemoteFilter.cs" />
+ <Compile Include="Messaging\LocalListener.cs" />
+ <Compile Include="Messaging\RemoteOrderedListener.cs" />
+ <Compile Include="Messaging\RemoteUnorderedListener.cs" />
+ <Compile Include="Messaging\Topic.cs" />
+ <Compile Include="Portable\Account.cs" />
+ <Compile Include="Portable\Address.cs" />
+ <Compile Include="Portable\Employee.cs" />
+ <Compile Include="Portable\EmployeeKey.cs" />
+ <Compile Include="Portable\Organization.cs" />
+ <Compile Include="Portable\OrganizationType.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Services\MapService.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs
new file mode 100644
index 0000000..e4713d4
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs
@@ -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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Apache.Ignite.Core.Compute;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.ExamplesDll.Compute
+{
+ /// <summary>
+ /// Average salary job.
+ /// </summary>
+ [Serializable]
+ public class AverageSalaryJob : ComputeJobAdapter<Tuple<long, int>>
+ {
+ /// <summary> Employees. </summary>
+ private readonly ICollection<Employee> _employees = new List<Employee>();
+
+ /// <summary>
+ /// Adds employee.
+ /// </summary>
+ /// <param name="employee">Employee.</param>
+ public void Add(Employee employee)
+ {
+ _employees.Add(employee);
+ }
+
+ /// <summary>
+ /// Execute the job.
+ /// </summary>
+ /// <returns>Job result: tuple with total salary in the first item and employees count in the second.</returns>
+ override public Tuple<long, int> Execute()
+ {
+ long sum = 0;
+ int count = 0;
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Executing salary job for " + _employees.Count + " employee(s) ...");
+ Console.WriteLine();
+
+ foreach (Employee emp in _employees)
+ {
+ sum += emp.Salary;
+ count++;
+ }
+
+ return new Tuple<long, int>(sum, count);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs
new file mode 100644
index 0000000..f8acb01
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Apache.Ignite.Core.Compute;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.ExamplesDll.Compute
+{
+ /// <summary>
+ /// Average salary task.
+ /// </summary>
+ public class AverageSalaryTask : ComputeTaskSplitAdapter<ICollection<Employee>, Tuple<long, int>, long>
+ {
+ /// <summary>
+ /// Split the task distributing employees between several jobs.
+ /// </summary>
+ /// <param name="gridSize">Number of available grid nodes.</param>
+ /// <param name="arg">Task execution argument.</param>
+ protected override ICollection<IComputeJob<Tuple<long, int>>> Split(int gridSize, ICollection<Employee> arg)
+ {
+ ICollection<Employee> employees = arg;
+
+ var jobs = new List<IComputeJob<Tuple<long, int>>>(gridSize);
+
+ int count = 0;
+
+ foreach (Employee employee in employees)
+ {
+ int idx = count++ % gridSize;
+
+ AverageSalaryJob job;
+
+ if (idx >= jobs.Count)
+ {
+ job = new AverageSalaryJob();
+
+ jobs.Add(job);
+ }
+ else
+ job = (AverageSalaryJob) jobs[idx];
+
+ job.Add(employee);
+ }
+
+ return jobs;
+ }
+
+ /// <summary>
+ /// Calculate average salary after all jobs are finished.
+ /// </summary>
+ /// <param name="results">Job results.</param>
+ /// <returns>Average salary.</returns>
+ public override long Reduce(IList<IComputeJobResult<Tuple<long, int>>> results)
+ {
+ long sum = 0;
+ int count = 0;
+
+ foreach (var t in results.Select(result => result.Data()))
+ {
+ sum += t.Item1;
+ count += t.Item2;
+ }
+
+ return sum / count;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountClosure.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountClosure.cs b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountClosure.cs
new file mode 100644
index 0000000..2823221
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountClosure.cs
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+
+using System;
+using Apache.Ignite.Core.Compute;
+
+namespace Apache.Ignite.ExamplesDll.Compute
+{
+ /// <summary>
+ /// Closure counting characters in a string.
+ /// </summary>
+ [Serializable]
+ public class CharacterCountClosure : IComputeFunc<string, int>
+ {
+ /// <summary>
+ /// Calculate character count of the given word.
+ /// </summary>
+ /// <param name="arg">Word.</param>
+ /// <returns>Character count.</returns>
+ public int Invoke(string arg)
+ {
+ int len = arg.Length;
+
+ Console.WriteLine("Character count in word \"" + arg + "\": " + len);
+
+ return len;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountReducer.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountReducer.cs b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountReducer.cs
new file mode 100644
index 0000000..6825046
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountReducer.cs
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using Apache.Ignite.Core.Compute;
+
+namespace Apache.Ignite.ExamplesDll.Compute
+{
+ /// <summary>
+ /// Character count reducer which collects individual string lengths and aggregate them.
+ /// </summary>
+ public class CharacterCountReducer : IComputeReducer<int, int>
+ {
+ /// <summary> Total length. </summary>
+ private int _length;
+
+ /// <summary>
+ /// Collect character counts of distinct words.
+ /// </summary>
+ /// <param name="res">Character count of a distinct word.</param>
+ /// <returns><c>True</c> to continue collecting results until all closures are finished.</returns>
+ public bool Collect(int res)
+ {
+ _length += res;
+
+ return true;
+ }
+
+ /// <summary>
+ /// Reduce all collected results.
+ /// </summary>
+ /// <returns>Total character count.</returns>
+ public int Reduce()
+ {
+ return _length;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Datagrid/ContinuousQueryFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Datagrid/ContinuousQueryFilter.cs b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Datagrid/ContinuousQueryFilter.cs
new file mode 100644
index 0000000..8c05f42
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Datagrid/ContinuousQueryFilter.cs
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+using System;
+using Apache.Ignite.Core.Cache.Event;
+
+namespace Apache.Ignite.ExamplesDll.Datagrid
+{
+ /// <summary>
+ /// Filter for continuous query example.
+ /// </summary>
+ [Serializable]
+ public class ContinuousQueryFilter : ICacheEntryEventFilter<int, string>
+ {
+ /// <summary> Threshold. </summary>
+ private readonly int _threshold;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="threshold">Threshold.</param>
+ public ContinuousQueryFilter(int threshold)
+ {
+ _threshold = threshold;
+ }
+
+ /// <summary>
+ /// Evaluates cache entry event.
+ /// </summary>
+ /// <param name="evt">Event.</param>
+ public bool Evaluate(ICacheEntryEvent<int, string> evt)
+ {
+ return evt.Key >= _threshold;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs
new file mode 100644
index 0000000..742b048
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using Apache.Ignite.Core.Cache;
+using Apache.Ignite.Core.Cache.Store;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.ExamplesDll.Datagrid
+{
+ /// <summary>
+ /// Example cache store implementation.
+ /// </summary>
+ public class EmployeeStore : CacheStoreAdapter
+ {
+ /// <summary>
+ /// Dictionary representing the store.
+ /// </summary>
+ private readonly ConcurrentDictionary<object, object> _db = new ConcurrentDictionary<object, object>(
+ new List<KeyValuePair<object, object>>
+ {
+ new KeyValuePair<object, object>(1, new Employee(
+ "Allison Mathis",
+ 25300,
+ new Address("2702 Freedom Lane, San Francisco, CA", 94109),
+ new List<string> {"Development"}
+ )),
+
+ new KeyValuePair<object, object>(2, new Employee(
+ "Breana Robbin",
+ 6500,
+ new Address("3960 Sundown Lane, Austin, TX", 78130),
+ new List<string> {"Sales"}
+ ))
+ });
+
+ /// <summary>
+ /// Loads all values from underlying persistent storage.
+ /// This method gets called as a result of <see cref="ICache{TK,TV}.LoadCache"/> call.
+ /// </summary>
+ /// <param name="act">Action that loads a cache entry.</param>
+ /// <param name="args">Optional arguments.</param>
+ public override void LoadCache(Action<object, object> act, params object[] args)
+ {
+ // Iterate over whole underlying store and call act on each entry to load it into the cache.
+ foreach (var entry in _db)
+ act(entry.Key, entry.Value);
+ }
+
+ /// <summary>
+ /// Loads multiple objects from the cache store.
+ /// This method gets called as a result of <see cref="ICache{K,V}.GetAll"/> call.
+ /// </summary>
+ /// <param name="keys">Keys to load.</param>
+ /// <returns>
+ /// A map of key, values to be stored in the cache.
+ /// </returns>
+ public override IDictionary LoadAll(ICollection keys)
+ {
+ var result = new Dictionary<object, object>();
+
+ foreach (var key in keys)
+ result[key] = Load(key);
+
+ return result;
+ }
+
+ /// <summary>
+ /// Loads an object from the cache store.
+ /// This method gets called as a result of <see cref="ICache{K,V}.Get"/> call.
+ /// </summary>
+ /// <param name="key">Key to load.</param>
+ /// <returns>Loaded value</returns>
+ public override object Load(object key)
+ {
+ object val;
+
+ _db.TryGetValue(key, out val);
+
+ return val;
+ }
+
+ /// <summary>
+ /// Write key-value pair to store.
+ /// </summary>
+ /// <param name="key">Key to write.</param>
+ /// <param name="val">Value to write.</param>
+ public override void Write(object key, object val)
+ {
+ _db[key] = val;
+ }
+
+ /// <summary>
+ /// Delete cache entry form store.
+ /// </summary>
+ /// <param name="key">Key to delete.</param>
+ public override void Delete(object key)
+ {
+ object val;
+
+ _db.TryRemove(key, out val);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs
new file mode 100644
index 0000000..a585e5e
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+using System;
+using Apache.Ignite.Core.Cache;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.ExamplesDll.Datagrid
+{
+ /// <summary>
+ /// Example cache entry predicate.
+ /// </summary>
+ [Serializable]
+ public class EmployeeStorePredicate : ICacheEntryFilter<int, Employee>
+ {
+ /// <summary>
+ /// Returns a value indicating whether provided cache entry satisfies this predicate.
+ /// </summary>
+ /// <param name="entry">Cache entry.</param>
+ /// <returns>Value indicating whether provided cache entry satisfies this predicate.</returns>
+ public bool Invoke(ICacheEntry<int, Employee> entry)
+ {
+ return entry.Key == 1;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
new file mode 100644
index 0000000..8a28355
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Threading;
+using Apache.Ignite.Core.Events;
+
+namespace Apache.Ignite.ExamplesDll.Events
+{
+ /// <summary>
+ /// Local event listener.
+ /// </summary>
+ public class LocalListener : IEventFilter<IEvent>
+ {
+ /** Сount of received events. */
+ private int _eventsReceived;
+
+ /// <summary>
+ /// Gets the count of received events.
+ /// </summary>
+ public int EventsReceived
+ {
+ get { return _eventsReceived; }
+ }
+
+ /// <summary>
+ /// Determines whether specified event passes this filter.
+ /// </summary>
+ /// <param name="nodeId">Node identifier.</param>
+ /// <param name="evt">Event.</param>
+ /// <returns>Value indicating whether specified event passes this filter.</returns>
+ public bool Invoke(Guid nodeId, IEvent evt)
+ {
+ Interlocked.Increment(ref _eventsReceived);
+
+ Console.WriteLine("Local listener received an event [evt={0}]", evt.Name);
+
+ return true;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs
new file mode 100644
index 0000000..db3204a
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs
@@ -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.
+ */
+
+using System;
+using Apache.Ignite.Core.Events;
+
+namespace Apache.Ignite.ExamplesDll.Events
+{
+ /// <summary>
+ /// Remote event filter.
+ /// </summary>
+ [Serializable]
+ public class RemoteFilter : IEventFilter<IEvent>
+ {
+ /// <summary>
+ /// Determines whether specified event passes this filter.
+ /// </summary>
+ /// <param name="nodeId">Node identifier.</param>
+ /// <param name="evt">Event.</param>
+ /// <returns>Value indicating whether specified event passes this filter.</returns>
+ public bool Invoke(Guid nodeId, IEvent evt)
+ {
+ Console.WriteLine("Remote filter received event [evt={0}]", evt.Name);
+
+ return evt is JobEvent;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs
new file mode 100644
index 0000000..7659bb4
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Threading;
+using Apache.Ignite.Core.Messaging;
+
+namespace Apache.Ignite.ExamplesDll.Messaging
+{
+ /// <summary>
+ /// Local message listener which signals countdown event on each received message.
+ /// </summary>
+ public class LocalListener : IMessageFilter<int>
+ {
+ /** Countdown event. */
+ private readonly CountdownEvent _countdown;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="LocalListener"/> class.
+ /// </summary>
+ /// <param name="countdown">The countdown event.</param>
+ public LocalListener(CountdownEvent countdown)
+ {
+ if (countdown == null)
+ throw new ArgumentNullException("countdown");
+
+ _countdown = countdown;
+ }
+
+ /// <summary>
+ /// Receives a message and returns a value
+ /// indicating whether provided message and node id satisfy this predicate.
+ /// Returning false will unsubscribe this listener from future notifications.
+ /// </summary>
+ /// <param name="nodeId">Node identifier.</param>
+ /// <param name="message">Message.</param>
+ /// <returns>Value indicating whether provided message and node id satisfy this predicate.</returns>
+ public bool Invoke(Guid nodeId, int message)
+ {
+ _countdown.Signal();
+
+ return !_countdown.IsSet;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs
new file mode 100644
index 0000000..8ae5ac1
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+using System;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Messaging;
+using Apache.Ignite.Core.Resource;
+
+namespace Apache.Ignite.ExamplesDll.Messaging
+{
+ /// <summary>
+ /// Listener for Ordered topic.
+ /// </summary>
+ [Serializable]
+ public class RemoteOrderedListener : IMessageFilter<int>
+ {
+ /** Injected Ignite instance. */
+ [InstanceResource]
+#pragma warning disable 649
+ private readonly IIgnite _ignite;
+#pragma warning restore 649
+
+ /// <summary>
+ /// Receives a message and returns a value
+ /// indicating whether provided message and node id satisfy this predicate.
+ /// Returning false will unsubscribe this listener from future notifications.
+ /// </summary>
+ /// <param name="nodeId">Node identifier.</param>
+ /// <param name="message">Message.</param>
+ /// <returns>Value indicating whether provided message and node id satisfy this predicate.</returns>
+ public bool Invoke(Guid nodeId, int message)
+ {
+ Console.WriteLine("Received ordered message [msg={0}, fromNodeId={1}]", message, nodeId);
+
+ _ignite.GetCluster().ForNodeIds(nodeId).GetMessaging().Send(message, Topic.Ordered);
+
+ return true;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs
new file mode 100644
index 0000000..166dbd6
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+using System;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Messaging;
+using Apache.Ignite.Core.Resource;
+
+namespace Apache.Ignite.ExamplesDll.Messaging
+{
+ /// <summary>
+ /// Listener for Unordered topic.
+ /// </summary>
+ [Serializable]
+ public class RemoteUnorderedListener : IMessageFilter<int>
+ {
+ /** Injected Ignite instance. */
+ [InstanceResource]
+#pragma warning disable 649
+ private readonly IIgnite _ignite;
+#pragma warning restore 649
+
+ /// <summary>
+ /// Receives a message and returns a value
+ /// indicating whether provided message and node id satisfy this predicate.
+ /// Returning false will unsubscribe this listener from future notifications.
+ /// </summary>
+ /// <param name="nodeId">Node identifier.</param>
+ /// <param name="message">Message.</param>
+ /// <returns>Value indicating whether provided message and node id satisfy this predicate.</returns>
+ public bool Invoke(Guid nodeId, int message)
+ {
+ Console.WriteLine("Received unordered message [msg={0}, fromNodeId={1}]", message, nodeId);
+
+ _ignite.GetCluster().ForNodeIds(nodeId).GetMessaging().Send(message, Topic.Unordered);
+
+ return true;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/Topic.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/Topic.cs b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/Topic.cs
new file mode 100644
index 0000000..bda0bfe
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/Topic.cs
@@ -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.
+ */
+
+namespace Apache.Ignite.ExamplesDll.Messaging
+{
+ /// <summary>
+ /// Message topics.
+ /// </summary>
+ public static class Topic
+ {
+ public const int Ordered = 1;
+ public const int Unordered = 2;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Account.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Account.cs b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Account.cs
new file mode 100644
index 0000000..8e247e3
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Account.cs
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+
+using System;
+
+namespace Apache.Ignite.ExamplesDll.Portable
+{
+ /// <summary>
+ /// Account object. Used in transaction example.
+ /// </summary>
+ [Serializable]
+ public class Account
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="id">Account ID.</param>
+ /// <param name="balance">Account balance.</param>
+ public Account(int id, decimal balance)
+ {
+ Id = id;
+ Balance = balance;
+ }
+
+ /// <summary>
+ /// Account ID.
+ /// </summary>
+ public int Id { get; set; }
+
+ /// <summary>
+ /// Account balance.
+ /// </summary>
+ public decimal Balance { get; set; }
+
+ /// <summary>
+ /// Returns a string that represents the current object.
+ /// </summary>
+ /// <returns>
+ /// A string that represents the current object.
+ /// </returns>
+ override public String ToString()
+ {
+ return string.Format("{0} [id={1}, balance={2}]", typeof(Account).Name, Id, Balance);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Address.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Address.cs b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Address.cs
new file mode 100644
index 0000000..ca069cb
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Address.cs
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+using System;
+using Apache.Ignite.Core.Portable;
+
+namespace Apache.Ignite.ExamplesDll.Portable
+{
+ /// <summary>
+ /// Address.
+ /// </summary>
+ [Serializable]
+ public class Address : IPortableMarshalAware
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="street">Street.</param>
+ /// <param name="zip">ZIP code.</param>
+ public Address(string street, int zip)
+ {
+ Street = street;
+ Zip = zip;
+ }
+
+ /// <summary>
+ /// Street.
+ /// </summary>
+ public string Street { get; set; }
+
+ /// <summary>
+ /// ZIP code.
+ /// </summary>
+ public int Zip { get; set; }
+
+ /// <summary>
+ /// Writes this object to the given writer.
+ /// </summary>
+ /// <param name="writer">Writer.</param>
+ public void WritePortable(IPortableWriter writer)
+ {
+ writer.WriteString("street", Street);
+ writer.WriteInt("zip", Zip);
+ }
+
+ /// <summary>
+ /// Reads this object from the given reader.
+ /// </summary>
+ /// <param name="reader">Reader.</param>
+ public void ReadPortable(IPortableReader reader)
+ {
+ Street = reader.ReadString("street");
+ Zip = reader.ReadInt("zip");
+ }
+
+ /// <summary>
+ /// Returns a string that represents the current object.
+ /// </summary>
+ /// <returns>
+ /// A string that represents the current object.
+ /// </returns>
+ override public string ToString()
+ {
+ return string.Format("{0} [street={1}, zip={2}]", typeof(Address).Name, Street, Zip);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Employee.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Employee.cs b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Employee.cs
new file mode 100644
index 0000000..7f4388d
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Employee.cs
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Apache.Ignite.ExamplesDll.Portable
+{
+ /// <summary>
+ /// Employee.
+ /// </summary>
+ [Serializable]
+ public class Employee
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="name">Name.</param>
+ /// <param name="salary">Salary.</param>
+ /// <param name="address">Address.</param>
+ /// <param name="departments">Departments.</param>
+ public Employee(string name, long salary, Address address, ICollection<string> departments)
+ {
+ Name = name;
+ Salary = salary;
+ Address = address;
+ Departments = departments;
+ }
+
+ /// <summary>
+ /// Name.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Salary.
+ /// </summary>
+ public long Salary { get; set; }
+
+ /// <summary>
+ /// Address.
+ /// </summary>
+ public Address Address { get; set; }
+
+ /// <summary>
+ /// Departments.
+ /// </summary>
+ public ICollection<string> Departments { get; set; }
+
+ /// <summary>
+ /// Returns a string that represents the current object.
+ /// </summary>
+ /// <returns>
+ /// A string that represents the current object.
+ /// </returns>
+ override public string ToString()
+ {
+ return string.Format("{0} [name={1}, salary={2}, address={3}, departments={4}]", typeof(Employee).Name,
+ Name, Salary, Address, CollectionToString(Departments));
+ }
+
+ /// <summary>
+ /// Get string representation of collection.
+ /// </summary>
+ /// <returns></returns>
+ private static string CollectionToString<T>(ICollection<T> col)
+ {
+ if (col == null)
+ return "null";
+
+ var elements = col.Any()
+ ? col.Select(x => x.ToString()).Aggregate((x, y) => x + ", " + y)
+ : string.Empty;
+
+ return string.Format("[{0}]", elements);
+ }
+ }
+}
[12/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Process/IgniteProcess.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Process/IgniteProcess.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Process/IgniteProcess.cs
deleted file mode 100644
index fd08116..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Process/IgniteProcess.cs
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Process
-{
- using System;
- using System.Diagnostics;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using Apache.Ignite.Core.Impl;
-
- /// <summary>
- /// Defines forked Ignite node.
- /// </summary>
- public class IgniteProcess
- {
- /** Executable file name. */
- private static readonly string ExeName = "Apache.Ignite.exe";
-
- /** Executable process name. */
- private static readonly string ExeProcName = ExeName.Substring(0, ExeName.LastIndexOf('.'));
-
- /** Executable configuration file name. */
- private static readonly string ExeCfgName = ExeName + ".config";
-
- /** Executable backup configuration file name. */
- private static readonly string ExeCfgBakName = ExeCfgName + ".bak";
-
- /** Directory where binaries are stored. */
- private static readonly string ExeDir;
-
- /** Full path to executable. */
- private static readonly string ExePath;
-
- /** Full path to executable configuration file. */
- private static readonly string ExeCfgPath;
-
- /** Full path to executable configuration file backup. */
- private static readonly string ExeCfgBakPath;
-
- /** Default process output reader. */
- private static readonly IIgniteProcessOutputReader DfltOutReader = new IgniteProcessConsoleOutputReader();
-
- /** Process. */
- private readonly Process _proc;
-
- /// <summary>
- /// Static initializer.
- /// </summary>
- static IgniteProcess()
- {
- // 1. Locate executable file and related stuff.
- DirectoryInfo dir = new FileInfo(new Uri(typeof(IgniteProcess).Assembly.CodeBase).LocalPath).Directory;
-
- // ReSharper disable once PossibleNullReferenceException
- ExeDir = dir.FullName;
-
- var exe = dir.GetFiles(ExeName);
-
- if (exe.Length == 0)
- throw new Exception(ExeName + " is not found in test output directory: " + dir.FullName);
-
- ExePath = exe[0].FullName;
-
- var exeCfg = dir.GetFiles(ExeCfgName);
-
- if (exeCfg.Length == 0)
- throw new Exception(ExeCfgName + " is not found in test output directory: " + dir.FullName);
-
- ExeCfgPath = exeCfg[0].FullName;
-
- ExeCfgBakPath = Path.Combine(ExeDir, ExeCfgBakName);
-
- File.Delete(ExeCfgBakPath);
- }
-
- /// <summary>
- /// Save current configuration to backup.
- /// </summary>
- public static void SaveConfigurationBackup()
- {
- File.Copy(ExeCfgPath, ExeCfgBakPath, true);
- }
-
- /// <summary>
- /// Restore configuration from backup.
- /// </summary>
- public static void RestoreConfigurationBackup()
- {
- File.Copy(ExeCfgBakPath, ExeCfgPath, true);
- }
-
- /// <summary>
- /// Replace application configuration with another one.
- /// </summary>
- /// <param name="relPath">Path to config relative to executable directory.</param>
- public static void ReplaceConfiguration(string relPath)
- {
- File.Copy(Path.Combine(ExeDir, relPath), ExeCfgPath, true);
- }
-
- /// <summary>
- /// Kill all Ignite processes.
- /// </summary>
- public static void KillAll()
- {
- foreach (Process proc in Process.GetProcesses())
- {
- if (proc.ProcessName.Equals(ExeProcName))
- {
- proc.Kill();
-
- proc.WaitForExit();
- }
- }
- }
-
- /// <summary>
- /// Construector.
- /// </summary>
- /// <param name="args">Arguments</param>
- public IgniteProcess(params string[] args) : this(DfltOutReader, args) { }
-
- /// <summary>
- /// Construector.
- /// </summary>
- /// <param name="outReader">Output reader.</param>
- /// <param name="args">Arguments.</param>
- public IgniteProcess(IIgniteProcessOutputReader outReader, params string[] args)
- {
- // Add test dll path
- args = args.Concat(new[] {"-assembly=" + GetType().Assembly.Location}).ToArray();
-
- _proc = Start(ExePath, IgniteManager.GetIgniteHome(null), outReader, args);
- }
-
- /// <summary>
- /// Starts a grid process.
- /// </summary>
- /// <param name="exePath">Exe path.</param>
- /// <param name="ggHome">Ignite home.</param>
- /// <param name="outReader">Output reader.</param>
- /// <param name="args">Arguments.</param>
- /// <returns>Started process.</returns>
- public static Process Start(string exePath, string ggHome, IIgniteProcessOutputReader outReader = null,
- params string[] args)
- {
- Debug.Assert(!string.IsNullOrEmpty(exePath));
- Debug.Assert(!string.IsNullOrEmpty(ggHome));
-
- // 1. Define process start configuration.
- var sb = new StringBuilder();
-
- foreach (string arg in args)
- sb.Append('\"').Append(arg).Append("\" ");
-
- var procStart = new ProcessStartInfo
- {
- FileName = exePath,
- Arguments = sb.ToString()
- };
-
- if (!string.IsNullOrEmpty(ggHome))
- procStart.EnvironmentVariables[IgniteManager.EnvIgniteHome] = ggHome;
-
- procStart.EnvironmentVariables[IgniteManager.EnvIgniteNativeTestClasspath] = "true";
-
- procStart.CreateNoWindow = true;
- procStart.UseShellExecute = false;
-
- procStart.RedirectStandardOutput = true;
- procStart.RedirectStandardError = true;
-
- var workDir = Path.GetDirectoryName(exePath);
-
- if (workDir != null)
- procStart.WorkingDirectory = workDir;
-
- Console.WriteLine("About to run Apache.Ignite.exe process [exePath=" + exePath + ", arguments=" + sb + ']');
-
- // 2. Start.
- var proc = Process.Start(procStart);
-
- Debug.Assert(proc != null);
-
- // 3. Attach output readers to avoid hangs.
- outReader = outReader ?? DfltOutReader;
-
- Attach(proc, proc.StandardOutput, outReader, false);
- Attach(proc, proc.StandardError, outReader, true);
-
- return proc;
- }
-
- /// <summary>
- /// Whether the process is still alive.
- /// </summary>
- public bool Alive
- {
- get { return !_proc.HasExited; }
- }
-
- /// <summary>
- /// Kill process.
- /// </summary>
- public void Kill()
- {
- _proc.Kill();
- }
-
- /// <summary>
- /// Join process.
- /// </summary>
- /// <returns>Exit code.</returns>
- public int Join()
- {
- _proc.WaitForExit();
-
- return _proc.ExitCode;
- }
-
- /// <summary>
- /// Join process with timeout.
- /// </summary>
- /// <param name="timeout">Timeout in milliseconds.</param>
- /// <returns><c>True</c> if process exit occurred before timeout.</returns>
- public bool Join(int timeout)
- {
- return _proc.WaitForExit(timeout);
- }
-
- /// <summary>
- /// Join process with timeout.
- /// </summary>
- /// <param name="timeout">Timeout in milliseconds.</param>
- /// <param name="exitCode">Exit code.</param>
- /// <returns><c>True</c> if process exit occurred before timeout.</returns>
- public bool Join(int timeout, out int exitCode)
- {
- if (_proc.WaitForExit(timeout))
- {
- exitCode = _proc.ExitCode;
-
- return true;
- }
- exitCode = 0;
-
- return false;
- }
-
- /// <summary>
- /// Attach output reader to the process.
- /// </summary>
- /// <param name="proc">Process.</param>
- /// <param name="reader">Process stream reader.</param>
- /// <param name="outReader">Output reader.</param>
- /// <param name="err">Whether this is error stream.</param>
- private static void Attach(Process proc, StreamReader reader, IIgniteProcessOutputReader outReader, bool err)
- {
- new Thread(() =>
- {
- while (!proc.HasExited)
- outReader.OnOutput(proc, reader.ReadLine(), err);
- }) {IsBackground = true}.Start();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Process/IgniteProcessConsoleOutputReader.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Process/IgniteProcessConsoleOutputReader.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Process/IgniteProcessConsoleOutputReader.cs
deleted file mode 100644
index 00cc040..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Process/IgniteProcessConsoleOutputReader.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Process
-{
- using System;
- using System.Diagnostics;
-
- /// <summary>
- /// Output reader pushing data to the console.
- /// </summary>
- public class IgniteProcessConsoleOutputReader : IIgniteProcessOutputReader
- {
- /** Out message format. */
- private static readonly string OutFormat = ">>> {0} OUT: {1}";
-
- /** Error message format. */
- private static readonly string ErrFormat = ">>> {0} ERR: {1}";
-
- /** <inheritDoc /> */
- public void OnOutput(Process proc, string data, bool err)
- {
- Console.WriteLine(err ? ErrFormat : OutFormat, proc.Id, data);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
deleted file mode 100644
index 1ebcf24..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-[assembly: AssemblyTitle("Apache.Ignite.Core.Tests")]
-[assembly: AssemblyDescription("Apache Ignite .NET Core Tests")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Apache Software Foundation")]
-[assembly: AssemblyProduct("Apache.Ignite.Core.Tests")]
-[assembly: AssemblyCopyright("Copyright © 2015")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-[assembly: ComVisible(false)]
-
-[assembly: Guid("de8dd5cc-7c7f-4a09-80d5-7086d9416a7b")]
-
-[assembly: AssemblyVersion("1.5.0")]
-[assembly: AssemblyFileVersion("1.5.0")]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Query/ImplicitPortablePerson.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Query/ImplicitPortablePerson.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Query/ImplicitPortablePerson.cs
deleted file mode 100644
index f80c4eb..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Query/ImplicitPortablePerson.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Query
-{
- /// <summary>
- /// Test person.
- /// </summary>
- internal class ImplicitPortablePerson
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="ImplicitPortablePerson"/> class.
- /// </summary>
- /// <param name="name">The name.</param>
- /// <param name="age">The age.</param>
- public ImplicitPortablePerson(string name, int age)
- {
- Name = name;
- Age = age;
- }
-
- /// <summary>
- /// Gets or sets the name.
- /// </summary>
- public string Name { get; set; }
-
- /// <summary>
- /// Gets or sets the age.
- /// </summary>
- public int Age { get; set; }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Query/NoDefPortablePerson.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Query/NoDefPortablePerson.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Query/NoDefPortablePerson.cs
deleted file mode 100644
index 16bd07d..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Query/NoDefPortablePerson.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Query
-{
- /// <summary>
- /// Test person.
- /// </summary>
- internal class NoDefPortablePerson
- {
- /// <summary>
- /// Gets or sets the name.
- /// </summary>
- public string Name { get; set; }
-
- /// <summary>
- /// Gets or sets the age.
- /// </summary>
- public int Age { get; set; }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Query/PortablePerson.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Query/PortablePerson.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Query/PortablePerson.cs
deleted file mode 100644
index 1e11001..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Query/PortablePerson.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Query
-{
- using Apache.Ignite.Core.Portable;
-
- /// <summary>
- /// Test person.
- /// </summary>
- internal class PortablePerson : IPortableMarshalAware
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="PortablePerson"/> class.
- /// </summary>
- /// <param name="name">The name.</param>
- /// <param name="age">The age.</param>
- public PortablePerson(string name, int age)
- {
- Name = name;
- Age = age;
- }
-
- /// <summary>
- /// Gets or sets the name.
- /// </summary>
- public string Name { get; set; }
-
- /// <summary>
- /// Gets or sets the address.
- /// </summary>
- public string Address { get; set; }
-
- /// <summary>
- /// Gets or sets the age.
- /// </summary>
- public int Age { get; set; }
-
- /** <ineritdoc /> */
- public void WritePortable(IPortableWriter writer)
- {
- writer.WriteString("name", Name);
- writer.WriteString("address", Address);
- writer.WriteInt("age", Age);
- }
-
- /** <ineritdoc /> */
- public void ReadPortable(IPortableReader reader)
- {
- Name = reader.ReadString("name");
- Address = reader.ReadString("address");
- Age = reader.ReadInt("age");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs
deleted file mode 100644
index e1a543e..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Reflection.Emit;
- using System.Runtime.Serialization;
- using System.Xml;
- using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Compute;
- using Apache.Ignite.Core.Impl;
- using NUnit.Framework;
-
- /// <summary>
- /// Tests for native serialization.
- /// </summary>
- public class SerializationTest
- {
- /** Grid name. */
- private const string GridName = "SerializationTest";
-
- /// <summary>
- /// Set up routine.
- /// </summary>
- [TestFixtureSetUp]
- public void SetUp()
- {
- var cfg = new IgniteConfigurationEx
- {
- GridName = GridName,
- JvmClasspath = TestUtils.CreateTestClasspath(),
- JvmOptions = TestUtils.TestJavaOptions(),
- SpringConfigUrl = "config\\native-client-test-cache.xml"
- };
-
- Ignition.Start(cfg);
- }
-
- /// <summary>
- /// Tear down routine.
- /// </summary>
- [TestFixtureTearDown]
- public void TearDown()
- {
- Ignition.StopAll(true);
- }
-
- /// <summary>
- /// Test complex file serialization.
- /// </summary>
- [Test]
- public void TestSerializableXmlDoc()
- {
- var grid = Ignition.GetIgnite(GridName);
- var cache = grid.GetCache<int, SerializableXmlDoc>("replicated");
-
- var doc = new SerializableXmlDoc();
-
- doc.LoadXml("<document><test1>val</test1><test2 attr=\"x\" /></document>");
-
- for (var i = 0; i < 50; i++)
- {
- // Test cache
- cache.Put(i, doc);
-
- var resultDoc = cache.Get(i);
-
- Assert.AreEqual(doc.OuterXml, resultDoc.OuterXml);
-
- // Test task with document arg
- CheckTask(grid, doc);
- }
- }
-
- /// <summary>
- /// Checks task execution.
- /// </summary>
- /// <param name="grid">Grid.</param>
- /// <param name="arg">Task arg.</param>
- private static void CheckTask(IIgnite grid, object arg)
- {
- var jobResult = grid.GetCompute().Execute(new CombineStringsTask(), arg);
-
- var nodeCount = grid.GetCluster().GetNodes().Count;
-
- var expectedRes =
- CombineStringsTask.CombineStrings(Enumerable.Range(0, nodeCount).Select(x => arg.ToString()));
-
- Assert.AreEqual(expectedRes, jobResult.InnerXml);
- }
-
- /// <summary>
- /// Tests custom serialization binder.
- /// </summary>
- [Test]
- public void TestSerializationBinder()
- {
- const int count = 50;
-
- var cache = Ignition.GetIgnite(GridName).GetCache<int, object>("local");
-
- // Put multiple objects from muliple same-named assemblies to cache
- for (var i = 0; i < count; i++)
- {
- dynamic val = Activator.CreateInstance(GenerateDynamicType());
-
- val.Id = i;
- val.Name = "Name_" + i;
-
- cache.Put(i, val);
- }
-
- // Verify correct deserialization
- for (var i = 0; i < count; i++)
- {
- dynamic val = cache.Get(i);
-
- Assert.AreEqual(val.Id, i);
- Assert.AreEqual(val.Name, "Name_" + i);
- }
- }
-
- /// <summary>
- /// Generates a Type in runtime, puts it into a dynamic assembly.
- /// </summary>
- /// <returns></returns>
- public static Type GenerateDynamicType()
- {
- var asmBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(
- new AssemblyName("GridSerializationTestDynamicAssembly"), AssemblyBuilderAccess.Run);
-
- var moduleBuilder = asmBuilder.DefineDynamicModule("GridSerializationTestDynamicModule");
-
- var typeBuilder = moduleBuilder.DefineType("GridSerializationTestDynamicType",
- TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Serializable);
-
- typeBuilder.DefineField("Id", typeof (int), FieldAttributes.Public);
-
- typeBuilder.DefineField("Name", typeof (string), FieldAttributes.Public);
-
- return typeBuilder.CreateType();
- }
- }
-
- [Serializable]
- [DataContract]
- public sealed class SerializableXmlDoc : XmlDocument, ISerializable
- {
- /// <summary>
- /// Default ctor.
- /// </summary>
- public SerializableXmlDoc()
- {
- // No-op
- }
-
- /// <summary>
- /// Serialization ctor.
- /// </summary>
- private SerializableXmlDoc(SerializationInfo info, StreamingContext context)
- {
- LoadXml(info.GetString("xmlDocument"));
- }
-
- /** <inheritdoc /> */
- public void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- info.AddValue("xmlDocument", OuterXml, typeof(string));
- }
- }
-
- [Serializable]
- public class CombineStringsTask : IComputeTask<object, string, SerializableXmlDoc>
- {
- public IDictionary<IComputeJob<string>, IClusterNode> Map(IList<IClusterNode> subgrid, object arg)
- {
- return subgrid.ToDictionary(x => (IComputeJob<string>) new ToStringJob {Arg = arg}, x => x);
- }
-
- public ComputeJobResultPolicy Result(IComputeJobResult<string> res, IList<IComputeJobResult<string>> rcvd)
- {
- return ComputeJobResultPolicy.Wait;
- }
-
- public SerializableXmlDoc Reduce(IList<IComputeJobResult<string>> results)
- {
- var result = new SerializableXmlDoc();
-
- result.LoadXml(CombineStrings(results.Select(x => x.Data())));
-
- return result;
- }
-
- public static string CombineStrings(IEnumerable<string> strings)
- {
- var text = string.Concat(strings.Select(x => string.Format("<val>{0}</val>", x)));
-
- return string.Format("<document>{0}</document>", text);
- }
- }
-
- [Serializable]
- public class ToStringJob : IComputeJob<string>
- {
- /// <summary>
- /// Job argument.
- /// </summary>
- public object Arg { get; set; }
-
- /** <inheritdoc /> */
- public string Execute()
- {
- return Arg.ToString();
- }
-
- /** <inheritdoc /> */
- public void Cancel()
- {
- // No-op.
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
deleted file mode 100644
index 44e1d71..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
+++ /dev/null
@@ -1,741 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Services
-{
- using System;
- using System.Diagnostics.CodeAnalysis;
- using System.IO;
- using System.Linq;
- using System.Reflection;
- using Apache.Ignite.Core.Impl.Memory;
- using Apache.Ignite.Core.Impl.Portable;
- using Apache.Ignite.Core.Impl.Services;
- using Apache.Ignite.Core.Portable;
- using Apache.Ignite.Core.Services;
- using NUnit.Framework;
-
- /// <summary>
- /// Tests <see cref="ServiceProxySerializer"/> functionality.
- /// </summary>
- public class ServiceProxyTest
- {
- /** */
- private TestIgniteService _svc;
-
- /** */
- private readonly PortableMarshaller _marsh = new PortableMarshaller(new PortableConfiguration
- {
- TypeConfigurations = new[]
- {
- new PortableTypeConfiguration(typeof (TestPortableClass)),
- new PortableTypeConfiguration(typeof (CustomExceptionPortable))
- }
- });
-
- /** */
- protected readonly IPortables Portables;
-
- /** */
- private readonly PlatformMemoryManager _memory = new PlatformMemoryManager(1024);
-
- /** */
- protected bool KeepPortable;
-
- /** */
- protected bool SrvKeepPortable;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="ServiceProxyTest"/> class.
- /// </summary>
- public ServiceProxyTest()
- {
- Portables = new PortablesImpl(_marsh);
- }
-
- /// <summary>
- /// Tests object class methods proxying.
- /// </summary>
- [Test]
- public void TestObjectClassMethods()
- {
- var prx = GetProxy();
-
- prx.IntProp = 12345;
-
- Assert.AreEqual("12345", prx.ToString());
- Assert.AreEqual("12345", _svc.ToString());
- Assert.AreEqual(12345, prx.GetHashCode());
- Assert.AreEqual(12345, _svc.GetHashCode());
- }
-
- /// <summary>
- /// Tests properties proxying.
- /// </summary>
- [Test]
- [SuppressMessage("ReSharper", "PossibleNullReferenceException")]
- public void TestProperties()
- {
- var prx = GetProxy();
-
- prx.IntProp = 10;
- Assert.AreEqual(10, prx.IntProp);
- Assert.AreEqual(10, _svc.IntProp);
-
- _svc.IntProp = 15;
- Assert.AreEqual(15, prx.IntProp);
- Assert.AreEqual(15, _svc.IntProp);
-
- prx.ObjProp = "prop1";
- Assert.AreEqual("prop1", prx.ObjProp);
- Assert.AreEqual("prop1", _svc.ObjProp);
-
- prx.ObjProp = null;
- Assert.IsNull(prx.ObjProp);
- Assert.IsNull(_svc.ObjProp);
-
- prx.ObjProp = new TestClass {Prop = "prop2"};
- Assert.AreEqual("prop2", ((TestClass)prx.ObjProp).Prop);
- Assert.AreEqual("prop2", ((TestClass)_svc.ObjProp).Prop);
- }
-
- /// <summary>
- /// Tests void methods proxying.
- /// </summary>
- [Test]
- public void TestVoidMethods()
- {
- var prx = GetProxy();
-
- prx.VoidMethod();
- Assert.AreEqual("VoidMethod", prx.InvokeResult);
- Assert.AreEqual("VoidMethod", _svc.InvokeResult);
-
- prx.VoidMethod(10);
- Assert.AreEqual(_svc.InvokeResult, prx.InvokeResult);
-
- prx.VoidMethod(10, "string");
- Assert.AreEqual(_svc.InvokeResult, prx.InvokeResult);
-
- prx.VoidMethod(10, "string", "arg");
- Assert.AreEqual(_svc.InvokeResult, prx.InvokeResult);
-
- prx.VoidMethod(10, "string", "arg", "arg1", 2, 3, "arg4");
- Assert.AreEqual(_svc.InvokeResult, prx.InvokeResult);
- }
-
- /// <summary>
- /// Tests object methods proxying.
- /// </summary>
- [Test]
- public void TestObjectMethods()
- {
- var prx = GetProxy();
-
- Assert.AreEqual("ObjectMethod", prx.ObjectMethod());
- Assert.AreEqual("ObjectMethod987", prx.ObjectMethod(987));
- Assert.AreEqual("ObjectMethod987str123", prx.ObjectMethod(987, "str123"));
- Assert.AreEqual("ObjectMethod987str123TestClass", prx.ObjectMethod(987, "str123", new TestClass()));
- Assert.AreEqual("ObjectMethod987str123TestClass34arg5arg6",
- prx.ObjectMethod(987, "str123", new TestClass(), 3, 4, "arg5", "arg6"));
- }
-
- /// <summary>
- /// Tests methods that exist in proxy interface, but do not exist in the actual service.
- /// </summary>
- [Test]
- public void TestMissingMethods()
- {
- var prx = GetProxy();
-
- var ex = Assert.Throws<InvalidOperationException>(() => prx.MissingMethod());
-
- Assert.AreEqual("Failed to invoke proxy: there is no method 'MissingMethod'" +
- " in type 'Apache.Ignite.Core.Tests.Services.ServiceProxyTest+TestIgniteService'", ex.Message);
- }
-
- /// <summary>
- /// Tests ambiguous methods handling (multiple methods with the same signature).
- /// </summary>
- [Test]
- public void TestAmbiguousMethods()
- {
- var prx = GetProxy();
-
- var ex = Assert.Throws<InvalidOperationException>(() => prx.AmbiguousMethod(1));
-
- Assert.AreEqual("Failed to invoke proxy: there are 2 methods 'AmbiguousMethod' in type " +
- "'Apache.Ignite.Core.Tests.Services.ServiceProxyTest+TestIgniteService' with (Int32) arguments, " +
- "can't resolve ambiguity.", ex.Message);
- }
-
- [Test]
- public void TestException()
- {
- var prx = GetProxy();
-
- var err = Assert.Throws<ServiceInvocationException>(prx.ExceptionMethod);
- Assert.AreEqual("Expected exception", err.InnerException.Message);
-
- var ex = Assert.Throws<ServiceInvocationException>(() => prx.CustomExceptionMethod());
- Assert.IsTrue(ex.ToString().Contains("+CustomException"));
- }
-
- [Test]
- public void TestPortableMarshallingException()
- {
- var prx = GetProxy();
-
- var ex = Assert.Throws<ServiceInvocationException>(() => prx.CustomExceptionPortableMethod(false, false));
-
- if (KeepPortable)
- {
- Assert.AreEqual("Proxy method invocation failed with a portable error. " +
- "Examine PortableCause for details.", ex.Message);
-
- Assert.IsNotNull(ex.PortableCause);
- Assert.IsNull(ex.InnerException);
- }
- else
- {
- Assert.AreEqual("Proxy method invocation failed with an exception. " +
- "Examine InnerException for details.", ex.Message);
-
- Assert.IsNull(ex.PortableCause);
- Assert.IsNotNull(ex.InnerException);
- }
-
- ex = Assert.Throws<ServiceInvocationException>(() => prx.CustomExceptionPortableMethod(true, false));
- Assert.IsTrue(ex.ToString().Contains(
- "Call completed with error, but error serialization failed [errType=CustomExceptionPortable, " +
- "serializationErrMsg=Expected exception in CustomExceptionPortable.WritePortable]"));
-
- ex = Assert.Throws<ServiceInvocationException>(() => prx.CustomExceptionPortableMethod(true, true));
- Assert.IsTrue(ex.ToString().Contains(
- "Call completed with error, but error serialization failed [errType=CustomExceptionPortable, " +
- "serializationErrMsg=Expected exception in CustomExceptionPortable.WritePortable]"));
- }
-
- /// <summary>
- /// Creates the proxy.
- /// </summary>
- protected ITestIgniteServiceProxyInterface GetProxy()
- {
- return GetProxy<ITestIgniteServiceProxyInterface>();
- }
-
- /// <summary>
- /// Creates the proxy.
- /// </summary>
- protected T GetProxy<T>()
- {
- _svc = new TestIgniteService(Portables);
-
- var prx = new ServiceProxy<T>(InvokeProxyMethod).GetTransparentProxy();
-
- Assert.IsFalse(ReferenceEquals(_svc, prx));
-
- return prx;
- }
-
- /// <summary>
- /// Invokes the proxy.
- /// </summary>
- /// <param name="method">Method.</param>
- /// <param name="args">Arguments.</param>
- /// <returns>
- /// Invocation result.
- /// </returns>
- private object InvokeProxyMethod(MethodBase method, object[] args)
- {
- using (var inStream = new PlatformMemoryStream(_memory.Allocate()))
- using (var outStream = new PlatformMemoryStream(_memory.Allocate()))
- {
- // 1) Write to a stream
- inStream.WriteBool(SrvKeepPortable); // WriteProxyMethod does not do this, but Java does
-
- ServiceProxySerializer.WriteProxyMethod(_marsh.StartMarshal(inStream), method, args);
-
- inStream.SynchronizeOutput();
-
- inStream.Seek(0, SeekOrigin.Begin);
-
- // 2) call InvokeServiceMethod
- string mthdName;
- object[] mthdArgs;
-
- ServiceProxySerializer.ReadProxyMethod(inStream, _marsh, out mthdName, out mthdArgs);
-
- var result = ServiceProxyInvoker.InvokeServiceMethod(_svc, mthdName, mthdArgs);
-
- ServiceProxySerializer.WriteInvocationResult(outStream, _marsh, result.Key, result.Value);
-
- _marsh.StartMarshal(outStream).WriteString("unused"); // fake Java exception details
-
- outStream.SynchronizeOutput();
-
- outStream.Seek(0, SeekOrigin.Begin);
-
- return ServiceProxySerializer.ReadInvocationResult(outStream, _marsh, KeepPortable);
- }
- }
-
- /// <summary>
- /// Test service interface.
- /// </summary>
- protected interface ITestIgniteServiceProperties
- {
- /** */
- int IntProp { get; set; }
-
- /** */
- object ObjProp { get; set; }
-
- /** */
- string InvokeResult { get; }
- }
-
- /// <summary>
- /// Test service interface to check ambiguity handling.
- /// </summary>
- protected interface ITestIgniteServiceAmbiguity
- {
- /** */
- int AmbiguousMethod(int arg);
- }
-
- /// <summary>
- /// Test service interface.
- /// </summary>
- protected interface ITestIgniteService : ITestIgniteServiceProperties
- {
- /** */
- void VoidMethod();
-
- /** */
- void VoidMethod(int arg);
-
- /** */
- void VoidMethod(int arg, string arg1, object arg2 = null);
-
- /** */
- void VoidMethod(int arg, string arg1, object arg2 = null, params object[] args);
-
- /** */
- object ObjectMethod();
-
- /** */
- object ObjectMethod(int arg);
-
- /** */
- object ObjectMethod(int arg, string arg1, object arg2 = null);
-
- /** */
- object ObjectMethod(int arg, string arg1, object arg2 = null, params object[] args);
-
- /** */
- void ExceptionMethod();
-
- /** */
- void CustomExceptionMethod();
-
- /** */
- void CustomExceptionPortableMethod(bool throwOnWrite, bool throwOnRead);
-
- /** */
- TestPortableClass PortableArgMethod(int arg1, IPortableObject arg2);
-
- /** */
- IPortableObject PortableResultMethod(int arg1, TestPortableClass arg2);
-
- /** */
- IPortableObject PortableArgAndResultMethod(int arg1, IPortableObject arg2);
-
- /** */
- int AmbiguousMethod(int arg);
- }
-
- /// <summary>
- /// Test service interface. Does not derive from actual interface, but has all the same method signatures.
- /// </summary>
- protected interface ITestIgniteServiceProxyInterface
- {
- /** */
- int IntProp { get; set; }
-
- /** */
- object ObjProp { get; set; }
-
- /** */
- string InvokeResult { get; }
-
- /** */
- void VoidMethod();
-
- /** */
- void VoidMethod(int arg);
-
- /** */
- void VoidMethod(int arg, string arg1, object arg2 = null);
-
- /** */
- void VoidMethod(int arg, string arg1, object arg2 = null, params object[] args);
-
- /** */
- object ObjectMethod();
-
- /** */
- object ObjectMethod(int arg);
-
- /** */
- object ObjectMethod(int arg, string arg1, object arg2 = null);
-
- /** */
- object ObjectMethod(int arg, string arg1, object arg2 = null, params object[] args);
-
- /** */
- void ExceptionMethod();
-
- /** */
- void CustomExceptionMethod();
-
- /** */
- void CustomExceptionPortableMethod(bool throwOnWrite, bool throwOnRead);
-
- /** */
- TestPortableClass PortableArgMethod(int arg1, IPortableObject arg2);
-
- /** */
- IPortableObject PortableResultMethod(int arg1, TestPortableClass arg2);
-
- /** */
- IPortableObject PortableArgAndResultMethod(int arg1, IPortableObject arg2);
-
- /** */
- void MissingMethod();
-
- /** */
- int AmbiguousMethod(int arg);
- }
-
- /// <summary>
- /// Test service.
- /// </summary>
- [Serializable]
- private class TestIgniteService : ITestIgniteService, ITestIgniteServiceAmbiguity
- {
- /** */
- private readonly IPortables _portables;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="TestIgniteService"/> class.
- /// </summary>
- /// <param name="portables">The portables.</param>
- public TestIgniteService(IPortables portables)
- {
- _portables = portables;
- }
-
- /** <inheritdoc /> */
- public int IntProp { get; set; }
-
- /** <inheritdoc /> */
- public object ObjProp { get; set; }
-
- /** <inheritdoc /> */
- public string InvokeResult { get; private set; }
-
- /** <inheritdoc /> */
- public void VoidMethod()
- {
- InvokeResult = "VoidMethod";
- }
-
- /** <inheritdoc /> */
- public void VoidMethod(int arg)
- {
- InvokeResult = "VoidMethod" + arg;
- }
-
- /** <inheritdoc /> */
- public void VoidMethod(int arg, string arg1, object arg2 = null)
- {
- InvokeResult = "VoidMethod" + arg + arg1 + arg2;
- }
-
- /** <inheritdoc /> */
- public void VoidMethod(int arg, string arg1, object arg2 = null, params object[] args)
- {
- InvokeResult = "VoidMethod" + arg + arg1 + arg2 + string.Concat(args.Select(x => x.ToString()));
- }
-
- /** <inheritdoc /> */
- public object ObjectMethod()
- {
- return "ObjectMethod";
- }
-
- /** <inheritdoc /> */
- public object ObjectMethod(int arg)
- {
- return "ObjectMethod" + arg;
- }
-
- /** <inheritdoc /> */
- public object ObjectMethod(int arg, string arg1, object arg2 = null)
- {
- return "ObjectMethod" + arg + arg1 + arg2;
- }
-
- /** <inheritdoc /> */
- public object ObjectMethod(int arg, string arg1, object arg2 = null, params object[] args)
- {
- return "ObjectMethod" + arg + arg1 + arg2 + string.Concat(args.Select(x => x.ToString()));
- }
-
- /** <inheritdoc /> */
- public void ExceptionMethod()
- {
- throw new ArithmeticException("Expected exception");
- }
-
- /** <inheritdoc /> */
- public void CustomExceptionMethod()
- {
- throw new CustomException();
- }
-
- /** <inheritdoc /> */
- public void CustomExceptionPortableMethod(bool throwOnWrite, bool throwOnRead)
- {
- throw new CustomExceptionPortable {ThrowOnRead = throwOnRead, ThrowOnWrite = throwOnWrite};
- }
-
- /** <inheritdoc /> */
- public TestPortableClass PortableArgMethod(int arg1, IPortableObject arg2)
- {
- return arg2.Deserialize<TestPortableClass>();
- }
-
- /** <inheritdoc /> */
- public IPortableObject PortableResultMethod(int arg1, TestPortableClass arg2)
- {
- return _portables.ToPortable<IPortableObject>(arg2);
- }
-
- /** <inheritdoc /> */
- public IPortableObject PortableArgAndResultMethod(int arg1, IPortableObject arg2)
- {
- return _portables.ToPortable<IPortableObject>(arg2.Deserialize<TestPortableClass>());
- }
-
- /** <inheritdoc /> */
- public override string ToString()
- {
- return IntProp.ToString();
- }
-
- /** <inheritdoc /> */
- public override int GetHashCode()
- {
- return IntProp.GetHashCode();
- }
-
- /** <inheritdoc /> */
- int ITestIgniteService.AmbiguousMethod(int arg)
- {
- return arg;
- }
-
- /** <inheritdoc /> */
- int ITestIgniteServiceAmbiguity.AmbiguousMethod(int arg)
- {
- return -arg;
- }
- }
-
- /// <summary>
- /// Test serializable class.
- /// </summary>
- [Serializable]
- private class TestClass
- {
- /** */
- public string Prop { get; set; }
-
- /** <inheritdoc /> */
- public override string ToString()
- {
- return "TestClass" + Prop;
- }
- }
-
- /// <summary>
- /// Custom non-serializable exception.
- /// </summary>
- private class CustomException : Exception
- {
-
- }
-
- /// <summary>
- /// Custom non-serializable exception.
- /// </summary>
- private class CustomExceptionPortable : Exception, IPortableMarshalAware
- {
- /** */
- public bool ThrowOnWrite { get; set; }
-
- /** */
- public bool ThrowOnRead { get; set; }
-
- /** <inheritdoc /> */
- public void WritePortable(IPortableWriter writer)
- {
- writer.WriteBoolean("ThrowOnRead", ThrowOnRead);
-
- if (ThrowOnWrite)
- throw new Exception("Expected exception in CustomExceptionPortable.WritePortable");
- }
-
- /** <inheritdoc /> */
- public void ReadPortable(IPortableReader reader)
- {
- ThrowOnRead = reader.ReadBoolean("ThrowOnRead");
-
- if (ThrowOnRead)
- throw new Exception("Expected exception in CustomExceptionPortable.ReadPortable");
- }
- }
-
- /// <summary>
- /// Portable object for method argument/result.
- /// </summary>
- protected class TestPortableClass : IPortableMarshalAware
- {
- /** */
- public string Prop { get; set; }
-
- /** */
- public bool ThrowOnWrite { get; set; }
-
- /** */
- public bool ThrowOnRead { get; set; }
-
- /** <inheritdoc /> */
- public void WritePortable(IPortableWriter writer)
- {
- writer.WriteString("Prop", Prop);
- writer.WriteBoolean("ThrowOnRead", ThrowOnRead);
-
- if (ThrowOnWrite)
- throw new Exception("Expected exception in TestPortableClass.WritePortable");
- }
-
- /** <inheritdoc /> */
- public void ReadPortable(IPortableReader reader)
- {
- Prop = reader.ReadString("Prop");
- ThrowOnRead = reader.ReadBoolean("ThrowOnRead");
-
- if (ThrowOnRead)
- throw new Exception("Expected exception in TestPortableClass.ReadPortable");
- }
- }
- }
-
- /// <summary>
- /// Tests <see cref="ServiceProxySerializer"/> functionality with keepPortable mode enabled on client.
- /// </summary>
- public class ServiceProxyTestKeepPortableClient : ServiceProxyTest
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="ServiceProxyTestKeepPortableClient"/> class.
- /// </summary>
- public ServiceProxyTestKeepPortableClient()
- {
- KeepPortable = true;
- }
-
- [Test]
- public void TestPortableMethods()
- {
- var prx = GetProxy();
-
- var obj = new TestPortableClass { Prop = "PropValue" };
-
- var result = prx.PortableResultMethod(1, obj);
-
- Assert.AreEqual(obj.Prop, result.Deserialize<TestPortableClass>().Prop);
- }
- }
-
- /// <summary>
- /// Tests <see cref="ServiceProxySerializer"/> functionality with keepPortable mode enabled on server.
- /// </summary>
- public class ServiceProxyTestKeepPortableServer : ServiceProxyTest
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="ServiceProxyTestKeepPortableServer"/> class.
- /// </summary>
- public ServiceProxyTestKeepPortableServer()
- {
- SrvKeepPortable = true;
- }
-
- [Test]
- public void TestPortableMethods()
- {
- var prx = GetProxy();
-
- var obj = new TestPortableClass { Prop = "PropValue" };
- var portObj = Portables.ToPortable<IPortableObject>(obj);
-
- var result = prx.PortableArgMethod(1, portObj);
-
- Assert.AreEqual(obj.Prop, result.Prop);
- }
- }
-
- /// <summary>
- /// Tests <see cref="ServiceProxySerializer"/> functionality with keepPortable mode enabled on client and on server.
- /// </summary>
- public class ServiceProxyTestKeepPortableClientServer : ServiceProxyTest
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="ServiceProxyTestKeepPortableClientServer"/> class.
- /// </summary>
- public ServiceProxyTestKeepPortableClientServer()
- {
- KeepPortable = true;
- SrvKeepPortable = true;
- }
-
- [Test]
- public void TestPortableMethods()
- {
- var prx = GetProxy();
-
- var obj = new TestPortableClass { Prop = "PropValue" };
- var portObj = Portables.ToPortable<IPortableObject>(obj);
-
- var result = prx.PortableArgAndResultMethod(1, portObj);
-
- Assert.AreEqual(obj.Prop, result.Deserialize<TestPortableClass>().Prop);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Services/ServicesAsyncWrapper.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Services/ServicesAsyncWrapper.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Services/ServicesAsyncWrapper.cs
deleted file mode 100644
index ba45dbd..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Services/ServicesAsyncWrapper.cs
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Services
-{
- using System.Collections.Generic;
- using System.Diagnostics;
- using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Services;
-
- /// <summary>
- /// Services async wrapper to simplify testing.
- /// </summary>
- public class ServicesAsyncWrapper : IServices
- {
- /** Wrapped async services. */
- private readonly IServices _services;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="ServicesAsyncWrapper"/> class.
- /// </summary>
- /// <param name="services">Services to wrap.</param>
- public ServicesAsyncWrapper(IServices services)
- {
- _services = services.WithAsync();
- }
-
- /** <inheritDoc /> */
- public IServices WithAsync()
- {
- return this;
- }
-
- /** <inheritDoc /> */
- public bool IsAsync
- {
- get { return true; }
- }
-
- /** <inheritDoc /> */
- public IFuture GetFuture()
- {
- Debug.Fail("ServicesAsyncWrapper.Future() should not be called. It always returns null.");
- return null;
- }
-
- /** <inheritDoc /> */
- public IFuture<TResult> GetFuture<TResult>()
- {
- Debug.Fail("ServicesAsyncWrapper.Future() should not be called. It always returns null.");
- return null;
- }
-
- /** <inheritDoc /> */
- public IClusterGroup ClusterGroup
- {
- get { return _services.ClusterGroup; }
- }
-
- /** <inheritDoc /> */
- public void DeployClusterSingleton(string name, IService service)
- {
- _services.DeployClusterSingleton(name, service);
- WaitResult();
- }
-
- /** <inheritDoc /> */
- public void DeployNodeSingleton(string name, IService service)
- {
- _services.DeployNodeSingleton(name, service);
- WaitResult();
- }
-
- /** <inheritDoc /> */
- public void DeployKeyAffinitySingleton<TK>(string name, IService service, string cacheName, TK affinityKey)
- {
- _services.DeployKeyAffinitySingleton(name, service, cacheName, affinityKey);
- WaitResult();
- }
-
- /** <inheritDoc /> */
- public void DeployMultiple(string name, IService service, int totalCount, int maxPerNodeCount)
- {
- _services.DeployMultiple(name, service, totalCount, maxPerNodeCount);
- WaitResult();
- }
-
- /** <inheritDoc /> */
- public void Deploy(ServiceConfiguration configuration)
- {
- _services.Deploy(configuration);
- WaitResult();
- }
-
- /** <inheritDoc /> */
- public void Cancel(string name)
- {
- _services.Cancel(name);
- WaitResult();
- }
-
- /** <inheritDoc /> */
- public void CancelAll()
- {
- _services.CancelAll();
- WaitResult();
- }
-
- /** <inheritDoc /> */
- public ICollection<IServiceDescriptor> GetServiceDescriptors()
- {
- return _services.GetServiceDescriptors();
- }
-
- /** <inheritDoc /> */
- public T GetService<T>(string name)
- {
- return _services.GetService<T>(name);
- }
-
- /** <inheritDoc /> */
- public ICollection<T> GetServices<T>(string name)
- {
- return _services.GetServices<T>(name);
- }
-
- /** <inheritDoc /> */
- public T GetServiceProxy<T>(string name) where T : class
- {
- return _services.GetServiceProxy<T>(name);
- }
-
- /** <inheritDoc /> */
- public T GetServiceProxy<T>(string name, bool sticky) where T : class
- {
- return _services.GetServiceProxy<T>(name, sticky);
- }
-
- /** <inheritDoc /> */
- public IServices WithKeepPortable()
- {
- return new ServicesAsyncWrapper(_services.WithKeepPortable());
- }
-
- /** <inheritDoc /> */
- public IServices WithServerKeepPortable()
- {
- return new ServicesAsyncWrapper(_services.WithServerKeepPortable());
- }
-
- /// <summary>
- /// Waits for the async result.
- /// </summary>
- private void WaitResult()
- {
- _services.GetFuture().Get();
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
deleted file mode 100644
index 6b2a7ec..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
+++ /dev/null
@@ -1,823 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Services
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading;
- using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Portable;
- using Apache.Ignite.Core.Resource;
- using Apache.Ignite.Core.Services;
- using NUnit.Framework;
-
- /// <summary>
- /// Services tests.
- /// </summary>
- public class ServicesTest
- {
- /** */
- private const string SvcName = "Service1";
-
- /** */
- private const string CacheName = "cache1";
-
- /** */
- private const int AffKey = 25;
-
- /** */
- protected IIgnite Grid1;
-
- /** */
- protected IIgnite Grid2;
-
- /** */
- protected IIgnite Grid3;
-
- /** */
- protected IIgnite[] Grids;
-
- [TestFixtureTearDown]
- public void FixtureTearDown()
- {
- StopGrids();
- }
-
- /// <summary>
- /// Executes before each test.
- /// </summary>
- [SetUp]
- public void SetUp()
- {
- StartGrids();
- EventsTestHelper.ListenResult = true;
- }
-
- /// <summary>
- /// Executes after each test.
- /// </summary>
- [TearDown]
- public void TearDown()
- {
- try
- {
- Services.Cancel(SvcName);
-
- TestUtils.AssertHandleRegistryIsEmpty(1000, Grid1, Grid2, Grid3);
- }
- catch (Exception)
- {
- // Restart grids to cleanup
- StopGrids();
-
- throw;
- }
- finally
- {
- EventsTestHelper.AssertFailures();
-
- if (TestContext.CurrentContext.Test.Name.StartsWith("TestEventTypes"))
- StopGrids(); // clean events for other tests
- }
- }
-
- /// <summary>
- /// Tests deployment.
- /// </summary>
- [Test]
- public void TestDeploy([Values(true, false)] bool portable)
- {
- var cfg = new ServiceConfiguration
- {
- Name = SvcName,
- MaxPerNodeCount = 3,
- TotalCount = 3,
- NodeFilter = new NodeFilter {NodeId = Grid1.GetCluster().GetLocalNode().Id},
- Service = portable ? new TestIgniteServicePortable() : new TestIgniteServiceSerializable()
- };
-
- Services.Deploy(cfg);
-
- CheckServiceStarted(Grid1, 3);
- }
-
- /// <summary>
- /// Tests cluster singleton deployment.
- /// </summary>
- [Test]
- public void TestDeployClusterSingleton()
- {
- var svc = new TestIgniteServiceSerializable();
-
- Services.DeployClusterSingleton(SvcName, svc);
-
- var svc0 = Services.GetServiceProxy<ITestIgniteService>(SvcName);
-
- // Check that only one node has the service.
- foreach (var grid in Grids)
- {
- if (grid.GetCluster().GetLocalNode().Id == svc0.NodeId)
- CheckServiceStarted(grid);
- else
- Assert.IsNull(grid.GetServices().GetService<TestIgniteServiceSerializable>(SvcName));
- }
- }
-
- /// <summary>
- /// Tests node singleton deployment.
- /// </summary>
- [Test]
- public void TestDeployNodeSingleton()
- {
- var svc = new TestIgniteServiceSerializable();
-
- Services.DeployNodeSingleton(SvcName, svc);
-
- Assert.AreEqual(1, Grid1.GetServices().GetServices<ITestIgniteService>(SvcName).Count);
- Assert.AreEqual(1, Grid2.GetServices().GetServices<ITestIgniteService>(SvcName).Count);
- Assert.AreEqual(1, Grid3.GetServices().GetServices<ITestIgniteService>(SvcName).Count);
- }
-
- /// <summary>
- /// Tests key affinity singleton deployment.
- /// </summary>
- [Test]
- public void TestDeployKeyAffinitySingleton()
- {
- var svc = new TestIgniteServicePortable();
-
- Services.DeployKeyAffinitySingleton(SvcName, svc, CacheName, AffKey);
-
- var affNode = Grid1.GetAffinity(CacheName).MapKeyToNode(AffKey);
-
- var prx = Services.GetServiceProxy<ITestIgniteService>(SvcName);
-
- Assert.AreEqual(affNode.Id, prx.NodeId);
- }
-
- /// <summary>
- /// Tests key affinity singleton deployment.
- /// </summary>
- [Test]
- public void TestDeployKeyAffinitySingletonPortable()
- {
- var services = Services.WithKeepPortable();
-
- var svc = new TestIgniteServicePortable();
-
- var affKey = new PortableObject {Val = AffKey};
-
- services.DeployKeyAffinitySingleton(SvcName, svc, CacheName, affKey);
-
- var prx = services.GetServiceProxy<ITestIgniteService>(SvcName);
-
- Assert.IsTrue(prx.Initialized);
- }
-
- /// <summary>
- /// Tests multiple deployment.
- /// </summary>
- [Test]
- public void TestDeployMultiple()
- {
- var svc = new TestIgniteServiceSerializable();
-
- Services.DeployMultiple(SvcName, svc, Grids.Length * 5, 5);
-
- foreach (var grid in Grids)
- CheckServiceStarted(grid, 5);
- }
-
- /// <summary>
- /// Tests cancellation.
- /// </summary>
- [Test]
- public void TestCancel()
- {
- for (var i = 0; i < 10; i++)
- {
- Services.DeployNodeSingleton(SvcName + i, new TestIgniteServicePortable());
- Assert.IsNotNull(Services.GetService<ITestIgniteService>(SvcName + i));
- }
-
- Services.Cancel(SvcName + 0);
- Services.Cancel(SvcName + 1);
-
- Assert.IsNull(Services.GetService<ITestIgniteService>(SvcName + 0));
- Assert.IsNull(Services.GetService<ITestIgniteService>(SvcName + 1));
-
- for (var i = 2; i < 10; i++)
- Assert.IsNotNull(Services.GetService<ITestIgniteService>(SvcName + i));
-
- Services.CancelAll();
-
- for (var i = 0; i < 10; i++)
- Assert.IsNull(Services.GetService<ITestIgniteService>(SvcName + i));
- }
-
- /// <summary>
- /// Tests service proxy.
- /// </summary>
- [Test]
- public void TestGetServiceProxy([Values(true, false)] bool portable)
- {
- // Test proxy without a service
- var prx = Services.GetServiceProxy<ITestIgniteService>(SvcName);
-
- Assert.IsTrue(prx != null);
-
- var ex = Assert.Throws<ServiceInvocationException>(() => Assert.IsTrue(prx.Initialized)).InnerException;
- Assert.AreEqual("Failed to find deployed service: " + SvcName, ex.Message);
-
- // Deploy to grid2 & grid3
- var svc = portable
- ? new TestIgniteServicePortable {TestProperty = 17}
- : new TestIgniteServiceSerializable {TestProperty = 17};
-
- Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id, Grid3.GetCluster().GetLocalNode().Id).GetServices()
- .DeployNodeSingleton(SvcName,
- svc);
-
- // Make sure there is no local instance on grid1
- Assert.IsNull(Services.GetService<ITestIgniteService>(SvcName));
-
- // Get proxy
- prx = Services.GetServiceProxy<ITestIgniteService>(SvcName);
-
- // Check proxy properties
- Assert.IsNotNull(prx);
- Assert.AreEqual(prx.GetType(), svc.GetType());
- Assert.AreEqual(prx.ToString(), svc.ToString());
- Assert.AreEqual(17, prx.TestProperty);
- Assert.IsTrue(prx.Initialized);
- Assert.IsTrue(prx.Executed);
- Assert.IsFalse(prx.Cancelled);
- Assert.AreEqual(SvcName, prx.LastCallContextName);
-
- // Check err method
- Assert.Throws<ServiceInvocationException>(() => prx.ErrMethod(123));
-
- // Check local scenario (proxy should not be created for local instance)
- Assert.IsTrue(ReferenceEquals(Grid2.GetServices().GetService<ITestIgniteService>(SvcName),
- Grid2.GetServices().GetServiceProxy<ITestIgniteService>(SvcName)));
-
- // Check sticky = false: call multiple times, check that different nodes get invoked
- var invokedIds = Enumerable.Range(1, 100).Select(x => prx.NodeId).Distinct().ToList();
- Assert.AreEqual(2, invokedIds.Count);
-
- // Check sticky = true: all calls should be to the same node
- prx = Services.GetServiceProxy<ITestIgniteService>(SvcName, true);
- invokedIds = Enumerable.Range(1, 100).Select(x => prx.NodeId).Distinct().ToList();
- Assert.AreEqual(1, invokedIds.Count);
-
- // Proxy does not work for cancelled service.
- Services.CancelAll();
-
- Assert.Throws<ServiceInvocationException>(() => { Assert.IsTrue(prx.Cancelled); });
- }
-
- /// <summary>
- /// Tests the duck typing: proxy interface can be different from actual service interface,
- /// only called method signature should be compatible.
- /// </summary>
- [Test]
- public void TestDuckTyping([Values(true, false)] bool local)
- {
- var svc = new TestIgniteServicePortable {TestProperty = 33};
-
- // Deploy locally or to the remote node
- var nodeId = (local ? Grid1 : Grid2).GetCluster().GetLocalNode().Id;
-
- var cluster = Grid1.GetCluster().ForNodeIds(nodeId);
-
- cluster.GetServices().DeployNodeSingleton(SvcName, svc);
-
- // Get proxy
- var prx = Services.GetServiceProxy<ITestIgniteServiceProxyInterface>(SvcName);
-
- // NodeId signature is the same as in service
- Assert.AreEqual(nodeId, prx.NodeId);
-
- // Method signature is different from service signature (object -> object), but is compatible.
- Assert.AreEqual(15, prx.Method(15));
-
- // TestProperty is object in proxy and int in service, getter works..
- Assert.AreEqual(33, prx.TestProperty);
-
- // .. but setter does not
- var ex = Assert.Throws<ServiceInvocationException>(() => { prx.TestProperty = new object(); });
- Assert.AreEqual("Object of type 'System.Object' cannot be converted to type 'System.Int32'.",
- ex.InnerException.Message);
- }
-
- /// <summary>
- /// Tests service descriptors.
- /// </summary>
- [Test]
- public void TestServiceDescriptors()
- {
- Services.DeployKeyAffinitySingleton(SvcName, new TestIgniteServiceSerializable(), CacheName, 1);
-
- var descriptors = Services.GetServiceDescriptors();
-
- Assert.AreEqual(1, descriptors.Count);
-
- var desc = descriptors.Single();
-
- Assert.AreEqual(SvcName, desc.Name);
- Assert.AreEqual(CacheName, desc.CacheName);
- Assert.AreEqual(1, desc.AffinityKey);
- Assert.AreEqual(1, desc.MaxPerNodeCount);
- Assert.AreEqual(1, desc.TotalCount);
- Assert.AreEqual(typeof(TestIgniteServiceSerializable), desc.Type);
- Assert.AreEqual(Grid1.GetCluster().GetLocalNode().Id, desc.OriginNodeId);
-
- var top = desc.TopologySnapshot;
- var prx = Services.GetServiceProxy<ITestIgniteService>(SvcName);
-
- Assert.AreEqual(1, top.Count);
- Assert.AreEqual(prx.NodeId, top.Keys.Single());
- Assert.AreEqual(1, top.Values.Single());
- }
-
- /// <summary>
- /// Tests the client portable flag.
- /// </summary>
- [Test]
- public void TestWithKeepPortableClient()
- {
- var svc = new TestIgniteServicePortable();
-
- // Deploy to grid2
- Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id).GetServices().WithKeepPortable()
- .DeployNodeSingleton(SvcName, svc);
-
- // Get proxy
- var prx = Services.WithKeepPortable().GetServiceProxy<ITestIgniteService>(SvcName);
-
- var obj = new PortableObject {Val = 11};
-
- var res = (IPortableObject) prx.Method(obj);
- Assert.AreEqual(11, res.Deserialize<PortableObject>().Val);
-
- res = (IPortableObject) prx.Method(Grid1.GetPortables().ToPortable<IPortableObject>(obj));
- Assert.AreEqual(11, res.Deserialize<PortableObject>().Val);
- }
-
- /// <summary>
- /// Tests the server portable flag.
- /// </summary>
- [Test]
- public void TestWithKeepPortableServer()
- {
- var svc = new TestIgniteServicePortable();
-
- // Deploy to grid2
- Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id).GetServices().WithServerKeepPortable()
- .DeployNodeSingleton(SvcName, svc);
-
- // Get proxy
- var prx = Services.WithServerKeepPortable().GetServiceProxy<ITestIgniteService>(SvcName);
-
- var obj = new PortableObject { Val = 11 };
-
- var res = (PortableObject) prx.Method(obj);
- Assert.AreEqual(11, res.Val);
-
- res = (PortableObject)prx.Method(Grid1.GetPortables().ToPortable<IPortableObject>(obj));
- Assert.AreEqual(11, res.Val);
- }
-
- /// <summary>
- /// Tests server and client portable flag.
- /// </summary>
- [Test]
- public void TestWithKeepPortableBoth()
- {
- var svc = new TestIgniteServicePortable();
-
- // Deploy to grid2
- Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id).GetServices().WithKeepPortable().WithServerKeepPortable()
- .DeployNodeSingleton(SvcName, svc);
-
- // Get proxy
- var prx = Services.WithKeepPortable().WithServerKeepPortable().GetServiceProxy<ITestIgniteService>(SvcName);
-
- var obj = new PortableObject { Val = 11 };
-
- var res = (IPortableObject)prx.Method(obj);
- Assert.AreEqual(11, res.Deserialize<PortableObject>().Val);
-
- res = (IPortableObject)prx.Method(Grid1.GetPortables().ToPortable<IPortableObject>(obj));
- Assert.AreEqual(11, res.Deserialize<PortableObject>().Val);
- }
-
- /// <summary>
- /// Tests exception in Initialize.
- /// </summary>
- [Test]
- public void TestInitException()
- {
- var svc = new TestIgniteServiceSerializable { ThrowInit = true };
-
- var ex = Assert.Throws<IgniteException>(() => Services.DeployMultiple(SvcName, svc, Grids.Length, 1));
- Assert.AreEqual("Expected exception", ex.Message);
-
- var svc0 = Services.GetService<TestIgniteServiceSerializable>(SvcName);
-
- Assert.IsNull(svc0);
- }
-
- /// <summary>
- /// Tests exception in Execute.
- /// </summary>
- [Test]
- public void TestExecuteException()
- {
- var svc = new TestIgniteServiceSerializable { ThrowExecute = true };
-
- Services.DeployMultiple(SvcName, svc, Grids.Length, 1);
-
- var svc0 = Services.GetService<TestIgniteServiceSerializable>(SvcName);
-
- // Execution failed, but service exists.
- Assert.IsNotNull(svc0);
- Assert.IsFalse(svc0.Executed);
- }
-
- /// <summary>
- /// Tests exception in Cancel.
- /// </summary>
- [Test]
- public void TestCancelException()
- {
- var svc = new TestIgniteServiceSerializable { ThrowCancel = true };
-
- Services.DeployMultiple(SvcName, svc, Grids.Length, 1);
-
- CheckServiceStarted(Grid1);
-
- Services.CancelAll();
-
- // Cancellation failed, but service is removed.
- foreach (var grid in Grids)
- Assert.IsNull(grid.GetServices().GetService<ITestIgniteService>(SvcName));
- }
-
- [Test]
- public void TestMarshalExceptionOnRead()
- {
- var svc = new TestIgniteServicePortableErr();
-
- var ex = Assert.Throws<IgniteException>(() => Services.DeployMultiple(SvcName, svc, Grids.Length, 1));
- Assert.AreEqual("Expected exception", ex.Message);
-
- var svc0 = Services.GetService<TestIgniteServiceSerializable>(SvcName);
-
- Assert.IsNull(svc0);
- }
-
- [Test]
- public void TestMarshalExceptionOnWrite()
- {
- var svc = new TestIgniteServicePortableErr {ThrowOnWrite = true};
-
- var ex = Assert.Throws<Exception>(() => Services.DeployMultiple(SvcName, svc, Grids.Length, 1));
- Assert.AreEqual("Expected exception", ex.Message);
-
- var svc0 = Services.GetService<TestIgniteServiceSerializable>(SvcName);
-
- Assert.IsNull(svc0);
- }
-
- /// <summary>
- /// Starts the grids.
- /// </summary>
- private void StartGrids()
- {
- if (Grid1 != null)
- return;
-
- Grid1 = Ignition.Start(Configuration("config\\compute\\compute-grid1.xml"));
- Grid2 = Ignition.Start(Configuration("config\\compute\\compute-grid2.xml"));
- Grid3 = Ignition.Start(Configuration("config\\compute\\compute-grid3.xml"));
-
- Grids = new[] { Grid1, Grid2, Grid3 };
- }
-
- /// <summary>
- /// Stops the grids.
- /// </summary>
- private void StopGrids()
- {
- Grid1 = Grid2 = Grid3 = null;
- Grids = null;
-
- Ignition.StopAll(true);
- }
-
- /// <summary>
- /// Checks that service has started on specified grid.
- /// </summary>
- private static void CheckServiceStarted(IIgnite grid, int count = 1)
- {
- var services = grid.GetServices().GetServices<TestIgniteServiceSerializable>(SvcName);
-
- Assert.AreEqual(count, services.Count);
-
- var svc = services.First();
-
- Assert.IsNotNull(svc);
-
- Assert.IsTrue(svc.Initialized);
-
- Thread.Sleep(100); // Service runs in a separate thread, wait for it to execute.
-
- Assert.IsTrue(svc.Executed);
- Assert.IsFalse(svc.Cancelled);
-
- Assert.AreEqual(grid.GetCluster().GetLocalNode().Id, svc.NodeId);
- }
-
- /// <summary>
- /// Gets the Ignite configuration.
- /// </summary>
- private static IgniteConfiguration Configuration(string springConfigUrl)
- {
- return new IgniteConfiguration
- {
- SpringConfigUrl = springConfigUrl,
- JvmClasspath = TestUtils.CreateTestClasspath(),
- JvmOptions = TestUtils.TestJavaOptions(),
- PortableConfiguration = new PortableConfiguration
- {
- TypeConfigurations = new List<PortableTypeConfiguration>
- {
- new PortableTypeConfiguration(typeof(TestIgniteServicePortable)),
- new PortableTypeConfiguration(typeof(TestIgniteServicePortableErr)),
- new PortableTypeConfiguration(typeof(PortableObject))
- }
- }
- };
- }
-
- /// <summary>
- /// Gets the services.
- /// </summary>
- protected virtual IServices Services
- {
- get { return Grid1.GetServices(); }
- }
-
- /// <summary>
- /// Test service interface for proxying.
- /// </summary>
- private interface ITestIgniteService
- {
- int TestProperty { get; set; }
-
- /** */
- bool Initialized { get; }
-
- /** */
- bool Cancelled { get; }
-
- /** */
- bool Executed { get; }
-
- /** */
- Guid NodeId { get; }
-
- /** */
- string LastCallContextName { get; }
-
- /** */
- object Method(object arg);
-
- /** */
- object ErrMethod(object arg);
- }
-
- /// <summary>
- /// Test service interface for proxy usage.
- /// Has some of the original interface members with different signatures.
- /// </summary>
- private interface ITestIgniteServiceProxyInterface
- {
- /** */
- Guid NodeId { get; }
-
- /** */
- object TestProperty { get; set; }
-
- /** */
- int Method(int arg);
- }
-
- #pragma warning disable 649
-
- /// <summary>
- /// Test serializable service.
- /// </summary>
- [Serializable]
- private class TestIgniteServiceSerializable : IService, ITestIgniteService
- {
- /** */
- [InstanceResource]
- private IIgnite _grid;
-
- /** <inheritdoc /> */
- public int TestProperty { get; set; }
-
- /** <inheritdoc /> */
- public bool Initialized { get; private set; }
-
- /** <inheritdoc /> */
- public bool Cancelled { get; private set; }
-
- /** <inheritdoc /> */
- public bool Executed { get; private set; }
-
- /** <inheritdoc /> */
- public Guid NodeId
- {
- get { return _grid.GetCluster().GetLocalNode().Id; }
- }
-
- /** <inheritdoc /> */
- public string LastCallContextName { get; private set; }
-
- /** */
- public bool ThrowInit { get; set; }
-
- /** */
- public bool ThrowExecute { get; set; }
-
- /** */
- public bool ThrowCancel { get; set; }
-
- /** */
- public object Method(object arg)
- {
- return arg;
- }
-
- /** */
- public object ErrMethod(object arg)
- {
- throw new ArgumentNullException("arg", "ExpectedException");
- }
-
- /** <inheritdoc /> */
- public void Init(IServiceContext context)
- {
- if (ThrowInit)
- throw new Exception("Expected exception");
-
- CheckContext(context);
-
- Assert.IsFalse(context.IsCancelled);
- Initialized = true;
- }
-
- /** <inheritdoc /> */
- public void Execute(IServiceContext context)
- {
- if (ThrowExecute)
- throw new Exception("Expected exception");
-
- CheckContext(context);
-
- Assert.IsFalse(context.IsCancelled);
- Assert.IsTrue(Initialized);
- Assert.IsFalse(Cancelled);
-
- Executed = true;
- }
-
- /** <inheritdoc /> */
- public void Cancel(IServiceContext context)
- {
- if (ThrowCancel)
- throw new Exception("Expected exception");
-
- CheckContext(context);
-
- Assert.IsTrue(context.IsCancelled);
-
- Cancelled = true;
- }
-
- /// <summary>
- /// Checks the service context.
- /// </summary>
- private void CheckContext(IServiceContext context)
- {
- LastCallContextName = context.Name;
-
- if (context.AffinityKey != null && !(context.AffinityKey is int))
- {
- var portableObject = context.AffinityKey as IPortableObject;
-
- var key = portableObject != null
- ? portableObject.Deserialize<PortableObject>()
- : (PortableObject) context.AffinityKey;
-
- Assert.AreEqual(AffKey, key.Val);
- }
-
- Assert.IsNotNull(_grid);
-
- Assert.IsTrue(context.Name.StartsWith(SvcName));
- Assert.AreNotEqual(Guid.Empty, context.ExecutionId);
- }
- }
-
- /// <summary>
- /// Test portable service.
- /// </summary>
- private class TestIgniteServicePortable : TestIgniteServiceSerializable, IPortableMarshalAware
- {
- /** <inheritdoc /> */
- public void WritePortable(IPortableWriter writer)
- {
- writer.WriteInt("TestProp", TestProperty);
- }
-
- /** <inheritdoc /> */
- public void ReadPortable(IPortableReader reader)
- {
- TestProperty = reader.ReadInt("TestProp");
- }
- }
-
- /// <summary>
- /// Test portable service with exceptions in marshalling.
- /// </summary>
- private class TestIgniteServicePortableErr : TestIgniteServiceSerializable, IPortableMarshalAware
- {
- /** */
- public bool ThrowOnWrite { get; set; }
-
- /** <inheritdoc /> */
- public void WritePortable(IPortableWriter writer)
- {
- writer.WriteInt("TestProp", TestProperty);
-
- if (ThrowOnWrite)
- throw new Exception("Expected exception");
- }
-
- /** <inheritdoc /> */
- public void ReadPortable(IPortableReader reader)
- {
- TestProperty = reader.ReadInt("TestProp");
-
- throw new Exception("Expected exception");
- }
- }
-
- /// <summary>
- /// Test node filter.
- /// </summary>
- [Serializable]
- private class NodeFilter : IClusterNodeFilter
- {
- /// <summary>
- /// Gets or sets the node identifier.
- /// </summary>
- public Guid NodeId { get; set; }
-
- /** <inheritdoc /> */
- public bool Invoke(IClusterNode node)
- {
- return node.Id == NodeId;
- }
- }
-
- /// <summary>
- /// Portable object.
- /// </summary>
- private class PortableObject
- {
- public int Val { get; set; }
- }
- }
-}
[03/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Config/example-cache-query.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Config/example-cache-query.xml b/modules/platform/dotnet/Examples/Config/example-cache-query.xml
deleted file mode 100644
index c9ea7e1..0000000
--- a/modules/platform/dotnet/Examples/Config/example-cache-query.xml
+++ /dev/null
@@ -1,111 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
-
- <property name="platformConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
- <property name="portableConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
- <property name="types">
- <list>
- <value>Apache.Ignite.Examples.Dll.Portable.Account</value>
- <value>Apache.Ignite.Examples.Dll.Portable.Address</value>
- <value>Apache.Ignite.Examples.Dll.Portable.Employee</value>
- <value>Apache.Ignite.Examples.Dll.Portable.EmployeeKey</value>
- <value>Apache.Ignite.Examples.Dll.Portable.Organization</value>
- <value>Apache.Ignite.Examples.Dll.Portable.OrganizationType</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
-
- <!-- Cache configurations (all properties are optional). -->
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="atomicityMode" value="ATOMIC"/>
- <property name="backups" value="1"/>
-
- <!-- Configure type metadata to enable queries. -->
- <property name="typeMetadata">
- <list>
- <bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="keyType" value="java.lang.Integer"/>
- <property name="valueType" value="Organization"/>
- <property name="ascendingFields">
- <map>
- <entry key="name" value="java.lang.String"/>
- </map>
- </property>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="keyType" value="EmployeeKey"/>
- <property name="valueType" value="Employee"/>
- <property name="ascendingFields">
- <map>
- <entry key="organizationId" value="java.lang.Integer"/>
- <entry key="address.zip" value="java.lang.Integer"/>
- </map>
- </property>
- <property name="queryFields">
- <map>
- <entry key="name" value="java.lang.String"/>
- <entry key="salary" value="java.lang.Long"/>
- </map>
- </property>
- <property name="textFields">
- <list>
- <value>address.street</value>
- </list>
- </property>
- </bean>
- </list>
- </property>
- </bean>
- </list>
- </property>
-
- <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47501</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Config/example-cache-store.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Config/example-cache-store.xml b/modules/platform/dotnet/Examples/Config/example-cache-store.xml
deleted file mode 100644
index adc5f45..0000000
--- a/modules/platform/dotnet/Examples/Config/example-cache-store.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="writeThrough" value="true"/>
- <property name="readThrough" value="true"/>
- <property name="cacheStoreFactory">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
- <property name="assemblyName" value="Apache.Ignite.ExamplesDll"/>
- <property name="className" value="Apache.Ignite.ExamplesDll.Datagrid.EmployeeStore"/>
- </bean>
- </property>
- </bean>
- </list>
- </property>
-
- <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47501</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Config/example-cache.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Config/example-cache.xml b/modules/platform/dotnet/Examples/Config/example-cache.xml
deleted file mode 100644
index a262ce1..0000000
--- a/modules/platform/dotnet/Examples/Config/example-cache.xml
+++ /dev/null
@@ -1,83 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <!-- Set to true to enable distributed class loading for examples, default is false. -->
- <property name="peerClassLoadingEnabled" value="true"/>
-
- <property name="platformConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
- <property name="portableConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
- <property name="types">
- <list>
- <value>Apache.Ignite.Examples.Dll.Portable.Account</value>
- <value>Apache.Ignite.Examples.Dll.Portable.Address</value>
- <value>Apache.Ignite.Examples.Dll.Portable.Employee</value>
- <value>Apache.Ignite.Examples.Dll.Portable.EmployeeKey</value>
- <value>Apache.Ignite.Examples.Dll.Portable.Organization</value>
- <value>Apache.Ignite.Examples.Dll.Portable.OrganizationType</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
-
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="cache*"/>
- <property name="atomicityMode" value="ATOMIC"/>
- <property name="backups" value="1"/>
- </bean>
-
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="tx"/>
- <property name="atomicityMode" value="TRANSACTIONAL"/>
- <property name="backups" value="1"/>
- </bean>
- </list>
- </property>
-
- <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47501</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Config/example-compute.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Config/example-compute.xml b/modules/platform/dotnet/Examples/Config/example-compute.xml
deleted file mode 100644
index bbc6550..0000000
--- a/modules/platform/dotnet/Examples/Config/example-compute.xml
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47501</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
-
- <!-- Enable task execution events for examples. -->
- <property name="includeEventTypes">
- <list>
- <!-- Task execution events -->
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED"/>
-
- <!-- Job execution events -->
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_MAPPED"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_RESULTED"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_FAILED_OVER"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_STARTED"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_FINISHED"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_TIMEDOUT"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_REJECTED"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_FAILED"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_QUEUED"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_CANCELLED"/>
- </list>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/README.txt
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/README.txt b/modules/platform/dotnet/Examples/README.txt
deleted file mode 100644
index c49dc5a..0000000
--- a/modules/platform/dotnet/Examples/README.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-Apache Ignite .Net Examples
-==================================
-
-Common requirements
-----------------------------------
- * Apache Ignite .Net library must be built using instructions from %IGNITE_HOME%\platforms\dotnet\README.txt.
-
-
-Running examples
-----------------------------------
-
- * Open Visual Studio solution %IGNITE_HOME%\platforms\dotnet\examples\Apache.Ignite.Examples.sln
- * Build Apache.Ignite.ExamplesDll project.
- * Set desired example as startup object in Apache.Ignite.Examples project and run it.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.Examples.sln
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples.sln b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples.sln
new file mode 100644
index 0000000..c1337f3
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples.sln
@@ -0,0 +1,72 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.31101.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Core", "..\Apache.Ignite.Core\Apache.Ignite.Core.csproj", "{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "..\..\cpp\common\project\vs\common.vcxproj", "{4F7E4917-4612-4B96-9838-025711ADE391}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Examples", "Apache.Ignite.Examples\Apache.Ignite.Examples.csproj", "{069FA680-3C4D-43A9-B84F-E67513B87827}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.ExamplesDll", "Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj", "{DFB08363-202E-412D-8812-349EF10A8702}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{F1491682-C798-4C23-8239-16C5BC2C5A02}"
+ ProjectSection(SolutionItems) = preProject
+ Config\example-cache-query.xml = Config\example-cache-query.xml
+ Config\example-cache-store.xml = Config\example-cache-store.xml
+ Config\example-cache.xml = Config\example-cache.xml
+ Config\example-compute.xml = Config\example-compute.xml
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite", "..\Apache.Ignite\Apache.Ignite.csproj", "{27F7F3C6-BDDE-43A9-B565-856F8395A04B}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x64.ActiveCfg = Debug|x64
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x64.Build.0 = Debug|x64
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x86.ActiveCfg = Debug|x86
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x86.Build.0 = Debug|x86
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x64.ActiveCfg = Release|x64
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x64.Build.0 = Release|x64
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x86.ActiveCfg = Release|x86
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x86.Build.0 = Release|x86
+ {4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x64.ActiveCfg = Debug|x64
+ {4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x64.Build.0 = Debug|x64
+ {4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x86.ActiveCfg = Debug|Win32
+ {4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x86.Build.0 = Debug|Win32
+ {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x64.ActiveCfg = Release|x64
+ {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x64.Build.0 = Release|x64
+ {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x86.ActiveCfg = Release|Win32
+ {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x86.Build.0 = Release|Win32
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.ActiveCfg = Debug|x64
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.Build.0 = Debug|x64
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.ActiveCfg = Debug|x86
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.Build.0 = Debug|x86
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.ActiveCfg = Release|x64
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.Build.0 = Release|x64
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.ActiveCfg = Release|x86
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.Build.0 = Release|x86
+ {DFB08363-202E-412D-8812-349EF10A8702}.Debug|x64.ActiveCfg = Debug|x64
+ {DFB08363-202E-412D-8812-349EF10A8702}.Debug|x86.ActiveCfg = Debug|x86
+ {DFB08363-202E-412D-8812-349EF10A8702}.Release|x64.ActiveCfg = Release|x64
+ {DFB08363-202E-412D-8812-349EF10A8702}.Release|x86.ActiveCfg = Release|x86
+ {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x64.ActiveCfg = Debug|x64
+ {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x64.Build.0 = Debug|x64
+ {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x86.ActiveCfg = Debug|x86
+ {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x86.Build.0 = Debug|x86
+ {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x64.ActiveCfg = Release|x64
+ {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x64.Build.0 = Release|x64
+ {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x86.ActiveCfg = Release|x86
+ {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x86.Build.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.Examples.slnrel
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples.slnrel b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples.slnrel
new file mode 100644
index 0000000..d898abc
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples.slnrel
@@ -0,0 +1,38 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Examples", "Apache.Ignite.Examples\Apache.Ignite.Examples.csproj", "{069FA680-3C4D-43A9-B84F-E67513B87827}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.ExamplesDll", "Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj", "{DFB08363-202E-412D-8812-349EF10A8702}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{F1491682-C798-4C23-8239-16C5BC2C5A02}"
+ ProjectSection(SolutionItems) = preProject
+ Config\example-cache-query.xml = Config\example-cache-query.xml
+ Config\example-cache-store.xml = Config\example-cache-store.xml
+ Config\example-cache.xml = Config\example-cache.xml
+ Config\example-compute.xml = Config\example-compute.xml
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.ActiveCfg = Debug|x64
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.Build.0 = Debug|x64
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.ActiveCfg = Debug|x86
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.Build.0 = Debug|x86
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.ActiveCfg = Release|x64
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.Build.0 = Release|x64
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.ActiveCfg = Release|x86
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.Build.0 = Release|x86
+ {DFB08363-202E-412D-8812-349EF10A8702}.Debug|x64.ActiveCfg = Debug|x64
+ {DFB08363-202E-412D-8812-349EF10A8702}.Debug|x86.ActiveCfg = Debug|x86
+ {DFB08363-202E-412D-8812-349EF10A8702}.Release|x64.ActiveCfg = Release|x64
+ {DFB08363-202E-412D-8812-349EF10A8702}.Release|x86.ActiveCfg = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
new file mode 100644
index 0000000..8ee90d9
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{069FA680-3C4D-43A9-B84F-E67513B87827}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Apache.Ignite.Examples</RootNamespace>
+ <AssemblyName>Apache.Ignite.Examples</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Debug\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Release\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup>
+ <StartupObject>Apache.Ignite.Examples.Compute.TaskExample</StartupObject>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\x86\Debug\</OutputPath>
+ <PlatformTarget>x86</PlatformTarget>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+ <OutputPath>bin\x86\Release\</OutputPath>
+ <PlatformTarget>x86</PlatformTarget>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Compute\ClosureExample.cs" />
+ <Compile Include="Compute\TaskExample.cs" />
+ <Compile Include="Datagrid\ContinuousQueryExample.cs" />
+ <Compile Include="Datagrid\CrossPlatformExample.cs" />
+ <Compile Include="Datagrid\DataStreamerExample.cs" />
+ <Compile Include="Datagrid\PutGetExample.cs" />
+ <Compile Include="Datagrid\QueryExample.cs" />
+ <Compile Include="Datagrid\StoreExample.cs" />
+ <Compile Include="Datagrid\TransactionExample.cs" />
+ <Compile Include="Events\EventsExample.cs" />
+ <Compile Include="Messaging\MessagingExample.cs" />
+ <Compile Include="Misc\LifecycleExample.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Services\IMapService.cs" />
+ <Compile Include="Services\ServicesExample.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\Apache.Ignite.Core\Apache.Ignite.Core.csproj">
+ <Project>{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}</Project>
+ <Name>Apache.Ignite.Core</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj">
+ <Project>{dfb08363-202e-412d-8812-349ef10a8702}</Project>
+ <Name>Apache.Ignite.ExamplesDll</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ </ItemGroup>
+ <ItemGroup />
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Apache.Ignite.Examples.csprojrel
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Apache.Ignite.Examples.csprojrel b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Apache.Ignite.Examples.csprojrel
new file mode 100644
index 0000000..ff13ddc
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Apache.Ignite.Examples.csprojrel
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{069FA680-3C4D-43A9-B84F-E67513B87827}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Apache.Ignite.Examples</RootNamespace>
+ <AssemblyName>Apache.Ignite.Examples</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Debug\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Release\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup>
+ <StartupObject>Apache.Ignite.Examples.Compute.TaskExample</StartupObject>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\x86\Debug\</OutputPath>
+ <PlatformTarget>x86</PlatformTarget>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+ <OutputPath>bin\x86\Release\</OutputPath>
+ <PlatformTarget>x86</PlatformTarget>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Apache.Ignite.Core">
+ <HintPath>..\..\Apache.Ignite\bin\$(Platform)\$(Configuration)\Apache.Ignite.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Compute\ClosureExample.cs" />
+ <Compile Include="Compute\TaskExample.cs" />
+ <Compile Include="Datagrid\ContinuousQueryExample.cs" />
+ <Compile Include="Datagrid\CrossPlatformExample.cs" />
+ <Compile Include="Datagrid\DataStreamerExample.cs" />
+ <Compile Include="Datagrid\PutGetExample.cs" />
+ <Compile Include="Datagrid\QueryExample.cs" />
+ <Compile Include="Datagrid\StoreExample.cs" />
+ <Compile Include="Datagrid\TransactionExample.cs" />
+ <Compile Include="Events\EventsExample.cs" />
+ <Compile Include="Messaging\MessagingExample.cs" />
+ <Compile Include="Misc\LifecycleExample.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Services\IMapService.cs" />
+ <Compile Include="Services\ServicesExample.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj">
+ <Project>{dfb08363-202e-412d-8812-349ef10a8702}</Project>
+ <Name>Apache.Ignite.ExamplesDll</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ </ItemGroup>
+ <ItemGroup />
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/App.config
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/App.config b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/App.config
new file mode 100644
index 0000000..8e69aeb
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/App.config
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8" ?>
+
+<!--
+ 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.
+-->
+
+<configuration>
+ <runtime>
+ <gcServer enabled="true" />
+ </runtime>
+</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Compute/ClosureExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Compute/ClosureExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Compute/ClosureExample.cs
new file mode 100644
index 0000000..7d0128d
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Compute/ClosureExample.cs
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Apache.Ignite.Core;
+using Apache.Ignite.ExamplesDll.Compute;
+
+namespace Apache.Ignite.Examples.Compute
+{
+ /// <summary>
+ /// Example demonstrating closure execution.
+ /// <para />
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+ /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start example (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run with standalone Apache Ignite .Net node:
+ /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+ /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-compute.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// 2) Start example.
+ /// </summary>
+ public class ClosureExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Closure execution example started.");
+
+ // Split the string by spaces to count letters in each word in parallel.
+ ICollection<string> words = "Count characters using closure".Split().ToList();
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Calculating character count with manual reducing:");
+
+ var res = ignite.GetCompute().Apply(new CharacterCountClosure(), words);
+
+ int totalLen = res.Sum();
+
+ Console.WriteLine(">>> Total character count: " + totalLen);
+ Console.WriteLine();
+ Console.WriteLine(">>> Calculating character count with reducer:");
+
+ totalLen = ignite.GetCompute().Apply(new CharacterCountClosure(), words, new CharacterCountReducer());
+
+ Console.WriteLine(">>> Total character count: " + totalLen);
+ Console.WriteLine();
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Compute/TaskExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Compute/TaskExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Compute/TaskExample.cs
new file mode 100644
index 0000000..47fee9e
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Compute/TaskExample.cs
@@ -0,0 +1,140 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.ExamplesDll.Compute;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Compute
+{
+ /// <summary>
+ /// Example demonstrating task execution.
+ /// <para />
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+ /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start example (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run with standalone Apache Ignite .Net node:
+ /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+ /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-compute.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// 2) Start example.
+ /// </summary>
+ public class TaskExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Task execution example started.");
+
+ // Generate employees to calculate average salary for.
+ ICollection<Employee> employees = Employees();
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Calculating average salary for employees:");
+
+ foreach (Employee employee in employees)
+ Console.WriteLine(">>> " + employee);
+
+ // Execute task and get average salary.
+ var avgSalary = ignite.GetCompute().Execute(new AverageSalaryTask(), employees);
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Average salary for all employees: " + avgSalary);
+ Console.WriteLine();
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+
+ /// <summary>
+ /// Generates collection of employees for example.
+ /// </summary>
+ /// <returns>Collection of employees.</returns>
+ private static ICollection<Employee> Employees()
+ {
+ return new []
+ {
+ new Employee(
+ "James Wilson",
+ 12500,
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ new List<string> {"Human Resources", "Customer Service"}
+ ),
+ new Employee(
+ "Daniel Adams",
+ 11000,
+ new Address("184 Fidler Drive, San Antonio, TX", 78205),
+ new List<string> {"Development", "QA"}
+ ),
+ new Employee(
+ "Cristian Moss",
+ 12500,
+ new Address("667 Jerry Dove Drive, Florence, SC", 29501),
+ new List<string> {"Logistics"}
+ ),
+ new Employee(
+ "Allison Mathis",
+ 25300,
+ new Address("2702 Freedom Lane, Hornitos, CA", 95325),
+ new List<string> {"Development"}
+ ),
+ new Employee(
+ "Breana Robbin",
+ 6500,
+ new Address("3960 Sundown Lane, Austin, TX", 78758),
+ new List<string> {"Sales"}
+ ),
+ new Employee(
+ "Philip Horsley",
+ 19800,
+ new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
+ new List<string> {"Sales"}
+ ),
+ new Employee(
+ "Brian Peters",
+ 10600,
+ new Address("1407 Pearlman Avenue, Boston, MA", 02110),
+ new List<string> {"Development", "QA"}
+ ),
+ new Employee(
+ "Jack Yang",
+ 12900,
+ new Address("4425 Parrish Avenue Smithsons Valley, TX", 78130),
+ new List<string> {"Sales"}
+ )
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
new file mode 100644
index 0000000..c61b45d
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Cache.Event;
+using Apache.Ignite.Core.Cache.Query.Continuous;
+using Apache.Ignite.ExamplesDll.Datagrid;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+ /// <summary>
+ /// This example demonstrates continuous query API.
+ /// <para />
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+ /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start example (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run with standalone Apache Ignite .Net node:
+ /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+ /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// 2) Start example.
+ /// </summary>
+ public class ContinuousQueryExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
+ JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Cache continuous query example started.");
+
+ var cache = ignite.GetOrCreateCache<int, string>("cache_continuous_query");
+
+ // Clean up caches on all nodes before run.
+ cache.Clear();
+
+ const int keyCnt = 20;
+
+ for (int i = 0; i < keyCnt; i++)
+ cache.Put(i, i.ToString());
+
+ var qry = new ContinuousQuery<int, string>(new Listener<string>(), new ContinuousQueryFilter(15));
+
+
+ // Create new continuous query.
+ using (cache.QueryContinuous(qry))
+ {
+ // Add a few more keys and watch more query notifications.
+ for (var i = keyCnt; i < keyCnt + 5; i++)
+ cache.Put(i, i.ToString());
+
+ // Wait for a while while callback is notified about remaining puts.
+ Thread.Sleep(2000);
+ }
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+
+ /// <summary>
+ /// Callback for continuous query example.
+ /// </summary>
+ private class Listener<T> : ICacheEntryEventListener<int, T>
+ {
+ public void OnEvent(IEnumerable<ICacheEntryEvent<int, T>> events)
+ {
+ foreach (var e in events)
+ Console.WriteLine("Queried entry [key=" + e.Key + ", val=" + e.Value + ']');
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
new file mode 100644
index 0000000..e23d615
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
@@ -0,0 +1,208 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Portable;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+ /// <summary>
+ /// This example demonstrates use of portable objects between different platforms.
+ /// <para/>
+ /// This example must be run with standalone Java node. To achieve this start a node from %IGNITE_HOME%
+ /// using "ignite.bat" with proper configuration:
+ /// <example>'bin\ignite.bat examples\config\example-server.xml'</example>.
+ /// <para />
+ /// Once remote node is started, launch this example as follows:
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build);
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start application (F5 or Ctrl+F5).
+ /// <para />
+ /// To see how objects can be transferred between platforms, start cross-platform Java example
+ /// without restarting remote node.
+ /// </summary>
+ public class CrossPlatformExample
+ {
+ /// <summary>Key for Java object.</summary>
+ private const int KeyJava = 100;
+
+ /// <summary>Key for .Net object.</summary>
+ private const int KeyDotnet = 200;
+
+ /// <summary>Key for C++ object.</summary>
+ private const int KeyCpp = 300;
+
+ /// <summary>Cache Name.</summary>
+ private const string CacheName = "cacheCrossPlatform";
+
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Cross-platform example started.");
+
+ if (ignite.GetCluster().ForRemotes().GetNodes().Count == 0)
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> This example requires remote nodes to be started.");
+ Console.WriteLine(">>> Please start at least 1 remote node.");
+ Console.WriteLine(">>> Refer to example's documentation for details on configuration.");
+ Console.WriteLine();
+ }
+ else
+ {
+ var cache = ignite.GetOrCreateCache<int, Organization>(CacheName);
+
+ // Create new Organization object to store in cache.
+ Organization org = new Organization(
+ "Apache",
+ new Address("1065 East Hillsdale Blvd, Foster City, CA", 94404),
+ OrganizationType.Private,
+ DateTime.Now
+ );
+
+ // Put created data entry to cache.
+ cache.Put(KeyDotnet, org);
+
+ // Retrieve value stored by Java client.
+ GetFromJava(ignite);
+
+ // Retrieve value stored by C++ client.
+ GetFromCpp(ignite);
+
+ // Gets portable value from cache in portable format, without de-serializing it.
+ GetDotNetPortableInstance(ignite);
+
+ // Gets portable value form cache as a strongly-typed fully de-serialized instance.
+ GetDotNetTypedInstance(ignite);
+
+ Console.WriteLine();
+ }
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+
+ /// <summary>
+ /// Gets entry put by Java client. In order for entry to be in cache, Java client example
+ /// must be run before this example.
+ /// </summary>
+ /// <param name="Ignite">Ignite instance.</param>
+ private static void GetFromJava(IIgnite ignite)
+ {
+ var cache = ignite.GetOrCreateCache<int, IPortableObject>(CacheName)
+ .WithKeepPortable<int, IPortableObject>().WithAsync();
+
+ cache.Get(KeyJava);
+
+ var orgPortable = cache.GetFuture<IPortableObject>().ToTask().Result;
+
+ if (orgPortable == null)
+ {
+ Console.WriteLine(">>> Java client hasn't put entry to cache. Run Java example before this example " +
+ "to see the output.");
+ }
+ else
+ {
+ Console.WriteLine(">>> Entry from Java client:");
+ Console.WriteLine(">>> Portable: " + orgPortable);
+ Console.WriteLine(">>> Deserialized: " + orgPortable.Deserialize<Organization>());
+ }
+ }
+
+ /// <summary>
+ /// Gets entry put by C++ client. In order for entry to be in cache, C++ client example
+ /// must be run before this example.
+ /// </summary>
+ /// <param name="ignite">Ignite instance.</param>
+ private static void GetFromCpp(IIgnite ignite)
+ {
+ var cache = ignite.GetOrCreateCache<int, IPortableObject>(CacheName)
+ .WithKeepPortable<int, IPortableObject>().WithAsync();
+
+ cache.Get(KeyCpp);
+
+ var orgPortable = cache.GetFuture<IPortableObject>().Get();
+
+ Console.WriteLine();
+
+ if (orgPortable == null)
+ {
+ Console.WriteLine(">>> CPP client hasn't put entry to cache. Run CPP example before this example " +
+ "to see the output.");
+ }
+ else
+ {
+ Console.WriteLine(">>> Entry from CPP client:");
+ Console.WriteLine(">>> Portable: " + orgPortable);
+ Console.WriteLine(">>> Deserialized: " + orgPortable.Deserialize<Organization>());
+ }
+ }
+
+ /// <summary>
+ /// Gets portable value from cache in portable format, without de-serializing it.
+ /// </summary>
+ /// <param name="ignite">Ignite instance.</param>
+ private static void GetDotNetPortableInstance(IIgnite ignite)
+ {
+ // Apply "KeepPortable" flag on data projection.
+ var cache = ignite.GetOrCreateCache<int, IPortableObject>(CacheName)
+ .WithKeepPortable<int, IPortableObject>();
+
+ var org = cache.Get(KeyDotnet);
+
+ string name = org.GetField<string>("name");
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Retrieved organization name from portable field: " + name);
+ }
+
+ /// <summary>
+ /// Gets portable value form cache as a strongly-typed fully de-serialized instance.
+ /// </summary>
+ /// <param name="ignite">Ignite instance.</param>
+ private static void GetDotNetTypedInstance(IIgnite ignite)
+ {
+ var cache = ignite.GetOrCreateCache<int, Organization>(CacheName);
+
+ // Get recently created employee as a strongly-typed fully de-serialized instance.
+ Organization emp = cache.Get(KeyDotnet);
+
+ string name = emp.Name;
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Retrieved organization name from deserialized Organization instance: " + name);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
new file mode 100644
index 0000000..ee9e200
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
@@ -0,0 +1,101 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Datastream;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+ /// <summary>
+ /// Demonstrates how cache can be populated with data utilizing <see cref="IDataStreamer{TK,TV}"/>.
+ /// Data streamer is a lot more efficient to use than standard cache put operation
+ /// as it properly buffers cache requests together and properly manages load on remote nodes.
+ /// <para />
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+ /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start example (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run with standalone Apache Ignite .Net node:
+ /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+ /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// 2) Start example.
+ /// </summary>
+ public class DataStreamerExample
+ {
+ /// <summary>Number of entries to load.</summary>
+ private const int EntryCount = 500000;
+
+ /// <summary>Cache name.</summary>
+ private const string CacheName = "cache_data_streamer";
+
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
+ JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Cache data streamer example started.");
+
+ // Clean up caches on all nodes before run.
+ ignite.GetOrCreateCache<int, Account>(CacheName).Clear();
+
+ Stopwatch timer = new Stopwatch();
+
+ timer.Start();
+
+ using (var ldr = ignite.GetDataStreamer<int, Account>(CacheName))
+ {
+ ldr.PerNodeBufferSize = 1024;
+
+ for (int i = 0; i < EntryCount; i++)
+ {
+ ldr.AddData(i, new Account(i, i));
+
+ // Print out progress while loading cache.
+ if (i > 0 && i % 10000 == 0)
+ Console.WriteLine("Loaded " + i + " accounts.");
+ }
+ }
+
+ timer.Stop();
+
+ long dur = timer.ElapsedMilliseconds;
+
+ Console.WriteLine(">>> Loaded " + EntryCount + " accounts in " + dur + "ms.");
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/PutGetExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
new file mode 100644
index 0000000..c1146f1
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
@@ -0,0 +1,219 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Portable;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+ /// <summary>
+ /// This example demonstrates several put-get operations on Ignite cache
+ /// with portable values. Note that portable object can be retrieved in
+ /// fully-deserialized form or in portable object format using special
+ /// cache projection.
+ /// <para />
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+ /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start example (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run with standalone Apache Ignite .Net node:
+ /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+ /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// 2) Start example.
+ /// </summary>
+ public class PutGetExample
+ {
+ /// <summary>Cache name.</summary>
+ private const string CacheName = "cache_put_get";
+
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Cache put-get example started.");
+
+ // Clean up caches on all nodes before run.
+ ignite.GetOrCreateCache<object, object>(CacheName).Clear();
+
+ PutGet(ignite);
+ PutGetPortable(ignite);
+ PutAllGetAll(ignite);
+ PutAllGetAllPortable(ignite);
+
+ Console.WriteLine();
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+
+ /// <summary>
+ /// Execute individual Put and Get.
+ /// </summary>
+ /// <param name="ignite">Ignite instance.</param>
+ private static void PutGet(IIgnite ignite)
+ {
+ var cache = ignite.GetCache<int, Organization>(CacheName);
+
+ // Create new Organization to store in cache.
+ Organization org = new Organization(
+ "Microsoft",
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ OrganizationType.Private,
+ DateTime.Now
+ );
+
+ // Put created data entry to cache.
+ cache.Put(1, org);
+
+ // Get recently created employee as a strongly-typed fully de-serialized instance.
+ Organization orgFromCache = cache.Get(1);
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Retrieved organization instance from cache: " + orgFromCache);
+ }
+
+ /// <summary>
+ /// Execute individual Put and Get, getting value in portable format, without de-serializing it.
+ /// </summary>
+ /// <param name="ignite">Ignite instance.</param>
+ private static void PutGetPortable(IIgnite ignite)
+ {
+ var cache = ignite.GetCache<int, Organization>(CacheName);
+
+ // Create new Organization to store in cache.
+ Organization org = new Organization(
+ "Microsoft",
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ OrganizationType.Private,
+ DateTime.Now
+ );
+
+ // Put created data entry to cache.
+ cache.Put(1, org);
+
+ // Create projection that will get values as portable objects.
+ var portableCache = cache.WithKeepPortable<int, IPortableObject>();
+
+ // Get recently created organization as a portable object.
+ var portableOrg = portableCache.Get(1);
+
+ // Get organization's name from portable object (note that object doesn't need to be fully deserialized).
+ string name = portableOrg.GetField<string>("name");
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Retrieved organization name from portable object: " + name);
+ }
+
+ /// <summary>
+ /// Execute bulk Put and Get operations.
+ /// </summary>
+ /// <param name="ignite">Ignite instance.</param>
+ private static void PutAllGetAll(IIgnite ignite)
+ {
+ var cache = ignite.GetCache<int, Organization>(CacheName);
+
+ // Create new Organizations to store in cache.
+ Organization org1 = new Organization(
+ "Microsoft",
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ OrganizationType.Private,
+ DateTime.Now
+ );
+
+ Organization org2 = new Organization(
+ "Red Cross",
+ new Address("184 Fidler Drive, San Antonio, TX", 78205),
+ OrganizationType.NonProfit,
+ DateTime.Now
+ );
+
+ var map = new Dictionary<int, Organization> { { 1, org1 }, { 2, org2 } };
+
+ // Put created data entries to cache.
+ cache.PutAll(map);
+
+ // Get recently created organizations as a strongly-typed fully de-serialized instances.
+ IDictionary<int, Organization> mapFromCache = cache.GetAll(new List<int> { 1, 2 });
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Retrieved organization instances from cache:");
+
+ foreach (Organization org in mapFromCache.Values)
+ Console.WriteLine(">>> " + org);
+ }
+
+ /// <summary>
+ /// Execute bulk Put and Get operations getting values in portable format, without de-serializing it.
+ /// </summary>
+ /// <param name="ignite">Ignite instance.</param>
+ private static void PutAllGetAllPortable(IIgnite ignite)
+ {
+ var cache = ignite.GetCache<int, Organization>(CacheName);
+
+ // Create new Organizations to store in cache.
+ Organization org1 = new Organization(
+ "Microsoft",
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ OrganizationType.Private,
+ DateTime.Now
+ );
+
+ Organization org2 = new Organization(
+ "Red Cross",
+ new Address("184 Fidler Drive, San Antonio, TX", 78205),
+ OrganizationType.NonProfit,
+ DateTime.Now
+ );
+
+ var map = new Dictionary<int, Organization> { { 1, org1 }, { 2, org2 } };
+
+ // Put created data entries to cache.
+ cache.PutAll(map);
+
+ // Create projection that will get values as portable objects.
+ var portableCache = cache.WithKeepPortable<int, IPortableObject>();
+
+ // Get recently created organizations as portable objects.
+ IDictionary<int, IPortableObject> portableMap =
+ portableCache.GetAll(new List<int> { 1, 2 });
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Retrieved organization names from portable objects:");
+
+ foreach (IPortableObject poratbleOrg in portableMap.Values)
+ Console.WriteLine(">>> " + poratbleOrg.GetField<string>("name"));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/QueryExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/QueryExample.cs b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/QueryExample.cs
new file mode 100644
index 0000000..523b83f
--- /dev/null
+++ b/modules/platform/dotnet/Examples2/Apache.Ignite.Examples/Datagrid/QueryExample.cs
@@ -0,0 +1,226 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Cache;
+using Apache.Ignite.Core.Cache.Query;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+ /// <summary>
+ /// This example populates cache with sample data and runs several SQL and
+ /// full text queries over this data.
+ /// <para />
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+ /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start example (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run with standalone Apache Ignite .Net node:
+ /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+ /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache-query.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// 2) Start example.
+ /// </summary>
+ public class QueryExample
+ {
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache-query.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Cache query example started.");
+
+ var cache = ignite.GetCache<object, object>(null);
+
+ // Clean up caches on all nodes before run.
+ cache.Clear();
+
+ // Populate cache with sample data entries.
+ PopulateCache(cache);
+
+ // Create cache that will work with specific types.
+ var employeeCache = ignite.GetCache<EmployeeKey, Employee>(null);
+
+ // Run SQL query example.
+ SqlQueryExample(employeeCache);
+
+ // Run SQL query with join example.
+ SqlJoinQueryExample(employeeCache);
+
+ // Run SQL fields query example.
+ SqlFieldsQueryExample(employeeCache);
+
+ // Run full text query example.
+ FullTextQueryExample(employeeCache);
+
+ Console.WriteLine();
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+
+ /// <summary>
+ /// Queries employees that have provided ZIP code in address.
+ /// </summary>
+ /// <param name="cache">Cache.</param>
+ private static void SqlQueryExample(ICache<EmployeeKey, Employee> cache)
+ {
+ const int zip = 94109;
+
+ var qry = cache.Query(new SqlQuery(typeof(Employee), "zip = ?", zip));
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Employees with zipcode " + zip + ":");
+
+ foreach (var entry in qry)
+ Console.WriteLine(">>> " + entry.Value);
+ }
+
+ /// <summary>
+ /// Queries employees that work for organization with provided name.
+ /// </summary>
+ /// <param name="cache">Cache.</param>
+ private static void SqlJoinQueryExample(ICache<EmployeeKey, Employee> cache)
+ {
+ const string orgName = "Apache";
+
+ var qry = cache.Query(new SqlQuery("Employee",
+ "from Employee, Organization " +
+ "where Employee.organizationId = Organization._key and Organization.name = ?", orgName));
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Employees working for " + orgName + ":");
+
+ foreach (var entry in qry)
+ Console.WriteLine(">>> " + entry.Value);
+ }
+
+ /// <summary>
+ /// Queries names and salaries for all employees.
+ /// </summary>
+ /// <param name="cache">Cache.</param>
+ private static void SqlFieldsQueryExample(ICache<EmployeeKey, Employee> cache)
+ {
+ var qry = cache.QueryFields(new SqlFieldsQuery("select name, salary from Employee"));
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Employee names and their salaries:");
+
+ foreach (IList row in qry)
+ Console.WriteLine(">>> [Name=" + row[0] + ", salary=" + row[1] + ']');
+ }
+
+ /// <summary>
+ /// Queries employees that live in Texas using full-text query API.
+ /// </summary>
+ /// <param name="cache">Cache.</param>
+ private static void FullTextQueryExample(ICache<EmployeeKey, Employee> cache)
+ {
+ var qry = cache.Query(new TextQuery("Employee", "TX"));
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Employees living in Texas:");
+
+ foreach (var entry in qry)
+ Console.WriteLine(">>> " + entry.Value);
+ }
+
+ /// <summary>
+ /// Populate cache with data for this example.
+ /// </summary>
+ /// <param name="cache">Cache.</param>
+ private static void PopulateCache(ICache<object, object> cache)
+ {
+ cache.Put(1, new Organization(
+ "Apache",
+ new Address("1065 East Hillsdale Blvd, Foster City, CA", 94404),
+ OrganizationType.Private,
+ DateTime.Now
+ ));
+
+ cache.Put(2, new Organization(
+ "Microsoft",
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ OrganizationType.Private,
+ DateTime.Now
+ ));
+
+ cache.Put(new EmployeeKey(1, 1), new Employee(
+ "James Wilson",
+ 12500,
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ new List<string> { "Human Resources", "Customer Service" }
+ ));
+
+ cache.Put(new EmployeeKey(2, 1), new Employee(
+ "Daniel Adams",
+ 11000,
+ new Address("184 Fidler Drive, San Antonio, TX", 78130),
+ new List<string> { "Development", "QA" }
+ ));
+
+ cache.Put(new EmployeeKey(3, 1), new Employee(
+ "Cristian Moss",
+ 12500,
+ new Address("667 Jerry Dove Drive, Florence, SC", 29501),
+ new List<string> { "Logistics" }
+ ));
+
+ cache.Put(new EmployeeKey(4, 2), new Employee(
+ "Allison Mathis",
+ 25300,
+ new Address("2702 Freedom Lane, San Francisco, CA", 94109),
+ new List<string> { "Development" }
+ ));
+
+ cache.Put(new EmployeeKey(5, 2), new Employee(
+ "Breana Robbin",
+ 6500,
+ new Address("3960 Sundown Lane, Austin, TX", 78130),
+ new List<string> { "Sales" }
+ ));
+
+ cache.Put(new EmployeeKey(6, 2), new Employee(
+ "Philip Horsley",
+ 19800,
+ new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
+ new List<string> { "Sales" }
+ ));
+
+ cache.Put(new EmployeeKey(7, 2), new Employee(
+ "Brian Peters",
+ 10600,
+ new Address("1407 Pearlman Avenue, Boston, MA", 12110),
+ new List<string> { "Development", "QA" }
+ ));
+ }
+ }
+}
[20/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
deleted file mode 100644
index 12c9992..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Compute
-{
- using System;
- using System.Collections.Generic;
- using System.Threading;
- using Apache.Ignite.Core.Portable;
- using Apache.Ignite.Core.Tests.Process;
- using NUnit.Framework;
-
- /// <summary>
- /// Base class for all task-related tests.
- /// </summary>
- public abstract class AbstractTaskTest
- {
- /** */
- protected const string Grid1Name = "grid1";
-
- /** */
- protected const string Grid2Name = "grid2";
-
- /** */
- protected const string Grid3Name = "grid3";
-
- /** */
- protected const string Cache1Name = "cache1";
-
- /** Whether this is a test with forked JVMs. */
- private readonly bool _fork;
-
- /** First node. */
- [NonSerialized]
- protected IIgnite Grid1;
-
- /** Second node. */
- [NonSerialized]
- private IIgnite _grid2;
-
- /** Third node. */
- [NonSerialized]
- private IIgnite _grid3;
-
- /** Second process. */
- [NonSerialized]
- private IgniteProcess _proc2;
-
- /** Third process. */
- [NonSerialized]
- private IgniteProcess _proc3;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="fork">Fork flag.</param>
- protected AbstractTaskTest(bool fork)
- {
- _fork = fork;
- }
-
- /// <summary>
- /// Initialization routine.
- /// </summary>
- [TestFixtureSetUp]
- public void InitClient()
- {
- TestUtils.KillProcesses();
-
- if (_fork)
- {
- Grid1 = Ignition.Start(Configuration("config\\compute\\compute-standalone.xml"));
-
- _proc2 = Fork("config\\compute\\compute-standalone.xml");
-
- while (true)
- {
- if (!_proc2.Alive)
- throw new Exception("Process 2 died unexpectedly: " + _proc2.Join());
-
- if (Grid1.GetCluster().GetNodes().Count < 2)
- Thread.Sleep(100);
- else
- break;
- }
-
- _proc3 = Fork("config\\compute\\compute-standalone.xml");
-
- while (true)
- {
- if (!_proc3.Alive)
- throw new Exception("Process 3 died unexpectedly: " + _proc3.Join());
-
- if (Grid1.GetCluster().GetNodes().Count < 3)
- Thread.Sleep(100);
- else
- break;
- }
- }
- else
- {
- Grid1 = Ignition.Start(Configuration("config\\compute\\compute-grid1.xml"));
- _grid2 = Ignition.Start(Configuration("config\\compute\\compute-grid2.xml"));
- _grid3 = Ignition.Start(Configuration("config\\compute\\compute-grid3.xml"));
- }
- }
-
- [SetUp]
- public void BeforeTest()
- {
- Console.WriteLine("Test started: " + TestContext.CurrentContext.Test.Name);
- }
-
- [TestFixtureTearDown]
- public void StopClient()
- {
- if (Grid1 != null)
- Ignition.Stop(Grid1.Name, true);
-
- if (_fork)
- {
- if (_proc2 != null) {
- _proc2.Kill();
-
- _proc2.Join();
- }
-
- if (_proc3 != null)
- {
- _proc3.Kill();
-
- _proc3.Join();
- }
- }
- else
- {
- if (_grid2 != null)
- Ignition.Stop(_grid2.Name, true);
-
- if (_grid3 != null)
- Ignition.Stop(_grid3.Name, true);
- }
- }
-
- /// <summary>
- /// Configuration for node.
- /// </summary>
- /// <param name="path">Path to Java XML configuration.</param>
- /// <returns>Node configuration.</returns>
- protected IgniteConfiguration Configuration(string path)
- {
- IgniteConfiguration cfg = new IgniteConfiguration();
-
- if (!_fork)
- {
- PortableConfiguration portCfg = new PortableConfiguration();
-
- ICollection<PortableTypeConfiguration> portTypeCfgs = new List<PortableTypeConfiguration>();
-
- PortableTypeConfigurations(portTypeCfgs);
-
- portCfg.TypeConfigurations = portTypeCfgs;
-
- cfg.PortableConfiguration = portCfg;
- }
-
- cfg.JvmClasspath = TestUtils.CreateTestClasspath();
-
- cfg.JvmOptions = TestUtils.TestJavaOptions();
-
- cfg.SpringConfigUrl = path;
-
- return cfg;
- }
-
- /// <summary>
- /// Create forked process with the following Spring config.
- /// </summary>
- /// <param name="path">Path to Java XML configuration.</param>
- /// <returns>Forked process.</returns>
- private static IgniteProcess Fork(string path)
- {
- return new IgniteProcess(
- "-springConfigUrl=" + path,
- "-J-ea",
- "-J-Xcheck:jni",
- "-J-Xms512m",
- "-J-Xmx512m",
- "-J-DIGNITE_QUIET=false"
- //"-J-Xnoagent", "-J-Djava.compiler=NONE", "-J-Xdebug", "-J-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5006"
- );
- }
-
- /// <summary>
- /// Define portable types.
- /// </summary>
- /// <param name="portTypeCfgs">Portable type configurations.</param>
- protected virtual void PortableTypeConfigurations(ICollection<PortableTypeConfiguration> portTypeCfgs)
- {
- // No-op.
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/ClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/ClosureTaskTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/ClosureTaskTest.cs
deleted file mode 100644
index 8664413..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/ClosureTaskTest.cs
+++ /dev/null
@@ -1,390 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Compute
-{
- using System;
- using System.Collections.Generic;
- using Apache.Ignite.Core.Compute;
- using NUnit.Framework;
-
- /// <summary>
- /// Tests for distributed closure executions.
- /// </summary>
- public abstract class ClosureTaskTest : AbstractTaskTest
- {
- /** Amount of multiple clousres. */
- private const int MultiCloCnt = 5;
-
- /** */
- protected const string ErrMsg = "An error has occurred.";
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="fork">Fork mode.</param>
- protected ClosureTaskTest(bool fork) : base(fork) { }
-
- /// <summary>
- /// Test for single closure returning result.
- /// </summary>
- [Test]
- public void TestExecuteSingle()
- {
- var res = Grid1.GetCompute().Call(OutFunc(false));
-
- CheckResult(res);
- }
-
- /// <summary>
- /// Test for single closure returning exception.
- /// </summary>
- [Test]
- public void TestExecuteSingleException()
- {
- try
- {
- Grid1.GetCompute().Call(OutFunc(true));
-
- Assert.Fail();
- }
- catch (Exception e)
- {
- CheckError(e);
- }
- }
-
- /// <summary>
- /// Test for multiple closures execution.
- /// </summary>
- [Test]
- public void TestExecuteMultiple()
- {
- var clos = new List<IComputeFunc<object>>(MultiCloCnt);
-
- for (int i = 0; i < MultiCloCnt; i++)
- clos.Add(OutFunc(false));
-
- ICollection<object> ress = Grid1.GetCompute().Call(clos);
-
- foreach (object res in ress)
- CheckResult(res);
- }
-
- /// <summary>
- /// Test for multiple closures execution.
- /// </summary>
- [Test]
- public void TestExecuteMultipleReduced()
- {
- var clos = new List<IComputeFunc<object>>(MultiCloCnt);
-
- for (int i = 0; i < MultiCloCnt; i++)
- clos.Add(OutFunc(false));
-
- ICollection<object> ress = Grid1.GetCompute().Call(clos, new Reducer(false));
-
- foreach (object res in ress)
- CheckResult(res);
- }
-
- /// <summary>
- /// Test for multiple closures execution with exceptions thrown from some of them.
- /// </summary>
- [Test]
- public void TestExecuteMultipleException()
- {
- var clos = new List<IComputeFunc<object>>(MultiCloCnt);
-
- for (int i = 0; i < MultiCloCnt; i++)
- clos.Add(OutFunc(i % 2 == 0)); // Some closures will be faulty.
-
- try
- {
- Grid1.GetCompute().Call(clos);
-
- Assert.Fail();
- }
- catch (Exception e)
- {
- CheckError(e);
- }
- }
-
- /// <summary>
- /// Test broadcast out-closure execution.
- /// </summary>
- [Test]
- public void TestBroadcastOut()
- {
- ICollection<object> ress = Grid1.GetCompute().Broadcast(OutFunc(false));
-
- foreach (object res in ress)
- CheckResult(res);
- }
-
- /// <summary>
- /// Test broadcast out-closure execution with exception.
- /// </summary>
- [Test]
- public void TestBroadcastOutException()
- {
- try
- {
- Grid1.GetCompute().Broadcast(OutFunc(true));
-
- Assert.Fail();
- }
- catch (Exception e)
- {
- CheckError(e);
- }
- }
-
- /// <summary>
- /// Test broadcast in-out-closure execution.
- /// </summary>
- [Test]
- public void TestBroadcastInOut()
- {
- ICollection<object> ress = Grid1.GetCompute().Broadcast(Func(false), 1);
-
- foreach (object res in ress)
- CheckResult(res);
- }
-
- /// <summary>
- /// Test broadcast in-out-closure execution with exception.
- /// </summary>
- [Test]
- public void TestBroadcastInOutException()
- {
- try
- {
- Grid1.GetCompute().Broadcast(Func(true), 1);
-
- Assert.Fail();
- }
- catch (Exception e)
- {
- CheckError(e);
- }
- }
-
- /// <summary>
- /// Test apply in-out-closure execution.
- /// </summary>
- [Test]
- public void TestApply()
- {
- object res = Grid1.GetCompute().Apply(Func(false), 1);
-
- CheckResult(res);
- }
-
- /// <summary>
- /// Test apply in-out-closure execution with exception.
- /// </summary>
- [Test]
- public void TestApplyException()
- {
- try
- {
- Grid1.GetCompute().Apply(Func(true), 1);
-
- Assert.Fail();
- }
- catch (Exception e)
- {
- CheckError(e);
- }
- }
-
- /// <summary>
- /// Test apply multiple in-out-closures execution.
- /// </summary>
- [Test]
- public void TestApplyMultiple()
- {
- var args = new List<object>(MultiCloCnt);
-
- for (int i = 0; i < MultiCloCnt; i++)
- args.Add(1);
-
- Console.WriteLine("START TASK");
-
- var ress = Grid1.GetCompute().Apply(Func(false), args);
-
- Console.WriteLine("END TASK.");
-
- foreach (object res in ress)
- CheckResult(res);
- }
-
- /// <summary>
- /// Test apply multiple in-out-closures execution with exception.
- /// </summary>
- [Test]
- public void TestApplyMultipleException()
- {
- ICollection<int> args = new List<int>(MultiCloCnt);
-
- for (int i = 0; i < MultiCloCnt; i++)
- args.Add(1);
-
- try
- {
- Grid1.GetCompute().Apply(Func(true), args);
-
- Assert.Fail();
- }
- catch (Exception e)
- {
- CheckError(e);
- }
- }
-
- /// <summary>
- /// Test apply multiple in-out-closures execution with reducer.
- /// </summary>
- [Test]
- public void TestApplyMultipleReducer()
- {
- var args = new List<object>(MultiCloCnt);
-
- for (int i = 0; i < MultiCloCnt; i++)
- args.Add(1);
-
- ICollection<object> ress =
- Grid1.GetCompute().Apply(Func(false), args, new Reducer(false));
-
- foreach (object res in ress)
- CheckResult(res);
- }
-
- /// <summary>
- /// Test apply multiple in-out-closures execution with reducer and exception thrown from closure.
- /// </summary>
- [Test]
- public void TestAppylMultipleReducerJobException()
- {
- List<object> args = new List<object>(MultiCloCnt);
-
- for (int i = 0; i < MultiCloCnt; i++)
- args.Add(1);
-
- try
- {
- Grid1.GetCompute().Apply(Func(true), args, new Reducer(false));
-
- Assert.Fail();
- }
- catch (Exception e)
- {
- CheckError(e);
- }
- }
-
- /// <summary>
- /// Test apply multiple in-out-closures execution with reducer and exception thrown from reducer.
- /// </summary>
- [Test]
- public void TestAppylMultipleReducerReduceException()
- {
- var args = new List<object>(MultiCloCnt);
-
- for (int i = 0; i < MultiCloCnt; i++)
- args.Add(1);
-
- try
- {
- Grid1.GetCompute().Apply(Func(false), args, new Reducer(true));
-
- Assert.Fail();
- }
- catch (Exception e)
- {
- Assert.AreEqual(typeof(Exception), e.GetType());
-
- Assert.AreEqual(ErrMsg, e.Message);
- }
- }
-
- /// <summary>
- /// Create out-only closure.
- /// </summary>
- /// <param name="err">Error flag.</param>
- /// <returns>Closure.</returns>
- protected abstract IComputeFunc<object> OutFunc(bool err);
-
- /// <summary>
- /// Create in-out closure.
- /// </summary>
- /// <param name="err">Error flag.</param>
- /// <returns>Closure.</returns>
- protected abstract IComputeFunc<object, object> Func(bool err);
-
- /// <summary>
- /// Check result.
- /// </summary>
- /// <param name="res">Result.</param>
- protected abstract void CheckResult(object res);
-
- /// <summary>
- /// Check error.
- /// </summary>
- /// <param name="err">Error.</param>
- protected abstract void CheckError(Exception err);
-
- /// <summary>
- /// Test reducer.
- /// </summary>
- public class Reducer : IComputeReducer<object, ICollection<object>>
- {
- /** Whether to throw an error on reduce. */
- private readonly bool _err;
-
- /** Results. */
- private readonly ICollection<object> _ress = new List<object>();
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="err">Error.</param>
- public Reducer(bool err)
- {
- _err = err;
- }
-
- /** <inheritDoc /> */
- public bool Collect(object res)
- {
- _ress.Add(res);
-
- return true;
- }
-
- /** <inheritDoc /> */
- public ICollection<object> Reduce()
- {
- if (_err)
- throw new Exception(ErrMsg);
- return _ress;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
deleted file mode 100644
index 039813b..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
+++ /dev/null
@@ -1,1281 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// ReSharper disable SpecifyACultureInStringConversionExplicitly
-namespace Apache.Ignite.Core.Tests.Compute
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading;
- using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Compute;
- using Apache.Ignite.Core.Impl;
- using Apache.Ignite.Core.Portable;
- using Apache.Ignite.Core.Resource;
- using NUnit.Framework;
-
- /// <summary>
- /// Tests for compute.
- /// </summary>
- public class ComputeApiTest
- {
- /** Echo task name. */
- private const string EchoTask = "org.apache.ignite.platform.PlatformComputeEchoTask";
-
- /** Portable argument task name. */
- private const string PortableArgTask = "org.apache.ignite.platform.PlatformComputePortableArgTask";
-
- /** Broadcast task name. */
- private const string BroadcastTask = "org.apache.ignite.platform.PlatformComputeBroadcastTask";
-
- /** Broadcast task name. */
- private const string DecimalTask = "org.apache.ignite.platform.PlatformComputeDecimalTask";
-
- /** Java portable class name. */
- private const string JavaPortableCls = "GridInteropComputeJavaPortable";
-
- /** Echo type: null. */
- private const int EchoTypeNull = 0;
-
- /** Echo type: byte. */
- private const int EchoTypeByte = 1;
-
- /** Echo type: bool. */
- private const int EchoTypeBool = 2;
-
- /** Echo type: short. */
- private const int EchoTypeShort = 3;
-
- /** Echo type: char. */
- private const int EchoTypeChar = 4;
-
- /** Echo type: int. */
- private const int EchoTypeInt = 5;
-
- /** Echo type: long. */
- private const int EchoTypeLong = 6;
-
- /** Echo type: float. */
- private const int EchoTypeFloat = 7;
-
- /** Echo type: double. */
- private const int EchoTypeDouble = 8;
-
- /** Echo type: array. */
- private const int EchoTypeArray = 9;
-
- /** Echo type: collection. */
- private const int EchoTypeCollection = 10;
-
- /** Echo type: map. */
- private const int EchoTypeMap = 11;
-
- /** Echo type: portable. */
- private const int EchoTypePortable = 12;
-
- /** Echo type: portable (Java only). */
- private const int EchoTypePortableJava = 13;
-
- /** Type: object array. */
- private const int EchoTypeObjArray = 14;
-
- /** Type: portable object array. */
- private const int EchoTypePortableArray = 15;
-
- /** Type: enum. */
- private const int EchoTypeEnum = 16;
-
- /** Type: enum array. */
- private const int EchoTypeEnumArray = 17;
-
- /** First node. */
- private IIgnite _grid1;
-
- /** Second node. */
- private IIgnite _grid2;
-
- /** Third node. */
- private IIgnite _grid3;
-
- /// <summary>
- /// Initialization routine.
- /// </summary>
- [TestFixtureSetUp]
- public void InitClient()
- {
- //TestUtils.JVM_DEBUG = true;
- TestUtils.KillProcesses();
-
- _grid1 = Ignition.Start(Configuration("config\\compute\\compute-grid1.xml"));
- _grid2 = Ignition.Start(Configuration("config\\compute\\compute-grid2.xml"));
- _grid3 = Ignition.Start(Configuration("config\\compute\\compute-grid3.xml"));
- }
-
- [TestFixtureTearDown]
- public void StopClient()
- {
- if (_grid1 != null)
- Ignition.Stop(_grid1.Name, true);
-
- if (_grid2 != null)
- Ignition.Stop(_grid2.Name, true);
-
- if (_grid3 != null)
- Ignition.Stop(_grid3.Name, true);
- }
-
- [TearDown]
- public void AfterTest()
- {
- TestUtils.AssertHandleRegistryIsEmpty(1000, _grid1, _grid2, _grid3);
- }
-
- /// <summary>
- /// Test that it is possible to get projection from grid.
- /// </summary>
- [Test]
- public void TestProjection()
- {
- IClusterGroup prj = _grid1.GetCluster();
-
- Assert.NotNull(prj);
-
- Assert.IsTrue(prj == prj.Ignite);
- }
-
- /// <summary>
- /// Test getting cache with default (null) name.
- /// </summary>
- [Test]
- public void TestCacheDefaultName()
- {
- var cache = _grid1.GetCache<int, int>(null);
-
- Assert.IsNotNull(cache);
-
- cache.GetAndPut(1, 1);
-
- Assert.AreEqual(1, cache.Get(1));
- }
-
- /// <summary>
- /// Test non-existent cache.
- /// </summary>
- [Test]
- public void TestNonExistentCache()
- {
- Assert.Catch(typeof(ArgumentException), () =>
- {
- _grid1.GetCache<int, int>("bad_name");
- });
- }
-
- /// <summary>
- /// Test node content.
- /// </summary>
- [Test]
- public void TestNodeContent()
- {
- ICollection<IClusterNode> nodes = _grid1.GetCluster().GetNodes();
-
- foreach (IClusterNode node in nodes)
- {
- Assert.NotNull(node.Addresses);
- Assert.IsTrue(node.Addresses.Count > 0);
- Assert.Throws<NotSupportedException>(() => node.Addresses.Add("addr"));
-
- Assert.NotNull(node.GetAttributes());
- Assert.IsTrue(node.GetAttributes().Count > 0);
- Assert.Throws<NotSupportedException>(() => node.GetAttributes().Add("key", "val"));
-
- Assert.NotNull(node.HostNames);
- Assert.Throws<NotSupportedException>(() => node.HostNames.Add("h"));
-
- Assert.IsTrue(node.Id != Guid.Empty);
-
- Assert.IsTrue(node.Order > 0);
-
- Assert.NotNull(node.GetMetrics());
- }
- }
-
- /// <summary>
- /// Test cluster metrics.
- /// </summary>
- [Test]
- public void TestClusterMetrics()
- {
- var cluster = _grid1.GetCluster();
-
- IClusterMetrics metrics = cluster.GetMetrics();
-
- Assert.IsNotNull(metrics);
-
- Assert.AreEqual(cluster.GetNodes().Count, metrics.TotalNodes);
-
- Thread.Sleep(2000);
-
- IClusterMetrics newMetrics = cluster.GetMetrics();
-
- Assert.IsFalse(metrics == newMetrics);
- Assert.IsTrue(metrics.LastUpdateTime < newMetrics.LastUpdateTime);
- }
-
- /// <summary>
- /// Test cluster metrics.
- /// </summary>
- [Test]
- public void TestNodeMetrics()
- {
- var node = _grid1.GetCluster().GetNode();
-
- IClusterMetrics metrics = node.GetMetrics();
-
- Assert.IsNotNull(metrics);
-
- Assert.IsTrue(metrics == node.GetMetrics());
-
- Thread.Sleep(2000);
-
- IClusterMetrics newMetrics = node.GetMetrics();
-
- Assert.IsFalse(metrics == newMetrics);
- Assert.IsTrue(metrics.LastUpdateTime < newMetrics.LastUpdateTime);
- }
-
- /// <summary>
- /// Test cluster metrics.
- /// </summary>
- [Test]
- public void TestResetMetrics()
- {
- var cluster = _grid1.GetCluster();
-
- Thread.Sleep(2000);
-
- var metrics1 = cluster.GetMetrics();
-
- cluster.ResetMetrics();
-
- var metrics2 = cluster.GetMetrics();
-
- Assert.IsNotNull(metrics1);
- Assert.IsNotNull(metrics2);
- }
-
- /// <summary>
- /// Test node ping.
- /// </summary>
- [Test]
- public void TestPingNode()
- {
- var cluster = _grid1.GetCluster();
-
- Assert.IsTrue(cluster.GetNodes().Select(node => node.Id).All(cluster.PingNode));
-
- Assert.IsFalse(cluster.PingNode(Guid.NewGuid()));
- }
-
- /// <summary>
- /// Tests the topology version.
- /// </summary>
- [Test]
- public void TestTopologyVersion()
- {
- var cluster = _grid1.GetCluster();
-
- var topVer = cluster.TopologyVersion;
-
- Ignition.Stop(_grid3.Name, true);
-
- Assert.AreEqual(topVer + 1, _grid1.GetCluster().TopologyVersion);
-
- _grid3 = Ignition.Start(Configuration("config\\compute\\compute-grid3.xml"));
-
- Assert.AreEqual(topVer + 2, _grid1.GetCluster().TopologyVersion);
- }
-
- /// <summary>
- /// Tests the topology by version.
- /// </summary>
- [Test]
- public void TestTopology()
- {
- var cluster = _grid1.GetCluster();
-
- Assert.AreEqual(1, cluster.GetTopology(1).Count);
-
- Assert.AreEqual(null, cluster.GetTopology(int.MaxValue));
-
- // Check that Nodes and Topology return the same for current version
- var topVer = cluster.TopologyVersion;
-
- var top = cluster.GetTopology(topVer);
-
- var nodes = cluster.GetNodes();
-
- Assert.AreEqual(top.Count, nodes.Count);
-
- Assert.IsTrue(top.All(nodes.Contains));
-
- // Stop/start node to advance version and check that history is still correct
- Assert.IsTrue(Ignition.Stop(_grid2.Name, true));
-
- try
- {
- top = cluster.GetTopology(topVer);
-
- Assert.AreEqual(top.Count, nodes.Count);
-
- Assert.IsTrue(top.All(nodes.Contains));
- }
- finally
- {
- _grid2 = Ignition.Start(Configuration("config\\compute\\compute-grid2.xml"));
- }
- }
-
- /// <summary>
- /// Test nodes in full topology.
- /// </summary>
- [Test]
- public void TestNodes()
- {
- Assert.IsNotNull(_grid1.GetCluster().GetNode());
-
- ICollection<IClusterNode> nodes = _grid1.GetCluster().GetNodes();
-
- Assert.IsTrue(nodes.Count == 3);
-
- // Check subsequent call on the same topology.
- nodes = _grid1.GetCluster().GetNodes();
-
- Assert.IsTrue(nodes.Count == 3);
-
- Assert.IsTrue(Ignition.Stop(_grid2.Name, true));
-
- // Check subsequent calls on updating topologies.
- nodes = _grid1.GetCluster().GetNodes();
-
- Assert.IsTrue(nodes.Count == 2);
-
- nodes = _grid1.GetCluster().GetNodes();
-
- Assert.IsTrue(nodes.Count == 2);
-
- _grid2 = Ignition.Start(Configuration("config\\compute\\compute-grid2.xml"));
-
- nodes = _grid1.GetCluster().GetNodes();
-
- Assert.IsTrue(nodes.Count == 3);
- }
-
- /// <summary>
- /// Test "ForNodes" and "ForNodeIds".
- /// </summary>
- [Test]
- public void TestForNodes()
- {
- ICollection<IClusterNode> nodes = _grid1.GetCluster().GetNodes();
-
- IClusterNode first = nodes.ElementAt(0);
- IClusterNode second = nodes.ElementAt(1);
-
- IClusterGroup singleNodePrj = _grid1.GetCluster().ForNodeIds(first.Id);
- Assert.AreEqual(1, singleNodePrj.GetNodes().Count);
- Assert.AreEqual(first.Id, singleNodePrj.GetNodes().First().Id);
-
- singleNodePrj = _grid1.GetCluster().ForNodeIds(new List<Guid> { first.Id });
- Assert.AreEqual(1, singleNodePrj.GetNodes().Count);
- Assert.AreEqual(first.Id, singleNodePrj.GetNodes().First().Id);
-
- singleNodePrj = _grid1.GetCluster().ForNodes(first);
- Assert.AreEqual(1, singleNodePrj.GetNodes().Count);
- Assert.AreEqual(first.Id, singleNodePrj.GetNodes().First().Id);
-
- singleNodePrj = _grid1.GetCluster().ForNodes(new List<IClusterNode> { first });
- Assert.AreEqual(1, singleNodePrj.GetNodes().Count);
- Assert.AreEqual(first.Id, singleNodePrj.GetNodes().First().Id);
-
- IClusterGroup multiNodePrj = _grid1.GetCluster().ForNodeIds(first.Id, second.Id);
- Assert.AreEqual(2, multiNodePrj.GetNodes().Count);
- Assert.IsTrue(multiNodePrj.GetNodes().Contains(first));
- Assert.IsTrue(multiNodePrj.GetNodes().Contains(second));
-
- multiNodePrj = _grid1.GetCluster().ForNodeIds(new[] {first, second}.Select(x => x.Id));
- Assert.AreEqual(2, multiNodePrj.GetNodes().Count);
- Assert.IsTrue(multiNodePrj.GetNodes().Contains(first));
- Assert.IsTrue(multiNodePrj.GetNodes().Contains(second));
-
- multiNodePrj = _grid1.GetCluster().ForNodes(first, second);
- Assert.AreEqual(2, multiNodePrj.GetNodes().Count);
- Assert.IsTrue(multiNodePrj.GetNodes().Contains(first));
- Assert.IsTrue(multiNodePrj.GetNodes().Contains(second));
-
- multiNodePrj = _grid1.GetCluster().ForNodes(new List<IClusterNode> { first, second });
- Assert.AreEqual(2, multiNodePrj.GetNodes().Count);
- Assert.IsTrue(multiNodePrj.GetNodes().Contains(first));
- Assert.IsTrue(multiNodePrj.GetNodes().Contains(second));
- }
-
- /// <summary>
- /// Test "ForNodes" and "ForNodeIds". Make sure lazy enumerables are enumerated only once.
- /// </summary>
- [Test]
- public void TestForNodesLaziness()
- {
- var nodes = _grid1.GetCluster().GetNodes().Take(2).ToArray();
-
- var callCount = 0;
-
- Func<IClusterNode, IClusterNode> nodeSelector = node =>
- {
- callCount++;
- return node;
- };
-
- Func<IClusterNode, Guid> idSelector = node =>
- {
- callCount++;
- return node.Id;
- };
-
- var projection = _grid1.GetCluster().ForNodes(nodes.Select(nodeSelector));
- Assert.AreEqual(2, projection.GetNodes().Count);
- Assert.AreEqual(2, callCount);
-
- projection = _grid1.GetCluster().ForNodeIds(nodes.Select(idSelector));
- Assert.AreEqual(2, projection.GetNodes().Count);
- Assert.AreEqual(4, callCount);
- }
-
- /// <summary>
- /// Test for local node projection.
- /// </summary>
- [Test]
- public void TestForLocal()
- {
- IClusterGroup prj = _grid1.GetCluster().ForLocal();
-
- Assert.AreEqual(1, prj.GetNodes().Count);
- Assert.AreEqual(_grid1.GetCluster().GetLocalNode(), prj.GetNodes().First());
- }
-
- /// <summary>
- /// Test for remote nodes projection.
- /// </summary>
- [Test]
- public void TestForRemotes()
- {
- ICollection<IClusterNode> nodes = _grid1.GetCluster().GetNodes();
-
- IClusterGroup prj = _grid1.GetCluster().ForRemotes();
-
- Assert.AreEqual(2, prj.GetNodes().Count);
- Assert.IsTrue(nodes.Contains(prj.GetNodes().ElementAt(0)));
- Assert.IsTrue(nodes.Contains(prj.GetNodes().ElementAt(1)));
- }
-
- /// <summary>
- /// Test for host nodes projection.
- /// </summary>
- [Test]
- public void TestForHost()
- {
- ICollection<IClusterNode> nodes = _grid1.GetCluster().GetNodes();
-
- IClusterGroup prj = _grid1.GetCluster().ForHost(nodes.First());
-
- Assert.AreEqual(3, prj.GetNodes().Count);
- Assert.IsTrue(nodes.Contains(prj.GetNodes().ElementAt(0)));
- Assert.IsTrue(nodes.Contains(prj.GetNodes().ElementAt(1)));
- Assert.IsTrue(nodes.Contains(prj.GetNodes().ElementAt(2)));
- }
-
- /// <summary>
- /// Test for oldest, youngest and random projections.
- /// </summary>
- [Test]
- public void TestForOldestYoungestRandom()
- {
- ICollection<IClusterNode> nodes = _grid1.GetCluster().GetNodes();
-
- IClusterGroup prj = _grid1.GetCluster().ForYoungest();
- Assert.AreEqual(1, prj.GetNodes().Count);
- Assert.IsTrue(nodes.Contains(prj.GetNode()));
-
- prj = _grid1.GetCluster().ForOldest();
- Assert.AreEqual(1, prj.GetNodes().Count);
- Assert.IsTrue(nodes.Contains(prj.GetNode()));
-
- prj = _grid1.GetCluster().ForRandom();
- Assert.AreEqual(1, prj.GetNodes().Count);
- Assert.IsTrue(nodes.Contains(prj.GetNode()));
- }
-
- /// <summary>
- /// Test for attribute projection.
- /// </summary>
- [Test]
- public void TestForAttribute()
- {
- ICollection<IClusterNode> nodes = _grid1.GetCluster().GetNodes();
-
- IClusterGroup prj = _grid1.GetCluster().ForAttribute("my_attr", "value1");
- Assert.AreEqual(1, prj.GetNodes().Count);
- Assert.IsTrue(nodes.Contains(prj.GetNode()));
- Assert.AreEqual("value1", prj.GetNodes().First().GetAttribute<string>("my_attr"));
- }
-
- /// <summary>
- /// Test for cache/data/client projections.
- /// </summary>
- [Test]
- public void TestForCacheNodes()
- {
- ICollection<IClusterNode> nodes = _grid1.GetCluster().GetNodes();
-
- // Cache nodes.
- IClusterGroup prjCache = _grid1.GetCluster().ForCacheNodes("cache1");
-
- Assert.AreEqual(2, prjCache.GetNodes().Count);
-
- Assert.IsTrue(nodes.Contains(prjCache.GetNodes().ElementAt(0)));
- Assert.IsTrue(nodes.Contains(prjCache.GetNodes().ElementAt(1)));
-
- // Data nodes.
- IClusterGroup prjData = _grid1.GetCluster().ForDataNodes("cache1");
-
- Assert.AreEqual(2, prjData.GetNodes().Count);
-
- Assert.IsTrue(prjCache.GetNodes().Contains(prjData.GetNodes().ElementAt(0)));
- Assert.IsTrue(prjCache.GetNodes().Contains(prjData.GetNodes().ElementAt(1)));
-
- // Client nodes.
- IClusterGroup prjClient = _grid1.GetCluster().ForClientNodes("cache1");
-
- Assert.AreEqual(0, prjClient.GetNodes().Count);
- }
-
- /// <summary>
- /// Test for cache predicate.
- /// </summary>
- [Test]
- public void TestForPredicate()
- {
- IClusterGroup prj1 = _grid1.GetCluster().ForPredicate(new NotAttributePredicate("value1").Apply);
- Assert.AreEqual(2, prj1.GetNodes().Count);
-
- IClusterGroup prj2 = prj1.ForPredicate(new NotAttributePredicate("value2").Apply);
- Assert.AreEqual(1, prj2.GetNodes().Count);
-
- string val;
-
- prj2.GetNodes().First().TryGetAttribute("my_attr", out val);
-
- Assert.IsTrue(val == null || (!val.Equals("value1") && !val.Equals("value2")));
- }
-
- /// <summary>
- /// Attribute predicate.
- /// </summary>
- private class NotAttributePredicate
- {
- /** Required attribute value. */
- private readonly string _attrVal;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="attrVal">Required attribute value.</param>
- public NotAttributePredicate(string attrVal)
- {
- _attrVal = attrVal;
- }
-
- /** <inhreitDoc /> */
- public bool Apply(IClusterNode node)
- {
- string val;
-
- node.TryGetAttribute("my_attr", out val);
-
- return val == null || !val.Equals(_attrVal);
- }
- }
-
- /// <summary>
- /// Test echo with decimals.
- /// </summary>
- [Test]
- public void TestEchoDecimal()
- {
- decimal val;
-
- Assert.AreEqual(val = decimal.Zero, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
-
- Assert.AreEqual(val = new decimal(0, 0, 1, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, 0, 1, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, 0, 1, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, 0, 1, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, 0, 1, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, 0, 1, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, 0, int.MinValue, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, 0, int.MinValue, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, 0, int.MinValue, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, 0, int.MinValue, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, 0, int.MinValue, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, 0, int.MinValue, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
-
- Assert.AreEqual(val = new decimal(0, 1, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, 1, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, 1, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, 1, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, 1, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, 1, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, int.MinValue, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, int.MinValue, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, int.MinValue, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, int.MinValue, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, int.MinValue, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, int.MinValue, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
-
- Assert.AreEqual(val = new decimal(1, 0, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(1, 0, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(1, 0, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(1, 0, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(1, 0, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(1, 0, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
-
- Assert.AreEqual(val = new decimal(1, 1, 1, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(1, 1, 1, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(1, 1, 1, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(1, 1, 1, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(1, 1, 1, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = new decimal(1, 1, 1, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
-
- Assert.AreEqual(val = decimal.Parse("65536"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("-65536"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("65536") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("-65536") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("65536") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("-65536") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
-
- Assert.AreEqual(val = decimal.Parse("4294967296"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("-4294967296"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("4294967296") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("-4294967296") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("4294967296") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("-4294967296") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
-
- Assert.AreEqual(val = decimal.Parse("281474976710656"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("-281474976710656"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("281474976710656") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("-281474976710656") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("281474976710656") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("-281474976710656") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
-
- Assert.AreEqual(val = decimal.Parse("18446744073709551616"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("-18446744073709551616"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("18446744073709551616") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("-18446744073709551616") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("18446744073709551616") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("-18446744073709551616") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
-
- Assert.AreEqual(val = decimal.Parse("1208925819614629174706176"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("-1208925819614629174706176"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("1208925819614629174706176") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("-1208925819614629174706176") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("1208925819614629174706176") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("-1208925819614629174706176") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
-
- Assert.AreEqual(val = decimal.MaxValue, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.MinValue, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.MaxValue - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.MinValue + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
-
- Assert.AreEqual(val = decimal.Parse("11,12"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
- Assert.AreEqual(val = decimal.Parse("-11,12"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
-
- // Test echo with overflow.
- try
- {
- _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { null, decimal.MaxValue.ToString() + 1 });
-
- Assert.Fail();
- }
- catch (IgniteException)
- {
- // No-op.
- }
- }
-
- /// <summary>
- /// Test echo task returning null.
- /// </summary>
- [Test]
- public void TestEchoTaskNull()
- {
- Assert.IsNull(_grid1.GetCompute().ExecuteJavaTask<object>(EchoTask, EchoTypeNull));
- }
-
- /// <summary>
- /// Test echo task returning various primitives.
- /// </summary>
- [Test]
- public void TestEchoTaskPrimitives()
- {
- Assert.AreEqual(1, _grid1.GetCompute().ExecuteJavaTask<byte>(EchoTask, EchoTypeByte));
- Assert.AreEqual(true, _grid1.GetCompute().ExecuteJavaTask<bool>(EchoTask, EchoTypeBool));
- Assert.AreEqual(1, _grid1.GetCompute().ExecuteJavaTask<short>(EchoTask, EchoTypeShort));
- Assert.AreEqual((char)1, _grid1.GetCompute().ExecuteJavaTask<char>(EchoTask, EchoTypeChar));
- Assert.AreEqual(1, _grid1.GetCompute().ExecuteJavaTask<int>(EchoTask, EchoTypeInt));
- Assert.AreEqual(1, _grid1.GetCompute().ExecuteJavaTask<long>(EchoTask, EchoTypeLong));
- Assert.AreEqual((float)1, _grid1.GetCompute().ExecuteJavaTask<float>(EchoTask, EchoTypeFloat));
- Assert.AreEqual((double)1, _grid1.GetCompute().ExecuteJavaTask<double>(EchoTask, EchoTypeDouble));
- }
-
- /// <summary>
- /// Test echo task returning compound types.
- /// </summary>
- [Test]
- public void TestEchoTaskCompound()
- {
- int[] res1 = _grid1.GetCompute().ExecuteJavaTask<int[]>(EchoTask, EchoTypeArray);
-
- Assert.AreEqual(1, res1.Length);
- Assert.AreEqual(1, res1[0]);
-
- IList<int> res2 = _grid1.GetCompute().ExecuteJavaTask<IList<int>>(EchoTask, EchoTypeCollection);
-
- Assert.AreEqual(1, res2.Count);
- Assert.AreEqual(1, res2[0]);
-
- IDictionary<int, int> res3 = _grid1.GetCompute().ExecuteJavaTask<IDictionary<int, int>>(EchoTask, EchoTypeMap);
-
- Assert.AreEqual(1, res3.Count);
- Assert.AreEqual(1, res3[1]);
- }
-
- /// <summary>
- /// Test echo task returning portable object.
- /// </summary>
- [Test]
- public void TestEchoTaskPortable()
- {
- PlatformComputePortable res = _grid1.GetCompute().ExecuteJavaTask<PlatformComputePortable>(EchoTask, EchoTypePortable);
-
- Assert.AreEqual(1, res.Field);
- }
-
- /// <summary>
- /// Test echo task returning portable object with no corresponding class definition.
- /// </summary>
- [Test]
- public void TestEchoTaskPortableNoClass()
- {
- ICompute compute = _grid1.GetCompute();
-
- compute.WithKeepPortable();
-
- IPortableObject res = compute.ExecuteJavaTask<IPortableObject>(EchoTask, EchoTypePortableJava);
-
- Assert.AreEqual(1, res.GetField<int>("field"));
-
- // This call must fail because "keepPortable" flag is reset.
- Assert.Catch(typeof(PortableException), () =>
- {
- compute.ExecuteJavaTask<IPortableObject>(EchoTask, EchoTypePortableJava);
- });
- }
-
- /// <summary>
- /// Tests the echo task returning object array.
- /// </summary>
- [Test]
- public void TestEchoTaskObjectArray()
- {
- var res = _grid1.GetCompute().ExecuteJavaTask<string[]>(EchoTask, EchoTypeObjArray);
-
- Assert.AreEqual(new[] {"foo", "bar", "baz"}, res);
- }
-
- /// <summary>
- /// Tests the echo task returning portable array.
- /// </summary>
- [Test]
- public void TestEchoTaskPortableArray()
- {
- var res = _grid1.GetCompute().ExecuteJavaTask<PlatformComputePortable[]>(EchoTask, EchoTypePortableArray);
-
- Assert.AreEqual(3, res.Length);
-
- for (var i = 0; i < res.Length; i++)
- Assert.AreEqual(i + 1, res[i].Field);
- }
-
- /// <summary>
- /// Tests the echo task returning enum.
- /// </summary>
- [Test]
- public void TestEchoTaskEnum()
- {
- var res = _grid1.GetCompute().ExecuteJavaTask<InteropComputeEnum>(EchoTask, EchoTypeEnum);
-
- Assert.AreEqual(InteropComputeEnum.Bar, res);
- }
-
- /// <summary>
- /// Tests the echo task returning enum.
- /// </summary>
- [Test]
- public void TestEchoTaskEnumArray()
- {
- var res = _grid1.GetCompute().ExecuteJavaTask<InteropComputeEnum[]>(EchoTask, EchoTypeEnumArray);
-
- Assert.AreEqual(new[]
- {
- InteropComputeEnum.Bar,
- InteropComputeEnum.Baz,
- InteropComputeEnum.Foo
- }, res);
- }
-
- /// <summary>
- /// Test for portable argument in Java.
- /// </summary>
- [Test]
- public void TestPortableArgTask()
- {
- ICompute compute = _grid1.GetCompute();
-
- compute.WithKeepPortable();
-
- PlatformComputeNetPortable arg = new PlatformComputeNetPortable();
-
- arg.Field = 100;
-
- int res = compute.ExecuteJavaTask<int>(PortableArgTask, arg);
-
- Assert.AreEqual(arg.Field, res);
- }
-
- /// <summary>
- /// Test running broadcast task.
- /// </summary>
- [Test]
- public void TestBroadcastTask()
- {
- ICollection<Guid> res = _grid1.GetCompute().ExecuteJavaTask<ICollection<Guid>>(BroadcastTask, null);
-
- Assert.AreEqual(3, res.Count);
- Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(0)).GetNodes().Count);
- Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(1)).GetNodes().Count);
- Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(2)).GetNodes().Count);
-
- var prj = _grid1.GetCluster().ForPredicate(node => res.Take(2).Contains(node.Id));
-
- Assert.AreEqual(2, prj.GetNodes().Count);
-
- ICollection<Guid> filteredRes = prj.GetCompute().ExecuteJavaTask<ICollection<Guid>>(BroadcastTask, null);
-
- Assert.AreEqual(2, filteredRes.Count);
- Assert.IsTrue(filteredRes.Contains(res.ElementAt(0)));
- Assert.IsTrue(filteredRes.Contains(res.ElementAt(1)));
- }
-
- /// <summary>
- /// Test running broadcast task in async mode.
- /// </summary>
- [Test]
- public void TestBroadcastTaskAsync()
- {
- var gridCompute = _grid1.GetCompute().WithAsync();
- Assert.IsNull(gridCompute.ExecuteJavaTask<ICollection<Guid>>(BroadcastTask, null));
- ICollection<Guid> res = gridCompute.GetFuture<ICollection<Guid>>().Get();
-
- Assert.AreEqual(3, res.Count);
- Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(0)).GetNodes().Count);
- Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(1)).GetNodes().Count);
- Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(2)).GetNodes().Count);
-
- var prj = _grid1.GetCluster().ForPredicate(node => res.Take(2).Contains(node.Id));
-
- Assert.AreEqual(2, prj.GetNodes().Count);
-
- var compute = prj.GetCompute().WithAsync();
- Assert.IsNull(compute.ExecuteJavaTask<ICollection<Guid>>(BroadcastTask, null));
- ICollection<Guid> filteredRes = compute.GetFuture<ICollection<Guid>>().Get();
-
- Assert.AreEqual(2, filteredRes.Count);
- Assert.IsTrue(filteredRes.Contains(res.ElementAt(0)));
- Assert.IsTrue(filteredRes.Contains(res.ElementAt(1)));
- }
-
- /// <summary>
- /// Tests the action broadcast.
- /// </summary>
- [Test]
- public void TestBroadcastAction()
- {
- ComputeAction.InvokeCount = 0;
-
- _grid1.GetCompute().Broadcast(new ComputeAction());
-
- Assert.AreEqual(_grid1.GetCluster().GetNodes().Count, ComputeAction.InvokeCount);
- }
-
- /// <summary>
- /// Tests single action run.
- /// </summary>
- [Test]
- public void TestRunAction()
- {
- ComputeAction.InvokeCount = 0;
-
- _grid1.GetCompute().Run(new ComputeAction());
-
- Assert.AreEqual(1, ComputeAction.InvokeCount);
- }
-
- /// <summary>
- /// Tests multiple actions run.
- /// </summary>
- [Test]
- public void TestRunActions()
- {
- ComputeAction.InvokeCount = 0;
-
- var actions = Enumerable.Range(0, 10).Select(x => new ComputeAction());
-
- _grid1.GetCompute().Run(actions);
-
- Assert.AreEqual(10, ComputeAction.InvokeCount);
- }
-
- /// <summary>
- /// Tests affinity run.
- /// </summary>
- [Test]
- public void TestAffinityRun()
- {
- const string cacheName = null;
-
- // Test keys for non-client nodes
- var nodes = new[] {_grid1, _grid2}.Select(x => x.GetCluster().GetLocalNode());
-
- var aff = _grid1.GetAffinity(cacheName);
-
- foreach (var node in nodes)
- {
- var primaryKey = Enumerable.Range(1, int.MaxValue).First(x => aff.IsPrimary(node, x));
-
- var affinityKey = _grid1.GetAffinity(cacheName).GetAffinityKey<int, int>(primaryKey);
-
- _grid1.GetCompute().AffinityRun(cacheName, affinityKey, new ComputeAction());
-
- Assert.AreEqual(node.Id, ComputeAction.LastNodeId);
- }
- }
-
- /// <summary>
- /// Tests affinity call.
- /// </summary>
- [Test]
- public void TestAffinityCall()
- {
- const string cacheName = null;
-
- // Test keys for non-client nodes
- var nodes = new[] { _grid1, _grid2 }.Select(x => x.GetCluster().GetLocalNode());
-
- var aff = _grid1.GetAffinity(cacheName);
-
- foreach (var node in nodes)
- {
- var primaryKey = Enumerable.Range(1, int.MaxValue).First(x => aff.IsPrimary(node, x));
-
- var affinityKey = _grid1.GetAffinity(cacheName).GetAffinityKey<int, int>(primaryKey);
-
- var result = _grid1.GetCompute().AffinityCall(cacheName, affinityKey, new ComputeFunc());
-
- Assert.AreEqual(result, ComputeFunc.InvokeCount);
-
- Assert.AreEqual(node.Id, ComputeFunc.LastNodeId);
- }
- }
-
- /// <summary>
- /// Test "withNoFailover" feature.
- /// </summary>
- [Test]
- public void TestWithNoFailover()
- {
- ICollection<Guid> res = _grid1.GetCompute().WithNoFailover().ExecuteJavaTask<ICollection<Guid>>(BroadcastTask, null);
-
- Assert.AreEqual(3, res.Count);
- Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(0)).GetNodes().Count);
- Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(1)).GetNodes().Count);
- Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(2)).GetNodes().Count);
- }
-
- /// <summary>
- /// Test "withTimeout" feature.
- /// </summary>
- [Test]
- public void TestWithTimeout()
- {
- ICollection<Guid> res = _grid1.GetCompute().WithTimeout(1000).ExecuteJavaTask<ICollection<Guid>>(BroadcastTask, null);
-
- Assert.AreEqual(3, res.Count);
- Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(0)).GetNodes().Count);
- Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(1)).GetNodes().Count);
- Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(2)).GetNodes().Count);
- }
-
- /// <summary>
- /// Test simple dotNet task execution.
- /// </summary>
- [Test]
- public void TestNetTaskSimple()
- {
- int res = _grid1.GetCompute().Execute<NetSimpleJobArgument, NetSimpleJobResult, NetSimpleTaskResult>(
- typeof(NetSimpleTask), new NetSimpleJobArgument(1)).Res;
-
- Assert.AreEqual(_grid1.GetCompute().ClusterGroup.GetNodes().Count, res);
- }
-
- /// <summary>
- /// Create configuration.
- /// </summary>
- /// <param name="path">XML config path.</param>
- private IgniteConfiguration Configuration(string path)
- {
- IgniteConfiguration cfg = new IgniteConfiguration();
-
- PortableConfiguration portCfg = new PortableConfiguration();
-
- ICollection<PortableTypeConfiguration> portTypeCfgs = new List<PortableTypeConfiguration>();
-
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PlatformComputePortable)));
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PlatformComputeNetPortable)));
- portTypeCfgs.Add(new PortableTypeConfiguration(JavaPortableCls));
-
- portCfg.TypeConfigurations = portTypeCfgs;
-
- cfg.PortableConfiguration = portCfg;
-
- cfg.JvmClasspath = IgniteManager.CreateClasspath(cfg, true);
-
- cfg.JvmOptions = TestUtils.TestJavaOptions();
-
- cfg.SpringConfigUrl = path;
-
- return cfg;
- }
- }
-
- class PlatformComputePortable
- {
- public int Field
- {
- get;
- set;
- }
- }
-
- class PlatformComputeNetPortable : PlatformComputePortable
- {
-
- }
-
- [Serializable]
- class NetSimpleTask : IComputeTask<NetSimpleJobArgument, NetSimpleJobResult, NetSimpleTaskResult>
- {
- /** <inheritDoc /> */
-
- public IDictionary<IComputeJob<NetSimpleJobResult>, IClusterNode> Map(IList<IClusterNode> subgrid,
- NetSimpleJobArgument arg)
- {
- var jobs = new Dictionary<IComputeJob<NetSimpleJobResult>, IClusterNode>();
-
- for (int i = 0; i < subgrid.Count; i++)
- {
- NetSimpleJob job = new NetSimpleJob {Arg = arg};
-
- jobs[job] = subgrid[i];
- }
-
- return jobs;
- }
-
- /** <inheritDoc /> */
- public ComputeJobResultPolicy Result(IComputeJobResult<NetSimpleJobResult> res,
- IList<IComputeJobResult<NetSimpleJobResult>> rcvd)
- {
- return ComputeJobResultPolicy.Wait;
- }
-
- /** <inheritDoc /> */
- public NetSimpleTaskResult Reduce(IList<IComputeJobResult<NetSimpleJobResult>> results)
- {
- return new NetSimpleTaskResult(results.Sum(res => res.Data().Res));
- }
- }
-
- [Serializable]
- class NetSimpleJob : IComputeJob<NetSimpleJobResult>
- {
- public NetSimpleJobArgument Arg;
-
- /** <inheritDoc /> */
- public NetSimpleJobResult Execute()
- {
- return new NetSimpleJobResult(Arg.Arg);
- }
-
- /** <inheritDoc /> */
- public void Cancel()
- {
- // No-op.
- }
- }
-
- [Serializable]
- class NetSimpleJobArgument
- {
- public int Arg;
-
- public NetSimpleJobArgument(int arg)
- {
- Arg = arg;
- }
- }
-
- [Serializable]
- class NetSimpleTaskResult
- {
- public int Res;
-
- public NetSimpleTaskResult(int res)
- {
- Res = res;
- }
- }
-
- [Serializable]
- class NetSimpleJobResult
- {
- public int Res;
-
- public NetSimpleJobResult(int res)
- {
- Res = res;
- }
- }
-
- [Serializable]
- class ComputeAction : IComputeAction
- {
- [InstanceResource]
- #pragma warning disable 649
- private IIgnite _grid;
-
- public static int InvokeCount;
-
- public static Guid LastNodeId;
-
- public void Invoke()
- {
- Interlocked.Increment(ref InvokeCount);
- LastNodeId = _grid.GetCluster().GetLocalNode().Id;
- }
- }
-
- interface IUserInterface<out T>
- {
- T Invoke();
- }
-
- interface INestedComputeFunc : IComputeFunc<int>
- {
-
- }
-
- [Serializable]
- class ComputeFunc : INestedComputeFunc, IUserInterface<int>
- {
- [InstanceResource]
- private IIgnite _grid;
-
- public static int InvokeCount;
-
- public static Guid LastNodeId;
-
- int IComputeFunc<int>.Invoke()
- {
- InvokeCount++;
- LastNodeId = _grid.GetCluster().GetLocalNode().Id;
- return InvokeCount;
- }
-
- int IUserInterface<int>.Invoke()
- {
- // Same signature as IComputeFunc<int>, but from different interface
- throw new Exception("Invalid method");
- }
-
- public int Invoke()
- {
- // Same signature as IComputeFunc<int>, but due to explicit interface implementation this is a wrong method
- throw new Exception("Invalid method");
- }
- }
-
- public enum InteropComputeEnum
- {
- Foo,
- Bar,
- Baz
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeMultithreadedTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeMultithreadedTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeMultithreadedTest.cs
deleted file mode 100644
index 5b6874f..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeMultithreadedTest.cs
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Compute
-{
- using System;
- using System.Collections.Generic;
- using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Compute;
- using NUnit.Framework;
-
- /// <summary>
- /// Tests class.
- /// </summary>
- [Category(TestUtils.CategoryIntensive)]
- public class ComputeMultithreadedTest : AbstractTaskTest
- {
- /** */
- private static IList<Action<ICompute>> _actions;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- public ComputeMultithreadedTest() : base(false) { }
-
- /// <summary>
- /// Set-up routine.
- /// </summary>
- [SetUp]
- public void SetUp()
- {
- _actions = new List<Action<ICompute>>
- {
- compute => { compute.Apply(new My1ArgClosure(), "zzzz"); },
- compute => { compute.Broadcast(new My1ArgClosure(), "zzzz"); },
- compute => { compute.Broadcast(new MyNoArgClosure("zzzz")); },
- compute => { compute.Call(new MyNoArgClosure("zzzz")); },
- compute => { compute.Execute(new StringLengthEmptyTask(), "zzzz"); },
- compute =>
- {
- compute.Apply(new My1ArgClosure(), new List<string> {"zzzz", "a", "b"}, new MyReducer());
- }
- };
-
- }
-
- /// <summary>
- /// Tear-down routine.
- /// </summary>
- [TearDown]
- public void TearDown()
- {
- _actions.Clear();
- }
-
- /// <summary>
- /// Test not-marshalable error occurred during map step.
- /// </summary>
- [Test]
- public void TestAllTaskTypeAtSameTime()
- {
- Assert.AreEqual(_actions.Count, 6);
-
- var compute = Grid1.GetCompute();
-
- TestUtils.RunMultiThreaded(() =>
- {
- _actions[TestUtils.Random.Next(_actions.Count)](compute);
- }, 4, 60);
- }
-
- /// <summary>
- ///
- /// </summary>
- [Test]
- public void TestSingleTaskType0()
- {
- Assert.AreEqual(_actions.Count, 6);
-
- TestUtils.RunMultiThreaded(() => _actions[0](Grid1.GetCompute()), 4, 20);
- }
-
- /// <summary>
- ///
- /// </summary>
- [Test]
- public void TestSingleTaskType1()
- {
- Assert.AreEqual(_actions.Count, 6);
-
- TestUtils.RunMultiThreaded(() => _actions[1](Grid1.GetCompute()), 4, 20);
- }
-
- /// <summary>
- ///
- /// </summary>
- [Test]
- public void TestSingleTaskType2()
- {
- Assert.AreEqual(_actions.Count, 6);
-
- TestUtils.RunMultiThreaded(() => _actions[2](Grid1.GetCompute()), 4, 20);
- }
-
- /// <summary>
- ///
- /// </summary>
- [Test]
- public void TestSingleTaskType3()
- {
- Assert.AreEqual(_actions.Count, 6);
-
- TestUtils.RunMultiThreaded(() => _actions[3](Grid1.GetCompute()), 4, 20);
- }
- /// <summary>
- ///
- /// </summary>
- [Test]
- public void TestSingleTaskType4()
- {
- Assert.AreEqual(_actions.Count, 6);
-
- TestUtils.RunMultiThreaded(() => _actions[4](Grid1.GetCompute()), 4, 20);
- }
-
- /// <summary>
- ///
- /// </summary>
- [Test]
- public void TestSingleTaskType5()
- {
- Assert.AreEqual(_actions.Count, 6);
-
- TestUtils.RunMultiThreaded(() => _actions[5](Grid1.GetCompute()), 4, 20);
- }
- }
-
- /// <summary>
- /// Test class.
- /// </summary>
- [Serializable]
- public class My1ArgClosure : IComputeFunc<string, int>
- {
- /** <inheritDoc /> */
- public int Invoke(string s)
- {
- return s.Length;
- }
- }
-
- /// <summary>
- /// Test class.
- /// </summary>
- [Serializable]
- public class MyNoArgClosure : IComputeFunc<int>
- {
- /** */
- private readonly string _s;
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="s"></param>
- public MyNoArgClosure(string s)
- {
- _s = s;
- }
-
- /** <inheritDoc /> */
- public int Invoke()
- {
- return _s.Length;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- public class StringLengthEmptyTask : IComputeTask<string, int, int>
- {
- /** <inheritDoc /> */
- public IDictionary<IComputeJob<int>, IClusterNode> Map(IList<IClusterNode> subgrid, string arg)
- {
- var res = new Dictionary<IComputeJob<int>, IClusterNode>();
-
- var job = new StringLengthEmptyJob(arg);
-
- IClusterNode node = subgrid[TestUtils.Random.Next(subgrid.Count)];
-
- res.Add(job, node);
-
- return res;
- }
-
- /** <inheritDoc /> */
- public ComputeJobResultPolicy Result(IComputeJobResult<int> res, IList<IComputeJobResult<int>> rcvd)
- {
- return ComputeJobResultPolicy.Wait;
- }
-
- /** <inheritDoc /> */
- public int Reduce(IList<IComputeJobResult<int>> results)
- {
- return results.Count == 0 ? 0 : results[0].Data();
- }
- }
-
- /// <summary>
- /// Test class.
- /// </summary>
- [Serializable]
- public class StringLengthEmptyJob: IComputeJob<int>
- {
- /** */
- private string _s;
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="s"></param>
- public StringLengthEmptyJob(string s)
- {
- _s = s;
- }
-
- /** <inheritDoc /> */
- public int Execute()
- {
- return _s.Length;
- }
-
- /** <inheritDoc /> */
- public void Cancel()
- {
- // No-op
- }
- }
-
- public class MyReducer : IComputeReducer<int, int>
- {
- /** */
- private int _res;
-
- public bool Collect(int res)
- {
- _res += res;
- return true;
- }
-
- public int Reduce()
- {
- return _res;
- }
- }
-}
[21/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
deleted file mode 100644
index e0dcdaa..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
+++ /dev/null
@@ -1,1181 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
-{
- using System;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
- using System.Linq;
- using System.Runtime.Serialization;
- using System.Threading;
- using Apache.Ignite.Core.Cache;
- using Apache.Ignite.Core.Cache.Event;
- using Apache.Ignite.Core.Cache.Query;
- using Apache.Ignite.Core.Cache.Query.Continuous;
- using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Impl;
- using Apache.Ignite.Core.Portable;
- using Apache.Ignite.Core.Resource;
- using NUnit.Framework;
- using CQU = Apache.Ignite.Core.Impl.Cache.Query.Continuous.ContinuousQueryUtils;
-
- /// <summary>
- /// Tests for continuous query.
- /// </summary>
- [SuppressMessage("ReSharper", "InconsistentNaming")]
- [SuppressMessage("ReSharper", "PossibleNullReferenceException")]
- [SuppressMessage("ReSharper", "StaticMemberInGenericType")]
- public abstract class ContinuousQueryAbstractTest
- {
- /** Cache name: ATOMIC, backup. */
- protected const string CACHE_ATOMIC_BACKUP = "atomic_backup";
-
- /** Cache name: ATOMIC, no backup. */
- protected const string CACHE_ATOMIC_NO_BACKUP = "atomic_no_backup";
-
- /** Cache name: TRANSACTIONAL, backup. */
- protected const string CACHE_TX_BACKUP = "transactional_backup";
-
- /** Cache name: TRANSACTIONAL, no backup. */
- protected const string CACHE_TX_NO_BACKUP = "transactional_no_backup";
-
- /** Listener events. */
- public static BlockingCollection<CallbackEvent> CB_EVTS = new BlockingCollection<CallbackEvent>();
-
- /** Listener events. */
- public static BlockingCollection<FilterEvent> FILTER_EVTS = new BlockingCollection<FilterEvent>();
-
- /** First node. */
- private IIgnite grid1;
-
- /** Second node. */
- private IIgnite grid2;
-
- /** Cache on the first node. */
- private ICache<int, PortableEntry> cache1;
-
- /** Cache on the second node. */
- private ICache<int, PortableEntry> cache2;
-
- /** Cache name. */
- private readonly string cacheName;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="cacheName">Cache name.</param>
- protected ContinuousQueryAbstractTest(string cacheName)
- {
- this.cacheName = cacheName;
- }
-
- /// <summary>
- /// Set-up routine.
- /// </summary>
- [TestFixtureSetUp]
- public void SetUp()
- {
- GC.Collect();
- TestUtils.JvmDebug = true;
-
- IgniteConfigurationEx cfg = new IgniteConfigurationEx();
-
- PortableConfiguration portCfg = new PortableConfiguration();
-
- ICollection<PortableTypeConfiguration> portTypeCfgs = new List<PortableTypeConfiguration>();
-
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableEntry)));
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableFilter)));
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(KeepPortableFilter)));
-
- portCfg.TypeConfigurations = portTypeCfgs;
-
- cfg.PortableConfiguration = portCfg;
- cfg.JvmClasspath = TestUtils.CreateTestClasspath();
- cfg.JvmOptions = TestUtils.TestJavaOptions();
- cfg.SpringConfigUrl = "config\\cache-query-continuous.xml";
-
- cfg.GridName = "grid-1";
- grid1 = Ignition.Start(cfg);
- cache1 = grid1.GetCache<int, PortableEntry>(cacheName);
-
- cfg.GridName = "grid-2";
- grid2 = Ignition.Start(cfg);
- cache2 = grid2.GetCache<int, PortableEntry>(cacheName);
- }
-
- /// <summary>
- /// Tear-down routine.
- /// </summary>
- [TestFixtureTearDown]
- public void TearDown()
- {
- Ignition.StopAll(true);
- }
-
- /// <summary>
- /// Before-test routine.
- /// </summary>
- [SetUp]
- public void BeforeTest()
- {
- CB_EVTS = new BlockingCollection<CallbackEvent>();
- FILTER_EVTS = new BlockingCollection<FilterEvent>();
-
- AbstractFilter<PortableEntry>.res = true;
- AbstractFilter<PortableEntry>.err = false;
- AbstractFilter<PortableEntry>.marshErr = false;
- AbstractFilter<PortableEntry>.unmarshErr = false;
-
- cache1.Remove(PrimaryKey(cache1));
- cache1.Remove(PrimaryKey(cache2));
-
- Assert.AreEqual(0, cache1.GetSize());
- Assert.AreEqual(0, cache2.GetSize());
-
- Console.WriteLine("Test started: " + TestContext.CurrentContext.Test.Name);
- }
-
- /// <summary>
- /// Test arguments validation.
- /// </summary>
- [Test]
- public void TestValidation()
- {
- Assert.Throws<ArgumentException>(() => { cache1.QueryContinuous(new ContinuousQuery<int, PortableEntry>(null)); });
- }
-
- /// <summary>
- /// Test multiple closes.
- /// </summary>
- [Test]
- public void TestMultipleClose()
- {
- int key1 = PrimaryKey(cache1);
- int key2 = PrimaryKey(cache2);
-
- ContinuousQuery<int, PortableEntry> qry =
- new ContinuousQuery<int, PortableEntry>(new Listener<PortableEntry>());
-
- IDisposable qryHnd;
-
- using (qryHnd = cache1.QueryContinuous(qry))
- {
- // Put from local node.
- cache1.GetAndPut(key1, Entry(key1));
- CheckCallbackSingle(key1, null, Entry(key1));
-
- // Put from remote node.
- cache2.GetAndPut(key2, Entry(key2));
- CheckCallbackSingle(key2, null, Entry(key2));
- }
-
- qryHnd.Dispose();
- }
-
- /// <summary>
- /// Test regular callback operations.
- /// </summary>
- [Test]
- public void TestCallback()
- {
- CheckCallback(false);
- }
-
- /// <summary>
- /// Check regular callback execution.
- /// </summary>
- /// <param name="loc"></param>
- protected void CheckCallback(bool loc)
- {
- int key1 = PrimaryKey(cache1);
- int key2 = PrimaryKey(cache2);
-
- ContinuousQuery<int, PortableEntry> qry = loc ?
- new ContinuousQuery<int, PortableEntry>(new Listener<PortableEntry>(), true) :
- new ContinuousQuery<int, PortableEntry>(new Listener<PortableEntry>());
-
- using (cache1.QueryContinuous(qry))
- {
- // Put from local node.
- cache1.GetAndPut(key1, Entry(key1));
- CheckCallbackSingle(key1, null, Entry(key1));
-
- cache1.GetAndPut(key1, Entry(key1 + 1));
- CheckCallbackSingle(key1, Entry(key1), Entry(key1 + 1));
-
- cache1.Remove(key1);
- CheckCallbackSingle(key1, Entry(key1 + 1), null);
-
- // Put from remote node.
- cache2.GetAndPut(key2, Entry(key2));
-
- if (loc)
- CheckNoCallback(100);
- else
- CheckCallbackSingle(key2, null, Entry(key2));
-
- cache1.GetAndPut(key2, Entry(key2 + 1));
-
- if (loc)
- CheckNoCallback(100);
- else
- CheckCallbackSingle(key2, Entry(key2), Entry(key2 + 1));
-
- cache1.Remove(key2);
-
- if (loc)
- CheckNoCallback(100);
- else
- CheckCallbackSingle(key2, Entry(key2 + 1), null);
- }
-
- cache1.Put(key1, Entry(key1));
- CheckNoCallback(100);
-
- cache1.Put(key2, Entry(key2));
- CheckNoCallback(100);
- }
-
- /// <summary>
- /// Test Ignite injection into callback.
- /// </summary>
- [Test]
- public void TestCallbackInjection()
- {
- Listener<PortableEntry> cb = new Listener<PortableEntry>();
-
- Assert.IsNull(cb.ignite);
-
- using (cache1.QueryContinuous(new ContinuousQuery<int, PortableEntry>(cb)))
- {
- Assert.IsNotNull(cb.ignite);
- }
- }
-
- /// <summary>
- /// Test portable filter logic.
- /// </summary>
- [Test]
- public void TestFilterPortable()
- {
- CheckFilter(true, false);
- }
-
- /// <summary>
- /// Test serializable filter logic.
- /// </summary>
- [Test]
- public void TestFilterSerializable()
- {
- CheckFilter(false, false);
- }
-
- /// <summary>
- /// Check filter.
- /// </summary>
- /// <param name="portable">Portable.</param>
- /// <param name="loc">Local cache flag.</param>
- protected void CheckFilter(bool portable, bool loc)
- {
- ICacheEntryEventListener<int, PortableEntry> lsnr = new Listener<PortableEntry>();
- ICacheEntryEventFilter<int, PortableEntry> filter =
- portable ? (AbstractFilter<PortableEntry>)new PortableFilter() : new SerializableFilter();
-
- ContinuousQuery<int, PortableEntry> qry = loc ?
- new ContinuousQuery<int, PortableEntry>(lsnr, filter, true) :
- new ContinuousQuery<int, PortableEntry>(lsnr, filter);
-
- using (cache1.QueryContinuous(qry))
- {
- // Put from local node.
- int key1 = PrimaryKey(cache1);
- cache1.GetAndPut(key1, Entry(key1));
- CheckFilterSingle(key1, null, Entry(key1));
- CheckCallbackSingle(key1, null, Entry(key1));
-
- // Put from remote node.
- int key2 = PrimaryKey(cache2);
- cache1.GetAndPut(key2, Entry(key2));
-
- if (loc)
- {
- CheckNoFilter(key2);
- CheckNoCallback(key2);
- }
- else
- {
- CheckFilterSingle(key2, null, Entry(key2));
- CheckCallbackSingle(key2, null, Entry(key2));
- }
-
- AbstractFilter<PortableEntry>.res = false;
-
- // Ignored put from local node.
- cache1.GetAndPut(key1, Entry(key1 + 1));
- CheckFilterSingle(key1, Entry(key1), Entry(key1 + 1));
- CheckNoCallback(100);
-
- // Ignored put from remote node.
- cache1.GetAndPut(key2, Entry(key2 + 1));
-
- if (loc)
- CheckNoFilter(100);
- else
- CheckFilterSingle(key2, Entry(key2), Entry(key2 + 1));
-
- CheckNoCallback(100);
- }
- }
-
- /// <summary>
- /// Test portable filter error during invoke.
- /// </summary>
- [Ignore("IGNITE-521")]
- [Test]
- public void TestFilterInvokeErrorPortable()
- {
- CheckFilterInvokeError(true);
- }
-
- /// <summary>
- /// Test serializable filter error during invoke.
- /// </summary>
- [Ignore("IGNITE-521")]
- [Test]
- public void TestFilterInvokeErrorSerializable()
- {
- CheckFilterInvokeError(false);
- }
-
- /// <summary>
- /// Check filter error handling logic during invoke.
- /// </summary>
- private void CheckFilterInvokeError(bool portable)
- {
- AbstractFilter<PortableEntry>.err = true;
-
- ICacheEntryEventListener<int, PortableEntry> lsnr = new Listener<PortableEntry>();
- ICacheEntryEventFilter<int, PortableEntry> filter =
- portable ? (AbstractFilter<PortableEntry>) new PortableFilter() : new SerializableFilter();
-
- ContinuousQuery<int, PortableEntry> qry = new ContinuousQuery<int, PortableEntry>(lsnr, filter);
-
- using (cache1.QueryContinuous(qry))
- {
- // Put from local node.
- try
- {
- cache1.GetAndPut(PrimaryKey(cache1), Entry(1));
-
- Assert.Fail("Should not reach this place.");
- }
- catch (IgniteException)
- {
- // No-op.
- }
- catch (Exception)
- {
- Assert.Fail("Unexpected error.");
- }
-
- // Put from remote node.
- try
- {
- cache1.GetAndPut(PrimaryKey(cache2), Entry(1));
-
- Assert.Fail("Should not reach this place.");
- }
- catch (IgniteException)
- {
- // No-op.
- }
- catch (Exception)
- {
- Assert.Fail("Unexpected error.");
- }
- }
- }
-
- /// <summary>
- /// Test portable filter marshalling error.
- /// </summary>
- [Test]
- public void TestFilterMarshalErrorPortable()
- {
- CheckFilterMarshalError(true);
- }
-
- /// <summary>
- /// Test serializable filter marshalling error.
- /// </summary>
- [Test]
- public void TestFilterMarshalErrorSerializable()
- {
- CheckFilterMarshalError(false);
- }
-
- /// <summary>
- /// Check filter marshal error handling.
- /// </summary>
- /// <param name="portable">Portable flag.</param>
- private void CheckFilterMarshalError(bool portable)
- {
- AbstractFilter<PortableEntry>.marshErr = true;
-
- ICacheEntryEventListener<int, PortableEntry> lsnr = new Listener<PortableEntry>();
- ICacheEntryEventFilter<int, PortableEntry> filter =
- portable ? (AbstractFilter<PortableEntry>)new PortableFilter() : new SerializableFilter();
-
- ContinuousQuery<int, PortableEntry> qry = new ContinuousQuery<int, PortableEntry>(lsnr, filter);
-
- Assert.Throws<Exception>(() =>
- {
- using (cache1.QueryContinuous(qry))
- {
- // No-op.
- }
- });
- }
-
- /// <summary>
- /// Test non-serializable filter error.
- /// </summary>
- [Test]
- public void TestFilterNonSerializable()
- {
- CheckFilterNonSerializable(false);
- }
-
- /// <summary>
- /// Test non-serializable filter behavior.
- /// </summary>
- /// <param name="loc"></param>
- protected void CheckFilterNonSerializable(bool loc)
- {
- AbstractFilter<PortableEntry>.unmarshErr = true;
-
- ICacheEntryEventListener<int, PortableEntry> lsnr = new Listener<PortableEntry>();
- ICacheEntryEventFilter<int, PortableEntry> filter = new LocalFilter();
-
- ContinuousQuery<int, PortableEntry> qry = loc
- ? new ContinuousQuery<int, PortableEntry>(lsnr, filter, true)
- : new ContinuousQuery<int, PortableEntry>(lsnr, filter);
-
- if (loc)
- {
- using (cache1.QueryContinuous(qry))
- {
- // Local put must be fine.
- int key1 = PrimaryKey(cache1);
- cache1.GetAndPut(key1, Entry(key1));
- CheckFilterSingle(key1, null, Entry(key1));
- }
- }
- else
- {
- Assert.Throws<SerializationException>(() =>
- {
- using (cache1.QueryContinuous(qry))
- {
- // No-op.
- }
- });
- }
- }
-
- /// <summary>
- /// Test portable filter unmarshalling error.
- /// </summary>
- [Ignore("IGNITE-521")]
- [Test]
- public void TestFilterUnmarshalErrorPortable()
- {
- CheckFilterUnmarshalError(true);
- }
-
- /// <summary>
- /// Test serializable filter unmarshalling error.
- /// </summary>
- [Ignore("IGNITE-521")]
- [Test]
- public void TestFilterUnmarshalErrorSerializable()
- {
- CheckFilterUnmarshalError(false);
- }
-
- /// <summary>
- /// Check filter unmarshal error handling.
- /// </summary>
- /// <param name="portable">Portable flag.</param>
- private void CheckFilterUnmarshalError(bool portable)
- {
- AbstractFilter<PortableEntry>.unmarshErr = true;
-
- ICacheEntryEventListener<int, PortableEntry> lsnr = new Listener<PortableEntry>();
- ICacheEntryEventFilter<int, PortableEntry> filter =
- portable ? (AbstractFilter<PortableEntry>)new PortableFilter() : new SerializableFilter();
-
- ContinuousQuery<int, PortableEntry> qry = new ContinuousQuery<int, PortableEntry>(lsnr, filter);
-
- using (cache1.QueryContinuous(qry))
- {
- // Local put must be fine.
- int key1 = PrimaryKey(cache1);
- cache1.GetAndPut(key1, Entry(key1));
- CheckFilterSingle(key1, null, Entry(key1));
-
- // Remote put must fail.
- try
- {
- cache1.GetAndPut(PrimaryKey(cache2), Entry(1));
-
- Assert.Fail("Should not reach this place.");
- }
- catch (IgniteException)
- {
- // No-op.
- }
- catch (Exception)
- {
- Assert.Fail("Unexpected error.");
- }
- }
- }
-
- /// <summary>
- /// Test Ignite injection into filters.
- /// </summary>
- [Test]
- public void TestFilterInjection()
- {
- Listener<PortableEntry> cb = new Listener<PortableEntry>();
- PortableFilter filter = new PortableFilter();
-
- Assert.IsNull(filter.ignite);
-
- using (cache1.QueryContinuous(new ContinuousQuery<int, PortableEntry>(cb, filter)))
- {
- // Local injection.
- Assert.IsNotNull(filter.ignite);
-
- // Remote injection.
- cache1.GetAndPut(PrimaryKey(cache2), Entry(1));
-
- FilterEvent evt;
-
- Assert.IsTrue(FILTER_EVTS.TryTake(out evt, 500));
-
- Assert.IsNotNull(evt.ignite);
- }
- }
-
-
- /// <summary>
- /// Test "keep-portable" scenario.
- /// </summary>
- [Test]
- public void TestKeepPortable()
- {
- var cache = cache1.WithKeepPortable<int, IPortableObject>();
-
- ContinuousQuery<int, IPortableObject> qry = new ContinuousQuery<int, IPortableObject>(
- new Listener<IPortableObject>(), new KeepPortableFilter());
-
- using (cache.QueryContinuous(qry))
- {
- // 1. Local put.
- cache1.GetAndPut(PrimaryKey(cache1), Entry(1));
-
- CallbackEvent cbEvt;
- FilterEvent filterEvt;
-
- Assert.IsTrue(FILTER_EVTS.TryTake(out filterEvt, 500));
- Assert.AreEqual(PrimaryKey(cache1), filterEvt.entry.Key);
- Assert.AreEqual(null, filterEvt.entry.OldValue);
- Assert.AreEqual(Entry(1), (filterEvt.entry.Value as IPortableObject)
- .Deserialize<PortableEntry>());
-
- Assert.IsTrue(CB_EVTS.TryTake(out cbEvt, 500));
- Assert.AreEqual(1, cbEvt.entries.Count);
- Assert.AreEqual(PrimaryKey(cache1), cbEvt.entries.First().Key);
- Assert.AreEqual(null, cbEvt.entries.First().OldValue);
- Assert.AreEqual(Entry(1), (cbEvt.entries.First().Value as IPortableObject)
- .Deserialize<PortableEntry>());
-
- // 2. Remote put.
- cache1.GetAndPut(PrimaryKey(cache2), Entry(2));
-
- Assert.IsTrue(FILTER_EVTS.TryTake(out filterEvt, 500));
- Assert.AreEqual(PrimaryKey(cache2), filterEvt.entry.Key);
- Assert.AreEqual(null, filterEvt.entry.OldValue);
- Assert.AreEqual(Entry(2), (filterEvt.entry.Value as IPortableObject)
- .Deserialize<PortableEntry>());
-
- Assert.IsTrue(CB_EVTS.TryTake(out cbEvt, 500));
- Assert.AreEqual(1, cbEvt.entries.Count);
- Assert.AreEqual(PrimaryKey(cache2), cbEvt.entries.First().Key);
- Assert.AreEqual(null, cbEvt.entries.First().OldValue);
- Assert.AreEqual(Entry(2),
- (cbEvt.entries.First().Value as IPortableObject).Deserialize<PortableEntry>());
- }
- }
-
- /// <summary>
- /// Test whether buffer size works fine.
- /// </summary>
- [Test]
- public void TestBufferSize()
- {
- // Put two remote keys in advance.
- List<int> rmtKeys = PrimaryKeys(cache2, 2);
-
- ContinuousQuery<int, PortableEntry> qry = new ContinuousQuery<int, PortableEntry>(new Listener<PortableEntry>());
-
- qry.BufferSize = 2;
- qry.TimeInterval = TimeSpan.FromMilliseconds(1000000);
-
- using (cache1.QueryContinuous(qry))
- {
- qry.BufferSize = 2;
-
- cache1.GetAndPut(rmtKeys[0], Entry(rmtKeys[0]));
-
- CheckNoCallback(100);
-
- cache1.GetAndPut(rmtKeys[1], Entry(rmtKeys[1]));
-
- CallbackEvent evt;
-
- Assert.IsTrue(CB_EVTS.TryTake(out evt, 1000));
-
- Assert.AreEqual(2, evt.entries.Count);
-
- var entryRmt0 = evt.entries.Single(entry => { return entry.Key.Equals(rmtKeys[0]); });
- var entryRmt1 = evt.entries.Single(entry => { return entry.Key.Equals(rmtKeys[1]); });
-
- Assert.AreEqual(rmtKeys[0], entryRmt0.Key);
- Assert.IsNull(entryRmt0.OldValue);
- Assert.AreEqual(Entry(rmtKeys[0]), entryRmt0.Value);
-
- Assert.AreEqual(rmtKeys[1], entryRmt1.Key);
- Assert.IsNull(entryRmt1.OldValue);
- Assert.AreEqual(Entry(rmtKeys[1]), entryRmt1.Value);
- }
-
- cache1.Remove(rmtKeys[0]);
- cache1.Remove(rmtKeys[1]);
- }
-
- /// <summary>
- /// Test whether timeout works fine.
- /// </summary>
- [Test]
- public void TestTimeout()
- {
- int key1 = PrimaryKey(cache1);
- int key2 = PrimaryKey(cache2);
-
- ContinuousQuery<int, PortableEntry> qry =
- new ContinuousQuery<int, PortableEntry>(new Listener<PortableEntry>());
-
- qry.BufferSize = 2;
- qry.TimeInterval = TimeSpan.FromMilliseconds(500);
-
- using (cache1.QueryContinuous(qry))
- {
- // Put from local node.
- cache1.GetAndPut(key1, Entry(key1));
- CheckCallbackSingle(key1, null, Entry(key1));
-
- // Put from remote node.
- cache1.GetAndPut(key2, Entry(key2));
- CheckNoCallback(100);
- CheckCallbackSingle(key2, null, Entry(key2), 1000);
- }
- }
-
- /// <summary>
- /// Test whether nested Ignite API call from callback works fine.
- /// </summary>
- [Test]
- public void TestNestedCallFromCallback()
- {
- var cache = cache1.WithKeepPortable<int, IPortableObject>();
-
- int key = PrimaryKey(cache1);
-
- NestedCallListener cb = new NestedCallListener();
-
- using (cache.QueryContinuous(new ContinuousQuery<int, IPortableObject>(cb)))
- {
- cache1.GetAndPut(key, Entry(key));
-
- cb.countDown.Wait();
- }
-
- cache.Remove(key);
- }
-
- /// <summary>
- /// Tests the initial query.
- /// </summary>
- [Test]
- public void TestInitialQuery()
- {
- // Scan query, GetAll
- TestInitialQuery(new ScanQuery<int, PortableEntry>(new InitialQueryScanFilter()), cur => cur.GetAll());
-
- // Scan query, iterator
- TestInitialQuery(new ScanQuery<int, PortableEntry>(new InitialQueryScanFilter()), cur => cur.ToList());
-
- // Sql query, GetAll
- TestInitialQuery(new SqlQuery(typeof(PortableEntry), "val < 33"), cur => cur.GetAll());
-
- // Sql query, iterator
- TestInitialQuery(new SqlQuery(typeof(PortableEntry), "val < 33"), cur => cur.ToList());
-
- // Text query, GetAll
- TestInitialQuery(new TextQuery(typeof(PortableEntry), "1*"), cur => cur.GetAll());
-
- // Text query, iterator
- TestInitialQuery(new TextQuery(typeof(PortableEntry), "1*"), cur => cur.ToList());
-
- // Test exception: invalid initial query
- var ex = Assert.Throws<IgniteException>(
- () => TestInitialQuery(new TextQuery(typeof (PortableEntry), "*"), cur => cur.GetAll()));
-
- Assert.AreEqual("Cannot parse '*': '*' or '?' not allowed as first character in WildcardQuery", ex.Message);
- }
-
- /// <summary>
- /// Tests the initial query.
- /// </summary>
- private void TestInitialQuery(QueryBase initialQry, Func<IQueryCursor<ICacheEntry<int, PortableEntry>>,
- IEnumerable<ICacheEntry<int, PortableEntry>>> getAllFunc)
- {
- var qry = new ContinuousQuery<int, PortableEntry>(new Listener<PortableEntry>());
-
- cache1.Put(11, Entry(11));
- cache1.Put(12, Entry(12));
- cache1.Put(33, Entry(33));
-
- try
- {
- IContinuousQueryHandle<ICacheEntry<int, PortableEntry>> contQry;
-
- using (contQry = cache1.QueryContinuous(qry, initialQry))
- {
- // Check initial query
- var initialEntries =
- getAllFunc(contQry.GetInitialQueryCursor()).Distinct().OrderBy(x => x.Key).ToList();
-
- Assert.Throws<InvalidOperationException>(() => contQry.GetInitialQueryCursor());
-
- Assert.AreEqual(2, initialEntries.Count);
-
- for (int i = 0; i < initialEntries.Count; i++)
- {
- Assert.AreEqual(i + 11, initialEntries[i].Key);
- Assert.AreEqual(i + 11, initialEntries[i].Value.val);
- }
-
- // Check continuous query
- cache1.Put(44, Entry(44));
- CheckCallbackSingle(44, null, Entry(44));
- }
-
- Assert.Throws<ObjectDisposedException>(() => contQry.GetInitialQueryCursor());
-
- contQry.Dispose(); // multiple dispose calls are ok
- }
- finally
- {
- cache1.Clear();
- }
- }
-
- /// <summary>
- /// Check single filter event.
- /// </summary>
- /// <param name="expKey">Expected key.</param>
- /// <param name="expOldVal">Expected old value.</param>
- /// <param name="expVal">Expected value.</param>
- private void CheckFilterSingle(int expKey, PortableEntry expOldVal, PortableEntry expVal)
- {
- CheckFilterSingle(expKey, expOldVal, expVal, 1000);
- }
-
- /// <summary>
- /// Check single filter event.
- /// </summary>
- /// <param name="expKey">Expected key.</param>
- /// <param name="expOldVal">Expected old value.</param>
- /// <param name="expVal">Expected value.</param>
- /// <param name="timeout">Timeout.</param>
- private void CheckFilterSingle(int expKey, PortableEntry expOldVal, PortableEntry expVal, int timeout)
- {
- FilterEvent evt;
-
- Assert.IsTrue(FILTER_EVTS.TryTake(out evt, timeout));
-
- Assert.AreEqual(expKey, evt.entry.Key);
- Assert.AreEqual(expOldVal, evt.entry.OldValue);
- Assert.AreEqual(expVal, evt.entry.Value);
- }
-
- /// <summary>
- /// Ensure that no filter events are logged.
- /// </summary>
- /// <param name="timeout">Timeout.</param>
- private void CheckNoFilter(int timeout)
- {
- FilterEvent evt;
-
- Assert.IsFalse(FILTER_EVTS.TryTake(out evt, timeout));
- }
-
- /// <summary>
- /// Check single callback event.
- /// </summary>
- /// <param name="expKey">Expected key.</param>
- /// <param name="expOldVal">Expected old value.</param>
- /// <param name="expVal">Expected new value.</param>
- private void CheckCallbackSingle(int expKey, PortableEntry expOldVal, PortableEntry expVal)
- {
- CheckCallbackSingle(expKey, expOldVal, expVal, 1000);
- }
-
- /// <summary>
- /// Check single callback event.
- /// </summary>
- /// <param name="expKey">Expected key.</param>
- /// <param name="expOldVal">Expected old value.</param>
- /// <param name="expVal">Expected new value.</param>
- /// <param name="timeout">Timeout.</param>
- private void CheckCallbackSingle(int expKey, PortableEntry expOldVal, PortableEntry expVal, int timeout)
- {
- CallbackEvent evt;
-
- Assert.IsTrue(CB_EVTS.TryTake(out evt, timeout));
-
- Assert.AreEqual(1, evt.entries.Count);
-
- Assert.AreEqual(expKey, evt.entries.First().Key);
- Assert.AreEqual(expOldVal, evt.entries.First().OldValue);
- Assert.AreEqual(expVal, evt.entries.First().Value);
- }
-
- /// <summary>
- /// Ensure that no callback events are logged.
- /// </summary>
- /// <param name="timeout">Timeout.</param>
- private void CheckNoCallback(int timeout)
- {
- CallbackEvent evt;
-
- Assert.IsFalse(CB_EVTS.TryTake(out evt, timeout));
- }
-
- /// <summary>
- /// Craate entry.
- /// </summary>
- /// <param name="val">Value.</param>
- /// <returns>Entry.</returns>
- private static PortableEntry Entry(int val)
- {
- return new PortableEntry(val);
- }
-
- /// <summary>
- /// Get primary key for cache.
- /// </summary>
- /// <param name="cache">Cache.</param>
- /// <returns>Primary key.</returns>
- private static int PrimaryKey<T>(ICache<int, T> cache)
- {
- return PrimaryKeys(cache, 1)[0];
- }
-
- /// <summary>
- /// Get primary keys for cache.
- /// </summary>
- /// <param name="cache">Cache.</param>
- /// <param name="cnt">Amount of keys.</param>
- /// <param name="startFrom">Value to start from.</param>
- /// <returns></returns>
- private static List<int> PrimaryKeys<T>(ICache<int, T> cache, int cnt, int startFrom = 0)
- {
- IClusterNode node = cache.Ignite.GetCluster().GetLocalNode();
-
- ICacheAffinity aff = cache.Ignite.GetAffinity(cache.Name);
-
- List<int> keys = new List<int>(cnt);
-
- for (int i = startFrom; i < startFrom + 100000; i++)
- {
- if (aff.IsPrimary(node, i))
- {
- keys.Add(i);
-
- if (keys.Count == cnt)
- return keys;
- }
- }
-
- Assert.Fail("Failed to find " + cnt + " primary keys.");
-
- return null;
- }
-
- /// <summary>
- /// Portable entry.
- /// </summary>
- public class PortableEntry
- {
- /** Value. */
- public readonly int val;
-
- /** <inheritDot /> */
- public override int GetHashCode()
- {
- return val;
- }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="val">Value.</param>
- public PortableEntry(int val)
- {
- this.val = val;
- }
-
- /** <inheritDoc /> */
- public override bool Equals(object obj)
- {
- return obj != null && obj is PortableEntry && ((PortableEntry)obj).val == val;
- }
- }
-
- /// <summary>
- /// Abstract filter.
- /// </summary>
- [Serializable]
- public abstract class AbstractFilter<V> : ICacheEntryEventFilter<int, V>
- {
- /** Result. */
- public static volatile bool res = true;
-
- /** Throw error on invocation. */
- public static volatile bool err;
-
- /** Throw error during marshalling. */
- public static volatile bool marshErr;
-
- /** Throw error during unmarshalling. */
- public static volatile bool unmarshErr;
-
- /** Grid. */
- [InstanceResource]
- public IIgnite ignite;
-
- /** <inheritDoc /> */
- public bool Evaluate(ICacheEntryEvent<int, V> evt)
- {
- if (err)
- throw new Exception("Filter error.");
-
- FILTER_EVTS.Add(new FilterEvent(ignite,
- CQU.CreateEvent<object, object>(evt.Key, evt.OldValue, evt.Value)));
-
- return res;
- }
- }
-
- /// <summary>
- /// Filter which cannot be serialized.
- /// </summary>
- public class LocalFilter : AbstractFilter<PortableEntry>
- {
- // No-op.
- }
-
- /// <summary>
- /// Portable filter.
- /// </summary>
- public class PortableFilter : AbstractFilter<PortableEntry>, IPortableMarshalAware
- {
- /** <inheritDoc /> */
- public void WritePortable(IPortableWriter writer)
- {
- if (marshErr)
- throw new Exception("Filter marshalling error.");
- }
-
- /** <inheritDoc /> */
- public void ReadPortable(IPortableReader reader)
- {
- if (unmarshErr)
- throw new Exception("Filter unmarshalling error.");
- }
- }
-
- /// <summary>
- /// Serializable filter.
- /// </summary>
- [Serializable]
- public class SerializableFilter : AbstractFilter<PortableEntry>, ISerializable
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- public SerializableFilter()
- {
- // No-op.
- }
-
- /// <summary>
- /// Serialization constructor.
- /// </summary>
- /// <param name="info">Info.</param>
- /// <param name="context">Context.</param>
- protected SerializableFilter(SerializationInfo info, StreamingContext context)
- {
- if (unmarshErr)
- throw new Exception("Filter unmarshalling error.");
- }
-
- /** <inheritDoc /> */
- public void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- if (marshErr)
- throw new Exception("Filter marshalling error.");
- }
- }
-
- /// <summary>
- /// Filter for "keep-portable" scenario.
- /// </summary>
- public class KeepPortableFilter : AbstractFilter<IPortableObject>
- {
- // No-op.
- }
-
- /// <summary>
- /// Listener.
- /// </summary>
- public class Listener<V> : ICacheEntryEventListener<int, V>
- {
- [InstanceResource]
- public IIgnite ignite;
-
- /** <inheritDoc /> */
- public void OnEvent(IEnumerable<ICacheEntryEvent<int, V>> evts)
- {
- ICollection<ICacheEntryEvent<object, object>> entries0 =
- new List<ICacheEntryEvent<object, object>>();
-
- foreach (ICacheEntryEvent<int, V> evt in evts)
- entries0.Add(CQU.CreateEvent<object, object>(evt.Key, evt.OldValue, evt.Value));
-
- CB_EVTS.Add(new CallbackEvent(entries0));
- }
- }
-
- /// <summary>
- /// Listener with nested Ignite API call.
- /// </summary>
- public class NestedCallListener : ICacheEntryEventListener<int, IPortableObject>
- {
- /** Event. */
- public readonly CountdownEvent countDown = new CountdownEvent(1);
-
- public void OnEvent(IEnumerable<ICacheEntryEvent<int, IPortableObject>> evts)
- {
- foreach (ICacheEntryEvent<int, IPortableObject> evt in evts)
- {
- IPortableObject val = evt.Value;
-
- IPortableMetadata meta = val.GetMetadata();
-
- Assert.AreEqual(typeof(PortableEntry).Name, meta.TypeName);
- }
-
- countDown.Signal();
- }
- }
-
- /// <summary>
- /// Filter event.
- /// </summary>
- public class FilterEvent
- {
- /** Grid. */
- public IIgnite ignite;
-
- /** Entry. */
- public ICacheEntryEvent<object, object> entry;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="ignite">Grid.</param>
- /// <param name="entry">Entry.</param>
- public FilterEvent(IIgnite ignite, ICacheEntryEvent<object, object> entry)
- {
- this.ignite = ignite;
- this.entry = entry;
- }
- }
-
- /// <summary>
- /// Callbakc event.
- /// </summary>
- public class CallbackEvent
- {
- /** Entries. */
- public ICollection<ICacheEntryEvent<object, object>> entries;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="entries">Entries.</param>
- public CallbackEvent(ICollection<ICacheEntryEvent<object, object>> entries)
- {
- this.entries = entries;
- }
- }
-
- /// <summary>
- /// ScanQuery filter for InitialQuery test.
- /// </summary>
- [Serializable]
- private class InitialQueryScanFilter : ICacheEntryFilter<int, PortableEntry>
- {
- /** <inheritdoc /> */
- public bool Invoke(ICacheEntry<int, PortableEntry> entry)
- {
- return entry.Key < 33;
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAtomicBackupTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAtomicBackupTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAtomicBackupTest.cs
deleted file mode 100644
index ac44f10..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAtomicBackupTest.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
-{
- /// <summary>
- /// Continuous query tests for ATOMIC cache with backups.
- /// </summary>
- public class ContinuousQueryAtomiclBackupTest : ContinuousQueryAbstractTest
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- public ContinuousQueryAtomiclBackupTest() : base(CACHE_ATOMIC_BACKUP)
- {
- // No-op.
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAtomicNoBackupTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAtomicNoBackupTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAtomicNoBackupTest.cs
deleted file mode 100644
index 8e1a18f..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAtomicNoBackupTest.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
-{
- /// <summary>
- /// Continuous query tests for ATOMIC cache with no backups.
- /// </summary>
- public class ContinuousQueryAtomiclNoBackupTest : ContinuousQueryNoBackupAbstractTest
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- public ContinuousQueryAtomiclNoBackupTest()
- : base(CACHE_ATOMIC_NO_BACKUP)
- {
- // No-op.
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryNoBackupAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryNoBackupAbstractTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryNoBackupAbstractTest.cs
deleted file mode 100644
index aa7d627..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryNoBackupAbstractTest.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
-{
- using NUnit.Framework;
-
- /// <summary>
- /// Tests for ocntinuous query when there are no backups.
- /// </summary>
- public abstract class ContinuousQueryNoBackupAbstractTest : ContinuousQueryAbstractTest
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="cacheName">Cache name.</param>
- protected ContinuousQueryNoBackupAbstractTest(string cacheName) : base(cacheName)
- {
- // No-op.
- }
-
- /// <summary>
- /// Test regular callback operations for local query.
- /// </summary>
- [Test]
- public void TestCallbackLocal()
- {
- CheckCallback(true);
- }
-
- /// <summary>
- /// Test portable filter logic.
- /// </summary>
- [Test]
- public void TestFilterPortableLocal()
- {
- CheckFilter(true, true);
- }
-
- /// <summary>
- /// Test serializable filter logic.
- /// </summary>
- [Test]
- public void TestFilterSerializableLocal()
- {
- CheckFilter(false, true);
- }
-
- /// <summary>
- /// Test non-serializable filter for local query.
- /// </summary>
- [Test]
- public void TestFilterNonSerializableLocal()
- {
- CheckFilterNonSerializable(true);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTransactionalBackupTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTransactionalBackupTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTransactionalBackupTest.cs
deleted file mode 100644
index 08ae88c..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTransactionalBackupTest.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
-{
- /// <summary>
- /// Continuous query tests for TRANSACTIONAL cache with backups.
- /// </summary>
- public class ContinuousQueryTransactionalBackupTest : ContinuousQueryAbstractTest
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- public ContinuousQueryTransactionalBackupTest()
- : base(CACHE_TX_BACKUP)
- {
- // No-op.
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTransactionalNoBackupTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTransactionalNoBackupTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTransactionalNoBackupTest.cs
deleted file mode 100644
index 685f7b4..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTransactionalNoBackupTest.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
-{
- /// <summary>
- /// Continuous query tests for TRANSACTIONAL cache with no backups.
- /// </summary>
- public class ContinuousQueryTransactionalNoBackupTest : ContinuousQueryNoBackupAbstractTest
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- public ContinuousQueryTransactionalNoBackupTest() : base(CACHE_TX_NO_BACKUP)
- {
- // No-op.
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheParallelLoadStoreTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheParallelLoadStoreTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheParallelLoadStoreTest.cs
deleted file mode 100644
index a7d9adb..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheParallelLoadStoreTest.cs
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache.Store
-{
- using System;
- using Apache.Ignite.Core.Cache;
- using Apache.Ignite.Core.Portable;
- using NUnit.Framework;
-
- /// <summary>
- /// Tests for GridCacheParallelLoadStoreAdapter.
- /// </summary>
- public class CacheParallelLoadStoreTest
- {
- // object store name
- private const string ObjectStoreCacheName = "object_store_parallel";
-
- /// <summary>
- /// Set up test class.
- /// </summary>
- [TestFixtureSetUp]
- public virtual void BeforeTests()
- {
- TestUtils.KillProcesses();
- TestUtils.JvmDebug = true;
-
- Ignition.Start(new IgniteConfiguration
- {
- JvmClasspath = TestUtils.CreateTestClasspath(),
- JvmOptions = TestUtils.TestJavaOptions(),
- SpringConfigUrl = "config\\native-client-test-cache-parallel-store.xml",
- PortableConfiguration = new PortableConfiguration
- {
- Types = new[] {typeof (CacheTestParallelLoadStore.Record).FullName}
- }
- });
- }
-
- /// <summary>
- /// Tear down test class.
- /// </summary>
- [TestFixtureTearDown]
- public virtual void AfterTests()
- {
- Ignition.StopAll(true);
- }
-
- /// <summary>
- /// Test setup.
- /// </summary>
- [SetUp]
- public void BeforeTest()
- {
- Console.WriteLine("Test started: " + TestContext.CurrentContext.Test.Name);
- }
-
- /// <summary>
- /// Tests the LoadCache.
- /// </summary>
- [Test]
- public void TestLoadCache()
- {
- var cache = GetCache();
-
- Assert.AreEqual(0, cache.GetSize());
-
- const int minId = 113;
- const int expectedItemCount = CacheTestParallelLoadStore.InputDataLength - minId;
-
- CacheTestParallelLoadStore.ResetCounters();
-
- cache.LocalLoadCache(null, minId);
-
- Assert.AreEqual(expectedItemCount, cache.GetSize());
-
- // check items presence; increment by 100 to speed up the test
- for (var i = minId; i < expectedItemCount; i += 100)
- {
- var rec = cache.Get(i);
- Assert.AreEqual(i, rec.Id);
- }
-
- // check that items were processed in parallel
- Assert.GreaterOrEqual(CacheTestParallelLoadStore.UniqueThreadCount, Environment.ProcessorCount);
- }
-
- /// <summary>
- /// Gets the cache.
- /// </summary>
- private static ICache<int, CacheTestParallelLoadStore.Record> GetCache()
- {
- return Ignition.GetIgnite().GetCache<int, CacheTestParallelLoadStore.Record>(ObjectStoreCacheName);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs
deleted file mode 100644
index 137215e..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache.Store
-{
- using System;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Linq;
- using Apache.Ignite.Core.Cache.Store;
- using Apache.Ignite.Core.Impl;
- using Apache.Ignite.Core.Resource;
- using NUnit.Framework;
-
- /// <summary>
- /// Tests for store session.
- /// </summary>
- public class CacheStoreSessionTest
- {
- /** Grid name. */
- private const string IgniteName = "grid";
-
- /** Cache 1 name. */
- private const string Cache1 = "cache1";
-
- /** Cache 2 name. */
- private const string Cache2 = "cache2";
-
- /** Operations. */
- private static ConcurrentBag<ICollection<Operation>> _dumps;
-
- /// <summary>
- /// Set up routine.
- /// </summary>
- [TestFixtureSetUp]
- public virtual void BeforeTests()
- {
- //TestUtils.JVM_DEBUG = true;
-
- TestUtils.KillProcesses();
-
- TestUtils.JvmDebug = true;
-
- IgniteConfigurationEx cfg = new IgniteConfigurationEx
- {
- GridName = IgniteName,
- JvmClasspath = TestUtils.CreateTestClasspath(),
- JvmOptions = TestUtils.TestJavaOptions(),
- SpringConfigUrl = @"config\cache\store\cache-store-session.xml"
- };
-
-
- Ignition.Start(cfg);
- }
-
- /// <summary>
- /// Tear down routine.
- /// </summary>
- [TestFixtureTearDown]
- public virtual void AfterTests()
- {
- Ignition.StopAll(true);
- }
-
- /// <summary>
- /// Test basic session API.
- /// </summary>
- [Test]
- public void TestSession()
- {
- _dumps = new ConcurrentBag<ICollection<Operation>>();
-
- var ignite = Ignition.GetIgnite(IgniteName);
-
- var cache1 = Ignition.GetIgnite(IgniteName).GetCache<int, int>(Cache1);
- var cache2 = Ignition.GetIgnite(IgniteName).GetCache<int, int>(Cache2);
-
- // 1. Test rollback.
- using (var tx = ignite.GetTransactions().TxStart())
- {
- cache1.Put(1, 1);
- cache2.Put(2, 2);
-
- tx.Rollback();
- }
-
- Assert.AreEqual(1, _dumps.Count);
- var ops = _dumps.First();
- Assert.AreEqual(1, ops.Count);
-
- Assert.AreEqual(1, ops.Count(op => op.Type == OperationType.SesEnd && !op.Commit));
-
- _dumps = new ConcurrentBag<ICollection<Operation>>();
-
- // 2. Test puts.
- using (var tx = ignite.GetTransactions().TxStart())
- {
- cache1.Put(1, 1);
- cache2.Put(2, 2);
-
- tx.Commit();
- }
-
- Assert.AreEqual(1, _dumps.Count);
- ops = _dumps.First();
- Assert.AreEqual(3, ops.Count);
-
- Assert.AreEqual(1, ops.Count(op => op.Type == OperationType.Write && Cache1.Equals(op.CacheName) && 1.Equals(op.Key) && 1.Equals(op.Value)));
- Assert.AreEqual(1, ops.Count(op => op.Type == OperationType.Write && Cache2.Equals(op.CacheName) && 2.Equals(op.Key) && 2.Equals(op.Value)));
- Assert.AreEqual(1, ops.Count(op => op.Type == OperationType.SesEnd && op.Commit));
-
- _dumps = new ConcurrentBag<ICollection<Operation>>();
-
- // 3. Test removes.
- using (var tx = ignite.GetTransactions().TxStart())
- {
- cache1.Remove(1);
- cache2.Remove(2);
-
- tx.Commit();
- }
-
- Assert.AreEqual(1, _dumps.Count);
- ops = _dumps.First();
- Assert.AreEqual(3, ops.Count);
-
- Assert.AreEqual(1, ops.Count(op => op.Type == OperationType.Delete && Cache1.Equals(op.CacheName) && 1.Equals(op.Key)));
- Assert.AreEqual(1, ops.Count(op => op.Type == OperationType.Delete && Cache2.Equals(op.CacheName) && 2.Equals(op.Key)));
- Assert.AreEqual(1, ops.Count(op => op.Type == OperationType.SesEnd && op.Commit));
- }
-
- /// <summary>
- /// Dump operations.
- /// </summary>
- /// <param name="dump">Dump.</param>
- internal static void DumpOperations(ICollection<Operation> dump)
- {
- _dumps.Add(dump);
- }
-
- /// <summary>
- /// Test store implementation.
- /// </summary>
- public class Store : CacheStoreAdapter
- {
- /** Store session. */
- [StoreSessionResource]
-#pragma warning disable 649
- private ICacheStoreSession _ses;
-#pragma warning restore 649
-
- /** <inheritdoc /> */
- public override object Load(object key)
- {
- throw new NotImplementedException();
- }
-
- /** <inheritdoc /> */
- public override void Write(object key, object val)
- {
- GetOperations().Add(new Operation(_ses.CacheName, OperationType.Write, (int)key, (int)val));
- }
-
- /** <inheritdoc /> */
- public override void Delete(object key)
- {
- GetOperations().Add(new Operation(_ses.CacheName, OperationType.Delete, (int)key, 0));
- }
-
- /** <inheritdoc /> */
- public override void SessionEnd(bool commit)
- {
- Operation op = new Operation(_ses.CacheName, OperationType.SesEnd) { Commit = commit };
-
- ICollection<Operation> ops = GetOperations();
-
- ops.Add(op);
-
- DumpOperations(ops);
- }
-
- /// <summary>
- /// Get collection with operations.
- /// </summary>
- /// <returns>Operations.</returns>
- private ICollection<Operation> GetOperations()
- {
- object ops;
-
- if (!_ses.Properties.TryGetValue("ops", out ops))
- {
- ops = new List<Operation>();
-
- _ses.Properties["ops"] = ops;
- }
-
- return (ICollection<Operation>) ops;
- }
- }
-
- /// <summary>
- /// Logged operation.
- /// </summary>
- internal class Operation
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="cacheName">Cache name.</param>
- /// <param name="type">Operation type.</param>
- public Operation(string cacheName, OperationType type)
- {
- CacheName = cacheName;
- Type = type;
- }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="cacheName">Cache name.</param>
- /// <param name="type">Operation type.</param>
- /// <param name="key">Key.</param>
- /// <param name="val">Value.</param>
- public Operation(string cacheName, OperationType type, int key, int val) : this(cacheName, type)
- {
- Key = key;
- Value = val;
- }
-
- /// <summary>
- /// Cache name.
- /// </summary>
- public string CacheName { get; set; }
-
- /// <summary>
- /// Operation type.
- /// </summary>
- public OperationType Type { get; set; }
-
- /// <summary>
- /// Key.
- /// </summary>
- public int Key { get; set; }
-
- /// <summary>
- /// Value.
- /// </summary>
- public int Value { get; set; }
-
- /// <summary>
- /// Commit flag.
- /// </summary>
- public bool Commit { get; set; }
- }
-
- /// <summary>
- /// Operation types.
- /// </summary>
- internal enum OperationType
- {
- /** Write. */
- Write,
-
- /** Delete. */
- Delete,
-
- /** Session end. */
- SesEnd
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
deleted file mode 100644
index bfafcf4..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
+++ /dev/null
@@ -1,510 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache.Store
-{
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using Apache.Ignite.Core.Cache;
- using Apache.Ignite.Core.Impl;
- using Apache.Ignite.Core.Portable;
- using NUnit.Framework;
-
- /// <summary>
- ///
- /// </summary>
- class Key
- {
- private readonly int _idx;
-
- public Key(int idx)
- {
- _idx = idx;
- }
-
- public int Index()
- {
- return _idx;
- }
-
- public override bool Equals(object obj)
- {
- if (obj == null || obj.GetType() != GetType())
- return false;
-
- Key key = (Key)obj;
-
- return key._idx == _idx;
- }
-
- public override int GetHashCode()
- {
- return _idx;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- class Value
- {
- private int _idx;
-
- public Value(int idx)
- {
- _idx = idx;
- }
-
- public int Index()
- {
- return _idx;
- }
- }
-
- /// <summary>
- /// Cache entry predicate.
- /// </summary>
- [Serializable]
- public class CacheEntryFilter : ICacheEntryFilter<int, string>
- {
- /** <inheritdoc /> */
- public bool Invoke(ICacheEntry<int, string> entry)
- {
- return entry.Key >= 105;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- public class CacheStoreTest
- {
- /** */
- private const string PortableStoreCacheName = "portable_store";
-
- /** */
- private const string ObjectStoreCacheName = "object_store";
-
- /** */
- private const string CustomStoreCacheName = "custom_store";
-
- /** */
- private const string TemplateStoreCacheName = "template_store*";
-
- /// <summary>
- ///
- /// </summary>
- [TestFixtureSetUp]
- public void BeforeTests()
- {
- //TestUtils.JVM_DEBUG = true;
-
- TestUtils.KillProcesses();
-
- TestUtils.JvmDebug = true;
-
- IgniteConfigurationEx cfg = new IgniteConfigurationEx();
-
- cfg.GridName = GridName();
- cfg.JvmClasspath = TestUtils.CreateTestClasspath();
- cfg.JvmOptions = TestUtils.TestJavaOptions();
- cfg.SpringConfigUrl = "config\\native-client-test-cache-store.xml";
-
- PortableConfiguration portCfg = new PortableConfiguration();
-
- portCfg.Types = new List<string> { typeof(Key).FullName, typeof(Value).FullName };
-
- cfg.PortableConfiguration = portCfg;
-
- Ignition.Start(cfg);
- }
-
- /// <summary>
- ///
- /// </summary>
- [TestFixtureTearDown]
- public virtual void AfterTests()
- {
- Ignition.StopAll(true);
- }
-
- /// <summary>
- ///
- /// </summary>
- [SetUp]
- public void BeforeTest()
- {
- Console.WriteLine("Test started: " + TestContext.CurrentContext.Test.Name);
- }
-
- /// <summary>
- ///
- /// </summary>
- [TearDown]
- public void AfterTest()
- {
- var cache = Cache();
-
- cache.Clear();
-
- Assert.IsTrue(cache.IsEmpty(), "Cache is not empty: " + cache.GetSize());
-
- CacheTestStore.Reset();
-
- Console.WriteLine("Test finished: " + TestContext.CurrentContext.Test.Name);
- }
-
- [Test]
- public void TestLoadCache()
- {
- var cache = Cache();
-
- Assert.AreEqual(0, cache.GetSize());
-
- cache.LoadCache(new CacheEntryFilter(), 100, 10);
-
- Assert.AreEqual(5, cache.GetSize());
-
- for (int i = 105; i < 110; i++)
- Assert.AreEqual("val_" + i, cache.Get(i));
- }
-
- [Test]
- public void TestLocalLoadCache()
- {
- var cache = Cache();
-
- Assert.AreEqual(0, cache.GetSize());
-
- cache.LocalLoadCache(new CacheEntryFilter(), 100, 10);
-
- Assert.AreEqual(5, cache.GetSize());
-
- for (int i = 105; i < 110; i++)
- Assert.AreEqual("val_" + i, cache.Get(i));
- }
-
- [Test]
- public void TestLoadCacheMetadata()
- {
- CacheTestStore.LoadObjects = true;
-
- var cache = Cache();
-
- Assert.AreEqual(0, cache.GetSize());
-
- cache.LocalLoadCache(null, 0, 3);
-
- Assert.AreEqual(3, cache.GetSize());
-
- var meta = cache.WithKeepPortable<Key, IPortableObject>().Get(new Key(0)).GetMetadata();
-
- Assert.NotNull(meta);
-
- Assert.AreEqual("Value", meta.TypeName);
- }
-
- [Test]
- public void TestLoadCacheAsync()
- {
- var cache = Cache().WithAsync();
-
- Assert.AreEqual(0, cache.GetSize());
-
- cache.LocalLoadCache(new CacheEntryFilter(), 100, 10);
-
- var fut = cache.GetFuture<object>();
-
- fut.Get();
-
- Assert.IsTrue(fut.IsDone);
-
- cache.GetSize();
- Assert.AreEqual(5, cache.GetFuture<int>().ToTask().Result);
-
- for (int i = 105; i < 110; i++)
- {
- cache.Get(i);
-
- Assert.AreEqual("val_" + i, cache.GetFuture<string>().ToTask().Result);
- }
- }
-
- [Test]
- public void TestPutLoad()
- {
- var cache = Cache();
-
- cache.Put(1, "val");
-
- IDictionary map = StoreMap();
-
- Assert.AreEqual(1, map.Count);
-
- cache.LocalEvict(new[] { 1 });
-
- Assert.AreEqual(0, cache.GetSize());
-
- Assert.AreEqual("val", cache.Get(1));
-
- Assert.AreEqual(1, cache.GetSize());
- }
-
- [Test]
- public void TestPutLoadPortables()
- {
- var cache = PortableStoreCache<int, Value>();
-
- cache.Put(1, new Value(1));
-
- IDictionary map = StoreMap();
-
- Assert.AreEqual(1, map.Count);
-
- IPortableObject v = (IPortableObject)map[1];
-
- Assert.AreEqual(1, v.GetField<int>("_idx"));
-
- cache.LocalEvict(new[] { 1 });
-
- Assert.AreEqual(0, cache.GetSize());
-
- Assert.AreEqual(1, cache.Get(1).Index());
-
- Assert.AreEqual(1, cache.GetSize());
- }
-
- [Test]
- public void TestPutLoadObjects()
- {
- var cache = ObjectStoreCache<int, Value>();
-
- cache.Put(1, new Value(1));
-
- IDictionary map = StoreMap();
-
- Assert.AreEqual(1, map.Count);
-
- Value v = (Value)map[1];
-
- Assert.AreEqual(1, v.Index());
-
- cache.LocalEvict(new[] { 1 });
-
- Assert.AreEqual(0, cache.GetSize());
-
- Assert.AreEqual(1, cache.Get(1).Index());
-
- Assert.AreEqual(1, cache.GetSize());
- }
-
- [Test]
- public void TestPutLoadAll()
- {
- var putMap = new Dictionary<int, string>();
-
- for (int i = 0; i < 10; i++)
- putMap.Add(i, "val_" + i);
-
- var cache = Cache();
-
- cache.PutAll(putMap);
-
- IDictionary map = StoreMap();
-
- Assert.AreEqual(10, map.Count);
-
- for (int i = 0; i < 10; i++)
- Assert.AreEqual("val_" + i, map[i]);
-
- cache.Clear();
-
- Assert.AreEqual(0, cache.GetSize());
-
- ICollection<int> keys = new List<int>();
-
- for (int i = 0; i < 10; i++)
- keys.Add(i);
-
- IDictionary<int, string> loaded = cache.GetAll(keys);
-
- Assert.AreEqual(10, loaded.Count);
-
- for (int i = 0; i < 10; i++)
- Assert.AreEqual("val_" + i, loaded[i]);
-
- Assert.AreEqual(10, cache.GetSize());
- }
-
- [Test]
- public void TestRemove()
- {
- var cache = Cache();
-
- for (int i = 0; i < 10; i++)
- cache.Put(i, "val_" + i);
-
- IDictionary map = StoreMap();
-
- Assert.AreEqual(10, map.Count);
-
- for (int i = 0; i < 5; i++)
- cache.Remove(i);
-
- Assert.AreEqual(5, map.Count);
-
- for (int i = 5; i < 10; i++)
- Assert.AreEqual("val_" + i, map[i]);
- }
-
- [Test]
- public void TestRemoveAll()
- {
- var cache = Cache();
-
- for (int i = 0; i < 10; i++)
- cache.Put(i, "val_" + i);
-
- IDictionary map = StoreMap();
-
- Assert.AreEqual(10, map.Count);
-
- cache.RemoveAll(new List<int> { 0, 1, 2, 3, 4 });
-
- Assert.AreEqual(5, map.Count);
-
- for (int i = 5; i < 10; i++)
- Assert.AreEqual("val_" + i, map[i]);
- }
-
- [Test]
- public void TestTx()
- {
- var cache = Cache();
-
- using (var tx = cache.Ignite.GetTransactions().TxStart())
- {
- CacheTestStore.ExpCommit = true;
-
- tx.AddMeta("meta", 100);
-
- cache.Put(1, "val");
-
- tx.Commit();
- }
-
- IDictionary map = StoreMap();
-
- Assert.AreEqual(1, map.Count);
-
- Assert.AreEqual("val", map[1]);
- }
-
- [Test]
- public void TestLoadCacheMultithreaded()
- {
- CacheTestStore.LoadMultithreaded = true;
-
- var cache = Cache();
-
- Assert.AreEqual(0, cache.GetSize());
-
- cache.LocalLoadCache(null, 0, null);
-
- Assert.AreEqual(1000, cache.GetSize());
-
- for (int i = 0; i < 1000; i++)
- Assert.AreEqual("val_" + i, cache.Get(i));
- }
-
- [Test]
- public void TestCustomStoreProperties()
- {
- var cache = CustomStoreCache();
- Assert.IsNotNull(cache);
-
- Assert.AreEqual(42, CacheTestStore.intProperty);
- Assert.AreEqual("String value", CacheTestStore.stringProperty);
- }
-
- [Test]
- public void TestDynamicStoreStart()
- {
- var cache = TemplateStoreCache();
-
- Assert.IsNotNull(cache);
-
- cache.Put(1, cache.Name);
-
- Assert.AreEqual(cache.Name, CacheTestStore.Map[1]);
- }
-
- /// <summary>
- /// Get's grid name for this test.
- /// </summary>
- /// <returns>Grid name.</returns>
- protected virtual string GridName()
- {
- return null;
- }
-
- private IDictionary StoreMap()
- {
- return CacheTestStore.Map;
- }
-
- private ICache<int, string> Cache()
- {
- return PortableStoreCache<int, string>();
- }
-
- private ICache<TK, TV> PortableStoreCache<TK, TV>()
- {
- return Ignition.GetIgnite(GridName()).GetCache<TK, TV>(PortableStoreCacheName);
- }
-
- private ICache<TK, TV> ObjectStoreCache<TK, TV>()
- {
- return Ignition.GetIgnite(GridName()).GetCache<TK, TV>(ObjectStoreCacheName);
- }
-
- private ICache<int, string> CustomStoreCache()
- {
- return Ignition.GetIgnite(GridName()).GetCache<int, string>(CustomStoreCacheName);
- }
-
- private ICache<int, string> TemplateStoreCache()
- {
- var cacheName = TemplateStoreCacheName.Replace("*", Guid.NewGuid().ToString());
-
- return Ignition.GetIgnite(GridName()).GetOrCreateCache<int, string>(cacheName);
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- public class NamedNodeCacheStoreTest : CacheStoreTest
- {
- /** <inheritDoc /> */
- protected override string GridName()
- {
- return "name";
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheTestParallelLoadStore.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheTestParallelLoadStore.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheTestParallelLoadStore.cs
deleted file mode 100644
index 770ca83..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheTestParallelLoadStore.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache.Store
-{
- using System.Collections;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading;
- using Apache.Ignite.Core.Cache.Store;
-
- /// <summary>
- /// Test cache store with parallel load.
- /// </summary>
- public class CacheTestParallelLoadStore : CacheParallelLoadStoreAdapter
- {
- /** Length of input data sequence */
- public const int InputDataLength = 10000;
-
- /** list of thread ids where Parse has been executed */
- private static readonly ConcurrentDictionary<int, int> ThreadIds = new ConcurrentDictionary<int, int>();
-
- /// <summary>
- /// Gets the count of unique threads that entered Parse method.
- /// </summary>
- public static int UniqueThreadCount
- {
- get { return ThreadIds.Count; }
- }
-
- /// <summary>
- /// Resets the test counters.
- /// </summary>
- public static void ResetCounters()
- {
- ThreadIds.Clear();
- }
-
- /** <inheritdoc /> */
- protected override IEnumerable GetInputData()
- {
- return Enumerable.Range(0, InputDataLength).Select(x => new Record {Id = x, Name = "Test Record " + x});
- }
-
- /** <inheritdoc /> */
- protected override KeyValuePair<object, object>? Parse(object inputRecord, params object[] args)
- {
- var threadId = Thread.CurrentThread.ManagedThreadId;
- ThreadIds.GetOrAdd(threadId, threadId);
-
- var minId = (int)args[0];
-
- var rec = (Record)inputRecord;
-
- return rec.Id >= minId
- ? new KeyValuePair<object, object>(rec.Id, rec)
- : (KeyValuePair<object, object>?) null;
- }
-
- /// <summary>
- /// Test store record.
- /// </summary>
- public class Record
- {
- /// <summary>
- /// Gets or sets the identifier.
- /// </summary>
- public int Id { get; set; }
-
- /// <summary>
- /// Gets or sets the name.
- /// </summary>
- public string Name { get; set; }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheTestStore.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheTestStore.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheTestStore.cs
deleted file mode 100644
index 9c381cb..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheTestStore.cs
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache.Store
-{
- using System;
- using System.Collections;
- using System.Collections.Concurrent;
- using System.Diagnostics;
- using System.Diagnostics.CodeAnalysis;
- using System.Linq;
- using System.Threading;
- using Apache.Ignite.Core.Cache.Store;
- using Apache.Ignite.Core.Resource;
-
- [SuppressMessage("ReSharper", "FieldCanBeMadeReadOnly.Local")]
- public class CacheTestStore : ICacheStore
- {
- public static readonly IDictionary Map = new ConcurrentDictionary<object, object>();
-
- public static bool ExpCommit;
-
- public static bool LoadMultithreaded;
-
- public static bool LoadObjects;
-
- [InstanceResource]
- private IIgnite _grid = null;
-
- [StoreSessionResource]
-#pragma warning disable 649
- private ICacheStoreSession _ses;
-#pragma warning restore 649
-
- public static int intProperty;
-
- public static string stringProperty;
-
- public static void Reset()
- {
- Map.Clear();
-
- ExpCommit = false;
- LoadMultithreaded = false;
- LoadObjects = false;
- }
-
- public void LoadCache(Action<object, object> act, params object[] args)
- {
- Debug.Assert(_grid != null);
-
- if (LoadMultithreaded)
- {
- int cnt = 0;
-
- TestUtils.RunMultiThreaded(() => {
- int i;
-
- while ((i = Interlocked.Increment(ref cnt) - 1) < 1000)
- act(i, "val_" + i);
- }, 8);
- }
- else
- {
- int start = (int)args[0];
- int cnt = (int)args[1];
-
- for (int i = start; i < start + cnt; i++)
- {
- if (LoadObjects)
- act(new Key(i), new Value(i));
- else
- act(i, "val_" + i);
- }
- }
- }
-
- public object Load(object key)
- {
- Debug.Assert(_grid != null);
-
- return Map[key];
- }
-
- public IDictionary LoadAll(ICollection keys)
- {
- Debug.Assert(_grid != null);
-
- return keys.OfType<object>().ToDictionary(key => key, Load);
- }
-
- public void Write(object key, object val)
- {
- Debug.Assert(_grid != null);
-
- Map[key] = val;
- }
-
- public void WriteAll(IDictionary map)
- {
- Debug.Assert(_grid != null);
-
- foreach (DictionaryEntry e in map)
- Map[e.Key] = e.Value;
- }
-
- public void Delete(object key)
- {
- Debug.Assert(_grid != null);
-
- Map.Remove(key);
- }
-
- public void DeleteAll(ICollection keys)
- {
- Debug.Assert(_grid != null);
-
- foreach (object key in keys)
- Map.Remove(key);
- }
-
- public void SessionEnd(bool commit)
- {
- Debug.Assert(_grid != null);
-
- Debug.Assert(_ses != null);
- }
-
- public int IntProperty
- {
- get { return intProperty; }
- set { intProperty = value; }
- }
-
- public string StringProperty
- {
- get { return stringProperty; }
- set { stringProperty = value; }
- }
- }
-}
[08/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Config/example-cache-query.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Config/example-cache-query.xml b/modules/platform/dotnet/Examples2/Config/example-cache-query.xml
deleted file mode 100644
index c9ea7e1..0000000
--- a/modules/platform/dotnet/Examples2/Config/example-cache-query.xml
+++ /dev/null
@@ -1,111 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
-
- <property name="platformConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
- <property name="portableConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
- <property name="types">
- <list>
- <value>Apache.Ignite.Examples.Dll.Portable.Account</value>
- <value>Apache.Ignite.Examples.Dll.Portable.Address</value>
- <value>Apache.Ignite.Examples.Dll.Portable.Employee</value>
- <value>Apache.Ignite.Examples.Dll.Portable.EmployeeKey</value>
- <value>Apache.Ignite.Examples.Dll.Portable.Organization</value>
- <value>Apache.Ignite.Examples.Dll.Portable.OrganizationType</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
-
- <!-- Cache configurations (all properties are optional). -->
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="atomicityMode" value="ATOMIC"/>
- <property name="backups" value="1"/>
-
- <!-- Configure type metadata to enable queries. -->
- <property name="typeMetadata">
- <list>
- <bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="keyType" value="java.lang.Integer"/>
- <property name="valueType" value="Organization"/>
- <property name="ascendingFields">
- <map>
- <entry key="name" value="java.lang.String"/>
- </map>
- </property>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="keyType" value="EmployeeKey"/>
- <property name="valueType" value="Employee"/>
- <property name="ascendingFields">
- <map>
- <entry key="organizationId" value="java.lang.Integer"/>
- <entry key="address.zip" value="java.lang.Integer"/>
- </map>
- </property>
- <property name="queryFields">
- <map>
- <entry key="name" value="java.lang.String"/>
- <entry key="salary" value="java.lang.Long"/>
- </map>
- </property>
- <property name="textFields">
- <list>
- <value>address.street</value>
- </list>
- </property>
- </bean>
- </list>
- </property>
- </bean>
- </list>
- </property>
-
- <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47501</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Config/example-cache-store.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Config/example-cache-store.xml b/modules/platform/dotnet/Examples2/Config/example-cache-store.xml
deleted file mode 100644
index adc5f45..0000000
--- a/modules/platform/dotnet/Examples2/Config/example-cache-store.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="writeThrough" value="true"/>
- <property name="readThrough" value="true"/>
- <property name="cacheStoreFactory">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
- <property name="assemblyName" value="Apache.Ignite.ExamplesDll"/>
- <property name="className" value="Apache.Ignite.ExamplesDll.Datagrid.EmployeeStore"/>
- </bean>
- </property>
- </bean>
- </list>
- </property>
-
- <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47501</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Config/example-cache.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Config/example-cache.xml b/modules/platform/dotnet/Examples2/Config/example-cache.xml
deleted file mode 100644
index a262ce1..0000000
--- a/modules/platform/dotnet/Examples2/Config/example-cache.xml
+++ /dev/null
@@ -1,83 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <!-- Set to true to enable distributed class loading for examples, default is false. -->
- <property name="peerClassLoadingEnabled" value="true"/>
-
- <property name="platformConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
- <property name="portableConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
- <property name="types">
- <list>
- <value>Apache.Ignite.Examples.Dll.Portable.Account</value>
- <value>Apache.Ignite.Examples.Dll.Portable.Address</value>
- <value>Apache.Ignite.Examples.Dll.Portable.Employee</value>
- <value>Apache.Ignite.Examples.Dll.Portable.EmployeeKey</value>
- <value>Apache.Ignite.Examples.Dll.Portable.Organization</value>
- <value>Apache.Ignite.Examples.Dll.Portable.OrganizationType</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
-
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="cache*"/>
- <property name="atomicityMode" value="ATOMIC"/>
- <property name="backups" value="1"/>
- </bean>
-
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="tx"/>
- <property name="atomicityMode" value="TRANSACTIONAL"/>
- <property name="backups" value="1"/>
- </bean>
- </list>
- </property>
-
- <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47501</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/Config/example-compute.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/Config/example-compute.xml b/modules/platform/dotnet/Examples2/Config/example-compute.xml
deleted file mode 100644
index bbc6550..0000000
--- a/modules/platform/dotnet/Examples2/Config/example-compute.xml
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47501</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
-
- <!-- Enable task execution events for examples. -->
- <property name="includeEventTypes">
- <list>
- <!-- Task execution events -->
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED"/>
-
- <!-- Job execution events -->
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_MAPPED"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_RESULTED"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_FAILED_OVER"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_STARTED"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_FINISHED"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_TIMEDOUT"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_REJECTED"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_FAILED"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_QUEUED"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_CANCELLED"/>
- </list>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/Examples2/README.txt
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples2/README.txt b/modules/platform/dotnet/Examples2/README.txt
deleted file mode 100644
index c49dc5a..0000000
--- a/modules/platform/dotnet/Examples2/README.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-Apache Ignite .Net Examples
-==================================
-
-Common requirements
-----------------------------------
- * Apache Ignite .Net library must be built using instructions from %IGNITE_HOME%\platforms\dotnet\README.txt.
-
-
-Running examples
-----------------------------------
-
- * Open Visual Studio solution %IGNITE_HOME%\platforms\dotnet\examples\Apache.Ignite.Examples.sln
- * Build Apache.Ignite.ExamplesDll project.
- * Set desired example as startup object in Apache.Ignite.Examples project and run it.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.Examples.sln
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.Examples.sln b/modules/platform/dotnet/examples/Apache.Ignite.Examples.sln
new file mode 100644
index 0000000..c1337f3
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.Examples.sln
@@ -0,0 +1,72 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.31101.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Core", "..\Apache.Ignite.Core\Apache.Ignite.Core.csproj", "{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "..\..\cpp\common\project\vs\common.vcxproj", "{4F7E4917-4612-4B96-9838-025711ADE391}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Examples", "Apache.Ignite.Examples\Apache.Ignite.Examples.csproj", "{069FA680-3C4D-43A9-B84F-E67513B87827}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.ExamplesDll", "Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj", "{DFB08363-202E-412D-8812-349EF10A8702}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{F1491682-C798-4C23-8239-16C5BC2C5A02}"
+ ProjectSection(SolutionItems) = preProject
+ Config\example-cache-query.xml = Config\example-cache-query.xml
+ Config\example-cache-store.xml = Config\example-cache-store.xml
+ Config\example-cache.xml = Config\example-cache.xml
+ Config\example-compute.xml = Config\example-compute.xml
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite", "..\Apache.Ignite\Apache.Ignite.csproj", "{27F7F3C6-BDDE-43A9-B565-856F8395A04B}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x64.ActiveCfg = Debug|x64
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x64.Build.0 = Debug|x64
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x86.ActiveCfg = Debug|x86
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x86.Build.0 = Debug|x86
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x64.ActiveCfg = Release|x64
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x64.Build.0 = Release|x64
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x86.ActiveCfg = Release|x86
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x86.Build.0 = Release|x86
+ {4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x64.ActiveCfg = Debug|x64
+ {4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x64.Build.0 = Debug|x64
+ {4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x86.ActiveCfg = Debug|Win32
+ {4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x86.Build.0 = Debug|Win32
+ {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x64.ActiveCfg = Release|x64
+ {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x64.Build.0 = Release|x64
+ {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x86.ActiveCfg = Release|Win32
+ {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x86.Build.0 = Release|Win32
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.ActiveCfg = Debug|x64
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.Build.0 = Debug|x64
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.ActiveCfg = Debug|x86
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.Build.0 = Debug|x86
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.ActiveCfg = Release|x64
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.Build.0 = Release|x64
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.ActiveCfg = Release|x86
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.Build.0 = Release|x86
+ {DFB08363-202E-412D-8812-349EF10A8702}.Debug|x64.ActiveCfg = Debug|x64
+ {DFB08363-202E-412D-8812-349EF10A8702}.Debug|x86.ActiveCfg = Debug|x86
+ {DFB08363-202E-412D-8812-349EF10A8702}.Release|x64.ActiveCfg = Release|x64
+ {DFB08363-202E-412D-8812-349EF10A8702}.Release|x86.ActiveCfg = Release|x86
+ {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x64.ActiveCfg = Debug|x64
+ {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x64.Build.0 = Debug|x64
+ {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x86.ActiveCfg = Debug|x86
+ {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x86.Build.0 = Debug|x86
+ {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x64.ActiveCfg = Release|x64
+ {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x64.Build.0 = Release|x64
+ {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x86.ActiveCfg = Release|x86
+ {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x86.Build.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.Examples.slnrel
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.Examples.slnrel b/modules/platform/dotnet/examples/Apache.Ignite.Examples.slnrel
new file mode 100644
index 0000000..d898abc
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.Examples.slnrel
@@ -0,0 +1,38 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Examples", "Apache.Ignite.Examples\Apache.Ignite.Examples.csproj", "{069FA680-3C4D-43A9-B84F-E67513B87827}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.ExamplesDll", "Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj", "{DFB08363-202E-412D-8812-349EF10A8702}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{F1491682-C798-4C23-8239-16C5BC2C5A02}"
+ ProjectSection(SolutionItems) = preProject
+ Config\example-cache-query.xml = Config\example-cache-query.xml
+ Config\example-cache-store.xml = Config\example-cache-store.xml
+ Config\example-cache.xml = Config\example-cache.xml
+ Config\example-compute.xml = Config\example-compute.xml
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.ActiveCfg = Debug|x64
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.Build.0 = Debug|x64
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.ActiveCfg = Debug|x86
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.Build.0 = Debug|x86
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.ActiveCfg = Release|x64
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.Build.0 = Release|x64
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.ActiveCfg = Release|x86
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.Build.0 = Release|x86
+ {DFB08363-202E-412D-8812-349EF10A8702}.Debug|x64.ActiveCfg = Debug|x64
+ {DFB08363-202E-412D-8812-349EF10A8702}.Debug|x86.ActiveCfg = Debug|x86
+ {DFB08363-202E-412D-8812-349EF10A8702}.Release|x64.ActiveCfg = Release|x64
+ {DFB08363-202E-412D-8812-349EF10A8702}.Release|x86.ActiveCfg = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
new file mode 100644
index 0000000..8ee90d9
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{069FA680-3C4D-43A9-B84F-E67513B87827}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Apache.Ignite.Examples</RootNamespace>
+ <AssemblyName>Apache.Ignite.Examples</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Debug\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Release\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup>
+ <StartupObject>Apache.Ignite.Examples.Compute.TaskExample</StartupObject>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\x86\Debug\</OutputPath>
+ <PlatformTarget>x86</PlatformTarget>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+ <OutputPath>bin\x86\Release\</OutputPath>
+ <PlatformTarget>x86</PlatformTarget>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Compute\ClosureExample.cs" />
+ <Compile Include="Compute\TaskExample.cs" />
+ <Compile Include="Datagrid\ContinuousQueryExample.cs" />
+ <Compile Include="Datagrid\CrossPlatformExample.cs" />
+ <Compile Include="Datagrid\DataStreamerExample.cs" />
+ <Compile Include="Datagrid\PutGetExample.cs" />
+ <Compile Include="Datagrid\QueryExample.cs" />
+ <Compile Include="Datagrid\StoreExample.cs" />
+ <Compile Include="Datagrid\TransactionExample.cs" />
+ <Compile Include="Events\EventsExample.cs" />
+ <Compile Include="Messaging\MessagingExample.cs" />
+ <Compile Include="Misc\LifecycleExample.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Services\IMapService.cs" />
+ <Compile Include="Services\ServicesExample.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\Apache.Ignite.Core\Apache.Ignite.Core.csproj">
+ <Project>{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}</Project>
+ <Name>Apache.Ignite.Core</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj">
+ <Project>{dfb08363-202e-412d-8812-349ef10a8702}</Project>
+ <Name>Apache.Ignite.ExamplesDll</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ </ItemGroup>
+ <ItemGroup />
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csprojrel
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csprojrel b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csprojrel
new file mode 100644
index 0000000..ff13ddc
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csprojrel
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{069FA680-3C4D-43A9-B84F-E67513B87827}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Apache.Ignite.Examples</RootNamespace>
+ <AssemblyName>Apache.Ignite.Examples</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Debug\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Release\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup>
+ <StartupObject>Apache.Ignite.Examples.Compute.TaskExample</StartupObject>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\x86\Debug\</OutputPath>
+ <PlatformTarget>x86</PlatformTarget>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+ <OutputPath>bin\x86\Release\</OutputPath>
+ <PlatformTarget>x86</PlatformTarget>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Apache.Ignite.Core">
+ <HintPath>..\..\Apache.Ignite\bin\$(Platform)\$(Configuration)\Apache.Ignite.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Compute\ClosureExample.cs" />
+ <Compile Include="Compute\TaskExample.cs" />
+ <Compile Include="Datagrid\ContinuousQueryExample.cs" />
+ <Compile Include="Datagrid\CrossPlatformExample.cs" />
+ <Compile Include="Datagrid\DataStreamerExample.cs" />
+ <Compile Include="Datagrid\PutGetExample.cs" />
+ <Compile Include="Datagrid\QueryExample.cs" />
+ <Compile Include="Datagrid\StoreExample.cs" />
+ <Compile Include="Datagrid\TransactionExample.cs" />
+ <Compile Include="Events\EventsExample.cs" />
+ <Compile Include="Messaging\MessagingExample.cs" />
+ <Compile Include="Misc\LifecycleExample.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Services\IMapService.cs" />
+ <Compile Include="Services\ServicesExample.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj">
+ <Project>{dfb08363-202e-412d-8812-349ef10a8702}</Project>
+ <Name>Apache.Ignite.ExamplesDll</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ </ItemGroup>
+ <ItemGroup />
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.Examples/App.config
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.Examples/App.config b/modules/platform/dotnet/examples/Apache.Ignite.Examples/App.config
new file mode 100644
index 0000000..8e69aeb
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.Examples/App.config
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8" ?>
+
+<!--
+ 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.
+-->
+
+<configuration>
+ <runtime>
+ <gcServer enabled="true" />
+ </runtime>
+</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.Examples/Compute/ClosureExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.Examples/Compute/ClosureExample.cs b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Compute/ClosureExample.cs
new file mode 100644
index 0000000..7d0128d
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Compute/ClosureExample.cs
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Apache.Ignite.Core;
+using Apache.Ignite.ExamplesDll.Compute;
+
+namespace Apache.Ignite.Examples.Compute
+{
+ /// <summary>
+ /// Example demonstrating closure execution.
+ /// <para />
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+ /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start example (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run with standalone Apache Ignite .Net node:
+ /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+ /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-compute.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// 2) Start example.
+ /// </summary>
+ public class ClosureExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Closure execution example started.");
+
+ // Split the string by spaces to count letters in each word in parallel.
+ ICollection<string> words = "Count characters using closure".Split().ToList();
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Calculating character count with manual reducing:");
+
+ var res = ignite.GetCompute().Apply(new CharacterCountClosure(), words);
+
+ int totalLen = res.Sum();
+
+ Console.WriteLine(">>> Total character count: " + totalLen);
+ Console.WriteLine();
+ Console.WriteLine(">>> Calculating character count with reducer:");
+
+ totalLen = ignite.GetCompute().Apply(new CharacterCountClosure(), words, new CharacterCountReducer());
+
+ Console.WriteLine(">>> Total character count: " + totalLen);
+ Console.WriteLine();
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.Examples/Compute/TaskExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.Examples/Compute/TaskExample.cs b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Compute/TaskExample.cs
new file mode 100644
index 0000000..47fee9e
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Compute/TaskExample.cs
@@ -0,0 +1,140 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.ExamplesDll.Compute;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Compute
+{
+ /// <summary>
+ /// Example demonstrating task execution.
+ /// <para />
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+ /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start example (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run with standalone Apache Ignite .Net node:
+ /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+ /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-compute.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// 2) Start example.
+ /// </summary>
+ public class TaskExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Task execution example started.");
+
+ // Generate employees to calculate average salary for.
+ ICollection<Employee> employees = Employees();
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Calculating average salary for employees:");
+
+ foreach (Employee employee in employees)
+ Console.WriteLine(">>> " + employee);
+
+ // Execute task and get average salary.
+ var avgSalary = ignite.GetCompute().Execute(new AverageSalaryTask(), employees);
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Average salary for all employees: " + avgSalary);
+ Console.WriteLine();
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+
+ /// <summary>
+ /// Generates collection of employees for example.
+ /// </summary>
+ /// <returns>Collection of employees.</returns>
+ private static ICollection<Employee> Employees()
+ {
+ return new []
+ {
+ new Employee(
+ "James Wilson",
+ 12500,
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ new List<string> {"Human Resources", "Customer Service"}
+ ),
+ new Employee(
+ "Daniel Adams",
+ 11000,
+ new Address("184 Fidler Drive, San Antonio, TX", 78205),
+ new List<string> {"Development", "QA"}
+ ),
+ new Employee(
+ "Cristian Moss",
+ 12500,
+ new Address("667 Jerry Dove Drive, Florence, SC", 29501),
+ new List<string> {"Logistics"}
+ ),
+ new Employee(
+ "Allison Mathis",
+ 25300,
+ new Address("2702 Freedom Lane, Hornitos, CA", 95325),
+ new List<string> {"Development"}
+ ),
+ new Employee(
+ "Breana Robbin",
+ 6500,
+ new Address("3960 Sundown Lane, Austin, TX", 78758),
+ new List<string> {"Sales"}
+ ),
+ new Employee(
+ "Philip Horsley",
+ 19800,
+ new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
+ new List<string> {"Sales"}
+ ),
+ new Employee(
+ "Brian Peters",
+ 10600,
+ new Address("1407 Pearlman Avenue, Boston, MA", 02110),
+ new List<string> {"Development", "QA"}
+ ),
+ new Employee(
+ "Jack Yang",
+ 12900,
+ new Address("4425 Parrish Avenue Smithsons Valley, TX", 78130),
+ new List<string> {"Sales"}
+ )
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
new file mode 100644
index 0000000..c61b45d
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Cache.Event;
+using Apache.Ignite.Core.Cache.Query.Continuous;
+using Apache.Ignite.ExamplesDll.Datagrid;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+ /// <summary>
+ /// This example demonstrates continuous query API.
+ /// <para />
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+ /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start example (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run with standalone Apache Ignite .Net node:
+ /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+ /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// 2) Start example.
+ /// </summary>
+ public class ContinuousQueryExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
+ JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Cache continuous query example started.");
+
+ var cache = ignite.GetOrCreateCache<int, string>("cache_continuous_query");
+
+ // Clean up caches on all nodes before run.
+ cache.Clear();
+
+ const int keyCnt = 20;
+
+ for (int i = 0; i < keyCnt; i++)
+ cache.Put(i, i.ToString());
+
+ var qry = new ContinuousQuery<int, string>(new Listener<string>(), new ContinuousQueryFilter(15));
+
+
+ // Create new continuous query.
+ using (cache.QueryContinuous(qry))
+ {
+ // Add a few more keys and watch more query notifications.
+ for (var i = keyCnt; i < keyCnt + 5; i++)
+ cache.Put(i, i.ToString());
+
+ // Wait for a while while callback is notified about remaining puts.
+ Thread.Sleep(2000);
+ }
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+
+ /// <summary>
+ /// Callback for continuous query example.
+ /// </summary>
+ private class Listener<T> : ICacheEntryEventListener<int, T>
+ {
+ public void OnEvent(IEnumerable<ICacheEntryEvent<int, T>> events)
+ {
+ foreach (var e in events)
+ Console.WriteLine("Queried entry [key=" + e.Key + ", val=" + e.Value + ']');
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
new file mode 100644
index 0000000..e23d615
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
@@ -0,0 +1,208 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Portable;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+ /// <summary>
+ /// This example demonstrates use of portable objects between different platforms.
+ /// <para/>
+ /// This example must be run with standalone Java node. To achieve this start a node from %IGNITE_HOME%
+ /// using "ignite.bat" with proper configuration:
+ /// <example>'bin\ignite.bat examples\config\example-server.xml'</example>.
+ /// <para />
+ /// Once remote node is started, launch this example as follows:
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build);
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start application (F5 or Ctrl+F5).
+ /// <para />
+ /// To see how objects can be transferred between platforms, start cross-platform Java example
+ /// without restarting remote node.
+ /// </summary>
+ public class CrossPlatformExample
+ {
+ /// <summary>Key for Java object.</summary>
+ private const int KeyJava = 100;
+
+ /// <summary>Key for .Net object.</summary>
+ private const int KeyDotnet = 200;
+
+ /// <summary>Key for C++ object.</summary>
+ private const int KeyCpp = 300;
+
+ /// <summary>Cache Name.</summary>
+ private const string CacheName = "cacheCrossPlatform";
+
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Cross-platform example started.");
+
+ if (ignite.GetCluster().ForRemotes().GetNodes().Count == 0)
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> This example requires remote nodes to be started.");
+ Console.WriteLine(">>> Please start at least 1 remote node.");
+ Console.WriteLine(">>> Refer to example's documentation for details on configuration.");
+ Console.WriteLine();
+ }
+ else
+ {
+ var cache = ignite.GetOrCreateCache<int, Organization>(CacheName);
+
+ // Create new Organization object to store in cache.
+ Organization org = new Organization(
+ "Apache",
+ new Address("1065 East Hillsdale Blvd, Foster City, CA", 94404),
+ OrganizationType.Private,
+ DateTime.Now
+ );
+
+ // Put created data entry to cache.
+ cache.Put(KeyDotnet, org);
+
+ // Retrieve value stored by Java client.
+ GetFromJava(ignite);
+
+ // Retrieve value stored by C++ client.
+ GetFromCpp(ignite);
+
+ // Gets portable value from cache in portable format, without de-serializing it.
+ GetDotNetPortableInstance(ignite);
+
+ // Gets portable value form cache as a strongly-typed fully de-serialized instance.
+ GetDotNetTypedInstance(ignite);
+
+ Console.WriteLine();
+ }
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+
+ /// <summary>
+ /// Gets entry put by Java client. In order for entry to be in cache, Java client example
+ /// must be run before this example.
+ /// </summary>
+ /// <param name="Ignite">Ignite instance.</param>
+ private static void GetFromJava(IIgnite ignite)
+ {
+ var cache = ignite.GetOrCreateCache<int, IPortableObject>(CacheName)
+ .WithKeepPortable<int, IPortableObject>().WithAsync();
+
+ cache.Get(KeyJava);
+
+ var orgPortable = cache.GetFuture<IPortableObject>().ToTask().Result;
+
+ if (orgPortable == null)
+ {
+ Console.WriteLine(">>> Java client hasn't put entry to cache. Run Java example before this example " +
+ "to see the output.");
+ }
+ else
+ {
+ Console.WriteLine(">>> Entry from Java client:");
+ Console.WriteLine(">>> Portable: " + orgPortable);
+ Console.WriteLine(">>> Deserialized: " + orgPortable.Deserialize<Organization>());
+ }
+ }
+
+ /// <summary>
+ /// Gets entry put by C++ client. In order for entry to be in cache, C++ client example
+ /// must be run before this example.
+ /// </summary>
+ /// <param name="ignite">Ignite instance.</param>
+ private static void GetFromCpp(IIgnite ignite)
+ {
+ var cache = ignite.GetOrCreateCache<int, IPortableObject>(CacheName)
+ .WithKeepPortable<int, IPortableObject>().WithAsync();
+
+ cache.Get(KeyCpp);
+
+ var orgPortable = cache.GetFuture<IPortableObject>().Get();
+
+ Console.WriteLine();
+
+ if (orgPortable == null)
+ {
+ Console.WriteLine(">>> CPP client hasn't put entry to cache. Run CPP example before this example " +
+ "to see the output.");
+ }
+ else
+ {
+ Console.WriteLine(">>> Entry from CPP client:");
+ Console.WriteLine(">>> Portable: " + orgPortable);
+ Console.WriteLine(">>> Deserialized: " + orgPortable.Deserialize<Organization>());
+ }
+ }
+
+ /// <summary>
+ /// Gets portable value from cache in portable format, without de-serializing it.
+ /// </summary>
+ /// <param name="ignite">Ignite instance.</param>
+ private static void GetDotNetPortableInstance(IIgnite ignite)
+ {
+ // Apply "KeepPortable" flag on data projection.
+ var cache = ignite.GetOrCreateCache<int, IPortableObject>(CacheName)
+ .WithKeepPortable<int, IPortableObject>();
+
+ var org = cache.Get(KeyDotnet);
+
+ string name = org.GetField<string>("name");
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Retrieved organization name from portable field: " + name);
+ }
+
+ /// <summary>
+ /// Gets portable value form cache as a strongly-typed fully de-serialized instance.
+ /// </summary>
+ /// <param name="ignite">Ignite instance.</param>
+ private static void GetDotNetTypedInstance(IIgnite ignite)
+ {
+ var cache = ignite.GetOrCreateCache<int, Organization>(CacheName);
+
+ // Get recently created employee as a strongly-typed fully de-serialized instance.
+ Organization emp = cache.Get(KeyDotnet);
+
+ string name = emp.Name;
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Retrieved organization name from deserialized Organization instance: " + name);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
new file mode 100644
index 0000000..ee9e200
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
@@ -0,0 +1,101 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Datastream;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+ /// <summary>
+ /// Demonstrates how cache can be populated with data utilizing <see cref="IDataStreamer{TK,TV}"/>.
+ /// Data streamer is a lot more efficient to use than standard cache put operation
+ /// as it properly buffers cache requests together and properly manages load on remote nodes.
+ /// <para />
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+ /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start example (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run with standalone Apache Ignite .Net node:
+ /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+ /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// 2) Start example.
+ /// </summary>
+ public class DataStreamerExample
+ {
+ /// <summary>Number of entries to load.</summary>
+ private const int EntryCount = 500000;
+
+ /// <summary>Cache name.</summary>
+ private const string CacheName = "cache_data_streamer";
+
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
+ JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Cache data streamer example started.");
+
+ // Clean up caches on all nodes before run.
+ ignite.GetOrCreateCache<int, Account>(CacheName).Clear();
+
+ Stopwatch timer = new Stopwatch();
+
+ timer.Start();
+
+ using (var ldr = ignite.GetDataStreamer<int, Account>(CacheName))
+ {
+ ldr.PerNodeBufferSize = 1024;
+
+ for (int i = 0; i < EntryCount; i++)
+ {
+ ldr.AddData(i, new Account(i, i));
+
+ // Print out progress while loading cache.
+ if (i > 0 && i % 10000 == 0)
+ Console.WriteLine("Loaded " + i + " accounts.");
+ }
+ }
+
+ timer.Stop();
+
+ long dur = timer.ElapsedMilliseconds;
+
+ Console.WriteLine(">>> Loaded " + EntryCount + " accounts in " + dur + "ms.");
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
new file mode 100644
index 0000000..c1146f1
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
@@ -0,0 +1,219 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Portable;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+ /// <summary>
+ /// This example demonstrates several put-get operations on Ignite cache
+ /// with portable values. Note that portable object can be retrieved in
+ /// fully-deserialized form or in portable object format using special
+ /// cache projection.
+ /// <para />
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+ /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start example (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run with standalone Apache Ignite .Net node:
+ /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+ /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// 2) Start example.
+ /// </summary>
+ public class PutGetExample
+ {
+ /// <summary>Cache name.</summary>
+ private const string CacheName = "cache_put_get";
+
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Cache put-get example started.");
+
+ // Clean up caches on all nodes before run.
+ ignite.GetOrCreateCache<object, object>(CacheName).Clear();
+
+ PutGet(ignite);
+ PutGetPortable(ignite);
+ PutAllGetAll(ignite);
+ PutAllGetAllPortable(ignite);
+
+ Console.WriteLine();
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+
+ /// <summary>
+ /// Execute individual Put and Get.
+ /// </summary>
+ /// <param name="ignite">Ignite instance.</param>
+ private static void PutGet(IIgnite ignite)
+ {
+ var cache = ignite.GetCache<int, Organization>(CacheName);
+
+ // Create new Organization to store in cache.
+ Organization org = new Organization(
+ "Microsoft",
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ OrganizationType.Private,
+ DateTime.Now
+ );
+
+ // Put created data entry to cache.
+ cache.Put(1, org);
+
+ // Get recently created employee as a strongly-typed fully de-serialized instance.
+ Organization orgFromCache = cache.Get(1);
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Retrieved organization instance from cache: " + orgFromCache);
+ }
+
+ /// <summary>
+ /// Execute individual Put and Get, getting value in portable format, without de-serializing it.
+ /// </summary>
+ /// <param name="ignite">Ignite instance.</param>
+ private static void PutGetPortable(IIgnite ignite)
+ {
+ var cache = ignite.GetCache<int, Organization>(CacheName);
+
+ // Create new Organization to store in cache.
+ Organization org = new Organization(
+ "Microsoft",
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ OrganizationType.Private,
+ DateTime.Now
+ );
+
+ // Put created data entry to cache.
+ cache.Put(1, org);
+
+ // Create projection that will get values as portable objects.
+ var portableCache = cache.WithKeepPortable<int, IPortableObject>();
+
+ // Get recently created organization as a portable object.
+ var portableOrg = portableCache.Get(1);
+
+ // Get organization's name from portable object (note that object doesn't need to be fully deserialized).
+ string name = portableOrg.GetField<string>("name");
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Retrieved organization name from portable object: " + name);
+ }
+
+ /// <summary>
+ /// Execute bulk Put and Get operations.
+ /// </summary>
+ /// <param name="ignite">Ignite instance.</param>
+ private static void PutAllGetAll(IIgnite ignite)
+ {
+ var cache = ignite.GetCache<int, Organization>(CacheName);
+
+ // Create new Organizations to store in cache.
+ Organization org1 = new Organization(
+ "Microsoft",
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ OrganizationType.Private,
+ DateTime.Now
+ );
+
+ Organization org2 = new Organization(
+ "Red Cross",
+ new Address("184 Fidler Drive, San Antonio, TX", 78205),
+ OrganizationType.NonProfit,
+ DateTime.Now
+ );
+
+ var map = new Dictionary<int, Organization> { { 1, org1 }, { 2, org2 } };
+
+ // Put created data entries to cache.
+ cache.PutAll(map);
+
+ // Get recently created organizations as a strongly-typed fully de-serialized instances.
+ IDictionary<int, Organization> mapFromCache = cache.GetAll(new List<int> { 1, 2 });
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Retrieved organization instances from cache:");
+
+ foreach (Organization org in mapFromCache.Values)
+ Console.WriteLine(">>> " + org);
+ }
+
+ /// <summary>
+ /// Execute bulk Put and Get operations getting values in portable format, without de-serializing it.
+ /// </summary>
+ /// <param name="ignite">Ignite instance.</param>
+ private static void PutAllGetAllPortable(IIgnite ignite)
+ {
+ var cache = ignite.GetCache<int, Organization>(CacheName);
+
+ // Create new Organizations to store in cache.
+ Organization org1 = new Organization(
+ "Microsoft",
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ OrganizationType.Private,
+ DateTime.Now
+ );
+
+ Organization org2 = new Organization(
+ "Red Cross",
+ new Address("184 Fidler Drive, San Antonio, TX", 78205),
+ OrganizationType.NonProfit,
+ DateTime.Now
+ );
+
+ var map = new Dictionary<int, Organization> { { 1, org1 }, { 2, org2 } };
+
+ // Put created data entries to cache.
+ cache.PutAll(map);
+
+ // Create projection that will get values as portable objects.
+ var portableCache = cache.WithKeepPortable<int, IPortableObject>();
+
+ // Get recently created organizations as portable objects.
+ IDictionary<int, IPortableObject> portableMap =
+ portableCache.GetAll(new List<int> { 1, 2 });
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Retrieved organization names from portable objects:");
+
+ foreach (IPortableObject poratbleOrg in portableMap.Values)
+ Console.WriteLine(">>> " + poratbleOrg.GetField<string>("name"));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a958801c/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
new file mode 100644
index 0000000..523b83f
--- /dev/null
+++ b/modules/platform/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
@@ -0,0 +1,226 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Cache;
+using Apache.Ignite.Core.Cache.Query;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+ /// <summary>
+ /// This example populates cache with sample data and runs several SQL and
+ /// full text queries over this data.
+ /// <para />
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+ /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start example (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run with standalone Apache Ignite .Net node:
+ /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+ /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache-query.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// 2) Start example.
+ /// </summary>
+ public class QueryExample
+ {
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache-query.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Cache query example started.");
+
+ var cache = ignite.GetCache<object, object>(null);
+
+ // Clean up caches on all nodes before run.
+ cache.Clear();
+
+ // Populate cache with sample data entries.
+ PopulateCache(cache);
+
+ // Create cache that will work with specific types.
+ var employeeCache = ignite.GetCache<EmployeeKey, Employee>(null);
+
+ // Run SQL query example.
+ SqlQueryExample(employeeCache);
+
+ // Run SQL query with join example.
+ SqlJoinQueryExample(employeeCache);
+
+ // Run SQL fields query example.
+ SqlFieldsQueryExample(employeeCache);
+
+ // Run full text query example.
+ FullTextQueryExample(employeeCache);
+
+ Console.WriteLine();
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+
+ /// <summary>
+ /// Queries employees that have provided ZIP code in address.
+ /// </summary>
+ /// <param name="cache">Cache.</param>
+ private static void SqlQueryExample(ICache<EmployeeKey, Employee> cache)
+ {
+ const int zip = 94109;
+
+ var qry = cache.Query(new SqlQuery(typeof(Employee), "zip = ?", zip));
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Employees with zipcode " + zip + ":");
+
+ foreach (var entry in qry)
+ Console.WriteLine(">>> " + entry.Value);
+ }
+
+ /// <summary>
+ /// Queries employees that work for organization with provided name.
+ /// </summary>
+ /// <param name="cache">Cache.</param>
+ private static void SqlJoinQueryExample(ICache<EmployeeKey, Employee> cache)
+ {
+ const string orgName = "Apache";
+
+ var qry = cache.Query(new SqlQuery("Employee",
+ "from Employee, Organization " +
+ "where Employee.organizationId = Organization._key and Organization.name = ?", orgName));
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Employees working for " + orgName + ":");
+
+ foreach (var entry in qry)
+ Console.WriteLine(">>> " + entry.Value);
+ }
+
+ /// <summary>
+ /// Queries names and salaries for all employees.
+ /// </summary>
+ /// <param name="cache">Cache.</param>
+ private static void SqlFieldsQueryExample(ICache<EmployeeKey, Employee> cache)
+ {
+ var qry = cache.QueryFields(new SqlFieldsQuery("select name, salary from Employee"));
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Employee names and their salaries:");
+
+ foreach (IList row in qry)
+ Console.WriteLine(">>> [Name=" + row[0] + ", salary=" + row[1] + ']');
+ }
+
+ /// <summary>
+ /// Queries employees that live in Texas using full-text query API.
+ /// </summary>
+ /// <param name="cache">Cache.</param>
+ private static void FullTextQueryExample(ICache<EmployeeKey, Employee> cache)
+ {
+ var qry = cache.Query(new TextQuery("Employee", "TX"));
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Employees living in Texas:");
+
+ foreach (var entry in qry)
+ Console.WriteLine(">>> " + entry.Value);
+ }
+
+ /// <summary>
+ /// Populate cache with data for this example.
+ /// </summary>
+ /// <param name="cache">Cache.</param>
+ private static void PopulateCache(ICache<object, object> cache)
+ {
+ cache.Put(1, new Organization(
+ "Apache",
+ new Address("1065 East Hillsdale Blvd, Foster City, CA", 94404),
+ OrganizationType.Private,
+ DateTime.Now
+ ));
+
+ cache.Put(2, new Organization(
+ "Microsoft",
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ OrganizationType.Private,
+ DateTime.Now
+ ));
+
+ cache.Put(new EmployeeKey(1, 1), new Employee(
+ "James Wilson",
+ 12500,
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ new List<string> { "Human Resources", "Customer Service" }
+ ));
+
+ cache.Put(new EmployeeKey(2, 1), new Employee(
+ "Daniel Adams",
+ 11000,
+ new Address("184 Fidler Drive, San Antonio, TX", 78130),
+ new List<string> { "Development", "QA" }
+ ));
+
+ cache.Put(new EmployeeKey(3, 1), new Employee(
+ "Cristian Moss",
+ 12500,
+ new Address("667 Jerry Dove Drive, Florence, SC", 29501),
+ new List<string> { "Logistics" }
+ ));
+
+ cache.Put(new EmployeeKey(4, 2), new Employee(
+ "Allison Mathis",
+ 25300,
+ new Address("2702 Freedom Lane, San Francisco, CA", 94109),
+ new List<string> { "Development" }
+ ));
+
+ cache.Put(new EmployeeKey(5, 2), new Employee(
+ "Breana Robbin",
+ 6500,
+ new Address("3960 Sundown Lane, Austin, TX", 78130),
+ new List<string> { "Sales" }
+ ));
+
+ cache.Put(new EmployeeKey(6, 2), new Employee(
+ "Philip Horsley",
+ 19800,
+ new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
+ new List<string> { "Sales" }
+ ));
+
+ cache.Put(new EmployeeKey(7, 2), new Employee(
+ "Brian Peters",
+ 10600,
+ new Address("1407 Pearlman Avenue, Boston, MA", 12110),
+ new List<string> { "Development", "QA" }
+ ));
+ }
+ }
+}
[31/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
new file mode 100644
index 0000000..e7c5ac9
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
@@ -0,0 +1,437 @@
+/*
+ * 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.Compute
+{
+ using System;
+ using System.Collections.Generic;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Compute;
+ using Apache.Ignite.Core.Portable;
+ using Apache.Ignite.Core.Resource;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests task result.
+ /// </summary>
+ public class TaskResultTest : AbstractTaskTest
+ {
+ /** Grid name. */
+ private static volatile string _gridName;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public TaskResultTest() : base(false) { }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="forked">Fork flag.</param>
+ protected TaskResultTest(bool forked) : base(forked) { }
+
+ /// <summary>
+ /// Test for task result.
+ /// </summary>
+ [Test]
+ public void TestTaskResultInt()
+ {
+ TestTask<int> task = new TestTask<int>();
+
+ int res = Grid1.GetCompute().Execute(task, new Tuple<bool, int>(true, 10));
+
+ Assert.AreEqual(10, res);
+
+ res = Grid1.GetCompute().Execute(task, new Tuple<bool, int>(false, 11));
+
+ Assert.AreEqual(11, res);
+ }
+
+ /// <summary>
+ /// Test for task result.
+ /// </summary>
+ [Test]
+ public void TestTaskResultLong()
+ {
+ TestTask<long> task = new TestTask<long>();
+
+ long res = Grid1.GetCompute().Execute(task, new Tuple<bool, long>(true, 10000000000));
+
+ Assert.AreEqual(10000000000, res);
+
+ res = Grid1.GetCompute().Execute(task, new Tuple<bool, long>(false, 10000000001));
+
+ Assert.AreEqual(10000000001, res);
+ }
+
+ /// <summary>
+ /// Test for task result.
+ /// </summary>
+ [Test]
+ public void TestTaskResultFloat()
+ {
+ TestTask<float> task = new TestTask<float>();
+
+ float res = Grid1.GetCompute().Execute(task, new Tuple<bool, float>(true, 1.1f));
+
+ Assert.AreEqual(1.1f, res);
+
+ res = Grid1.GetCompute().Execute(task, new Tuple<bool, float>(false, -1.1f));
+
+ Assert.AreEqual(-1.1f, res);
+ }
+
+ /// <summary>
+ /// Test for task result.
+ /// </summary>
+ [Test]
+ public void TestTaskResultPortable()
+ {
+ TestTask<PortableResult> task = new TestTask<PortableResult>();
+
+ PortableResult val = new PortableResult(100);
+
+ PortableResult res = Grid1.GetCompute().Execute(task, new Tuple<bool, PortableResult>(true, val));
+
+ Assert.AreEqual(val.Val, res.Val);
+
+ val.Val = 101;
+
+ res = Grid1.GetCompute().Execute(task, new Tuple<bool, PortableResult>(false, val));
+
+ Assert.AreEqual(val.Val, res.Val);
+ }
+
+ /// <summary>
+ /// Test for task result.
+ /// </summary>
+ [Test]
+ public void TestTaskResultSerializable()
+ {
+ TestTask<SerializableResult> task = new TestTask<SerializableResult>();
+
+ SerializableResult val = new SerializableResult(100);
+
+ SerializableResult res = Grid1.GetCompute().Execute(task, new Tuple<bool, SerializableResult>(true, val));
+
+ Assert.AreEqual(val.Val, res.Val);
+
+ val.Val = 101;
+
+ res = Grid1.GetCompute().Execute(task, new Tuple<bool, SerializableResult>(false, val));
+
+ Assert.AreEqual(val.Val, res.Val);
+ }
+
+ /// <summary>
+ /// Test for task result.
+ /// </summary>
+ [Test]
+ public void TestTaskResultLarge()
+ {
+ TestTask<byte[]> task = new TestTask<byte[]>();
+
+ byte[] res = Grid1.GetCompute().Execute(task,
+ new Tuple<bool, byte[]>(true, new byte[100 * 1024]));
+
+ Assert.AreEqual(100 * 1024, res.Length);
+
+ res = Grid1.GetCompute().Execute(task, new Tuple<bool, byte[]>(false, new byte[101 * 1024]));
+
+ Assert.AreEqual(101 * 1024, res.Length);
+ }
+
+ /** <inheritDoc /> */
+ override protected void PortableTypeConfigurations(ICollection<PortableTypeConfiguration> portTypeCfgs)
+ {
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableResult)));
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(TestPortableJob)));
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableOutFunc)));
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableFunc)));
+ }
+
+ [Test]
+ public void TestOutFuncResultPrimitive1()
+ {
+ ICollection<int> res = Grid1.GetCompute().Broadcast(new PortableOutFunc());
+
+ Assert.AreEqual(3, res.Count);
+
+ foreach (int r in res)
+ Assert.AreEqual(10, r);
+ }
+
+ [Test]
+ public void TestOutFuncResultPrimitive2()
+ {
+ ICollection<int> res = Grid1.GetCompute().Broadcast(new SerializableOutFunc());
+
+ Assert.AreEqual(3, res.Count);
+
+ foreach (int r in res)
+ Assert.AreEqual(10, r);
+ }
+
+ [Test]
+ public void TestFuncResultPrimitive1()
+ {
+ ICollection<int> res = Grid1.GetCompute().Broadcast(new PortableFunc(), 10);
+
+ Assert.AreEqual(3, res.Count);
+
+ foreach (int r in res)
+ Assert.AreEqual(11, r);
+ }
+
+ [Test]
+ public void TestFuncResultPrimitive2()
+ {
+ ICollection<int> res = Grid1.GetCompute().Broadcast(new SerializableFunc(), 10);
+
+ Assert.AreEqual(3, res.Count);
+
+ foreach (int r in res)
+ Assert.AreEqual(11, r);
+ }
+
+ interface IUserInterface<in T, out TR>
+ {
+ TR Invoke(T arg);
+ }
+
+ /// <summary>
+ /// Test function.
+ /// </summary>
+ public class PortableFunc : IComputeFunc<int, int>, IUserInterface<int, int>
+ {
+ int IComputeFunc<int, int>.Invoke(int arg)
+ {
+ return arg + 1;
+ }
+
+ int IUserInterface<int, int>.Invoke(int arg)
+ {
+ // Same signature as IComputeFunc<int, int>, but from different interface
+ throw new Exception("Invalid method");
+ }
+
+ public int Invoke(int arg)
+ {
+ // Same signature as IComputeFunc<int, int>,
+ // but due to explicit interface implementation this is a wrong method
+ throw new Exception("Invalid method");
+ }
+ }
+
+ /// <summary>
+ /// Test function.
+ /// </summary>
+ [Serializable]
+ public class SerializableFunc : IComputeFunc<int, int>
+ {
+ public int Invoke(int arg)
+ {
+ return arg + 1;
+ }
+ }
+
+ /// <summary>
+ /// Test function.
+ /// </summary>
+ public class PortableOutFunc : IComputeFunc<int>
+ {
+ public int Invoke()
+ {
+ return 10;
+ }
+ }
+
+ /// <summary>
+ /// Test function.
+ /// </summary>
+ [Serializable]
+ public class SerializableOutFunc : IComputeFunc<int>
+ {
+ public int Invoke()
+ {
+ return 10;
+ }
+ }
+
+ /// <summary>
+ /// Test task.
+ /// </summary>
+ public class TestTask<T> : ComputeTaskAdapter<Tuple<bool, T>, T, T>
+ {
+ /** <inheritDoc /> */
+ override public IDictionary<IComputeJob<T>, IClusterNode> Map(IList<IClusterNode> subgrid, Tuple<bool, T> arg)
+ {
+ _gridName = null;
+
+ Assert.AreEqual(3, subgrid.Count);
+
+ bool local = arg.Item1;
+ T res = arg.Item2;
+
+ var jobs = new Dictionary<IComputeJob<T>, IClusterNode>();
+
+ IComputeJob<T> job;
+
+ if (res is PortableResult)
+ {
+ TestPortableJob job0 = new TestPortableJob();
+
+ job0.SetArguments(res);
+
+ job = (IComputeJob<T>) job0;
+ }
+ else
+ {
+ TestJob<T> job0 = new TestJob<T>();
+
+ job0.SetArguments(res);
+
+ job = job0;
+ }
+
+ foreach (IClusterNode node in subgrid)
+ {
+ bool add = local ? node.IsLocal : !node.IsLocal;
+
+ if (add)
+ {
+ jobs.Add(job, node);
+
+ break;
+ }
+ }
+
+ Assert.AreEqual(1, jobs.Count);
+
+ return jobs;
+ }
+
+ /** <inheritDoc /> */
+ override public T Reduce(IList<IComputeJobResult<T>> results)
+ {
+ Assert.AreEqual(1, results.Count);
+
+ var res = results[0];
+
+ Assert.IsNull(res.Exception());
+
+ Assert.IsFalse(res.Cancelled);
+
+ Assert.IsNotNull(_gridName);
+
+ Assert.AreEqual(GridId(_gridName), res.NodeId);
+
+ var job = res.Job();
+
+ Assert.IsNotNull(job);
+
+ return res.Data();
+ }
+ }
+
+ private static Guid GridId(string gridName)
+ {
+ if (gridName.Equals(Grid1Name))
+ return Ignition.GetIgnite(Grid1Name).GetCluster().GetLocalNode().Id;
+ if (gridName.Equals(Grid2Name))
+ return Ignition.GetIgnite(Grid2Name).GetCluster().GetLocalNode().Id;
+ if (gridName.Equals(Grid3Name))
+ return Ignition.GetIgnite(Grid3Name).GetCluster().GetLocalNode().Id;
+
+ Assert.Fail("Failed to find grid " + gridName);
+
+ return new Guid();
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ class PortableResult
+ {
+ /** */
+ public int Val;
+
+ public PortableResult(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Serializable]
+ class SerializableResult
+ {
+ /** */
+ public int Val;
+
+ public SerializableResult(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Serializable]
+ class TestJob<T> : ComputeJobAdapter<T>
+ {
+ [InstanceResource]
+ private IIgnite _grid = null;
+
+ /** <inheritDoc /> */
+ override public T Execute()
+ {
+ Assert.IsNotNull(_grid);
+
+ _gridName = _grid.Name;
+
+ T res = Argument<T>(0);
+
+ return res;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ class TestPortableJob : ComputeJobAdapter<PortableResult>
+ {
+ [InstanceResource]
+ private IIgnite _grid = null;
+
+ /** <inheritDoc /> */
+ override public PortableResult Execute()
+ {
+ Assert.IsNotNull(_grid);
+
+ _gridName = _grid.Name;
+
+ PortableResult res = Argument<PortableResult>(0);
+
+ return res;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test
new file mode 100644
index 0000000..2bda365
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ 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.
+-->
+
+<configuration>
+ <startup>
+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
+ </startup>
+
+ <runtime>
+ <gcServer enabled="true" />
+ </runtime>
+
+ <appSettings>
+ <add key="Ignite.SpringConfigUrl" value="config\compute\compute-standalone.xml" />
+ <add key="Ignite.Assembly.1" value="test-1.dll" />
+ <add key="Ignite.Assembly.2" value="test-2.dll" />
+ <add key="Ignite.JvmOption.1" value="-DOPT1" />
+ <add key="Ignite.JvmOption.2" value="-DOPT2" />
+ <add key="Ignite.JvmOption.3" value="-Xms601m" />
+ <add key="Ignite.JvmOption.4" value="-Xmx702m" />
+ <add key="Ignite.JvmInitialMemoryMB" value="601" />
+ <add key="Ignite.JvmMaxMemoryMB" value="702" />
+ </appSettings>
+
+</configuration>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Cache/Store/cache-store-session.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Cache/Store/cache-store-session.xml b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Cache/Store/cache-store-session.xml
new file mode 100644
index 0000000..00837a9
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Cache/Store/cache-store-session.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="storeFactory" class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
+ <property name="assemblyName" value="Apache.Ignite.Core.Tests"/>
+ <property name="className" value="Apache.Ignite.Core.Tests.Cache.Store.CacheStoreSessionTest+Store"/>
+ </bean>
+
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="includeEventTypes">
+ <util:constant static-field="org.apache.ignite.events.EventType.EVTS_CACHE"/>
+ </property>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="cache1"/>
+ <property name="cacheMode" value="LOCAL"/>
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="writeThrough" value="true"/>
+ <property name="readThrough" value="true"/>
+
+ <property name="cacheStoreFactory" ref="storeFactory" />
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="cache2"/>
+ <property name="cacheMode" value="LOCAL"/>
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="writeThrough" value="true"/>
+ <property name="readThrough" value="true"/>
+
+ <property name="cacheStoreFactory" ref="storeFactory" />
+ </bean>
+ </list>
+ </property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47501</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
new file mode 100644
index 0000000..183676b
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="gridName" value="grid1"/>
+
+ <property name="metricsUpdateFrequency" value="1000"/>
+ <property name="metricsLogFrequency" value="0"/>
+
+ <property name="userAttributes">
+ <map>
+ <entry key="my_attr" value="value1"/>
+ </map>
+ </property>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="startSize" value="10"/>
+ </bean>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="cache1"/>
+ <property name="startSize" value="10"/>
+ </bean>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="cache2"/>
+ <property name="startSize" value="10"/>
+ </bean>
+ </list>
+ </property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47502</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+
+ <!-- Portable marshaller configuration -->
+ <property name="marshaller">
+ <bean class="org.apache.ignite.marshaller.portable.PortableMarshaller">
+ <property name="typeConfigurations">
+ <list>
+ <bean class="org.apache.ignite.portable.PortableTypeConfiguration">
+ <property name="className" value="org.apache.ignite.platform.PlatformComputePortable"/>
+ </bean>
+ <bean class="org.apache.ignite.portable.PortableTypeConfiguration">
+ <property name="className" value="org.apache.ignite.platform.PlatformComputeJavaPortable"/>
+ </bean>
+ <bean class="org.apache.ignite.portable.PortableTypeConfiguration">
+ <property name="className" value="org.apache.ignite.platform.PlatformComputeEnum"/>
+ </bean>
+ </list>
+ </property>
+ </bean>
+ </property>
+
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid2.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid2.xml b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid2.xml
new file mode 100644
index 0000000..434f468
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid2.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="gridName" value="grid2"/>
+
+ <property name="metricsUpdateFrequency" value="1000"/>
+ <property name="metricsLogFrequency" value="0"/>
+
+ <property name="userAttributes">
+ <map>
+ <entry key="my_attr" value="value2"/>
+ </map>
+ </property>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="cache1"/>
+ <property name="startSize" value="10"/>
+ </bean>
+ </list>
+ </property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47502</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid3.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid3.xml b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid3.xml
new file mode 100644
index 0000000..31ccdf0
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid3.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="clientMode" value="true"/>
+
+ <property name="gridName" value="grid3"/>
+
+ <property name="metricsUpdateFrequency" value="1000"/>
+ <property name="metricsLogFrequency" value="0"/>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="forceServerMode" value="true"/>
+
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47502</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml
new file mode 100644
index 0000000..bd34958
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="metricsLogFrequency" value="0"/>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration" />
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="cache1"/>
+ </bean>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="cache2"/>
+ </bean>
+ </list>
+ </property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <value>127.0.0.1:47500..47502</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+
+ <property name="platformConfiguration">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
+ <property name="portableConfiguration">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
+ <property name="types">
+ <list>
+ <value>Apache.Ignite.Core.Tests.ExecutableTest+RemoteConfiguration</value>
+ <value>Apache.Ignite.Core.Tests.ExecutableTest+RemoteConfigurationClosure</value>
+ <value>Apache.Ignite.Core.Tests.Compute.TaskAdapterTest+PortableJob</value>
+ <value>Apache.Ignite.Core.Tests.Compute.PortableClosureTaskTest+PortableOutFunc</value>
+ <value>Apache.Ignite.Core.Tests.Compute.PortableClosureTaskTest+PortableFunc</value>
+ <value>Apache.Ignite.Core.Tests.Compute.PortableClosureTaskTest+PortableResult</value>
+ <value>Apache.Ignite.Core.Tests.Compute.PortableClosureTaskTest+PortableException</value>
+ </list>
+ </property>
+ <property name="typesConfiguration">
+ <list>
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableTypeConfiguration">
+ <property name="typeName" value="org.apache.ignite.platform.PlatformComputePortable"/>
+ </bean>
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableTypeConfiguration">
+ <property name="typeName" value="org.apache.ignite.platform.PlatformComputeJavaPortable"/>
+ </bean>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Dynamic/dynamic-client.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Dynamic/dynamic-client.xml b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Dynamic/dynamic-client.xml
new file mode 100644
index 0000000..8f8893f
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Dynamic/dynamic-client.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="clientMode" value="true"/>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="forceServerMode" value="true"/>
+
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47502</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Dynamic/dynamic-data-no-cfg.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Dynamic/dynamic-data-no-cfg.xml b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Dynamic/dynamic-data-no-cfg.xml
new file mode 100644
index 0000000..83c6642
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Dynamic/dynamic-data-no-cfg.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47502</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Dynamic/dynamic-data.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Dynamic/dynamic-data.xml b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Dynamic/dynamic-data.xml
new file mode 100644
index 0000000..dbbae90
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Dynamic/dynamic-data.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="p"/>
+ <property name="cacheMode" value="PARTITIONED"/>
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="startSize" value="10"/>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="pa"/>
+ <property name="cacheMode" value="PARTITIONED"/>
+ <property name="atomicityMode" value="ATOMIC"/>
+ <property name="startSize" value="10"/>
+ </bean>
+ </list>
+ </property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47502</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Lifecycle/lifecycle-beans.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Lifecycle/lifecycle-beans.xml b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Lifecycle/lifecycle-beans.xml
new file mode 100644
index 0000000..da36032
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Lifecycle/lifecycle-beans.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="gridName" value="grid"/>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <value>127.0.0.1:47500..47502</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+
+ <property name="lifecycleBeans">
+ <list>
+ <bean class="org.apache.ignite.platform.lifecycle.PlatformJavaLifecycleBean" />
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetLifecycleBean">
+ <property name="className" value="Apache.Ignite.Core.Tests.Bean" />
+ </bean>
+ <bean class="org.apache.ignite.platform.lifecycle.PlatformJavaLifecycleBean" />
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetLifecycleBean">
+ <property name="className" value="Apache.Ignite.Core.Tests.Bean" />
+ <property name="properties">
+ <map>
+ <entry key="Property1">
+ <value type="java.lang.Integer">1</value>
+ </entry>
+ <entry key="Property2" value="1"/>
+ </map>
+ </property>
+ </bean>
+ <bean class="org.apache.ignite.platform.lifecycle.PlatformJavaLifecycleBean" />
+ </list>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Lifecycle/lifecycle-no-beans.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Lifecycle/lifecycle-no-beans.xml b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Lifecycle/lifecycle-no-beans.xml
new file mode 100644
index 0000000..4063e6e
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/Lifecycle/lifecycle-no-beans.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="gridName" value="grid"/>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <value>127.0.0.1:47500..47502</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml
new file mode 100644
index 0000000..84f9e5a
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="platformConfiguration">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
+ <property name="portableConfiguration">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
+ <property name="types">
+ <list>
+ <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64]</value>
+ <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Type]</value>
+ <value>Apache.Ignite.Core.Tests.TestGenericPortable[Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64]]</value>
+ <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Collections.Generic.List[System.Tuple[System.Int64,System.String]]]</value>
+ <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64,System.String]</value>
+ <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64,Apache.Ignite.Core.Tests.TestGenericPortable[System.String]]</value>
+ <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64,System.String,System.Type]</value>
+ <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64,System.String,Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64,System.String,System.Type]]</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+
+ <property name="includeEventTypes">
+ <util:constant static-field="org.apache.ignite.events.EventType.EVTS_CACHE"/>
+ </property>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration" />
+ </list>
+ </property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47501</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml
new file mode 100644
index 0000000..7f9ce40
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml
@@ -0,0 +1,171 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="transactional_no_backup"/>
+ <property name="cacheMode" value="PARTITIONED"/>
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="writeSynchronizationMode" value="FULL_SYNC"/>
+ <property name="backups" value="0"/>
+ <property name="startSize" value="10"/>
+ <property name="typeMetadata">
+ <list>
+ <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+ <property name="valueType" value="PortableEntry"/>
+ <property name="ascendingFields">
+ <map>
+ <entry key="val" value="java.lang.Integer"/>
+ </map>
+ </property>
+ <property name="queryFields">
+ <map>
+ <entry key="val" value="java.lang.Integer"/>
+ </map>
+ </property>
+ <property name="textFields">
+ <list>
+ <value>val</value>
+ </list>
+ </property>
+ </bean>
+ </list>
+ </property>
+ </bean>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="transactional_backup"/>
+ <property name="cacheMode" value="PARTITIONED"/>
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="writeSynchronizationMode" value="FULL_SYNC"/>
+ <property name="backups" value="1"/>
+ <property name="startSize" value="10"/>
+ <property name="typeMetadata">
+ <list>
+ <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+ <property name="valueType" value="PortableEntry"/>
+ <property name="ascendingFields">
+ <map>
+ <entry key="val" value="java.lang.Integer"/>
+ </map>
+ </property>
+ <property name="queryFields">
+ <map>
+ <entry key="val" value="java.lang.Integer"/>
+ </map>
+ </property>
+ <property name="textFields">
+ <list>
+ <value>val</value>
+ </list>
+ </property>
+ </bean>
+ </list>
+ </property>
+ </bean>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="atomic_no_backup"/>
+ <property name="cacheMode" value="PARTITIONED"/>
+ <property name="atomicityMode" value="ATOMIC"/>
+ <property name="writeSynchronizationMode" value="FULL_SYNC"/>
+ <property name="backups" value="0"/>
+ <property name="startSize" value="10"/>
+ <property name="typeMetadata">
+ <list>
+ <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+ <property name="valueType" value="PortableEntry"/>
+ <property name="ascendingFields">
+ <map>
+ <entry key="val" value="java.lang.Integer"/>
+ </map>
+ </property>
+ <property name="queryFields">
+ <map>
+ <entry key="val" value="java.lang.Integer"/>
+ </map>
+ </property>
+ <property name="textFields">
+ <list>
+ <value>val</value>
+ </list>
+ </property>
+ </bean>
+ </list>
+ </property>
+ </bean>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="atomic_backup"/>
+ <property name="cacheMode" value="PARTITIONED"/>
+ <property name="atomicityMode" value="ATOMIC"/>
+ <property name="writeSynchronizationMode" value="FULL_SYNC"/>
+ <property name="backups" value="1"/>
+ <property name="startSize" value="10"/>
+ <property name="typeMetadata">
+ <list>
+ <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+ <property name="valueType" value="PortableEntry"/>
+ <property name="ascendingFields">
+ <map>
+ <entry key="val" value="java.lang.Integer"/>
+ </map>
+ </property>
+ <property name="queryFields">
+ <map>
+ <entry key="val" value="java.lang.Integer"/>
+ </map>
+ </property>
+ <property name="textFields">
+ <list>
+ <value>val</value>
+ </list>
+ </property>
+ </bean>
+ </list>
+ </property>
+ </bean>
+ </list>
+ </property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47501</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/cache-query.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/cache-query.xml b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/cache-query.xml
new file mode 100644
index 0000000..787a921
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/cache-query.xml
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="platformConfiguration">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
+ <property name="portableConfiguration">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
+ <property name="types">
+ <list>
+ <value>Apache.Ignite.Core.Tests.Cache.Query.QueryPerson</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+
+ <property name="includeEventTypes">
+ <util:constant static-field="org.apache.ignite.events.EventType.EVTS_CACHE"/>
+ </property>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="cache"/>
+ <property name="cacheMode" value="PARTITIONED"/>
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="writeSynchronizationMode" value="FULL_SYNC"/>
+
+ <property name="typeMetadata">
+ <list>
+ <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+ <property name="valueType" value="QueryPerson"/>
+ <property name="ascendingFields">
+ <map>
+ <entry key="age" value="java.lang.Integer"/>
+ </map>
+ </property>
+ <property name="queryFields">
+ <map>
+ <entry key="name" value="java.lang.String"/>
+ <entry key="age" value="java.lang.Integer"/>
+ </map>
+ </property>
+ <property name="textFields">
+ <list>
+ <value>name</value>
+ </list>
+ </property>
+ </bean>
+ </list>
+ </property>
+ </bean>
+ </list>
+ </property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47501</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-default.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-default.xml b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-default.xml
new file mode 100644
index 0000000..753fad1
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-default.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47502</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-invalid.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-invalid.xml b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-invalid.xml
new file mode 100644
index 0000000..188781d
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-invalid.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="marshaller">
+ <bean class="org.apache.ignite.marshaller.optimized.OptimizedMarshaller" />
+ </property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47502</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-portable.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-portable.xml b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-portable.xml
new file mode 100644
index 0000000..753fad1
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-portable.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47502</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-affinity.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-affinity.xml b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-affinity.xml
new file mode 100644
index 0000000..f08018d
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-affinity.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="platformConfiguration">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
+ <property name="portableConfiguration">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
+ <property name="typesConfiguration">
+ <list>
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableTypeConfiguration">
+ <property name="typeName"
+ value="Apache.Ignite.Core.Tests.Cache.CacheAffinityTest+AffinityTestKey"/>
+ <property name="affinityKeyFieldName" value="_affKey"/>
+ </bean>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="cacheMode" value="PARTITIONED"/>
+ </bean>
+ </list>
+ </property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47501</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-parallel-store.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-parallel-store.xml b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-parallel-store.xml
new file mode 100644
index 0000000..00e8e45
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-parallel-store.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="includeEventTypes">
+ <util:constant static-field="org.apache.ignite.events.EventType.EVTS_CACHE"/>
+ </property>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="object_store_parallel"/>
+ <property name="cacheMode" value="LOCAL"/>
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="keepPortableInStore" value="false"/>
+
+ <property name="cacheStoreFactory">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
+ <property name="assemblyName" value="Apache.Ignite.Core.Tests"/>
+ <property name="className" value="Apache.Ignite.Core.Tests.Cache.Store.CacheTestParallelLoadStore"/>
+ </bean>
+ </property>
+ </bean>
+ </list>
+ </property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47501</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
[29/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
new file mode 100644
index 0000000..0f4ba5e
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
@@ -0,0 +1,137 @@
+/*
+ * 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.Examples
+{
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
+ using System.Linq;
+ using Apache.Ignite.Core.Tests.Process;
+ using Apache.Ignite.ExamplesDll.Compute;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests all examples in various modes.
+ /// </summary>
+ [Category(TestUtils.CategoryIntensive)]
+ public class ExamplesTest
+ {
+ /// <summary>
+ /// Tests the example in a single node mode.
+ /// </summary>
+ /// <param name="example">The example to run.</param>
+ [Test, TestCaseSource("TestCases")]
+ public void TestLocalNode(Example example)
+ {
+ example.Run();
+ }
+
+ /// <summary>
+ /// Tests the example with standalone Apache.Ignite.exe nodes.
+ /// </summary>
+ /// <param name="example">The example to run.</param>
+ [Test, TestCaseSource("TestCases")]
+ public void TestRemoteNodes(Example example)
+ {
+ TestRemoteNodes(example, false);
+ }
+
+ /// <summary>
+ /// Tests the example with standalone Apache.Ignite.exe nodes while local node is in client mode.
+ /// </summary>
+ /// <param name="example">The example to run.</param>
+ [Test, TestCaseSource("TestCases")]
+ public void TestRemoteNodesClientMode(Example example)
+ {
+ TestRemoteNodes(example, true);
+ }
+
+ /// <summary>
+ /// Tests the example with standalone Apache.Ignite.exe nodes.
+ /// </summary>
+ /// <param name="example">The example to run.</param>
+ /// <param name="clientMode">Client mode flag.</param>
+ private static void TestRemoteNodes(Example example, bool clientMode)
+ {
+ // Exclude CrossPlatformExample and LifecycleExample
+ if (string.IsNullOrEmpty(example.SpringConfigUrl))
+ {
+ Assert.IsTrue(new[] {"CrossPlatformExample", "LifecycleExample"}.Contains(example.Name));
+
+ return;
+ }
+
+ Assert.IsTrue(File.Exists(example.SpringConfigUrl));
+
+ var gridConfig = new IgniteConfiguration {SpringConfigUrl = example.SpringConfigUrl};
+
+ // Try with multiple standalone nodes
+ for (var i = 0; i < 2; i++)
+ {
+ // Start a grid to monitor topology
+ // Stop it after topology check so we don't interfere with example
+ Ignition.ClientMode = false;
+
+ using (var ignite = Ignition.Start(gridConfig))
+ {
+ var args = new List<string> {"-springConfigUrl=" + example.SpringConfigUrl};
+
+ if (example.NeedsTestDll)
+ args.Add(" -assembly=" + typeof(AverageSalaryJob).Assembly.Location);
+
+ // ReSharper disable once UnusedVariable
+ var proc = new IgniteProcess(args.ToArray());
+
+ Assert.IsTrue(ignite.WaitTopology(i + 2, 30000));
+ }
+
+ Ignition.ClientMode = clientMode;
+ example.Run();
+ }
+ }
+
+ /// <summary>
+ /// Fixture setup.
+ /// </summary>
+ [TestFixtureSetUp]
+ public void FixtureSetUp()
+ {
+ Environment.SetEnvironmentVariable("IGNITE_NATIVE_TEST_CLASSPATH", "true");
+
+ Directory.SetCurrentDirectory(PathUtil.IgniteHome);
+ }
+
+ /// <summary>
+ /// Test teardown.
+ /// </summary>
+ [TearDown]
+ public void TearDown()
+ {
+ Ignition.ClientMode = false;
+ IgniteProcess.KillAll();
+ }
+
+ /// <summary>
+ /// Gets the test cases.
+ /// </summary>
+ public IEnumerable<Example> TestCases
+ {
+ get { return Example.All; }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Examples/PathUtil.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Examples/PathUtil.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Examples/PathUtil.cs
new file mode 100644
index 0000000..4f9625f
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Examples/PathUtil.cs
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Examples
+{
+ using System.IO;
+ using Apache.Ignite.Core.Impl;
+
+ /// <summary>
+ /// Grid path resolver.
+ /// </summary>
+ public static class PathUtil
+ {
+ public static readonly string IgniteHome = IgniteManager.GetIgniteHome(null);
+
+ /// <summary>
+ /// Full Apache.Ignite.exe path.
+ /// </summary>
+ public static readonly string IgniteExePath = typeof(IgniteRunner).Assembly.Location;
+
+ /// <summary>
+ /// Examples source code path.
+ /// </summary>
+ public static readonly string ExamplesSourcePath = Path.Combine(IgniteHome, @"platforms\dotnet\Examples");
+
+ /// <summary>
+ /// Gets the full configuration path.
+ /// </summary>
+ public static string GetFullConfigPath(string springConfigUrl)
+ {
+ if (string.IsNullOrEmpty(springConfigUrl))
+ return springConfigUrl;
+
+ return Path.GetFullPath(Path.Combine(IgniteHome, springConfigUrl));
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Examples/ProjectFilesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Examples/ProjectFilesTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Examples/ProjectFilesTest.cs
new file mode 100644
index 0000000..24bd663
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Examples/ProjectFilesTest.cs
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Examples
+{
+ using System.IO;
+ using System.Linq;
+ using System.Text.RegularExpressions;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests project files.
+ /// </summary>
+ public class ProjectFilesTest
+ {
+ /// <summary>
+ /// Checks config files in examples comments for existence.
+ /// </summary>
+ [Test]
+ public void CheckConfigFilesExist()
+ {
+ Directory.GetFiles(PathUtil.ExamplesSourcePath, "*.cs", SearchOption.AllDirectories)
+ .Select(File.ReadAllText)
+ .SelectMany(src => Regex.Matches(src, @"modules\\platform[^\s]+.xml").OfType<Match>())
+ .Where(match => match.Success)
+ .Select(match => Path.Combine(PathUtil.IgniteHome, match.Value))
+ .ToList()
+ .ForEach(path => Assert.IsTrue(File.Exists(path), "Config file does not exist: " + path));
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
new file mode 100644
index 0000000..7a5a725
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
@@ -0,0 +1,352 @@
+/*
+ * 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.IO;
+ using System.Linq;
+ using System.Runtime.Serialization.Formatters.Binary;
+ using System.Threading.Tasks;
+ using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Impl;
+ using Apache.Ignite.Core.Portable;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests grid exceptions propagation.
+ /// </summary>
+ public class ExceptionsTest
+ {
+ /// <summary>
+ /// Before test.
+ /// </summary>
+ [SetUp]
+ public void SetUp()
+ {
+ TestUtils.KillProcesses();
+ }
+
+ /// <summary>
+ /// After test.
+ /// </summary>
+ [TearDown]
+ public void TearDown()
+ {
+ Ignition.StopAll(true);
+ }
+
+ /// <summary>
+ /// Tests exceptions.
+ /// </summary>
+ [Test]
+ public void TestExceptions()
+ {
+ var grid = StartGrid();
+
+ try
+ {
+ grid.GetCache<object, object>("invalidCacheName");
+
+ Assert.Fail();
+ }
+ catch (Exception e)
+ {
+ Assert.IsTrue(e is ArgumentException);
+ }
+
+ try
+ {
+ grid.GetCluster().ForRemotes().GetMetrics();
+
+ Assert.Fail();
+ }
+ catch (Exception e)
+ {
+ Assert.IsTrue(e is ClusterGroupEmptyException);
+ }
+
+ grid.Dispose();
+
+ try
+ {
+ grid.GetCache<object, object>("cache1");
+
+ Assert.Fail();
+ }
+ catch (Exception e)
+ {
+ Assert.IsTrue(e is InvalidOperationException);
+ }
+ }
+
+ /// <summary>
+ /// Tests CachePartialUpdateException keys propagation.
+ /// </summary>
+ [Test]
+ [Category(TestUtils.CategoryIntensive)]
+ public void TestPartialUpdateException()
+ {
+ // Primitive type
+ TestPartialUpdateException(false, (x, g) => x);
+
+ // User type
+ TestPartialUpdateException(false, (x, g) => new PortableEntry(x));
+ }
+
+ /// <summary>
+ /// Tests CachePartialUpdateException keys propagation in portable mode.
+ /// </summary>
+ [Test]
+ [Category(TestUtils.CategoryIntensive)]
+ public void TestPartialUpdateExceptionPortable()
+ {
+ // User type
+ TestPartialUpdateException(false, (x, g) => g.GetPortables().ToPortable<IPortableObject>(new PortableEntry(x)));
+ }
+
+ /// <summary>
+ /// Tests CachePartialUpdateException serialization.
+ /// </summary>
+ [Test]
+ public void TestPartialUpdateExceptionSerialization()
+ {
+ // Inner exception
+ TestPartialUpdateExceptionSerialization(new CachePartialUpdateException("Msg",
+ new IgniteException("Inner msg")));
+
+ // Primitive keys
+ TestPartialUpdateExceptionSerialization(new CachePartialUpdateException("Msg", new object[] {1, 2, 3}));
+
+ // User type keys
+ TestPartialUpdateExceptionSerialization(new CachePartialUpdateException("Msg",
+ new object[]
+ {
+ new SerializableEntry(1),
+ new SerializableEntry(2),
+ new SerializableEntry(3)
+ }));
+ }
+
+ /// <summary>
+ /// Tests CachePartialUpdateException serialization.
+ /// </summary>
+ private static void TestPartialUpdateExceptionSerialization(Exception ex)
+ {
+ var formatter = new BinaryFormatter();
+
+ var stream = new MemoryStream();
+
+ formatter.Serialize(stream, ex);
+
+ stream.Seek(0, SeekOrigin.Begin);
+
+ var ex0 = (Exception) formatter.Deserialize(stream);
+
+ var updateEx = ((CachePartialUpdateException) ex);
+
+ try
+ {
+ Assert.AreEqual(updateEx.GetFailedKeys<object>(),
+ ((CachePartialUpdateException)ex0).GetFailedKeys<object>());
+ }
+ catch (Exception e)
+ {
+ if (typeof (IgniteException) != e.GetType())
+ throw;
+ }
+
+ while (ex != null && ex0 != null)
+ {
+ Assert.AreEqual(ex0.GetType(), ex.GetType());
+ Assert.AreEqual(ex.Message, ex0.Message);
+
+ ex = ex.InnerException;
+ ex0 = ex0.InnerException;
+ }
+
+ Assert.AreEqual(ex, ex0);
+ }
+
+ /// <summary>
+ /// Tests CachePartialUpdateException keys propagation.
+ /// </summary>
+ [Test]
+ [Category(TestUtils.CategoryIntensive)]
+ public void TestPartialUpdateExceptionAsync()
+ {
+ // Primitive type
+ TestPartialUpdateException(true, (x, g) => x);
+
+ // User type
+ TestPartialUpdateException(true, (x, g) => new PortableEntry(x));
+ }
+
+ /// <summary>
+ /// Tests CachePartialUpdateException keys propagation in portable mode.
+ /// </summary>
+ [Test]
+ [Category(TestUtils.CategoryIntensive)]
+ public void TestPartialUpdateExceptionAsyncPortable()
+ {
+ TestPartialUpdateException(true, (x, g) => g.GetPortables().ToPortable<IPortableObject>(new PortableEntry(x)));
+ }
+
+ /// <summary>
+ /// Tests CachePartialUpdateException keys propagation.
+ /// </summary>
+ private static void TestPartialUpdateException<TK>(bool async, Func<int, IIgnite, TK> keyFunc)
+ {
+ using (var grid = StartGrid())
+ {
+ var cache = grid.GetCache<TK, int>("partitioned_atomic").WithNoRetries();
+
+ if (async)
+ cache = cache.WithAsync();
+
+ if (typeof (TK) == typeof (IPortableObject))
+ cache = cache.WithKeepPortable<TK, int>();
+
+ // Do cache puts in parallel
+ var putTask = Task.Factory.StartNew(() =>
+ {
+ try
+ {
+ // Do a lot of puts so that one fails during Ignite stop
+ for (var i = 0; i < 1000000; i++)
+ {
+ cache.PutAll(Enumerable.Range(1, 100).ToDictionary(k => keyFunc(k, grid), k => i));
+
+ if (async)
+ cache.GetFuture().Get();
+ }
+ }
+ catch (CachePartialUpdateException ex)
+ {
+ var failedKeys = ex.GetFailedKeys<TK>();
+
+ Assert.IsTrue(failedKeys.Any());
+
+ var failedKeysObj = ex.GetFailedKeys<object>();
+
+ Assert.IsTrue(failedKeysObj.Any());
+
+ return;
+ }
+
+ Assert.Fail("CachePartialUpdateException has not been thrown.");
+ });
+
+ while (true)
+ {
+ Ignition.Stop("grid_2", true);
+ StartGrid("grid_2");
+
+ if (putTask.Exception != null)
+ throw putTask.Exception;
+
+ if (putTask.IsCompleted)
+ return;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Starts the grid.
+ /// </summary>
+ private static IIgnite StartGrid(string gridName = null)
+ {
+ return Ignition.Start(new IgniteConfigurationEx
+ {
+ SpringConfigUrl = "config\\native-client-test-cache.xml",
+ JvmOptions = TestUtils.TestJavaOptions(),
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ GridName = gridName,
+ PortableConfiguration = new PortableConfiguration
+ {
+ TypeConfigurations = new[]
+ {
+ new PortableTypeConfiguration(typeof (PortableEntry))
+ }
+ }
+ });
+ }
+
+ /// <summary>
+ /// Portable entry.
+ /// </summary>
+ private class PortableEntry
+ {
+ /** Value. */
+ private readonly int _val;
+
+ /** <inheritDot /> */
+ public override int GetHashCode()
+ {
+ return _val;
+ }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="val">Value.</param>
+ public PortableEntry(int val)
+ {
+ _val = val;
+ }
+
+ /** <inheritDoc /> */
+ public override bool Equals(object obj)
+ {
+ return obj is PortableEntry && ((PortableEntry)obj)._val == _val;
+ }
+ }
+
+ /// <summary>
+ /// Portable entry.
+ /// </summary>
+ [Serializable]
+ private class SerializableEntry
+ {
+ /** Value. */
+ private readonly int _val;
+
+ /** <inheritDot /> */
+ public override int GetHashCode()
+ {
+ return _val;
+ }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="val">Value.</param>
+ public SerializableEntry(int val)
+ {
+ _val = val;
+ }
+
+ /** <inheritDoc /> */
+ public override bool Equals(object obj)
+ {
+ return obj is SerializableEntry && ((SerializableEntry)obj)._val == _val;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs
new file mode 100644
index 0000000..abb296c
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs
@@ -0,0 +1,443 @@
+/*
+ * 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.
+ */
+
+// ReSharper disable UnusedVariable
+// ReSharper disable UnusedAutoPropertyAccessor.Global
+namespace Apache.Ignite.Core.Tests
+{
+ using System;
+ using System.CodeDom.Compiler;
+ using System.Collections.Generic;
+ using Apache.Ignite.Core.Compute;
+ using Apache.Ignite.Core.Impl;
+ using Apache.Ignite.Core.Portable;
+ using Apache.Ignite.Core.Resource;
+ using Apache.Ignite.Core.Tests.Process;
+ using Microsoft.CSharp;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests for executable.
+ /// </summary>
+ public class ExecutableTest
+ {
+ /** Spring configuration path. */
+ private static readonly string SpringCfgPath = "config\\compute\\compute-standalone.xml";
+
+ /** Min memory Java task. */
+ private const string MinMemTask = "org.apache.ignite.platform.PlatformMinMemoryTask";
+
+ /** Max memory Java task. */
+ private const string MaxMemTask = "org.apache.ignite.platform.PlatformMaxMemoryTask";
+
+ /** Grid. */
+ private IIgnite _grid;
+
+ /// <summary>
+ /// Test fixture set-up routine.
+ /// </summary>
+ [TestFixtureSetUp]
+ public void TestFixtureSetUp()
+ {
+ TestUtils.KillProcesses();
+
+ _grid = Ignition.Start(Configuration(SpringCfgPath));
+ }
+
+ /// <summary>
+ /// Test fixture tear-down routine.
+ /// </summary>
+ [TestFixtureTearDown]
+ public void TestFixtureTearDown()
+ {
+ Ignition.StopAll(true);
+
+ TestUtils.KillProcesses();
+ }
+
+ /// <summary>
+ /// Set-up routine.
+ /// </summary>
+ [SetUp]
+ public void SetUp()
+ {
+ TestUtils.KillProcesses();
+
+ Assert.IsTrue(_grid.WaitTopology(1, 30000));
+
+ IgniteProcess.SaveConfigurationBackup();
+ }
+
+ /// <summary>
+ /// Tear-down routine.
+ /// </summary>
+ [TearDown]
+ public void TearDown()
+ {
+ IgniteProcess.RestoreConfigurationBackup();
+ }
+
+ /// <summary>
+ /// Test data pass through configuration file.
+ /// </summary>
+ [Test]
+ public void TestConfig()
+ {
+ IgniteProcess.ReplaceConfiguration("config\\Apache.Ignite.exe.config.test");
+
+ GenerateDll("test-1.dll");
+ GenerateDll("test-2.dll");
+
+ var proc = new IgniteProcess(
+ "-jvmClasspath=" + TestUtils.CreateTestClasspath()
+ );
+
+ Assert.IsTrue(_grid.WaitTopology(2, 30000));
+
+ var cfg = RemoteConfig();
+
+ Assert.AreEqual(SpringCfgPath, cfg.SpringConfigUrl);
+ Assert.IsTrue(cfg.JvmOptions.Contains("-DOPT1") && cfg.JvmOptions.Contains("-DOPT2"));
+ Assert.IsTrue(cfg.Assemblies.Contains("test-1.dll") && cfg.Assemblies.Contains("test-2.dll"));
+ Assert.AreEqual(601, cfg.JvmInitialMemoryMb);
+ Assert.AreEqual(702, cfg.JvmMaxMemoryMb);
+ }
+
+ /// <summary>
+ /// Test assemblies passing through command-line.
+ /// </summary>
+ [Test]
+ public void TestAssemblyCmd()
+ {
+ GenerateDll("test-1.dll");
+ GenerateDll("test-2.dll");
+
+ var proc = new IgniteProcess(
+ "-jvmClasspath=" + TestUtils.CreateTestClasspath(),
+ "-springConfigUrl=" + SpringCfgPath,
+ "-assembly=test-1.dll",
+ "-assembly=test-2.dll"
+ );
+
+ Assert.IsTrue(_grid.WaitTopology(2, 30000));
+
+ var cfg = RemoteConfig();
+
+ Assert.IsTrue(cfg.Assemblies.Contains("test-1.dll") && cfg.Assemblies.Contains("test-2.dll"));
+ }
+
+ /// <summary>
+ /// Test JVM options passing through command-line.
+ /// </summary>
+ [Test]
+ public void TestJvmOptsCmd()
+ {
+ var proc = new IgniteProcess(
+ "-jvmClasspath=" + TestUtils.CreateTestClasspath(),
+ "-springConfigUrl=" + SpringCfgPath,
+ "-J-DOPT1",
+ "-J-DOPT2"
+ );
+
+ Assert.IsTrue(_grid.WaitTopology(2, 30000));
+
+ var cfg = RemoteConfig();
+
+ Assert.IsTrue(cfg.JvmOptions.Contains("-DOPT1") && cfg.JvmOptions.Contains("-DOPT2"));
+ }
+
+ /// <summary>
+ /// Test JVM memory options passing through command-line: raw java options.
+ /// </summary>
+ [Test]
+ public void TestJvmMemoryOptsCmdRaw()
+ {
+ var proc = new IgniteProcess(
+ "-jvmClasspath=" + TestUtils.CreateTestClasspath(),
+ "-springConfigUrl=" + SpringCfgPath,
+ "-J-Xms506m",
+ "-J-Xmx607m"
+ );
+
+ Assert.IsTrue(_grid.WaitTopology(2, 30000));
+
+ var minMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MinMemTask, null);
+ Assert.AreEqual((long) 506*1024*1024, minMem);
+
+ var maxMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MaxMemTask, null);
+ AssertJvmMaxMemory((long) 607*1024*1024, maxMem);
+ }
+
+ /// <summary>
+ /// Test JVM memory options passing through command-line: custom options.
+ /// </summary>
+ [Test]
+ public void TestJvmMemoryOptsCmdCustom()
+ {
+ var proc = new IgniteProcess(
+ "-jvmClasspath=" + TestUtils.CreateTestClasspath(),
+ "-springConfigUrl=" + SpringCfgPath,
+ "-JvmInitialMemoryMB=615",
+ "-JvmMaxMemoryMB=863"
+ );
+
+ Assert.IsTrue(_grid.WaitTopology(2, 30000));
+
+ var minMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MinMemTask, null);
+ Assert.AreEqual((long) 615*1024*1024, minMem);
+
+ var maxMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MaxMemTask, null);
+ AssertJvmMaxMemory((long) 863*1024*1024, maxMem);
+ }
+
+ /// <summary>
+ /// Test JVM memory options passing from application configuration.
+ /// </summary>
+ [Test]
+ public void TestJvmMemoryOptsAppConfig()
+ {
+ IgniteProcess.ReplaceConfiguration("config\\Apache.Ignite.exe.config.test");
+
+ GenerateDll("test-1.dll");
+ GenerateDll("test-2.dll");
+
+ var proc = new IgniteProcess("-jvmClasspath=" + TestUtils.CreateTestClasspath());
+
+ Assert.IsTrue(_grid.WaitTopology(2, 30000));
+
+ var minMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MinMemTask, null);
+ Assert.AreEqual((long) 601*1024*1024, minMem);
+
+ var maxMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MaxMemTask, null);
+ AssertJvmMaxMemory((long) 702*1024*1024, maxMem);
+
+ proc.Kill();
+
+ Assert.IsTrue(_grid.WaitTopology(1, 30000));
+
+ // Command line options overwrite config file options
+ // ReSharper disable once RedundantAssignment
+ proc = new IgniteProcess("-jvmClasspath=" + TestUtils.CreateTestClasspath(),
+ "-J-Xms605m", "-J-Xmx706m");
+
+ Assert.IsTrue(_grid.WaitTopology(2, 30000));
+
+ minMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MinMemTask, null);
+ Assert.AreEqual((long) 605*1024*1024, minMem);
+
+ maxMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MaxMemTask, null);
+ AssertJvmMaxMemory((long) 706*1024*1024, maxMem);
+ }
+
+ /// <summary>
+ /// Test JVM memory options passing through command-line: custom options + raw options.
+ /// </summary>
+ [Test]
+ public void TestJvmMemoryOptsCmdCombined()
+ {
+ var proc = new IgniteProcess(
+ "-jvmClasspath=" + TestUtils.CreateTestClasspath(),
+ "-springConfigUrl=" + SpringCfgPath,
+ "-J-Xms555m",
+ "-J-Xmx666m",
+ "-JvmInitialMemoryMB=128",
+ "-JvmMaxMemoryMB=256"
+ );
+
+ Assert.IsTrue(_grid.WaitTopology(2, 30000));
+
+ // Raw JVM options (Xms/Xmx) should override custom options
+ var minMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MinMemTask, null);
+ Assert.AreEqual((long) 555*1024*1024, minMem);
+
+ var maxMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MaxMemTask, null);
+ AssertJvmMaxMemory((long) 666*1024*1024, maxMem);
+ }
+
+ /// <summary>
+ /// Get remote node configuration.
+ /// </summary>
+ /// <returns>Configuration.</returns>
+ private RemoteConfiguration RemoteConfig()
+ {
+ return _grid.GetCluster().ForRemotes().GetCompute().Call(new RemoteConfigurationClosure());
+ }
+
+ /// <summary>
+ /// Configuration for node.
+ /// </summary>
+ /// <param name="path">Path to Java XML configuration.</param>
+ /// <returns>Node configuration.</returns>
+ private static IgniteConfiguration Configuration(string path)
+ {
+ var cfg = new IgniteConfiguration();
+
+
+ var portCfg = new PortableConfiguration();
+
+ ICollection<PortableTypeConfiguration> portTypeCfgs = new List<PortableTypeConfiguration>();
+
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof (RemoteConfiguration)));
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof (RemoteConfigurationClosure)));
+
+ portCfg.TypeConfigurations = portTypeCfgs;
+
+ cfg.PortableConfiguration = portCfg;
+
+ cfg.JvmClasspath = TestUtils.CreateTestClasspath();
+
+ cfg.JvmOptions = new List<string>
+ {
+ "-ea",
+ "-Xcheck:jni",
+ "-Xms4g",
+ "-Xmx4g",
+ "-DIGNITE_QUIET=false",
+ "-Xnoagent",
+ "-Djava.compiler=NONE",
+ "-Xdebug",
+ "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005",
+ "-XX:+HeapDumpOnOutOfMemoryError"
+ };
+
+ cfg.SpringConfigUrl = path;
+
+ return cfg;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="outputPath"></param>
+ private static void GenerateDll(string outputPath)
+ {
+ var codeProvider = new CSharpCodeProvider();
+
+#pragma warning disable 0618
+
+ var icc = codeProvider.CreateCompiler();
+
+#pragma warning restore 0618
+
+ var parameters = new CompilerParameters();
+ parameters.GenerateExecutable = false;
+ parameters.OutputAssembly = outputPath;
+
+ var src = "namespace Apache.Ignite.Client.Test { public class Foo {}}";
+
+ var results = icc.CompileAssemblyFromSource(parameters, src);
+
+ Assert.False(results.Errors.HasErrors);
+ }
+
+ /// <summary>
+ /// Asserts that JVM maximum memory corresponds to Xmx parameter value.
+ /// </summary>
+ private static void AssertJvmMaxMemory(long expected, long actual)
+ {
+ // allow 20% tolerance because max memory in Java is not exactly equal to Xmx parameter value
+ Assert.LessOrEqual(actual, expected);
+ Assert.Greater(actual, expected/5*4);
+ }
+
+ /// <summary>
+ /// Closure which extracts configuration and passes it back.
+ /// </summary>
+ public class RemoteConfigurationClosure : IComputeFunc<RemoteConfiguration>
+ {
+
+#pragma warning disable 0649
+
+ /** Grid. */
+ [InstanceResource] private IIgnite _grid;
+
+#pragma warning restore 0649
+
+ /** <inheritDoc /> */
+
+ public RemoteConfiguration Invoke()
+ {
+ var grid0 = (Ignite) ((IgniteProxy) _grid).Target;
+
+ var cfg = grid0.Configuration;
+
+ var res = new RemoteConfiguration
+ {
+ IgniteHome = cfg.IgniteHome,
+ SpringConfigUrl = cfg.SpringConfigUrl,
+ JvmDll = cfg.JvmDllPath,
+ JvmClasspath = cfg.JvmClasspath,
+ JvmOptions = cfg.JvmOptions,
+ Assemblies = cfg.Assemblies,
+ JvmInitialMemoryMb = cfg.JvmInitialMemoryMb,
+ JvmMaxMemoryMb = cfg.JvmMaxMemoryMb
+ };
+
+ Console.WriteLine("RETURNING CFG: " + cfg);
+
+ return res;
+ }
+ }
+
+ /// <summary>
+ /// Configuration.
+ /// </summary>
+ public class RemoteConfiguration
+ {
+ /// <summary>
+ /// GG home.
+ /// </summary>
+ public string IgniteHome { get; set; }
+
+ /// <summary>
+ /// Spring config URL.
+ /// </summary>
+ public string SpringConfigUrl { get; set; }
+
+ /// <summary>
+ /// JVM DLL.
+ /// </summary>
+ public string JvmDll { get; set; }
+
+ /// <summary>
+ /// JVM classpath.
+ /// </summary>
+ public string JvmClasspath { get; set; }
+
+ /// <summary>
+ /// JVM options.
+ /// </summary>
+ public ICollection<string> JvmOptions { get; set; }
+
+ /// <summary>
+ /// Assemblies.
+ /// </summary>
+ public ICollection<string> Assemblies { get; set; }
+
+ /// <summary>
+ /// Minimum JVM memory (Xms).
+ /// </summary>
+ public int JvmInitialMemoryMb { get; set; }
+
+ /// <summary>
+ /// Maximum JVM memory (Xms).
+ /// </summary>
+ public int JvmMaxMemoryMb { get; set; }
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
new file mode 100644
index 0000000..993c604
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
@@ -0,0 +1,278 @@
+/*
+ * 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.Threading;
+ using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Compute;
+ using Apache.Ignite.Core.Portable;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Future tests.
+ /// </summary>
+ public class FutureTest
+ {
+ /** */
+ private ICache<object, object> _cache;
+
+ /** */
+ private ICompute _compute;
+
+ /// <summary>
+ /// Test fixture set-up routine.
+ /// </summary>
+ [TestFixtureSetUp]
+ public void TestFixtureSetUp()
+ {
+ TestUtils.KillProcesses();
+
+ var grid = Ignition.Start(new IgniteConfiguration
+ {
+ SpringConfigUrl = "config\\compute\\compute-standalone.xml",
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = TestUtils.TestJavaOptions(),
+ PortableConfiguration = new PortableConfiguration
+ {
+ TypeConfigurations =
+ new List<PortableTypeConfiguration> { new PortableTypeConfiguration(typeof(Portable)) }
+ }
+ });
+
+ _cache = grid.GetCache<object, object>(null).WithAsync();
+
+ _compute = grid.GetCompute().WithAsync();
+ }
+
+ /// <summary>
+ /// Test fixture tear-down routine.
+ /// </summary>
+ [TestFixtureTearDown]
+ public void TestFixtureTearDown()
+ {
+ TestUtils.KillProcesses();
+ }
+
+ [Test]
+ public void TestListen()
+ {
+ // Listen(Action callback)
+ TestListen((fut, act) => fut.Listen(act));
+
+ // Listen(Action<IFuture> callback)
+ TestListen((fut, act) => ((IFuture)fut).Listen(f =>
+ {
+ Assert.AreEqual(f, fut);
+ act();
+ }));
+
+ // Listen(Action<IFuture<T>> callback)
+ TestListen((fut, act) => fut.Listen(f =>
+ {
+ Assert.AreEqual(f, fut);
+ act();
+ }));
+ }
+
+ private void TestListen(Action<IFuture<object>, Action> listenAction)
+ {
+ _compute.Broadcast(new SleepAction());
+
+ var fut = _compute.GetFuture<object>();
+
+ var listenCount = 0;
+
+ // Multiple subscribers before completion
+ for (var i = 0; i < 10; i++)
+ listenAction(fut, () => Interlocked.Increment(ref listenCount));
+
+ Assert.IsFalse(fut.IsDone);
+
+ Assert.IsNull(fut.Get());
+
+ Thread.Sleep(100); // wait for future completion thread
+
+ Assert.AreEqual(10, listenCount);
+
+ // Multiple subscribers after completion
+ for (var i = 0; i < 10; i++)
+ listenAction(fut, () => Interlocked.Decrement(ref listenCount));
+
+ Assert.AreEqual(0, listenCount);
+ }
+
+ [Test]
+ public void TestToTask()
+ {
+ _cache.Put(1, 1);
+
+ _cache.GetFuture().ToTask().Wait();
+
+ _cache.Get(1);
+
+ var task1 = _cache.GetFuture<int>().ToTask();
+
+ Assert.AreEqual(1, task1.Result);
+
+ Assert.IsTrue(task1.IsCompleted);
+
+ _compute.Broadcast(new SleepAction());
+
+ var task2 = _compute.GetFuture().ToTask();
+
+ Assert.IsFalse(task2.IsCompleted);
+
+ Assert.IsFalse(task2.Wait(100));
+
+ task2.Wait();
+
+ Assert.IsTrue(task2.IsCompleted);
+
+ Assert.AreEqual(null, task2.Result);
+ }
+
+ [Test]
+ public void TestGetWithTimeout()
+ {
+ _compute.Broadcast(new SleepAction());
+
+ var fut = _compute.GetFuture();
+
+ Assert.Throws<TimeoutException>(() => fut.Get(TimeSpan.FromMilliseconds(100)));
+
+ fut.Get(TimeSpan.FromSeconds(1));
+
+ Assert.IsTrue(fut.IsDone);
+ }
+
+ [Test]
+ public void TestToAsyncResult()
+ {
+ _compute.Broadcast(new SleepAction());
+
+ IFuture fut = _compute.GetFuture();
+
+ var asyncRes = fut.ToAsyncResult();
+
+ Assert.IsFalse(asyncRes.IsCompleted);
+
+ Assert.IsTrue(asyncRes.AsyncWaitHandle.WaitOne(1000));
+
+ Assert.IsTrue(asyncRes.IsCompleted);
+ }
+
+ [Test]
+ public void TestFutureTypes()
+ {
+ TestType(false);
+ TestType((byte)11);
+ TestType('x'); // char
+ TestType(2.7d); // double
+ TestType(3.14f); // float
+ TestType(16); // int
+ TestType(17L); // long
+ TestType((short)18);
+
+ TestType(18m); // decimal
+
+ TestType(new Portable { A = 10, B = "foo" });
+ }
+
+ /// <summary>
+ /// Tests future type.
+ /// </summary>
+ private void TestType<T>(T value)
+ {
+ var key = typeof(T).Name;
+
+ _cache.Put(key, value);
+
+ _cache.GetFuture().Get();
+
+ _cache.Get(key);
+
+ Assert.AreEqual(value, _cache.GetFuture<T>().Get());
+ }
+
+ /// <summary>
+ /// Portable test class.
+ /// </summary>
+ private class Portable : IPortableMarshalAware
+ {
+ public int A;
+ public string B;
+
+ /** <inheritDoc /> */
+ public void WritePortable(IPortableWriter writer)
+ {
+ writer.WriteInt("a", A);
+ writer.RawWriter().WriteString(B);
+ }
+
+ /** <inheritDoc /> */
+ public void ReadPortable(IPortableReader reader)
+ {
+ A = reader.ReadInt("a");
+ B = reader.RawReader().ReadString();
+ }
+
+ /** <inheritDoc /> */
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj))
+ return false;
+
+ if (ReferenceEquals(this, obj))
+ return true;
+
+ if (obj.GetType() != GetType())
+ return false;
+
+ var other = (Portable)obj;
+
+ return A == other.A && string.Equals(B, other.B);
+ }
+
+ /** <inheritDoc /> */
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ // ReSharper disable NonReadonlyMemberInGetHashCode
+ return (A * 397) ^ (B != null ? B.GetHashCode() : 0);
+ // ReSharper restore NonReadonlyMemberInGetHashCode
+ }
+ }
+ }
+
+ /// <summary>
+ /// Compute action with a delay to ensure lengthy future execution.
+ /// </summary>
+ [Serializable]
+ private class SleepAction : IComputeAction
+ {
+ public void Invoke()
+ {
+ Thread.Sleep(500);
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/IgniteManagerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/IgniteManagerTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/IgniteManagerTest.cs
new file mode 100644
index 0000000..5a90c20
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/IgniteManagerTest.cs
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests
+{
+ using System;
+ using System.IO;
+ using Apache.Ignite.Core.Impl;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests IgniteManager class.
+ /// </summary>
+ public class IgniteManagerTest
+ {
+ /// <summary>
+ /// Tests home dir resolver.
+ /// </summary>
+ [Test]
+ public void TestIgniteHome()
+ {
+ var env = Environment.GetEnvironmentVariable(IgniteManager.EnvIgniteHome);
+
+ Environment.SetEnvironmentVariable(IgniteManager.EnvIgniteHome, null);
+
+ try
+ {
+ Assert.IsTrue(Directory.Exists(IgniteManager.GetIgniteHome(null)));
+ }
+ finally
+ {
+ // Restore
+ Environment.SetEnvironmentVariable(IgniteManager.EnvIgniteHome, env);
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
new file mode 100644
index 0000000..bd776ce
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
@@ -0,0 +1,422 @@
+/*
+ * 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.IO;
+ using System.Threading;
+ using System.Threading.Tasks;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Messaging;
+ using Apache.Ignite.Core.Tests.Process;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Ignite start/stop tests.
+ /// </summary>
+ [Category(TestUtils.CategoryIntensive)]
+ public class IgniteStartStopTest
+ {
+ /// <summary>
+ ///
+ /// </summary>
+ [SetUp]
+ public void SetUp()
+ {
+ TestUtils.KillProcesses();
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [TearDown]
+ public void TearDown()
+ {
+ TestUtils.KillProcesses();
+ Ignition.StopAll(true);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Test]
+ public void TestStartDefault()
+ {
+ var cfg = new IgniteConfiguration {JvmClasspath = TestUtils.CreateTestClasspath()};
+
+ var grid = Ignition.Start(cfg);
+
+ Assert.IsNotNull(grid);
+
+ Assert.AreEqual(1, grid.GetCluster().GetNodes().Count);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Test]
+ public void TestStartWithConfigPath()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = "config/default-config.xml",
+ JvmClasspath = TestUtils.CreateTestClasspath()
+ };
+
+ var grid = Ignition.Start(cfg);
+
+ Assert.IsNotNull(grid);
+
+ Assert.AreEqual(1, grid.GetCluster().GetNodes().Count);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Test]
+ public void TestStartGetStop()
+ {
+ var cfgs = new List<string> { "config\\start-test-grid1.xml", "config\\start-test-grid2.xml", "config\\start-test-grid3.xml" };
+
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = cfgs[0],
+ JvmOptions = TestUtils.TestJavaOptions(),
+ JvmClasspath = TestUtils.CreateTestClasspath()
+ };
+
+ var grid1 = Ignition.Start(cfg);
+
+ Assert.AreEqual("grid1", grid1.Name);
+
+ cfg.SpringConfigUrl = cfgs[1];
+
+ var grid2 = Ignition.Start(cfg);
+
+ Assert.AreEqual("grid2", grid2.Name);
+
+ cfg.SpringConfigUrl = cfgs[2];
+
+ var grid3 = Ignition.Start(cfg);
+
+ Assert.IsNull(grid3.Name);
+
+ Assert.AreSame(grid1, Ignition.GetIgnite("grid1"));
+
+ Assert.AreSame(grid2, Ignition.GetIgnite("grid2"));
+
+ Assert.AreSame(grid3, Ignition.GetIgnite(null));
+
+ try
+ {
+ Ignition.GetIgnite("invalid_name");
+ }
+ catch (IgniteException e)
+ {
+ Console.WriteLine("Expected exception: " + e);
+ }
+
+ Assert.IsTrue(Ignition.Stop("grid1", true));
+
+ try
+ {
+ Ignition.GetIgnite("grid1");
+ }
+ catch (IgniteException e)
+ {
+ Console.WriteLine("Expected exception: " + e);
+ }
+
+ grid2.Dispose();
+
+ try
+ {
+ Ignition.GetIgnite("grid2");
+ }
+ catch (IgniteException e)
+ {
+ Console.WriteLine("Expected exception: " + e);
+ }
+
+ grid3.Dispose();
+
+ try
+ {
+ Ignition.GetIgnite(null);
+ }
+ catch (IgniteException e)
+ {
+ Console.WriteLine("Expected exception: " + e);
+ }
+
+ foreach (var cfgName in cfgs)
+ {
+ cfg.SpringConfigUrl = cfgName;
+ cfg.JvmOptions = TestUtils.TestJavaOptions();
+
+ Ignition.Start(cfg);
+ }
+
+ foreach (var gridName in new List<string> { "grid1", "grid2", null })
+ Assert.IsNotNull(Ignition.GetIgnite(gridName));
+
+ Ignition.StopAll(true);
+
+ foreach (var gridName in new List<string> { "grid1", "grid2", null })
+ {
+ try
+ {
+ Ignition.GetIgnite(gridName);
+ }
+ catch (IgniteException e)
+ {
+ Console.WriteLine("Expected exception: " + e);
+ }
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Test]
+ public void TestStartTheSameName()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = "config\\start-test-grid1.xml",
+ JvmOptions = TestUtils.TestJavaOptions(),
+ JvmClasspath = TestUtils.CreateTestClasspath()
+ };
+
+ var grid1 = Ignition.Start(cfg);
+
+ Assert.AreEqual("grid1", grid1.Name);
+
+ try
+ {
+ Ignition.Start(cfg);
+
+ Assert.Fail("Start should fail.");
+ }
+ catch (IgniteException e)
+ {
+ Console.WriteLine("Expected exception: " + e);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Test]
+ public void TestUsageAfterStop()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = "config\\start-test-grid1.xml",
+ JvmOptions = TestUtils.TestJavaOptions(),
+ JvmClasspath = TestUtils.CreateTestClasspath()
+ };
+
+ var grid = Ignition.Start(cfg);
+
+ Assert.IsNotNull(grid.GetCache<int, int>("cache1"));
+
+ grid.Dispose();
+
+ try
+ {
+ grid.GetCache<int, int>("cache1");
+
+ Assert.Fail();
+ }
+ catch (InvalidOperationException e)
+ {
+ Console.WriteLine("Expected exception: " + e);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Test]
+ public void TestStartStopLeak()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = "config\\start-test-grid1.xml",
+ JvmOptions = new List<string> {"-Xcheck:jni", "-Xms256m", "-Xmx256m", "-XX:+HeapDumpOnOutOfMemoryError"},
+ JvmClasspath = TestUtils.CreateTestClasspath()
+ };
+
+ for (var i = 0; i < 20; i++)
+ {
+ Console.WriteLine("Iteration: " + i);
+
+ var grid = Ignition.Start(cfg);
+
+ UseIgnite(grid);
+
+ if (i % 2 == 0) // Try to stop ignite from another thread.
+ {
+ var t = new Thread(() => {
+ grid.Dispose();
+ });
+
+ t.Start();
+
+ t.Join();
+ }
+ else
+ grid.Dispose();
+
+ GC.Collect(); // At the time of writing java references are cleaned from finalizer, so GC is needed.
+ }
+ }
+
+ /// <summary>
+ /// Tests the client mode flag.
+ /// </summary>
+ [Test]
+ public void TestClientMode()
+ {
+ var servCfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = "config\\start-test-grid1.xml",
+ JvmOptions = TestUtils.TestJavaOptions(),
+ JvmClasspath = TestUtils.CreateTestClasspath()
+ };
+
+ var clientCfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = "config\\start-test-grid2.xml",
+ JvmOptions = TestUtils.TestJavaOptions(),
+ JvmClasspath = TestUtils.CreateTestClasspath()
+ };
+
+ try
+ {
+ using (Ignition.Start(servCfg)) // start server-mode ignite first
+ {
+ Ignition.ClientMode = true;
+
+ using (var grid = Ignition.Start(clientCfg))
+ {
+ UseIgnite(grid);
+ }
+ }
+ }
+ finally
+ {
+ Ignition.ClientMode = false;
+ }
+ }
+
+ /// <summary>
+ /// Uses the ignite.
+ /// </summary>
+ /// <param name="ignite">The ignite.</param>
+ private static void UseIgnite(IIgnite ignite)
+ {
+ // Create objects holding references to java objects.
+ var comp = ignite.GetCompute();
+
+ // ReSharper disable once RedundantAssignment
+ comp = comp.WithKeepPortable();
+
+ var prj = ignite.GetCluster().ForOldest();
+
+ Assert.IsTrue(prj.GetNodes().Count > 0);
+
+ Assert.IsNotNull(prj.GetCompute());
+
+ var cache = ignite.GetCache<int, int>("cache1");
+
+ Assert.IsNotNull(cache);
+
+ cache.GetAndPut(1, 1);
+
+ Assert.AreEqual(1, cache.Get(1));
+ }
+
+ /// <summary>
+ /// Tests the processor initialization and grid usage right after topology enter.
+ /// </summary>
+ [Test]
+ public void TestProcessorInit()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = "config\\start-test-grid1.xml",
+ JvmOptions = TestUtils.TestJavaOptions(),
+ JvmClasspath = TestUtils.CreateTestClasspath()
+ };
+
+ // Start local node
+ var grid = Ignition.Start(cfg);
+
+ // Start remote node in a separate process
+ // ReSharper disable once UnusedVariable
+ var proc = new IgniteProcess(
+ "-jvmClasspath=" + TestUtils.CreateTestClasspath(),
+ "-springConfigUrl=" + Path.GetFullPath(cfg.SpringConfigUrl),
+ "-J-Xms512m", "-J-Xmx512m");
+
+ var cts = new CancellationTokenSource();
+ var token = cts.Token;
+
+ // Spam message subscriptions on a separate thread
+ // to test race conditions during processor init on remote node
+ var listenTask = Task.Factory.StartNew(() =>
+ {
+ var filter = new MessageFilter();
+
+ while (!token.IsCancellationRequested)
+ {
+ var listenId = grid.GetMessaging().RemoteListen(filter);
+
+ grid.GetMessaging().StopRemoteListen(listenId);
+ }
+ // ReSharper disable once FunctionNeverReturns
+ });
+
+ // Wait for remote node to join
+ Assert.IsTrue(grid.WaitTopology(2, 30000));
+
+ // Wait some more for initialization
+ Thread.Sleep(1000);
+
+ // Cancel listen task and check that it finishes
+ cts.Cancel();
+ Assert.IsTrue(listenTask.Wait(5000));
+ }
+
+ /// <summary>
+ /// Noop message filter.
+ /// </summary>
+ [Serializable]
+ private class MessageFilter : IMessageFilter<int>
+ {
+ /** <inheritdoc /> */
+ public bool Invoke(Guid nodeId, int message)
+ {
+ return true;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/LifecycleTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/LifecycleTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/LifecycleTest.cs
new file mode 100644
index 0000000..84f446c
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/LifecycleTest.cs
@@ -0,0 +1,288 @@
+/*
+ * 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 Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Impl;
+ using Apache.Ignite.Core.Lifecycle;
+ using Apache.Ignite.Core.Resource;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Lifecycle beans test.
+ /// </summary>
+ public class LifecycleTest
+ {
+ /** Configuration: without Java beans. */
+ private const string CfgNoBeans = "config//lifecycle//lifecycle-no-beans.xml";
+
+ /** Configuration: with Java beans. */
+ private const string CfgBeans = "config//lifecycle//lifecycle-beans.xml";
+
+ /** Whether to throw an error on lifecycle event. */
+ internal static bool ThrowErr;
+
+ /** Events: before start. */
+ internal static IList<Event> BeforeStartEvts;
+
+ /** Events: after start. */
+ internal static IList<Event> AfterStartEvts;
+
+ /** Events: before stop. */
+ internal static IList<Event> BeforeStopEvts;
+
+ /** Events: after stop. */
+ internal static IList<Event> AfterStopEvts;
+
+ /// <summary>
+ /// Set up routine.
+ /// </summary>
+ [SetUp]
+ public void SetUp()
+ {
+ ThrowErr = false;
+
+ BeforeStartEvts = new List<Event>();
+ AfterStartEvts = new List<Event>();
+ BeforeStopEvts = new List<Event>();
+ AfterStopEvts = new List<Event>();
+ }
+
+ /// <summary>
+ /// Tear down routine.
+ /// </summary>
+ [TearDown]
+ public void TearDown()
+ {
+ Ignition.StopAll(true);
+ }
+
+ /// <summary>
+ /// Test without Java beans.
+ /// </summary>
+ [Test]
+ public void TestWithoutBeans()
+ {
+ // 1. Test start events.
+ IIgnite grid = Start(CfgNoBeans);
+
+ Assert.AreEqual(2, BeforeStartEvts.Count);
+ CheckEvent(BeforeStartEvts[0], null, null, 0, null);
+ CheckEvent(BeforeStartEvts[1], null, null, 0, null);
+
+ Assert.AreEqual(2, AfterStartEvts.Count);
+ CheckEvent(AfterStartEvts[0], grid, grid, 0, null);
+ CheckEvent(AfterStartEvts[1], grid, grid, 0, null);
+
+ // 2. Test stop events.
+ Ignition.Stop(grid.Name, false);
+
+ Assert.AreEqual(2, BeforeStartEvts.Count);
+ Assert.AreEqual(2, AfterStartEvts.Count);
+
+ Assert.AreEqual(2, BeforeStopEvts.Count);
+ CheckEvent(BeforeStopEvts[0], grid, grid, 0, null);
+ CheckEvent(BeforeStopEvts[1], grid, grid, 0, null);
+
+ Assert.AreEqual(2, AfterStopEvts.Count);
+ CheckEvent(AfterStopEvts[0], grid, grid, 0, null);
+ CheckEvent(AfterStopEvts[1], grid, grid, 0, null);
+ }
+
+ /// <summary>
+ /// Test with Java beans.
+ /// </summary>
+ [Test]
+ public void TestWithBeans()
+ {
+ // 1. Test .Net start events.
+ IIgnite grid = Start(CfgBeans);
+
+ Assert.AreEqual(4, BeforeStartEvts.Count);
+ CheckEvent(BeforeStartEvts[0], null, null, 0, null);
+ CheckEvent(BeforeStartEvts[1], null, null, 1, "1");
+ CheckEvent(BeforeStartEvts[2], null, null, 0, null);
+ CheckEvent(BeforeStartEvts[3], null, null, 0, null);
+
+ Assert.AreEqual(4, AfterStartEvts.Count);
+ CheckEvent(AfterStartEvts[0], grid, grid, 0, null);
+ CheckEvent(AfterStartEvts[1], grid, grid, 1, "1");
+ CheckEvent(AfterStartEvts[2], grid, grid, 0, null);
+ CheckEvent(AfterStartEvts[3], grid, grid, 0, null);
+
+ // 2. Test Java start events.
+ IList<int> res = grid.GetCompute().ExecuteJavaTask<IList<int>>(
+ "org.apache.ignite.platform.lifecycle.PlatformJavaLifecycleTask", null);
+
+ Assert.AreEqual(2, res.Count);
+ Assert.AreEqual(3, res[0]);
+ Assert.AreEqual(3, res[1]);
+
+ // 3. Test .Net stop events.
+ Ignition.Stop(grid.Name, false);
+
+ Assert.AreEqual(4, BeforeStartEvts.Count);
+ Assert.AreEqual(4, AfterStartEvts.Count);
+
+ Assert.AreEqual(4, BeforeStopEvts.Count);
+ CheckEvent(BeforeStopEvts[0], grid, grid, 0, null);
+ CheckEvent(BeforeStopEvts[1], grid, grid, 1, "1");
+ CheckEvent(BeforeStopEvts[2], grid, grid, 0, null);
+ CheckEvent(BeforeStopEvts[3], grid, grid, 0, null);
+
+ Assert.AreEqual(4, AfterStopEvts.Count);
+ CheckEvent(AfterStopEvts[0], grid, grid, 0, null);
+ CheckEvent(AfterStopEvts[1], grid, grid, 1, "1");
+ CheckEvent(AfterStopEvts[2], grid, grid, 0, null);
+ CheckEvent(AfterStopEvts[3], grid, grid, 0, null);
+ }
+
+ /// <summary>
+ /// Test behavior when error is thrown from lifecycle beans.
+ /// </summary>
+ [Test]
+ public void TestError()
+ {
+ ThrowErr = true;
+
+ try
+ {
+ Start(CfgNoBeans);
+
+ Assert.Fail("Should not reach this place.");
+ }
+ catch (Exception e)
+ {
+ Assert.AreEqual(typeof(IgniteException), e.GetType());
+ }
+ }
+
+ /// <summary>
+ /// Start grid.
+ /// </summary>
+ /// <param name="cfgPath">Spring configuration path.</param>
+ /// <returns>Grid.</returns>
+ private static IIgnite Start(string cfgPath)
+ {
+ TestUtils.JvmDebug = true;
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ cfg.JvmClasspath = TestUtils.CreateTestClasspath();
+ cfg.JvmOptions = TestUtils.TestJavaOptions();
+ cfg.SpringConfigUrl = cfgPath;
+
+ cfg.LifecycleBeans = new List<ILifecycleBean> { new Bean(), new Bean() };
+
+ return Ignition.Start(cfg);
+ }
+
+ /// <summary>
+ /// Check event.
+ /// </summary>
+ /// <param name="evt">Event.</param>
+ /// <param name="expGrid1">Expected grid 1.</param>
+ /// <param name="expGrid2">Expected grid 2.</param>
+ /// <param name="expProp1">Expected property 1.</param>
+ /// <param name="expProp2">Expected property 2.</param>
+ private static void CheckEvent(Event evt, IIgnite expGrid1, IIgnite expGrid2, int expProp1, string expProp2)
+ {
+ if (evt.Grid1 != null && evt.Grid1 is IgniteProxy)
+ evt.Grid1 = (evt.Grid1 as IgniteProxy).Target;
+
+ if (evt.Grid2 != null && evt.Grid2 is IgniteProxy)
+ evt.Grid2 = (evt.Grid2 as IgniteProxy).Target;
+
+ Assert.AreEqual(expGrid1, evt.Grid1);
+ Assert.AreEqual(expGrid2, evt.Grid2);
+ Assert.AreEqual(expProp1, evt.Prop1);
+ Assert.AreEqual(expProp2, evt.Prop2);
+ }
+ }
+
+ public abstract class AbstractBean
+ {
+ [InstanceResource]
+ public IIgnite Grid1;
+
+ public int Property1
+ {
+ get;
+ set;
+ }
+ }
+
+ public class Bean : AbstractBean, ILifecycleBean
+ {
+ [InstanceResource]
+ public IIgnite Grid2;
+
+ public string Property2
+ {
+ get;
+ set;
+ }
+
+ /** <inheritDoc /> */
+ public void OnLifecycleEvent(LifecycleEventType evtType)
+ {
+ if (LifecycleTest.ThrowErr)
+ throw new Exception("Lifecycle exception.");
+
+ Event evt = new Event();
+
+ evt.Grid1 = Grid1;
+ evt.Grid2 = Grid2;
+ evt.Prop1 = Property1;
+ evt.Prop2 = Property2;
+
+ switch (evtType)
+ {
+ case LifecycleEventType.BeforeNodeStart:
+ LifecycleTest.BeforeStartEvts.Add(evt);
+
+ break;
+
+ case LifecycleEventType.AfterNodeStart:
+ LifecycleTest.AfterStartEvts.Add(evt);
+
+ break;
+
+ case LifecycleEventType.BeforeNodeStop:
+ LifecycleTest.BeforeStopEvts.Add(evt);
+
+ break;
+
+ case LifecycleEventType.AfterNodeStop:
+ LifecycleTest.AfterStopEvts.Add(evt);
+
+ break;
+ }
+ }
+ }
+
+ public class Event
+ {
+ public IIgnite Grid1;
+ public IIgnite Grid2;
+ public int Prop1;
+ public string Prop2;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/LoadDllTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/LoadDllTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/LoadDllTest.cs
new file mode 100644
index 0000000..25ffab3
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/LoadDllTest.cs
@@ -0,0 +1,243 @@
+/*
+ * 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.CodeDom.Compiler;
+ using System.Collections.Generic;
+ using System.IO;
+ using System.Linq;
+ using Apache.Ignite.Core.Common;
+ using Microsoft.CSharp;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Dll loading test.
+ /// </summary>
+ public class LoadDllTest
+ {
+ /// <summary>
+ ///
+ /// </summary>
+ [SetUp]
+ public void SetUp()
+ {
+ TestUtils.KillProcesses();
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [TearDown]
+ public void TearDown()
+ {
+ Ignition.StopAll(true);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Test]
+ public void TestLoadFromGac()
+ {
+ Assert.False(IsLoaded("System.Data.Linq"));
+
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = "config\\start-test-grid3.xml",
+ Assemblies =
+ new List<string>
+ {
+ "System.Data.Linq,Culture=neutral,Version=1.0.0.0,PublicKeyToken=b77a5c561934e089"
+ },
+ JvmClasspath = TestUtils.CreateTestClasspath()
+ };
+
+
+ var grid = Ignition.Start(cfg);
+
+ Assert.IsNotNull(grid);
+
+ Assert.True(IsLoaded("System.Data.Linq"));
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Test]
+ public void TestLoadFromCurrentDir()
+ {
+ Assert.False(IsLoaded("testDll"));
+
+ GenerateDll("testDll.dll");
+
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = "config\\start-test-grid3.xml",
+ Assemblies = new List<string> {"testDll.dll"},
+ JvmClasspath = TestUtils.CreateTestClasspath()
+ };
+
+ var grid = Ignition.Start(cfg);
+
+ Assert.IsNotNull(grid);
+
+ Assert.True(IsLoaded("testDll"));
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Test]
+ public void TestLoadAllDllInDir()
+ {
+ var dirInfo = Directory.CreateDirectory(Path.GetTempPath() + "/testDlls");
+
+ Assert.False(IsLoaded("dllFromDir1"));
+ Assert.False(IsLoaded("dllFromDir2"));
+
+ GenerateDll(dirInfo.FullName + "/dllFromDir1.dll");
+ GenerateDll(dirInfo.FullName + "/dllFromDir2.dll");
+ File.WriteAllText(dirInfo.FullName + "/notADll.txt", "notADll");
+
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = "config\\start-test-grid3.xml",
+ Assemblies = new List<string> {dirInfo.FullName},
+ JvmClasspath = TestUtils.CreateTestClasspath()
+ };
+
+ var grid = Ignition.Start(cfg);
+
+ Assert.IsNotNull(grid);
+
+ Assert.True(IsLoaded("dllFromDir1"));
+ Assert.True(IsLoaded("dllFromDir2"));
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Test]
+ public void TestLoadFromCurrentDirByName()
+ {
+ Assert.False(IsLoaded("testDllByName"));
+
+ GenerateDll("testDllByName.dll");
+
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = "config\\start-test-grid3.xml",
+ Assemblies = new List<string> {"testDllByName"},
+ JvmClasspath = TestUtils.CreateTestClasspath()
+ };
+
+ var grid = Ignition.Start(cfg);
+
+ Assert.IsNotNull(grid);
+
+ Assert.True(IsLoaded("testDllByName"));
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Test]
+ public void TestLoadByAbsoluteUri()
+ {
+ var dllPath = Path.GetTempPath() + "/tempDll.dll";
+ Assert.False(IsLoaded("tempDll"));
+
+ GenerateDll(dllPath);
+
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = "config\\start-test-grid3.xml",
+ Assemblies = new List<string> {dllPath},
+ JvmClasspath = TestUtils.CreateTestClasspath()
+ };
+
+ var grid = Ignition.Start(cfg);
+
+ Assert.IsNotNull(grid);
+
+ Assert.True(IsLoaded("tempDll"));
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Test]
+ public void TestLoadUnexistingLibrary()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = "config\\start-test-grid3.xml",
+ Assemblies = new List<string> {"unexistingAssembly.820482.dll"},
+ JvmClasspath = TestUtils.CreateTestClasspath()
+ };
+
+ try
+ {
+ Ignition.Start(cfg);
+
+ Assert.Fail("Grid has been started with broken configuration.");
+ }
+ catch (IgniteException)
+ {
+
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="outputPath"></param>
+ private void GenerateDll(string outputPath)
+ {
+ var codeProvider = new CSharpCodeProvider();
+
+#pragma warning disable 0618
+
+ var icc = codeProvider.CreateCompiler();
+
+#pragma warning restore 0618
+
+ var parameters = new CompilerParameters
+ {
+ GenerateExecutable = false,
+ OutputAssembly = outputPath
+ };
+
+ var src = "namespace Apache.Ignite.Client.Test { public class Foo {}}";
+
+ var results = icc.CompileAssemblyFromSource(parameters, src);
+
+ Assert.False(results.Errors.HasErrors);
+ }
+
+ /// <summary>
+ /// Determines whether the specified assembly is loaded.
+ /// </summary>
+ /// <param name="asmName">Name of the assembly.</param>
+ private static bool IsLoaded(string asmName)
+ {
+ return AppDomain.CurrentDomain.GetAssemblies().Any(a => a.GetName().Name == asmName);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
new file mode 100644
index 0000000..d3af288
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
@@ -0,0 +1,71 @@
+/*
+ * 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 Apache.Ignite.Core.Common;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Test marshaller initialization.
+ /// </summary>
+ public class MarshallerTest
+ {
+ /// <summary>
+ /// Tests the default marhsaller.
+ /// By default, portable marshaller is used.
+ /// </summary>
+ [Test]
+ public void TestDefaultMarhsaller()
+ {
+ using (var grid = Ignition.Start("config\\marshaller-default.xml"))
+ {
+ var cache = grid.GetOrCreateCache<int, int>(null);
+
+ cache.Put(1, 1);
+
+ Assert.AreEqual(1, cache.Get(1));
+ }
+ }
+
+ /// <summary>
+ /// Tests the portable marhsaller.
+ /// PortableMarshaller can be specified explicitly in config.
+ /// </summary>
+ [Test]
+ public void TestPortableMarhsaller()
+ {
+ using (var grid = Ignition.Start("config\\marshaller-portable.xml"))
+ {
+ var cache = grid.GetOrCreateCache<int, int>(null);
+
+ cache.Put(1, 1);
+
+ Assert.AreEqual(1, cache.Get(1));
+ }
+ }
+
+ /// <summary>
+ /// Tests the invalid marshaller.
+ /// </summary>
+ [Test]
+ public void TestInvalidMarshaller()
+ {
+ Assert.Throws<IgniteException>(() => Ignition.Start("config\\marshaller-invalid.xml"));
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Memory/InteropMemoryTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Memory/InteropMemoryTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Memory/InteropMemoryTest.cs
new file mode 100644
index 0000000..e32e622
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Memory/InteropMemoryTest.cs
@@ -0,0 +1,213 @@
+/*
+ * 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.Memory
+{
+ using System;
+ using Apache.Ignite.Core.Impl.Memory;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests for interop memory.
+ /// </summary>
+ public class InteropMemoryTest
+ {
+ /// <summary>
+ /// Test pooled memory.
+ /// </summary>
+ [Test]
+ public void TestPooled()
+ {
+ PlatformMemoryManager mgr = new PlatformMemoryManager(256);
+
+ var mem1 = mgr.Allocate();
+ Assert.IsTrue(mem1 is PlatformPooledMemory);
+ Assert.IsTrue(mem1.Capacity >= 256);
+ Assert.IsTrue(mem1.Pointer > 0);
+ Assert.IsTrue(mem1.Data > 0);
+ Assert.AreEqual(0, mem1.Length);
+
+ mem1.Reallocate(512);
+
+ Assert.IsTrue(mem1.Capacity >= 512);
+ Assert.IsTrue(mem1.Pointer > 0);
+ Assert.IsTrue(mem1.Data > 0);
+ Assert.AreEqual(0, mem1.Length);
+
+ mem1.Length = 128;
+ Assert.AreEqual(128, mem1.Length);
+
+ mem1.Release();
+
+ Assert.AreSame(mem1, mgr.Allocate());
+ Assert.IsTrue(mem1.Capacity >= 512);
+ Assert.IsTrue(mem1.Pointer > 0);
+ Assert.IsTrue(mem1.Data > 0);
+ Assert.AreEqual(128, mem1.Length);
+
+ IPlatformMemory mem2 = mgr.Allocate();
+ Assert.IsTrue(mem2 is PlatformPooledMemory);
+
+ IPlatformMemory mem3 = mgr.Allocate();
+ Assert.IsTrue(mem3 is PlatformPooledMemory);
+
+ mem1.Release();
+ Assert.AreSame(mem1, mgr.Allocate());
+
+ mem2.Release();
+ Assert.AreSame(mem2, mgr.Allocate());
+
+ mem3.Release();
+ Assert.AreSame(mem3, mgr.Allocate());
+
+ mem1.Release();
+ mem2.Release();
+
+ Assert.AreSame(mem1, mgr.Allocate());
+ Assert.AreSame(mem2, mgr.Allocate());
+
+ IPlatformMemory unpooled = mgr.Allocate();
+
+ try
+ {
+ Assert.IsTrue(unpooled is PlatformUnpooledMemory);
+ }
+ finally
+ {
+ unpooled.Release();
+ }
+ }
+
+ /// <summary>
+ /// Test unpooled memory.
+ /// </summary>
+ [Test]
+ public void TestUnpooled()
+ {
+ PlatformMemoryManager mgr = new PlatformMemoryManager(256);
+
+ for (int i = 0; i < 3; i++)
+ mgr.Allocate();
+
+ IPlatformMemory mem1 = mgr.Allocate();
+ Assert.IsTrue(mem1 is PlatformUnpooledMemory);
+ Assert.IsTrue(mem1.Capacity >= 256);
+ Assert.IsTrue(mem1.Pointer > 0);
+ Assert.IsTrue(mem1.Data > 0);
+ Assert.AreEqual(0, mem1.Length);
+
+ mem1.Reallocate(512);
+ Assert.IsTrue(mem1.Capacity >= 512);
+ Assert.IsTrue(mem1.Pointer > 0);
+ Assert.IsTrue(mem1.Data > 0);
+ Assert.AreEqual(0, mem1.Length);
+
+ mem1.Length = 128;
+ Assert.AreEqual(128, mem1.Length);
+
+ mem1.Release();
+
+ IPlatformMemory mem2 = mgr.Allocate();
+ Assert.AreNotSame(mem1, mem2);
+ Assert.IsTrue(mem2.Capacity >= 256);
+ Assert.IsTrue(mem2.Pointer > 0);
+ Assert.IsTrue(mem2.Data > 0);
+ Assert.AreEqual(0, mem2.Length);
+
+ mem2.Release();
+ }
+
+ /// <summary>
+ /// Test pooled memory stream reallocation initiated from stream.
+ /// </summary>
+ [Test]
+ public void TestPooledStreamReallocate()
+ {
+ IPlatformMemory mem = new PlatformMemoryManager(256).Allocate();
+
+ try
+ {
+ Assert.IsTrue(mem is PlatformPooledMemory);
+
+ CheckStreamReallocate(mem);
+ }
+ finally
+ {
+ mem.Release();
+ }
+ }
+
+ /// <summary>
+ /// Test unpooled memory stream reallocation initiated from stream.
+ /// </summary>
+ [Test]
+ public void TestUnpooledStreamReallocate()
+ {
+ PlatformMemoryManager mgr = new PlatformMemoryManager(256);
+
+ for (int i = 0; i < 3; i++)
+ mgr.Allocate();
+
+ IPlatformMemory mem = mgr.Allocate();
+
+ try
+ {
+ Assert.IsTrue(mem is PlatformUnpooledMemory);
+
+ CheckStreamReallocate(mem);
+ }
+ finally
+ {
+ mem.Release();
+ }
+ }
+
+ /// <summary>
+ /// Check stream reallocation.
+ /// </summary>
+ /// <param name="mem">Memory.</param>
+ private void CheckStreamReallocate(IPlatformMemory mem)
+ {
+ Assert.IsTrue(mem.Capacity >= 256);
+
+ int dataLen = 2048 + 13;
+
+ Random rand = new Random();
+
+ byte[] data = new byte[dataLen];
+
+ for (int i = 0; i < data.Length; i++)
+ data[i] = (byte)rand.Next(0, 255);
+
+ PlatformMemoryStream stream = mem.Stream();
+
+ stream.WriteByteArray(data);
+
+ stream.SynchronizeOutput();
+
+ Assert.IsTrue(mem.Capacity >= dataLen);
+
+ stream.Reset();
+
+ stream.SynchronizeInput();
+
+ byte[] data0 = stream.ReadByteArray(dataLen);
+
+ Assert.AreEqual(data, data0);
+ }
+ }
+}
[04/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs
deleted file mode 100644
index a24c47c..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Threading;
-using Apache.Ignite.Core;
-using Apache.Ignite.ExamplesDll.Messaging;
-
-namespace Apache.Ignite.Examples.Messaging
-{
- /// <summary>
- /// Example demonstrating Ignite messaging. Should be run with standalone Apache Ignite .Net node.
- /// <para />
- /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
- /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-compute.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
- /// 2) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
- /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
- /// 3) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 4) Start example (F5 or Ctrl+F5).
- /// </summary>
- public class MessagingExample
- {
- /// <summary>
- /// Runs the example.
- /// </summary>
- [STAThread]
- public static void Main()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
- };
-
- using (var ignite = Ignition.Start(cfg))
- {
- var remotes = ignite.GetCluster().ForRemotes();
-
- if (remotes.GetNodes().Count == 0)
- {
- Console.WriteLine(">>> This example requires remote nodes to be started.");
- Console.WriteLine(">>> Please start at least 1 remote node.");
- Console.WriteLine(">>> Refer to example's documentation for details on configuration.");
- }
- else
- {
- Console.WriteLine(">>> Messaging example started.");
- Console.WriteLine();
-
- // Set up local listeners
- var localMessaging = ignite.GetCluster().ForLocal().GetMessaging();
-
- var msgCount = remotes.GetNodes().Count * 10;
-
- var orderedCounter = new CountdownEvent(msgCount);
- var unorderedCounter = new CountdownEvent(msgCount);
-
- localMessaging.LocalListen(new LocalListener(unorderedCounter), Topic.Unordered);
- localMessaging.LocalListen(new LocalListener(orderedCounter), Topic.Ordered);
-
- // Set up remote listeners
- var remoteMessaging = remotes.GetMessaging();
-
- remoteMessaging.RemoteListen(new RemoteUnorderedListener(), Topic.Unordered);
- remoteMessaging.RemoteListen(new RemoteOrderedListener(), Topic.Ordered);
-
- // Send unordered
- Console.WriteLine(">>> Sending unordered messages...");
-
- for (var i = 0; i < 10; i++)
- remoteMessaging.Send(i, Topic.Unordered);
-
- Console.WriteLine(">>> Finished sending unordered messages.");
-
- // Send ordered
- Console.WriteLine(">>> Sending ordered messages...");
-
- for (var i = 0; i < 10; i++)
- remoteMessaging.SendOrdered(i, Topic.Ordered);
-
- Console.WriteLine(">>> Finished sending ordered messages.");
-
- Console.WriteLine(">>> Check output on all nodes for message printouts.");
- Console.WriteLine(">>> Waiting for messages acknowledgements from all remote nodes...");
-
- unorderedCounter.Wait();
- orderedCounter.Wait();
- }
- }
-
- Console.WriteLine();
- Console.WriteLine(">>> Example finished, press any key to exit ...");
- Console.ReadKey();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs
deleted file mode 100644
index 2d319e8..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using Apache.Ignite.Core;
-using Apache.Ignite.Core.Lifecycle;
-using Apache.Ignite.Core.Resource;
-
-namespace Apache.Ignite.Examples.Misc
-{
- /// <summary>
- /// This example shows how to provide your own <see cref="ILifecycleBean"/> implementation
- /// to be able to hook into Apache lifecycle. Example bean will output occurred lifecycle
- /// events to the console.
- /// <para />
- /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
- /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
- /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 3) Start example (F5 or Ctrl+F5).
- /// </summary>
- public class LifecycleExample
- {
- /// <summary>
- /// Runs the example.
- /// </summary>
- [STAThread]
- public static void Main()
- {
- Console.WriteLine();
- Console.WriteLine(">>> Lifecycle example started.");
-
- // Create new configuration.
- var lifecycleExampleBean = new LifecycleExampleBean();
-
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" },
- LifecycleBeans = new List<ILifecycleBean> { lifecycleExampleBean }
- };
-
- // Provide lifecycle bean to configuration.
- using (Ignition.Start(cfg))
- {
- // Make sure that lifecycle bean was notified about Ignite startup.
- Console.WriteLine();
- Console.WriteLine(">>> Started (should be true): " + lifecycleExampleBean.Started);
- }
-
- // Make sure that lifecycle bean was notified about Ignite stop.
- Console.WriteLine();
- Console.WriteLine(">>> Started (should be false): " + lifecycleExampleBean.Started);
-
- Console.WriteLine();
- Console.WriteLine(">>> Example finished, press any key to exit ...");
- Console.ReadKey();
- }
-
- /// <summary>
- /// Sample lifecycle bean implementation.
- /// </summary>
- private class LifecycleExampleBean : ILifecycleBean
- {
- /** Auto-injected Ignite instance. */
- [InstanceResource]
-#pragma warning disable 649
- private IIgnite _ignite;
-#pragma warning restore 649
-
- /** <inheritDoc /> */
- public void OnLifecycleEvent(LifecycleEventType evt)
- {
- Console.WriteLine();
- Console.WriteLine(">>> Ignite lifecycle event occurred: " + evt);
- Console.WriteLine(">>> Ignite name: " + (_ignite != null ? _ignite.Name : "not available"));
-
- if (evt == LifecycleEventType.AfterNodeStart)
- Started = true;
- else if (evt == LifecycleEventType.AfterNodeStop)
- Started = false;
- }
-
- /// <summary>
- /// Started flag.
- /// </summary>
- public bool Started
- {
- get;
- private set;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs
deleted file mode 100644
index 555a35f..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-[assembly: AssemblyTitle("Apache Ignite Examples")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Apache Software Foundation")]
-[assembly: AssemblyProduct("Apache Ignite")]
-[assembly: AssemblyCopyright("Copyright © 2015")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-[assembly: ComVisible(false)]
-
-[assembly: Guid("41a0cb95-3435-4c78-b867-900b28e2c9ee")]
-
-[assembly: AssemblyVersion("1.5.0")]
-[assembly: AssemblyFileVersion("1.5.0")]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Services/IMapService.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Services/IMapService.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Services/IMapService.cs
deleted file mode 100644
index 7253a0b..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Services/IMapService.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using Apache.Ignite.ExamplesDll.Services;
-
-namespace Apache.Ignite.Examples.Services
-{
- /// <summary>
- /// Interface for service proxy interaction.
- /// Actual service class (<see cref="MapService{TK,TV}"/>) does not have to implement this interface.
- /// Target method/property will be searched by signature (name, arguments).
- /// </summary>
- public interface IMapService<TK, TV>
- {
- /// <summary>
- /// Puts an entry to the map.
- /// </summary>
- /// <param name="key">The key.</param>
- /// <param name="value">The value.</param>
- void Put(TK key, TV value);
-
- /// <summary>
- /// Gets an entry from the map.
- /// </summary>
- /// <param name="key">The key.</param>
- /// <returns>Entry value.</returns>
- TV Get(TK key);
-
- /// <summary>
- /// Clears the map.
- /// </summary>
- void Clear();
-
- /// <summary>
- /// Gets the size of the map.
- /// </summary>
- /// <value>
- /// The size.
- /// </value>
- int Size { get; }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Services/ServicesExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Services/ServicesExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Services/ServicesExample.cs
deleted file mode 100644
index 6d0ddd0..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Services/ServicesExample.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using Apache.Ignite.Core;
-using Apache.Ignite.ExamplesDll.Services;
-
-namespace Apache.Ignite.Examples.Services
-{
- /// <summary>
- /// Example demonstrating Ignite services.
- /// <para />
- /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
- /// Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
- /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
- /// Application -> Startup object);
- /// 3) Start example (F5 or Ctrl+F5).
- /// <para />
- /// This example can be run with standalone Apache Ignite .Net node:
- /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
- /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
- /// 2) Start example.
- /// </summary>
- public class ServicesExample
- {
- /// <summary>
- /// Runs the example.
- /// </summary>
- [STAThread]
- public static void Main()
- {
- var cfg = new IgniteConfiguration
- {
- SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
- JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
- };
-
- using (var ignite = Ignition.Start(cfg))
- {
- Console.WriteLine(">>> Services example started.");
- Console.WriteLine();
-
- // Deploy a service
- var svc = new MapService<int, string>();
- Console.WriteLine(">>> Deploying service to all nodes...");
- ignite.GetServices().DeployNodeSingleton("service", svc);
-
- // Get a sticky service proxy so that we will always be contacting the same remote node.
- var prx = ignite.GetServices().GetServiceProxy<IMapService<int, string>>("service", true);
-
- for (var i = 0; i < 10; i++)
- prx.Put(i, i.ToString());
-
- var mapSize = prx.Size;
-
- Console.WriteLine(">>> Map service size: " + mapSize);
-
- ignite.GetServices().CancelAll();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
deleted file mode 100644
index cb2ff6f..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
+++ /dev/null
@@ -1,75 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{DFB08363-202E-412D-8812-349EF10A8702}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>Apache.Ignite.ExamplesDll</RootNamespace>
- <AssemblyName>Apache.Ignite.ExamplesDll</AssemblyName>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
- <PlatformTarget>x64</PlatformTarget>
- <OutputPath>bin\x64\Debug\</OutputPath>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
- <PlatformTarget>x64</PlatformTarget>
- <OutputPath>bin\x64\Release\</OutputPath>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
- <DebugSymbols>true</DebugSymbols>
- <OutputPath>bin\x86\Debug\</OutputPath>
- <PlatformTarget>x86</PlatformTarget>
- <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
- <OutputPath>bin\x86\Release\</OutputPath>
- <PlatformTarget>x86</PlatformTarget>
- <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Compute\AverageSalaryJob.cs" />
- <Compile Include="Compute\AverageSalaryTask.cs" />
- <Compile Include="Compute\CharacterCountClosure.cs" />
- <Compile Include="Compute\CharacterCountReducer.cs" />
- <Compile Include="Datagrid\EmployeeStorePredicate.cs" />
- <Compile Include="Datagrid\ContinuousQueryFilter.cs" />
- <Compile Include="Datagrid\EmployeeStore.cs" />
- <Compile Include="Events\LocalListener.cs" />
- <Compile Include="Events\RemoteFilter.cs" />
- <Compile Include="Messaging\LocalListener.cs" />
- <Compile Include="Messaging\RemoteOrderedListener.cs" />
- <Compile Include="Messaging\RemoteUnorderedListener.cs" />
- <Compile Include="Messaging\Topic.cs" />
- <Compile Include="Portable\Account.cs" />
- <Compile Include="Portable\Address.cs" />
- <Compile Include="Portable\Employee.cs" />
- <Compile Include="Portable\EmployeeKey.cs" />
- <Compile Include="Portable\Organization.cs" />
- <Compile Include="Portable\OrganizationType.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Services\MapService.cs" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\Apache.Ignite.Core\Apache.Ignite.Core.csproj">
- <Project>{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}</Project>
- <Name>Apache.Ignite.Core</Name>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csprojrel
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csprojrel b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csprojrel
deleted file mode 100644
index fa6b71c..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csprojrel
+++ /dev/null
@@ -1,72 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{DFB08363-202E-412D-8812-349EF10A8702}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>Apache.Ignite.ExamplesDll</RootNamespace>
- <AssemblyName>Apache.Ignite.ExamplesDll</AssemblyName>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
- <PlatformTarget>x64</PlatformTarget>
- <OutputPath>bin\x64\Debug\</OutputPath>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
- <PlatformTarget>x64</PlatformTarget>
- <OutputPath>bin\x64\Release\</OutputPath>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
- <DebugSymbols>true</DebugSymbols>
- <OutputPath>bin\x86\Debug\</OutputPath>
- <PlatformTarget>x86</PlatformTarget>
- <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
- <OutputPath>bin\x86\Release\</OutputPath>
- <PlatformTarget>x86</PlatformTarget>
- <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="Apache.Ignite.Core">
- <HintPath>..\..\Apache.Ignite\bin\$(Platform)\$(Configuration)\Apache.Ignite.Core.dll</HintPath>
- </Reference>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Compute\AverageSalaryJob.cs" />
- <Compile Include="Compute\AverageSalaryTask.cs" />
- <Compile Include="Compute\CharacterCountClosure.cs" />
- <Compile Include="Compute\CharacterCountReducer.cs" />
- <Compile Include="Datagrid\EmployeeStorePredicate.cs" />
- <Compile Include="Datagrid\ContinuousQueryFilter.cs" />
- <Compile Include="Datagrid\EmployeeStore.cs" />
- <Compile Include="Events\LocalListener.cs" />
- <Compile Include="Events\RemoteFilter.cs" />
- <Compile Include="Messaging\LocalListener.cs" />
- <Compile Include="Messaging\RemoteOrderedListener.cs" />
- <Compile Include="Messaging\RemoteUnorderedListener.cs" />
- <Compile Include="Messaging\Topic.cs" />
- <Compile Include="Portable\Account.cs" />
- <Compile Include="Portable\Address.cs" />
- <Compile Include="Portable\Employee.cs" />
- <Compile Include="Portable\EmployeeKey.cs" />
- <Compile Include="Portable\Organization.cs" />
- <Compile Include="Portable\OrganizationType.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Services\MapService.cs" />
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs
deleted file mode 100644
index e4713d4..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using Apache.Ignite.Core.Compute;
-using Apache.Ignite.ExamplesDll.Portable;
-
-namespace Apache.Ignite.ExamplesDll.Compute
-{
- /// <summary>
- /// Average salary job.
- /// </summary>
- [Serializable]
- public class AverageSalaryJob : ComputeJobAdapter<Tuple<long, int>>
- {
- /// <summary> Employees. </summary>
- private readonly ICollection<Employee> _employees = new List<Employee>();
-
- /// <summary>
- /// Adds employee.
- /// </summary>
- /// <param name="employee">Employee.</param>
- public void Add(Employee employee)
- {
- _employees.Add(employee);
- }
-
- /// <summary>
- /// Execute the job.
- /// </summary>
- /// <returns>Job result: tuple with total salary in the first item and employees count in the second.</returns>
- override public Tuple<long, int> Execute()
- {
- long sum = 0;
- int count = 0;
-
- Console.WriteLine();
- Console.WriteLine(">>> Executing salary job for " + _employees.Count + " employee(s) ...");
- Console.WriteLine();
-
- foreach (Employee emp in _employees)
- {
- sum += emp.Salary;
- count++;
- }
-
- return new Tuple<long, int>(sum, count);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs
deleted file mode 100644
index f8acb01..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Apache.Ignite.Core.Compute;
-using Apache.Ignite.ExamplesDll.Portable;
-
-namespace Apache.Ignite.ExamplesDll.Compute
-{
- /// <summary>
- /// Average salary task.
- /// </summary>
- public class AverageSalaryTask : ComputeTaskSplitAdapter<ICollection<Employee>, Tuple<long, int>, long>
- {
- /// <summary>
- /// Split the task distributing employees between several jobs.
- /// </summary>
- /// <param name="gridSize">Number of available grid nodes.</param>
- /// <param name="arg">Task execution argument.</param>
- protected override ICollection<IComputeJob<Tuple<long, int>>> Split(int gridSize, ICollection<Employee> arg)
- {
- ICollection<Employee> employees = arg;
-
- var jobs = new List<IComputeJob<Tuple<long, int>>>(gridSize);
-
- int count = 0;
-
- foreach (Employee employee in employees)
- {
- int idx = count++ % gridSize;
-
- AverageSalaryJob job;
-
- if (idx >= jobs.Count)
- {
- job = new AverageSalaryJob();
-
- jobs.Add(job);
- }
- else
- job = (AverageSalaryJob) jobs[idx];
-
- job.Add(employee);
- }
-
- return jobs;
- }
-
- /// <summary>
- /// Calculate average salary after all jobs are finished.
- /// </summary>
- /// <param name="results">Job results.</param>
- /// <returns>Average salary.</returns>
- public override long Reduce(IList<IComputeJobResult<Tuple<long, int>>> results)
- {
- long sum = 0;
- int count = 0;
-
- foreach (var t in results.Select(result => result.Data()))
- {
- sum += t.Item1;
- count += t.Item2;
- }
-
- return sum / count;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountClosure.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountClosure.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountClosure.cs
deleted file mode 100644
index 2823221..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountClosure.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using Apache.Ignite.Core.Compute;
-
-namespace Apache.Ignite.ExamplesDll.Compute
-{
- /// <summary>
- /// Closure counting characters in a string.
- /// </summary>
- [Serializable]
- public class CharacterCountClosure : IComputeFunc<string, int>
- {
- /// <summary>
- /// Calculate character count of the given word.
- /// </summary>
- /// <param name="arg">Word.</param>
- /// <returns>Character count.</returns>
- public int Invoke(string arg)
- {
- int len = arg.Length;
-
- Console.WriteLine("Character count in word \"" + arg + "\": " + len);
-
- return len;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountReducer.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountReducer.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountReducer.cs
deleted file mode 100644
index 6825046..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountReducer.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using Apache.Ignite.Core.Compute;
-
-namespace Apache.Ignite.ExamplesDll.Compute
-{
- /// <summary>
- /// Character count reducer which collects individual string lengths and aggregate them.
- /// </summary>
- public class CharacterCountReducer : IComputeReducer<int, int>
- {
- /// <summary> Total length. </summary>
- private int _length;
-
- /// <summary>
- /// Collect character counts of distinct words.
- /// </summary>
- /// <param name="res">Character count of a distinct word.</param>
- /// <returns><c>True</c> to continue collecting results until all closures are finished.</returns>
- public bool Collect(int res)
- {
- _length += res;
-
- return true;
- }
-
- /// <summary>
- /// Reduce all collected results.
- /// </summary>
- /// <returns>Total character count.</returns>
- public int Reduce()
- {
- return _length;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/ContinuousQueryFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/ContinuousQueryFilter.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/ContinuousQueryFilter.cs
deleted file mode 100644
index 8c05f42..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/ContinuousQueryFilter.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using Apache.Ignite.Core.Cache.Event;
-
-namespace Apache.Ignite.ExamplesDll.Datagrid
-{
- /// <summary>
- /// Filter for continuous query example.
- /// </summary>
- [Serializable]
- public class ContinuousQueryFilter : ICacheEntryEventFilter<int, string>
- {
- /// <summary> Threshold. </summary>
- private readonly int _threshold;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="threshold">Threshold.</param>
- public ContinuousQueryFilter(int threshold)
- {
- _threshold = threshold;
- }
-
- /// <summary>
- /// Evaluates cache entry event.
- /// </summary>
- /// <param name="evt">Event.</param>
- public bool Evaluate(ICacheEntryEvent<int, string> evt)
- {
- return evt.Key >= _threshold;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs
deleted file mode 100644
index 742b048..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
-using Apache.Ignite.Core.Cache;
-using Apache.Ignite.Core.Cache.Store;
-using Apache.Ignite.ExamplesDll.Portable;
-
-namespace Apache.Ignite.ExamplesDll.Datagrid
-{
- /// <summary>
- /// Example cache store implementation.
- /// </summary>
- public class EmployeeStore : CacheStoreAdapter
- {
- /// <summary>
- /// Dictionary representing the store.
- /// </summary>
- private readonly ConcurrentDictionary<object, object> _db = new ConcurrentDictionary<object, object>(
- new List<KeyValuePair<object, object>>
- {
- new KeyValuePair<object, object>(1, new Employee(
- "Allison Mathis",
- 25300,
- new Address("2702 Freedom Lane, San Francisco, CA", 94109),
- new List<string> {"Development"}
- )),
-
- new KeyValuePair<object, object>(2, new Employee(
- "Breana Robbin",
- 6500,
- new Address("3960 Sundown Lane, Austin, TX", 78130),
- new List<string> {"Sales"}
- ))
- });
-
- /// <summary>
- /// Loads all values from underlying persistent storage.
- /// This method gets called as a result of <see cref="ICache{TK,TV}.LoadCache"/> call.
- /// </summary>
- /// <param name="act">Action that loads a cache entry.</param>
- /// <param name="args">Optional arguments.</param>
- public override void LoadCache(Action<object, object> act, params object[] args)
- {
- // Iterate over whole underlying store and call act on each entry to load it into the cache.
- foreach (var entry in _db)
- act(entry.Key, entry.Value);
- }
-
- /// <summary>
- /// Loads multiple objects from the cache store.
- /// This method gets called as a result of <see cref="ICache{K,V}.GetAll"/> call.
- /// </summary>
- /// <param name="keys">Keys to load.</param>
- /// <returns>
- /// A map of key, values to be stored in the cache.
- /// </returns>
- public override IDictionary LoadAll(ICollection keys)
- {
- var result = new Dictionary<object, object>();
-
- foreach (var key in keys)
- result[key] = Load(key);
-
- return result;
- }
-
- /// <summary>
- /// Loads an object from the cache store.
- /// This method gets called as a result of <see cref="ICache{K,V}.Get"/> call.
- /// </summary>
- /// <param name="key">Key to load.</param>
- /// <returns>Loaded value</returns>
- public override object Load(object key)
- {
- object val;
-
- _db.TryGetValue(key, out val);
-
- return val;
- }
-
- /// <summary>
- /// Write key-value pair to store.
- /// </summary>
- /// <param name="key">Key to write.</param>
- /// <param name="val">Value to write.</param>
- public override void Write(object key, object val)
- {
- _db[key] = val;
- }
-
- /// <summary>
- /// Delete cache entry form store.
- /// </summary>
- /// <param name="key">Key to delete.</param>
- public override void Delete(object key)
- {
- object val;
-
- _db.TryRemove(key, out val);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs
deleted file mode 100644
index a585e5e..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using Apache.Ignite.Core.Cache;
-using Apache.Ignite.ExamplesDll.Portable;
-
-namespace Apache.Ignite.ExamplesDll.Datagrid
-{
- /// <summary>
- /// Example cache entry predicate.
- /// </summary>
- [Serializable]
- public class EmployeeStorePredicate : ICacheEntryFilter<int, Employee>
- {
- /// <summary>
- /// Returns a value indicating whether provided cache entry satisfies this predicate.
- /// </summary>
- /// <param name="entry">Cache entry.</param>
- /// <returns>Value indicating whether provided cache entry satisfies this predicate.</returns>
- public bool Invoke(ICacheEntry<int, Employee> entry)
- {
- return entry.Key == 1;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
deleted file mode 100644
index 8a28355..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Threading;
-using Apache.Ignite.Core.Events;
-
-namespace Apache.Ignite.ExamplesDll.Events
-{
- /// <summary>
- /// Local event listener.
- /// </summary>
- public class LocalListener : IEventFilter<IEvent>
- {
- /** Сount of received events. */
- private int _eventsReceived;
-
- /// <summary>
- /// Gets the count of received events.
- /// </summary>
- public int EventsReceived
- {
- get { return _eventsReceived; }
- }
-
- /// <summary>
- /// Determines whether specified event passes this filter.
- /// </summary>
- /// <param name="nodeId">Node identifier.</param>
- /// <param name="evt">Event.</param>
- /// <returns>Value indicating whether specified event passes this filter.</returns>
- public bool Invoke(Guid nodeId, IEvent evt)
- {
- Interlocked.Increment(ref _eventsReceived);
-
- Console.WriteLine("Local listener received an event [evt={0}]", evt.Name);
-
- return true;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs
deleted file mode 100644
index db3204a..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using Apache.Ignite.Core.Events;
-
-namespace Apache.Ignite.ExamplesDll.Events
-{
- /// <summary>
- /// Remote event filter.
- /// </summary>
- [Serializable]
- public class RemoteFilter : IEventFilter<IEvent>
- {
- /// <summary>
- /// Determines whether specified event passes this filter.
- /// </summary>
- /// <param name="nodeId">Node identifier.</param>
- /// <param name="evt">Event.</param>
- /// <returns>Value indicating whether specified event passes this filter.</returns>
- public bool Invoke(Guid nodeId, IEvent evt)
- {
- Console.WriteLine("Remote filter received event [evt={0}]", evt.Name);
-
- return evt is JobEvent;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs
deleted file mode 100644
index 7659bb4..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Threading;
-using Apache.Ignite.Core.Messaging;
-
-namespace Apache.Ignite.ExamplesDll.Messaging
-{
- /// <summary>
- /// Local message listener which signals countdown event on each received message.
- /// </summary>
- public class LocalListener : IMessageFilter<int>
- {
- /** Countdown event. */
- private readonly CountdownEvent _countdown;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="LocalListener"/> class.
- /// </summary>
- /// <param name="countdown">The countdown event.</param>
- public LocalListener(CountdownEvent countdown)
- {
- if (countdown == null)
- throw new ArgumentNullException("countdown");
-
- _countdown = countdown;
- }
-
- /// <summary>
- /// Receives a message and returns a value
- /// indicating whether provided message and node id satisfy this predicate.
- /// Returning false will unsubscribe this listener from future notifications.
- /// </summary>
- /// <param name="nodeId">Node identifier.</param>
- /// <param name="message">Message.</param>
- /// <returns>Value indicating whether provided message and node id satisfy this predicate.</returns>
- public bool Invoke(Guid nodeId, int message)
- {
- _countdown.Signal();
-
- return !_countdown.IsSet;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs
deleted file mode 100644
index 8ae5ac1..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using Apache.Ignite.Core;
-using Apache.Ignite.Core.Messaging;
-using Apache.Ignite.Core.Resource;
-
-namespace Apache.Ignite.ExamplesDll.Messaging
-{
- /// <summary>
- /// Listener for Ordered topic.
- /// </summary>
- [Serializable]
- public class RemoteOrderedListener : IMessageFilter<int>
- {
- /** Injected Ignite instance. */
- [InstanceResource]
-#pragma warning disable 649
- private readonly IIgnite _ignite;
-#pragma warning restore 649
-
- /// <summary>
- /// Receives a message and returns a value
- /// indicating whether provided message and node id satisfy this predicate.
- /// Returning false will unsubscribe this listener from future notifications.
- /// </summary>
- /// <param name="nodeId">Node identifier.</param>
- /// <param name="message">Message.</param>
- /// <returns>Value indicating whether provided message and node id satisfy this predicate.</returns>
- public bool Invoke(Guid nodeId, int message)
- {
- Console.WriteLine("Received ordered message [msg={0}, fromNodeId={1}]", message, nodeId);
-
- _ignite.GetCluster().ForNodeIds(nodeId).GetMessaging().Send(message, Topic.Ordered);
-
- return true;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs
deleted file mode 100644
index 166dbd6..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using Apache.Ignite.Core;
-using Apache.Ignite.Core.Messaging;
-using Apache.Ignite.Core.Resource;
-
-namespace Apache.Ignite.ExamplesDll.Messaging
-{
- /// <summary>
- /// Listener for Unordered topic.
- /// </summary>
- [Serializable]
- public class RemoteUnorderedListener : IMessageFilter<int>
- {
- /** Injected Ignite instance. */
- [InstanceResource]
-#pragma warning disable 649
- private readonly IIgnite _ignite;
-#pragma warning restore 649
-
- /// <summary>
- /// Receives a message and returns a value
- /// indicating whether provided message and node id satisfy this predicate.
- /// Returning false will unsubscribe this listener from future notifications.
- /// </summary>
- /// <param name="nodeId">Node identifier.</param>
- /// <param name="message">Message.</param>
- /// <returns>Value indicating whether provided message and node id satisfy this predicate.</returns>
- public bool Invoke(Guid nodeId, int message)
- {
- Console.WriteLine("Received unordered message [msg={0}, fromNodeId={1}]", message, nodeId);
-
- _ignite.GetCluster().ForNodeIds(nodeId).GetMessaging().Send(message, Topic.Unordered);
-
- return true;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/Topic.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/Topic.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/Topic.cs
deleted file mode 100644
index bda0bfe..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/Topic.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.ExamplesDll.Messaging
-{
- /// <summary>
- /// Message topics.
- /// </summary>
- public static class Topic
- {
- public const int Ordered = 1;
- public const int Unordered = 2;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Account.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Account.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Account.cs
deleted file mode 100644
index 8e247e3..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Account.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-
-namespace Apache.Ignite.ExamplesDll.Portable
-{
- /// <summary>
- /// Account object. Used in transaction example.
- /// </summary>
- [Serializable]
- public class Account
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="id">Account ID.</param>
- /// <param name="balance">Account balance.</param>
- public Account(int id, decimal balance)
- {
- Id = id;
- Balance = balance;
- }
-
- /// <summary>
- /// Account ID.
- /// </summary>
- public int Id { get; set; }
-
- /// <summary>
- /// Account balance.
- /// </summary>
- public decimal Balance { get; set; }
-
- /// <summary>
- /// Returns a string that represents the current object.
- /// </summary>
- /// <returns>
- /// A string that represents the current object.
- /// </returns>
- override public String ToString()
- {
- return string.Format("{0} [id={1}, balance={2}]", typeof(Account).Name, Id, Balance);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Address.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Address.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Address.cs
deleted file mode 100644
index ca069cb..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Address.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using Apache.Ignite.Core.Portable;
-
-namespace Apache.Ignite.ExamplesDll.Portable
-{
- /// <summary>
- /// Address.
- /// </summary>
- [Serializable]
- public class Address : IPortableMarshalAware
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="street">Street.</param>
- /// <param name="zip">ZIP code.</param>
- public Address(string street, int zip)
- {
- Street = street;
- Zip = zip;
- }
-
- /// <summary>
- /// Street.
- /// </summary>
- public string Street { get; set; }
-
- /// <summary>
- /// ZIP code.
- /// </summary>
- public int Zip { get; set; }
-
- /// <summary>
- /// Writes this object to the given writer.
- /// </summary>
- /// <param name="writer">Writer.</param>
- public void WritePortable(IPortableWriter writer)
- {
- writer.WriteString("street", Street);
- writer.WriteInt("zip", Zip);
- }
-
- /// <summary>
- /// Reads this object from the given reader.
- /// </summary>
- /// <param name="reader">Reader.</param>
- public void ReadPortable(IPortableReader reader)
- {
- Street = reader.ReadString("street");
- Zip = reader.ReadInt("zip");
- }
-
- /// <summary>
- /// Returns a string that represents the current object.
- /// </summary>
- /// <returns>
- /// A string that represents the current object.
- /// </returns>
- override public string ToString()
- {
- return string.Format("{0} [street={1}, zip={2}]", typeof(Address).Name, Street, Zip);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Employee.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Employee.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Employee.cs
deleted file mode 100644
index 7f4388d..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Employee.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace Apache.Ignite.ExamplesDll.Portable
-{
- /// <summary>
- /// Employee.
- /// </summary>
- [Serializable]
- public class Employee
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="name">Name.</param>
- /// <param name="salary">Salary.</param>
- /// <param name="address">Address.</param>
- /// <param name="departments">Departments.</param>
- public Employee(string name, long salary, Address address, ICollection<string> departments)
- {
- Name = name;
- Salary = salary;
- Address = address;
- Departments = departments;
- }
-
- /// <summary>
- /// Name.
- /// </summary>
- public string Name { get; set; }
-
- /// <summary>
- /// Salary.
- /// </summary>
- public long Salary { get; set; }
-
- /// <summary>
- /// Address.
- /// </summary>
- public Address Address { get; set; }
-
- /// <summary>
- /// Departments.
- /// </summary>
- public ICollection<string> Departments { get; set; }
-
- /// <summary>
- /// Returns a string that represents the current object.
- /// </summary>
- /// <returns>
- /// A string that represents the current object.
- /// </returns>
- override public string ToString()
- {
- return string.Format("{0} [name={1}, salary={2}, address={3}, departments={4}]", typeof(Employee).Name,
- Name, Salary, Address, CollectionToString(Departments));
- }
-
- /// <summary>
- /// Get string representation of collection.
- /// </summary>
- /// <returns></returns>
- private static string CollectionToString<T>(ICollection<T> col)
- {
- if (col == null)
- return "null";
-
- var elements = col.Any()
- ? col.Select(x => x.ToString()).Aggregate((x, y) => x + ", " + y)
- : string.Empty;
-
- return string.Format("[{0}]", elements);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs
deleted file mode 100644
index 2267154..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-
-namespace Apache.Ignite.ExamplesDll.Portable
-{
- /// <summary>
- /// Employee key. Used in query example to co-locate employees with their organizations.
- /// </summary>
- [Serializable]
- public class EmployeeKey
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="id">ID.</param>
- /// <param name="orgId">Organization ID.</param>
- public EmployeeKey(int id, int orgId)
- {
- Id = id;
- OrganizationId = orgId;
- }
-
- /// <summary>
- /// ID.
- /// </summary>
- public int Id { get; private set; }
-
- /// <summary>
- /// Organization ID.
- /// </summary>
- public int OrganizationId { get; private set; }
-
- /// <summary>
- /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
- /// </summary>
- /// <returns>
- /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
- /// </returns>
- /// <param name="obj">The object to compare with the current object. </param><filterpriority>2</filterpriority>
- public override bool Equals(object obj)
- {
- EmployeeKey other = obj as EmployeeKey;
-
- return other != null && Id == other.Id && OrganizationId == other.OrganizationId;
- }
-
- /// <summary>
- /// Serves as a hash function for a particular type.
- /// </summary>
- /// <returns>
- /// A hash code for the current <see cref="T:System.Object"/>.
- /// </returns>
- /// <filterpriority>2</filterpriority>
- public override int GetHashCode()
- {
- return 31 * Id + OrganizationId;
- }
-
- /// <summary>
- /// Returns a string that represents the current object.
- /// </summary>
- /// <returns>
- /// A string that represents the current object.
- /// </returns>
- public override string ToString()
- {
- return string.Format("{0} [id={1}, organizationId={2}]", typeof (EmployeeKey).Name, Id, OrganizationId);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Organization.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Organization.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Organization.cs
deleted file mode 100644
index e23c3c1..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Organization.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-
-namespace Apache.Ignite.ExamplesDll.Portable
-{
- /// <summary>
- /// Organization.
- /// </summary>
- [Serializable]
- public class Organization
- {
- /// <summary>
- /// Default constructor.
- /// </summary>
- public Organization()
- {
- // No-op.
- }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="name">Name.</param>
- /// <param name="address">Address.</param>
- /// <param name="type">Type.</param>
- /// <param name="lastUpdated">Last update time.</param>
- public Organization(string name, Address address, OrganizationType type, DateTime lastUpdated)
- {
- Name = name;
- Address = address;
- Type = type;
- LastUpdated = lastUpdated;
- }
-
- /// <summary>
- /// Name.
- /// </summary>
- public string Name { get; set; }
-
- /// <summary>
- /// Address.
- /// </summary>
- public Address Address { get; set; }
-
- /// <summary>
- /// Type.
- /// </summary>
- public OrganizationType Type { get; set; }
-
- /// <summary>
- /// Last update time.
- /// </summary>
- public DateTime LastUpdated { get; set; }
-
- /// <summary>
- /// Returns a string that represents the current object.
- /// </summary>
- /// <returns>
- /// A string that represents the current object.
- /// </returns>
- /// <filterpriority>2</filterpriority>
- public override string ToString()
- {
- return string.Format("{0} [name={1}, address={2}, type={3}, lastUpdated={4}]", typeof (Organization).Name,
- Name, Address, Type, LastUpdated);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs
deleted file mode 100644
index 198edb1..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-
-namespace Apache.Ignite.ExamplesDll.Portable
-{
- /// <summary>
- /// Organization type.
- /// </summary>
- [Serializable]
- public enum OrganizationType
- {
- /// <summary>
- /// Non-profit organization.
- /// </summary>
- NonProfit,
-
- /// <summary>
- /// Private organization.
- /// </summary>
- Private,
-
- /// <summary>
- /// Government organization.
- /// </summary>
- Government
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs
deleted file mode 100644
index f149d64..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-[assembly: AssemblyTitle("Apache Ignite Examples Dll")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Apache Software Foundation")]
-[assembly: AssemblyProduct("Apache Ignite")]
-[assembly: AssemblyCopyright("Copyright © 2015")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-[assembly: ComVisible(false)]
-
-[assembly: Guid("ce65ec7c-d3cf-41ad-8f45-f90d5af68d77")]
-
-[assembly: AssemblyVersion("1.5.0")]
-[assembly: AssemblyFileVersion("1.5.0")]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/525d66df/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Services/MapService.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Services/MapService.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Services/MapService.cs
deleted file mode 100644
index d577ff7..0000000
--- a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Services/MapService.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using Apache.Ignite.Core;
-using Apache.Ignite.Core.Cache;
-using Apache.Ignite.Core.Resource;
-using Apache.Ignite.Core.Services;
-
-namespace Apache.Ignite.ExamplesDll.Services
-{
- /// <summary>
- /// Service implementation.
- /// </summary>
- [Serializable]
- public class MapService<TK, TV> : IService
- {
- /** Injected Ignite instance. */
-#pragma warning disable 649
- [InstanceResource] private readonly IIgnite _ignite;
-#pragma warning restore 649
-
- /** Cache. */
- private ICache<TK, TV> _cache;
-
- /// <summary>
- /// Initializes this instance before execution.
- /// </summary>
- /// <param name="context">Service execution context.</param>
- public void Init(IServiceContext context)
- {
- // Create a new cache for every service deployment.
- // Note that we use service name as cache name, which allows
- // for each service deployment to use its own isolated cache.
- _cache = _ignite.GetOrCreateCache<TK, TV>("MapService_" + context.Name);
-
- Console.WriteLine("Service initialized: " + context.Name);
- }
-
- /// <summary>
- /// Starts execution of this service. This method is automatically invoked whenever an instance of the service
- /// is deployed on an Ignite node. Note that service is considered deployed even after it exits the Execute
- /// method and can be cancelled (or undeployed) only by calling any of the Cancel methods on
- /// <see cref="IServices"/> API. Also note that service is not required to exit from Execute method until
- /// Cancel method was called.
- /// </summary>
- /// <param name="context">Service execution context.</param>
- public void Execute(IServiceContext context)
- {
- Console.WriteLine("Service started: " + context.Name);
- }
-
- /// <summary>
- /// Cancels this instance.
- /// <para/>
- /// Note that Ignite cannot guarantee that the service exits from <see cref="IService.Execute"/>
- /// method whenever <see cref="IService.Cancel"/> is called. It is up to the user to
- /// make sure that the service code properly reacts to cancellations.
- /// </summary>
- /// <param name="context">Service execution context.</param>
- public void Cancel(IServiceContext context)
- {
- Console.WriteLine("Service cancelled: " + context.Name);
- }
-
- /// <summary>
- /// Puts an entry to the map.
- /// </summary>
- /// <param name="key">The key.</param>
- /// <param name="value">The value.</param>
- public void Put(TK key, TV value)
- {
- _cache.Put(key, value);
- }
-
- /// <summary>
- /// Gets an entry from the map.
- /// </summary>
- /// <param name="key">The key.</param>
- /// <returns>Entry value.</returns>
- public TV Get(TK key)
- {
- return _cache.Get(key);
- }
-
- /// <summary>
- /// Clears the map.
- /// </summary>
- public void Clear()
- {
- _cache.Clear();
- }
-
- /// <summary>
- /// Gets the size of the map.
- /// </summary>
- /// <value>
- /// The size.
- /// </value>
- public int Size
- {
- get { return _cache.GetSize(); }
- }
- }
-}
[28/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/MessagingTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/MessagingTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/MessagingTest.cs
new file mode 100644
index 0000000..95e48d3
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/MessagingTest.cs
@@ -0,0 +1,646 @@
+/*
+ * 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.Diagnostics.CodeAnalysis;
+ using System.Linq;
+ using System.Threading;
+ using System.Threading.Tasks;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Messaging;
+ using Apache.Ignite.Core.Resource;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// <see cref="IMessaging"/> tests.
+ /// </summary>
+ public class MessagingTest
+ {
+ /** */
+ private IIgnite _grid1;
+
+ /** */
+ private IIgnite _grid2;
+
+ /** */
+ private IIgnite _grid3;
+
+ /** */
+ public static int MessageId;
+
+ /// <summary>
+ /// Executes before each test.
+ /// </summary>
+ [SetUp]
+ public void SetUp()
+ {
+ _grid1 = Ignition.Start(Configuration("config\\compute\\compute-grid1.xml"));
+ _grid2 = Ignition.Start(Configuration("config\\compute\\compute-grid2.xml"));
+ _grid3 = Ignition.Start(Configuration("config\\compute\\compute-grid3.xml"));
+ }
+
+ /// <summary>
+ /// Executes after each test.
+ /// </summary>
+ [TearDown]
+ public virtual void TearDown()
+ {
+ try
+ {
+ TestUtils.AssertHandleRegistryIsEmpty(1000, _grid1, _grid2, _grid3);
+
+ MessagingTestHelper.AssertFailures();
+ }
+ finally
+ {
+ // Stop all grids between tests to drop any hanging messages
+ Ignition.StopAll(true);
+ }
+ }
+
+ /// <summary>
+ /// Tests LocalListen.
+ /// </summary>
+ [Test]
+ public void TestLocalListen()
+ {
+ TestLocalListen(null);
+ TestLocalListen("string topic");
+ TestLocalListen(NextId());
+ }
+
+ /// <summary>
+ /// Tests LocalListen.
+ /// </summary>
+ [SuppressMessage("ReSharper", "AccessToModifiedClosure")]
+ public void TestLocalListen(object topic)
+ {
+ var messaging = _grid1.GetMessaging();
+ var listener = MessagingTestHelper.GetListener();
+ messaging.LocalListen(listener, topic);
+
+ // Test sending
+ CheckSend(topic);
+ CheckSend(topic, _grid2);
+ CheckSend(topic, _grid3);
+
+ // Test different topic
+ CheckNoMessage(NextId());
+ CheckNoMessage(NextId(), _grid2);
+
+ // Test multiple subscriptions for the same filter
+ messaging.LocalListen(listener, topic);
+ messaging.LocalListen(listener, topic);
+ CheckSend(topic, repeatMultiplier: 3); // expect all messages repeated 3 times
+
+ messaging.StopLocalListen(listener, topic);
+ CheckSend(topic, repeatMultiplier: 2); // expect all messages repeated 2 times
+
+ messaging.StopLocalListen(listener, topic);
+ CheckSend(topic); // back to 1 listener
+
+ // Test message type mismatch
+ var ex = Assert.Throws<IgniteException>(() => messaging.Send(1.1, topic));
+ Assert.AreEqual("Unable to cast object of type 'System.Double' to type 'System.String'.", ex.Message);
+
+ // Test end listen
+ MessagingTestHelper.ListenResult = false;
+ CheckSend(topic, single: true); // we'll receive one more and then unsubscribe because of delegate result.
+ CheckNoMessage(topic);
+
+ // Start again
+ MessagingTestHelper.ListenResult = true;
+ messaging.LocalListen(listener, topic);
+ CheckSend(topic);
+
+ // Stop
+ messaging.StopLocalListen(listener, topic);
+ CheckNoMessage(topic);
+ }
+
+ /// <summary>
+ /// Tests LocalListen with projection.
+ /// </summary>
+ [Test]
+ public void TestLocalListenProjection()
+ {
+ TestLocalListenProjection(null);
+ TestLocalListenProjection("prj");
+ TestLocalListenProjection(NextId());
+ }
+
+ /// <summary>
+ /// Tests LocalListen with projection.
+ /// </summary>
+ private void TestLocalListenProjection(object topic)
+ {
+ var grid3GotMessage = false;
+
+ var grid3Listener = new MessageFilter<string>((id, x) =>
+ {
+ grid3GotMessage = true;
+ return true;
+ });
+
+ _grid3.GetMessaging().LocalListen(grid3Listener, topic);
+
+ var clusterMessaging = _grid1.GetCluster().ForNodes(_grid1.GetCluster().GetLocalNode(), _grid2.GetCluster().GetLocalNode()).GetMessaging();
+ var clusterListener = MessagingTestHelper.GetListener();
+ clusterMessaging.LocalListen(clusterListener, topic);
+
+ CheckSend(msg: clusterMessaging, topic: topic);
+ Assert.IsFalse(grid3GotMessage, "Grid3 should not get messages");
+
+ CheckSend(grid: _grid2, msg: clusterMessaging, topic: topic);
+ Assert.IsFalse(grid3GotMessage, "Grid3 should not get messages");
+
+ clusterMessaging.StopLocalListen(clusterListener, topic);
+ _grid3.GetMessaging().StopLocalListen(grid3Listener, topic);
+ }
+
+ /// <summary>
+ /// Tests LocalListen in multithreaded mode.
+ /// </summary>
+ [Test]
+ [SuppressMessage("ReSharper", "AccessToModifiedClosure")]
+ [Category(TestUtils.CategoryIntensive)]
+ public void TestLocalListenMultithreaded()
+ {
+ const int threadCnt = 20;
+ const int runSeconds = 20;
+
+ var messaging = _grid1.GetMessaging();
+
+ var senders = Task.Factory.StartNew(() => TestUtils.RunMultiThreaded(() =>
+ {
+ messaging.Send((object) NextMessage());
+ Thread.Sleep(50);
+ }, threadCnt, runSeconds));
+
+
+ var sharedReceived = 0;
+
+ var sharedListener = new MessageFilter<string>((id, x) =>
+ {
+ Interlocked.Increment(ref sharedReceived);
+ Thread.MemoryBarrier();
+ return true;
+ });
+
+ TestUtils.RunMultiThreaded(() =>
+ {
+ // Check that listen/stop work concurrently
+ messaging.LocalListen(sharedListener);
+
+ for (int i = 0; i < 100; i++)
+ {
+ messaging.LocalListen(sharedListener);
+ messaging.StopLocalListen(sharedListener);
+ }
+
+ var localReceived = 0;
+ var stopLocal = 0;
+
+ var localListener = new MessageFilter<string>((id, x) =>
+ {
+ Interlocked.Increment(ref localReceived);
+ Thread.MemoryBarrier();
+ return Thread.VolatileRead(ref stopLocal) == 0;
+ });
+
+ messaging.LocalListen(localListener);
+
+ Thread.Sleep(100);
+
+ Thread.VolatileWrite(ref stopLocal, 1);
+
+ Thread.Sleep(1000);
+
+ var result = Thread.VolatileRead(ref localReceived);
+
+ Thread.Sleep(100);
+
+ // Check that unsubscription worked properly
+ Assert.AreEqual(result, Thread.VolatileRead(ref localReceived));
+
+ messaging.StopLocalListen(sharedListener);
+
+ }, threadCnt, runSeconds);
+
+ senders.Wait();
+
+ Thread.Sleep(100);
+
+ var sharedResult = Thread.VolatileRead(ref sharedReceived);
+
+ messaging.Send((object)NextMessage());
+
+ Thread.Sleep(MessagingTestHelper.MessageTimeout);
+
+ // Check that unsubscription worked properly
+ Assert.AreEqual(sharedResult, Thread.VolatileRead(ref sharedReceived));
+ }
+
+ /// <summary>
+ /// Tests RemoteListen.
+ /// </summary>
+ [Test]
+ public void TestRemoteListen()
+ {
+ TestRemoteListen(null);
+ TestRemoteListen("string topic");
+ TestRemoteListen(NextId());
+ }
+
+ /// <summary>
+ /// Tests RemoteListen with async mode enabled.
+ /// </summary>
+ [Test]
+ public void TestRemoteListenAsync()
+ {
+ TestRemoteListen(null, true);
+ TestRemoteListen("string topic", true);
+ TestRemoteListen(NextId(), true);
+ }
+
+ /// <summary>
+ /// Tests RemoteListen.
+ /// </summary>
+ public void TestRemoteListen(object topic, bool async = false)
+ {
+ var messaging = async ? _grid1.GetMessaging().WithAsync() : _grid1.GetMessaging();
+
+ var listener = MessagingTestHelper.GetListener();
+ var listenId = messaging.RemoteListen(listener, topic);
+
+ if (async)
+ listenId = messaging.GetFuture<Guid>().Get();
+
+ // Test sending
+ CheckSend(topic, msg: messaging, remoteListen: true);
+
+ // Test different topic
+ CheckNoMessage(NextId());
+
+ // Test multiple subscriptions for the same filter
+ var listenId2 = messaging.RemoteListen(listener, topic);
+
+ if (async)
+ listenId2 = messaging.GetFuture<Guid>().Get();
+
+ CheckSend(topic, msg: messaging, remoteListen: true, repeatMultiplier: 2); // expect twice the messages
+
+ messaging.StopRemoteListen(listenId2);
+
+ if (async)
+ messaging.GetFuture().Get();
+
+ CheckSend(topic, msg: messaging, remoteListen: true); // back to normal after unsubscription
+
+ // Test message type mismatch
+ var ex = Assert.Throws<IgniteException>(() => messaging.Send(1.1, topic));
+ Assert.AreEqual("Unable to cast object of type 'System.Double' to type 'System.String'.", ex.Message);
+
+ // Test end listen
+ messaging.StopRemoteListen(listenId);
+
+ if (async)
+ messaging.GetFuture().Get();
+
+ CheckNoMessage(topic);
+ }
+
+ /// <summary>
+ /// Tests RemoteListen with a projection.
+ /// </summary>
+ [Test]
+ public void TestRemoteListenProjection()
+ {
+ TestRemoteListenProjection(null);
+ TestRemoteListenProjection("string topic");
+ TestRemoteListenProjection(NextId());
+ }
+
+ /// <summary>
+ /// Tests RemoteListen with a projection.
+ /// </summary>
+ private void TestRemoteListenProjection(object topic)
+ {
+ var clusterMessaging = _grid1.GetCluster().ForNodes(_grid1.GetCluster().GetLocalNode(), _grid2.GetCluster().GetLocalNode()).GetMessaging();
+ var clusterListener = MessagingTestHelper.GetListener();
+ var listenId = clusterMessaging.RemoteListen(clusterListener, topic);
+
+ CheckSend(msg: clusterMessaging, topic: topic, remoteListen: true);
+
+ clusterMessaging.StopRemoteListen(listenId);
+
+ CheckNoMessage(topic);
+ }
+
+ /// <summary>
+ /// Tests LocalListen in multithreaded mode.
+ /// </summary>
+ [Test]
+ [Category(TestUtils.CategoryIntensive)]
+ public void TestRemoteListenMultithreaded()
+ {
+ const int threadCnt = 20;
+ const int runSeconds = 20;
+
+ var messaging = _grid1.GetMessaging();
+
+ var senders = Task.Factory.StartNew(() => TestUtils.RunMultiThreaded(() =>
+ {
+ MessagingTestHelper.ClearReceived(int.MaxValue);
+ messaging.Send((object) NextMessage());
+ Thread.Sleep(50);
+ }, threadCnt, runSeconds));
+
+
+ var sharedListener = MessagingTestHelper.GetListener();
+
+ for (int i = 0; i < 100; i++)
+ messaging.RemoteListen(sharedListener); // add some listeners to be stopped by filter result
+
+ TestUtils.RunMultiThreaded(() =>
+ {
+ // Check that listen/stop work concurrently
+ messaging.StopRemoteListen(messaging.RemoteListen(sharedListener));
+
+ }, threadCnt, runSeconds);
+
+ MessagingTestHelper.ListenResult = false;
+
+ messaging.Send((object) NextMessage()); // send a message to make filters return false
+
+ Thread.Sleep(MessagingTestHelper.MessageTimeout); // wait for all to unsubscribe
+
+ MessagingTestHelper.ListenResult = true;
+
+ senders.Wait(); // wait for senders to stop
+
+ var sharedResult = MessagingTestHelper.ReceivedMessages.Count;
+
+ messaging.Send((object) NextMessage());
+
+ Thread.Sleep(MessagingTestHelper.MessageTimeout);
+
+ // Check that unsubscription worked properly
+ Assert.AreEqual(sharedResult, MessagingTestHelper.ReceivedMessages.Count);
+
+ }
+
+ /// <summary>
+ /// Sends messages in various ways and verefies correct receival.
+ /// </summary>
+ /// <param name="topic">Topic.</param>
+ /// <param name="grid">The grid to use.</param>
+ /// <param name="msg">Messaging to use.</param>
+ /// <param name="remoteListen">Whether to expect remote listeners.</param>
+ /// <param name="single">When true, only check one message.</param>
+ /// <param name="repeatMultiplier">Expected message count multiplier.</param>
+ private void CheckSend(object topic = null, IIgnite grid = null,
+ IMessaging msg = null, bool remoteListen = false, bool single = false, int repeatMultiplier = 1)
+ {
+ IClusterGroup cluster;
+
+ if (msg != null)
+ cluster = msg.ClusterGroup;
+ else
+ {
+ grid = grid ?? _grid1;
+ msg = grid.GetMessaging();
+ cluster = grid.GetCluster().ForLocal();
+ }
+
+ // Messages will repeat due to multiple nodes listening
+ var expectedRepeat = repeatMultiplier * (remoteListen ? cluster.GetNodes().Count : 1);
+
+ var messages = Enumerable.Range(1, 10).Select(x => NextMessage()).OrderBy(x => x).ToList();
+
+ // Single message
+ MessagingTestHelper.ClearReceived(expectedRepeat);
+ msg.Send((object) messages[0], topic);
+ MessagingTestHelper.VerifyReceive(cluster, messages.Take(1), m => m.ToList(), expectedRepeat);
+
+ if (single)
+ return;
+
+ // Multiple messages (receive order is undefined)
+ MessagingTestHelper.ClearReceived(messages.Count * expectedRepeat);
+ msg.Send(messages, topic);
+ MessagingTestHelper.VerifyReceive(cluster, messages, m => m.OrderBy(x => x), expectedRepeat);
+
+ // Multiple messages, ordered
+ MessagingTestHelper.ClearReceived(messages.Count * expectedRepeat);
+ messages.ForEach(x => msg.SendOrdered(x, topic, MessagingTestHelper.MessageTimeout));
+
+ if (remoteListen) // in remote scenario messages get mixed up due to different timing on different nodes
+ MessagingTestHelper.VerifyReceive(cluster, messages, m => m.OrderBy(x => x), expectedRepeat);
+ else
+ MessagingTestHelper.VerifyReceive(cluster, messages, m => m.Reverse(), expectedRepeat);
+ }
+
+ /// <summary>
+ /// Checks that no message has arrived.
+ /// </summary>
+ private void CheckNoMessage(object topic, IIgnite grid = null)
+ {
+ // this will result in an exception in case of a message
+ MessagingTestHelper.ClearReceived(0);
+
+ (grid ?? _grid1).GetMessaging().Send(NextMessage(), topic);
+
+ Thread.Sleep(MessagingTestHelper.MessageTimeout);
+
+ MessagingTestHelper.AssertFailures();
+ }
+
+ /// <summary>
+ /// Gets the Ignite configuration.
+ /// </summary>
+ private static IgniteConfiguration Configuration(string springConfigUrl)
+ {
+ return new IgniteConfiguration
+ {
+ SpringConfigUrl = springConfigUrl,
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = TestUtils.TestJavaOptions()
+ };
+ }
+
+ /// <summary>
+ /// Generates next message with sequential ID and current test name.
+ /// </summary>
+ private static string NextMessage()
+ {
+ var id = NextId();
+ return id + "_" + TestContext.CurrentContext.Test.Name;
+ }
+
+ /// <summary>
+ /// Generates next sequential ID.
+ /// </summary>
+ private static int NextId()
+ {
+ return Interlocked.Increment(ref MessageId);
+ }
+ }
+
+ /// <summary>
+ /// Messaging test helper class.
+ /// </summary>
+ [Serializable]
+ public static class MessagingTestHelper
+ {
+ /** */
+ public static readonly ConcurrentStack<string> ReceivedMessages = new ConcurrentStack<string>();
+
+ /** */
+ public static readonly ConcurrentStack<string> Failures = new ConcurrentStack<string>();
+
+ /** */
+ public static readonly CountdownEvent ReceivedEvent = new CountdownEvent(0);
+
+ /** */
+ public static readonly ConcurrentStack<Guid> LastNodeIds = new ConcurrentStack<Guid>();
+
+ /** */
+ public static volatile bool ListenResult = true;
+
+ /** */
+ public static readonly TimeSpan MessageTimeout = TimeSpan.FromMilliseconds(700);
+
+ /// <summary>
+ /// Clears received message information.
+ /// </summary>
+ /// <param name="expectedCount">The expected count of messages to be received.</param>
+ public static void ClearReceived(int expectedCount)
+ {
+ ReceivedMessages.Clear();
+ ReceivedEvent.Reset(expectedCount);
+ LastNodeIds.Clear();
+ }
+
+ /// <summary>
+ /// Verifies received messages against expected messages.
+ /// </summary>
+ /// <param name="cluster">Cluster.</param>
+ /// <param name="expectedMessages">Expected messages.</param>
+ /// <param name="resultFunc">Result transform function.</param>
+ /// <param name="expectedRepeat">Expected repeat count.</param>
+ public static void VerifyReceive(IClusterGroup cluster, IEnumerable<string> expectedMessages,
+ Func<IEnumerable<string>, IEnumerable<string>> resultFunc, int expectedRepeat)
+ {
+ // check if expected message count has been received; Wait returns false if there were none.
+ Assert.IsTrue(ReceivedEvent.Wait(MessageTimeout));
+
+ expectedMessages = expectedMessages.SelectMany(x => Enumerable.Repeat(x, expectedRepeat));
+
+ Assert.AreEqual(expectedMessages, resultFunc(ReceivedMessages));
+
+ // check that all messages came from local node.
+ var localNodeId = cluster.Ignite.GetCluster().GetLocalNode().Id;
+ Assert.AreEqual(localNodeId, LastNodeIds.Distinct().Single());
+
+ AssertFailures();
+ }
+
+ /// <summary>
+ /// Gets the message listener.
+ /// </summary>
+ /// <returns>New instance of message listener.</returns>
+ public static IMessageFilter<string> GetListener()
+ {
+ return new MessageFilter<string>(Listen);
+ }
+
+ /// <summary>
+ /// Combines accumulated failures and throws an assertion, if there are any.
+ /// Clears accumulated failures.
+ /// </summary>
+ public static void AssertFailures()
+ {
+ if (Failures.Any())
+ Assert.Fail(Failures.Reverse().Aggregate((x, y) => string.Format("{0}\n{1}", x, y)));
+
+ Failures.Clear();
+ }
+
+ /// <summary>
+ /// Listen method.
+ /// </summary>
+ /// <param name="id">Originating node ID.</param>
+ /// <param name="msg">Message.</param>
+ private static bool Listen(Guid id, string msg)
+ {
+ try
+ {
+ LastNodeIds.Push(id);
+ ReceivedMessages.Push(msg);
+
+ ReceivedEvent.Signal();
+
+ return ListenResult;
+ }
+ catch (Exception ex)
+ {
+ // When executed on remote nodes, these exceptions will not go to sender,
+ // so we have to accumulate them.
+ Failures.Push(string.Format("Exception in Listen (msg: {0}, id: {1}): {2}", msg, id, ex));
+ throw;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Test message filter.
+ /// </summary>
+ [Serializable]
+ public class MessageFilter<T> : IMessageFilter<T>
+ {
+ /** */
+ private readonly Func<Guid, T, bool> _invoke;
+
+ #pragma warning disable 649
+ /** Grid. */
+ [InstanceResource]
+ private IIgnite _grid;
+ #pragma warning restore 649
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MessageFilter{T}"/> class.
+ /// </summary>
+ /// <param name="invoke">The invoke delegate.</param>
+ public MessageFilter(Func<Guid, T, bool> invoke)
+ {
+ _invoke = invoke;
+ }
+
+ /** <inheritdoc /> */
+ public bool Invoke(Guid nodeId, T message)
+ {
+ Assert.IsNotNull(_grid);
+ return _invoke(nodeId, message);
+ }
+ }
+}
[22/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
deleted file mode 100644
index 469887d..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache
-{
- using Apache.Ignite.Core.Cache;
- using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Impl;
- using Apache.Ignite.Core.Portable;
- using NUnit.Framework;
-
- /// <summary>
- /// Affinity key tests.
- /// </summary>
- public class CacheAffinityTest
- {
- /// <summary>
- ///
- /// </summary>
- [TestFixtureSetUp]
- public virtual void StartGrids()
- {
- TestUtils.KillProcesses();
-
- IgniteConfigurationEx cfg = new IgniteConfigurationEx();
-
- cfg.JvmClasspath = TestUtils.CreateTestClasspath();
- cfg.JvmOptions = TestUtils.TestJavaOptions();
- cfg.SpringConfigUrl = "config\\native-client-test-cache-affinity.xml";
-
- for (int i = 0; i < 3; i++)
- {
- cfg.GridName = "grid-" + i;
-
- Ignition.Start(cfg);
- }
- }
-
- /// <summary>
- /// Tear-down routine.
- /// </summary>
- [TestFixtureTearDown]
- public virtual void StopGrids()
- {
- for (int i = 0; i < 3; i++)
- Ignition.Stop("grid-" + i, true);
- }
-
- /// <summary>
- /// Test affinity key.
- /// </summary>
- [Test]
- public void TestAffinity()
- {
- IIgnite g = Ignition.GetIgnite("grid-0");
-
- ICacheAffinity aff = g.GetAffinity(null);
-
- IClusterNode node = aff.MapKeyToNode(new AffinityTestKey(0, 1));
-
- for (int i = 0; i < 10; i++)
- Assert.AreEqual(node.Id, aff.MapKeyToNode(new AffinityTestKey(i, 1)).Id);
- }
-
- /// <summary>
- /// Test affinity with portable flag.
- /// </summary>
- [Test]
- public void TestAffinityPortable()
- {
- IIgnite g = Ignition.GetIgnite("grid-0");
-
- ICacheAffinity aff = g.GetAffinity(null);
-
- IPortableObject affKey = g.GetPortables().ToPortable<IPortableObject>(new AffinityTestKey(0, 1));
-
- IClusterNode node = aff.MapKeyToNode(affKey);
-
- for (int i = 0; i < 10; i++)
- {
- IPortableObject otherAffKey =
- g.GetPortables().ToPortable<IPortableObject>(new AffinityTestKey(i, 1));
-
- Assert.AreEqual(node.Id, aff.MapKeyToNode(otherAffKey).Id);
- }
- }
-
- /// <summary>
- /// Affinity key.
- /// </summary>
- public class AffinityTestKey
- {
- /** ID. */
- private int _id;
-
- /** Affinity key. */
- private int _affKey;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="id">ID.</param>
- /// <param name="affKey">Affinity key.</param>
- public AffinityTestKey(int id, int affKey)
- {
- _id = id;
- _affKey = affKey;
- }
-
- /** <inheritdoc /> */
- public override bool Equals(object obj)
- {
- AffinityTestKey other = obj as AffinityTestKey;
-
- return other != null && _id == other._id;
- }
-
- /** <inheritdoc /> */
- public override int GetHashCode()
- {
- return _id;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
deleted file mode 100644
index abef473..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache
-{
- using System;
- using System.Collections.Generic;
- using Apache.Ignite.Core.Cache;
- using Apache.Ignite.Core.Impl;
- using Apache.Ignite.Core.Portable;
- using Apache.Ignite.Core.Tests.Query;
- using NUnit.Framework;
-
- /// <summary>
- /// Tests for dynamic a cache start.
- /// </summary>
- public class CacheDynamicStartTest
- {
- /** Grid name: data. */
- private const string GridData = "d";
-
- /** Grid name: data, no configuration. */
- private const string GridDataNoCfg = "dnc";
-
- /** Grid name: client. */
- private const string GridClient = "c";
-
- /** Cache name: partitioned, transactional. */
- private const string CacheTx = "p";
-
- /** Cache name: atomic. */
- private const string CacheAtomic = "pa";
-
- /** Cache name: dummy. */
- private const string CacheDummy = "dummy";
-
- /// <summary>
- /// Set up routine.
- /// </summary>
- [SetUp]
- public void SetUp()
- {
- TestUtils.KillProcesses();
-
- Ignition.Start(CreateConfiguration(GridData, @"config/dynamic/dynamic-data.xml"));
- Ignition.Start(CreateConfiguration(GridDataNoCfg, @"config/dynamic/dynamic-data-no-cfg.xml"));
- Ignition.Start(CreateConfiguration(GridClient, @"config/dynamic/dynamic-client.xml"));
- }
-
- /// <summary>
- /// Tear down routine.
- /// </summary>
- [TearDown]
- public void StopGrids()
- {
- Ignition.Stop(GridData, true);
- Ignition.Stop(GridDataNoCfg, true);
- Ignition.Stop(GridClient, true);
- }
-
- /// <summary>
- /// Create configuration.
- /// </summary>
- /// <param name="name">Grid name.</param>
- /// <param name="springCfg">Spring configuration.</param>
- /// <returns>Configuration.</returns>
- private static IgniteConfigurationEx CreateConfiguration(string name, string springCfg)
- {
- IgniteConfigurationEx cfg = new IgniteConfigurationEx();
-
- PortableConfiguration portCfg = new PortableConfiguration();
-
- ICollection<PortableTypeConfiguration> portTypeCfgs = new List<PortableTypeConfiguration>();
-
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(DynamicTestKey)));
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(DynamicTestValue)));
-
- portCfg.TypeConfigurations = portTypeCfgs;
-
- cfg.GridName = name;
- cfg.PortableConfiguration = portCfg;
- cfg.JvmClasspath = TestUtils.CreateTestClasspath();
- cfg.JvmOptions = TestUtils.TestJavaOptions();
- cfg.SpringConfigUrl = springCfg;
-
- return cfg;
- }
-
- /// <summary>
- /// Try getting not configured cache.
- /// </summary>
- [Test]
- public void TestNoStarted()
- {
- Assert.Throws<ArgumentException>(() =>
- {
- Ignition.GetIgnite(GridData).GetCache<CacheTestKey, PortablePerson>(CacheDummy);
- });
-
- Assert.Throws<ArgumentException>(() =>
- {
- Ignition.GetIgnite(GridDataNoCfg).GetCache<CacheTestKey, PortablePerson>(CacheDummy);
- });
-
- Assert.Throws<ArgumentException>(() =>
- {
- Ignition.GetIgnite(GridClient).GetCache<CacheTestKey, PortablePerson>(CacheDummy);
- });
- }
-
- /// <summary>
- /// Test TX cache.
- /// </summary>
- [Test]
- public void TestTransactional()
- {
- Check(CacheTx);
- }
-
- /// <summary>
- /// Test ATOMIC cache.
- /// </summary>
- [Test]
- public void TestAtomic()
- {
- Check(CacheAtomic);
- }
-
- /// <summary>
- /// Check routine.
- /// </summary>
- /// <param name="cacheName">Cache name.</param>
- private void Check(string cacheName)
- {
- ICache<DynamicTestKey, DynamicTestValue> cacheData =
- Ignition.GetIgnite(GridData).GetCache<DynamicTestKey, DynamicTestValue>(cacheName);
-
- ICache<DynamicTestKey, DynamicTestValue> cacheDataNoCfg =
- Ignition.GetIgnite(GridDataNoCfg).GetCache<DynamicTestKey, DynamicTestValue>(cacheName);
-
- ICache<DynamicTestKey, DynamicTestValue> cacheClient =
- Ignition.GetIgnite(GridClient).GetCache<DynamicTestKey, DynamicTestValue>(cacheName);
-
- DynamicTestKey key1 = new DynamicTestKey(1);
- DynamicTestKey key2 = new DynamicTestKey(2);
- DynamicTestKey key3 = new DynamicTestKey(3);
-
- DynamicTestValue val1 = new DynamicTestValue(1);
- DynamicTestValue val2 = new DynamicTestValue(2);
- DynamicTestValue val3 = new DynamicTestValue(3);
-
- cacheData.Put(key1, val1);
- Assert.AreEqual(val1, cacheData.Get(key1));
- Assert.AreEqual(val1, cacheDataNoCfg.Get(key1));
- Assert.AreEqual(val1, cacheClient.Get(key1));
-
- cacheDataNoCfg.Put(key2, val2);
- Assert.AreEqual(val2, cacheData.Get(key2));
- Assert.AreEqual(val2, cacheDataNoCfg.Get(key2));
- Assert.AreEqual(val2, cacheClient.Get(key2));
-
- cacheClient.Put(key3, val3);
- Assert.AreEqual(val3, cacheData.Get(key3));
- Assert.AreEqual(val3, cacheDataNoCfg.Get(key3));
- Assert.AreEqual(val3, cacheClient.Get(key3));
-
- for (int i = 0; i < 10000; i++)
- cacheClient.Put(new DynamicTestKey(i), new DynamicTestValue(1));
-
- int sizeClient = cacheClient.GetLocalSize();
-
- Assert.AreEqual(0, sizeClient);
- }
- }
-
- /// <summary>
- /// Key for dynamic cache start tests.
- /// </summary>
- class DynamicTestKey
- {
- /// <summary>
- /// Default constructor.
- /// </summary>
- public DynamicTestKey()
- {
- // No-op.
- }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="id">ID.</param>
- public DynamicTestKey(int id)
- {
- Id = id;
- }
-
- /// <summary>
- /// ID.
- /// </summary>
- public int Id
- {
- get;
- set;
- }
-
- /** <inheritdoc /> */
- public override bool Equals(object obj)
- {
- DynamicTestKey other = obj as DynamicTestKey;
-
- return other != null && Id == other.Id;
- }
-
- /** <inheritdoc /> */
- public override int GetHashCode()
- {
- return Id;
- }
- }
-
- /// <summary>
- /// Value for dynamic cache start tests.
- /// </summary>
- class DynamicTestValue
- {
- /// <summary>
- /// Default constructor.
- /// </summary>
- public DynamicTestValue()
- {
- // No-op.
- }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="id">ID.</param>
- public DynamicTestValue(int id)
- {
- Id = id;
- }
-
- /// <summary>
- /// ID.
- /// </summary>
- public int Id
- {
- get;
- set;
- }
-
- /** <inheritdoc /> */
- public override bool Equals(object obj)
- {
- DynamicTestValue other = obj as DynamicTestValue;
-
- return other != null && Id == other.Id;
- }
-
- /** <inheritdoc /> */
- public override int GetHashCode()
- {
- return Id;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheEntryTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheEntryTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheEntryTest.cs
deleted file mode 100644
index 8464b8e..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheEntryTest.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache
-{
- using System.Collections.Generic;
- using Apache.Ignite.Core.Impl.Cache;
- using NUnit.Framework;
-
- /// <summary>
- /// <see cref="CacheEntry{TK,TV}"/> tests.
- /// </summary>
- public class CacheEntryTest
- {
- /// <summary>
- /// Tests equality members.
- /// </summary>
- [Test]
- public void TestEquality()
- {
- var entry1 = new CacheEntry<int, int>(1, 2);
- var entry2 = new CacheEntry<int, int>(1, 2);
- var entry3 = new CacheEntry<int, int>(1, 3);
-
- Assert.AreEqual(entry1, entry2);
- Assert.AreNotEqual(entry1, entry3);
-
- var boxedEntry1 = (object) entry1;
- var boxedEntry2 = (object) entry2;
- var boxedEntry3 = (object) entry3;
-
- Assert.IsFalse(ReferenceEquals(boxedEntry1, boxedEntry2));
-
- Assert.AreEqual(boxedEntry1, boxedEntry2);
- Assert.AreNotEqual(boxedEntry1, boxedEntry3);
- }
-
- /// <summary>
- /// Tests with hash data structures.
- /// </summary>
- [Test]
- public void TestHashCode()
- {
- var entry1 = new CacheEntry<int, int>(1, 2);
- var entry2 = new CacheEntry<int, int>(1, 2);
- var entry3 = new CacheEntry<int, int>(1, 3);
-
- var set = new HashSet<object> {entry1};
-
- Assert.IsTrue(set.Contains(entry1));
- Assert.IsTrue(set.Contains(entry2));
- Assert.IsFalse(set.Contains(entry3));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheForkedTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheForkedTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheForkedTest.cs
deleted file mode 100644
index 46c54e6..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheForkedTest.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache
-{
- using System.IO;
- using Apache.Ignite.Core.Tests.Process;
- using NUnit.Framework;
-
- /// <summary>
- /// Tests cache with a standalone process.
- /// </summary>
- public class CacheForkedTest
- {
- /** */
- private IIgnite _grid;
-
- /// <summary>
- /// Set up.
- /// </summary>
- [TestFixtureSetUp]
- public void SetUp()
- {
- const string springConfigUrl = "config\\compute\\compute-grid1.xml";
-
- // ReSharper disable once UnusedVariable
- var proc = new IgniteProcess(
- "-jvmClasspath=" + TestUtils.CreateTestClasspath(),
- "-springConfigUrl=" + Path.GetFullPath(springConfigUrl),
- "-J-ea",
- "-J-Xcheck:jni",
- "-J-Xms512m",
- "-J-Xmx512m",
- "-J-DIGNITE_QUIET=false"
- );
-
- _grid = Ignition.Start(new IgniteConfiguration
- {
- JvmClasspath = TestUtils.CreateTestClasspath(),
- JvmOptions = TestUtils.TestJavaOptions(),
- SpringConfigUrl = springConfigUrl
- });
-
- Assert.IsTrue(_grid.WaitTopology(2, 30000));
- }
-
- /// <summary>
- /// Tear down.
- /// </summary>
- [TestFixtureTearDown]
- public void TearDown()
- {
- IgniteProcess.KillAll();
-
- Ignition.StopAll(true);
- }
-
- /// <summary>
- /// Tests cache clear.
- /// </summary>
- [Test]
- public void TestClearCache()
- {
- _grid.GetCache<object, object>(null).Clear();
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheLocalAtomicTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheLocalAtomicTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheLocalAtomicTest.cs
deleted file mode 100644
index b60c254..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheLocalAtomicTest.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache
-{
- public class CacheLocalAtomicTest : CacheAbstractTest
- {
- protected override int CachePartitions()
- {
- return 1;
- }
-
- protected override int GridCount()
- {
- return 1;
- }
-
- protected override string CacheName()
- {
- return "local_atomic";
- }
-
- protected override bool NearEnabled()
- {
- return false;
- }
-
- protected override bool TxEnabled()
- {
- return false;
- }
-
- protected override bool LocalCache()
- {
- return true;
- }
-
- protected override int Backups()
- {
- return 0;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheLocalTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheLocalTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheLocalTest.cs
deleted file mode 100644
index 02cb987..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheLocalTest.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache
-{
- public class CacheLocalTest : CacheAbstractTest
- {
- protected override int CachePartitions()
- {
- return 1;
- }
-
- protected override int GridCount()
- {
- return 1;
- }
-
- protected override string CacheName()
- {
- return "local";
- }
-
- protected override bool NearEnabled()
- {
- return false;
- }
-
- protected override bool TxEnabled()
- {
- return true;
- }
- protected override bool LocalCache()
- {
- return true;
- }
-
- protected override int Backups()
- {
- return 0;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedAtomicNearEnabledTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedAtomicNearEnabledTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedAtomicNearEnabledTest.cs
deleted file mode 100644
index 4f6e7a0..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedAtomicNearEnabledTest.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache
-{
- using NUnit.Framework;
-
- [Category(TestUtils.CategoryIntensive)]
- public class CachePartitionedAtomicNearEnabledTest : CacheAbstractTest
- {
- protected override int GridCount()
- {
- return 3;
- }
-
- protected override string CacheName()
- {
- return "partitioned_atomic_near";
- }
-
- protected override bool NearEnabled()
- {
- return true;
- }
-
- protected override bool TxEnabled()
- {
- return false;
- }
-
- protected override int Backups()
- {
- return 1;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedAtomicTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedAtomicTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedAtomicTest.cs
deleted file mode 100644
index ab59c64..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedAtomicTest.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache
-{
- using NUnit.Framework;
-
- [Category(TestUtils.CategoryIntensive)]
- public class CachePartitionedAtomicTest : CacheAbstractTest
- {
- protected override int GridCount()
- {
- return 3;
- }
-
- protected override string CacheName()
- {
- return "partitioned_atomic";
- }
-
- protected override bool NearEnabled()
- {
- return false;
- }
-
- protected override bool TxEnabled()
- {
- return false;
- }
-
- protected override int Backups()
- {
- return 1;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedNearEnabledTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedNearEnabledTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedNearEnabledTest.cs
deleted file mode 100644
index 830698b..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedNearEnabledTest.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache
-{
- using NUnit.Framework;
-
- [Category(TestUtils.CategoryIntensive)]
- public class CachePartitionedNearEnabledTest : CacheAbstractTest
- {
- protected override int GridCount()
- {
- return 3;
- }
-
- protected override string CacheName()
- {
- return "partitioned_near";
- }
-
- protected override bool NearEnabled()
- {
- return true;
- }
-
- protected override bool TxEnabled()
- {
- return true;
- }
-
- protected override int Backups()
- {
- return 1;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedTest.cs
deleted file mode 100644
index 02d3208..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedTest.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache
-{
- using NUnit.Framework;
-
- [Category(TestUtils.CategoryIntensive)]
- public class CachePartitionedTest : CacheAbstractTest
- {
- protected override int GridCount()
- {
- return 3;
- }
-
- protected override string CacheName()
- {
- return "partitioned";
- }
-
- protected override bool NearEnabled()
- {
- return false;
- }
-
- protected override bool TxEnabled()
- {
- return true;
- }
-
- protected override int Backups()
- {
- return 1;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheReplicatedAtomicTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheReplicatedAtomicTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheReplicatedAtomicTest.cs
deleted file mode 100644
index db6f5a5..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheReplicatedAtomicTest.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache
-{
- using NUnit.Framework;
-
- [Category(TestUtils.CategoryIntensive)]
- public class CacheReplicatedAtomicTest : CacheAbstractTest
- {
- protected override int CachePartitions()
- {
- return 512;
- }
-
- protected override int GridCount()
- {
- return 3;
- }
-
- protected override string CacheName()
- {
- return "replicated_atomic";
- }
-
- protected override bool NearEnabled()
- {
- return false;
- }
-
- protected override bool TxEnabled()
- {
- return false;
- }
-
- protected override int Backups()
- {
- return GridCount() - 1;
- }
-
- protected override bool ReplicatedCache()
- {
- return true;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheReplicatedTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheReplicatedTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheReplicatedTest.cs
deleted file mode 100644
index 7c70222..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheReplicatedTest.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache
-{
- using NUnit.Framework;
-
- [Category(TestUtils.CategoryIntensive)]
- public class CacheReplicatedTest : CacheAbstractTest
- {
- protected override int CachePartitions()
- {
- return 512;
- }
-
- protected override int GridCount()
- {
- return 3;
- }
-
- protected override string CacheName()
- {
- return "replicated";
- }
-
- protected override bool NearEnabled()
- {
- return false;
- }
-
- protected override bool TxEnabled()
- {
- return true;
- }
-
- protected override int Backups()
- {
- return GridCount() - 1;
- }
-
- protected override bool ReplicatedCache()
- {
- return true;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
deleted file mode 100644
index 52a856a..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache
-{
- using System.Collections;
- using System.Collections.Generic;
- using System.Diagnostics;
- using Apache.Ignite.Core.Cache;
- using Apache.Ignite.Core.Cache.Expiry;
- using Apache.Ignite.Core.Cache.Query;
- using Apache.Ignite.Core.Cache.Query.Continuous;
- using Apache.Ignite.Core.Common;
-
- /// <summary>
- /// Wraps IGridCache implementation to simplify async mode testing.
- /// </summary>
- internal class CacheTestAsyncWrapper<TK, TV> : ICache<TK, TV>
- {
- private readonly ICache<TK, TV> _cache;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="CacheTestAsyncWrapper{K, V}"/> class.
- /// </summary>
- /// <param name="cache">The cache to be wrapped.</param>
- public CacheTestAsyncWrapper(ICache<TK, TV> cache)
- {
- Debug.Assert(cache.IsAsync, "GridCacheTestAsyncWrapper only works with async caches.");
-
- _cache = cache;
- }
-
- /** <inheritDoc /> */
- public ICache<TK, TV> WithAsync()
- {
- return this;
- }
-
- /** <inheritDoc /> */
- public bool IsAsync
- {
- get { return true; }
- }
-
- /** <inheritDoc /> */
- public IFuture GetFuture()
- {
- Debug.Fail("GridCacheTestAsyncWrapper.Future() should not be called. It always returns null.");
- return null;
- }
-
- /** <inheritDoc /> */
- public IFuture<TResult> GetFuture<TResult>()
- {
- Debug.Fail("GridCacheTestAsyncWrapper.Future() should not be called. It always returns null.");
- return null;
- }
-
- /** <inheritDoc /> */
- public string Name
- {
- get { return _cache.Name; }
- }
-
- /** <inheritDoc /> */
- public IIgnite Ignite
- {
- get { return _cache.Ignite; }
- }
-
- /** <inheritDoc /> */
-
- public bool IsEmpty()
- {
- return _cache.IsEmpty();
- }
-
- /** <inheritDoc /> */
- public bool IsKeepPortable
- {
- get { return _cache.IsKeepPortable; }
- }
-
- /** <inheritDoc /> */
- public ICache<TK, TV> WithSkipStore()
- {
- return _cache.WithSkipStore().WrapAsync();
- }
-
- /** <inheritDoc /> */
- public ICache<TK, TV> WithExpiryPolicy(IExpiryPolicy plc)
- {
- return _cache.WithExpiryPolicy(plc).WrapAsync();
- }
-
- /** <inheritDoc /> */
- public ICache<TK1, TV1> WithKeepPortable<TK1, TV1>()
- {
- return _cache.WithKeepPortable<TK1, TV1>().WrapAsync();
- }
-
- /** <inheritDoc /> */
- public void LoadCache(ICacheEntryFilter<TK, TV> p, params object[] args)
- {
- _cache.LoadCache(p, args);
- WaitResult();
- }
-
- /** <inheritDoc /> */
- public void LocalLoadCache(ICacheEntryFilter<TK, TV> p, params object[] args)
- {
- _cache.LocalLoadCache(p, args);
- WaitResult();
- }
-
- /** <inheritDoc /> */
- public bool ContainsKey(TK key)
- {
- _cache.ContainsKey(key);
- return GetResult<bool>();
- }
-
- /** <inheritDoc /> */
- public bool ContainsKeys(IEnumerable<TK> keys)
- {
- _cache.ContainsKeys(keys);
- return GetResult<bool>();
- }
-
- /** <inheritDoc /> */
- public TV LocalPeek(TK key, params CachePeekMode[] modes)
- {
- _cache.LocalPeek(key, modes);
- return GetResult<TV>();
- }
-
- /** <inheritDoc /> */
- public TV Get(TK key)
- {
- _cache.Get(key);
- return GetResult<TV>();
- }
-
- /** <inheritDoc /> */
- public IDictionary<TK, TV> GetAll(IEnumerable<TK> keys)
- {
- _cache.GetAll(keys);
- return GetResult<IDictionary<TK, TV>>();
- }
-
- /** <inheritDoc /> */
- public void Put(TK key, TV val)
- {
- _cache.Put(key, val);
- WaitResult();
- }
-
- /** <inheritDoc /> */
- public TV GetAndPut(TK key, TV val)
- {
- _cache.GetAndPut(key, val);
- return GetResult<TV>();
- }
-
- /** <inheritDoc /> */
- public TV GetAndReplace(TK key, TV val)
- {
- _cache.GetAndReplace(key, val);
- return GetResult<TV>();
- }
-
- /** <inheritDoc /> */
- public TV GetAndRemove(TK key)
- {
- _cache.GetAndRemove(key);
- return GetResult<TV>();
- }
-
- /** <inheritDoc /> */
- public bool PutIfAbsent(TK key, TV val)
- {
- _cache.PutIfAbsent(key, val);
- return GetResult<bool>();
- }
-
- /** <inheritDoc /> */
- public TV GetAndPutIfAbsent(TK key, TV val)
- {
- _cache.GetAndPutIfAbsent(key, val);
- return GetResult<TV>();
- }
-
- /** <inheritDoc /> */
- public bool Replace(TK key, TV val)
- {
- _cache.Replace(key, val);
- return GetResult<bool>();
- }
-
- /** <inheritDoc /> */
- public bool Replace(TK key, TV oldVal, TV newVal)
- {
- _cache.Replace(key, oldVal, newVal);
- return GetResult<bool>();
- }
-
- /** <inheritDoc /> */
- public void PutAll(IDictionary<TK, TV> vals)
- {
- _cache.PutAll(vals);
- WaitResult();
- }
-
- /** <inheritDoc /> */
- public void LocalEvict(IEnumerable<TK> keys)
- {
- _cache.LocalEvict(keys);
- }
-
- /** <inheritDoc /> */
- public void Clear()
- {
- _cache.Clear();
- WaitResult();
- }
-
- /** <inheritDoc /> */
- public void Clear(TK key)
- {
- _cache.Clear(key);
- }
-
- /** <inheritDoc /> */
- public void ClearAll(IEnumerable<TK> keys)
- {
- _cache.ClearAll(keys);
- }
-
- /** <inheritDoc /> */
- public void LocalClear(TK key)
- {
- _cache.LocalClear(key);
- }
-
- /** <inheritDoc /> */
- public void LocalClearAll(IEnumerable<TK> keys)
- {
- _cache.LocalClearAll(keys);
- }
-
- /** <inheritDoc /> */
- public bool Remove(TK key)
- {
- _cache.Remove(key);
- return GetResult<bool>();
- }
-
- /** <inheritDoc /> */
- public bool Remove(TK key, TV val)
- {
- _cache.Remove(key, val);
- return GetResult<bool>();
- }
-
- /** <inheritDoc /> */
- public void RemoveAll(IEnumerable<TK> keys)
- {
- _cache.RemoveAll(keys);
- WaitResult();
- }
-
- /** <inheritDoc /> */
- public void RemoveAll()
- {
- _cache.RemoveAll();
- WaitResult();
- }
-
- /** <inheritDoc /> */
- public int GetLocalSize(params CachePeekMode[] modes)
- {
- return _cache.GetLocalSize(modes);
- }
-
- /** <inheritDoc /> */
- public int GetSize(params CachePeekMode[] modes)
- {
- _cache.GetSize(modes);
- return GetResult<int>();
- }
-
- /** <inheritDoc /> */
- public void LocalPromote(IEnumerable<TK> keys)
- {
- _cache.LocalPromote(keys);
- }
-
- /** <inheritDoc /> */
- public IQueryCursor<ICacheEntry<TK, TV>> Query(QueryBase qry)
- {
- return _cache.Query(qry);
- }
-
- /** <inheritDoc /> */
- public IQueryCursor<IList> QueryFields(SqlFieldsQuery qry)
- {
- return _cache.QueryFields(qry);
- }
-
- /** <inheritDoc /> */
- IContinuousQueryHandle ICache<TK, TV>.QueryContinuous(ContinuousQuery<TK, TV> qry)
- {
- return _cache.QueryContinuous(qry);
- }
-
- /** <inheritDoc /> */
- public IContinuousQueryHandle<ICacheEntry<TK, TV>> QueryContinuous(ContinuousQuery<TK, TV> qry, QueryBase initialQry)
- {
- return _cache.QueryContinuous(qry, initialQry);
- }
-
- /** <inheritDoc /> */
- public IEnumerable<ICacheEntry<TK, TV>> GetLocalEntries(params CachePeekMode[] peekModes)
- {
- return _cache.GetLocalEntries(peekModes);
- }
-
- /** <inheritDoc /> */
- public TR Invoke<TR, TA>(TK key, ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg)
- {
- _cache.Invoke(key, processor, arg);
-
- return GetResult<TR>();
- }
-
- /** <inheritDoc /> */
- public IDictionary<TK, ICacheEntryProcessorResult<TR>> InvokeAll<TR, TA>(IEnumerable<TK> keys,
- ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg)
- {
- _cache.InvokeAll(keys, processor, arg);
-
- return GetResult<IDictionary<TK, ICacheEntryProcessorResult<TR>>>();
- }
-
- /** <inheritDoc /> */
- public ICacheLock Lock(TK key)
- {
- return _cache.Lock(key);
- }
-
- /** <inheritDoc /> */
- public ICacheLock LockAll(IEnumerable<TK> keys)
- {
- return _cache.LockAll(keys);
- }
-
- /** <inheritDoc /> */
- public bool IsLocalLocked(TK key, bool byCurrentThread)
- {
- return _cache.IsLocalLocked(key, byCurrentThread);
- }
-
- /** <inheritDoc /> */
- public ICacheMetrics GetMetrics()
- {
- return _cache.GetMetrics();
- }
-
- /** <inheritDoc /> */
- public IFuture Rebalance()
- {
- return _cache.Rebalance();
- }
-
- /** <inheritDoc /> */
- public ICache<TK, TV> WithNoRetries()
- {
- return _cache.WithNoRetries();
- }
-
- /** <inheritDoc /> */
- public IEnumerator<ICacheEntry<TK, TV>> GetEnumerator()
- {
- return _cache.GetEnumerator();
- }
-
- /** <inheritDoc /> */
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
-
- /// <summary>
- /// Waits for the async result.
- /// </summary>
- private void WaitResult()
- {
- GetResult<object>();
- }
-
- /// <summary>
- /// Gets the async result.
- /// </summary>
- private T GetResult<T>()
- {
- return _cache.GetFuture<T>().Get();
- }
- }
-
- /// <summary>
- /// Extension methods for IGridCache.
- /// </summary>
- public static class CacheExtensions
- {
- /// <summary>
- /// Wraps specified instance into GridCacheTestAsyncWrapper.
- /// </summary>
- public static ICache<TK, TV> WrapAsync<TK, TV>(this ICache<TK, TV> cache)
- {
- return new CacheTestAsyncWrapper<TK, TV>(cache);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
deleted file mode 100644
index 18f04ef..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
+++ /dev/null
@@ -1,928 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Cache.Query
-{
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
- using System.Text;
- using Apache.Ignite.Core.Cache;
- using Apache.Ignite.Core.Cache.Query;
- using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Impl;
- using Apache.Ignite.Core.Impl.Portable;
- using Apache.Ignite.Core.Portable;
- using NUnit.Framework;
-
- /// <summary>
- /// Queries tests.
- /// </summary>
- public class CacheQueriesTest
- {
- /** Grid count. */
- private const int GridCnt = 2;
-
- /** Cache name. */
- private const string CacheName = "cache";
-
- /** Path to XML configuration. */
- private const string CfgPath = "config\\cache-query.xml";
-
- /** Maximum amount of items in cache. */
- private const int MaxItemCnt = 100;
-
- /// <summary>
- ///
- /// </summary>
- [TestFixtureSetUp]
- public virtual void StartGrids()
- {
- TestUtils.JvmDebug = true;
- TestUtils.KillProcesses();
-
- IgniteConfigurationEx cfg = new IgniteConfigurationEx
- {
- PortableConfiguration = new PortableConfiguration
- {
- TypeConfigurations = new[]
- {
- new PortableTypeConfiguration(typeof (QueryPerson)),
- new PortableTypeConfiguration(typeof (PortableScanQueryFilter<QueryPerson>)),
- new PortableTypeConfiguration(typeof (PortableScanQueryFilter<PortableUserObject>))
- }
- },
- JvmClasspath = TestUtils.CreateTestClasspath(),
- JvmOptions = TestUtils.TestJavaOptions(),
- SpringConfigUrl = CfgPath
- };
-
- for (int i = 0; i < GridCnt; i++)
- {
- cfg.GridName = "grid-" + i;
-
- Ignition.Start(cfg);
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- [TestFixtureTearDown]
- public virtual void StopGrids()
- {
- for (int i = 0; i < GridCnt; i++)
- Ignition.Stop("grid-" + i, true);
- }
-
- /// <summary>
- ///
- /// </summary>
- [SetUp]
- public virtual void BeforeTest()
- {
- Console.WriteLine("Test started: " + TestContext.CurrentContext.Test.Name);
- }
-
- /// <summary>
- ///
- /// </summary>
- [TearDown]
- public virtual void AfterTest()
- {
- var cache = Cache();
-
- for (int i = 0; i < GridCnt; i++)
- {
- for (int j = 0; j < MaxItemCnt; j++)
- cache.Remove(j);
-
- Assert.IsTrue(cache.IsEmpty());
- }
-
- Console.WriteLine("Test finished: " + TestContext.CurrentContext.Test.Name);
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="idx"></param>
- /// <returns></returns>
- public IIgnite GetIgnite(int idx)
- {
- return Ignition.GetIgnite("grid-" + idx);
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="idx"></param>
- /// <returns></returns>
- public ICache<int, QueryPerson> Cache(int idx)
- {
- return GetIgnite(idx).GetCache<int, QueryPerson>(CacheName);
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- public ICache<int, QueryPerson> Cache()
- {
- return Cache(0);
- }
-
- /// <summary>
- /// Test arguments validation for SQL queries.
- /// </summary>
- [Test]
- public void TestValidationSql()
- {
- // 1. No sql.
- Assert.Throws<ArgumentException>(() =>
- { Cache().Query(new SqlQuery(typeof(QueryPerson), null)); });
-
- // 2. No type.
- Assert.Throws<ArgumentException>(() =>
- { Cache().Query(new SqlQuery((string)null, "age >= 50")); });
- }
-
- /// <summary>
- /// Test arguments validation for SQL fields queries.
- /// </summary>
- [Test]
- public void TestValidationSqlFields()
- {
- // 1. No sql.
- Assert.Throws<ArgumentException>(() => { Cache().QueryFields(new SqlFieldsQuery(null)); });
- }
-
- /// <summary>
- /// Test arguments validation for TEXT queries.
- /// </summary>
- [Test]
- public void TestValidationText()
- {
- // 1. No text.
- Assert.Throws<ArgumentException>(() =>
- { Cache().Query(new TextQuery(typeof(QueryPerson), null)); });
-
- // 2. No type.
- Assert.Throws<ArgumentException>(() =>
- { Cache().Query(new TextQuery((string)null, "Ivanov")); });
- }
-
- /// <summary>
- /// Cursor tests.
- /// </summary>
- [Test]
- [SuppressMessage("ReSharper", "ReturnValueOfPureMethodIsNotUsed")]
- public void TestCursor()
- {
- var cache0 = Cache().WithAsync();
-
- cache0.WithAsync().Put(1, new QueryPerson("Ivanov", 30));
-
- IFuture<object> res = cache0.GetFuture<object>();
-
- res.Get();
-
- Cache().Put(1, new QueryPerson("Ivanov", 30));
- Cache().Put(1, new QueryPerson("Petrov", 40));
- Cache().Put(1, new QueryPerson("Sidorov", 50));
-
- SqlQuery qry = new SqlQuery(typeof(QueryPerson), "age >= 20");
-
- // 1. Test GetAll().
- using (IQueryCursor<ICacheEntry<int, QueryPerson>> cursor = Cache().Query(qry))
- {
- cursor.GetAll();
-
- Assert.Throws<InvalidOperationException>(() => { cursor.GetAll(); });
- Assert.Throws<InvalidOperationException>(() => { cursor.GetEnumerator(); });
- }
-
- // 2. Test GetEnumerator.
- using (IQueryCursor<ICacheEntry<int, QueryPerson>> cursor = Cache().Query(qry))
- {
- cursor.GetEnumerator();
-
- Assert.Throws<InvalidOperationException>(() => { cursor.GetAll(); });
- Assert.Throws<InvalidOperationException>(() => { cursor.GetEnumerator(); });
- }
- }
-
- /// <summary>
- /// Test enumerator.
- /// </summary>
- [Test]
- [SuppressMessage("ReSharper", "UnusedVariable")]
- public void TestEnumerator()
- {
- Cache().Put(1, new QueryPerson("Ivanov", 30));
- Cache().Put(2, new QueryPerson("Petrov", 40));
- Cache().Put(3, new QueryPerson("Sidorov", 50));
- Cache().Put(4, new QueryPerson("Unknown", 60));
-
- // 1. Empty result set.
- using (
- IQueryCursor<ICacheEntry<int, QueryPerson>> cursor =
- Cache().Query(new SqlQuery(typeof(QueryPerson), "age = 100")))
- {
- IEnumerator<ICacheEntry<int, QueryPerson>> e = cursor.GetEnumerator();
-
- Assert.Throws<InvalidOperationException>(() =>
- { ICacheEntry<int, QueryPerson> entry = e.Current; });
-
- Assert.IsFalse(e.MoveNext());
-
- Assert.Throws<InvalidOperationException>(() =>
- { ICacheEntry<int, QueryPerson> entry = e.Current; });
-
- Assert.Throws<NotSupportedException>(() => e.Reset());
- }
-
- SqlQuery qry = new SqlQuery(typeof (QueryPerson), "age < 60");
-
- // 2. Page size is bigger than result set.
- qry.PageSize = 4;
- CheckEnumeratorQuery(qry);
-
- // 3. Page size equal to result set.
- qry.PageSize = 3;
- CheckEnumeratorQuery(qry);
-
- // 4. Page size if less than result set.
- qry.PageSize = 2;
- CheckEnumeratorQuery(qry);
- }
-
- /// <summary>
- /// Test SQL query arguments passing.
- /// </summary>
- public void TestSqlQueryArguments()
- {
- Cache().Put(1, new QueryPerson("Ivanov", 30));
- Cache().Put(2, new QueryPerson("Petrov", 40));
- Cache().Put(3, new QueryPerson("Sidorov", 50));
-
- // 1. Empty result set.
- using (
- IQueryCursor<ICacheEntry<int, QueryPerson>> cursor =
- Cache().Query(new SqlQuery(typeof(QueryPerson), "age < ?", 50)))
- {
- foreach (ICacheEntry<int, QueryPerson> entry in cursor.GetAll())
- Assert.IsTrue(entry.Key == 1 || entry.Key == 2);
- }
- }
-
- /// <summary>
- /// Test SQL fields query arguments passing.
- /// </summary>
- public void TestSqlFieldsQueryArguments()
- {
- Cache().Put(1, new QueryPerson("Ivanov", 30));
- Cache().Put(2, new QueryPerson("Petrov", 40));
- Cache().Put(3, new QueryPerson("Sidorov", 50));
-
- // 1. Empty result set.
- using (
- IQueryCursor<IList> cursor = Cache().QueryFields(
- new SqlFieldsQuery("SELECT age FROM QueryPerson WHERE age < ?", 50)))
- {
- foreach (IList entry in cursor.GetAll())
- Assert.IsTrue((int) entry[0] < 50);
- }
- }
-
- /// <summary>
- /// Check query result for enumerator test.
- /// </summary>
- /// <param name="qry">QUery.</param>
- private void CheckEnumeratorQuery(SqlQuery qry)
- {
- using (IQueryCursor<ICacheEntry<int, QueryPerson>> cursor = Cache().Query(qry))
- {
- bool first = false;
- bool second = false;
- bool third = false;
-
- foreach (var entry in cursor)
- {
- if (entry.Key == 1)
- {
- first = true;
-
- Assert.AreEqual("Ivanov", entry.Value.Name);
- Assert.AreEqual(30, entry.Value.Age);
- }
- else if (entry.Key == 2)
- {
- second = true;
-
- Assert.AreEqual("Petrov", entry.Value.Name);
- Assert.AreEqual(40, entry.Value.Age);
- }
- else if (entry.Key == 3)
- {
- third = true;
-
- Assert.AreEqual("Sidorov", entry.Value.Name);
- Assert.AreEqual(50, entry.Value.Age);
- }
- else
- Assert.Fail("Unexpected value: " + entry);
- }
-
- Assert.IsTrue(first && second && third);
- }
- }
-
- /// <summary>
- /// Check SQL query.
- /// </summary>
- [Test]
- public void TestSqlQuery()
- {
- CheckSqlQuery(MaxItemCnt, false, false);
- }
-
- /// <summary>
- /// Check SQL query in portable mode.
- /// </summary>
- [Test]
- public void TestSqlQueryPortable()
- {
- CheckSqlQuery(MaxItemCnt, false, true);
- }
-
- /// <summary>
- /// Check local SQL query.
- /// </summary>
- [Test]
- public void TestSqlQueryLocal()
- {
- CheckSqlQuery(MaxItemCnt, true, false);
- }
-
- /// <summary>
- /// Check local SQL query in portable mode.
- /// </summary>
- [Test]
- public void TestSqlQueryLocalPortable()
- {
- CheckSqlQuery(MaxItemCnt, true, true);
- }
-
- /// <summary>
- /// Check SQL query.
- /// </summary>
- /// <param name="cnt">Amount of cache entries to create.</param>
- /// <param name="loc">Local query flag.</param>
- /// <param name="keepPortable">Keep portable flag.</param>
- private void CheckSqlQuery(int cnt, bool loc, bool keepPortable)
- {
- var cache = Cache();
-
- // 1. Populate cache with data, calculating expected count in parallel.
- var exp = PopulateCache(cache, loc, cnt, x => x < 50);
-
- // 2. Validate results.
- SqlQuery qry = loc ? new SqlQuery(typeof(QueryPerson), "age < 50", true) :
- new SqlQuery(typeof(QueryPerson), "age < 50");
-
- ValidateQueryResults(cache, qry, exp, keepPortable);
- }
-
- /// <summary>
- /// Check SQL fields query.
- /// </summary>
- [Test]
- public void TestSqlFieldsQuery()
- {
- CheckSqlFieldsQuery(MaxItemCnt, false);
- }
-
- /// <summary>
- /// Check local SQL fields query.
- /// </summary>
- [Test]
- public void TestSqlFieldsQueryLocal()
- {
- CheckSqlFieldsQuery(MaxItemCnt, true);
- }
-
- /// <summary>
- /// Check SQL fields query.
- /// </summary>
- /// <param name="cnt">Amount of cache entries to create.</param>
- /// <param name="loc">Local query flag.</param>
- private void CheckSqlFieldsQuery(int cnt, bool loc)
- {
- var cache = Cache();
-
- // 1. Populate cache with data, calculating expected count in parallel.
- var exp = PopulateCache(cache, loc, cnt, x => x < 50);
-
- // 2. Vlaidate results.
- SqlFieldsQuery qry = loc ? new SqlFieldsQuery("SELECT name, age FROM QueryPerson WHERE age < 50", true) :
- new SqlFieldsQuery("SELECT name, age FROM QueryPerson WHERE age < 50");
-
- using (IQueryCursor<IList> cursor = cache.QueryFields(qry))
- {
- HashSet<int> exp0 = new HashSet<int>(exp);
-
- foreach (var entry in cursor.GetAll())
- {
- Assert.AreEqual(2, entry.Count);
- Assert.AreEqual(entry[0].ToString(), entry[1].ToString());
-
- exp0.Remove((int)entry[1]);
- }
-
- Assert.AreEqual(0, exp0.Count);
- }
-
- using (IQueryCursor<IList> cursor = cache.QueryFields(qry))
- {
- HashSet<int> exp0 = new HashSet<int>(exp);
-
- foreach (var entry in cursor)
- {
- Assert.AreEqual(entry[0].ToString(), entry[1].ToString());
-
- exp0.Remove((int)entry[1]);
- }
-
- Assert.AreEqual(0, exp0.Count);
- }
- }
-
- /// <summary>
- /// Check text query.
- /// </summary>
- [Test]
- public void TestTextQuery()
- {
- CheckTextQuery(MaxItemCnt, false, false);
- }
-
- /// <summary>
- /// Check SQL query in portable mode.
- /// </summary>
- [Test]
- public void TestTextQueryPortable()
- {
- CheckTextQuery(MaxItemCnt, false, true);
- }
-
- /// <summary>
- /// Check local SQL query.
- /// </summary>
- [Test]
- public void TestTextQueryLocal()
- {
- CheckTextQuery(MaxItemCnt, true, false);
- }
-
- /// <summary>
- /// Check local SQL query in portable mode.
- /// </summary>
- [Test]
- public void TestTextQueryLocalPortable()
- {
- CheckTextQuery(MaxItemCnt, true, true);
- }
-
- /// <summary>
- /// Check text query.
- /// </summary>
- /// <param name="cnt">Amount of cache entries to create.</param>
- /// <param name="loc">Local query flag.</param>
- /// <param name="keepPortable">Keep portable flag.</param>
- private void CheckTextQuery(int cnt, bool loc, bool keepPortable)
- {
- var cache = Cache();
-
- // 1. Populate cache with data, calculating expected count in parallel.
- var exp = PopulateCache(cache, loc, cnt, x => x.ToString().StartsWith("1"));
-
- // 2. Validate results.
- TextQuery qry = loc ? new TextQuery(typeof(QueryPerson), "1*", true) :
- new TextQuery(typeof(QueryPerson), "1*");
-
- ValidateQueryResults(cache, qry, exp, keepPortable);
- }
-
- /// <summary>
- /// Check scan query.
- /// </summary>
- [Test]
- public void TestScanQuery()
- {
- CheckScanQuery<QueryPerson>(MaxItemCnt, false, false);
- }
-
- /// <summary>
- /// Check scan query in portable mode.
- /// </summary>
- [Test]
- public void TestScanQueryPortable()
- {
- CheckScanQuery<PortableUserObject>(MaxItemCnt, false, true);
- }
-
- /// <summary>
- /// Check local scan query.
- /// </summary>
- [Test]
- public void TestScanQueryLocal()
- {
- CheckScanQuery<QueryPerson>(MaxItemCnt, true, false);
- }
-
- /// <summary>
- /// Check local scan query in portable mode.
- /// </summary>
- [Test]
- public void TestScanQueryLocalPortable()
- {
- CheckScanQuery<PortableUserObject>(MaxItemCnt, true, true);
- }
-
- /// <summary>
- /// Check scan query with partitions.
- /// </summary>
- [Test]
- [Ignore("IGNITE-1012")]
- public void TestScanQueryPartitions([Values(true, false)] bool loc)
- {
- CheckScanQueryPartitions<QueryPerson>(MaxItemCnt, loc, false);
- }
-
- /// <summary>
- /// Check scan query with partitions in portable mode.
- /// </summary>
- [Test]
- [Ignore("IGNITE-1012")]
- public void TestScanQueryPartitionsPortable([Values(true, false)] bool loc)
- {
- CheckScanQueryPartitions<PortableUserObject>(MaxItemCnt, loc, true);
- }
-
- /// <summary>
- /// Tests that query attempt on non-indexed cache causes an exception.
- /// </summary>
- [Test]
- public void TestIndexingDisabledError()
- {
- var cache = GetIgnite(0).GetOrCreateCache<int, QueryPerson>("nonindexed_cache");
-
- var queries = new QueryBase[]
- {
- new TextQuery(typeof (QueryPerson), "1*"),
- new SqlQuery(typeof (QueryPerson), "age < 50")
- };
-
- foreach (var qry in queries)
- {
- var err = Assert.Throws<IgniteException>(() => cache.Query(qry));
-
- Assert.AreEqual("Indexing is disabled for cache: nonindexed_cache. " +
- "Use setIndexedTypes or setTypeMetadata methods on CacheConfiguration to enable.", err.Message);
- }
- }
-
- /// <summary>
- /// Check scan query.
- /// </summary>
- /// <param name="cnt">Amount of cache entries to create.</param>
- /// <param name="loc">Local query flag.</param>
- /// <param name="keepPortable">Keep portable flag.</param>
- private void CheckScanQuery<TV>(int cnt, bool loc, bool keepPortable)
- {
- var cache = Cache();
-
- // No predicate
- var exp = PopulateCache(cache, loc, cnt, x => true);
- var qry = new ScanQuery<int, TV>();
- ValidateQueryResults(cache, qry, exp, keepPortable);
-
- // Serializable
- exp = PopulateCache(cache, loc, cnt, x => x < 50);
- qry = new ScanQuery<int, TV>(new ScanQueryFilter<TV>());
- ValidateQueryResults(cache, qry, exp, keepPortable);
-
- // Portable
- exp = PopulateCache(cache, loc, cnt, x => x < 50);
- qry = new ScanQuery<int, TV>(new PortableScanQueryFilter<TV>());
- ValidateQueryResults(cache, qry, exp, keepPortable);
-
- // Exception
- exp = PopulateCache(cache, loc, cnt, x => x < 50);
- qry = new ScanQuery<int, TV>(new ScanQueryFilter<TV> {ThrowErr = true});
-
- var ex = Assert.Throws<IgniteException>(() => ValidateQueryResults(cache, qry, exp, keepPortable));
- Assert.AreEqual(ScanQueryFilter<TV>.ErrMessage, ex.Message);
- }
-
- /// <summary>
- /// Checks scan query with partitions.
- /// </summary>
- /// <param name="cnt">Amount of cache entries to create.</param>
- /// <param name="loc">Local query flag.</param>
- /// <param name="keepPortable">Keep portable flag.</param>
- private void CheckScanQueryPartitions<TV>(int cnt, bool loc, bool keepPortable)
- {
- StopGrids();
- StartGrids();
-
- var cache = Cache();
-
- var aff = cache.Ignite.GetAffinity(CacheName);
- var exp = PopulateCache(cache, loc, cnt, x => true); // populate outside the loop (slow)
-
- for (var part = 0; part < aff.Partitions; part++)
- {
- //var exp0 = new HashSet<int>(exp.Where(x => aff.Partition(x) == part)); // filter expected keys
- var exp0 = new HashSet<int>();
- foreach (var x in exp)
- if (aff.GetPartition(x) == part)
- exp0.Add(x);
-
- var qry = new ScanQuery<int, TV> { Partition = part };
-
- Console.WriteLine("Checking query on partition " + part);
- ValidateQueryResults(cache, qry, exp0, keepPortable);
- }
-
- // Partitions with predicate
- exp = PopulateCache(cache, loc, cnt, x => x < 50); // populate outside the loop (slow)
-
- for (var part = 0; part < aff.Partitions; part++)
- {
- //var exp0 = new HashSet<int>(exp.Where(x => aff.Partition(x) == part)); // filter expected keys
- var exp0 = new HashSet<int>();
- foreach (var x in exp)
- if (aff.GetPartition(x) == part)
- exp0.Add(x);
-
- var qry = new ScanQuery<int, TV>(new ScanQueryFilter<TV>()) { Partition = part };
-
- Console.WriteLine("Checking predicate query on partition " + part);
- ValidateQueryResults(cache, qry, exp0, keepPortable);
- }
-
- }
-
- /// <summary>
- /// Validates the query results.
- /// </summary>
- /// <param name="cache">Cache.</param>
- /// <param name="qry">Query.</param>
- /// <param name="exp">Expected keys.</param>
- /// <param name="keepPortable">Keep portable flag.</param>
- private static void ValidateQueryResults(ICache<int, QueryPerson> cache, QueryBase qry, HashSet<int> exp,
- bool keepPortable)
- {
- if (keepPortable)
- {
- var cache0 = cache.WithKeepPortable<int, IPortableObject>();
-
- using (var cursor = cache0.Query(qry))
- {
- HashSet<int> exp0 = new HashSet<int>(exp);
- var all = new List<ICacheEntry<int, object>>();
-
- foreach (var entry in cursor.GetAll())
- {
- all.Add(entry);
-
- Assert.AreEqual(entry.Key.ToString(), entry.Value.GetField<string>("name"));
- Assert.AreEqual(entry.Key, entry.Value.GetField<int>("age"));
-
- exp0.Remove(entry.Key);
- }
-
- AssertMissingExpectedKeys(exp0, cache, all);
- }
-
- using (var cursor = cache0.Query(qry))
- {
- HashSet<int> exp0 = new HashSet<int>(exp);
- var all = new List<ICacheEntry<int, object>>();
-
- foreach (var entry in cursor)
- {
- all.Add(entry);
-
- Assert.AreEqual(entry.Key.ToString(), entry.Value.GetField<string>("name"));
- Assert.AreEqual(entry.Key, entry.Value.GetField<int>("age"));
-
- exp0.Remove(entry.Key);
- }
-
- AssertMissingExpectedKeys(exp0, cache, all);
- }
- }
- else
- {
- using (var cursor = cache.Query(qry))
- {
- HashSet<int> exp0 = new HashSet<int>(exp);
- var all = new List<ICacheEntry<int, object>>();
-
- foreach (var entry in cursor.GetAll())
- {
- all.Add(entry);
-
- Assert.AreEqual(entry.Key.ToString(), entry.Value.Name);
- Assert.AreEqual(entry.Key, entry.Value.Age);
-
- exp0.Remove(entry.Key);
- }
-
- AssertMissingExpectedKeys(exp0, cache, all);
- }
-
- using (var cursor = cache.Query(qry))
- {
- HashSet<int> exp0 = new HashSet<int>(exp);
- var all = new List<ICacheEntry<int, object>>();
-
- foreach (var entry in cursor)
- {
- all.Add(entry);
-
- Assert.AreEqual(entry.Key.ToString(), entry.Value.Name);
- Assert.AreEqual(entry.Key, entry.Value.Age);
-
- exp0.Remove(entry.Key);
- }
-
- AssertMissingExpectedKeys(exp0, cache, all);
- }
- }
- }
-
- /// <summary>
- /// Asserts that all expected entries have been received.
- /// </summary>
- private static void AssertMissingExpectedKeys(ICollection<int> exp, ICache<int, QueryPerson> cache,
- IList<ICacheEntry<int, object>> all)
- {
- if (exp.Count == 0)
- return;
-
- var sb = new StringBuilder();
- var aff = cache.Ignite.GetAffinity(cache.Name);
-
- foreach (var key in exp)
- {
- var part = aff.GetPartition(key);
- sb.AppendFormat(
- "Query did not return expected key '{0}' (exists: {1}), partition '{2}', partition nodes: ",
- key, cache.Get(key) != null, part);
-
- var partNodes = aff.MapPartitionToPrimaryAndBackups(part);
-
- foreach (var node in partNodes)
- sb.Append(node).Append(" ");
-
- sb.AppendLine(";");
- }
-
- sb.Append("Returned keys: ");
-
- foreach (var e in all)
- sb.Append(e.Key).Append(" ");
-
- sb.AppendLine(";");
-
- Assert.Fail(sb.ToString());
- }
-
- /// <summary>
- /// Populates the cache with random entries and returns expected results set according to filter.
- /// </summary>
- /// <param name="cache">The cache.</param>
- /// <param name="cnt">Amount of cache entries to create.</param>
- /// <param name="loc">Local query flag.</param>
- /// <param name="expectedEntryFilter">The expected entry filter.</param>
- /// <returns>Expected results set.</returns>
- private static HashSet<int> PopulateCache(ICache<int, QueryPerson> cache, bool loc, int cnt,
- Func<int, bool> expectedEntryFilter)
- {
- var rand = new Random();
-
- var exp = new HashSet<int>();
-
- for (var i = 0; i < cnt; i++)
- {
- var val = rand.Next(100);
-
- cache.Put(val, new QueryPerson(val.ToString(), val));
-
- if (expectedEntryFilter(val) && (!loc || cache.Ignite.GetAffinity(cache.Name)
- .IsPrimary(cache.Ignite.GetCluster().GetLocalNode(), val)))
- exp.Add(val);
- }
-
- return exp;
- }
- }
-
- /// <summary>
- /// Person.
- /// </summary>
- public class QueryPerson
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- public QueryPerson()
- {
- // No-op.
- }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="name">Name.</param>
- /// <param name="age">Age.</param>
- public QueryPerson(string name, int age)
- {
- Name = name;
- Age = age;
- }
-
- /// <summary>
- /// Name.
- /// </summary>
- public string Name { get; set; }
-
- /// <summary>
- /// Age.
- /// </summary>
- public int Age { get; set; }
- }
-
- /// <summary>
- /// Query filter.
- /// </summary>
- [Serializable]
- public class ScanQueryFilter<TV> : ICacheEntryFilter<int, TV>
- {
- // Error message
- public const string ErrMessage = "Error in ScanQueryFilter.Invoke";
-
- // Error flag
- public bool ThrowErr { get; set; }
-
- /** <inheritdoc /> */
- public bool Invoke(ICacheEntry<int, TV> entry)
- {
- if (ThrowErr)
- throw new Exception(ErrMessage);
-
- return entry.Key < 50;
- }
- }
-
- /// <summary>
- /// Portable query filter.
- /// </summary>
- public class PortableScanQueryFilter<TV> : ScanQueryFilter<TV>, IPortableMarshalAware
- {
- /** <inheritdoc /> */
- public void WritePortable(IPortableWriter writer)
- {
- var w = writer.RawWriter();
-
- w.WriteBoolean(ThrowErr);
- }
-
- /** <inheritdoc /> */
- public void ReadPortable(IPortableReader reader)
- {
- var r = reader.RawReader();
-
- ThrowErr = r.ReadBoolean();
- }
- }
-}
[25/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Process/IgniteProcess.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Process/IgniteProcess.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Process/IgniteProcess.cs
new file mode 100644
index 0000000..fd08116
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Process/IgniteProcess.cs
@@ -0,0 +1,283 @@
+/*
+ * 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.Process
+{
+ using System;
+ using System.Diagnostics;
+ using System.IO;
+ using System.Linq;
+ using System.Text;
+ using System.Threading;
+ using Apache.Ignite.Core.Impl;
+
+ /// <summary>
+ /// Defines forked Ignite node.
+ /// </summary>
+ public class IgniteProcess
+ {
+ /** Executable file name. */
+ private static readonly string ExeName = "Apache.Ignite.exe";
+
+ /** Executable process name. */
+ private static readonly string ExeProcName = ExeName.Substring(0, ExeName.LastIndexOf('.'));
+
+ /** Executable configuration file name. */
+ private static readonly string ExeCfgName = ExeName + ".config";
+
+ /** Executable backup configuration file name. */
+ private static readonly string ExeCfgBakName = ExeCfgName + ".bak";
+
+ /** Directory where binaries are stored. */
+ private static readonly string ExeDir;
+
+ /** Full path to executable. */
+ private static readonly string ExePath;
+
+ /** Full path to executable configuration file. */
+ private static readonly string ExeCfgPath;
+
+ /** Full path to executable configuration file backup. */
+ private static readonly string ExeCfgBakPath;
+
+ /** Default process output reader. */
+ private static readonly IIgniteProcessOutputReader DfltOutReader = new IgniteProcessConsoleOutputReader();
+
+ /** Process. */
+ private readonly Process _proc;
+
+ /// <summary>
+ /// Static initializer.
+ /// </summary>
+ static IgniteProcess()
+ {
+ // 1. Locate executable file and related stuff.
+ DirectoryInfo dir = new FileInfo(new Uri(typeof(IgniteProcess).Assembly.CodeBase).LocalPath).Directory;
+
+ // ReSharper disable once PossibleNullReferenceException
+ ExeDir = dir.FullName;
+
+ var exe = dir.GetFiles(ExeName);
+
+ if (exe.Length == 0)
+ throw new Exception(ExeName + " is not found in test output directory: " + dir.FullName);
+
+ ExePath = exe[0].FullName;
+
+ var exeCfg = dir.GetFiles(ExeCfgName);
+
+ if (exeCfg.Length == 0)
+ throw new Exception(ExeCfgName + " is not found in test output directory: " + dir.FullName);
+
+ ExeCfgPath = exeCfg[0].FullName;
+
+ ExeCfgBakPath = Path.Combine(ExeDir, ExeCfgBakName);
+
+ File.Delete(ExeCfgBakPath);
+ }
+
+ /// <summary>
+ /// Save current configuration to backup.
+ /// </summary>
+ public static void SaveConfigurationBackup()
+ {
+ File.Copy(ExeCfgPath, ExeCfgBakPath, true);
+ }
+
+ /// <summary>
+ /// Restore configuration from backup.
+ /// </summary>
+ public static void RestoreConfigurationBackup()
+ {
+ File.Copy(ExeCfgBakPath, ExeCfgPath, true);
+ }
+
+ /// <summary>
+ /// Replace application configuration with another one.
+ /// </summary>
+ /// <param name="relPath">Path to config relative to executable directory.</param>
+ public static void ReplaceConfiguration(string relPath)
+ {
+ File.Copy(Path.Combine(ExeDir, relPath), ExeCfgPath, true);
+ }
+
+ /// <summary>
+ /// Kill all Ignite processes.
+ /// </summary>
+ public static void KillAll()
+ {
+ foreach (Process proc in Process.GetProcesses())
+ {
+ if (proc.ProcessName.Equals(ExeProcName))
+ {
+ proc.Kill();
+
+ proc.WaitForExit();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Construector.
+ /// </summary>
+ /// <param name="args">Arguments</param>
+ public IgniteProcess(params string[] args) : this(DfltOutReader, args) { }
+
+ /// <summary>
+ /// Construector.
+ /// </summary>
+ /// <param name="outReader">Output reader.</param>
+ /// <param name="args">Arguments.</param>
+ public IgniteProcess(IIgniteProcessOutputReader outReader, params string[] args)
+ {
+ // Add test dll path
+ args = args.Concat(new[] {"-assembly=" + GetType().Assembly.Location}).ToArray();
+
+ _proc = Start(ExePath, IgniteManager.GetIgniteHome(null), outReader, args);
+ }
+
+ /// <summary>
+ /// Starts a grid process.
+ /// </summary>
+ /// <param name="exePath">Exe path.</param>
+ /// <param name="ggHome">Ignite home.</param>
+ /// <param name="outReader">Output reader.</param>
+ /// <param name="args">Arguments.</param>
+ /// <returns>Started process.</returns>
+ public static Process Start(string exePath, string ggHome, IIgniteProcessOutputReader outReader = null,
+ params string[] args)
+ {
+ Debug.Assert(!string.IsNullOrEmpty(exePath));
+ Debug.Assert(!string.IsNullOrEmpty(ggHome));
+
+ // 1. Define process start configuration.
+ var sb = new StringBuilder();
+
+ foreach (string arg in args)
+ sb.Append('\"').Append(arg).Append("\" ");
+
+ var procStart = new ProcessStartInfo
+ {
+ FileName = exePath,
+ Arguments = sb.ToString()
+ };
+
+ if (!string.IsNullOrEmpty(ggHome))
+ procStart.EnvironmentVariables[IgniteManager.EnvIgniteHome] = ggHome;
+
+ procStart.EnvironmentVariables[IgniteManager.EnvIgniteNativeTestClasspath] = "true";
+
+ procStart.CreateNoWindow = true;
+ procStart.UseShellExecute = false;
+
+ procStart.RedirectStandardOutput = true;
+ procStart.RedirectStandardError = true;
+
+ var workDir = Path.GetDirectoryName(exePath);
+
+ if (workDir != null)
+ procStart.WorkingDirectory = workDir;
+
+ Console.WriteLine("About to run Apache.Ignite.exe process [exePath=" + exePath + ", arguments=" + sb + ']');
+
+ // 2. Start.
+ var proc = Process.Start(procStart);
+
+ Debug.Assert(proc != null);
+
+ // 3. Attach output readers to avoid hangs.
+ outReader = outReader ?? DfltOutReader;
+
+ Attach(proc, proc.StandardOutput, outReader, false);
+ Attach(proc, proc.StandardError, outReader, true);
+
+ return proc;
+ }
+
+ /// <summary>
+ /// Whether the process is still alive.
+ /// </summary>
+ public bool Alive
+ {
+ get { return !_proc.HasExited; }
+ }
+
+ /// <summary>
+ /// Kill process.
+ /// </summary>
+ public void Kill()
+ {
+ _proc.Kill();
+ }
+
+ /// <summary>
+ /// Join process.
+ /// </summary>
+ /// <returns>Exit code.</returns>
+ public int Join()
+ {
+ _proc.WaitForExit();
+
+ return _proc.ExitCode;
+ }
+
+ /// <summary>
+ /// Join process with timeout.
+ /// </summary>
+ /// <param name="timeout">Timeout in milliseconds.</param>
+ /// <returns><c>True</c> if process exit occurred before timeout.</returns>
+ public bool Join(int timeout)
+ {
+ return _proc.WaitForExit(timeout);
+ }
+
+ /// <summary>
+ /// Join process with timeout.
+ /// </summary>
+ /// <param name="timeout">Timeout in milliseconds.</param>
+ /// <param name="exitCode">Exit code.</param>
+ /// <returns><c>True</c> if process exit occurred before timeout.</returns>
+ public bool Join(int timeout, out int exitCode)
+ {
+ if (_proc.WaitForExit(timeout))
+ {
+ exitCode = _proc.ExitCode;
+
+ return true;
+ }
+ exitCode = 0;
+
+ return false;
+ }
+
+ /// <summary>
+ /// Attach output reader to the process.
+ /// </summary>
+ /// <param name="proc">Process.</param>
+ /// <param name="reader">Process stream reader.</param>
+ /// <param name="outReader">Output reader.</param>
+ /// <param name="err">Whether this is error stream.</param>
+ private static void Attach(Process proc, StreamReader reader, IIgniteProcessOutputReader outReader, bool err)
+ {
+ new Thread(() =>
+ {
+ while (!proc.HasExited)
+ outReader.OnOutput(proc, reader.ReadLine(), err);
+ }) {IsBackground = true}.Start();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Process/IgniteProcessConsoleOutputReader.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Process/IgniteProcessConsoleOutputReader.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Process/IgniteProcessConsoleOutputReader.cs
new file mode 100644
index 0000000..00cc040
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Process/IgniteProcessConsoleOutputReader.cs
@@ -0,0 +1,40 @@
+/*
+ * 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.Process
+{
+ using System;
+ using System.Diagnostics;
+
+ /// <summary>
+ /// Output reader pushing data to the console.
+ /// </summary>
+ public class IgniteProcessConsoleOutputReader : IIgniteProcessOutputReader
+ {
+ /** Out message format. */
+ private static readonly string OutFormat = ">>> {0} OUT: {1}";
+
+ /** Error message format. */
+ private static readonly string ErrFormat = ">>> {0} ERR: {1}";
+
+ /** <inheritDoc /> */
+ public void OnOutput(Process proc, string data, bool err)
+ {
+ Console.WriteLine(err ? ErrFormat : OutFormat, proc.Id, data);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..1ebcf24
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("Apache.Ignite.Core.Tests")]
+[assembly: AssemblyDescription("Apache Ignite .NET Core Tests")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("Apache.Ignite.Core.Tests")]
+[assembly: AssemblyCopyright("Copyright © 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+[assembly: ComVisible(false)]
+
+[assembly: Guid("de8dd5cc-7c7f-4a09-80d5-7086d9416a7b")]
+
+[assembly: AssemblyVersion("1.5.0")]
+[assembly: AssemblyFileVersion("1.5.0")]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Query/ImplicitPortablePerson.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Query/ImplicitPortablePerson.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Query/ImplicitPortablePerson.cs
new file mode 100644
index 0000000..f80c4eb
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Query/ImplicitPortablePerson.cs
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Query
+{
+ /// <summary>
+ /// Test person.
+ /// </summary>
+ internal class ImplicitPortablePerson
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ImplicitPortablePerson"/> class.
+ /// </summary>
+ /// <param name="name">The name.</param>
+ /// <param name="age">The age.</param>
+ public ImplicitPortablePerson(string name, int age)
+ {
+ Name = name;
+ Age = age;
+ }
+
+ /// <summary>
+ /// Gets or sets the name.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the age.
+ /// </summary>
+ public int Age { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Query/NoDefPortablePerson.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Query/NoDefPortablePerson.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Query/NoDefPortablePerson.cs
new file mode 100644
index 0000000..16bd07d
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Query/NoDefPortablePerson.cs
@@ -0,0 +1,35 @@
+/*
+ * 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.Query
+{
+ /// <summary>
+ /// Test person.
+ /// </summary>
+ internal class NoDefPortablePerson
+ {
+ /// <summary>
+ /// Gets or sets the name.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the age.
+ /// </summary>
+ public int Age { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Query/PortablePerson.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Query/PortablePerson.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Query/PortablePerson.cs
new file mode 100644
index 0000000..1e11001
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Query/PortablePerson.cs
@@ -0,0 +1,69 @@
+/*
+ * 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.Query
+{
+ using Apache.Ignite.Core.Portable;
+
+ /// <summary>
+ /// Test person.
+ /// </summary>
+ internal class PortablePerson : IPortableMarshalAware
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="PortablePerson"/> class.
+ /// </summary>
+ /// <param name="name">The name.</param>
+ /// <param name="age">The age.</param>
+ public PortablePerson(string name, int age)
+ {
+ Name = name;
+ Age = age;
+ }
+
+ /// <summary>
+ /// Gets or sets the name.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the address.
+ /// </summary>
+ public string Address { get; set; }
+
+ /// <summary>
+ /// Gets or sets the age.
+ /// </summary>
+ public int Age { get; set; }
+
+ /** <ineritdoc /> */
+ public void WritePortable(IPortableWriter writer)
+ {
+ writer.WriteString("name", Name);
+ writer.WriteString("address", Address);
+ writer.WriteInt("age", Age);
+ }
+
+ /** <ineritdoc /> */
+ public void ReadPortable(IPortableReader reader)
+ {
+ Name = reader.ReadString("name");
+ Address = reader.ReadString("address");
+ Age = reader.ReadInt("age");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs
new file mode 100644
index 0000000..e1a543e
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs
@@ -0,0 +1,240 @@
+/*
+ * 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 System.Reflection.Emit;
+ using System.Runtime.Serialization;
+ using System.Xml;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Compute;
+ using Apache.Ignite.Core.Impl;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests for native serialization.
+ /// </summary>
+ public class SerializationTest
+ {
+ /** Grid name. */
+ private const string GridName = "SerializationTest";
+
+ /// <summary>
+ /// Set up routine.
+ /// </summary>
+ [TestFixtureSetUp]
+ public void SetUp()
+ {
+ var cfg = new IgniteConfigurationEx
+ {
+ GridName = GridName,
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = TestUtils.TestJavaOptions(),
+ SpringConfigUrl = "config\\native-client-test-cache.xml"
+ };
+
+ Ignition.Start(cfg);
+ }
+
+ /// <summary>
+ /// Tear down routine.
+ /// </summary>
+ [TestFixtureTearDown]
+ public void TearDown()
+ {
+ Ignition.StopAll(true);
+ }
+
+ /// <summary>
+ /// Test complex file serialization.
+ /// </summary>
+ [Test]
+ public void TestSerializableXmlDoc()
+ {
+ var grid = Ignition.GetIgnite(GridName);
+ var cache = grid.GetCache<int, SerializableXmlDoc>("replicated");
+
+ var doc = new SerializableXmlDoc();
+
+ doc.LoadXml("<document><test1>val</test1><test2 attr=\"x\" /></document>");
+
+ for (var i = 0; i < 50; i++)
+ {
+ // Test cache
+ cache.Put(i, doc);
+
+ var resultDoc = cache.Get(i);
+
+ Assert.AreEqual(doc.OuterXml, resultDoc.OuterXml);
+
+ // Test task with document arg
+ CheckTask(grid, doc);
+ }
+ }
+
+ /// <summary>
+ /// Checks task execution.
+ /// </summary>
+ /// <param name="grid">Grid.</param>
+ /// <param name="arg">Task arg.</param>
+ private static void CheckTask(IIgnite grid, object arg)
+ {
+ var jobResult = grid.GetCompute().Execute(new CombineStringsTask(), arg);
+
+ var nodeCount = grid.GetCluster().GetNodes().Count;
+
+ var expectedRes =
+ CombineStringsTask.CombineStrings(Enumerable.Range(0, nodeCount).Select(x => arg.ToString()));
+
+ Assert.AreEqual(expectedRes, jobResult.InnerXml);
+ }
+
+ /// <summary>
+ /// Tests custom serialization binder.
+ /// </summary>
+ [Test]
+ public void TestSerializationBinder()
+ {
+ const int count = 50;
+
+ var cache = Ignition.GetIgnite(GridName).GetCache<int, object>("local");
+
+ // Put multiple objects from muliple same-named assemblies to cache
+ for (var i = 0; i < count; i++)
+ {
+ dynamic val = Activator.CreateInstance(GenerateDynamicType());
+
+ val.Id = i;
+ val.Name = "Name_" + i;
+
+ cache.Put(i, val);
+ }
+
+ // Verify correct deserialization
+ for (var i = 0; i < count; i++)
+ {
+ dynamic val = cache.Get(i);
+
+ Assert.AreEqual(val.Id, i);
+ Assert.AreEqual(val.Name, "Name_" + i);
+ }
+ }
+
+ /// <summary>
+ /// Generates a Type in runtime, puts it into a dynamic assembly.
+ /// </summary>
+ /// <returns></returns>
+ public static Type GenerateDynamicType()
+ {
+ var asmBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(
+ new AssemblyName("GridSerializationTestDynamicAssembly"), AssemblyBuilderAccess.Run);
+
+ var moduleBuilder = asmBuilder.DefineDynamicModule("GridSerializationTestDynamicModule");
+
+ var typeBuilder = moduleBuilder.DefineType("GridSerializationTestDynamicType",
+ TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Serializable);
+
+ typeBuilder.DefineField("Id", typeof (int), FieldAttributes.Public);
+
+ typeBuilder.DefineField("Name", typeof (string), FieldAttributes.Public);
+
+ return typeBuilder.CreateType();
+ }
+ }
+
+ [Serializable]
+ [DataContract]
+ public sealed class SerializableXmlDoc : XmlDocument, ISerializable
+ {
+ /// <summary>
+ /// Default ctor.
+ /// </summary>
+ public SerializableXmlDoc()
+ {
+ // No-op
+ }
+
+ /// <summary>
+ /// Serialization ctor.
+ /// </summary>
+ private SerializableXmlDoc(SerializationInfo info, StreamingContext context)
+ {
+ LoadXml(info.GetString("xmlDocument"));
+ }
+
+ /** <inheritdoc /> */
+ public void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ info.AddValue("xmlDocument", OuterXml, typeof(string));
+ }
+ }
+
+ [Serializable]
+ public class CombineStringsTask : IComputeTask<object, string, SerializableXmlDoc>
+ {
+ public IDictionary<IComputeJob<string>, IClusterNode> Map(IList<IClusterNode> subgrid, object arg)
+ {
+ return subgrid.ToDictionary(x => (IComputeJob<string>) new ToStringJob {Arg = arg}, x => x);
+ }
+
+ public ComputeJobResultPolicy Result(IComputeJobResult<string> res, IList<IComputeJobResult<string>> rcvd)
+ {
+ return ComputeJobResultPolicy.Wait;
+ }
+
+ public SerializableXmlDoc Reduce(IList<IComputeJobResult<string>> results)
+ {
+ var result = new SerializableXmlDoc();
+
+ result.LoadXml(CombineStrings(results.Select(x => x.Data())));
+
+ return result;
+ }
+
+ public static string CombineStrings(IEnumerable<string> strings)
+ {
+ var text = string.Concat(strings.Select(x => string.Format("<val>{0}</val>", x)));
+
+ return string.Format("<document>{0}</document>", text);
+ }
+ }
+
+ [Serializable]
+ public class ToStringJob : IComputeJob<string>
+ {
+ /// <summary>
+ /// Job argument.
+ /// </summary>
+ public object Arg { get; set; }
+
+ /** <inheritdoc /> */
+ public string Execute()
+ {
+ return Arg.ToString();
+ }
+
+ /** <inheritdoc /> */
+ public void Cancel()
+ {
+ // No-op.
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
new file mode 100644
index 0000000..44e1d71
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
@@ -0,0 +1,741 @@
+/*
+ * 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.Services
+{
+ using System;
+ using System.Diagnostics.CodeAnalysis;
+ using System.IO;
+ using System.Linq;
+ using System.Reflection;
+ using Apache.Ignite.Core.Impl.Memory;
+ using Apache.Ignite.Core.Impl.Portable;
+ using Apache.Ignite.Core.Impl.Services;
+ using Apache.Ignite.Core.Portable;
+ using Apache.Ignite.Core.Services;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests <see cref="ServiceProxySerializer"/> functionality.
+ /// </summary>
+ public class ServiceProxyTest
+ {
+ /** */
+ private TestIgniteService _svc;
+
+ /** */
+ private readonly PortableMarshaller _marsh = new PortableMarshaller(new PortableConfiguration
+ {
+ TypeConfigurations = new[]
+ {
+ new PortableTypeConfiguration(typeof (TestPortableClass)),
+ new PortableTypeConfiguration(typeof (CustomExceptionPortable))
+ }
+ });
+
+ /** */
+ protected readonly IPortables Portables;
+
+ /** */
+ private readonly PlatformMemoryManager _memory = new PlatformMemoryManager(1024);
+
+ /** */
+ protected bool KeepPortable;
+
+ /** */
+ protected bool SrvKeepPortable;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ServiceProxyTest"/> class.
+ /// </summary>
+ public ServiceProxyTest()
+ {
+ Portables = new PortablesImpl(_marsh);
+ }
+
+ /// <summary>
+ /// Tests object class methods proxying.
+ /// </summary>
+ [Test]
+ public void TestObjectClassMethods()
+ {
+ var prx = GetProxy();
+
+ prx.IntProp = 12345;
+
+ Assert.AreEqual("12345", prx.ToString());
+ Assert.AreEqual("12345", _svc.ToString());
+ Assert.AreEqual(12345, prx.GetHashCode());
+ Assert.AreEqual(12345, _svc.GetHashCode());
+ }
+
+ /// <summary>
+ /// Tests properties proxying.
+ /// </summary>
+ [Test]
+ [SuppressMessage("ReSharper", "PossibleNullReferenceException")]
+ public void TestProperties()
+ {
+ var prx = GetProxy();
+
+ prx.IntProp = 10;
+ Assert.AreEqual(10, prx.IntProp);
+ Assert.AreEqual(10, _svc.IntProp);
+
+ _svc.IntProp = 15;
+ Assert.AreEqual(15, prx.IntProp);
+ Assert.AreEqual(15, _svc.IntProp);
+
+ prx.ObjProp = "prop1";
+ Assert.AreEqual("prop1", prx.ObjProp);
+ Assert.AreEqual("prop1", _svc.ObjProp);
+
+ prx.ObjProp = null;
+ Assert.IsNull(prx.ObjProp);
+ Assert.IsNull(_svc.ObjProp);
+
+ prx.ObjProp = new TestClass {Prop = "prop2"};
+ Assert.AreEqual("prop2", ((TestClass)prx.ObjProp).Prop);
+ Assert.AreEqual("prop2", ((TestClass)_svc.ObjProp).Prop);
+ }
+
+ /// <summary>
+ /// Tests void methods proxying.
+ /// </summary>
+ [Test]
+ public void TestVoidMethods()
+ {
+ var prx = GetProxy();
+
+ prx.VoidMethod();
+ Assert.AreEqual("VoidMethod", prx.InvokeResult);
+ Assert.AreEqual("VoidMethod", _svc.InvokeResult);
+
+ prx.VoidMethod(10);
+ Assert.AreEqual(_svc.InvokeResult, prx.InvokeResult);
+
+ prx.VoidMethod(10, "string");
+ Assert.AreEqual(_svc.InvokeResult, prx.InvokeResult);
+
+ prx.VoidMethod(10, "string", "arg");
+ Assert.AreEqual(_svc.InvokeResult, prx.InvokeResult);
+
+ prx.VoidMethod(10, "string", "arg", "arg1", 2, 3, "arg4");
+ Assert.AreEqual(_svc.InvokeResult, prx.InvokeResult);
+ }
+
+ /// <summary>
+ /// Tests object methods proxying.
+ /// </summary>
+ [Test]
+ public void TestObjectMethods()
+ {
+ var prx = GetProxy();
+
+ Assert.AreEqual("ObjectMethod", prx.ObjectMethod());
+ Assert.AreEqual("ObjectMethod987", prx.ObjectMethod(987));
+ Assert.AreEqual("ObjectMethod987str123", prx.ObjectMethod(987, "str123"));
+ Assert.AreEqual("ObjectMethod987str123TestClass", prx.ObjectMethod(987, "str123", new TestClass()));
+ Assert.AreEqual("ObjectMethod987str123TestClass34arg5arg6",
+ prx.ObjectMethod(987, "str123", new TestClass(), 3, 4, "arg5", "arg6"));
+ }
+
+ /// <summary>
+ /// Tests methods that exist in proxy interface, but do not exist in the actual service.
+ /// </summary>
+ [Test]
+ public void TestMissingMethods()
+ {
+ var prx = GetProxy();
+
+ var ex = Assert.Throws<InvalidOperationException>(() => prx.MissingMethod());
+
+ Assert.AreEqual("Failed to invoke proxy: there is no method 'MissingMethod'" +
+ " in type 'Apache.Ignite.Core.Tests.Services.ServiceProxyTest+TestIgniteService'", ex.Message);
+ }
+
+ /// <summary>
+ /// Tests ambiguous methods handling (multiple methods with the same signature).
+ /// </summary>
+ [Test]
+ public void TestAmbiguousMethods()
+ {
+ var prx = GetProxy();
+
+ var ex = Assert.Throws<InvalidOperationException>(() => prx.AmbiguousMethod(1));
+
+ Assert.AreEqual("Failed to invoke proxy: there are 2 methods 'AmbiguousMethod' in type " +
+ "'Apache.Ignite.Core.Tests.Services.ServiceProxyTest+TestIgniteService' with (Int32) arguments, " +
+ "can't resolve ambiguity.", ex.Message);
+ }
+
+ [Test]
+ public void TestException()
+ {
+ var prx = GetProxy();
+
+ var err = Assert.Throws<ServiceInvocationException>(prx.ExceptionMethod);
+ Assert.AreEqual("Expected exception", err.InnerException.Message);
+
+ var ex = Assert.Throws<ServiceInvocationException>(() => prx.CustomExceptionMethod());
+ Assert.IsTrue(ex.ToString().Contains("+CustomException"));
+ }
+
+ [Test]
+ public void TestPortableMarshallingException()
+ {
+ var prx = GetProxy();
+
+ var ex = Assert.Throws<ServiceInvocationException>(() => prx.CustomExceptionPortableMethod(false, false));
+
+ if (KeepPortable)
+ {
+ Assert.AreEqual("Proxy method invocation failed with a portable error. " +
+ "Examine PortableCause for details.", ex.Message);
+
+ Assert.IsNotNull(ex.PortableCause);
+ Assert.IsNull(ex.InnerException);
+ }
+ else
+ {
+ Assert.AreEqual("Proxy method invocation failed with an exception. " +
+ "Examine InnerException for details.", ex.Message);
+
+ Assert.IsNull(ex.PortableCause);
+ Assert.IsNotNull(ex.InnerException);
+ }
+
+ ex = Assert.Throws<ServiceInvocationException>(() => prx.CustomExceptionPortableMethod(true, false));
+ Assert.IsTrue(ex.ToString().Contains(
+ "Call completed with error, but error serialization failed [errType=CustomExceptionPortable, " +
+ "serializationErrMsg=Expected exception in CustomExceptionPortable.WritePortable]"));
+
+ ex = Assert.Throws<ServiceInvocationException>(() => prx.CustomExceptionPortableMethod(true, true));
+ Assert.IsTrue(ex.ToString().Contains(
+ "Call completed with error, but error serialization failed [errType=CustomExceptionPortable, " +
+ "serializationErrMsg=Expected exception in CustomExceptionPortable.WritePortable]"));
+ }
+
+ /// <summary>
+ /// Creates the proxy.
+ /// </summary>
+ protected ITestIgniteServiceProxyInterface GetProxy()
+ {
+ return GetProxy<ITestIgniteServiceProxyInterface>();
+ }
+
+ /// <summary>
+ /// Creates the proxy.
+ /// </summary>
+ protected T GetProxy<T>()
+ {
+ _svc = new TestIgniteService(Portables);
+
+ var prx = new ServiceProxy<T>(InvokeProxyMethod).GetTransparentProxy();
+
+ Assert.IsFalse(ReferenceEquals(_svc, prx));
+
+ return prx;
+ }
+
+ /// <summary>
+ /// Invokes the proxy.
+ /// </summary>
+ /// <param name="method">Method.</param>
+ /// <param name="args">Arguments.</param>
+ /// <returns>
+ /// Invocation result.
+ /// </returns>
+ private object InvokeProxyMethod(MethodBase method, object[] args)
+ {
+ using (var inStream = new PlatformMemoryStream(_memory.Allocate()))
+ using (var outStream = new PlatformMemoryStream(_memory.Allocate()))
+ {
+ // 1) Write to a stream
+ inStream.WriteBool(SrvKeepPortable); // WriteProxyMethod does not do this, but Java does
+
+ ServiceProxySerializer.WriteProxyMethod(_marsh.StartMarshal(inStream), method, args);
+
+ inStream.SynchronizeOutput();
+
+ inStream.Seek(0, SeekOrigin.Begin);
+
+ // 2) call InvokeServiceMethod
+ string mthdName;
+ object[] mthdArgs;
+
+ ServiceProxySerializer.ReadProxyMethod(inStream, _marsh, out mthdName, out mthdArgs);
+
+ var result = ServiceProxyInvoker.InvokeServiceMethod(_svc, mthdName, mthdArgs);
+
+ ServiceProxySerializer.WriteInvocationResult(outStream, _marsh, result.Key, result.Value);
+
+ _marsh.StartMarshal(outStream).WriteString("unused"); // fake Java exception details
+
+ outStream.SynchronizeOutput();
+
+ outStream.Seek(0, SeekOrigin.Begin);
+
+ return ServiceProxySerializer.ReadInvocationResult(outStream, _marsh, KeepPortable);
+ }
+ }
+
+ /// <summary>
+ /// Test service interface.
+ /// </summary>
+ protected interface ITestIgniteServiceProperties
+ {
+ /** */
+ int IntProp { get; set; }
+
+ /** */
+ object ObjProp { get; set; }
+
+ /** */
+ string InvokeResult { get; }
+ }
+
+ /// <summary>
+ /// Test service interface to check ambiguity handling.
+ /// </summary>
+ protected interface ITestIgniteServiceAmbiguity
+ {
+ /** */
+ int AmbiguousMethod(int arg);
+ }
+
+ /// <summary>
+ /// Test service interface.
+ /// </summary>
+ protected interface ITestIgniteService : ITestIgniteServiceProperties
+ {
+ /** */
+ void VoidMethod();
+
+ /** */
+ void VoidMethod(int arg);
+
+ /** */
+ void VoidMethod(int arg, string arg1, object arg2 = null);
+
+ /** */
+ void VoidMethod(int arg, string arg1, object arg2 = null, params object[] args);
+
+ /** */
+ object ObjectMethod();
+
+ /** */
+ object ObjectMethod(int arg);
+
+ /** */
+ object ObjectMethod(int arg, string arg1, object arg2 = null);
+
+ /** */
+ object ObjectMethod(int arg, string arg1, object arg2 = null, params object[] args);
+
+ /** */
+ void ExceptionMethod();
+
+ /** */
+ void CustomExceptionMethod();
+
+ /** */
+ void CustomExceptionPortableMethod(bool throwOnWrite, bool throwOnRead);
+
+ /** */
+ TestPortableClass PortableArgMethod(int arg1, IPortableObject arg2);
+
+ /** */
+ IPortableObject PortableResultMethod(int arg1, TestPortableClass arg2);
+
+ /** */
+ IPortableObject PortableArgAndResultMethod(int arg1, IPortableObject arg2);
+
+ /** */
+ int AmbiguousMethod(int arg);
+ }
+
+ /// <summary>
+ /// Test service interface. Does not derive from actual interface, but has all the same method signatures.
+ /// </summary>
+ protected interface ITestIgniteServiceProxyInterface
+ {
+ /** */
+ int IntProp { get; set; }
+
+ /** */
+ object ObjProp { get; set; }
+
+ /** */
+ string InvokeResult { get; }
+
+ /** */
+ void VoidMethod();
+
+ /** */
+ void VoidMethod(int arg);
+
+ /** */
+ void VoidMethod(int arg, string arg1, object arg2 = null);
+
+ /** */
+ void VoidMethod(int arg, string arg1, object arg2 = null, params object[] args);
+
+ /** */
+ object ObjectMethod();
+
+ /** */
+ object ObjectMethod(int arg);
+
+ /** */
+ object ObjectMethod(int arg, string arg1, object arg2 = null);
+
+ /** */
+ object ObjectMethod(int arg, string arg1, object arg2 = null, params object[] args);
+
+ /** */
+ void ExceptionMethod();
+
+ /** */
+ void CustomExceptionMethod();
+
+ /** */
+ void CustomExceptionPortableMethod(bool throwOnWrite, bool throwOnRead);
+
+ /** */
+ TestPortableClass PortableArgMethod(int arg1, IPortableObject arg2);
+
+ /** */
+ IPortableObject PortableResultMethod(int arg1, TestPortableClass arg2);
+
+ /** */
+ IPortableObject PortableArgAndResultMethod(int arg1, IPortableObject arg2);
+
+ /** */
+ void MissingMethod();
+
+ /** */
+ int AmbiguousMethod(int arg);
+ }
+
+ /// <summary>
+ /// Test service.
+ /// </summary>
+ [Serializable]
+ private class TestIgniteService : ITestIgniteService, ITestIgniteServiceAmbiguity
+ {
+ /** */
+ private readonly IPortables _portables;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="TestIgniteService"/> class.
+ /// </summary>
+ /// <param name="portables">The portables.</param>
+ public TestIgniteService(IPortables portables)
+ {
+ _portables = portables;
+ }
+
+ /** <inheritdoc /> */
+ public int IntProp { get; set; }
+
+ /** <inheritdoc /> */
+ public object ObjProp { get; set; }
+
+ /** <inheritdoc /> */
+ public string InvokeResult { get; private set; }
+
+ /** <inheritdoc /> */
+ public void VoidMethod()
+ {
+ InvokeResult = "VoidMethod";
+ }
+
+ /** <inheritdoc /> */
+ public void VoidMethod(int arg)
+ {
+ InvokeResult = "VoidMethod" + arg;
+ }
+
+ /** <inheritdoc /> */
+ public void VoidMethod(int arg, string arg1, object arg2 = null)
+ {
+ InvokeResult = "VoidMethod" + arg + arg1 + arg2;
+ }
+
+ /** <inheritdoc /> */
+ public void VoidMethod(int arg, string arg1, object arg2 = null, params object[] args)
+ {
+ InvokeResult = "VoidMethod" + arg + arg1 + arg2 + string.Concat(args.Select(x => x.ToString()));
+ }
+
+ /** <inheritdoc /> */
+ public object ObjectMethod()
+ {
+ return "ObjectMethod";
+ }
+
+ /** <inheritdoc /> */
+ public object ObjectMethod(int arg)
+ {
+ return "ObjectMethod" + arg;
+ }
+
+ /** <inheritdoc /> */
+ public object ObjectMethod(int arg, string arg1, object arg2 = null)
+ {
+ return "ObjectMethod" + arg + arg1 + arg2;
+ }
+
+ /** <inheritdoc /> */
+ public object ObjectMethod(int arg, string arg1, object arg2 = null, params object[] args)
+ {
+ return "ObjectMethod" + arg + arg1 + arg2 + string.Concat(args.Select(x => x.ToString()));
+ }
+
+ /** <inheritdoc /> */
+ public void ExceptionMethod()
+ {
+ throw new ArithmeticException("Expected exception");
+ }
+
+ /** <inheritdoc /> */
+ public void CustomExceptionMethod()
+ {
+ throw new CustomException();
+ }
+
+ /** <inheritdoc /> */
+ public void CustomExceptionPortableMethod(bool throwOnWrite, bool throwOnRead)
+ {
+ throw new CustomExceptionPortable {ThrowOnRead = throwOnRead, ThrowOnWrite = throwOnWrite};
+ }
+
+ /** <inheritdoc /> */
+ public TestPortableClass PortableArgMethod(int arg1, IPortableObject arg2)
+ {
+ return arg2.Deserialize<TestPortableClass>();
+ }
+
+ /** <inheritdoc /> */
+ public IPortableObject PortableResultMethod(int arg1, TestPortableClass arg2)
+ {
+ return _portables.ToPortable<IPortableObject>(arg2);
+ }
+
+ /** <inheritdoc /> */
+ public IPortableObject PortableArgAndResultMethod(int arg1, IPortableObject arg2)
+ {
+ return _portables.ToPortable<IPortableObject>(arg2.Deserialize<TestPortableClass>());
+ }
+
+ /** <inheritdoc /> */
+ public override string ToString()
+ {
+ return IntProp.ToString();
+ }
+
+ /** <inheritdoc /> */
+ public override int GetHashCode()
+ {
+ return IntProp.GetHashCode();
+ }
+
+ /** <inheritdoc /> */
+ int ITestIgniteService.AmbiguousMethod(int arg)
+ {
+ return arg;
+ }
+
+ /** <inheritdoc /> */
+ int ITestIgniteServiceAmbiguity.AmbiguousMethod(int arg)
+ {
+ return -arg;
+ }
+ }
+
+ /// <summary>
+ /// Test serializable class.
+ /// </summary>
+ [Serializable]
+ private class TestClass
+ {
+ /** */
+ public string Prop { get; set; }
+
+ /** <inheritdoc /> */
+ public override string ToString()
+ {
+ return "TestClass" + Prop;
+ }
+ }
+
+ /// <summary>
+ /// Custom non-serializable exception.
+ /// </summary>
+ private class CustomException : Exception
+ {
+
+ }
+
+ /// <summary>
+ /// Custom non-serializable exception.
+ /// </summary>
+ private class CustomExceptionPortable : Exception, IPortableMarshalAware
+ {
+ /** */
+ public bool ThrowOnWrite { get; set; }
+
+ /** */
+ public bool ThrowOnRead { get; set; }
+
+ /** <inheritdoc /> */
+ public void WritePortable(IPortableWriter writer)
+ {
+ writer.WriteBoolean("ThrowOnRead", ThrowOnRead);
+
+ if (ThrowOnWrite)
+ throw new Exception("Expected exception in CustomExceptionPortable.WritePortable");
+ }
+
+ /** <inheritdoc /> */
+ public void ReadPortable(IPortableReader reader)
+ {
+ ThrowOnRead = reader.ReadBoolean("ThrowOnRead");
+
+ if (ThrowOnRead)
+ throw new Exception("Expected exception in CustomExceptionPortable.ReadPortable");
+ }
+ }
+
+ /// <summary>
+ /// Portable object for method argument/result.
+ /// </summary>
+ protected class TestPortableClass : IPortableMarshalAware
+ {
+ /** */
+ public string Prop { get; set; }
+
+ /** */
+ public bool ThrowOnWrite { get; set; }
+
+ /** */
+ public bool ThrowOnRead { get; set; }
+
+ /** <inheritdoc /> */
+ public void WritePortable(IPortableWriter writer)
+ {
+ writer.WriteString("Prop", Prop);
+ writer.WriteBoolean("ThrowOnRead", ThrowOnRead);
+
+ if (ThrowOnWrite)
+ throw new Exception("Expected exception in TestPortableClass.WritePortable");
+ }
+
+ /** <inheritdoc /> */
+ public void ReadPortable(IPortableReader reader)
+ {
+ Prop = reader.ReadString("Prop");
+ ThrowOnRead = reader.ReadBoolean("ThrowOnRead");
+
+ if (ThrowOnRead)
+ throw new Exception("Expected exception in TestPortableClass.ReadPortable");
+ }
+ }
+ }
+
+ /// <summary>
+ /// Tests <see cref="ServiceProxySerializer"/> functionality with keepPortable mode enabled on client.
+ /// </summary>
+ public class ServiceProxyTestKeepPortableClient : ServiceProxyTest
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ServiceProxyTestKeepPortableClient"/> class.
+ /// </summary>
+ public ServiceProxyTestKeepPortableClient()
+ {
+ KeepPortable = true;
+ }
+
+ [Test]
+ public void TestPortableMethods()
+ {
+ var prx = GetProxy();
+
+ var obj = new TestPortableClass { Prop = "PropValue" };
+
+ var result = prx.PortableResultMethod(1, obj);
+
+ Assert.AreEqual(obj.Prop, result.Deserialize<TestPortableClass>().Prop);
+ }
+ }
+
+ /// <summary>
+ /// Tests <see cref="ServiceProxySerializer"/> functionality with keepPortable mode enabled on server.
+ /// </summary>
+ public class ServiceProxyTestKeepPortableServer : ServiceProxyTest
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ServiceProxyTestKeepPortableServer"/> class.
+ /// </summary>
+ public ServiceProxyTestKeepPortableServer()
+ {
+ SrvKeepPortable = true;
+ }
+
+ [Test]
+ public void TestPortableMethods()
+ {
+ var prx = GetProxy();
+
+ var obj = new TestPortableClass { Prop = "PropValue" };
+ var portObj = Portables.ToPortable<IPortableObject>(obj);
+
+ var result = prx.PortableArgMethod(1, portObj);
+
+ Assert.AreEqual(obj.Prop, result.Prop);
+ }
+ }
+
+ /// <summary>
+ /// Tests <see cref="ServiceProxySerializer"/> functionality with keepPortable mode enabled on client and on server.
+ /// </summary>
+ public class ServiceProxyTestKeepPortableClientServer : ServiceProxyTest
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ServiceProxyTestKeepPortableClientServer"/> class.
+ /// </summary>
+ public ServiceProxyTestKeepPortableClientServer()
+ {
+ KeepPortable = true;
+ SrvKeepPortable = true;
+ }
+
+ [Test]
+ public void TestPortableMethods()
+ {
+ var prx = GetProxy();
+
+ var obj = new TestPortableClass { Prop = "PropValue" };
+ var portObj = Portables.ToPortable<IPortableObject>(obj);
+
+ var result = prx.PortableArgAndResultMethod(1, portObj);
+
+ Assert.AreEqual(obj.Prop, result.Deserialize<TestPortableClass>().Prop);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Services/ServicesAsyncWrapper.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Services/ServicesAsyncWrapper.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Services/ServicesAsyncWrapper.cs
new file mode 100644
index 0000000..ba45dbd
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Services/ServicesAsyncWrapper.cs
@@ -0,0 +1,174 @@
+/*
+ * 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.Services
+{
+ using System.Collections.Generic;
+ using System.Diagnostics;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Services;
+
+ /// <summary>
+ /// Services async wrapper to simplify testing.
+ /// </summary>
+ public class ServicesAsyncWrapper : IServices
+ {
+ /** Wrapped async services. */
+ private readonly IServices _services;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ServicesAsyncWrapper"/> class.
+ /// </summary>
+ /// <param name="services">Services to wrap.</param>
+ public ServicesAsyncWrapper(IServices services)
+ {
+ _services = services.WithAsync();
+ }
+
+ /** <inheritDoc /> */
+ public IServices WithAsync()
+ {
+ return this;
+ }
+
+ /** <inheritDoc /> */
+ public bool IsAsync
+ {
+ get { return true; }
+ }
+
+ /** <inheritDoc /> */
+ public IFuture GetFuture()
+ {
+ Debug.Fail("ServicesAsyncWrapper.Future() should not be called. It always returns null.");
+ return null;
+ }
+
+ /** <inheritDoc /> */
+ public IFuture<TResult> GetFuture<TResult>()
+ {
+ Debug.Fail("ServicesAsyncWrapper.Future() should not be called. It always returns null.");
+ return null;
+ }
+
+ /** <inheritDoc /> */
+ public IClusterGroup ClusterGroup
+ {
+ get { return _services.ClusterGroup; }
+ }
+
+ /** <inheritDoc /> */
+ public void DeployClusterSingleton(string name, IService service)
+ {
+ _services.DeployClusterSingleton(name, service);
+ WaitResult();
+ }
+
+ /** <inheritDoc /> */
+ public void DeployNodeSingleton(string name, IService service)
+ {
+ _services.DeployNodeSingleton(name, service);
+ WaitResult();
+ }
+
+ /** <inheritDoc /> */
+ public void DeployKeyAffinitySingleton<TK>(string name, IService service, string cacheName, TK affinityKey)
+ {
+ _services.DeployKeyAffinitySingleton(name, service, cacheName, affinityKey);
+ WaitResult();
+ }
+
+ /** <inheritDoc /> */
+ public void DeployMultiple(string name, IService service, int totalCount, int maxPerNodeCount)
+ {
+ _services.DeployMultiple(name, service, totalCount, maxPerNodeCount);
+ WaitResult();
+ }
+
+ /** <inheritDoc /> */
+ public void Deploy(ServiceConfiguration configuration)
+ {
+ _services.Deploy(configuration);
+ WaitResult();
+ }
+
+ /** <inheritDoc /> */
+ public void Cancel(string name)
+ {
+ _services.Cancel(name);
+ WaitResult();
+ }
+
+ /** <inheritDoc /> */
+ public void CancelAll()
+ {
+ _services.CancelAll();
+ WaitResult();
+ }
+
+ /** <inheritDoc /> */
+ public ICollection<IServiceDescriptor> GetServiceDescriptors()
+ {
+ return _services.GetServiceDescriptors();
+ }
+
+ /** <inheritDoc /> */
+ public T GetService<T>(string name)
+ {
+ return _services.GetService<T>(name);
+ }
+
+ /** <inheritDoc /> */
+ public ICollection<T> GetServices<T>(string name)
+ {
+ return _services.GetServices<T>(name);
+ }
+
+ /** <inheritDoc /> */
+ public T GetServiceProxy<T>(string name) where T : class
+ {
+ return _services.GetServiceProxy<T>(name);
+ }
+
+ /** <inheritDoc /> */
+ public T GetServiceProxy<T>(string name, bool sticky) where T : class
+ {
+ return _services.GetServiceProxy<T>(name, sticky);
+ }
+
+ /** <inheritDoc /> */
+ public IServices WithKeepPortable()
+ {
+ return new ServicesAsyncWrapper(_services.WithKeepPortable());
+ }
+
+ /** <inheritDoc /> */
+ public IServices WithServerKeepPortable()
+ {
+ return new ServicesAsyncWrapper(_services.WithServerKeepPortable());
+ }
+
+ /// <summary>
+ /// Waits for the async result.
+ /// </summary>
+ private void WaitResult()
+ {
+ _services.GetFuture().Get();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
new file mode 100644
index 0000000..6b2a7ec
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
@@ -0,0 +1,823 @@
+/*
+ * 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.Services
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Portable;
+ using Apache.Ignite.Core.Resource;
+ using Apache.Ignite.Core.Services;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Services tests.
+ /// </summary>
+ public class ServicesTest
+ {
+ /** */
+ private const string SvcName = "Service1";
+
+ /** */
+ private const string CacheName = "cache1";
+
+ /** */
+ private const int AffKey = 25;
+
+ /** */
+ protected IIgnite Grid1;
+
+ /** */
+ protected IIgnite Grid2;
+
+ /** */
+ protected IIgnite Grid3;
+
+ /** */
+ protected IIgnite[] Grids;
+
+ [TestFixtureTearDown]
+ public void FixtureTearDown()
+ {
+ StopGrids();
+ }
+
+ /// <summary>
+ /// Executes before each test.
+ /// </summary>
+ [SetUp]
+ public void SetUp()
+ {
+ StartGrids();
+ EventsTestHelper.ListenResult = true;
+ }
+
+ /// <summary>
+ /// Executes after each test.
+ /// </summary>
+ [TearDown]
+ public void TearDown()
+ {
+ try
+ {
+ Services.Cancel(SvcName);
+
+ TestUtils.AssertHandleRegistryIsEmpty(1000, Grid1, Grid2, Grid3);
+ }
+ catch (Exception)
+ {
+ // Restart grids to cleanup
+ StopGrids();
+
+ throw;
+ }
+ finally
+ {
+ EventsTestHelper.AssertFailures();
+
+ if (TestContext.CurrentContext.Test.Name.StartsWith("TestEventTypes"))
+ StopGrids(); // clean events for other tests
+ }
+ }
+
+ /// <summary>
+ /// Tests deployment.
+ /// </summary>
+ [Test]
+ public void TestDeploy([Values(true, false)] bool portable)
+ {
+ var cfg = new ServiceConfiguration
+ {
+ Name = SvcName,
+ MaxPerNodeCount = 3,
+ TotalCount = 3,
+ NodeFilter = new NodeFilter {NodeId = Grid1.GetCluster().GetLocalNode().Id},
+ Service = portable ? new TestIgniteServicePortable() : new TestIgniteServiceSerializable()
+ };
+
+ Services.Deploy(cfg);
+
+ CheckServiceStarted(Grid1, 3);
+ }
+
+ /// <summary>
+ /// Tests cluster singleton deployment.
+ /// </summary>
+ [Test]
+ public void TestDeployClusterSingleton()
+ {
+ var svc = new TestIgniteServiceSerializable();
+
+ Services.DeployClusterSingleton(SvcName, svc);
+
+ var svc0 = Services.GetServiceProxy<ITestIgniteService>(SvcName);
+
+ // Check that only one node has the service.
+ foreach (var grid in Grids)
+ {
+ if (grid.GetCluster().GetLocalNode().Id == svc0.NodeId)
+ CheckServiceStarted(grid);
+ else
+ Assert.IsNull(grid.GetServices().GetService<TestIgniteServiceSerializable>(SvcName));
+ }
+ }
+
+ /// <summary>
+ /// Tests node singleton deployment.
+ /// </summary>
+ [Test]
+ public void TestDeployNodeSingleton()
+ {
+ var svc = new TestIgniteServiceSerializable();
+
+ Services.DeployNodeSingleton(SvcName, svc);
+
+ Assert.AreEqual(1, Grid1.GetServices().GetServices<ITestIgniteService>(SvcName).Count);
+ Assert.AreEqual(1, Grid2.GetServices().GetServices<ITestIgniteService>(SvcName).Count);
+ Assert.AreEqual(1, Grid3.GetServices().GetServices<ITestIgniteService>(SvcName).Count);
+ }
+
+ /// <summary>
+ /// Tests key affinity singleton deployment.
+ /// </summary>
+ [Test]
+ public void TestDeployKeyAffinitySingleton()
+ {
+ var svc = new TestIgniteServicePortable();
+
+ Services.DeployKeyAffinitySingleton(SvcName, svc, CacheName, AffKey);
+
+ var affNode = Grid1.GetAffinity(CacheName).MapKeyToNode(AffKey);
+
+ var prx = Services.GetServiceProxy<ITestIgniteService>(SvcName);
+
+ Assert.AreEqual(affNode.Id, prx.NodeId);
+ }
+
+ /// <summary>
+ /// Tests key affinity singleton deployment.
+ /// </summary>
+ [Test]
+ public void TestDeployKeyAffinitySingletonPortable()
+ {
+ var services = Services.WithKeepPortable();
+
+ var svc = new TestIgniteServicePortable();
+
+ var affKey = new PortableObject {Val = AffKey};
+
+ services.DeployKeyAffinitySingleton(SvcName, svc, CacheName, affKey);
+
+ var prx = services.GetServiceProxy<ITestIgniteService>(SvcName);
+
+ Assert.IsTrue(prx.Initialized);
+ }
+
+ /// <summary>
+ /// Tests multiple deployment.
+ /// </summary>
+ [Test]
+ public void TestDeployMultiple()
+ {
+ var svc = new TestIgniteServiceSerializable();
+
+ Services.DeployMultiple(SvcName, svc, Grids.Length * 5, 5);
+
+ foreach (var grid in Grids)
+ CheckServiceStarted(grid, 5);
+ }
+
+ /// <summary>
+ /// Tests cancellation.
+ /// </summary>
+ [Test]
+ public void TestCancel()
+ {
+ for (var i = 0; i < 10; i++)
+ {
+ Services.DeployNodeSingleton(SvcName + i, new TestIgniteServicePortable());
+ Assert.IsNotNull(Services.GetService<ITestIgniteService>(SvcName + i));
+ }
+
+ Services.Cancel(SvcName + 0);
+ Services.Cancel(SvcName + 1);
+
+ Assert.IsNull(Services.GetService<ITestIgniteService>(SvcName + 0));
+ Assert.IsNull(Services.GetService<ITestIgniteService>(SvcName + 1));
+
+ for (var i = 2; i < 10; i++)
+ Assert.IsNotNull(Services.GetService<ITestIgniteService>(SvcName + i));
+
+ Services.CancelAll();
+
+ for (var i = 0; i < 10; i++)
+ Assert.IsNull(Services.GetService<ITestIgniteService>(SvcName + i));
+ }
+
+ /// <summary>
+ /// Tests service proxy.
+ /// </summary>
+ [Test]
+ public void TestGetServiceProxy([Values(true, false)] bool portable)
+ {
+ // Test proxy without a service
+ var prx = Services.GetServiceProxy<ITestIgniteService>(SvcName);
+
+ Assert.IsTrue(prx != null);
+
+ var ex = Assert.Throws<ServiceInvocationException>(() => Assert.IsTrue(prx.Initialized)).InnerException;
+ Assert.AreEqual("Failed to find deployed service: " + SvcName, ex.Message);
+
+ // Deploy to grid2 & grid3
+ var svc = portable
+ ? new TestIgniteServicePortable {TestProperty = 17}
+ : new TestIgniteServiceSerializable {TestProperty = 17};
+
+ Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id, Grid3.GetCluster().GetLocalNode().Id).GetServices()
+ .DeployNodeSingleton(SvcName,
+ svc);
+
+ // Make sure there is no local instance on grid1
+ Assert.IsNull(Services.GetService<ITestIgniteService>(SvcName));
+
+ // Get proxy
+ prx = Services.GetServiceProxy<ITestIgniteService>(SvcName);
+
+ // Check proxy properties
+ Assert.IsNotNull(prx);
+ Assert.AreEqual(prx.GetType(), svc.GetType());
+ Assert.AreEqual(prx.ToString(), svc.ToString());
+ Assert.AreEqual(17, prx.TestProperty);
+ Assert.IsTrue(prx.Initialized);
+ Assert.IsTrue(prx.Executed);
+ Assert.IsFalse(prx.Cancelled);
+ Assert.AreEqual(SvcName, prx.LastCallContextName);
+
+ // Check err method
+ Assert.Throws<ServiceInvocationException>(() => prx.ErrMethod(123));
+
+ // Check local scenario (proxy should not be created for local instance)
+ Assert.IsTrue(ReferenceEquals(Grid2.GetServices().GetService<ITestIgniteService>(SvcName),
+ Grid2.GetServices().GetServiceProxy<ITestIgniteService>(SvcName)));
+
+ // Check sticky = false: call multiple times, check that different nodes get invoked
+ var invokedIds = Enumerable.Range(1, 100).Select(x => prx.NodeId).Distinct().ToList();
+ Assert.AreEqual(2, invokedIds.Count);
+
+ // Check sticky = true: all calls should be to the same node
+ prx = Services.GetServiceProxy<ITestIgniteService>(SvcName, true);
+ invokedIds = Enumerable.Range(1, 100).Select(x => prx.NodeId).Distinct().ToList();
+ Assert.AreEqual(1, invokedIds.Count);
+
+ // Proxy does not work for cancelled service.
+ Services.CancelAll();
+
+ Assert.Throws<ServiceInvocationException>(() => { Assert.IsTrue(prx.Cancelled); });
+ }
+
+ /// <summary>
+ /// Tests the duck typing: proxy interface can be different from actual service interface,
+ /// only called method signature should be compatible.
+ /// </summary>
+ [Test]
+ public void TestDuckTyping([Values(true, false)] bool local)
+ {
+ var svc = new TestIgniteServicePortable {TestProperty = 33};
+
+ // Deploy locally or to the remote node
+ var nodeId = (local ? Grid1 : Grid2).GetCluster().GetLocalNode().Id;
+
+ var cluster = Grid1.GetCluster().ForNodeIds(nodeId);
+
+ cluster.GetServices().DeployNodeSingleton(SvcName, svc);
+
+ // Get proxy
+ var prx = Services.GetServiceProxy<ITestIgniteServiceProxyInterface>(SvcName);
+
+ // NodeId signature is the same as in service
+ Assert.AreEqual(nodeId, prx.NodeId);
+
+ // Method signature is different from service signature (object -> object), but is compatible.
+ Assert.AreEqual(15, prx.Method(15));
+
+ // TestProperty is object in proxy and int in service, getter works..
+ Assert.AreEqual(33, prx.TestProperty);
+
+ // .. but setter does not
+ var ex = Assert.Throws<ServiceInvocationException>(() => { prx.TestProperty = new object(); });
+ Assert.AreEqual("Object of type 'System.Object' cannot be converted to type 'System.Int32'.",
+ ex.InnerException.Message);
+ }
+
+ /// <summary>
+ /// Tests service descriptors.
+ /// </summary>
+ [Test]
+ public void TestServiceDescriptors()
+ {
+ Services.DeployKeyAffinitySingleton(SvcName, new TestIgniteServiceSerializable(), CacheName, 1);
+
+ var descriptors = Services.GetServiceDescriptors();
+
+ Assert.AreEqual(1, descriptors.Count);
+
+ var desc = descriptors.Single();
+
+ Assert.AreEqual(SvcName, desc.Name);
+ Assert.AreEqual(CacheName, desc.CacheName);
+ Assert.AreEqual(1, desc.AffinityKey);
+ Assert.AreEqual(1, desc.MaxPerNodeCount);
+ Assert.AreEqual(1, desc.TotalCount);
+ Assert.AreEqual(typeof(TestIgniteServiceSerializable), desc.Type);
+ Assert.AreEqual(Grid1.GetCluster().GetLocalNode().Id, desc.OriginNodeId);
+
+ var top = desc.TopologySnapshot;
+ var prx = Services.GetServiceProxy<ITestIgniteService>(SvcName);
+
+ Assert.AreEqual(1, top.Count);
+ Assert.AreEqual(prx.NodeId, top.Keys.Single());
+ Assert.AreEqual(1, top.Values.Single());
+ }
+
+ /// <summary>
+ /// Tests the client portable flag.
+ /// </summary>
+ [Test]
+ public void TestWithKeepPortableClient()
+ {
+ var svc = new TestIgniteServicePortable();
+
+ // Deploy to grid2
+ Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id).GetServices().WithKeepPortable()
+ .DeployNodeSingleton(SvcName, svc);
+
+ // Get proxy
+ var prx = Services.WithKeepPortable().GetServiceProxy<ITestIgniteService>(SvcName);
+
+ var obj = new PortableObject {Val = 11};
+
+ var res = (IPortableObject) prx.Method(obj);
+ Assert.AreEqual(11, res.Deserialize<PortableObject>().Val);
+
+ res = (IPortableObject) prx.Method(Grid1.GetPortables().ToPortable<IPortableObject>(obj));
+ Assert.AreEqual(11, res.Deserialize<PortableObject>().Val);
+ }
+
+ /// <summary>
+ /// Tests the server portable flag.
+ /// </summary>
+ [Test]
+ public void TestWithKeepPortableServer()
+ {
+ var svc = new TestIgniteServicePortable();
+
+ // Deploy to grid2
+ Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id).GetServices().WithServerKeepPortable()
+ .DeployNodeSingleton(SvcName, svc);
+
+ // Get proxy
+ var prx = Services.WithServerKeepPortable().GetServiceProxy<ITestIgniteService>(SvcName);
+
+ var obj = new PortableObject { Val = 11 };
+
+ var res = (PortableObject) prx.Method(obj);
+ Assert.AreEqual(11, res.Val);
+
+ res = (PortableObject)prx.Method(Grid1.GetPortables().ToPortable<IPortableObject>(obj));
+ Assert.AreEqual(11, res.Val);
+ }
+
+ /// <summary>
+ /// Tests server and client portable flag.
+ /// </summary>
+ [Test]
+ public void TestWithKeepPortableBoth()
+ {
+ var svc = new TestIgniteServicePortable();
+
+ // Deploy to grid2
+ Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id).GetServices().WithKeepPortable().WithServerKeepPortable()
+ .DeployNodeSingleton(SvcName, svc);
+
+ // Get proxy
+ var prx = Services.WithKeepPortable().WithServerKeepPortable().GetServiceProxy<ITestIgniteService>(SvcName);
+
+ var obj = new PortableObject { Val = 11 };
+
+ var res = (IPortableObject)prx.Method(obj);
+ Assert.AreEqual(11, res.Deserialize<PortableObject>().Val);
+
+ res = (IPortableObject)prx.Method(Grid1.GetPortables().ToPortable<IPortableObject>(obj));
+ Assert.AreEqual(11, res.Deserialize<PortableObject>().Val);
+ }
+
+ /// <summary>
+ /// Tests exception in Initialize.
+ /// </summary>
+ [Test]
+ public void TestInitException()
+ {
+ var svc = new TestIgniteServiceSerializable { ThrowInit = true };
+
+ var ex = Assert.Throws<IgniteException>(() => Services.DeployMultiple(SvcName, svc, Grids.Length, 1));
+ Assert.AreEqual("Expected exception", ex.Message);
+
+ var svc0 = Services.GetService<TestIgniteServiceSerializable>(SvcName);
+
+ Assert.IsNull(svc0);
+ }
+
+ /// <summary>
+ /// Tests exception in Execute.
+ /// </summary>
+ [Test]
+ public void TestExecuteException()
+ {
+ var svc = new TestIgniteServiceSerializable { ThrowExecute = true };
+
+ Services.DeployMultiple(SvcName, svc, Grids.Length, 1);
+
+ var svc0 = Services.GetService<TestIgniteServiceSerializable>(SvcName);
+
+ // Execution failed, but service exists.
+ Assert.IsNotNull(svc0);
+ Assert.IsFalse(svc0.Executed);
+ }
+
+ /// <summary>
+ /// Tests exception in Cancel.
+ /// </summary>
+ [Test]
+ public void TestCancelException()
+ {
+ var svc = new TestIgniteServiceSerializable { ThrowCancel = true };
+
+ Services.DeployMultiple(SvcName, svc, Grids.Length, 1);
+
+ CheckServiceStarted(Grid1);
+
+ Services.CancelAll();
+
+ // Cancellation failed, but service is removed.
+ foreach (var grid in Grids)
+ Assert.IsNull(grid.GetServices().GetService<ITestIgniteService>(SvcName));
+ }
+
+ [Test]
+ public void TestMarshalExceptionOnRead()
+ {
+ var svc = new TestIgniteServicePortableErr();
+
+ var ex = Assert.Throws<IgniteException>(() => Services.DeployMultiple(SvcName, svc, Grids.Length, 1));
+ Assert.AreEqual("Expected exception", ex.Message);
+
+ var svc0 = Services.GetService<TestIgniteServiceSerializable>(SvcName);
+
+ Assert.IsNull(svc0);
+ }
+
+ [Test]
+ public void TestMarshalExceptionOnWrite()
+ {
+ var svc = new TestIgniteServicePortableErr {ThrowOnWrite = true};
+
+ var ex = Assert.Throws<Exception>(() => Services.DeployMultiple(SvcName, svc, Grids.Length, 1));
+ Assert.AreEqual("Expected exception", ex.Message);
+
+ var svc0 = Services.GetService<TestIgniteServiceSerializable>(SvcName);
+
+ Assert.IsNull(svc0);
+ }
+
+ /// <summary>
+ /// Starts the grids.
+ /// </summary>
+ private void StartGrids()
+ {
+ if (Grid1 != null)
+ return;
+
+ Grid1 = Ignition.Start(Configuration("config\\compute\\compute-grid1.xml"));
+ Grid2 = Ignition.Start(Configuration("config\\compute\\compute-grid2.xml"));
+ Grid3 = Ignition.Start(Configuration("config\\compute\\compute-grid3.xml"));
+
+ Grids = new[] { Grid1, Grid2, Grid3 };
+ }
+
+ /// <summary>
+ /// Stops the grids.
+ /// </summary>
+ private void StopGrids()
+ {
+ Grid1 = Grid2 = Grid3 = null;
+ Grids = null;
+
+ Ignition.StopAll(true);
+ }
+
+ /// <summary>
+ /// Checks that service has started on specified grid.
+ /// </summary>
+ private static void CheckServiceStarted(IIgnite grid, int count = 1)
+ {
+ var services = grid.GetServices().GetServices<TestIgniteServiceSerializable>(SvcName);
+
+ Assert.AreEqual(count, services.Count);
+
+ var svc = services.First();
+
+ Assert.IsNotNull(svc);
+
+ Assert.IsTrue(svc.Initialized);
+
+ Thread.Sleep(100); // Service runs in a separate thread, wait for it to execute.
+
+ Assert.IsTrue(svc.Executed);
+ Assert.IsFalse(svc.Cancelled);
+
+ Assert.AreEqual(grid.GetCluster().GetLocalNode().Id, svc.NodeId);
+ }
+
+ /// <summary>
+ /// Gets the Ignite configuration.
+ /// </summary>
+ private static IgniteConfiguration Configuration(string springConfigUrl)
+ {
+ return new IgniteConfiguration
+ {
+ SpringConfigUrl = springConfigUrl,
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = TestUtils.TestJavaOptions(),
+ PortableConfiguration = new PortableConfiguration
+ {
+ TypeConfigurations = new List<PortableTypeConfiguration>
+ {
+ new PortableTypeConfiguration(typeof(TestIgniteServicePortable)),
+ new PortableTypeConfiguration(typeof(TestIgniteServicePortableErr)),
+ new PortableTypeConfiguration(typeof(PortableObject))
+ }
+ }
+ };
+ }
+
+ /// <summary>
+ /// Gets the services.
+ /// </summary>
+ protected virtual IServices Services
+ {
+ get { return Grid1.GetServices(); }
+ }
+
+ /// <summary>
+ /// Test service interface for proxying.
+ /// </summary>
+ private interface ITestIgniteService
+ {
+ int TestProperty { get; set; }
+
+ /** */
+ bool Initialized { get; }
+
+ /** */
+ bool Cancelled { get; }
+
+ /** */
+ bool Executed { get; }
+
+ /** */
+ Guid NodeId { get; }
+
+ /** */
+ string LastCallContextName { get; }
+
+ /** */
+ object Method(object arg);
+
+ /** */
+ object ErrMethod(object arg);
+ }
+
+ /// <summary>
+ /// Test service interface for proxy usage.
+ /// Has some of the original interface members with different signatures.
+ /// </summary>
+ private interface ITestIgniteServiceProxyInterface
+ {
+ /** */
+ Guid NodeId { get; }
+
+ /** */
+ object TestProperty { get; set; }
+
+ /** */
+ int Method(int arg);
+ }
+
+ #pragma warning disable 649
+
+ /// <summary>
+ /// Test serializable service.
+ /// </summary>
+ [Serializable]
+ private class TestIgniteServiceSerializable : IService, ITestIgniteService
+ {
+ /** */
+ [InstanceResource]
+ private IIgnite _grid;
+
+ /** <inheritdoc /> */
+ public int TestProperty { get; set; }
+
+ /** <inheritdoc /> */
+ public bool Initialized { get; private set; }
+
+ /** <inheritdoc /> */
+ public bool Cancelled { get; private set; }
+
+ /** <inheritdoc /> */
+ public bool Executed { get; private set; }
+
+ /** <inheritdoc /> */
+ public Guid NodeId
+ {
+ get { return _grid.GetCluster().GetLocalNode().Id; }
+ }
+
+ /** <inheritdoc /> */
+ public string LastCallContextName { get; private set; }
+
+ /** */
+ public bool ThrowInit { get; set; }
+
+ /** */
+ public bool ThrowExecute { get; set; }
+
+ /** */
+ public bool ThrowCancel { get; set; }
+
+ /** */
+ public object Method(object arg)
+ {
+ return arg;
+ }
+
+ /** */
+ public object ErrMethod(object arg)
+ {
+ throw new ArgumentNullException("arg", "ExpectedException");
+ }
+
+ /** <inheritdoc /> */
+ public void Init(IServiceContext context)
+ {
+ if (ThrowInit)
+ throw new Exception("Expected exception");
+
+ CheckContext(context);
+
+ Assert.IsFalse(context.IsCancelled);
+ Initialized = true;
+ }
+
+ /** <inheritdoc /> */
+ public void Execute(IServiceContext context)
+ {
+ if (ThrowExecute)
+ throw new Exception("Expected exception");
+
+ CheckContext(context);
+
+ Assert.IsFalse(context.IsCancelled);
+ Assert.IsTrue(Initialized);
+ Assert.IsFalse(Cancelled);
+
+ Executed = true;
+ }
+
+ /** <inheritdoc /> */
+ public void Cancel(IServiceContext context)
+ {
+ if (ThrowCancel)
+ throw new Exception("Expected exception");
+
+ CheckContext(context);
+
+ Assert.IsTrue(context.IsCancelled);
+
+ Cancelled = true;
+ }
+
+ /// <summary>
+ /// Checks the service context.
+ /// </summary>
+ private void CheckContext(IServiceContext context)
+ {
+ LastCallContextName = context.Name;
+
+ if (context.AffinityKey != null && !(context.AffinityKey is int))
+ {
+ var portableObject = context.AffinityKey as IPortableObject;
+
+ var key = portableObject != null
+ ? portableObject.Deserialize<PortableObject>()
+ : (PortableObject) context.AffinityKey;
+
+ Assert.AreEqual(AffKey, key.Val);
+ }
+
+ Assert.IsNotNull(_grid);
+
+ Assert.IsTrue(context.Name.StartsWith(SvcName));
+ Assert.AreNotEqual(Guid.Empty, context.ExecutionId);
+ }
+ }
+
+ /// <summary>
+ /// Test portable service.
+ /// </summary>
+ private class TestIgniteServicePortable : TestIgniteServiceSerializable, IPortableMarshalAware
+ {
+ /** <inheritdoc /> */
+ public void WritePortable(IPortableWriter writer)
+ {
+ writer.WriteInt("TestProp", TestProperty);
+ }
+
+ /** <inheritdoc /> */
+ public void ReadPortable(IPortableReader reader)
+ {
+ TestProperty = reader.ReadInt("TestProp");
+ }
+ }
+
+ /// <summary>
+ /// Test portable service with exceptions in marshalling.
+ /// </summary>
+ private class TestIgniteServicePortableErr : TestIgniteServiceSerializable, IPortableMarshalAware
+ {
+ /** */
+ public bool ThrowOnWrite { get; set; }
+
+ /** <inheritdoc /> */
+ public void WritePortable(IPortableWriter writer)
+ {
+ writer.WriteInt("TestProp", TestProperty);
+
+ if (ThrowOnWrite)
+ throw new Exception("Expected exception");
+ }
+
+ /** <inheritdoc /> */
+ public void ReadPortable(IPortableReader reader)
+ {
+ TestProperty = reader.ReadInt("TestProp");
+
+ throw new Exception("Expected exception");
+ }
+ }
+
+ /// <summary>
+ /// Test node filter.
+ /// </summary>
+ [Serializable]
+ private class NodeFilter : IClusterNodeFilter
+ {
+ /// <summary>
+ /// Gets or sets the node identifier.
+ /// </summary>
+ public Guid NodeId { get; set; }
+
+ /** <inheritdoc /> */
+ public bool Invoke(IClusterNode node)
+ {
+ return node.Id == NodeId;
+ }
+ }
+
+ /// <summary>
+ /// Portable object.
+ /// </summary>
+ private class PortableObject
+ {
+ public int Val { get; set; }
+ }
+ }
+}
[19/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
deleted file mode 100644
index e46ec64..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Compute
-{
- using System;
- using System.Collections.Generic;
- using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Compute;
- using Apache.Ignite.Core.Portable;
- using Apache.Ignite.Core.Resource;
- using NUnit.Framework;
-
- /// <summary>
- /// Test for task and job adapter.
- /// </summary>
- public class FailoverTaskSelfTest : AbstractTaskTest
- {
- /** */
- static volatile string _gridName;
-
- /** */
- static volatile int _cnt;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- public FailoverTaskSelfTest() : base(false) { }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="fork">Fork flag.</param>
- protected FailoverTaskSelfTest(bool fork) : base(fork) { }
-
- /// <summary>
- /// Test for GridComputeJobFailoverException.
- /// </summary>
- [Test]
- public void TestClosureFailoverException()
- {
- for (int i = 0; i < 20; i++)
- {
- int res = Grid1.GetCompute().Call(new TestClosure());
-
- Assert.AreEqual(2, res);
-
- Cleanup();
- }
- }
-
- /// <summary>
- /// Test for GridComputeJobFailoverException with serializable job.
- /// </summary>
- [Test]
- public void TestTaskAdapterFailoverExceptionSerializable()
- {
- TestTaskAdapterFailoverException(true);
- }
-
- /// <summary>
- /// Test for GridComputeJobFailoverException with portable job.
- /// </summary>
- [Test]
- public void TestTaskAdapterFailoverExceptionPortable()
- {
- TestTaskAdapterFailoverException(false);
- }
-
- /// <summary>
- /// Test for GridComputeJobFailoverException.
- /// </summary>
- private void TestTaskAdapterFailoverException(bool serializable)
- {
- int res = Grid1.GetCompute().Execute(new TestTask(),
- new Tuple<bool, bool>(serializable, true));
-
- Assert.AreEqual(2, res);
-
- Cleanup();
-
- res = Grid1.GetCompute().Execute(new TestTask(),
- new Tuple<bool, bool>(serializable, false));
-
- Assert.AreEqual(2, res);
- }
-
- /// <summary>
- /// Cleanup.
- /// </summary>
- [TearDown]
- public void Cleanup()
- {
- _cnt = 0;
-
- _gridName = null;
- }
-
- /** <inheritDoc /> */
- override protected void PortableTypeConfigurations(ICollection<PortableTypeConfiguration> portTypeCfgs)
- {
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(TestPortableJob)));
- }
-
- /// <summary>
- /// Test task.
- /// </summary>
- public class TestTask : ComputeTaskAdapter<Tuple<bool, bool>, int, int>
- {
- /** <inheritDoc /> */
- override public IDictionary<IComputeJob<int>, IClusterNode> Map(IList<IClusterNode> subgrid, Tuple<bool, bool> arg)
- {
- Assert.AreEqual(3, subgrid.Count);
-
- Tuple<bool, bool> t = arg;
-
- bool serializable = t.Item1;
- bool local = t.Item2;
-
- IDictionary<IComputeJob<int>, IClusterNode> jobs = new Dictionary<IComputeJob<int>, IClusterNode>();
-
- IComputeJob<int> job;
-
- if (serializable)
- job = new TestSerializableJob();
- else
- job = new TestPortableJob();
-
- foreach (IClusterNode node in subgrid) {
- bool add = local ? node.IsLocal : !node.IsLocal;
-
- if (add)
- {
- jobs.Add(job, node);
-
- break;
- }
- }
-
- Assert.AreEqual(1, jobs.Count);
-
- return jobs;
- }
-
- /** <inheritDoc /> */
- override public int Reduce(IList<IComputeJobResult<int>> results)
- {
- Assert.AreEqual(1, results.Count);
-
- return results[0].Data();
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- [Serializable]
- class TestClosure : IComputeFunc<int>
- {
- [InstanceResource]
- private IIgnite _grid = null;
-
- /** <inheritDoc /> */
- public int Invoke()
- {
- return FailoverJob(_grid);
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- [Serializable]
- class TestSerializableJob : IComputeJob<int>
- {
- [InstanceResource]
- private IIgnite _grid = null;
-
- /** <inheritDoc /> */
- public int Execute()
- {
- return FailoverJob(_grid);
- }
-
- /** <inheritDoc /> */
- public void Cancel()
- {
- // No-op.
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- class TestPortableJob : IComputeJob<int>
- {
- [InstanceResource]
- private IIgnite _grid = null;
-
- /** <inheritDoc /> */
- public int Execute()
- {
- return FailoverJob(_grid);
- }
-
- public void Cancel()
- {
- // No-op.
- }
- }
-
- /// <summary>
- /// Throws GridComputeJobFailoverException on first call.
- /// </summary>
- private static int FailoverJob(IIgnite grid)
- {
- Assert.NotNull(grid);
-
- _cnt++;
-
- if (_gridName == null)
- {
- _gridName = grid.Name;
-
- throw new ComputeJobFailoverException("Test error.");
- }
- Assert.AreNotEqual(_gridName, grid.Name);
-
- return _cnt;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedPortableClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedPortableClosureTaskTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedPortableClosureTaskTest.cs
deleted file mode 100644
index 4ce917b..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedPortableClosureTaskTest.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Compute.Forked
-{
- /// <summary>
- /// Forked closure execution tests for portable objects.
- /// </summary>
- public class ForkedPortableClosureTaskTest : PortableClosureTaskTest
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- public ForkedPortableClosureTaskTest() : base(true) { }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedResourceTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedResourceTaskTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedResourceTaskTest.cs
deleted file mode 100644
index 84c1ba2..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedResourceTaskTest.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Compute.Forked
-{
- using NUnit.Framework;
-
- /// <summary>
- /// Forked resource task test.
- /// </summary>
- [Ignore("IGNITE-1381")]
- public class ForkedResourceTaskTest : ResourceTaskTest
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- public ForkedResourceTaskTest() : base(true) { }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedSerializableClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedSerializableClosureTaskTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedSerializableClosureTaskTest.cs
deleted file mode 100644
index 0324125..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedSerializableClosureTaskTest.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Compute.Forked
-{
- using NUnit.Framework;
-
- /// <summary>
- /// Forked closure execution tests for serializable objects.
- /// </summary>
- [Ignore("IGNITE-1381")]
- public class ForkedSerializableClosureTaskTest : SerializableClosureTaskTest
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- public ForkedSerializableClosureTaskTest() : base(true) { }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedTaskAdapterTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedTaskAdapterTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedTaskAdapterTest.cs
deleted file mode 100644
index a4cf182..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedTaskAdapterTest.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Compute.Forked
-{
- /// <summary>
- /// Forked task adapter test.
- /// </summary>
- public class ForkedTaskAdapterTest : TaskAdapterTest
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- public ForkedTaskAdapterTest() : base(true) { }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
deleted file mode 100644
index 62f860d..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
+++ /dev/null
@@ -1,753 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Compute
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.Serialization;
- using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Compute;
- using Apache.Ignite.Core.Resource;
- using NUnit.Framework;
-
- /// <summary>
- /// Tests for exception handling on various task execution stages.
- /// </summary>
- public class IgniteExceptionTaskSelfTest : AbstractTaskTest
- {
- /** Error mode. */
- public static ErrorMode Mode;
-
- /** Observed job errors. */
- public static readonly ICollection<Exception> JobErrs = new List<Exception>();
-
- /// <summary>
- /// Constructor.
- /// </summary>
- public IgniteExceptionTaskSelfTest() : base(false) { }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="fork">Fork flag.</param>
- protected IgniteExceptionTaskSelfTest(bool fork) : base(fork) { }
-
- /// <summary>
- /// Test error occurred during map step.
- /// </summary>
- [Test]
- public void TestMapError()
- {
- Mode = ErrorMode.MapErr;
-
- GoodException e = ExecuteWithError() as GoodException;
-
- Assert.IsNotNull(e);
-
- Assert.AreEqual(ErrorMode.MapErr, e.Mode);
- }
-
- /// <summary>
- /// Test not-marshalable error occurred during map step.
- /// </summary>
- [Test]
- public void TestMapNotMarshalableError()
- {
- Mode = ErrorMode.MapErrNotMarshalable;
-
- BadException e = ExecuteWithError() as BadException;
-
- Assert.IsNotNull(e);
-
- Assert.AreEqual(ErrorMode.MapErrNotMarshalable, e.Mode);
- }
-
- /// <summary>
- /// Test task behavior when job produced by mapper is not marshalable.
- /// </summary>
- [Test]
- public void TestMapNotMarshalableJob()
- {
- Mode = ErrorMode.MapJobNotMarshalable;
-
- SerializationException e = ExecuteWithError() as SerializationException;
-
- Assert.IsNotNull(e);
- }
-
- /// <summary>
- /// Test local job error.
- /// </summary>
- [Test]
- public void TestLocalJobError()
- {
- Mode = ErrorMode.LocJobErr;
-
- int res = Execute();
-
- Assert.AreEqual(2, res);
-
- Assert.AreEqual(1, JobErrs.Count);
- Assert.IsNotNull(JobErrs.First() as GoodException);
- Assert.AreEqual(ErrorMode.LocJobErr, ((GoodException) JobErrs.First()).Mode);
- }
-
- /// <summary>
- /// Test local not-marshalable job error.
- /// </summary>
- [Test]
- public void TestLocalJobErrorNotMarshalable()
- {
- Mode = ErrorMode.LocJobErrNotMarshalable;
-
- int res = Execute();
-
- Assert.AreEqual(2, res);
-
- Assert.AreEqual(1, JobErrs.Count);
- Assert.IsNotNull(JobErrs.First() as BadException); // Local job exception is not marshalled.
- }
-
- /// <summary>
- /// Test local not-marshalable job result.
- /// </summary>
- [Test]
- public void TestLocalJobResultNotMarshalable()
- {
- Mode = ErrorMode.LocJobResNotMarshalable;
-
- int res = Execute();
-
- Assert.AreEqual(3, res); // Local job result is not marshalled.
-
- Assert.AreEqual(0, JobErrs.Count);
- }
-
- /// <summary>
- /// Test remote job error.
- /// </summary>
- [Test]
- public void TestRemoteJobError()
- {
- Mode = ErrorMode.RmtJobErr;
-
- int res = Execute();
-
- Assert.AreEqual(1, res);
-
- Assert.AreEqual(2, JobErrs.Count);
-
- Assert.IsNotNull(JobErrs.ElementAt(0) as GoodException);
- Assert.IsNotNull(JobErrs.ElementAt(1) as GoodException);
-
- Assert.AreEqual(ErrorMode.RmtJobErr, ((GoodException) JobErrs.ElementAt(0)).Mode);
- Assert.AreEqual(ErrorMode.RmtJobErr, ((GoodException) JobErrs.ElementAt(1)).Mode);
- }
-
- /// <summary>
- /// Test remote not-marshalable job error.
- /// </summary>
- [Test]
- public void TestRemoteJobErrorNotMarshalable()
- {
- Mode = ErrorMode.RmtJobErrNotMarshalable;
-
- int res = Execute();
-
- Assert.AreEqual(1, res);
-
- Assert.AreEqual(2, JobErrs.Count);
-
- Assert.IsNotNull(JobErrs.ElementAt(0) as IgniteException);
- Assert.IsNotNull(JobErrs.ElementAt(1) as IgniteException);
- }
-
- /// <summary>
- /// Test local not-marshalable job result.
- /// </summary>
- [Test]
- public void TestRemoteJobResultNotMarshalable()
- {
- Mode = ErrorMode.RmtJobResNotMarshalable;
-
- int res = Execute();
-
- Assert.AreEqual(1, res);
-
- Assert.AreEqual(2, JobErrs.Count);
-
- Assert.IsNotNull(JobErrs.ElementAt(0) as IgniteException);
- Assert.IsNotNull(JobErrs.ElementAt(1) as IgniteException);
- }
-
- /// <summary>
- /// Test local result error.
- /// </summary>
- [Test]
- public void TestLocalResultError()
- {
- Mode = ErrorMode.LocResErr;
-
- GoodException e = ExecuteWithError() as GoodException;
-
- Assert.IsNotNull(e);
-
- Assert.AreEqual(ErrorMode.LocResErr, e.Mode);
- }
-
- /// <summary>
- /// Test local result not-marshalable error.
- /// </summary>
- [Test]
- public void TestLocalResultErrorNotMarshalable()
- {
- Mode = ErrorMode.LocResErrNotMarshalable;
-
- BadException e = ExecuteWithError() as BadException;
-
- Assert.IsNotNull(e);
-
- Assert.AreEqual(ErrorMode.LocResErrNotMarshalable, e.Mode);
- }
-
- /// <summary>
- /// Test remote result error.
- /// </summary>
- [Test]
- public void TestRemoteResultError()
- {
- Mode = ErrorMode.RmtResErr;
-
- GoodException e = ExecuteWithError() as GoodException;
-
- Assert.IsNotNull(e);
-
- Assert.AreEqual(ErrorMode.RmtResErr, e.Mode);
- }
-
- /// <summary>
- /// Test remote result not-marshalable error.
- /// </summary>
- [Test]
- public void TestRemoteResultErrorNotMarshalable()
- {
- Mode = ErrorMode.RmtResErrNotMarshalable;
-
- BadException e = ExecuteWithError() as BadException;
-
- Assert.IsNotNull(e);
-
- Assert.AreEqual(ErrorMode.RmtResErrNotMarshalable, e.Mode);
- }
-
- /// <summary>
- /// Test reduce with error.
- /// </summary>
- [Test]
- public void TestReduceError()
- {
- Mode = ErrorMode.ReduceErr;
-
- GoodException e = ExecuteWithError() as GoodException;
-
- Assert.IsNotNull(e);
-
- Assert.AreEqual(ErrorMode.ReduceErr, e.Mode);
- }
-
- /// <summary>
- /// Test reduce with not-marshalable error.
- /// </summary>
- [Test]
- public void TestReduceErrorNotMarshalable()
- {
- Mode = ErrorMode.ReduceErrNotMarshalable;
-
- BadException e = ExecuteWithError() as BadException;
-
- Assert.IsNotNull(e);
-
- Assert.AreEqual(ErrorMode.ReduceErrNotMarshalable, e.Mode);
- }
-
- /// <summary>
- /// Test reduce with not-marshalable result.
- /// </summary>
- [Test]
- public void TestReduceResultNotMarshalable()
- {
- Mode = ErrorMode.ReduceResNotMarshalable;
-
- int res = Execute();
-
- Assert.AreEqual(3, res);
- }
-
- /// <summary>
- /// Execute task successfully.
- /// </summary>
- /// <returns>Task result.</returns>
- private int Execute()
- {
- JobErrs.Clear();
-
- object res = Grid1.GetCompute().Execute(new Task());
-
- return res is GoodTaskResult ? ((GoodTaskResult)res).Res : ((BadTaskResult)res).Res;
- }
-
- /// <summary>
- /// Execute task with error.
- /// </summary>
- /// <returns>Task</returns>
- private Exception ExecuteWithError()
- {
- JobErrs.Clear();
-
- Exception err = null;
-
- try
- {
- Grid1.GetCompute().Execute(new Task());
-
- Assert.Fail();
- }
- catch (Exception e)
- {
- err = e;
- }
-
- return err;
- }
-
- /// <summary>
- /// Error modes.
- /// </summary>
- public enum ErrorMode
- {
- /** Error during map step. */
- MapErr,
-
- /** Error during map step which is not marshalable. */
- MapErrNotMarshalable,
-
- /** Job created by mapper is not marshalable. */
- MapJobNotMarshalable,
-
- /** Error occurred in local job. */
- LocJobErr,
-
- /** Error occurred in local job and is not marshalable. */
- LocJobErrNotMarshalable,
-
- /** Local job result is not marshalable. */
- LocJobResNotMarshalable,
-
- /** Error occurred in remote job. */
- RmtJobErr,
-
- /** Error occurred in remote job and is not marshalable. */
- RmtJobErrNotMarshalable,
-
- /** Remote job result is not marshalable. */
- RmtJobResNotMarshalable,
-
- /** Error occurred during local result processing. */
- LocResErr,
-
- /** Error occurred during local result processing and is not marshalable. */
- LocResErrNotMarshalable,
-
- /** Error occurred during remote result processing. */
- RmtResErr,
-
- /** Error occurred during remote result processing and is not marshalable. */
- RmtResErrNotMarshalable,
-
- /** Error during reduce step. */
- ReduceErr,
-
- /** Error during reduce step and is not marshalable. */
- ReduceErrNotMarshalable,
-
- /** Reduce result is not marshalable. */
- ReduceResNotMarshalable
- }
-
- /// <summary>
- /// Task.
- /// </summary>
- public class Task : IComputeTask<object, object>
- {
- /** Grid. */
- [InstanceResource]
- private IIgnite _grid = null;
-
- /** Result. */
- private int _res;
-
- /** <inheritDoc /> */
- public IDictionary<IComputeJob<object>, IClusterNode> Map(IList<IClusterNode> subgrid, object arg)
- {
- switch (Mode)
- {
- case ErrorMode.MapErr:
- throw new GoodException(ErrorMode.MapErr);
-
- case ErrorMode.MapErrNotMarshalable:
- throw new BadException(ErrorMode.MapErrNotMarshalable);
-
- case ErrorMode.MapJobNotMarshalable:
- {
- var badJobs = new Dictionary<IComputeJob<object>, IClusterNode>();
-
- foreach (IClusterNode node in subgrid)
- badJobs.Add(new BadJob(), node);
-
- return badJobs;
- }
- }
-
- // Map completes sucessfully and we spread jobs to all nodes.
- var jobs = new Dictionary<IComputeJob<object>, IClusterNode>();
-
- foreach (IClusterNode node in subgrid)
- jobs.Add(new GoodJob(!_grid.GetCluster().GetLocalNode().Id.Equals(node.Id)), node);
-
- return jobs;
- }
-
- /** <inheritDoc /> */
- public ComputeJobResultPolicy Result(IComputeJobResult<object> res, IList<IComputeJobResult<object>> rcvd)
- {
- if (res.Exception() != null)
- JobErrs.Add(res.Exception());
- else
- {
- object res0 = res.Data();
-
- bool rmt = res0 is GoodJobResult ? ((GoodJobResult)res0).Rmt : ((BadJobResult)res0).Rmt;
-
- if (rmt)
- {
- switch (Mode)
- {
- case ErrorMode.RmtResErr:
- throw new GoodException(ErrorMode.RmtResErr);
-
- case ErrorMode.RmtResErrNotMarshalable:
- throw new BadException(ErrorMode.RmtResErrNotMarshalable);
- }
- }
- else
- {
- switch (Mode)
- {
- case ErrorMode.LocResErr:
- throw new GoodException(ErrorMode.LocResErr);
-
- case ErrorMode.LocResErrNotMarshalable:
- throw new BadException(ErrorMode.LocResErrNotMarshalable);
- }
- }
-
- _res += 1;
- }
-
- return ComputeJobResultPolicy.Wait;
- }
-
- /** <inheritDoc /> */
- public object Reduce(IList<IComputeJobResult<object>> results)
- {
- switch (Mode)
- {
- case ErrorMode.ReduceErr:
- throw new GoodException(ErrorMode.ReduceErr);
-
- case ErrorMode.ReduceErrNotMarshalable:
- throw new BadException(ErrorMode.ReduceErrNotMarshalable);
-
- case ErrorMode.ReduceResNotMarshalable:
- return new BadTaskResult(_res);
- }
-
- return new GoodTaskResult(_res);
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- [Serializable]
- public class GoodJob : IComputeJob<object>
- {
- /** Whether the job is remote. */
- private bool _rmt;
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="rmt"></param>
- public GoodJob(bool rmt)
- {
- _rmt = rmt;
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="info"></param>
- /// <param name="context"></param>
- public GoodJob(SerializationInfo info, StreamingContext context)
- {
- _rmt = info.GetBoolean("rmt");
- }
-
- /** <inheritDoc /> */
- public void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- info.AddValue("rmt", _rmt);
- }
-
- /** <inheritDoc /> */
- public object Execute()
- {
- if (_rmt)
- {
- switch (Mode)
- {
- case ErrorMode.RmtJobErr:
- throw new GoodException(ErrorMode.RmtJobErr);
-
- case ErrorMode.RmtJobErrNotMarshalable:
- throw new BadException(ErrorMode.RmtJobErr);
-
- case ErrorMode.RmtJobResNotMarshalable:
- return new BadJobResult(_rmt);
- }
- }
- else
- {
- switch (Mode)
- {
- case ErrorMode.LocJobErr:
- throw new GoodException(ErrorMode.LocJobErr);
-
- case ErrorMode.LocJobErrNotMarshalable:
- throw new BadException(ErrorMode.LocJobErr);
-
- case ErrorMode.LocJobResNotMarshalable:
- return new BadJobResult(_rmt);
- }
- }
-
- return new GoodJobResult(_rmt);
- }
-
- /** <inheritDoc /> */
- public void Cancel()
- {
- // No-op.
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- public class BadJob : IComputeJob<object>
- {
- [InstanceResource]
-
- /** <inheritDoc /> */
- public object Execute()
- {
- throw new NotImplementedException();
- }
-
- /** <inheritDoc /> */
- public void Cancel()
- {
- // No-op.
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- [Serializable]
- public class GoodJobResult
- {
- /** */
- public bool Rmt;
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="rmt"></param>
- public GoodJobResult(bool rmt)
- {
- Rmt = rmt;
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="info"></param>
- /// <param name="context"></param>
- public GoodJobResult(SerializationInfo info, StreamingContext context)
- {
- Rmt = info.GetBoolean("rmt");
- }
-
- /** <inheritDoc /> */
- public void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- info.AddValue("rmt", Rmt);
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- public class BadJobResult
- {
- /** */
- public bool Rmt;
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="rmt"></param>
- public BadJobResult(bool rmt)
- {
- Rmt = rmt;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- [Serializable]
- public class GoodTaskResult
- {
- /** */
- public int Res;
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="res"></param>
- public GoodTaskResult(int res)
- {
- Res = res;
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="info"></param>
- /// <param name="context"></param>
- public GoodTaskResult(SerializationInfo info, StreamingContext context)
- {
- Res = info.GetInt32("res");
- }
-
- /** <inheritDoc /> */
- public void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- info.AddValue("res", Res);
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- public class BadTaskResult
- {
- /** */
- public int Res;
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="res"></param>
- public BadTaskResult(int res)
- {
- Res = res;
- }
- }
-
- /// <summary>
- /// Marshalable exception.
- /// </summary>
- [Serializable]
- public class GoodException : Exception
- {
- /** */
- public ErrorMode Mode;
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="mode"></param>
- public GoodException(ErrorMode mode)
- {
- Mode = mode;
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="info"></param>
- /// <param name="context"></param>
- public GoodException(SerializationInfo info, StreamingContext context)
- {
- Mode = (ErrorMode)info.GetInt32("mode");
- }
-
- /** <inheritDoc /> */
- public override void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- info.AddValue("mode", (int)Mode);
-
- base.GetObjectData(info, context);
- }
- }
-
- /// <summary>
- /// Not marshalable exception.
- /// </summary>
- public class BadException : Exception
- {
- /** */
- public ErrorMode Mode;
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="mode"></param>
- public BadException(ErrorMode mode)
- {
- Mode = mode;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/PortableClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/PortableClosureTaskTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/PortableClosureTaskTest.cs
deleted file mode 100644
index 3ca933e..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/PortableClosureTaskTest.cs
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Compute
-{
- using System;
- using System.Collections.Generic;
- using Apache.Ignite.Core.Compute;
- using Apache.Ignite.Core.Portable;
- using NUnit.Framework;
-
- /// <summary>
- /// Closure execution tests for portable objects.
- /// </summary>
- public class PortableClosureTaskTest : ClosureTaskTest
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- public PortableClosureTaskTest() : base(false) { }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="fork">Fork flag.</param>
- protected PortableClosureTaskTest(bool fork) : base(fork) { }
-
- /** <inheritDoc /> */
- protected override void PortableTypeConfigurations(ICollection<PortableTypeConfiguration> portTypeCfgs)
- {
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableOutFunc)));
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableFunc)));
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableResult)));
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableException)));
- }
-
- /** <inheritDoc /> */
- protected override IComputeFunc<object> OutFunc(bool err)
- {
- return new PortableOutFunc(err);
- }
-
- /** <inheritDoc /> */
- protected override IComputeFunc<object, object> Func(bool err)
- {
- return new PortableFunc(err);
- }
-
- /** <inheritDoc /> */
- protected override void CheckResult(object res)
- {
- Assert.IsTrue(res != null);
-
- PortableResult res0 = res as PortableResult;
-
- Assert.IsTrue(res0 != null);
- Assert.AreEqual(1, res0.Res);
- }
-
- /** <inheritDoc /> */
- protected override void CheckError(Exception err)
- {
- Assert.IsTrue(err != null);
-
- PortableException err0 = err as PortableException;
-
- Assert.IsTrue(err0 != null);
- Assert.AreEqual(ErrMsg, err0.Msg);
- }
-
- /// <summary>
- ///
- /// </summary>
- private class PortableOutFunc : IComputeFunc<object>
- {
- /** Error. */
- private bool _err;
-
- /// <summary>
- ///
- /// </summary>
- public PortableOutFunc()
- {
- // No-op.
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="err"></param>
- public PortableOutFunc(bool err)
- {
- _err = err;
- }
-
- /** <inheritDoc /> */
- public object Invoke()
- {
- if (_err)
- throw new PortableException(ErrMsg);
- return new PortableResult(1);
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- private class PortableFunc : IComputeFunc<object, object>
- {
- /** Error. */
- private bool _err;
-
- /// <summary>
- ///
- /// </summary>
- public PortableFunc()
- {
- // No-op.
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="err"></param>
- public PortableFunc(bool err)
- {
- _err = err;
- }
-
- /** <inheritDoc /> */
- public object Invoke(object arg)
- {
- if (_err)
- throw new PortableException(ErrMsg);
- return new PortableResult(1);
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- private class PortableException : Exception, IPortableMarshalAware
- {
- /** */
- public string Msg;
-
- /// <summary>
- ///
- /// </summary>
- public PortableException()
- {
- // No-op.
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="msg"></param>
- public PortableException(string msg) : this()
- {
- Msg = msg;
- }
-
- /** <inheritDoc /> */
- public void WritePortable(IPortableWriter writer)
- {
- writer.RawWriter().WriteString(Msg);
- }
-
- /** <inheritDoc /> */
- public void ReadPortable(IPortableReader reader)
- {
- Msg = reader.RawReader().ReadString();
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- private class PortableResult
- {
- /** */
- public int Res;
-
- /// <summary>
- ///
- /// </summary>
- public PortableResult()
- {
- // No-op.
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="res"></param>
- public PortableResult(int res)
- {
- Res = res;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs
deleted file mode 100644
index 736aa61..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Compute
-{
- using System.Collections.Generic;
- using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Compute;
- using Apache.Ignite.Core.Portable;
- using Apache.Ignite.Core.Resource;
- using NUnit.Framework;
-
- /// <summary>
- /// Task test result.
- /// </summary>
- public class PortableTaskTest : AbstractTaskTest
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- public PortableTaskTest() : base(false) { }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="fork">Fork flag.</param>
- protected PortableTaskTest(bool fork) : base(fork) { }
-
- /// <summary>
- /// Test for task result.
- /// </summary>
- [Test]
- public void TestPortableObjectInTask()
- {
- IPortableObject taskArg = ToPortable(Grid1, new PortableTaskArgument(100));
-
- TestTask task = new TestTask(Grid1, taskArg);
-
- IPortableObject res = Grid1.GetCompute().Execute(task, taskArg);
-
- Assert.NotNull(res);
-
- Assert.AreEqual(400, res.GetField<int>("val"));
-
- PortableTaskResult resObj = res.Deserialize<PortableTaskResult>();
-
- Assert.AreEqual(400, resObj.Val);
- }
-
- private static IPortableObject ToPortable(IIgnite grid, object obj)
- {
- var cache = grid.GetCache<object, object>(Cache1Name).WithKeepPortable<object, object>();
-
- cache.Put(1, obj);
-
- return (IPortableObject) cache.Get(1);
- }
-
- /** <inheritDoc /> */
- override protected void PortableTypeConfigurations(ICollection<PortableTypeConfiguration> portTypeCfgs)
- {
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableJobArgument)));
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableJobResult)));
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableTaskArgument)));
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableTaskResult)));
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableJob)));
- }
-
- /// <summary>
- /// Test task.
- /// </summary>
- public class TestTask : ComputeTaskAdapter<IPortableObject, IPortableObject, IPortableObject>
- {
- /** */
- private readonly IIgnite _grid;
-
- private readonly IPortableObject _taskArgField;
-
- public TestTask(IIgnite grid, IPortableObject taskArgField)
- {
- _grid = grid;
- _taskArgField = taskArgField;
- }
-
- /** <inheritDoc /> */
- override public IDictionary<IComputeJob<IPortableObject>, IClusterNode> Map(IList<IClusterNode> subgrid, IPortableObject arg)
- {
- Assert.AreEqual(3, subgrid.Count);
- Assert.NotNull(_grid);
-
- IPortableObject taskArg = arg;
-
- CheckTaskArgument(taskArg);
-
- CheckTaskArgument(_taskArgField);
-
- IDictionary<IComputeJob<IPortableObject>, IClusterNode> jobs = new Dictionary<IComputeJob<IPortableObject>, IClusterNode>();
-
-
- foreach (IClusterNode node in subgrid)
- {
- if (!Grid3Name.Equals(node.GetAttribute<string>("org.apache.ignite.ignite.name"))) // Grid3 does not have cache.
- {
- PortableJob job = new PortableJob();
-
- job.Arg = ToPortable(_grid, new PortableJobArgument(200));
-
- jobs.Add(job, node);
- }
- }
-
- Assert.AreEqual(2, jobs.Count);
-
- return jobs;
- }
-
- private void CheckTaskArgument(IPortableObject taskArg)
- {
- Assert.IsNotNull(taskArg);
-
- Assert.AreEqual(100, taskArg.GetField<int>("val"));
-
- PortableTaskArgument taskArgObj = taskArg.Deserialize<PortableTaskArgument>();
-
- Assert.AreEqual(100, taskArgObj.Val);
- }
-
- /** <inheritDoc /> */
- override public IPortableObject Reduce(IList<IComputeJobResult<IPortableObject>> results)
- {
- Assert.NotNull(_grid);
-
- Assert.AreEqual(2, results.Count);
-
- foreach (IComputeJobResult<IPortableObject> res in results)
- {
- IPortableObject jobRes = res.Data();
-
- Assert.NotNull(jobRes);
-
- Assert.AreEqual(300, jobRes.GetField<int>("val"));
-
- PortableJobResult jobResObj = jobRes.Deserialize<PortableJobResult>();
-
- Assert.AreEqual(300, jobResObj.Val);
- }
-
- return ToPortable(_grid, new PortableTaskResult(400));
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- class PortableJobArgument
- {
- /** */
- public int Val;
-
- public PortableJobArgument(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- class PortableJobResult
- {
- /** */
- public int Val;
-
- public PortableJobResult(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- class PortableTaskArgument
- {
- /** */
- public int Val;
-
- public PortableTaskArgument(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- class PortableTaskResult
- {
- /** */
- public int Val;
-
- public PortableTaskResult(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- class PortableJob : IComputeJob<IPortableObject>
- {
- [InstanceResource]
- private IIgnite _grid = null;
-
- /** */
- public IPortableObject Arg;
-
- /** <inheritDoc /> */
- public IPortableObject Execute()
- {
- Assert.IsNotNull(Arg);
-
- Assert.AreEqual(200, Arg.GetField<int>("val"));
-
- PortableJobArgument argObj = Arg.Deserialize<PortableJobArgument>();
-
- Assert.AreEqual(200, argObj.Val);
-
- return ToPortable(_grid, new PortableJobResult(300));
- }
-
- public void Cancel()
- {
- // No-op.
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/ResourceTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/ResourceTaskTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/ResourceTaskTest.cs
deleted file mode 100644
index 55bb9d0..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/ResourceTaskTest.cs
+++ /dev/null
@@ -1,568 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Compute
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.Serialization;
- using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Compute;
- using Apache.Ignite.Core.Resource;
- using NUnit.Framework;
-
- /// <summary>
- /// Test resource injections in tasks and jobs.
- /// </summary>
- public class ResourceTaskTest : AbstractTaskTest
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- public ResourceTaskTest() : base(false) { }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="fork">Fork flag.</param>
- protected ResourceTaskTest(bool fork) : base(fork) { }
-
- /// <summary>
- /// Test Ignite injection into the task.
- /// </summary>
- [Test]
- public void TestTaskInjection()
- {
- int res = Grid1.GetCompute().Execute(new InjectionTask(), 0);
-
- Assert.AreEqual(Grid1.GetCluster().GetNodes().Count, res);
- }
-
- /// <summary>
- /// Test Ignite injection into the closure.
- /// </summary>
- [Test]
- public void TestClosureInjection()
- {
- var res = Grid1.GetCompute().Broadcast(new InjectionClosure(), 1);
-
- Assert.AreEqual(Grid1.GetCluster().GetNodes().Count, res.Sum());
- }
-
- /// <summary>
- /// Test Ignite injection into reducer.
- /// </summary>
- [Test]
- public void TestReducerInjection()
- {
- int res = Grid1.GetCompute().Apply(new InjectionClosure(), new List<int> { 1, 1, 1 }, new InjectionReducer());
-
- Assert.AreEqual(Grid1.GetCluster().GetNodes().Count, res);
- }
-
- /// <summary>
- /// Test no-result-cache attribute.
- /// </summary>
- [Test]
- public void TestNoResultCache()
- {
- int res = Grid1.GetCompute().Execute(new NoResultCacheTask(), 0);
-
- Assert.AreEqual(Grid1.GetCluster().GetNodes().Count, res);
- }
-
- /// <summary>
- /// Injection task.
- /// </summary>
- public class InjectionTask : Injectee, IComputeTask<object, int, int>
- {
- /** <inheritDoc /> */
- public IDictionary<IComputeJob<int>, IClusterNode> Map(IList<IClusterNode> subgrid, object arg)
- {
- CheckInjection();
-
- return subgrid.ToDictionary(x => (IComputeJob<int>) new InjectionJob(), x => x);
- }
-
- /** <inheritDoc /> */
- public ComputeJobResultPolicy Result(IComputeJobResult<int> res, IList<IComputeJobResult<int>> rcvd)
- {
- return ComputeJobResultPolicy.Wait;
- }
-
- /** <inheritDoc /> */
- public int Reduce(IList<IComputeJobResult<int>> results)
- {
- return results.Sum(res => res.Data());
- }
- }
-
- /// <summary>
- /// Injection job.
- /// </summary>
- [Serializable]
- public class InjectionJob : Injectee, IComputeJob<int>
- {
- /// <summary>
- ///
- /// </summary>
- public InjectionJob()
- {
- // No-op.
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="info"></param>
- /// <param name="context"></param>
- public InjectionJob(SerializationInfo info, StreamingContext context) : base(info, context)
- {
- // No-op.
- }
-
- /** <inheritDoc /> */
- public int Execute()
- {
- CheckInjection();
-
- return 1;
- }
-
- public void Cancel()
- {
- // No-op.
- }
- }
-
- /// <summary>
- /// Injection closure.
- /// </summary>
- [Serializable]
- public class InjectionClosure : IComputeFunc<int, int>
- {
- /** */
- [InstanceResource]
- private static IIgnite _staticGrid1;
-
- /** */
- [InstanceResource]
- public static IIgnite StaticGrid2;
-
- /// <summary>
- ///
- /// </summary>
- [InstanceResource]
- public static IIgnite StaticPropGrid1
- {
- get { return _staticGrid1; }
- set { _staticGrid1 = value; }
- }
-
- /// <summary>
- ///
- /// </summary>
- [InstanceResource]
- private static IIgnite StaticPropGrid2
- {
- get { return StaticGrid2; }
- set { StaticGrid2 = value; }
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="grid"></param>
- [InstanceResource]
- public static void StaticMethod1(IIgnite grid)
- {
- _staticGrid1 = grid;
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="grid"></param>
- [InstanceResource]
- private static void StaticMethod2(IIgnite grid)
- {
- StaticGrid2 = grid;
- }
-
- /// <summary>
- ///
- /// </summary>
- public InjectionClosure()
- {
- // No-op.
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="info"></param>
- /// <param name="context"></param>
- public InjectionClosure(SerializationInfo info, StreamingContext context)
- {
- // No-op.
- }
-
- /** */
- [InstanceResource]
- private readonly IIgnite _grid1 = null;
-
- /** */
- [InstanceResource]
- public IIgnite Grid2;
-
- /** */
- private IIgnite _mthdGrid1;
-
- /** */
- private IIgnite _mthdGrid2;
-
- /// <summary>
- ///
- /// </summary>
- [InstanceResource]
- public IIgnite PropGrid1
- {
- get;
- set;
- }
-
- /// <summary>
- ///
- /// </summary>
- [InstanceResource]
- private IIgnite PropGrid2
- {
- get;
- set;
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="grid"></param>
- [InstanceResource]
- public void Method1(IIgnite grid)
- {
- _mthdGrid1 = grid;
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="grid"></param>
- [InstanceResource]
- private void Method2(IIgnite grid)
- {
- _mthdGrid2 = grid;
- }
-
- /// <summary>
- /// Check Ignite injections.
- /// </summary>
- protected void CheckInjection()
- {
- Assert.IsTrue(_staticGrid1 == null);
- Assert.IsTrue(StaticGrid2 == null);
-
- Assert.IsTrue(_grid1 != null);
- Assert.IsTrue(Grid2 == _grid1);
-
- Assert.IsTrue(PropGrid1 == _grid1);
- Assert.IsTrue(PropGrid2 == _grid1);
-
- Assert.IsTrue(_mthdGrid1 == _grid1);
- Assert.IsTrue(_mthdGrid2 == _grid1);
- }
-
- /** <inheritDoc /> */
- public void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- // No-op.
- }
-
- /** <inheritDoc /> */
- public int Invoke(int arg)
- {
- CheckInjection();
-
- return arg;
- }
- }
-
- /// <summary>
- /// Injection reducer.
- /// </summary>
- public class InjectionReducer : Injectee, IComputeReducer<int, int>
- {
- /** Collected results. */
- private readonly ICollection<int> _ress = new List<int>();
-
- /** <inheritDoc /> */
- public bool Collect(int res)
- {
- CheckInjection();
-
- lock (_ress)
- {
- _ress.Add(res);
- }
-
- return true;
- }
-
- /** <inheritDoc /> */
- public int Reduce()
- {
- CheckInjection();
-
- lock (_ress)
- {
- return _ress.Sum();
- }
- }
- }
-
- /// <summary>
- /// Injectee.
- /// </summary>
- [Serializable]
- public class Injectee : ISerializable
- {
- /** */
- [InstanceResource]
- private static IIgnite _staticGrid1;
-
- /** */
- [InstanceResource]
- public static IIgnite StaticGrid2;
-
- /// <summary>
- ///
- /// </summary>
- [InstanceResource]
- public static IIgnite StaticPropGrid1
- {
- get { return _staticGrid1; }
- set { _staticGrid1 = value; }
- }
-
- /// <summary>
- ///
- /// </summary>
- [InstanceResource]
- private static IIgnite StaticPropGrid2
- {
- get { return StaticGrid2; }
- set { StaticGrid2 = value; }
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="grid"></param>
- [InstanceResource]
- public static void StaticMethod1(IIgnite grid)
- {
- _staticGrid1 = grid;
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="grid"></param>
- [InstanceResource]
- private static void StaticMethod2(IIgnite grid)
- {
- StaticGrid2 = grid;
- }
-
- /// <summary>
- ///
- /// </summary>
- public Injectee()
- {
- // No-op.
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="info"></param>
- /// <param name="context"></param>
- public Injectee(SerializationInfo info, StreamingContext context)
- {
- // No-op.
- }
-
- /** */
- [InstanceResource]
- private readonly IIgnite _grid1 = null;
-
- /** */
- [InstanceResource]
- public IIgnite Grid2;
-
- /** */
- private IIgnite _mthdGrid1;
-
- /** */
- private IIgnite _mthdGrid2;
-
- /// <summary>
- ///
- /// </summary>
- [InstanceResource]
- public IIgnite PropGrid1
- {
- get;
- set;
- }
-
- /// <summary>
- ///
- /// </summary>
- [InstanceResource]
- private IIgnite PropGrid2
- {
- get;
- set;
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="grid"></param>
- [InstanceResource]
- public void Method1(IIgnite grid)
- {
- _mthdGrid1 = grid;
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="grid"></param>
- [InstanceResource]
- private void Method2(IIgnite grid)
- {
- _mthdGrid2 = grid;
- }
-
- /// <summary>
- /// Check Ignite injections.
- /// </summary>
- protected void CheckInjection()
- {
- Assert.IsTrue(_staticGrid1 == null);
- Assert.IsTrue(StaticGrid2 == null);
-
- Assert.IsTrue(_grid1 != null);
- Assert.IsTrue(Grid2 == _grid1);
-
- Assert.IsTrue(PropGrid1 == _grid1);
- Assert.IsTrue(PropGrid2 == _grid1);
-
- Assert.IsTrue(_mthdGrid1 == _grid1);
- Assert.IsTrue(_mthdGrid2 == _grid1);
- }
-
- /** <inheritDoc /> */
- public void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- // No-op.
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- [ComputeTaskNoResultCache]
- public class NoResultCacheTask : IComputeTask<int, int, int>
- {
- /** Sum. */
- private int _sum;
-
- /** <inheritDoc /> */
- public IDictionary<IComputeJob<int>, IClusterNode> Map(IList<IClusterNode> subgrid, int arg)
- {
- return subgrid.ToDictionary(x => (IComputeJob<int>) new NoResultCacheJob(), x => x);
- }
-
- /** <inheritDoc /> */
- public ComputeJobResultPolicy Result(IComputeJobResult<int> res, IList<IComputeJobResult<int>> rcvd)
- {
- Assert.IsTrue(rcvd != null);
- Assert.IsTrue(rcvd.Count == 0);
-
- _sum += res.Data();
-
- return ComputeJobResultPolicy.Wait;
- }
-
- /** <inheritDoc /> */
- public int Reduce(IList<IComputeJobResult<int>> results)
- {
- Assert.IsTrue(results != null);
- Assert.IsTrue(results.Count == 0);
-
- return _sum;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- [Serializable]
- public class NoResultCacheJob : IComputeJob<int>
- {
- /// <summary>
- ///
- /// </summary>
- public NoResultCacheJob()
- {
- // No-op.
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="info"></param>
- /// <param name="context"></param>
- public NoResultCacheJob(SerializationInfo info, StreamingContext context)
- {
- // No-op.
- }
-
- /** <inheritDoc /> */
- public int Execute()
- {
- return 1;
- }
-
- public void Cancel()
- {
- // No-op.
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/SerializableClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/SerializableClosureTaskTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/SerializableClosureTaskTest.cs
deleted file mode 100644
index ded56ed..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/SerializableClosureTaskTest.cs
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Compute
-{
- using System;
- using System.Runtime.Serialization;
- using Apache.Ignite.Core.Compute;
- using NUnit.Framework;
-
- /// <summary>
- /// Closure execution tests for serializable objects.
- /// </summary>
- public class SerializableClosureTaskTest : ClosureTaskTest
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- public SerializableClosureTaskTest() : base(false) { }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="fork">Fork flag.</param>
- protected SerializableClosureTaskTest(bool fork) : base(fork) { }
-
- /** <inheritDoc /> */
- protected override IComputeFunc<object> OutFunc(bool err)
- {
- return new SerializableOutFunc(err);
- }
-
- /** <inheritDoc /> */
- protected override IComputeFunc<object, object> Func(bool err)
- {
- return new SerializableFunc(err);
- }
-
- /** <inheritDoc /> */
- protected override void CheckResult(object res)
- {
- Assert.IsTrue(res != null);
-
- SerializableResult res0 = res as SerializableResult;
-
- Assert.IsTrue(res0 != null);
- Assert.AreEqual(1, res0.Res);
- }
-
- /** <inheritDoc /> */
- protected override void CheckError(Exception err)
- {
- Assert.IsTrue(err != null);
-
- SerializableException err0 = err as SerializableException;
-
- Assert.IsTrue(err0 != null);
- Assert.AreEqual(ErrMsg, err0.Msg);
- }
-
- /// <summary>
- ///
- /// </summary>
- [Serializable]
- private class SerializableOutFunc : IComputeFunc<object>
- {
- /** Error. */
- private bool _err;
-
- /// <summary>
- ///
- /// </summary>
- public SerializableOutFunc()
- {
- // No-op.
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="err"></param>
- public SerializableOutFunc(bool err)
- {
- _err = err;
- }
-
- /** <inheritDoc /> */
- public object Invoke()
- {
- if (_err)
- throw new SerializableException(ErrMsg);
- return new SerializableResult(1);
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- [Serializable]
- private class SerializableFunc : IComputeFunc<object, object>
- {
- /** Error. */
- private bool _err;
-
- /// <summary>
- ///
- /// </summary>
- public SerializableFunc()
- {
- // No-op.
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="err"></param>
- public SerializableFunc(bool err)
- {
- _err = err;
- }
-
- /** <inheritDoc /> */
- public object Invoke(object arg)
- {
- Console.WriteLine("INVOKED!");
-
- if (_err)
- throw new SerializableException(ErrMsg);
- return new SerializableResult(1);
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- [Serializable]
- private class SerializableException : Exception
- {
- /** */
- public string Msg;
-
- /// <summary>
- ///
- /// </summary>
- public SerializableException()
- {
- // No-op.
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="msg"></param>
- public SerializableException(string msg) : this()
- {
- Msg = msg;
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="info"></param>
- /// <param name="context"></param>
- public SerializableException(SerializationInfo info, StreamingContext context) : base(info, context)
- {
- Msg = info.GetString("msg");
- }
-
- /** <inheritDoc /> */
- public override void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- info.AddValue("msg", Msg);
-
- base.GetObjectData(info, context);
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- [Serializable]
- private class SerializableResult
- {
- public int Res;
-
- /// <summary>
- ///
- /// </summary>
- public SerializableResult()
- {
- // No-op.
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="res"></param>
- public SerializableResult(int res)
- {
- Res = res;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
deleted file mode 100644
index f7fb422..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Compute
-{
- using System;
- using System.Collections.Generic;
- using Apache.Ignite.Core.Compute;
- using Apache.Ignite.Core.Portable;
- using Apache.Ignite.Core.Resource;
- using NUnit.Framework;
-
- /// <summary>
- /// Test for task and job adapter.
- /// </summary>
- public class TaskAdapterTest : AbstractTaskTest
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- public TaskAdapterTest() : base(false) { }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="fork">Fork flag.</param>
- protected TaskAdapterTest(bool fork) : base(fork) { }
-
- /// <summary>
- /// Test for task adapter.
- /// </summary>
- [Test]
- public void TestTaskAdapter()
- {
- Assert.AreEqual(3, Grid1.GetCluster().GetNodes().Count);
-
- HashSet<Guid> allNodes = new HashSet<Guid>();
-
- for (int i = 0; i < 20 && allNodes.Count < 3; i++)
- {
- HashSet<Guid> res = Grid1.GetCompute().Execute(new TestSplitTask(), 1);
-
- Assert.AreEqual(1, res.Count);
-
- allNodes.UnionWith(res);
- }
-
- Assert.AreEqual(3, allNodes.Count);
-
- HashSet<Guid> res2 = Grid1.GetCompute().Execute<int, Guid, HashSet<Guid>>(typeof(TestSplitTask), 3);
-
- Assert.IsTrue(res2.Count > 0);
-
- Grid1.GetCompute().Execute(new TestSplitTask(), 100);
-
- Assert.AreEqual(3, allNodes.Count);
- }
-
- /// <summary>
- /// Test for job adapter.
- /// </summary>
- [Test]
- public void TestSerializableJobAdapter()
- {
- for (int i = 0; i < 10; i++)
- {
- bool res = Grid1.GetCompute().Execute(new TestJobAdapterTask(), true);
-
- Assert.IsTrue(res);
- }
- }
-
- /// <summary>
- /// Test for job adapter.
- /// </summary>
- [Test]
- public void TestPortableJobAdapter()
- {
- for (int i = 0; i < 10; i++)
- {
- bool res = Grid1.GetCompute().Execute(new TestJobAdapterTask(), false);
-
- Assert.IsTrue(res);
- }
- }
-
- /** <inheritDoc /> */
- override protected void PortableTypeConfigurations(ICollection<PortableTypeConfiguration> portTypeCfgs)
- {
- portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableJob)));
- }
-
- /// <summary>
- /// Test task.
- /// </summary>
- public class TestSplitTask : ComputeTaskSplitAdapter<int, Guid, HashSet<Guid>>
- {
- /** <inheritDoc /> */
- override protected ICollection<IComputeJob<Guid>> Split(int gridSize, int arg)
- {
- Assert.AreEqual(3, gridSize);
-
- int jobsNum = arg;
-
- Assert.IsTrue(jobsNum > 0);
-
- var jobs = new List<IComputeJob<Guid>>(jobsNum);
-
- for (int i = 0; i < jobsNum; i++)
- jobs.Add(new NodeIdJob());
-
- return jobs;
- }
-
- /** <inheritDoc /> */
- override public HashSet<Guid> Reduce(IList<IComputeJobResult<Guid>> results)
- {
- HashSet<Guid> nodes = new HashSet<Guid>();
-
- foreach (var res in results) {
- Guid id = res.Data();
-
- Assert.NotNull(id);
-
- nodes.Add(id);
- }
-
- return nodes;
- }
- }
-
- /// <summary>
- /// Test task.
- /// </summary>
- public class TestJobAdapterTask : ComputeTaskSplitAdapter<bool, bool, bool>
- {
- /** <inheritDoc /> */
- override protected ICollection<IComputeJob<bool>> Split(int gridSize, bool arg)
- {
- bool serializable = arg;
-
- ICollection<IComputeJob<bool>> jobs = new List<IComputeJob<bool>>(1);
-
- if (serializable)
- jobs.Add(new SerializableJob(100, "str"));
- else
- jobs.Add(new PortableJob(100, "str"));
-
- return jobs;
- }
-
- /** <inheritDoc /> */
- override public bool Reduce(IList<IComputeJobResult<bool>> results)
- {
- Assert.AreEqual(1, results.Count);
-
- Assert.IsTrue(results[0].Data());
-
- return true;
- }
- }
-
- /// <summary>
- /// Test job.
- /// </summary>
- [Serializable]
- public class NodeIdJob : IComputeJob<Guid>
- {
- [InstanceResource]
- private IIgnite _grid = null;
-
- /** <inheritDoc /> */
- public Guid Execute()
- {
- Assert.NotNull(_grid);
-
- return _grid.GetCluster().GetLocalNode().Id;
- }
-
- /** <inheritDoc /> */
- public void Cancel()
- {
- // No-op.
- }
- }
-
- /// <summary>
- /// Test serializable job.
- /// </summary>
- [Serializable]
- public class SerializableJob : ComputeJobAdapter<bool>
- {
- [InstanceResource]
- private IIgnite _grid = null;
-
- public SerializableJob(params object[] args) : base(args)
- {
- // No-op.
- }
-
- /** <inheritDoc /> */
- override public bool Execute()
- {
- Assert.IsFalse(IsCancelled());
-
- Cancel();
-
- Assert.IsTrue(IsCancelled());
-
- Assert.NotNull(_grid);
-
- int arg1 = Argument<int>(0);
-
- Assert.AreEqual(100, arg1);
-
- string arg2 = Argument<string>(1);
-
- Assert.AreEqual("str", arg2);
-
- return true;
- }
- }
-
- /// <summary>
- /// Test portable job.
- /// </summary>
- public class PortableJob : ComputeJobAdapter<bool>
- {
- [InstanceResource]
- private IIgnite _grid = null;
-
- public PortableJob(params object[] args) : base(args)
- {
- // No-op.
- }
-
- /** <inheritDoc /> */
- override public bool Execute()
- {
- Assert.IsFalse(IsCancelled());
-
- Cancel();
-
- Assert.IsTrue(IsCancelled());
-
- Assert.NotNull(_grid);
-
- int arg1 = Argument<int>(0);
-
- Assert.AreEqual(100, arg1);
-
- string arg2 = Argument<string>(1);
-
- Assert.AreEqual("str", arg2);
-
- return true;
- }
- }
- }
-}
[30/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml
new file mode 100644
index 0000000..9af4611
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="includeEventTypes">
+ <util:constant static-field="org.apache.ignite.events.EventType.EVTS_CACHE"/>
+ </property>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="portable_store"/>
+ <property name="cacheMode" value="LOCAL"/>
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="writeThrough" value="true"/>
+ <property name="readThrough" value="true"/>
+
+ <property name="cacheStoreFactory">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
+ <property name="assemblyName" value="Apache.Ignite.Core.Tests"/>
+ <property name="className" value="Apache.Ignite.Core.Tests.Cache.Store.CacheTestStore"/>
+ </bean>
+ </property>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="object_store"/>
+ <property name="cacheMode" value="LOCAL"/>
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="writeThrough" value="true"/>
+ <property name="readThrough" value="true"/>
+ <property name="keepPortableInStore" value="false"/>
+
+ <property name="cacheStoreFactory">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
+ <property name="assemblyName" value="Apache.Ignite.Core.Tests"/>
+ <property name="className" value="Apache.Ignite.Core.Tests.Cache.Store.CacheTestStore"/>
+ </bean>
+ </property>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="template_store*"/>
+ <property name="cacheMode" value="LOCAL"/>
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="writeThrough" value="true"/>
+ <property name="readThrough" value="true"/>
+ <property name="keepPortableInStore" value="false"/>
+
+ <property name="cacheStoreFactory">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
+ <property name="assemblyName" value="Apache.Ignite.Core.Tests"/>
+ <property name="className" value="Apache.Ignite.Core.Tests.Cache.Store.CacheTestStore"/>
+ </bean>
+ </property>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="custom_store"/>
+ <property name="cacheMode" value="LOCAL"/>
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="writeThrough" value="true"/>
+ <property name="readThrough" value="true"/>
+
+ <property name="cacheStoreFactory">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
+ <property name="assemblyName" value="Apache.Ignite.Core.Tests"/>
+ <property name="className" value="Apache.Ignite.Core.Tests.Cache.Store.CacheTestStore"/>
+ <property name="properties">
+ <map>
+ <entry key="IntProperty">
+ <value type="java.lang.Integer">42</value>
+ </entry>
+ <entry key="StringProperty" value="String value"/>
+ </map>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </list>
+ </property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47501</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache.xml b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache.xml
new file mode 100644
index 0000000..c48e867
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache.xml
@@ -0,0 +1,194 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="includeEventTypes">
+ <util:constant static-field="org.apache.ignite.events.EventType.EVTS_CACHE"/>
+ </property>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean parent="cache-template">
+ <property name="name" value="local"/>
+ <property name="cacheMode" value="LOCAL"/>
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="startSize" value="10"/>
+ </bean>
+
+ <bean parent="cache-template">
+ <property name="name" value="local_atomic"/>
+ <property name="cacheMode" value="LOCAL"/>
+ <property name="atomicityMode" value="ATOMIC"/>
+ <property name="startSize" value="10"/>
+ </bean>
+
+ <bean parent="cache-template">
+ <property name="name" value="partitioned"/>
+ <property name="cacheMode" value="PARTITIONED"/>
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="startSize" value="10"/>
+ </bean>
+
+ <bean parent="cache-template">
+ <property name="name" value="partitioned_atomic"/>
+ <property name="cacheMode" value="PARTITIONED"/>
+ <property name="atomicityMode" value="ATOMIC"/>
+ <property name="atomicWriteOrderMode" value="PRIMARY"/>
+ <property name="startSize" value="10"/>
+ </bean>
+
+ <bean parent="cache-template">
+ <property name="name" value="partitioned_near"/>
+ <property name="cacheMode" value="PARTITIONED"/>
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="nearConfiguration">
+ <bean class="org.apache.ignite.configuration.NearCacheConfiguration" />
+ </property>
+ <property name="startSize" value="10"/>
+ </bean>
+
+ <bean parent="cache-template">
+ <property name="name" value="partitioned_atomic_near"/>
+ <property name="cacheMode" value="PARTITIONED"/>
+ <property name="atomicityMode" value="ATOMIC"/>
+ <property name="atomicWriteOrderMode" value="PRIMARY"/>
+ <property name="nearConfiguration">
+ <bean class="org.apache.ignite.configuration.NearCacheConfiguration" />
+ </property>
+ <property name="startSize" value="10"/>
+ </bean>
+
+ <bean parent="cache-template">
+ <property name="name" value="replicated"/>
+ <property name="cacheMode" value="REPLICATED"/>
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="startSize" value="10"/>
+ </bean>
+
+ <bean parent="cache-template">
+ <property name="name" value="replicated_atomic"/>
+ <property name="cacheMode" value="REPLICATED"/>
+ <property name="atomicityMode" value="ATOMIC"/>
+ <property name="atomicWriteOrderMode" value="PRIMARY"/>
+ <property name="startSize" value="10"/>
+ </bean>
+
+ <bean parent="cache-template">
+ <property name="name" value="template*"/>
+ <property name="startSize" value="10"/>
+ </bean>
+ </list>
+ </property>
+
+ <property name="swapSpaceSpi">
+ <bean class="org.apache.ignite.spi.swapspace.inmemory.GridTestSwapSpaceSpi"/>
+ </property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47501</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+
+ <property name="transactionConfiguration">
+ <bean class="org.apache.ignite.configuration.TransactionConfiguration">
+ <property name="txSerializableEnabled" value="true"/>
+ </bean>
+ </property>
+ </bean>
+
+ <bean id="cache-template" abstract="true" class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="rebalanceMode" value="SYNC"/>
+ <property name="writeSynchronizationMode" value="FULL_SYNC"/>
+ <property name="swapEnabled" value="true"/>
+ <property name="backups" value="1"/>
+ <property name="eagerTtl" value="true"/>
+
+ <!--
+ <property name="typeMetadata">
+ <list>
+ <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+ <property name="valueType" value="GridPortablePerson"/>
+ <property name="ascendingFields">
+ <map>
+ <entry key="age" value="java.lang.Integer"/>
+ </map>
+ </property>
+ <property name="queryFields">
+ <map>
+ <entry key="name" value="java.lang.String"/>
+ </map>
+ </property>
+ <property name="textFields">
+ <list>
+ <value>address</value>
+ </list>
+ </property>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+ <property name="valueType" value="GridImplicitPortablePerson"/>
+ <property name="ascendingFields">
+ <map>
+ <entry key="age" value="java.lang.Integer"/>
+ </map>
+ </property>
+ <property name="queryFields">
+ <map>
+ <entry key="name" value="java.lang.String"/>
+ </map>
+ </property>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+ <property name="valueType" value="GridNoDefPortablePerson"/>
+ <property name="ascendingFields">
+ <map>
+ <entry key="age" value="java.lang.Integer"/>
+ </map>
+ </property>
+ <property name="queryFields">
+ <map>
+ <entry key="name" value="java.lang.String"/>
+ </map>
+ </property>
+ </bean>
+ </list>
+ </property>
+ -->
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/portable.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/portable.xml b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/portable.xml
new file mode 100644
index 0000000..f013749
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/portable.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="gridName" value="grid"/>
+
+ <property name="metricsUpdateFrequency" value="1000"/>
+ <property name="metricsLogFrequency" value="0"/>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="cache"/>
+ </bean>
+ </list>
+ </property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47502</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/start-test-grid1.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/start-test-grid1.xml b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/start-test-grid1.xml
new file mode 100644
index 0000000..8559173
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/start-test-grid1.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="gridName" value="grid1"/>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="cache1"/>
+ <property name="rebalanceMode" value="SYNC"/>
+ </bean>
+ </list>
+ </property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47502</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/start-test-grid2.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/start-test-grid2.xml b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/start-test-grid2.xml
new file mode 100644
index 0000000..cb628fe
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/start-test-grid2.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="gridName" value="grid2"/>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47502</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/start-test-grid3.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/start-test-grid3.xml b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/start-test-grid3.xml
new file mode 100644
index 0000000..753fad1
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Config/start-test-grid3.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47502</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
new file mode 100644
index 0000000..245ed5f
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
@@ -0,0 +1,592 @@
+/*
+ * 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.Dataload
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Diagnostics;
+ using System.Linq;
+ using System.Threading;
+ using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Datastream;
+ using Apache.Ignite.Core.Impl;
+ using Apache.Ignite.Core.Portable;
+ using Apache.Ignite.Core.Tests.Cache;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Data streamer tests.
+ /// </summary>
+ public class DataStreamerTest
+ {
+ /** Node name. */
+ protected const string GridName = "grid";
+
+ /** Cache name. */
+ protected const string CacheName = "partitioned";
+
+ /** Node. */
+ private IIgnite _grid;
+
+ /** Cache. */
+ private ICache<int, int?> _cache;
+
+ /// <summary>
+ /// Initialization routine.
+ /// </summary>
+ [TestFixtureSetUp]
+ public virtual void InitClient()
+ {
+ _grid = Ignition.Start(GetIgniteConfiguration(GridName));
+
+ Ignition.Start(GetIgniteConfiguration(GridName + "_1"));
+
+ _cache = _grid.GetCache<int, int?>(CacheName);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [TestFixtureTearDown]
+ public virtual void StopGrids()
+ {
+ Ignition.StopAll(true);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [SetUp]
+ public virtual void BeforeTest()
+ {
+ Console.WriteLine("Test started: " + TestContext.CurrentContext.Test.Name);
+
+ for (int i = 0; i < 100; i++)
+ _cache.Remove(i);
+ }
+
+ [TearDown]
+ public void AfterTest()
+ {
+ TestUtils.AssertHandleRegistryIsEmpty(_grid, 1000);
+ }
+
+ /// <summary>
+ /// Test data streamer property configuration. Ensures that at least no exceptions are thrown.
+ /// </summary>
+ [Test]
+ public void TestPropertyPropagation()
+ {
+ using (IDataStreamer<int, int> ldr = _grid.GetDataStreamer<int, int>(CacheName))
+ {
+ ldr.AllowOverwrite = true;
+ Assert.IsTrue(ldr.AllowOverwrite);
+ ldr.AllowOverwrite = false;
+ Assert.IsFalse(ldr.AllowOverwrite);
+
+ ldr.SkipStore = true;
+ Assert.IsTrue(ldr.SkipStore);
+ ldr.SkipStore = false;
+ Assert.IsFalse(ldr.SkipStore);
+
+ ldr.PerNodeBufferSize = 1;
+ Assert.AreEqual(1, ldr.PerNodeBufferSize);
+ ldr.PerNodeBufferSize = 2;
+ Assert.AreEqual(2, ldr.PerNodeBufferSize);
+
+ ldr.PerNodeParallelOperations = 1;
+ Assert.AreEqual(1, ldr.PerNodeParallelOperations);
+ ldr.PerNodeParallelOperations = 2;
+ Assert.AreEqual(2, ldr.PerNodeParallelOperations);
+ }
+ }
+
+ /// <summary>
+ /// Test data add/remove.
+ /// </summary>
+ [Test]
+ public void TestAddRemove()
+ {
+ using (IDataStreamer<int, int> ldr = _grid.GetDataStreamer<int, int>(CacheName))
+ {
+ ldr.AllowOverwrite = true;
+
+ // Additions.
+ ldr.AddData(1, 1);
+ ldr.Flush();
+ Assert.AreEqual(1, _cache.Get(1));
+
+ ldr.AddData(new KeyValuePair<int, int>(2, 2));
+ ldr.Flush();
+ Assert.AreEqual(2, _cache.Get(2));
+
+ ldr.AddData(new List<KeyValuePair<int, int>> { new KeyValuePair<int, int>(3, 3), new KeyValuePair<int, int>(4, 4) });
+ ldr.Flush();
+ Assert.AreEqual(3, _cache.Get(3));
+ Assert.AreEqual(4, _cache.Get(4));
+
+ // Removal.
+ ldr.RemoveData(1);
+ ldr.Flush();
+ Assert.IsNull(_cache.Get(1));
+
+ // Mixed.
+ ldr.AddData(5, 5);
+ ldr.RemoveData(2);
+ ldr.AddData(new KeyValuePair<int, int>(7, 7));
+ ldr.AddData(6, 6);
+ ldr.RemoveData(4);
+ ldr.AddData(new List<KeyValuePair<int, int>> { new KeyValuePair<int, int>(9, 9), new KeyValuePair<int, int>(10, 10) });
+ ldr.AddData(new KeyValuePair<int, int>(8, 8));
+ ldr.RemoveData(3);
+ ldr.AddData(new List<KeyValuePair<int, int>> { new KeyValuePair<int, int>(11, 11), new KeyValuePair<int, int>(12, 12) });
+
+ ldr.Flush();
+
+ for (int i = 2; i < 5; i++)
+ Assert.IsNull(_cache.Get(i));
+
+ for (int i = 5; i < 13; i++)
+ Assert.AreEqual(i, _cache.Get(i));
+ }
+ }
+
+ /// <summary>
+ /// Test "tryFlush".
+ /// </summary>
+ [Test]
+ public void TestTryFlush()
+ {
+ using (IDataStreamer<int, int> ldr = _grid.GetDataStreamer<int, int>(CacheName))
+ {
+ var fut = ldr.AddData(1, 1);
+
+ ldr.TryFlush();
+
+ fut.Get();
+
+ Assert.AreEqual(1, _cache.Get(1));
+ }
+ }
+
+ /// <summary>
+ /// Test buffer size adjustments.
+ /// </summary>
+ [Test]
+ public void TestBufferSize()
+ {
+ using (IDataStreamer<int, int> ldr = _grid.GetDataStreamer<int, int>(CacheName))
+ {
+ var fut = ldr.AddData(1, 1);
+
+ Thread.Sleep(100);
+
+ Assert.IsFalse(fut.IsDone);
+
+ ldr.PerNodeBufferSize = 2;
+
+ ldr.AddData(2, 2);
+ ldr.AddData(3, 3);
+ ldr.AddData(4, 4).Get();
+ fut.Get();
+
+ Assert.AreEqual(1, _cache.Get(1));
+ Assert.AreEqual(2, _cache.Get(2));
+ Assert.AreEqual(3, _cache.Get(3));
+ Assert.AreEqual(4, _cache.Get(4));
+
+ ldr.AddData(new List<KeyValuePair<int, int>>
+ {
+ new KeyValuePair<int, int>(5, 5),
+ new KeyValuePair<int, int>(6, 6),
+ new KeyValuePair<int, int>(7, 7),
+ new KeyValuePair<int, int>(8, 8)
+ }).Get();
+
+ Assert.AreEqual(5, _cache.Get(5));
+ Assert.AreEqual(6, _cache.Get(6));
+ Assert.AreEqual(7, _cache.Get(7));
+ Assert.AreEqual(8, _cache.Get(8));
+ }
+ }
+
+ /// <summary>
+ /// Test close.
+ /// </summary>
+ [Test]
+ public void TestClose()
+ {
+ using (IDataStreamer<int, int> ldr = _grid.GetDataStreamer<int, int>(CacheName))
+ {
+ var fut = ldr.AddData(1, 1);
+
+ ldr.Close(false);
+
+ fut.Get();
+
+ Assert.AreEqual(1, _cache.Get(1));
+ }
+ }
+
+ /// <summary>
+ /// Test close with cancellation.
+ /// </summary>
+ [Test]
+ public void TestCancel()
+ {
+ using (IDataStreamer<int, int> ldr = _grid.GetDataStreamer<int, int>(CacheName))
+ {
+ var fut = ldr.AddData(1, 1);
+
+ ldr.Close(true);
+
+ fut.Get();
+
+ Assert.IsNull(_cache.Get(1));
+ }
+ }
+
+ /// <summary>
+ /// Tests that streamer gets collected when there are no references to it.
+ /// </summary>
+ [Test]
+ public void TestFinalizer()
+ {
+ var streamer = _grid.GetDataStreamer<int, int>(CacheName);
+ var streamerRef = new WeakReference(streamer);
+
+ Assert.IsNotNull(streamerRef.Target);
+
+ // ReSharper disable once RedundantAssignment
+ streamer = null;
+
+ GC.Collect();
+ GC.WaitForPendingFinalizers();
+
+ Assert.IsNull(streamerRef.Target);
+ }
+
+ /// <summary>
+ /// Test auto-flush feature.
+ /// </summary>
+ [Test]
+ public void TestAutoFlush()
+ {
+ using (IDataStreamer<int, int> ldr = _grid.GetDataStreamer<int, int>(CacheName))
+ {
+ // Test auto flush turning on.
+ var fut = ldr.AddData(1, 1);
+ Thread.Sleep(100);
+ Assert.IsFalse(fut.IsDone);
+ ldr.AutoFlushFrequency = 1000;
+ fut.Get();
+
+ // Test forced flush after frequency change.
+ fut = ldr.AddData(2, 2);
+ ldr.AutoFlushFrequency = long.MaxValue;
+ fut.Get();
+
+ // Test another forced flush after frequency change.
+ fut = ldr.AddData(3, 3);
+ ldr.AutoFlushFrequency = 1000;
+ fut.Get();
+
+ // Test flush before stop.
+ fut = ldr.AddData(4, 4);
+ ldr.AutoFlushFrequency = 0;
+ fut.Get();
+
+ // Test flush after second turn on.
+ fut = ldr.AddData(5, 5);
+ ldr.AutoFlushFrequency = 1000;
+ fut.Get();
+
+ Assert.AreEqual(1, _cache.Get(1));
+ Assert.AreEqual(2, _cache.Get(2));
+ Assert.AreEqual(3, _cache.Get(3));
+ Assert.AreEqual(4, _cache.Get(4));
+ Assert.AreEqual(5, _cache.Get(5));
+ }
+ }
+
+ /// <summary>
+ /// Test multithreaded behavior.
+ /// </summary>
+ [Test]
+ [Category(TestUtils.CategoryIntensive)]
+ public void TestMultithreaded()
+ {
+ int entriesPerThread = 100000;
+ int threadCnt = 8;
+
+ for (int i = 0; i < 5; i++)
+ {
+ _cache.Clear();
+
+ Assert.AreEqual(0, _cache.GetSize());
+
+ Stopwatch watch = new Stopwatch();
+
+ watch.Start();
+
+ using (IDataStreamer<int, int> ldr = _grid.GetDataStreamer<int, int>(CacheName))
+ {
+ ldr.PerNodeBufferSize = 1024;
+
+ int ctr = 0;
+
+ TestUtils.RunMultiThreaded(() =>
+ {
+ int threadIdx = Interlocked.Increment(ref ctr);
+
+ int startIdx = (threadIdx - 1) * entriesPerThread;
+ int endIdx = startIdx + entriesPerThread;
+
+ for (int j = startIdx; j < endIdx; j++)
+ {
+ // ReSharper disable once AccessToDisposedClosure
+ ldr.AddData(j, j);
+
+ if (j % 100000 == 0)
+ Console.WriteLine("Put [thread=" + threadIdx + ", cnt=" + j + ']');
+ }
+ }, threadCnt);
+ }
+
+ Console.WriteLine("Iteration " + i + ": " + watch.ElapsedMilliseconds);
+
+ watch.Reset();
+
+ for (int j = 0; j < threadCnt * entriesPerThread; j++)
+ Assert.AreEqual(j, j);
+ }
+ }
+
+ /// <summary>
+ /// Tests custom receiver.
+ /// </summary>
+ [Test]
+ public void TestStreamReceiver()
+ {
+ TestStreamReceiver(new StreamReceiverPortable());
+ TestStreamReceiver(new StreamReceiverSerializable());
+ }
+
+ /// <summary>
+ /// Tests StreamVisitor.
+ /// </summary>
+ [Test]
+ public void TestStreamVisitor()
+ {
+ TestStreamReceiver(new StreamVisitor<int, int>((c, e) => c.Put(e.Key, e.Value + 1)));
+ }
+
+ /// <summary>
+ /// Tests StreamTransformer.
+ /// </summary>
+ [Test]
+ public void TestStreamTransformer()
+ {
+ TestStreamReceiver(new StreamTransformer<int, int, int, int>(new EntryProcessorSerializable()));
+ TestStreamReceiver(new StreamTransformer<int, int, int, int>(new EntryProcessorPortable()));
+ }
+
+ /// <summary>
+ /// Tests specified receiver.
+ /// </summary>
+ private void TestStreamReceiver(IStreamReceiver<int, int> receiver)
+ {
+ using (var ldr = _grid.GetDataStreamer<int, int>(CacheName))
+ {
+ ldr.AllowOverwrite = true;
+
+ ldr.Receiver = new StreamReceiverPortable();
+
+ ldr.Receiver = receiver; // check double assignment
+
+ Assert.AreEqual(ldr.Receiver, receiver);
+
+ for (var i = 0; i < 100; i++)
+ ldr.AddData(i, i);
+
+ ldr.Flush();
+
+ for (var i = 0; i < 100; i++)
+ Assert.AreEqual(i + 1, _cache.Get(i));
+ }
+ }
+
+ /// <summary>
+ /// Tests the stream receiver in keepPortable mode.
+ /// </summary>
+ [Test]
+ public void TestStreamReceiverKeepPortable()
+ {
+ // ReSharper disable once LocalVariableHidesMember
+ var cache = _grid.GetCache<int, PortableEntry>(CacheName);
+
+ using (var ldr0 = _grid.GetDataStreamer<int, int>(CacheName))
+ using (var ldr = ldr0.WithKeepPortable<int, IPortableObject>())
+ {
+ ldr.Receiver = new StreamReceiverKeepPortable();
+
+ ldr.AllowOverwrite = true;
+
+ for (var i = 0; i < 100; i++)
+ ldr.AddData(i, _grid.GetPortables().ToPortable<IPortableObject>(new PortableEntry {Val = i}));
+
+ ldr.Flush();
+
+ for (var i = 0; i < 100; i++)
+ Assert.AreEqual(i + 1, cache.Get(i).Val);
+ }
+ }
+
+ /// <summary>
+ /// Gets the Ignite configuration.
+ /// </summary>
+ /// <param name="gridName">Grid name.</param>
+ private static IgniteConfigurationEx GetIgniteConfiguration(string gridName)
+ {
+ return new IgniteConfigurationEx
+ {
+ GridName = gridName,
+ SpringConfigUrl = "config\\native-client-test-cache.xml",
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ PortableConfiguration = new PortableConfiguration
+ {
+ TypeConfigurations = new List<PortableTypeConfiguration>
+ {
+ new PortableTypeConfiguration(typeof (CacheTestKey)),
+ new PortableTypeConfiguration(typeof (TestReferenceObject)),
+ new PortableTypeConfiguration(typeof (StreamReceiverPortable)),
+ new PortableTypeConfiguration(typeof (EntryProcessorPortable)),
+ new PortableTypeConfiguration(typeof (PortableEntry))
+ }
+ },
+ JvmOptions = TestUtils.TestJavaOptions().Concat(new[]
+ {
+ "-Xms3096m",
+ "-Xmx3096m",
+ "-XX:+UseParNewGC",
+ "-XX:+UseConcMarkSweepGC",
+ "-XX:+UseTLAB",
+ "-XX:NewSize=128m",
+ "-XX:MaxNewSize=128m",
+ "-XX:MaxTenuringThreshold=0",
+ "-XX:SurvivorRatio=1024",
+ "-XX:+UseCMSInitiatingOccupancyOnly",
+ "-XX:CMSInitiatingOccupancyFraction=60"
+ }).ToArray()
+ };
+ }
+
+ /// <summary>
+ /// Test portable receiver.
+ /// </summary>
+ private class StreamReceiverPortable : IStreamReceiver<int, int>
+ {
+ /** <inheritdoc /> */
+ public void Receive(ICache<int, int> cache, ICollection<ICacheEntry<int, int>> entries)
+ {
+ cache.PutAll(entries.ToDictionary(x => x.Key, x => x.Value + 1));
+ }
+ }
+
+ /// <summary>
+ /// Test portable receiver.
+ /// </summary>
+ [Serializable]
+ private class StreamReceiverKeepPortable : IStreamReceiver<int, IPortableObject>
+ {
+ /** <inheritdoc /> */
+ public void Receive(ICache<int, IPortableObject> cache, ICollection<ICacheEntry<int, IPortableObject>> entries)
+ {
+ var portables = cache.Ignite.GetPortables();
+
+ cache.PutAll(entries.ToDictionary(x => x.Key, x =>
+ portables.ToPortable<IPortableObject>(new PortableEntry
+ {
+ Val = x.Value.Deserialize<PortableEntry>().Val + 1
+ })));
+ }
+ }
+
+ /// <summary>
+ /// Test serializable receiver.
+ /// </summary>
+ [Serializable]
+ private class StreamReceiverSerializable : IStreamReceiver<int, int>
+ {
+ /** <inheritdoc /> */
+ public void Receive(ICache<int, int> cache, ICollection<ICacheEntry<int, int>> entries)
+ {
+ cache.PutAll(entries.ToDictionary(x => x.Key, x => x.Value + 1));
+ }
+ }
+
+ /// <summary>
+ /// Test entry processor.
+ /// </summary>
+ [Serializable]
+ private class EntryProcessorSerializable : ICacheEntryProcessor<int, int, int, int>
+ {
+ /** <inheritdoc /> */
+ public int Process(IMutableCacheEntry<int, int> entry, int arg)
+ {
+ entry.Value = entry.Key + 1;
+
+ return 0;
+ }
+ }
+
+ /// <summary>
+ /// Test entry processor.
+ /// </summary>
+ private class EntryProcessorPortable : ICacheEntryProcessor<int, int, int, int>, IPortableMarshalAware
+ {
+ /** <inheritdoc /> */
+ public int Process(IMutableCacheEntry<int, int> entry, int arg)
+ {
+ entry.Value = entry.Key + 1;
+
+ return 0;
+ }
+
+ /** <inheritdoc /> */
+ public void WritePortable(IPortableWriter writer)
+ {
+ // No-op.
+ }
+
+ /** <inheritdoc /> */
+ public void ReadPortable(IPortableReader reader)
+ {
+ // No-op.
+ }
+ }
+
+ /// <summary>
+ /// Portablecache entry.
+ /// </summary>
+ private class PortableEntry
+ {
+ public int Val { get; set; }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
new file mode 100644
index 0000000..aa103d4
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
@@ -0,0 +1,961 @@
+/*
+ * 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 System.Threading.Tasks;
+ using Apache.Ignite.Core.Cache.Query;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Events;
+ using Apache.Ignite.Core.Impl;
+ using Apache.Ignite.Core.Impl.Events;
+ using Apache.Ignite.Core.Portable;
+ using Apache.Ignite.Core.Tests.Compute;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// <see cref="IEvents"/> tests.
+ /// </summary>
+ public class EventsTest
+ {
+ /** */
+ private IIgnite _grid1;
+
+ /** */
+ private IIgnite _grid2;
+
+ /** */
+ private IIgnite _grid3;
+
+ /** */
+ private IIgnite[] _grids;
+
+ /** */
+ public static int IdGen;
+
+ [TestFixtureTearDown]
+ public void FixtureTearDown()
+ {
+ StopGrids();
+ }
+
+ /// <summary>
+ /// Executes before each test.
+ /// </summary>
+ [SetUp]
+ public void SetUp()
+ {
+ StartGrids();
+ EventsTestHelper.ListenResult = true;
+ }
+
+ /// <summary>
+ /// Executes after each test.
+ /// </summary>
+ [TearDown]
+ public virtual void TearDown()
+ {
+ try
+ {
+ TestUtils.AssertHandleRegistryIsEmpty(1000, _grid1, _grid2, _grid3);
+ }
+ catch (Exception)
+ {
+ // Restart grids to cleanup
+ StopGrids();
+
+ throw;
+ }
+ finally
+ {
+ EventsTestHelper.AssertFailures();
+
+ if (TestContext.CurrentContext.Test.Name.StartsWith("TestEventTypes"))
+ StopGrids(); // clean events for other tests
+ }
+ }
+
+ /// <summary>
+ /// Tests enable/disable of event types.
+ /// </summary>
+ [Test]
+ public void TestEnableDisable()
+ {
+ var events = _grid1.GetEvents();
+
+ Assert.AreEqual(0, events.GetEnabledEvents().Length);
+
+ Assert.IsFalse(EventType.EvtsCache.Any(events.IsEnabled));
+
+ events.EnableLocal(EventType.EvtsCache);
+
+ Assert.AreEqual(EventType.EvtsCache, events.GetEnabledEvents());
+
+ Assert.IsTrue(EventType.EvtsCache.All(events.IsEnabled));
+
+ events.EnableLocal(EventType.EvtsTaskExecution);
+
+ events.DisableLocal(EventType.EvtsCache);
+
+ Assert.AreEqual(EventType.EvtsTaskExecution, events.GetEnabledEvents());
+ }
+
+ /// <summary>
+ /// Tests LocalListen.
+ /// </summary>
+ [Test]
+ public void TestLocalListen()
+ {
+ var events = _grid1.GetEvents();
+ var listener = EventsTestHelper.GetListener();
+ var eventType = EventType.EvtsTaskExecution;
+
+ events.EnableLocal(eventType);
+
+ events.LocalListen(listener, eventType);
+
+ CheckSend(3); // 3 events per task * 3 grids
+
+ // Check unsubscription for specific event
+ events.StopLocalListen(listener, EventType.EvtTaskReduced);
+
+ CheckSend(2);
+
+ // Unsubscribe from all events
+ events.StopLocalListen(listener);
+
+ CheckNoEvent();
+
+ // Check unsubscription by filter
+ events.LocalListen(listener, EventType.EvtTaskReduced);
+
+ CheckSend();
+
+ EventsTestHelper.ListenResult = false;
+
+ CheckSend(); // one last event will be received for each listener
+
+ CheckNoEvent();
+ }
+
+ /// <summary>
+ /// Tests LocalListen.
+ /// </summary>
+ [Test]
+ [Ignore("IGNITE-879")]
+ public void TestLocalListenRepeatedSubscription()
+ {
+ var events = _grid1.GetEvents();
+ var listener = EventsTestHelper.GetListener();
+ var eventType = EventType.EvtsTaskExecution;
+
+ events.EnableLocal(eventType);
+
+ events.LocalListen(listener, eventType);
+
+ CheckSend(3); // 3 events per task * 3 grids
+
+ events.LocalListen(listener, eventType);
+ events.LocalListen(listener, eventType);
+
+ CheckSend(9);
+
+ events.StopLocalListen(listener, eventType);
+
+ CheckSend(6);
+
+ events.StopLocalListen(listener, eventType);
+
+ CheckSend(3);
+
+ events.StopLocalListen(listener, eventType);
+
+ CheckNoEvent();
+ }
+
+ /// <summary>
+ /// Tests all available event types/classes.
+ /// </summary>
+ [Test, TestCaseSource("TestCases")]
+ public void TestEventTypes(EventTestCase testCase)
+ {
+ var events = _grid1.GetEvents();
+
+ events.EnableLocal(testCase.EventType);
+
+ var listener = EventsTestHelper.GetListener();
+
+ events.LocalListen(listener, testCase.EventType);
+
+ EventsTestHelper.ClearReceived(testCase.EventCount);
+
+ testCase.GenerateEvent(_grid1);
+
+ EventsTestHelper.VerifyReceive(testCase.EventCount, testCase.EventObjectType, testCase.EventType);
+
+ if (testCase.VerifyEvents != null)
+ testCase.VerifyEvents(EventsTestHelper.ReceivedEvents.Reverse(), _grid1);
+
+ // Check stop
+ events.StopLocalListen(listener);
+
+ EventsTestHelper.ClearReceived(0);
+
+ testCase.GenerateEvent(_grid1);
+
+ Thread.Sleep(EventsTestHelper.Timeout);
+ }
+
+ /// <summary>
+ /// Test cases for TestEventTypes: type id + type + event generator.
+ /// </summary>
+ public IEnumerable<EventTestCase> TestCases
+ {
+ get
+ {
+ yield return new EventTestCase
+ {
+ EventType = EventType.EvtsCache,
+ EventObjectType = typeof (CacheEvent),
+ GenerateEvent = g => g.GetCache<int, int>(null).Put(1, 1),
+ VerifyEvents = (e, g) => VerifyCacheEvents(e, g),
+ EventCount = 1
+ };
+
+ yield return new EventTestCase
+ {
+ EventType = EventType.EvtsTaskExecution,
+ EventObjectType = typeof (TaskEvent),
+ GenerateEvent = g => GenerateTaskEvent(g),
+ VerifyEvents = (e, g) => VerifyTaskEvents(e),
+ EventCount = 3
+ };
+
+ yield return new EventTestCase
+ {
+ EventType = EventType.EvtsJobExecution,
+ EventObjectType = typeof (JobEvent),
+ GenerateEvent = g => GenerateTaskEvent(g),
+ EventCount = 9
+ };
+
+ yield return new EventTestCase
+ {
+ EventType = new[] {EventType.EvtCacheQueryExecuted},
+ EventObjectType = typeof (CacheQueryExecutedEvent),
+ GenerateEvent = g => GenerateCacheQueryEvent(g),
+ EventCount = 1
+ };
+
+ yield return new EventTestCase
+ {
+ EventType = new[] { EventType.EvtCacheQueryObjectRead },
+ EventObjectType = typeof (CacheQueryReadEvent),
+ GenerateEvent = g => GenerateCacheQueryEvent(g),
+ EventCount = 1
+ };
+ }
+ }
+
+ /// <summary>
+ /// Tests the LocalQuery.
+ /// </summary>
+ [Test]
+ public void TestLocalQuery()
+ {
+ var events = _grid1.GetEvents();
+
+ var eventType = EventType.EvtsTaskExecution;
+
+ events.EnableLocal(eventType);
+
+ var oldEvents = events.LocalQuery();
+
+ GenerateTaskEvent();
+
+ // "Except" works because of overridden equality
+ var qryResult = events.LocalQuery(eventType).Except(oldEvents).ToList();
+
+ Assert.AreEqual(3, qryResult.Count);
+ }
+
+ /// <summary>
+ /// Tests the WaitForLocal.
+ /// </summary>
+ [Test]
+ public void TestWaitForLocal([Values(true, false)] bool async)
+ {
+ var events = _grid1.GetEvents();
+
+ var timeout = TimeSpan.FromSeconds(3);
+
+ if (async)
+ events = events.WithAsync();
+
+ var eventType = EventType.EvtsTaskExecution;
+
+ events.EnableLocal(eventType);
+
+ Func<Func<IEvent>, Task<IEvent>> getWaitTask;
+
+ if (async)
+ getWaitTask = func =>
+ {
+ Assert.IsNull(func());
+ var task = events.GetFuture<IEvent>().ToTask();
+ GenerateTaskEvent();
+ return task;
+ };
+ else
+ getWaitTask = func =>
+ {
+ var task = Task.Factory.StartNew(func);
+ Thread.Sleep(500); // allow task to start and begin waiting for events
+ GenerateTaskEvent();
+ return task;
+ };
+
+ // No params
+ var waitTask = getWaitTask(() => events.WaitForLocal());
+
+ waitTask.Wait(timeout);
+
+ // Event types
+ waitTask = getWaitTask(() => events.WaitForLocal(EventType.EvtTaskReduced));
+
+ Assert.IsTrue(waitTask.Wait(timeout));
+ Assert.IsInstanceOf(typeof(TaskEvent), waitTask.Result);
+ Assert.AreEqual(EventType.EvtTaskReduced, waitTask.Result.Type);
+
+ // Filter
+ waitTask = getWaitTask(() => events.WaitForLocal(
+ new EventFilter<IEvent>((g, e) => e.Type == EventType.EvtTaskReduced)));
+
+ Assert.IsTrue(waitTask.Wait(timeout));
+ Assert.IsInstanceOf(typeof(TaskEvent), waitTask.Result);
+ Assert.AreEqual(EventType.EvtTaskReduced, waitTask.Result.Type);
+
+ // Filter & types
+ waitTask = getWaitTask(() => events.WaitForLocal(
+ new EventFilter<IEvent>((g, e) => e.Type == EventType.EvtTaskReduced), EventType.EvtTaskReduced));
+
+ Assert.IsTrue(waitTask.Wait(timeout));
+ Assert.IsInstanceOf(typeof(TaskEvent), waitTask.Result);
+ Assert.AreEqual(EventType.EvtTaskReduced, waitTask.Result.Type);
+ }
+
+ /// <summary>
+ /// Tests RemoteListen.
+ /// </summary>
+ [Test]
+ public void TestRemoteListen(
+ [Values(true, false)] bool async,
+ [Values(true, false)] bool portable,
+ [Values(true, false)] bool autoUnsubscribe)
+ {
+ foreach (var g in _grids)
+ {
+ g.GetEvents().EnableLocal(EventType.EvtsJobExecution);
+ g.GetEvents().EnableLocal(EventType.EvtsTaskExecution);
+ }
+
+ var events = _grid1.GetEvents();
+
+ var expectedType = EventType.EvtJobStarted;
+
+ var remoteFilter = portable
+ ? (IEventFilter<IEvent>) new RemoteEventPortableFilter(expectedType)
+ : new RemoteEventFilter(expectedType);
+
+ var localListener = EventsTestHelper.GetListener();
+
+ if (async)
+ events = events.WithAsync();
+
+ var listenId = events.RemoteListen(localListener: localListener, remoteFilter: remoteFilter,
+ autoUnsubscribe: autoUnsubscribe);
+
+ if (async)
+ listenId = events.GetFuture<Guid>().Get();
+
+ CheckSend(3, typeof(JobEvent), expectedType);
+
+ _grid3.GetEvents().DisableLocal(EventType.EvtsJobExecution);
+
+ CheckSend(2, typeof(JobEvent), expectedType);
+
+ events.StopRemoteListen(listenId);
+
+ if (async)
+ events.GetFuture().Get();
+
+ CheckNoEvent();
+
+ // Check unsubscription with listener
+ events.RemoteListen(localListener: localListener, remoteFilter: remoteFilter,
+ autoUnsubscribe: autoUnsubscribe);
+
+ if (async)
+ events.GetFuture<Guid>().Get();
+
+ CheckSend(2, typeof(JobEvent), expectedType);
+
+ EventsTestHelper.ListenResult = false;
+
+ CheckSend(1, typeof(JobEvent), expectedType); // one last event
+
+ CheckNoEvent();
+ }
+
+ /// <summary>
+ /// Tests RemoteQuery.
+ /// </summary>
+ [Test]
+ public void TestRemoteQuery([Values(true, false)] bool async)
+ {
+ foreach (var g in _grids)
+ g.GetEvents().EnableLocal(EventType.EvtsJobExecution);
+
+ var events = _grid1.GetEvents();
+
+ var eventFilter = new RemoteEventFilter(EventType.EvtJobStarted);
+
+ var oldEvents = events.RemoteQuery(eventFilter);
+
+ if (async)
+ events = events.WithAsync();
+
+ GenerateTaskEvent();
+
+ var remoteQuery = events.RemoteQuery(eventFilter, EventsTestHelper.Timeout, EventType.EvtsJobExecution);
+
+ if (async)
+ {
+ Assert.IsNull(remoteQuery);
+
+ remoteQuery = events.GetFuture<List<IEvent>>().Get().ToList();
+ }
+
+ var qryResult = remoteQuery.Except(oldEvents).Cast<JobEvent>().ToList();
+
+ Assert.AreEqual(_grids.Length, qryResult.Count);
+
+ Assert.IsTrue(qryResult.All(x => x.Type == EventType.EvtJobStarted));
+ }
+
+ /// <summary>
+ /// Tests serialization.
+ /// </summary>
+ [Test]
+ public void TestSerialization()
+ {
+ var grid = (Ignite) _grid1;
+ var comp = (Impl.Compute.Compute) grid.GetCluster().ForLocal().GetCompute();
+ var locNode = grid.GetCluster().GetLocalNode();
+
+ var expectedGuid = Guid.Parse("00000000-0000-0001-0000-000000000002");
+ var expectedGridGuid = new IgniteGuid(expectedGuid, 3);
+
+ using (var inStream = IgniteManager.Memory.Allocate().Stream())
+ {
+ var result = comp.ExecuteJavaTask<bool>("org.apache.ignite.platform.PlatformEventsWriteEventTask",
+ inStream.MemoryPointer);
+
+ Assert.IsTrue(result);
+
+ inStream.SynchronizeInput();
+
+ var reader = grid.Marshaller.StartUnmarshal(inStream);
+
+ var cacheEvent = EventReader.Read<CacheEvent>(reader);
+ CheckEventBase(cacheEvent);
+ Assert.AreEqual("cacheName", cacheEvent.CacheName);
+ Assert.AreEqual(locNode, cacheEvent.EventNode);
+ Assert.AreEqual(1, cacheEvent.Partition);
+ Assert.AreEqual(true, cacheEvent.IsNear);
+ Assert.AreEqual(2, cacheEvent.Key);
+ Assert.AreEqual(expectedGridGuid, cacheEvent.Xid);
+ Assert.AreEqual(3, cacheEvent.LockId);
+ Assert.AreEqual(4, cacheEvent.NewValue);
+ Assert.AreEqual(true, cacheEvent.HasNewValue);
+ Assert.AreEqual(5, cacheEvent.OldValue);
+ Assert.AreEqual(true, cacheEvent.HasOldValue);
+ Assert.AreEqual(expectedGuid, cacheEvent.SubjectId);
+ Assert.AreEqual("cloClsName", cacheEvent.ClosureClassName);
+ Assert.AreEqual("taskName", cacheEvent.TaskName);
+
+ var qryExecEvent = EventReader.Read<CacheQueryExecutedEvent>(reader);
+ CheckEventBase(qryExecEvent);
+ Assert.AreEqual("qryType", qryExecEvent.QueryType);
+ Assert.AreEqual("cacheName", qryExecEvent.CacheName);
+ Assert.AreEqual("clsName", qryExecEvent.ClassName);
+ Assert.AreEqual("clause", qryExecEvent.Clause);
+ Assert.AreEqual(expectedGuid, qryExecEvent.SubjectId);
+ Assert.AreEqual("taskName", qryExecEvent.TaskName);
+
+ var qryReadEvent = EventReader.Read<CacheQueryReadEvent>(reader);
+ CheckEventBase(qryReadEvent);
+ Assert.AreEqual("qryType", qryReadEvent.QueryType);
+ Assert.AreEqual("cacheName", qryReadEvent.CacheName);
+ Assert.AreEqual("clsName", qryReadEvent.ClassName);
+ Assert.AreEqual("clause", qryReadEvent.Clause);
+ Assert.AreEqual(expectedGuid, qryReadEvent.SubjectId);
+ Assert.AreEqual("taskName", qryReadEvent.TaskName);
+ Assert.AreEqual(1, qryReadEvent.Key);
+ Assert.AreEqual(2, qryReadEvent.Value);
+ Assert.AreEqual(3, qryReadEvent.OldValue);
+ Assert.AreEqual(4, qryReadEvent.Row);
+
+ var cacheRebalancingEvent = EventReader.Read<CacheRebalancingEvent>(reader);
+ CheckEventBase(cacheRebalancingEvent);
+ Assert.AreEqual("cacheName", cacheRebalancingEvent.CacheName);
+ Assert.AreEqual(1, cacheRebalancingEvent.Partition);
+ Assert.AreEqual(locNode, cacheRebalancingEvent.DiscoveryNode);
+ Assert.AreEqual(2, cacheRebalancingEvent.DiscoveryEventType);
+ Assert.AreEqual(3, cacheRebalancingEvent.DiscoveryTimestamp);
+
+ var checkpointEvent = EventReader.Read<CheckpointEvent>(reader);
+ CheckEventBase(checkpointEvent);
+ Assert.AreEqual("cpKey", checkpointEvent.Key);
+
+ var discoEvent = EventReader.Read<DiscoveryEvent>(reader);
+ CheckEventBase(discoEvent);
+ Assert.AreEqual(grid.TopologyVersion, discoEvent.TopologyVersion);
+ Assert.AreEqual(grid.GetNodes(), discoEvent.TopologyNodes);
+
+ var jobEvent = EventReader.Read<JobEvent>(reader);
+ CheckEventBase(jobEvent);
+ Assert.AreEqual(expectedGridGuid, jobEvent.JobId);
+ Assert.AreEqual("taskClsName", jobEvent.TaskClassName);
+ Assert.AreEqual("taskName", jobEvent.TaskName);
+ Assert.AreEqual(locNode, jobEvent.TaskNode);
+ Assert.AreEqual(expectedGridGuid, jobEvent.TaskSessionId);
+ Assert.AreEqual(expectedGuid, jobEvent.TaskSubjectId);
+
+ var spaceEvent = EventReader.Read<SwapSpaceEvent>(reader);
+ CheckEventBase(spaceEvent);
+ Assert.AreEqual("space", spaceEvent.Space);
+
+ var taskEvent = EventReader.Read<TaskEvent>(reader);
+ CheckEventBase(taskEvent);
+ Assert.AreEqual(true,taskEvent.Internal);
+ Assert.AreEqual(expectedGuid, taskEvent.SubjectId);
+ Assert.AreEqual("taskClsName", taskEvent.TaskClassName);
+ Assert.AreEqual("taskName", taskEvent.TaskName);
+ Assert.AreEqual(expectedGridGuid, taskEvent.TaskSessionId);
+ }
+ }
+
+ /// <summary>
+ /// Checks base event fields serialization.
+ /// </summary>
+ /// <param name="evt">The evt.</param>
+ private void CheckEventBase(IEvent evt)
+ {
+ var locNode = _grid1.GetCluster().GetLocalNode();
+
+ Assert.AreEqual(locNode, evt.Node);
+ Assert.AreEqual("msg", evt.Message);
+ Assert.AreEqual(EventType.EvtSwapSpaceCleared, evt.Type);
+ Assert.IsNotNullOrEmpty(evt.Name);
+ Assert.AreNotEqual(Guid.Empty, evt.Id.GlobalId);
+ Assert.IsTrue((evt.TimeStamp - DateTime.Now).TotalSeconds < 10);
+ }
+
+ /// <summary>
+ /// Sends events in various ways and verifies correct receive.
+ /// </summary>
+ /// <param name="repeat">Expected event count multiplier.</param>
+ /// <param name="eventObjectType">Expected event object type.</param>
+ /// <param name="eventType">Type of the event.</param>
+ private void CheckSend(int repeat = 1, Type eventObjectType = null, params int[] eventType)
+ {
+ EventsTestHelper.ClearReceived(repeat);
+
+ GenerateTaskEvent();
+
+ EventsTestHelper.VerifyReceive(repeat, eventObjectType ?? typeof (TaskEvent),
+ eventType.Any() ? eventType : EventType.EvtsTaskExecution);
+ }
+
+ /// <summary>
+ /// Checks that no event has arrived.
+ /// </summary>
+ private void CheckNoEvent()
+ {
+ // this will result in an exception in case of a event
+ EventsTestHelper.ClearReceived(0);
+
+ GenerateTaskEvent();
+
+ Thread.Sleep(EventsTestHelper.Timeout);
+
+ EventsTestHelper.AssertFailures();
+ }
+
+ /// <summary>
+ /// Gets the Ignite configuration.
+ /// </summary>
+ private static IgniteConfiguration Configuration(string springConfigUrl)
+ {
+ return new IgniteConfiguration
+ {
+ SpringConfigUrl = springConfigUrl,
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = TestUtils.TestJavaOptions(),
+ PortableConfiguration = new PortableConfiguration
+ {
+ TypeConfigurations = new List<PortableTypeConfiguration>
+ {
+ new PortableTypeConfiguration(typeof (RemoteEventPortableFilter))
+ }
+ }
+ };
+ }
+
+ /// <summary>
+ /// Generates the task event.
+ /// </summary>
+ private void GenerateTaskEvent(IIgnite grid = null)
+ {
+ (grid ?? _grid1).GetCompute().Broadcast(new ComputeAction());
+ }
+
+ /// <summary>
+ /// Verifies the task events.
+ /// </summary>
+ private static void VerifyTaskEvents(IEnumerable<IEvent> events)
+ {
+ var e = events.Cast<TaskEvent>().ToArray();
+
+ // started, reduced, finished
+ Assert.AreEqual(
+ new[] {EventType.EvtTaskStarted, EventType.EvtTaskReduced, EventType.EvtTaskFinished},
+ e.Select(x => x.Type).ToArray());
+ }
+
+ /// <summary>
+ /// Generates the cache query event.
+ /// </summary>
+ private static void GenerateCacheQueryEvent(IIgnite g)
+ {
+ var cache = g.GetCache<int, int>(null);
+
+ cache.Clear();
+
+ cache.Put(1, 1);
+
+ cache.Query(new ScanQuery<int, int>()).GetAll();
+ }
+
+ /// <summary>
+ /// Verifies the cache events.
+ /// </summary>
+ private static void VerifyCacheEvents(IEnumerable<IEvent> events, IIgnite grid)
+ {
+ var e = events.Cast<CacheEvent>().ToArray();
+
+ foreach (var cacheEvent in e)
+ {
+ Assert.AreEqual(null, cacheEvent.CacheName);
+ Assert.AreEqual(null, cacheEvent.ClosureClassName);
+ Assert.AreEqual(null, cacheEvent.TaskName);
+ Assert.AreEqual(grid.GetCluster().GetLocalNode(), cacheEvent.EventNode);
+ Assert.AreEqual(grid.GetCluster().GetLocalNode(), cacheEvent.Node);
+
+ Assert.AreEqual(false, cacheEvent.HasOldValue);
+ Assert.AreEqual(null, cacheEvent.OldValue);
+
+ if (cacheEvent.Type == EventType.EvtCacheObjectPut)
+ {
+ Assert.AreEqual(true, cacheEvent.HasNewValue);
+ Assert.AreEqual(1, cacheEvent.NewValue);
+ }
+ else if (cacheEvent.Type == EventType.EvtCacheEntryCreated)
+ {
+ Assert.AreEqual(false, cacheEvent.HasNewValue);
+ Assert.AreEqual(null, cacheEvent.NewValue);
+ }
+ else
+ {
+ Assert.Fail("Unexpected event type");
+ }
+ }
+ }
+
+ /// <summary>
+ /// Starts the grids.
+ /// </summary>
+ private void StartGrids()
+ {
+ if (_grid1 != null)
+ return;
+
+ _grid1 = Ignition.Start(Configuration("config\\compute\\compute-grid1.xml"));
+ _grid2 = Ignition.Start(Configuration("config\\compute\\compute-grid2.xml"));
+ _grid3 = Ignition.Start(Configuration("config\\compute\\compute-grid3.xml"));
+
+ _grids = new[] {_grid1, _grid2, _grid3};
+ }
+
+ /// <summary>
+ /// Stops the grids.
+ /// </summary>
+ private void StopGrids()
+ {
+ _grid1 = _grid2 = _grid3 = null;
+ _grids = null;
+
+ Ignition.StopAll(true);
+ }
+ }
+
+ /// <summary>
+ /// Event test helper class.
+ /// </summary>
+ [Serializable]
+ public static class EventsTestHelper
+ {
+ /** */
+ public static readonly ConcurrentStack<IEvent> ReceivedEvents = new ConcurrentStack<IEvent>();
+
+ /** */
+ public static readonly ConcurrentStack<string> Failures = new ConcurrentStack<string>();
+
+ /** */
+ public static readonly CountdownEvent ReceivedEvent = new CountdownEvent(0);
+
+ /** */
+ public static readonly ConcurrentStack<Guid> LastNodeIds = new ConcurrentStack<Guid>();
+
+ /** */
+ public static volatile bool ListenResult = true;
+
+ /** */
+ public static readonly TimeSpan Timeout = TimeSpan.FromMilliseconds(800);
+
+ /// <summary>
+ /// Clears received event information.
+ /// </summary>
+ /// <param name="expectedCount">The expected count of events to be received.</param>
+ public static void ClearReceived(int expectedCount)
+ {
+ ReceivedEvents.Clear();
+ ReceivedEvent.Reset(expectedCount);
+ LastNodeIds.Clear();
+ }
+
+ /// <summary>
+ /// Verifies received events against events events.
+ /// </summary>
+ public static void VerifyReceive(int count, Type eventObjectType, params int[] eventTypes)
+ {
+ // check if expected event count has been received; Wait returns false if there were none.
+ Assert.IsTrue(ReceivedEvent.Wait(Timeout),
+ "Failed to receive expected number of events. Remaining count: " + ReceivedEvent.CurrentCount);
+
+ Assert.AreEqual(count, ReceivedEvents.Count);
+
+ Assert.IsTrue(ReceivedEvents.All(x => x.GetType() == eventObjectType));
+
+ Assert.IsTrue(ReceivedEvents.All(x => eventTypes.Contains(x.Type)));
+
+ AssertFailures();
+ }
+
+ /// <summary>
+ /// Gets the event listener.
+ /// </summary>
+ /// <returns>New instance of event listener.</returns>
+ public static IEventFilter<IEvent> GetListener()
+ {
+ return new EventFilter<IEvent>(Listen);
+ }
+
+ /// <summary>
+ /// Combines accumulated failures and throws an assertion, if there are any.
+ /// Clears accumulated failures.
+ /// </summary>
+ public static void AssertFailures()
+ {
+ try
+ {
+ if (Failures.Any())
+ Assert.Fail(Failures.Reverse().Aggregate((x, y) => string.Format("{0}\n{1}", x, y)));
+ }
+ finally
+ {
+ Failures.Clear();
+ }
+ }
+
+ /// <summary>
+ /// Listen method.
+ /// </summary>
+ /// <param name="id">Originating node ID.</param>
+ /// <param name="evt">Event.</param>
+ private static bool Listen(Guid id, IEvent evt)
+ {
+ try
+ {
+ LastNodeIds.Push(id);
+ ReceivedEvents.Push(evt);
+
+ ReceivedEvent.Signal();
+
+ return ListenResult;
+ }
+ catch (Exception ex)
+ {
+ // When executed on remote nodes, these exceptions will not go to sender,
+ // so we have to accumulate them.
+ Failures.Push(string.Format("Exception in Listen (msg: {0}, id: {1}): {2}", evt, id, ex));
+ throw;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Test event filter.
+ /// </summary>
+ [Serializable]
+ public class EventFilter<T> : IEventFilter<T> where T : IEvent
+ {
+ /** */
+ private readonly Func<Guid, T, bool> _invoke;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="RemoteListenEventFilter"/> class.
+ /// </summary>
+ /// <param name="invoke">The invoke delegate.</param>
+ public EventFilter(Func<Guid, T, bool> invoke)
+ {
+ _invoke = invoke;
+ }
+
+ /** <inheritdoc /> */
+ bool IEventFilter<T>.Invoke(Guid nodeId, T evt)
+ {
+ return _invoke(nodeId, evt);
+ }
+
+ /** <inheritdoc /> */
+ public bool Invoke(Guid nodeId, T evt)
+ {
+ throw new Exception("Invalid method");
+ }
+ }
+
+ /// <summary>
+ /// Remote event filter.
+ /// </summary>
+ [Serializable]
+ public class RemoteEventFilter : IEventFilter<IEvent>
+ {
+ /** */
+ private readonly int _type;
+
+ public RemoteEventFilter(int type)
+ {
+ _type = type;
+ }
+
+ /** <inheritdoc /> */
+ public bool Invoke(Guid nodeId, IEvent evt)
+ {
+ return evt.Type == _type;
+ }
+ }
+
+ /// <summary>
+ /// Portable remote event filter.
+ /// </summary>
+ public class RemoteEventPortableFilter : IEventFilter<IEvent>, IPortableMarshalAware
+ {
+ /** */
+ private int _type;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="RemoteEventPortableFilter"/> class.
+ /// </summary>
+ /// <param name="type">The event type.</param>
+ public RemoteEventPortableFilter(int type)
+ {
+ _type = type;
+ }
+
+ /** <inheritdoc /> */
+ public bool Invoke(Guid nodeId, IEvent evt)
+ {
+ return evt.Type == _type;
+ }
+
+ /** <inheritdoc /> */
+ public void WritePortable(IPortableWriter writer)
+ {
+ writer.RawWriter().WriteInt(_type);
+ }
+
+ /** <inheritdoc /> */
+ public void ReadPortable(IPortableReader reader)
+ {
+ _type = reader.RawReader().ReadInt();
+ }
+ }
+
+ /// <summary>
+ /// Event test case.
+ /// </summary>
+ public class EventTestCase
+ {
+ /// <summary>
+ /// Gets or sets the type of the event.
+ /// </summary>
+ public int[] EventType { get; set; }
+
+ /// <summary>
+ /// Gets or sets the type of the event object.
+ /// </summary>
+ public Type EventObjectType { get; set; }
+
+ /// <summary>
+ /// Gets or sets the generate event action.
+ /// </summary>
+ public Action<IIgnite> GenerateEvent { get; set; }
+
+ /// <summary>
+ /// Gets or sets the verify events action.
+ /// </summary>
+ public Action<IEnumerable<IEvent>, IIgnite> VerifyEvents { get; set; }
+
+ /// <summary>
+ /// Gets or sets the event count.
+ /// </summary>
+ public int EventCount { get; set; }
+
+ /** <inheritdoc /> */
+ public override string ToString()
+ {
+ return EventObjectType.ToString();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Examples/Example.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Examples/Example.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Examples/Example.cs
new file mode 100644
index 0000000..edb04cb
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Examples/Example.cs
@@ -0,0 +1,137 @@
+/*
+ * 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.Examples
+{
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
+ using System.Linq;
+ using System.Text.RegularExpressions;
+ using Apache.Ignite.Examples.Compute;
+ using Apache.Ignite.ExamplesDll.Compute;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Represents an Example to be tested.
+ /// </summary>
+ public class Example
+ {
+ /** All examples */
+ private static readonly Example[] Examples = GetExamples().ToArray();
+
+ /** Execute action */
+ private Action _runAction;
+
+ /** Config url */
+ public string SpringConfigUrl { get; private set; }
+
+ /** Source path */
+ public string SourceFilePath { get; private set; }
+
+ /** Dll load flag */
+ public bool NeedsTestDll { get; private set; }
+
+ /** Name */
+ public string Name { get; private set; }
+
+ /// <summary>
+ /// Runs this example.
+ /// </summary>
+ public void Run()
+ {
+ try
+ {
+ _runAction();
+ }
+ catch (InvalidOperationException ex)
+ {
+ // Each example has a ReadKey at the end, which throws an exception in test environment.
+ if (ex.Message != "Cannot read keys when either application does not have a console or " +
+ "when console input has been redirected from a file. Try Console.Read.")
+ throw;
+ }
+ }
+
+ /// <summary>
+ /// Gets all examples.
+ /// </summary>
+ public static IEnumerable<Example> All
+ {
+ get { return Examples; }
+ }
+
+ /// <summary>
+ /// Gets all examples.
+ /// </summary>
+ private static IEnumerable<Example> GetExamples()
+ {
+ var examplesAsm = typeof (ClosureExample).Assembly;
+
+ var sourceFiles = Directory.GetFiles(PathUtil.ExamplesSourcePath, "*.cs", SearchOption.AllDirectories);
+
+ Assert.IsTrue(sourceFiles.Any());
+
+ var types = examplesAsm.GetTypes().Where(x => x.GetMethod("Main") != null).ToArray();
+
+ Assert.IsTrue(types.Any());
+
+ var examplesDllName = typeof(AverageSalaryJob).Assembly.GetName().Name;
+
+ foreach (var type in types)
+ {
+ var sourceFile = sourceFiles.Single(x => x.EndsWith(string.Format("\\{0}.cs", type.Name)));
+
+ var sourceCode = File.ReadAllText(sourceFile);
+
+ yield return new Example
+ {
+ SourceFilePath = sourceFile,
+ SpringConfigUrl = PathUtil.GetFullConfigPath(GetSpringConfigUrl(sourceCode)),
+ NeedsTestDll = sourceCode.Contains(examplesDllName),
+ _runAction = GetRunAction(type),
+ Name = type.Name
+ };
+ }
+ }
+
+ /// <summary>
+ /// Gets the run action.
+ /// </summary>
+ private static Action GetRunAction(Type type)
+ {
+ return (Action) Delegate.CreateDelegate(typeof (Action), type.GetMethod("Main"));
+ }
+
+ /// <summary>
+ /// Gets the spring configuration URL.
+ /// </summary>
+ private static string GetSpringConfigUrl(string code)
+ {
+ var match = Regex.Match(code, "-springConfigUrl=(.*?.xml)");
+
+ return match.Success ? match.Groups[1].Value : null;
+ }
+
+ /** <inheritdoc /> */
+ public override string ToString()
+ {
+ // This will be displayed in TeamCity and R# test runner
+ return Name;
+ }
+ }
+}
\ No newline at end of file
[14/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
deleted file mode 100644
index b9a9936..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
+++ /dev/null
@@ -1,1787 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// ReSharper disable UnassignedField.Global
-// ReSharper disable CollectionNeverUpdated.Global
-namespace Apache.Ignite.Core.Tests.Portable
-{
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using Apache.Ignite.Core.Impl;
- using Apache.Ignite.Core.Impl.Portable;
- using Apache.Ignite.Core.Portable;
- using NUnit.Framework;
-
- /// <summary>
- /// Portable builder self test.
- /// </summary>
- public class PortableApiSelfTest
- {
- /** Undefined type: Empty. */
- private const string TypeEmpty = "EmptyUndefined";
-
- /** Grid. */
- private Ignite _grid;
-
- /** Marshaller. */
- private PortableMarshaller _marsh;
-
- /// <summary>
- /// Set up routine.
- /// </summary>
- [TestFixtureSetUp]
- public void SetUp()
- {
- TestUtils.KillProcesses();
-
- var cfg = new IgniteConfiguration
- {
- PortableConfiguration = new PortableConfiguration
- {
- TypeConfigurations = new List<PortableTypeConfiguration>
- {
- new PortableTypeConfiguration(typeof (Empty)),
- new PortableTypeConfiguration(typeof (Primitives)),
- new PortableTypeConfiguration(typeof (PrimitiveArrays)),
- new PortableTypeConfiguration(typeof (StringDateGuidEnum)),
- new PortableTypeConfiguration(typeof (WithRaw)),
- new PortableTypeConfiguration(typeof (MetaOverwrite)),
- new PortableTypeConfiguration(typeof (NestedOuter)),
- new PortableTypeConfiguration(typeof (NestedInner)),
- new PortableTypeConfiguration(typeof (MigrationOuter)),
- new PortableTypeConfiguration(typeof (MigrationInner)),
- new PortableTypeConfiguration(typeof (InversionOuter)),
- new PortableTypeConfiguration(typeof (InversionInner)),
- new PortableTypeConfiguration(typeof (CompositeOuter)),
- new PortableTypeConfiguration(typeof (CompositeInner)),
- new PortableTypeConfiguration(typeof (CompositeArray)),
- new PortableTypeConfiguration(typeof (CompositeContainer)),
- new PortableTypeConfiguration(typeof (ToPortable)),
- new PortableTypeConfiguration(typeof (Remove)),
- new PortableTypeConfiguration(typeof (RemoveInner)),
- new PortableTypeConfiguration(typeof (BuilderInBuilderOuter)),
- new PortableTypeConfiguration(typeof (BuilderInBuilderInner)),
- new PortableTypeConfiguration(typeof (BuilderCollection)),
- new PortableTypeConfiguration(typeof (BuilderCollectionItem)),
- new PortableTypeConfiguration(typeof (DecimalHolder)),
- new PortableTypeConfiguration(TypeEmpty),
- TypeConfigurationNoMeta(typeof (EmptyNoMeta)),
- TypeConfigurationNoMeta(typeof (ToPortableNoMeta))
- },
- DefaultIdMapper = new IdMapper()
- },
- JvmClasspath = TestUtils.CreateTestClasspath(),
- JvmOptions = new List<string>
- {
- "-ea",
- "-Xcheck:jni",
- "-Xms4g",
- "-Xmx4g",
- "-DIGNITE_QUIET=false",
- "-Xnoagent",
- "-Djava.compiler=NONE",
- "-Xdebug",
- "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005",
- "-XX:+HeapDumpOnOutOfMemoryError"
- },
- SpringConfigUrl = "config\\portable.xml"
- };
-
- _grid = (Ignite) Ignition.Start(cfg);
-
- _marsh = _grid.Marshaller;
- }
-
- /// <summary>
- /// Tear down routine.
- /// </summary>
- [TestFixtureTearDown]
- public virtual void TearDown()
- {
- if (_grid != null)
- Ignition.Stop(_grid.Name, true);
-
- _grid = null;
- }
-
- /// <summary>
- /// Ensure that portable engine is able to work with type names, which are not configured.
- /// </summary>
- [Test]
- public void TestNonConfigured()
- {
- string typeName1 = "Type1";
- string typeName2 = "Type2";
- string field1 = "field1";
- string field2 = "field2";
-
- // 1. Ensure that builder works fine.
- IPortableObject portObj1 = _grid.GetPortables().GetBuilder(typeName1).SetField(field1, 1).Build();
-
- Assert.AreEqual(typeName1, portObj1.GetMetadata().TypeName);
- Assert.AreEqual(1, portObj1.GetMetadata().Fields.Count);
- Assert.AreEqual(field1, portObj1.GetMetadata().Fields.First());
- Assert.AreEqual(PortableTypeNames.TypeNameInt, portObj1.GetMetadata().GetFieldTypeName(field1));
-
- Assert.AreEqual(1, portObj1.GetField<int>(field1));
-
- // 2. Ensure that object can be unmarshalled without deserialization.
- byte[] data = ((PortableUserObject) portObj1).Data;
-
- portObj1 = _grid.Marshaller.Unmarshal<IPortableObject>(data, PortableMode.ForcePortable);
-
- Assert.AreEqual(typeName1, portObj1.GetMetadata().TypeName);
- Assert.AreEqual(1, portObj1.GetMetadata().Fields.Count);
- Assert.AreEqual(field1, portObj1.GetMetadata().Fields.First());
- Assert.AreEqual(PortableTypeNames.TypeNameInt, portObj1.GetMetadata().GetFieldTypeName(field1));
-
- Assert.AreEqual(1, portObj1.GetField<int>(field1));
-
- // 3. Ensure that we can nest one anonymous object inside another
- IPortableObject portObj2 =
- _grid.GetPortables().GetBuilder(typeName2).SetField(field2, portObj1).Build();
-
- Assert.AreEqual(typeName2, portObj2.GetMetadata().TypeName);
- Assert.AreEqual(1, portObj2.GetMetadata().Fields.Count);
- Assert.AreEqual(field2, portObj2.GetMetadata().Fields.First());
- Assert.AreEqual(PortableTypeNames.TypeNameObject, portObj2.GetMetadata().GetFieldTypeName(field2));
-
- portObj1 = portObj2.GetField<IPortableObject>(field2);
-
- Assert.AreEqual(typeName1, portObj1.GetMetadata().TypeName);
- Assert.AreEqual(1, portObj1.GetMetadata().Fields.Count);
- Assert.AreEqual(field1, portObj1.GetMetadata().Fields.First());
- Assert.AreEqual(PortableTypeNames.TypeNameInt, portObj1.GetMetadata().GetFieldTypeName(field1));
-
- Assert.AreEqual(1, portObj1.GetField<int>(field1));
-
- // 4. Ensure that we can unmarshal object with other nested object.
- data = ((PortableUserObject) portObj2).Data;
-
- portObj2 = _grid.Marshaller.Unmarshal<IPortableObject>(data, PortableMode.ForcePortable);
-
- Assert.AreEqual(typeName2, portObj2.GetMetadata().TypeName);
- Assert.AreEqual(1, portObj2.GetMetadata().Fields.Count);
- Assert.AreEqual(field2, portObj2.GetMetadata().Fields.First());
- Assert.AreEqual(PortableTypeNames.TypeNameObject, portObj2.GetMetadata().GetFieldTypeName(field2));
-
- portObj1 = portObj2.GetField<IPortableObject>(field2);
-
- Assert.AreEqual(typeName1, portObj1.GetMetadata().TypeName);
- Assert.AreEqual(1, portObj1.GetMetadata().Fields.Count);
- Assert.AreEqual(field1, portObj1.GetMetadata().Fields.First());
- Assert.AreEqual(PortableTypeNames.TypeNameInt, portObj1.GetMetadata().GetFieldTypeName(field1));
-
- Assert.AreEqual(1, portObj1.GetField<int>(field1));
- }
-
- /// <summary>
- /// Test "ToPortable()" method.
- /// </summary>
- [Test]
- public void TestToPortable()
- {
- DateTime date = DateTime.Now.ToUniversalTime();
- Guid guid = Guid.NewGuid();
-
- IPortables api = _grid.GetPortables();
-
- // 1. Primitives.
- Assert.AreEqual(1, api.ToPortable<byte>((byte)1));
- Assert.AreEqual(1, api.ToPortable<short>((short)1));
- Assert.AreEqual(1, api.ToPortable<int>(1));
- Assert.AreEqual(1, api.ToPortable<long>((long)1));
-
- Assert.AreEqual((float)1, api.ToPortable<float>((float)1));
- Assert.AreEqual((double)1, api.ToPortable<double>((double)1));
-
- Assert.AreEqual(true, api.ToPortable<bool>(true));
- Assert.AreEqual('a', api.ToPortable<char>('a'));
-
- // 2. Special types.
- Assert.AreEqual("a", api.ToPortable<string>("a"));
- Assert.AreEqual(date, api.ToPortable<DateTime>(date));
- Assert.AreEqual(guid, api.ToPortable<Guid>(guid));
- Assert.AreEqual(TestEnum.One, api.ToPortable<TestEnum>(TestEnum.One));
-
- // 3. Arrays.
- Assert.AreEqual(new byte[] { 1 }, api.ToPortable<byte[]>(new byte[] { 1 }));
- Assert.AreEqual(new short[] { 1 }, api.ToPortable<short[]>(new short[] { 1 }));
- Assert.AreEqual(new[] { 1 }, api.ToPortable<int[]>(new[] { 1 }));
- Assert.AreEqual(new long[] { 1 }, api.ToPortable<long[]>(new long[] { 1 }));
-
- Assert.AreEqual(new float[] { 1 }, api.ToPortable<float[]>(new float[] { 1 }));
- Assert.AreEqual(new double[] { 1 }, api.ToPortable<double[]>(new double[] { 1 }));
-
- Assert.AreEqual(new[] { true }, api.ToPortable<bool[]>(new[] { true }));
- Assert.AreEqual(new[] { 'a' }, api.ToPortable<char[]>(new[] { 'a' }));
-
- Assert.AreEqual(new[] { "a" }, api.ToPortable<string[]>(new[] { "a" }));
- Assert.AreEqual(new[] { date }, api.ToPortable<DateTime[]>(new[] { date }));
- Assert.AreEqual(new[] { guid }, api.ToPortable<Guid[]>(new[] { guid }));
- Assert.AreEqual(new[] { TestEnum.One }, api.ToPortable<TestEnum[]>(new[] { TestEnum.One }));
-
- // 4. Objects.
- IPortableObject portObj = api.ToPortable<IPortableObject>(new ToPortable(1));
-
- Assert.AreEqual(typeof(ToPortable).Name, portObj.GetMetadata().TypeName);
- Assert.AreEqual(1, portObj.GetMetadata().Fields.Count);
- Assert.AreEqual("Val", portObj.GetMetadata().Fields.First());
- Assert.AreEqual(PortableTypeNames.TypeNameInt, portObj.GetMetadata().GetFieldTypeName("Val"));
-
- Assert.AreEqual(1, portObj.GetField<int>("val"));
- Assert.AreEqual(1, portObj.Deserialize<ToPortable>().Val);
-
- portObj = api.ToPortable<IPortableObject>(new ToPortableNoMeta(1));
-
- Assert.AreEqual(0, portObj.GetMetadata().Fields.Count);
-
- Assert.AreEqual(1, portObj.GetField<int>("Val"));
- Assert.AreEqual(1, portObj.Deserialize<ToPortableNoMeta>().Val);
-
- // 5. Object array.
- IPortableObject[] portObjArr = api.ToPortable<IPortableObject[]>(new[] { new ToPortable(1) });
-
- Assert.AreEqual(1, portObjArr.Length);
- Assert.AreEqual(1, portObjArr[0].GetField<int>("Val"));
- Assert.AreEqual(1, portObjArr[0].Deserialize<ToPortable>().Val);
- }
-
- /// <summary>
- /// Test builder field remove logic.
- /// </summary>
- [Test]
- public void TestRemove()
- {
- // Create empty object.
- IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(Remove)).Build();
-
- Assert.IsNull(portObj.GetField<object>("val"));
- Assert.IsNull(portObj.Deserialize<Remove>().Val);
-
- IPortableMetadata meta = portObj.GetMetadata();
-
- Assert.AreEqual(typeof(Remove).Name, meta.TypeName);
- Assert.AreEqual(0, meta.Fields.Count);
-
- // Populate it with field.
- IPortableBuilder builder = _grid.GetPortables().GetBuilder(portObj);
-
- Assert.IsNull(builder.GetField<object>("val"));
-
- object val = 1;
-
- builder.SetField("val", val);
-
- Assert.AreEqual(val, builder.GetField<object>("val"));
-
- portObj = builder.Build();
-
- Assert.AreEqual(val, portObj.GetField<object>("val"));
- Assert.AreEqual(val, portObj.Deserialize<Remove>().Val);
-
- meta = portObj.GetMetadata();
-
- Assert.AreEqual(typeof(Remove).Name, meta.TypeName);
- Assert.AreEqual(1, meta.Fields.Count);
- Assert.AreEqual("val", meta.Fields.First());
- Assert.AreEqual(PortableTypeNames.TypeNameObject, meta.GetFieldTypeName("val"));
-
- // Perform field remove.
- builder = _grid.GetPortables().GetBuilder(portObj);
-
- Assert.AreEqual(val, builder.GetField<object>("val"));
-
- builder.RemoveField("val");
- Assert.IsNull(builder.GetField<object>("val"));
-
- builder.SetField("val", val);
- Assert.AreEqual(val, builder.GetField<object>("val"));
-
- builder.RemoveField("val");
- Assert.IsNull(builder.GetField<object>("val"));
-
- portObj = builder.Build();
-
- Assert.IsNull(portObj.GetField<object>("val"));
- Assert.IsNull(portObj.Deserialize<Remove>().Val);
-
- // Test correct removal of field being referenced by handle somewhere else.
- RemoveInner inner = new RemoveInner(2);
-
- portObj = _grid.GetPortables().GetBuilder(typeof(Remove))
- .SetField("val", inner)
- .SetField("val2", inner)
- .Build();
-
- portObj = _grid.GetPortables().GetBuilder(portObj).RemoveField("val").Build();
-
- Remove obj = portObj.Deserialize<Remove>();
-
- Assert.IsNull(obj.Val);
- Assert.AreEqual(2, obj.Val2.Val);
- }
-
- /// <summary>
- /// Test builder-in-builder scenario.
- /// </summary>
- [Test]
- public void TestBuilderInBuilder()
- {
- // Test different builders assembly.
- IPortableBuilder builderOuter = _grid.GetPortables().GetBuilder(typeof(BuilderInBuilderOuter));
- IPortableBuilder builderInner = _grid.GetPortables().GetBuilder(typeof(BuilderInBuilderInner));
-
- builderOuter.SetField<object>("inner", builderInner);
- builderInner.SetField<object>("outer", builderOuter);
-
- IPortableObject outerPortObj = builderOuter.Build();
-
- IPortableMetadata meta = outerPortObj.GetMetadata();
-
- Assert.AreEqual(typeof(BuilderInBuilderOuter).Name, meta.TypeName);
- Assert.AreEqual(1, meta.Fields.Count);
- Assert.AreEqual("inner", meta.Fields.First());
- Assert.AreEqual(PortableTypeNames.TypeNameObject, meta.GetFieldTypeName("inner"));
-
- IPortableObject innerPortObj = outerPortObj.GetField<IPortableObject>("inner");
-
- meta = innerPortObj.GetMetadata();
-
- Assert.AreEqual(typeof(BuilderInBuilderInner).Name, meta.TypeName);
- Assert.AreEqual(1, meta.Fields.Count);
- Assert.AreEqual("outer", meta.Fields.First());
- Assert.AreEqual(PortableTypeNames.TypeNameObject, meta.GetFieldTypeName("outer"));
-
- BuilderInBuilderOuter outer = outerPortObj.Deserialize<BuilderInBuilderOuter>();
-
- Assert.AreSame(outer, outer.Inner.Outer);
-
- // Test same builders assembly.
- innerPortObj = _grid.GetPortables().GetBuilder(typeof(BuilderInBuilderInner)).Build();
-
- outerPortObj = _grid.GetPortables().GetBuilder(typeof(BuilderInBuilderOuter))
- .SetField("inner", innerPortObj)
- .SetField("inner2", innerPortObj)
- .Build();
-
- meta = outerPortObj.GetMetadata();
-
- Assert.AreEqual(typeof(BuilderInBuilderOuter).Name, meta.TypeName);
- Assert.AreEqual(2, meta.Fields.Count);
- Assert.IsTrue(meta.Fields.Contains("inner"));
- Assert.IsTrue(meta.Fields.Contains("inner2"));
- Assert.AreEqual(PortableTypeNames.TypeNameObject, meta.GetFieldTypeName("inner"));
- Assert.AreEqual(PortableTypeNames.TypeNameObject, meta.GetFieldTypeName("inner2"));
-
- outer = outerPortObj.Deserialize<BuilderInBuilderOuter>();
-
- Assert.AreSame(outer.Inner, outer.Inner2);
-
- builderOuter = _grid.GetPortables().GetBuilder(outerPortObj);
- IPortableBuilder builderInner2 = builderOuter.GetField<IPortableBuilder>("inner2");
-
- builderInner2.SetField("outer", builderOuter);
-
- outerPortObj = builderOuter.Build();
-
- outer = outerPortObj.Deserialize<BuilderInBuilderOuter>();
-
- Assert.AreSame(outer, outer.Inner.Outer);
- Assert.AreSame(outer.Inner, outer.Inner2);
- }
-
- /// <summary>
- /// Test for decimals building.
- /// </summary>
- [Test]
- public void TestDecimals()
- {
- IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(DecimalHolder))
- .SetField("val", decimal.One)
- .SetField("valArr", new[] { decimal.MinusOne })
- .Build();
-
- IPortableMetadata meta = portObj.GetMetadata();
-
- Assert.AreEqual(typeof(DecimalHolder).Name, meta.TypeName);
- Assert.AreEqual(2, meta.Fields.Count);
- Assert.IsTrue(meta.Fields.Contains("val"));
- Assert.IsTrue(meta.Fields.Contains("valArr"));
- Assert.AreEqual(PortableTypeNames.TypeNameDecimal, meta.GetFieldTypeName("val"));
- Assert.AreEqual(PortableTypeNames.TypeNameArrayDecimal, meta.GetFieldTypeName("valArr"));
-
- Assert.AreEqual(decimal.One, portObj.GetField<decimal>("val"));
- Assert.AreEqual(new[] { decimal.MinusOne }, portObj.GetField<decimal[]>("valArr"));
-
- DecimalHolder obj = portObj.Deserialize<DecimalHolder>();
-
- Assert.AreEqual(decimal.One, obj.Val);
- Assert.AreEqual(new[] { decimal.MinusOne }, obj.ValArr);
- }
-
- /// <summary>
- /// Test for an object returning collection of builders.
- /// </summary>
- [Test]
- public void TestBuilderCollection()
- {
- // Test collection with single element.
- IPortableBuilder builderCol = _grid.GetPortables().GetBuilder(typeof(BuilderCollection));
- IPortableBuilder builderItem =
- _grid.GetPortables().GetBuilder(typeof(BuilderCollectionItem)).SetField("val", 1);
-
- builderCol.SetField<ICollection>("col", new List<IPortableBuilder> { builderItem });
-
- IPortableObject portCol = builderCol.Build();
-
- IPortableMetadata meta = portCol.GetMetadata();
-
- Assert.AreEqual(typeof(BuilderCollection).Name, meta.TypeName);
- Assert.AreEqual(1, meta.Fields.Count);
- Assert.AreEqual("col", meta.Fields.First());
- Assert.AreEqual(PortableTypeNames.TypeNameCollection, meta.GetFieldTypeName("col"));
-
- ICollection<IPortableObject> portColItems = portCol.GetField<ICollection<IPortableObject>>("col");
-
- Assert.AreEqual(1, portColItems.Count);
-
- IPortableObject portItem = portColItems.First();
-
- meta = portItem.GetMetadata();
-
- Assert.AreEqual(typeof(BuilderCollectionItem).Name, meta.TypeName);
- Assert.AreEqual(1, meta.Fields.Count);
- Assert.AreEqual("val", meta.Fields.First());
- Assert.AreEqual(PortableTypeNames.TypeNameInt, meta.GetFieldTypeName("val"));
-
- BuilderCollection col = portCol.Deserialize<BuilderCollection>();
-
- Assert.IsNotNull(col.Col);
- Assert.AreEqual(1, col.Col.Count);
- Assert.AreEqual(1, col.Col.First().Val);
-
- // Add more portable objects to collection.
- builderCol = _grid.GetPortables().GetBuilder(portCol);
-
- IList builderColItems = builderCol.GetField<IList>("col");
-
- Assert.AreEqual(1, builderColItems.Count);
-
- PortableBuilderImpl builderColItem = (PortableBuilderImpl) builderColItems[0];
-
- builderColItem.SetField("val", 2); // Change nested value.
-
- builderColItems.Add(builderColItem); // Add the same object to check handles.
- builderColItems.Add(builderItem); // Add item from another builder.
- builderColItems.Add(portItem); // Add item in portable form.
-
- portCol = builderCol.Build();
-
- col = portCol.Deserialize<BuilderCollection>();
-
- Assert.AreEqual(4, col.Col.Count);
-
- BuilderCollectionItem item0 = col.Col.ElementAt(0);
- BuilderCollectionItem item1 = col.Col.ElementAt(1);
- BuilderCollectionItem item2 = col.Col.ElementAt(2);
- BuilderCollectionItem item3 = col.Col.ElementAt(3);
-
- Assert.AreEqual(2, item0.Val);
-
- Assert.AreSame(item0, item1);
- Assert.AreNotSame(item0, item2);
- Assert.AreNotSame(item0, item3);
-
- Assert.AreEqual(1, item2.Val);
- Assert.AreEqual(1, item3.Val);
-
- Assert.AreNotSame(item2, item3);
-
- // Test handle update inside collection.
- builderCol = _grid.GetPortables().GetBuilder(portCol);
-
- builderColItems = builderCol.GetField<IList>("col");
-
- ((PortableBuilderImpl) builderColItems[1]).SetField("val", 3);
-
- portCol = builderCol.Build();
-
- col = portCol.Deserialize<BuilderCollection>();
-
- item0 = col.Col.ElementAt(0);
- item1 = col.Col.ElementAt(1);
-
- Assert.AreEqual(3, item0.Val);
- Assert.AreSame(item0, item1);
- }
-
- /// <summary>
- /// Test build of an empty object.
- /// </summary>
- [Test]
- public void TestEmptyDefined()
- {
- IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(Empty)).Build();
-
- Assert.IsNotNull(portObj);
- Assert.AreEqual(0, portObj.GetHashCode());
-
- IPortableMetadata meta = portObj.GetMetadata();
-
- Assert.IsNotNull(meta);
- Assert.AreEqual(typeof(Empty).Name, meta.TypeName);
- Assert.AreEqual(0, meta.Fields.Count);
-
- Empty obj = portObj.Deserialize<Empty>();
-
- Assert.IsNotNull(obj);
- }
-
- /// <summary>
- /// Test build of an empty object with disabled metadata.
- /// </summary>
- [Test]
- public void TestEmptyNoMeta()
- {
- IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(EmptyNoMeta)).Build();
-
- Assert.IsNotNull(portObj);
- Assert.AreEqual(0, portObj.GetHashCode());
-
- EmptyNoMeta obj = portObj.Deserialize<EmptyNoMeta>();
-
- Assert.IsNotNull(obj);
- }
-
- /// <summary>
- /// Test build of an empty undefined object.
- /// </summary>
- [Test]
- public void TestEmptyUndefined()
- {
- IPortableObject portObj = _grid.GetPortables().GetBuilder(TypeEmpty).Build();
-
- Assert.IsNotNull(portObj);
- Assert.AreEqual(0, portObj.GetHashCode());
-
- IPortableMetadata meta = portObj.GetMetadata();
-
- Assert.IsNotNull(meta);
- Assert.AreEqual(TypeEmpty, meta.TypeName);
- Assert.AreEqual(0, meta.Fields.Count);
- }
-
- /// <summary>
- /// Test object rebuild with no changes.
- /// </summary>
- [Test]
- public void TestEmptyRebuild()
- {
- var portObj = (PortableUserObject) _grid.GetPortables().GetBuilder(typeof(EmptyNoMeta)).Build();
-
- PortableUserObject newPortObj = (PortableUserObject) _grid.GetPortables().GetBuilder(portObj).Build();
-
- Assert.AreEqual(portObj.Data, newPortObj.Data);
- }
-
- /// <summary>
- /// Test hash code alteration.
- /// </summary>
- [Test]
- public void TestHashCodeChange()
- {
- IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(EmptyNoMeta)).SetHashCode(100).Build();
-
- Assert.AreEqual(100, portObj.GetHashCode());
- }
-
- /// <summary>
- /// Test primitive fields setting.
- /// </summary>
- [Test]
- public void TestPrimitiveFields()
- {
- IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(Primitives))
- .SetField<byte>("fByte", 1)
- .SetField("fBool", true)
- .SetField<short>("fShort", 2)
- .SetField("fChar", 'a')
- .SetField("fInt", 3)
- .SetField<long>("fLong", 4)
- .SetField<float>("fFloat", 5)
- .SetField<double>("fDouble", 6)
- .SetHashCode(100)
- .Build();
-
- Assert.AreEqual(100, portObj.GetHashCode());
-
- IPortableMetadata meta = portObj.GetMetadata();
-
- Assert.AreEqual(typeof(Primitives).Name, meta.TypeName);
-
- Assert.AreEqual(8, meta.Fields.Count);
-
- Assert.AreEqual(PortableTypeNames.TypeNameByte, meta.GetFieldTypeName("fByte"));
- Assert.AreEqual(PortableTypeNames.TypeNameBool, meta.GetFieldTypeName("fBool"));
- Assert.AreEqual(PortableTypeNames.TypeNameShort, meta.GetFieldTypeName("fShort"));
- Assert.AreEqual(PortableTypeNames.TypeNameChar, meta.GetFieldTypeName("fChar"));
- Assert.AreEqual(PortableTypeNames.TypeNameInt, meta.GetFieldTypeName("fInt"));
- Assert.AreEqual(PortableTypeNames.TypeNameLong, meta.GetFieldTypeName("fLong"));
- Assert.AreEqual(PortableTypeNames.TypeNameFloat, meta.GetFieldTypeName("fFloat"));
- Assert.AreEqual(PortableTypeNames.TypeNameDouble, meta.GetFieldTypeName("fDouble"));
-
- Assert.AreEqual(1, portObj.GetField<byte>("fByte"));
- Assert.AreEqual(true, portObj.GetField<bool>("fBool"));
- Assert.AreEqual(2, portObj.GetField<short>("fShort"));
- Assert.AreEqual('a', portObj.GetField<char>("fChar"));
- Assert.AreEqual(3, portObj.GetField<int>("fInt"));
- Assert.AreEqual(4, portObj.GetField<long>("fLong"));
- Assert.AreEqual(5, portObj.GetField<float>("fFloat"));
- Assert.AreEqual(6, portObj.GetField<double>("fDouble"));
-
- Primitives obj = portObj.Deserialize<Primitives>();
-
- Assert.AreEqual(1, obj.FByte);
- Assert.AreEqual(true, obj.FBool);
- Assert.AreEqual(2, obj.FShort);
- Assert.AreEqual('a', obj.FChar);
- Assert.AreEqual(3, obj.FInt);
- Assert.AreEqual(4, obj.FLong);
- Assert.AreEqual(5, obj.FFloat);
- Assert.AreEqual(6, obj.FDouble);
-
- // Overwrite.
- portObj = _grid.GetPortables().GetBuilder(portObj)
- .SetField<byte>("fByte", 7)
- .SetField("fBool", false)
- .SetField<short>("fShort", 8)
- .SetField("fChar", 'b')
- .SetField("fInt", 9)
- .SetField<long>("fLong", 10)
- .SetField<float>("fFloat", 11)
- .SetField<double>("fDouble", 12)
- .SetHashCode(200)
- .Build();
-
- Assert.AreEqual(200, portObj.GetHashCode());
-
- Assert.AreEqual(7, portObj.GetField<byte>("fByte"));
- Assert.AreEqual(false, portObj.GetField<bool>("fBool"));
- Assert.AreEqual(8, portObj.GetField<short>("fShort"));
- Assert.AreEqual('b', portObj.GetField<char>("fChar"));
- Assert.AreEqual(9, portObj.GetField<int>("fInt"));
- Assert.AreEqual(10, portObj.GetField<long>("fLong"));
- Assert.AreEqual(11, portObj.GetField<float>("fFloat"));
- Assert.AreEqual(12, portObj.GetField<double>("fDouble"));
-
- obj = portObj.Deserialize<Primitives>();
-
- Assert.AreEqual(7, obj.FByte);
- Assert.AreEqual(false, obj.FBool);
- Assert.AreEqual(8, obj.FShort);
- Assert.AreEqual('b', obj.FChar);
- Assert.AreEqual(9, obj.FInt);
- Assert.AreEqual(10, obj.FLong);
- Assert.AreEqual(11, obj.FFloat);
- Assert.AreEqual(12, obj.FDouble);
- }
-
- /// <summary>
- /// Test primitive array fields setting.
- /// </summary>
- [Test]
- public void TestPrimitiveArrayFields()
- {
- IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(PrimitiveArrays))
- .SetField("fByte", new byte[] { 1 })
- .SetField("fBool", new[] { true })
- .SetField("fShort", new short[] { 2 })
- .SetField("fChar", new[] { 'a' })
- .SetField("fInt", new[] { 3 })
- .SetField("fLong", new long[] { 4 })
- .SetField("fFloat", new float[] { 5 })
- .SetField("fDouble", new double[] { 6 })
- .SetHashCode(100)
- .Build();
-
- Assert.AreEqual(100, portObj.GetHashCode());
-
- IPortableMetadata meta = portObj.GetMetadata();
-
- Assert.AreEqual(typeof(PrimitiveArrays).Name, meta.TypeName);
-
- Assert.AreEqual(8, meta.Fields.Count);
-
- Assert.AreEqual(PortableTypeNames.TypeNameArrayByte, meta.GetFieldTypeName("fByte"));
- Assert.AreEqual(PortableTypeNames.TypeNameArrayBool, meta.GetFieldTypeName("fBool"));
- Assert.AreEqual(PortableTypeNames.TypeNameArrayShort, meta.GetFieldTypeName("fShort"));
- Assert.AreEqual(PortableTypeNames.TypeNameArrayChar, meta.GetFieldTypeName("fChar"));
- Assert.AreEqual(PortableTypeNames.TypeNameArrayInt, meta.GetFieldTypeName("fInt"));
- Assert.AreEqual(PortableTypeNames.TypeNameArrayLong, meta.GetFieldTypeName("fLong"));
- Assert.AreEqual(PortableTypeNames.TypeNameArrayFloat, meta.GetFieldTypeName("fFloat"));
- Assert.AreEqual(PortableTypeNames.TypeNameArrayDouble, meta.GetFieldTypeName("fDouble"));
-
- Assert.AreEqual(new byte[] { 1 }, portObj.GetField<byte[]>("fByte"));
- Assert.AreEqual(new[] { true }, portObj.GetField<bool[]>("fBool"));
- Assert.AreEqual(new short[] { 2 }, portObj.GetField<short[]>("fShort"));
- Assert.AreEqual(new[] { 'a' }, portObj.GetField<char[]>("fChar"));
- Assert.AreEqual(new[] { 3 }, portObj.GetField<int[]>("fInt"));
- Assert.AreEqual(new long[] { 4 }, portObj.GetField<long[]>("fLong"));
- Assert.AreEqual(new float[] { 5 }, portObj.GetField<float[]>("fFloat"));
- Assert.AreEqual(new double[] { 6 }, portObj.GetField<double[]>("fDouble"));
-
- PrimitiveArrays obj = portObj.Deserialize<PrimitiveArrays>();
-
- Assert.AreEqual(new byte[] { 1 }, obj.FByte);
- Assert.AreEqual(new[] { true }, obj.FBool);
- Assert.AreEqual(new short[] { 2 }, obj.FShort);
- Assert.AreEqual(new[] { 'a' }, obj.FChar);
- Assert.AreEqual(new[] { 3 }, obj.FInt);
- Assert.AreEqual(new long[] { 4 }, obj.FLong);
- Assert.AreEqual(new float[] { 5 }, obj.FFloat);
- Assert.AreEqual(new double[] { 6 }, obj.FDouble);
-
- // Overwrite.
- portObj = _grid.GetPortables().GetBuilder(portObj)
- .SetField("fByte", new byte[] { 7 })
- .SetField("fBool", new[] { false })
- .SetField("fShort", new short[] { 8 })
- .SetField("fChar", new[] { 'b' })
- .SetField("fInt", new[] { 9 })
- .SetField("fLong", new long[] { 10 })
- .SetField("fFloat", new float[] { 11 })
- .SetField("fDouble", new double[] { 12 })
- .SetHashCode(200)
- .Build();
-
- Assert.AreEqual(200, portObj.GetHashCode());
-
- Assert.AreEqual(new byte[] { 7 }, portObj.GetField<byte[]>("fByte"));
- Assert.AreEqual(new[] { false }, portObj.GetField<bool[]>("fBool"));
- Assert.AreEqual(new short[] { 8 }, portObj.GetField<short[]>("fShort"));
- Assert.AreEqual(new[] { 'b' }, portObj.GetField<char[]>("fChar"));
- Assert.AreEqual(new[] { 9 }, portObj.GetField<int[]>("fInt"));
- Assert.AreEqual(new long[] { 10 }, portObj.GetField<long[]>("fLong"));
- Assert.AreEqual(new float[] { 11 }, portObj.GetField<float[]>("fFloat"));
- Assert.AreEqual(new double[] { 12 }, portObj.GetField<double[]>("fDouble"));
-
- obj = portObj.Deserialize<PrimitiveArrays>();
-
- Assert.AreEqual(new byte[] { 7 }, obj.FByte);
- Assert.AreEqual(new[] { false }, obj.FBool);
- Assert.AreEqual(new short[] { 8 }, obj.FShort);
- Assert.AreEqual(new[] { 'b' }, obj.FChar);
- Assert.AreEqual(new[] { 9 }, obj.FInt);
- Assert.AreEqual(new long[] { 10 }, obj.FLong);
- Assert.AreEqual(new float[] { 11 }, obj.FFloat);
- Assert.AreEqual(new double[] { 12 }, obj.FDouble);
- }
-
- /// <summary>
- /// Test non-primitive fields and their array counterparts.
- /// </summary>
- [Test]
- public void TestStringDateGuidEnum()
- {
- DateTime date = DateTime.Now.ToUniversalTime();
- DateTime? nDate = DateTime.Now.ToUniversalTime();
-
- Guid guid = Guid.NewGuid();
- Guid? nGuid = Guid.NewGuid();
-
- IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(StringDateGuidEnum))
- .SetField("fStr", "str")
- .SetField("fDate", date)
- .SetField("fNDate", nDate)
- .SetField("fGuid", guid)
- .SetField("fNGuid", nGuid)
- .SetField("fEnum", TestEnum.One)
- .SetField("fStrArr", new[] { "str" })
- .SetField("fDateArr", new[] { nDate })
- .SetField("fGuidArr", new[] { nGuid })
- .SetField("fEnumArr", new[] { TestEnum.One })
- .SetHashCode(100)
- .Build();
-
- Assert.AreEqual(100, portObj.GetHashCode());
-
- IPortableMetadata meta = portObj.GetMetadata();
-
- Assert.AreEqual(typeof(StringDateGuidEnum).Name, meta.TypeName);
-
- Assert.AreEqual(10, meta.Fields.Count);
-
- Assert.AreEqual(PortableTypeNames.TypeNameString, meta.GetFieldTypeName("fStr"));
- Assert.AreEqual(PortableTypeNames.TypeNameDate, meta.GetFieldTypeName("fDate"));
- Assert.AreEqual(PortableTypeNames.TypeNameDate, meta.GetFieldTypeName("fNDate"));
- Assert.AreEqual(PortableTypeNames.TypeNameGuid, meta.GetFieldTypeName("fGuid"));
- Assert.AreEqual(PortableTypeNames.TypeNameGuid, meta.GetFieldTypeName("fNGuid"));
- Assert.AreEqual(PortableTypeNames.TypeNameEnum, meta.GetFieldTypeName("fEnum"));
- Assert.AreEqual(PortableTypeNames.TypeNameArrayString, meta.GetFieldTypeName("fStrArr"));
- Assert.AreEqual(PortableTypeNames.TypeNameArrayDate, meta.GetFieldTypeName("fDateArr"));
- Assert.AreEqual(PortableTypeNames.TypeNameArrayGuid, meta.GetFieldTypeName("fGuidArr"));
- Assert.AreEqual(PortableTypeNames.TypeNameArrayEnum, meta.GetFieldTypeName("fEnumArr"));
-
- Assert.AreEqual("str", portObj.GetField<string>("fStr"));
- Assert.AreEqual(date, portObj.GetField<DateTime>("fDate"));
- Assert.AreEqual(nDate, portObj.GetField<DateTime?>("fNDate"));
- Assert.AreEqual(guid, portObj.GetField<Guid>("fGuid"));
- Assert.AreEqual(nGuid, portObj.GetField<Guid?>("fNGuid"));
- Assert.AreEqual(TestEnum.One, portObj.GetField<TestEnum>("fEnum"));
- Assert.AreEqual(new[] { "str" }, portObj.GetField<string[]>("fStrArr"));
- Assert.AreEqual(new[] { nDate }, portObj.GetField<DateTime?[]>("fDateArr"));
- Assert.AreEqual(new[] { nGuid }, portObj.GetField<Guid?[]>("fGuidArr"));
- Assert.AreEqual(new[] { TestEnum.One }, portObj.GetField<TestEnum[]>("fEnumArr"));
-
- StringDateGuidEnum obj = portObj.Deserialize<StringDateGuidEnum>();
-
- Assert.AreEqual("str", obj.FStr);
- Assert.AreEqual(date, obj.FDate);
- Assert.AreEqual(nDate, obj.FnDate);
- Assert.AreEqual(guid, obj.FGuid);
- Assert.AreEqual(nGuid, obj.FnGuid);
- Assert.AreEqual(TestEnum.One, obj.FEnum);
- Assert.AreEqual(new[] { "str" }, obj.FStrArr);
- Assert.AreEqual(new[] { nDate }, obj.FDateArr);
- Assert.AreEqual(new[] { nGuid }, obj.FGuidArr);
- Assert.AreEqual(new[] { TestEnum.One }, obj.FEnumArr);
-
- // Overwrite.
- date = DateTime.Now.ToUniversalTime();
- nDate = DateTime.Now.ToUniversalTime();
-
- guid = Guid.NewGuid();
- nGuid = Guid.NewGuid();
-
- portObj = _grid.GetPortables().GetBuilder(typeof(StringDateGuidEnum))
- .SetField("fStr", "str2")
- .SetField("fDate", date)
- .SetField("fNDate", nDate)
- .SetField("fGuid", guid)
- .SetField("fNGuid", nGuid)
- .SetField("fEnum", TestEnum.Two)
- .SetField("fStrArr", new[] { "str2" })
- .SetField("fDateArr", new[] { nDate })
- .SetField("fGuidArr", new[] { nGuid })
- .SetField("fEnumArr", new[] { TestEnum.Two })
- .SetHashCode(200)
- .Build();
-
- Assert.AreEqual(200, portObj.GetHashCode());
-
- Assert.AreEqual("str2", portObj.GetField<string>("fStr"));
- Assert.AreEqual(date, portObj.GetField<DateTime>("fDate"));
- Assert.AreEqual(nDate, portObj.GetField<DateTime?>("fNDate"));
- Assert.AreEqual(guid, portObj.GetField<Guid>("fGuid"));
- Assert.AreEqual(nGuid, portObj.GetField<Guid?>("fNGuid"));
- Assert.AreEqual(TestEnum.Two, portObj.GetField<TestEnum>("fEnum"));
- Assert.AreEqual(new[] { "str2" }, portObj.GetField<string[]>("fStrArr"));
- Assert.AreEqual(new[] { nDate }, portObj.GetField<DateTime?[]>("fDateArr"));
- Assert.AreEqual(new[] { nGuid }, portObj.GetField<Guid?[]>("fGuidArr"));
- Assert.AreEqual(new[] { TestEnum.Two }, portObj.GetField<TestEnum[]>("fEnumArr"));
-
- obj = portObj.Deserialize<StringDateGuidEnum>();
-
- Assert.AreEqual("str2", obj.FStr);
- Assert.AreEqual(date, obj.FDate);
- Assert.AreEqual(nDate, obj.FnDate);
- Assert.AreEqual(guid, obj.FGuid);
- Assert.AreEqual(nGuid, obj.FnGuid);
- Assert.AreEqual(TestEnum.Two, obj.FEnum);
- Assert.AreEqual(new[] { "str2" }, obj.FStrArr);
- Assert.AreEqual(new[] { nDate }, obj.FDateArr);
- Assert.AreEqual(new[] { nGuid }, obj.FGuidArr);
- Assert.AreEqual(new[] { TestEnum.Two }, obj.FEnumArr);
- }
-
- /// <summary>
- /// Test arrays.
- /// </summary>
- [Test]
- public void TestCompositeArray()
- {
- // 1. Test simple array.
- CompositeInner[] inArr = { new CompositeInner(1) };
-
- IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
- .SetField("inArr", inArr).Build();
-
- IPortableMetadata meta = portObj.GetMetadata();
-
- Assert.AreEqual(typeof(CompositeArray).Name, meta.TypeName);
- Assert.AreEqual(1, meta.Fields.Count);
- Assert.AreEqual(PortableTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("inArr"));
-
- Assert.AreEqual(100, portObj.GetHashCode());
-
- IPortableObject[] portInArr = portObj.GetField<IPortableObject[]>("inArr");
-
- Assert.AreEqual(1, portInArr.Length);
- Assert.AreEqual(1, portInArr[0].GetField<int>("val"));
-
- CompositeArray arr = portObj.Deserialize<CompositeArray>();
-
- Assert.IsNull(arr.OutArr);
- Assert.AreEqual(1, arr.InArr.Length);
- Assert.AreEqual(1, arr.InArr[0].Val);
-
- // 2. Test addition to array.
- portInArr = new[] { portInArr[0], null };
-
- portObj = _grid.GetPortables().GetBuilder(portObj).SetHashCode(200)
- .SetField("inArr", portInArr).Build();
-
- Assert.AreEqual(200, portObj.GetHashCode());
-
- portInArr = portObj.GetField<IPortableObject[]>("inArr");
-
- Assert.AreEqual(2, portInArr.Length);
- Assert.AreEqual(1, portInArr[0].GetField<int>("val"));
- Assert.IsNull(portInArr[1]);
-
- arr = portObj.Deserialize<CompositeArray>();
-
- Assert.IsNull(arr.OutArr);
- Assert.AreEqual(2, arr.InArr.Length);
- Assert.AreEqual(1, arr.InArr[0].Val);
- Assert.IsNull(arr.InArr[1]);
-
- portInArr[1] = _grid.GetPortables().GetBuilder(typeof(CompositeInner)).SetField("val", 2).Build();
-
- portObj = _grid.GetPortables().GetBuilder(portObj).SetHashCode(300)
- .SetField("inArr", portInArr).Build();
-
- Assert.AreEqual(300, portObj.GetHashCode());
-
- portInArr = portObj.GetField<IPortableObject[]>("inArr");
-
- Assert.AreEqual(2, portInArr.Length);
- Assert.AreEqual(1, portInArr[0].GetField<int>("val"));
- Assert.AreEqual(2, portInArr[1].GetField<int>("val"));
-
- arr = portObj.Deserialize<CompositeArray>();
-
- Assert.IsNull(arr.OutArr);
- Assert.AreEqual(2, arr.InArr.Length);
- Assert.AreEqual(1, arr.InArr[0].Val);
- Assert.AreEqual(2, arr.InArr[1].Val);
-
- // 3. Test top-level handle inversion.
- CompositeInner inner = new CompositeInner(1);
-
- inArr = new[] { inner, inner };
-
- portObj = _grid.GetPortables().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
- .SetField("inArr", inArr).Build();
-
- Assert.AreEqual(100, portObj.GetHashCode());
-
- portInArr = portObj.GetField<IPortableObject[]>("inArr");
-
- Assert.AreEqual(2, portInArr.Length);
- Assert.AreEqual(1, portInArr[0].GetField<int>("val"));
- Assert.AreEqual(1, portInArr[1].GetField<int>("val"));
-
- arr = portObj.Deserialize<CompositeArray>();
-
- Assert.IsNull(arr.OutArr);
- Assert.AreEqual(2, arr.InArr.Length);
- Assert.AreEqual(1, arr.InArr[0].Val);
- Assert.AreEqual(1, arr.InArr[1].Val);
-
- portInArr[0] = _grid.GetPortables().GetBuilder(typeof(CompositeInner)).SetField("val", 2).Build();
-
- portObj = _grid.GetPortables().GetBuilder(portObj).SetHashCode(200)
- .SetField("inArr", portInArr).Build();
-
- Assert.AreEqual(200, portObj.GetHashCode());
-
- portInArr = portObj.GetField<IPortableObject[]>("inArr");
-
- Assert.AreEqual(2, portInArr.Length);
- Assert.AreEqual(2, portInArr[0].GetField<int>("val"));
- Assert.AreEqual(1, portInArr[1].GetField<int>("val"));
-
- arr = portObj.Deserialize<CompositeArray>();
-
- Assert.IsNull(arr.OutArr);
- Assert.AreEqual(2, arr.InArr.Length);
- Assert.AreEqual(2, arr.InArr[0].Val);
- Assert.AreEqual(1, arr.InArr[1].Val);
-
- // 4. Test nested object handle inversion.
- CompositeOuter[] outArr = { new CompositeOuter(inner), new CompositeOuter(inner) };
-
- portObj = _grid.GetPortables().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
- .SetField("outArr", outArr).Build();
-
- meta = portObj.GetMetadata();
-
- Assert.AreEqual(typeof(CompositeArray).Name, meta.TypeName);
- Assert.AreEqual(2, meta.Fields.Count);
- Assert.AreEqual(PortableTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("inArr"));
- Assert.AreEqual(PortableTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("outArr"));
-
- Assert.AreEqual(100, portObj.GetHashCode());
-
- IPortableObject[] portOutArr = portObj.GetField<IPortableObject[]>("outArr");
-
- Assert.AreEqual(2, portOutArr.Length);
- Assert.AreEqual(1, portOutArr[0].GetField<IPortableObject>("inner").GetField<int>("val"));
- Assert.AreEqual(1, portOutArr[1].GetField<IPortableObject>("inner").GetField<int>("val"));
-
- arr = portObj.Deserialize<CompositeArray>();
-
- Assert.IsNull(arr.InArr);
- Assert.AreEqual(2, arr.OutArr.Length);
- Assert.AreEqual(1, arr.OutArr[0].Inner.Val);
- Assert.AreEqual(1, arr.OutArr[1].Inner.Val);
-
- portOutArr[0] = _grid.GetPortables().GetBuilder(typeof(CompositeOuter))
- .SetField("inner", new CompositeInner(2)).Build();
-
- portObj = _grid.GetPortables().GetBuilder(portObj).SetHashCode(200)
- .SetField("outArr", portOutArr).Build();
-
- Assert.AreEqual(200, portObj.GetHashCode());
-
- portInArr = portObj.GetField<IPortableObject[]>("outArr");
-
- Assert.AreEqual(2, portInArr.Length);
- Assert.AreEqual(2, portOutArr[0].GetField<IPortableObject>("inner").GetField<int>("val"));
- Assert.AreEqual(1, portOutArr[1].GetField<IPortableObject>("inner").GetField<int>("val"));
-
- arr = portObj.Deserialize<CompositeArray>();
-
- Assert.IsNull(arr.InArr);
- Assert.AreEqual(2, arr.OutArr.Length);
- Assert.AreEqual(2, arr.OutArr[0].Inner.Val);
- Assert.AreEqual(1, arr.OutArr[1].Inner.Val);
- }
-
- /// <summary>
- /// Test container types other than array.
- /// </summary>
- [Test]
- public void TestCompositeContainer()
- {
- ArrayList col = new ArrayList();
- ICollection<CompositeInner> gCol = new List<CompositeInner>();
- IDictionary dict = new Hashtable();
- IDictionary<int, CompositeInner> gDict = new Dictionary<int, CompositeInner>();
-
- col.Add(new CompositeInner(1));
- gCol.Add(new CompositeInner(2));
- dict[3] = new CompositeInner(3);
- gDict[4] = new CompositeInner(4);
-
- IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(CompositeContainer)).SetHashCode(100)
- .SetField<ICollection>("col", col)
- .SetField("gCol", gCol)
- .SetField("dict", dict)
- .SetField("gDict", gDict).Build();
-
- // 1. Check meta.
- IPortableMetadata meta = portObj.GetMetadata();
-
- Assert.AreEqual(typeof(CompositeContainer).Name, meta.TypeName);
-
- Assert.AreEqual(4, meta.Fields.Count);
- Assert.AreEqual(PortableTypeNames.TypeNameCollection, meta.GetFieldTypeName("col"));
- Assert.AreEqual(PortableTypeNames.TypeNameCollection, meta.GetFieldTypeName("gCol"));
- Assert.AreEqual(PortableTypeNames.TypeNameMap, meta.GetFieldTypeName("dict"));
- Assert.AreEqual(PortableTypeNames.TypeNameMap, meta.GetFieldTypeName("gDict"));
-
- // 2. Check in portable form.
- Assert.AreEqual(1, portObj.GetField<ICollection>("col").Count);
- Assert.AreEqual(1, portObj.GetField<ICollection>("col").OfType<IPortableObject>().First()
- .GetField<int>("val"));
-
- Assert.AreEqual(1, portObj.GetField<ICollection<IPortableObject>>("gCol").Count);
- Assert.AreEqual(2, portObj.GetField<ICollection<IPortableObject>>("gCol").First().GetField<int>("val"));
-
- Assert.AreEqual(1, portObj.GetField<IDictionary>("dict").Count);
- Assert.AreEqual(3, ((IPortableObject) portObj.GetField<IDictionary>("dict")[3]).GetField<int>("val"));
-
- Assert.AreEqual(1, portObj.GetField<IDictionary<int, IPortableObject>>("gDict").Count);
- Assert.AreEqual(4, portObj.GetField<IDictionary<int, IPortableObject>>("gDict")[4].GetField<int>("val"));
-
- // 3. Check in deserialized form.
- CompositeContainer obj = portObj.Deserialize<CompositeContainer>();
-
- Assert.AreEqual(1, obj.Col.Count);
- Assert.AreEqual(1, obj.Col.OfType<CompositeInner>().First().Val);
-
- Assert.AreEqual(1, obj.GCol.Count);
- Assert.AreEqual(2, obj.GCol.First().Val);
-
- Assert.AreEqual(1, obj.Dict.Count);
- Assert.AreEqual(3, ((CompositeInner) obj.Dict[3]).Val);
-
- Assert.AreEqual(1, obj.GDict.Count);
- Assert.AreEqual(4, obj.GDict[4].Val);
- }
-
- /// <summary>
- /// Ensure that raw data is not lost during build.
- /// </summary>
- [Test]
- public void TestRawData()
- {
- var raw = new WithRaw
- {
- A = 1,
- B = 2
- };
-
- var portObj = _marsh.Unmarshal<IPortableObject>(_marsh.Marshal(raw), PortableMode.ForcePortable);
-
- raw = portObj.Deserialize<WithRaw>();
-
- Assert.AreEqual(1, raw.A);
- Assert.AreEqual(2, raw.B);
-
- IPortableObject newPortObj = _grid.GetPortables().GetBuilder(portObj).SetField("a", 3).Build();
-
- raw = newPortObj.Deserialize<WithRaw>();
-
- Assert.AreEqual(3, raw.A);
- Assert.AreEqual(2, raw.B);
- }
-
- /// <summary>
- /// Test nested objects.
- /// </summary>
- [Test]
- public void TestNested()
- {
- // 1. Create from scratch.
- IPortableBuilder builder = _grid.GetPortables().GetBuilder(typeof(NestedOuter));
-
- NestedInner inner1 = new NestedInner {Val = 1};
- builder.SetField("inner1", inner1);
-
- IPortableObject outerPortObj = builder.Build();
-
- IPortableMetadata meta = outerPortObj.GetMetadata();
-
- Assert.AreEqual(typeof(NestedOuter).Name, meta.TypeName);
- Assert.AreEqual(1, meta.Fields.Count);
- Assert.AreEqual(PortableTypeNames.TypeNameObject, meta.GetFieldTypeName("inner1"));
-
- IPortableObject innerPortObj1 = outerPortObj.GetField<IPortableObject>("inner1");
-
- IPortableMetadata innerMeta = innerPortObj1.GetMetadata();
-
- Assert.AreEqual(typeof(NestedInner).Name, innerMeta.TypeName);
- Assert.AreEqual(1, innerMeta.Fields.Count);
- Assert.AreEqual(PortableTypeNames.TypeNameInt, innerMeta.GetFieldTypeName("Val"));
-
- inner1 = innerPortObj1.Deserialize<NestedInner>();
-
- Assert.AreEqual(1, inner1.Val);
-
- NestedOuter outer = outerPortObj.Deserialize<NestedOuter>();
- Assert.AreEqual(outer.Inner1.Val, 1);
- Assert.IsNull(outer.Inner2);
-
- // 2. Add another field over existing portable object.
- builder = _grid.GetPortables().GetBuilder(outerPortObj);
-
- NestedInner inner2 = new NestedInner {Val = 2};
- builder.SetField("inner2", inner2);
-
- outerPortObj = builder.Build();
-
- outer = outerPortObj.Deserialize<NestedOuter>();
- Assert.AreEqual(1, outer.Inner1.Val);
- Assert.AreEqual(2, outer.Inner2.Val);
-
- // 3. Try setting inner object in portable form.
- innerPortObj1 = _grid.GetPortables().GetBuilder(innerPortObj1).SetField("val", 3).Build();
-
- inner1 = innerPortObj1.Deserialize<NestedInner>();
-
- Assert.AreEqual(3, inner1.Val);
-
- outerPortObj = _grid.GetPortables().GetBuilder(outerPortObj).SetField<object>("inner1", innerPortObj1).Build();
-
- outer = outerPortObj.Deserialize<NestedOuter>();
- Assert.AreEqual(3, outer.Inner1.Val);
- Assert.AreEqual(2, outer.Inner2.Val);
- }
-
- /// <summary>
- /// Test handle migration.
- /// </summary>
- [Test]
- public void TestHandleMigration()
- {
- // 1. Simple comparison of results.
- MigrationInner inner = new MigrationInner {Val = 1};
-
- MigrationOuter outer = new MigrationOuter
- {
- Inner1 = inner,
- Inner2 = inner
- };
-
- byte[] outerBytes = _marsh.Marshal(outer);
-
- IPortableBuilder builder = _grid.GetPortables().GetBuilder(typeof(MigrationOuter));
-
- builder.SetHashCode(outer.GetHashCode());
-
- builder.SetField<object>("inner1", inner);
- builder.SetField<object>("inner2", inner);
-
- PortableUserObject portOuter = (PortableUserObject) builder.Build();
-
- byte[] portOuterBytes = new byte[outerBytes.Length];
-
- Buffer.BlockCopy(portOuter.Data, 0, portOuterBytes, 0, portOuterBytes.Length);
-
- Assert.AreEqual(outerBytes, portOuterBytes);
-
- // 2. Change the first inner object so that the handle must migrate.
- MigrationInner inner1 = new MigrationInner {Val = 2};
-
- IPortableObject portOuterMigrated =
- _grid.GetPortables().GetBuilder(portOuter).SetField<object>("inner1", inner1).Build();
-
- MigrationOuter outerMigrated = portOuterMigrated.Deserialize<MigrationOuter>();
-
- Assert.AreEqual(2, outerMigrated.Inner1.Val);
- Assert.AreEqual(1, outerMigrated.Inner2.Val);
-
- // 3. Change the first value using serialized form.
- IPortableObject inner1Port =
- _grid.GetPortables().GetBuilder(typeof(MigrationInner)).SetField("val", 2).Build();
-
- portOuterMigrated =
- _grid.GetPortables().GetBuilder(portOuter).SetField<object>("inner1", inner1Port).Build();
-
- outerMigrated = portOuterMigrated.Deserialize<MigrationOuter>();
-
- Assert.AreEqual(2, outerMigrated.Inner1.Val);
- Assert.AreEqual(1, outerMigrated.Inner2.Val);
- }
-
- /// <summary>
- /// Test handle inversion.
- /// </summary>
- [Test]
- public void TestHandleInversion()
- {
- InversionInner inner = new InversionInner();
- InversionOuter outer = new InversionOuter();
-
- inner.Outer = outer;
- outer.Inner = inner;
-
- byte[] rawOuter = _marsh.Marshal(outer);
-
- IPortableObject portOuter = _marsh.Unmarshal<IPortableObject>(rawOuter, PortableMode.ForcePortable);
- IPortableObject portInner = portOuter.GetField<IPortableObject>("inner");
-
- // 1. Ensure that inner object can be deserialized after build.
- IPortableObject portInnerNew = _grid.GetPortables().GetBuilder(portInner).Build();
-
- InversionInner innerNew = portInnerNew.Deserialize<InversionInner>();
-
- Assert.AreSame(innerNew, innerNew.Outer.Inner);
-
- // 2. Ensure that portable object with external dependencies could be added to builder.
- IPortableObject portOuterNew =
- _grid.GetPortables().GetBuilder(typeof(InversionOuter)).SetField<object>("inner", portInner).Build();
-
- InversionOuter outerNew = portOuterNew.Deserialize<InversionOuter>();
-
- Assert.AreNotSame(outerNew, outerNew.Inner.Outer);
- Assert.AreSame(outerNew.Inner, outerNew.Inner.Outer.Inner);
- }
-
- /// <summary>
- /// Test build multiple objects.
- /// </summary>
- [Test]
- public void TestBuildMultiple()
- {
- IPortableBuilder builder = _grid.GetPortables().GetBuilder(typeof(Primitives));
-
- builder.SetField<byte>("fByte", 1).SetField("fBool", true);
-
- IPortableObject po1 = builder.Build();
- IPortableObject po2 = builder.Build();
-
- Assert.AreEqual(1, po1.GetField<byte>("fByte"));
- Assert.AreEqual(true, po1.GetField<bool>("fBool"));
-
- Assert.AreEqual(1, po2.GetField<byte>("fByte"));
- Assert.AreEqual(true, po2.GetField<bool>("fBool"));
-
- builder.SetField<byte>("fByte", 2);
-
- IPortableObject po3 = builder.Build();
-
- Assert.AreEqual(1, po1.GetField<byte>("fByte"));
- Assert.AreEqual(true, po1.GetField<bool>("fBool"));
-
- Assert.AreEqual(1, po2.GetField<byte>("fByte"));
- Assert.AreEqual(true, po2.GetField<bool>("fBool"));
-
- Assert.AreEqual(2, po3.GetField<byte>("fByte"));
- Assert.AreEqual(true, po2.GetField<bool>("fBool"));
-
- builder = _grid.GetPortables().GetBuilder(po1);
-
- builder.SetField<byte>("fByte", 10);
-
- po1 = builder.Build();
- po2 = builder.Build();
-
- builder.SetField<byte>("fByte", 20);
-
- po3 = builder.Build();
-
- Assert.AreEqual(10, po1.GetField<byte>("fByte"));
- Assert.AreEqual(true, po1.GetField<bool>("fBool"));
-
- Assert.AreEqual(10, po2.GetField<byte>("fByte"));
- Assert.AreEqual(true, po2.GetField<bool>("fBool"));
-
- Assert.AreEqual(20, po3.GetField<byte>("fByte"));
- Assert.AreEqual(true, po3.GetField<bool>("fBool"));
- }
-
- /// <summary>
- /// Tests type id method.
- /// </summary>
- [Test]
- public void TestTypeId()
- {
- Assert.Throws<ArgumentException>(() => _grid.GetPortables().GetTypeId(null));
-
- Assert.AreEqual(IdMapper.TestTypeId, _grid.GetPortables().GetTypeId(IdMapper.TestTypeName));
-
- Assert.AreEqual(PortableUtils.StringHashCode("someTypeName"), _grid.GetPortables().GetTypeId("someTypeName"));
- }
-
- /// <summary>
- /// Tests metadata methods.
- /// </summary>
- [Test]
- public void TestMetadata()
- {
- // Populate metadata
- var portables = _grid.GetPortables();
-
- portables.ToPortable<IPortableObject>(new DecimalHolder());
-
- // All meta
- var allMetas = portables.GetMetadata();
-
- var decimalMeta = allMetas.Single(x => x.TypeName == "DecimalHolder");
-
- Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
-
- // By type
- decimalMeta = portables.GetMetadata(typeof (DecimalHolder));
-
- Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
-
- // By type id
- decimalMeta = portables.GetMetadata(portables.GetTypeId("DecimalHolder"));
-
- Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
-
- // By type name
- decimalMeta = portables.GetMetadata("DecimalHolder");
-
- Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
- }
-
- /// <summary>
- /// Create portable type configuration with disabled metadata.
- /// </summary>
- /// <param name="typ">Type.</param>
- /// <returns>Configuration.</returns>
- private static PortableTypeConfiguration TypeConfigurationNoMeta(Type typ)
- {
- return new PortableTypeConfiguration(typ) {MetadataEnabled = false};
- }
- }
-
- /// <summary>
- /// Empty portable class.
- /// </summary>
- public class Empty
- {
- // No-op.
- }
-
- /// <summary>
- /// Empty portable class with no metadata.
- /// </summary>
- public class EmptyNoMeta
- {
- // No-op.
- }
-
- /// <summary>
- /// Portable with primitive fields.
- /// </summary>
- public class Primitives
- {
- public byte FByte;
- public bool FBool;
- public short FShort;
- public char FChar;
- public int FInt;
- public long FLong;
- public float FFloat;
- public double FDouble;
- }
-
- /// <summary>
- /// Portable with primitive array fields.
- /// </summary>
- public class PrimitiveArrays
- {
- public byte[] FByte;
- public bool[] FBool;
- public short[] FShort;
- public char[] FChar;
- public int[] FInt;
- public long[] FLong;
- public float[] FFloat;
- public double[] FDouble;
- }
-
- /// <summary>
- /// Portable having strings, dates, Guids and enums.
- /// </summary>
- public class StringDateGuidEnum
- {
- public string FStr;
- public DateTime FDate;
- public DateTime? FnDate;
- public Guid FGuid;
- public Guid? FnGuid;
- public TestEnum FEnum;
-
- public string[] FStrArr;
- public DateTime?[] FDateArr;
- public Guid?[] FGuidArr;
- public TestEnum[] FEnumArr;
- }
-
- /// <summary>
- /// Enumeration.
- /// </summary>
- public enum TestEnum
- {
- One, Two
- }
-
- /// <summary>
- /// Portable with raw data.
- /// </summary>
- public class WithRaw : IPortableMarshalAware
- {
- public int A;
- public int B;
-
- /** <inheritDoc /> */
- public void WritePortable(IPortableWriter writer)
- {
- writer.WriteInt("a", A);
- writer.RawWriter().WriteInt(B);
- }
-
- /** <inheritDoc /> */
- public void ReadPortable(IPortableReader reader)
- {
- A = reader.ReadInt("a");
- B = reader.RawReader().ReadInt();
- }
- }
-
- /// <summary>
- /// Empty class for metadata overwrite test.
- /// </summary>
- public class MetaOverwrite
- {
- // No-op.
- }
-
- /// <summary>
- /// Nested outer object.
- /// </summary>
- public class NestedOuter
- {
- public NestedInner Inner1;
- public NestedInner Inner2;
- }
-
- /// <summary>
- /// Nested inner object.
- /// </summary>
- public class NestedInner
- {
- public int Val;
- }
-
- /// <summary>
- /// Outer object for handle migration test.
- /// </summary>
- public class MigrationOuter
- {
- public MigrationInner Inner1;
- public MigrationInner Inner2;
- }
-
- /// <summary>
- /// Inner object for handle migration test.
- /// </summary>
- public class MigrationInner
- {
- public int Val;
- }
-
- /// <summary>
- /// Outer object for handle inversion test.
- /// </summary>
- public class InversionOuter
- {
- public InversionInner Inner;
- }
-
- /// <summary>
- /// Inner object for handle inversion test.
- /// </summary>
- public class InversionInner
- {
- public InversionOuter Outer;
- }
-
- /// <summary>
- /// Object for composite array tests.
- /// </summary>
- public class CompositeArray
- {
- public CompositeInner[] InArr;
- public CompositeOuter[] OutArr;
- }
-
- /// <summary>
- /// Object for composite collection/dictionary tests.
- /// </summary>
- public class CompositeContainer
- {
- public ICollection Col;
- public ICollection<CompositeInner> GCol;
-
- public IDictionary Dict;
- public IDictionary<int, CompositeInner> GDict;
- }
-
- /// <summary>
- /// OUter object for composite structures test.
- /// </summary>
- public class CompositeOuter
- {
- public CompositeInner Inner;
-
- public CompositeOuter()
- {
- // No-op.
- }
-
- public CompositeOuter(CompositeInner inner)
- {
- Inner = inner;
- }
- }
-
- /// <summary>
- /// Inner object for composite structures test.
- /// </summary>
- public class CompositeInner
- {
- public int Val;
-
- public CompositeInner()
- {
- // No-op.
- }
-
- public CompositeInner(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- /// Type to test "ToPortable()" logic.
- /// </summary>
- public class ToPortable
- {
- public int Val;
-
- public ToPortable(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- /// Type to test "ToPortable()" logic with metadata disabled.
- /// </summary>
- public class ToPortableNoMeta
- {
- public int Val;
-
- public ToPortableNoMeta(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- /// Type to test removal.
- /// </summary>
- public class Remove
- {
- public object Val;
- public RemoveInner Val2;
- }
-
- /// <summary>
- /// Inner type to test removal.
- /// </summary>
- public class RemoveInner
- {
- /** */
- public int Val;
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="val"></param>
- public RemoveInner(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- public class BuilderInBuilderOuter
- {
- /** */
- public BuilderInBuilderInner Inner;
-
- /** */
- public BuilderInBuilderInner Inner2;
- }
-
- /// <summary>
- ///
- /// </summary>
- public class BuilderInBuilderInner
- {
- /** */
- public BuilderInBuilderOuter Outer;
- }
-
- /// <summary>
- ///
- /// </summary>
- public class BuilderCollection
- {
- /** */
- public ICollection<BuilderCollectionItem> Col;
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="col"></param>
- public BuilderCollection(ICollection<BuilderCollectionItem> col)
- {
- Col = col;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- public class BuilderCollectionItem
- {
- /** */
- public int Val;
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="val"></param>
- public BuilderCollectionItem(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- public class DecimalHolder
- {
- /** */
- public decimal Val;
-
- /** */
- public decimal[] ValArr;
- }
-
- /// <summary>
- /// Test id mapper.
- /// </summary>
- public class IdMapper : IPortableIdMapper
- {
- /** */
- public const string TestTypeName = "IdMapperTestType";
-
- /** */
- public const int TestTypeId = -65537;
-
- /** <inheritdoc /> */
- public int GetTypeId(string typeName)
- {
- return typeName == TestTypeName ? TestTypeId : 0;
- }
-
- /** <inheritdoc /> */
- public int GetFieldId(int typeId, string fieldName)
- {
- return 0;
- }
- }
-}
[26/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
new file mode 100644
index 0000000..ae114f3
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
@@ -0,0 +1,2078 @@
+/*
+ * 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.
+ */
+
+// ReSharper disable NonReadonlyMemberInGetHashCode
+// ReSharper disable CompareOfFloatsByEqualityOperator
+// ReSharper disable PossibleInvalidOperationException
+// ReSharper disable UnusedAutoPropertyAccessor.Global
+// ReSharper disable MemberCanBePrivate.Global
+namespace Apache.Ignite.Core.Tests.Portable
+{
+ using System;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+ using Apache.Ignite.Core.Impl.Portable;
+ using Apache.Ignite.Core.Impl.Portable.IO;
+ using Apache.Ignite.Core.Portable;
+ using NUnit.Framework;
+
+ /// <summary>
+ ///
+ /// </summary>
+ [TestFixture]
+ public class PortableSelfTest {
+ /** */
+ private PortableMarshaller _marsh;
+
+ /// <summary>
+ ///
+ /// </summary>
+ [TestFixtureSetUp]
+ public void BeforeTest()
+ {
+ _marsh = new PortableMarshaller(null);
+ }
+
+ /**
+ * <summary>Check write of primitive boolean.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveBool()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<bool>(_marsh.Marshal(false)), false);
+ Assert.AreEqual(_marsh.Unmarshal<bool>(_marsh.Marshal(true)), true);
+
+ Assert.AreEqual(_marsh.Unmarshal<bool?>(_marsh.Marshal((bool?)false)), false);
+ Assert.AreEqual(_marsh.Unmarshal<bool?>(_marsh.Marshal(null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive boolean array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveBoolArray()
+ {
+ bool[] vals = { true, false };
+
+ Assert.AreEqual(_marsh.Unmarshal<bool[]>(_marsh.Marshal(vals)), vals);
+ }
+
+ /**
+ * <summary>Check write of primitive sbyte.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveSbyte()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<sbyte>(_marsh.Marshal((sbyte)1)), 1);
+ Assert.AreEqual(_marsh.Unmarshal<sbyte>(_marsh.Marshal(sbyte.MinValue)), sbyte.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<sbyte>(_marsh.Marshal(sbyte.MaxValue)), sbyte.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<sbyte?>(_marsh.Marshal((sbyte?)1)), (sbyte?)1);
+ Assert.AreEqual(_marsh.Unmarshal<sbyte?>(_marsh.Marshal(null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive sbyte array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveSbyteArray()
+ {
+ sbyte[] vals = { sbyte.MinValue, 0, 1, sbyte.MaxValue };
+ sbyte[] newVals = _marsh.Unmarshal<sbyte[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive byte.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveByte()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<byte>(_marsh.Marshal((byte)1)), 1);
+ Assert.AreEqual(_marsh.Unmarshal<byte>(_marsh.Marshal(byte.MinValue)), byte.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<byte>(_marsh.Marshal(byte.MaxValue)), byte.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<byte?>(_marsh.Marshal((byte?)1)), (byte?)1);
+ Assert.AreEqual(_marsh.Unmarshal<byte?>(_marsh.Marshal(null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive byte array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveByteArray()
+ {
+ byte[] vals = { byte.MinValue, 0, 1, byte.MaxValue };
+ byte[] newVals = _marsh.Unmarshal<byte[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive short.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveShort()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<short>(_marsh.Marshal((short)1)), 1);
+ Assert.AreEqual(_marsh.Unmarshal<short>(_marsh.Marshal(short.MinValue)), short.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<short>(_marsh.Marshal(short.MaxValue)), short.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<short?>(_marsh.Marshal((short?)1)), (short?)1);
+ Assert.AreEqual(_marsh.Unmarshal<short?>(_marsh.Marshal(null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive short array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveShortArray()
+ {
+ short[] vals = { short.MinValue, 0, 1, short.MaxValue };
+ short[] newVals = _marsh.Unmarshal<short[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive ushort.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveUshort()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<ushort>(_marsh.Marshal((ushort)1)), 1);
+ Assert.AreEqual(_marsh.Unmarshal<ushort>(_marsh.Marshal(ushort.MinValue)), ushort.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<ushort>(_marsh.Marshal(ushort.MaxValue)), ushort.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<ushort?>(_marsh.Marshal((ushort?)1)), (ushort?)1);
+ Assert.AreEqual(_marsh.Unmarshal<ushort?>(_marsh.Marshal(null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive short array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveUshortArray()
+ {
+ ushort[] vals = { ushort.MinValue, 0, 1, ushort.MaxValue };
+ ushort[] newVals = _marsh.Unmarshal<ushort[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive char.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveChar()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<char>(_marsh.Marshal((char)1)), (char)1);
+ Assert.AreEqual(_marsh.Unmarshal<char>(_marsh.Marshal(char.MinValue)), char.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<char>(_marsh.Marshal(char.MaxValue)), char.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<char?>(_marsh.Marshal((char?)1)), (char?)1);
+ Assert.AreEqual(_marsh.Unmarshal<char?>(_marsh.Marshal(null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive uint array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveCharArray()
+ {
+ char[] vals = { char.MinValue, (char)0, (char)1, char.MaxValue };
+ char[] newVals = _marsh.Unmarshal<char[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive int.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveInt()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<int>(_marsh.Marshal(1)), 1);
+ Assert.AreEqual(_marsh.Unmarshal<int>(_marsh.Marshal(int.MinValue)), int.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<int>(_marsh.Marshal(int.MaxValue)), int.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<int?>(_marsh.Marshal((int?)1)), (int?)1);
+ Assert.AreEqual(_marsh.Unmarshal<int?>(_marsh.Marshal(null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive uint array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveIntArray()
+ {
+ int[] vals = { int.MinValue, 0, 1, int.MaxValue };
+ int[] newVals = _marsh.Unmarshal<int[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive uint.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveUint()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<uint>(_marsh.Marshal((uint)1)), 1);
+ Assert.AreEqual(_marsh.Unmarshal<uint>(_marsh.Marshal(uint.MinValue)), uint.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<uint>(_marsh.Marshal(uint.MaxValue)), uint.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<uint?>(_marsh.Marshal((uint?)1)), (int?)1);
+ Assert.AreEqual(_marsh.Unmarshal<uint?>(_marsh.Marshal(null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive uint array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveUintArray()
+ {
+ uint[] vals = { uint.MinValue, 0, 1, uint.MaxValue };
+ uint[] newVals = _marsh.Unmarshal<uint[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive long.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveLong()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<long>(_marsh.Marshal((long)1)), 1);
+ Assert.AreEqual(_marsh.Unmarshal<long>(_marsh.Marshal(long.MinValue)), long.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<long>(_marsh.Marshal(long.MaxValue)), long.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<long?>(_marsh.Marshal((long?)1)), (long?)1);
+ Assert.AreEqual(_marsh.Unmarshal<long?>(_marsh.Marshal(null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive long array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveLongArray()
+ {
+ long[] vals = { long.MinValue, 0, 1, long.MaxValue };
+ long[] newVals = _marsh.Unmarshal<long[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive ulong.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveUlong()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<ulong>(_marsh.Marshal((ulong)1)), 1);
+ Assert.AreEqual(_marsh.Unmarshal<ulong>(_marsh.Marshal(ulong.MinValue)), ulong.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<ulong>(_marsh.Marshal(ulong.MaxValue)), ulong.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<ulong?>(_marsh.Marshal((ulong?)1)), (ulong?)1);
+ Assert.AreEqual(_marsh.Unmarshal<ulong?>(_marsh.Marshal(null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive ulong array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveUlongArray()
+ {
+ ulong[] vals = { ulong.MinValue, 0, 1, ulong.MaxValue };
+ ulong[] newVals = _marsh.Unmarshal<ulong[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive float.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveFloat()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<float>(_marsh.Marshal((float)1)), (float)1);
+ Assert.AreEqual(_marsh.Unmarshal<float>(_marsh.Marshal(float.MinValue)), float.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<float>(_marsh.Marshal(float.MaxValue)), float.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<float?>(_marsh.Marshal((float?)1)), (float?)1);
+ Assert.AreEqual(_marsh.Unmarshal<float?>(_marsh.Marshal(null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive float array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveFloatArray()
+ {
+ float[] vals = { float.MinValue, 0, 1, float.MaxValue };
+ float[] newVals = _marsh.Unmarshal<float[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive double.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveDouble()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<double>(_marsh.Marshal((double)1)), (double)1);
+ Assert.AreEqual(_marsh.Unmarshal<double>(_marsh.Marshal(double.MinValue)), double.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<double>(_marsh.Marshal(double.MaxValue)), double.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<double?>(_marsh.Marshal((double?)1)), (double?)1);
+ Assert.AreEqual(_marsh.Unmarshal<double?>(_marsh.Marshal(null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive double array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveDoubleArray()
+ {
+ double[] vals = { double.MinValue, 0, 1, double.MaxValue };
+ double[] newVals = _marsh.Unmarshal<double[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of decimal.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveDecimal()
+ {
+ decimal val;
+
+ // Test positibe and negative.
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Zero)), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(1, 0, 0, false, 0))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(1, 0, 0, true, 0))), val);
+
+ // Test 32, 64 and 96 bits + mixed.
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(0, 1, 0, false, 0))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(0, 1, 0, true, 0))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(0, 0, 1, false, 0))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(0, 0, 1, true, 0))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(1, 1, 1, false, 0))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(1, 1, 1, true, 0))), val);
+
+ // Test extremes.
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("65536"))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-65536"))), val);
+
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("4294967296"))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-4294967296"))), val);
+
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("281474976710656"))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-281474976710656"))), val);
+
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("18446744073709551616"))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-18446744073709551616"))), val);
+
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("1208925819614629174706176"))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-1208925819614629174706176"))), val);
+
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.MaxValue)), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.MinValue)), val);
+
+ // Test scale.
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("11,12"))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-11,12"))), val);
+
+ // Test null.
+ Assert.AreEqual(_marsh.Unmarshal<decimal?>(_marsh.Marshal(null)), null);
+ }
+
+ /**
+ * <summary>Check write of decimal array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveDecimalArray()
+ {
+ decimal[] vals = { decimal.One, decimal.Parse("11,12") };
+ decimal[] newVals = _marsh.Unmarshal<decimal[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of string.</summary>
+ */
+ [Test]
+ public void TestWriteString()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<string>(_marsh.Marshal("str")), "str");
+ Assert.AreEqual(_marsh.Unmarshal<string>(_marsh.Marshal(null)), null);
+ }
+
+ /**
+ * <summary>Check write of string array.</summary>
+ */
+ [Test]
+ public void TestWriteStringArray()
+ {
+ string[] vals = { "str1", null, "", "str2", null};
+ string[] newVals = _marsh.Unmarshal<string[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of Guid.</summary>
+ */
+ [Test]
+ public void TestWriteGuid()
+ {
+ Guid guid = Guid.NewGuid();
+ Guid? nGuid = guid;
+
+ Assert.AreEqual(_marsh.Unmarshal<Guid>(_marsh.Marshal(guid)), guid);
+ Assert.AreEqual(_marsh.Unmarshal<Guid?>(_marsh.Marshal(nGuid)), nGuid);
+
+ nGuid = null;
+
+ // ReSharper disable once ExpressionIsAlwaysNull
+ Assert.AreEqual(_marsh.Unmarshal<Guid?>(_marsh.Marshal(nGuid)), null);
+ }
+
+ /**
+ * <summary>Check write of string array.</summary>
+ */
+ [Test]
+ public void TestWriteGuidArray()
+ {
+ Guid?[] vals = { Guid.NewGuid(), null, Guid.Empty, Guid.NewGuid(), null };
+ Guid?[] newVals = _marsh.Unmarshal<Guid?[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of enum.</summary>
+ */
+ [Test]
+ public void TestWriteEnum()
+ {
+ TestEnum val = TestEnum.Val1;
+
+ Assert.AreEqual(_marsh.Unmarshal<TestEnum>(_marsh.Marshal(val)), val);
+ }
+
+ /**
+ * <summary>Check write of enum.</summary>
+ */
+ [Test]
+ public void TestWriteEnumArray()
+ {
+ TestEnum[] vals = { TestEnum.Val2, TestEnum.Val3 };
+ TestEnum[] newVals = _marsh.Unmarshal<TestEnum[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of date.</summary>
+ */
+ [Test]
+ public void TestWriteDate() {
+ DateTime time = DateTime.Now.ToUniversalTime();
+
+ Assert.AreEqual(_marsh.Unmarshal<DateTime>(_marsh.Marshal(time)), time);
+ }
+
+ /// <summary>
+ /// Test object with dates.
+ /// </summary>
+ [Test]
+ public void TestDateObject()
+ {
+ ICollection<PortableTypeConfiguration> typeCfgs =
+ new List<PortableTypeConfiguration>();
+
+ typeCfgs.Add(new PortableTypeConfiguration(typeof(DateTimeType)));
+
+ PortableConfiguration cfg = new PortableConfiguration {TypeConfigurations = typeCfgs};
+
+ PortableMarshaller marsh = new PortableMarshaller(cfg);
+
+ DateTime now = DateTime.Now;
+
+ DateTimeType obj = new DateTimeType(now);
+
+ DateTimeType otherObj = marsh.Unmarshal<DateTimeType>(marsh.Marshal(obj));
+
+ Assert.AreEqual(obj.Loc, otherObj.Loc);
+ Assert.AreEqual(obj.Utc, otherObj.Utc);
+ Assert.AreEqual(obj.LocNull, otherObj.LocNull);
+ Assert.AreEqual(obj.UtcNull, otherObj.UtcNull);
+ Assert.AreEqual(obj.LocArr, otherObj.LocArr);
+ Assert.AreEqual(obj.UtcArr, otherObj.UtcArr);
+
+ Assert.AreEqual(obj.LocRaw, otherObj.LocRaw);
+ Assert.AreEqual(obj.UtcRaw, otherObj.UtcRaw);
+ Assert.AreEqual(obj.LocNullRaw, otherObj.LocNullRaw);
+ Assert.AreEqual(obj.UtcNullRaw, otherObj.UtcNullRaw);
+ Assert.AreEqual(obj.LocArrRaw, otherObj.LocArrRaw);
+ Assert.AreEqual(obj.UtcArrRaw, otherObj.UtcArrRaw);
+ }
+
+ /**
+ * <summary>Check generic collections.</summary>
+ */
+ [Test]
+ public void TestGenericCollections()
+ {
+ ICollection<string> list = new List<string>();
+
+ list.Add("1");
+
+ byte[] data = _marsh.Marshal(list);
+
+ ICollection<object> newObjList = _marsh.Unmarshal<List<object>>(data);
+
+ Assert.NotNull(newObjList);
+
+ ICollection<string> newList = new List<string>();
+
+ foreach (object obj in newObjList)
+ newList.Add((string)obj);
+
+ CollectionAssert.AreEquivalent(list, newList);
+ }
+
+ /**
+ * <summary>Check property read.</summary>
+ */
+ [Test]
+ public void TestProperty()
+ {
+ ICollection<PortableTypeConfiguration> typeCfgs =
+ new List<PortableTypeConfiguration>();
+
+ typeCfgs.Add(new PortableTypeConfiguration(typeof(PropertyType)));
+
+ PortableConfiguration cfg = new PortableConfiguration {TypeConfigurations = typeCfgs};
+
+ PortableMarshaller marsh = new PortableMarshaller(cfg);
+
+ PropertyType obj = new PropertyType
+ {
+ Field1 = 1,
+ Field2 = 2
+ };
+
+ byte[] data = marsh.Marshal(obj);
+
+ PropertyType newObj = marsh.Unmarshal<PropertyType>(data);
+
+ Assert.AreEqual(obj.Field1, newObj.Field1);
+ Assert.AreEqual(obj.Field2, newObj.Field2);
+
+ IPortableObject portNewObj = marsh.Unmarshal<IPortableObject>(data, PortableMode.ForcePortable);
+
+ Assert.AreEqual(obj.Field1, portNewObj.GetField<int>("field1"));
+ Assert.AreEqual(obj.Field2, portNewObj.GetField<int>("Field2"));
+ }
+
+ /**
+ * <summary>Check write of primitive fields through reflection.</summary>
+ */
+ [Test]
+ public void TestPrimitiveFieldsReflective()
+ {
+ ICollection<PortableTypeConfiguration> typeCfgs =
+ new List<PortableTypeConfiguration>();
+
+ typeCfgs.Add(new PortableTypeConfiguration(typeof(PrimitiveFieldType)));
+
+ PortableConfiguration cfg = new PortableConfiguration {TypeConfigurations = typeCfgs};
+
+ PortableMarshaller marsh = new PortableMarshaller(cfg);
+
+ PrimitiveFieldType obj = new PrimitiveFieldType();
+
+ CheckPrimitiveFields(marsh, obj);
+ }
+
+ /**
+ * <summary>Check write of primitive fields through portable interface.</summary>
+ */
+ [Test]
+ public void TestPrimitiveFieldsPortable()
+ {
+ ICollection<PortableTypeConfiguration> typeCfgs =
+ new List<PortableTypeConfiguration>();
+
+ typeCfgs.Add(new PortableTypeConfiguration(typeof(PrimitiveFieldPortableType)));
+
+ PortableConfiguration cfg = new PortableConfiguration();
+
+ cfg.TypeConfigurations = typeCfgs;
+
+ PortableMarshaller marsh = new PortableMarshaller(cfg);
+
+ PrimitiveFieldPortableType obj = new PrimitiveFieldPortableType();
+
+ CheckPrimitiveFields(marsh, obj);
+ }
+
+ /**
+ * <summary>Check write of primitive fields through portable interface.</summary>
+ */
+ [Test]
+ public void TestPrimitiveFieldsRawPortable()
+ {
+ ICollection<PortableTypeConfiguration> typeCfgs =
+ new List<PortableTypeConfiguration>();
+
+ typeCfgs.Add(new PortableTypeConfiguration(typeof(PrimitiveFieldRawPortableType)));
+
+ PortableConfiguration cfg = new PortableConfiguration();
+
+ cfg.TypeConfigurations = typeCfgs;
+
+ PortableMarshaller marsh = new PortableMarshaller(cfg);
+
+ PrimitiveFieldRawPortableType obj = new PrimitiveFieldRawPortableType();
+
+ CheckPrimitiveFields(marsh, obj);
+ }
+
+ /**
+ * <summary>Check write of primitive fields through portable interface.</summary>
+ */
+ [Test]
+ public void TestPrimitiveFieldsSerializer()
+ {
+ var typeCfgs = new List<PortableTypeConfiguration>
+ {
+ new PortableTypeConfiguration(typeof (PrimitiveFieldType))
+ {
+ Serializer = new PrimitiveFieldsSerializer()
+ }
+ };
+
+ PortableConfiguration cfg = new PortableConfiguration {TypeConfigurations = typeCfgs};
+
+ PortableMarshaller marsh = new PortableMarshaller(cfg);
+
+ PrimitiveFieldType obj = new PrimitiveFieldType();
+
+ CheckPrimitiveFields(marsh, obj);
+ }
+
+ /**
+ * <summary>Check decimals.</summary>
+ */
+ [Test]
+ public void TestDecimalFields()
+ {
+ PortableConfiguration cfg = new PortableConfiguration
+ {
+ TypeConfigurations = new List<PortableTypeConfiguration>
+ {
+ new PortableTypeConfiguration(typeof (DecimalReflective)),
+ new PortableTypeConfiguration(typeof (DecimalMarshalAware))
+ }
+ };
+
+ PortableMarshaller marsh = new PortableMarshaller(cfg);
+
+ // 1. Test reflective stuff.
+ DecimalReflective obj1 = new DecimalReflective
+ {
+ Val = decimal.Zero,
+ ValArr = new[] {decimal.One, decimal.MinusOne}
+ };
+
+ IPortableObject portObj = marsh.Unmarshal<IPortableObject>(marsh.Marshal(obj1), PortableMode.ForcePortable);
+
+ Assert.AreEqual(obj1.Val, portObj.GetField<decimal>("val"));
+ Assert.AreEqual(obj1.ValArr, portObj.GetField<decimal[]>("valArr"));
+
+ Assert.AreEqual(obj1.Val, portObj.Deserialize<DecimalReflective>().Val);
+ Assert.AreEqual(obj1.ValArr, portObj.Deserialize<DecimalReflective>().ValArr);
+
+ // 2. Test marshal aware stuff.
+ DecimalMarshalAware obj2 = new DecimalMarshalAware();
+
+ obj2.Val = decimal.Zero;
+ obj2.ValArr = new[] { decimal.One, decimal.MinusOne };
+ obj2.RawVal = decimal.MaxValue;
+ obj2.RawValArr = new[] { decimal.MinusOne, decimal.One} ;
+
+ portObj = marsh.Unmarshal<IPortableObject>(marsh.Marshal(obj2), PortableMode.ForcePortable);
+
+ Assert.AreEqual(obj2.Val, portObj.GetField<decimal>("val"));
+ Assert.AreEqual(obj2.ValArr, portObj.GetField<decimal[]>("valArr"));
+
+ Assert.AreEqual(obj2.Val, portObj.Deserialize<DecimalMarshalAware>().Val);
+ Assert.AreEqual(obj2.ValArr, portObj.Deserialize<DecimalMarshalAware>().ValArr);
+ Assert.AreEqual(obj2.RawVal, portObj.Deserialize<DecimalMarshalAware>().RawVal);
+ Assert.AreEqual(obj2.RawValArr, portObj.Deserialize<DecimalMarshalAware>().RawValArr);
+ }
+
+ /**
+ * <summary>Check write of primitive fields through raw serializer.</summary>
+ */
+ [Test]
+ public void TestPrimitiveFieldsRawSerializer()
+ {
+ ICollection<PortableTypeConfiguration> typeCfgs =
+ new List<PortableTypeConfiguration>();
+
+ PortableTypeConfiguration typeCfg =
+ new PortableTypeConfiguration(typeof(PrimitiveFieldType));
+
+ typeCfg.Serializer = new PrimitiveFieldsRawSerializer();
+
+ typeCfgs.Add(typeCfg);
+
+ PortableConfiguration cfg = new PortableConfiguration();
+
+ cfg.TypeConfigurations = typeCfgs;
+
+ PortableMarshaller marsh = new PortableMarshaller(cfg);
+
+ PrimitiveFieldType obj = new PrimitiveFieldType();
+
+ CheckPrimitiveFields(marsh, obj);
+ }
+
+ private void CheckPrimitiveFields(PortableMarshaller marsh, PrimitiveFieldType obj)
+ {
+ obj.PBool = true;
+ obj.PByte = 2;
+ obj.PSbyte = 3;
+ obj.PShort = 4;
+ obj.PUshort = 5;
+ obj.PInt = 6;
+ obj.PUint = 7;
+ obj.PLong = 8;
+ obj.PUlong = 9;
+ obj.PChar = 'a';
+ obj.PFloat = 10;
+ obj.PDouble = 11;
+ obj.PString = "abc";
+ obj.PGuid = Guid.NewGuid();
+ obj.PnGuid = Guid.NewGuid();
+
+ //CheckPrimitiveFieldsSerialization(marsh, obj);
+
+ //obj.PString = "";
+
+ //CheckPrimitiveFieldsSerialization(marsh, obj);
+
+ //obj.PString = null;
+
+ //CheckPrimitiveFieldsSerialization(marsh, obj);
+
+ //obj.PString = null;
+ //obj.PNGuid = null;
+
+ CheckPrimitiveFieldsSerialization(marsh, obj);
+ }
+
+ private void CheckPrimitiveFieldsSerialization(PortableMarshaller marsh, PrimitiveFieldType obj)
+ {
+ byte[] bytes = marsh.Marshal(obj);
+
+ IPortableObject portObj = marsh.Unmarshal<IPortableObject>(bytes, PortableMode.ForcePortable);
+
+ Assert.AreEqual(obj.GetHashCode(), portObj.GetHashCode());
+
+ PrimitiveFieldType newObj = portObj.Deserialize<PrimitiveFieldType>();
+
+ Assert.AreEqual(obj, newObj);
+ }
+
+ /**
+ * <summary>Check write of object with enums.</summary>
+ */
+ [Test]
+ public void TestEnumsReflective()
+ {
+ PortableMarshaller marsh =
+ new PortableMarshaller(new PortableConfiguration
+ {
+ TypeConfigurations =
+ new List<PortableTypeConfiguration> {new PortableTypeConfiguration(typeof (EnumType))}
+ });
+
+ EnumType obj = new EnumType
+ {
+ PEnum = TestEnum.Val1,
+ PEnumArray = new[] {TestEnum.Val2, TestEnum.Val3}
+ };
+
+ byte[] bytes = marsh.Marshal(obj);
+
+ IPortableObject portObj = marsh.Unmarshal<IPortableObject>(bytes, PortableMode.ForcePortable);
+
+ Assert.AreEqual(obj.GetHashCode(), portObj.GetHashCode());
+
+ EnumType newObj = portObj.Deserialize<EnumType>();
+
+ Assert.AreEqual(obj.PEnum, newObj.PEnum);
+ Assert.AreEqual(obj.PEnumArray, newObj.PEnumArray);
+ }
+
+ /**
+ * <summary>Check write of object with collections.</summary>
+ */
+ [Test]
+ public void TestCollectionsReflective()
+ {
+ ICollection<PortableTypeConfiguration> typeCfgs =
+ new List<PortableTypeConfiguration>();
+
+ typeCfgs.Add(new PortableTypeConfiguration(typeof(CollectionsType)));
+ typeCfgs.Add(new PortableTypeConfiguration(typeof(InnerObjectType)));
+
+ PortableConfiguration cfg = new PortableConfiguration();
+
+ cfg.TypeConfigurations = typeCfgs;
+
+ PortableMarshaller marsh = new PortableMarshaller(cfg);
+
+ CollectionsType obj = new CollectionsType();
+
+ ArrayList list = new ArrayList();
+
+ list.Add(true);
+ list.Add((byte)1);
+ list.Add((short)2);
+ list.Add('a');
+ list.Add(3);
+ list.Add((long)4);
+ list.Add((float)5);
+ list.Add((double)6);
+
+ list.Add("string");
+ list.Add(Guid.NewGuid());
+
+ InnerObjectType innerObj = new InnerObjectType();
+
+ innerObj.PInt1 = 1;
+ innerObj.PInt2 = 2;
+
+ list.Add(innerObj);
+
+ obj.Col1 = list;
+
+ byte[] bytes = marsh.Marshal(obj);
+
+ IPortableObject portObj = marsh.Unmarshal<IPortableObject>(bytes, PortableMode.ForcePortable);
+
+ Assert.AreEqual(obj.GetHashCode(), portObj.GetHashCode());
+
+ CollectionsType newObj = portObj.Deserialize<CollectionsType>();
+
+ Assert.AreEqual(obj, newObj);
+
+ obj.Col1 = null;
+
+ Assert.AreEqual(obj, marsh.Unmarshal<CollectionsType>(marsh.Marshal(obj)));
+
+ obj.Col1 = list;
+ obj.Col2 = list;
+
+ Assert.AreEqual(obj, marsh.Unmarshal<CollectionsType>(marsh.Marshal(obj)));
+
+ obj.Col2 = new TestList();
+
+ Assert.AreEqual(obj, marsh.Unmarshal<CollectionsType>(marsh.Marshal(obj)));
+ }
+
+ /**
+ * <summary>Check write of object fields through reflective serializer.</summary>
+ */
+ [Test]
+ public void TestObjectReflective()
+ {
+ ICollection<PortableTypeConfiguration> typeCfgs =
+ new List<PortableTypeConfiguration>();
+
+ typeCfgs.Add(new PortableTypeConfiguration(typeof(OuterObjectType)));
+ typeCfgs.Add(new PortableTypeConfiguration(typeof(InnerObjectType)));
+
+ PortableConfiguration cfg = new PortableConfiguration();
+
+ cfg.TypeConfigurations = typeCfgs;
+
+ PortableMarshaller marsh = new PortableMarshaller(cfg);
+
+ CheckObject(marsh, new OuterObjectType(), new InnerObjectType());
+ }
+
+ /**
+ * <summary>Test handles.</summary>
+ */
+ [Test]
+ public void TestHandles()
+ {
+ ICollection<PortableTypeConfiguration> typeCfgs =
+ new List<PortableTypeConfiguration>();
+
+ typeCfgs.Add(new PortableTypeConfiguration(typeof(HandleInner)));
+ typeCfgs.Add(new PortableTypeConfiguration(typeof(HandleOuter)));
+
+ PortableConfiguration cfg = new PortableConfiguration();
+
+ cfg.TypeConfigurations = typeCfgs;
+
+ PortableMarshaller marsh = new PortableMarshaller(cfg);
+
+ HandleOuter outer = new HandleOuter();
+
+ outer.Before = "outBefore";
+ outer.After = "outAfter";
+ outer.RawBefore = "outRawBefore";
+ outer.RawAfter = "outRawAfter";
+
+ HandleInner inner = new HandleInner();
+
+ inner.Before = "inBefore";
+ inner.After = "inAfter";
+ inner.RawBefore = "inRawBefore";
+ inner.RawAfter = "inRawAfter";
+
+ outer.Inner = inner;
+ outer.RawInner = inner;
+
+ inner.Outer = outer;
+ inner.RawOuter = outer;
+
+ byte[] bytes = marsh.Marshal(outer);
+
+ IPortableObject outerObj = marsh.Unmarshal<IPortableObject>(bytes, PortableMode.ForcePortable);
+
+ HandleOuter newOuter = outerObj.Deserialize<HandleOuter>();
+ HandleInner newInner = newOuter.Inner;
+
+ CheckHandlesConsistency(outer, inner, newOuter, newInner);
+
+ // Get inner object by field.
+ IPortableObject innerObj = outerObj.GetField<IPortableObject>("inner");
+
+ newInner = innerObj.Deserialize<HandleInner>();
+ newOuter = newInner.Outer;
+
+ CheckHandlesConsistency(outer, inner, newOuter, newInner);
+
+ // Get outer object from inner object by handle.
+ outerObj = innerObj.GetField<IPortableObject>("outer");
+
+ newOuter = outerObj.Deserialize<HandleOuter>();
+ newInner = newOuter.Inner;
+
+ CheckHandlesConsistency(outer, inner, newOuter, newInner);
+ }
+
+ /**
+ * <summary>Test handles with exclusive writes.</summary>
+ */
+ [Test]
+ public void TestHandlesExclusive([Values(true, false)] bool detached, [Values(true, false)] bool asPortable)
+ {
+ var marsh = new PortableMarshaller(new PortableConfiguration
+ {
+ TypeConfigurations = new List<PortableTypeConfiguration>
+ {
+ new PortableTypeConfiguration(typeof (HandleInner)),
+ new PortableTypeConfiguration(typeof (HandleOuterExclusive))
+ }
+ });
+
+ var inner = new HandleInner
+ {
+ Before = "inBefore",
+ After = "inAfter",
+ RawBefore = "inRawBefore",
+ RawAfter = "inRawAfter"
+ };
+
+ var outer = new HandleOuterExclusive
+ {
+ Before = "outBefore",
+ After = "outAfter",
+ RawBefore = "outRawBefore",
+ RawAfter = "outRawAfter",
+ Inner = inner,
+ RawInner = inner
+ };
+
+ inner.Outer = outer;
+ inner.RawOuter = outer;
+
+ var bytes = asPortable
+ ? marsh.Marshal(new PortablesImpl(marsh).ToPortable<IPortableObject>(outer))
+ : marsh.Marshal(outer);
+
+ IPortableObject outerObj;
+
+ if (detached)
+ {
+ var reader = new PortableReaderImpl(marsh, new Dictionary<long, IPortableTypeDescriptor>(),
+ new PortableHeapStream(bytes), PortableMode.ForcePortable, null);
+
+ reader.DetachNext();
+
+ outerObj = reader.Deserialize<IPortableObject>();
+ }
+ else
+ outerObj = marsh.Unmarshal<IPortableObject>(bytes, PortableMode.ForcePortable);
+
+ HandleOuter newOuter = outerObj.Deserialize<HandleOuter>();
+
+ Assert.IsFalse(newOuter == newOuter.Inner.Outer);
+ Assert.IsFalse(newOuter == newOuter.Inner.RawOuter);
+ Assert.IsFalse(newOuter == newOuter.RawInner.RawOuter);
+ Assert.IsFalse(newOuter == newOuter.RawInner.RawOuter);
+
+ Assert.IsFalse(newOuter.Inner == newOuter.RawInner);
+
+ Assert.IsTrue(newOuter.Inner.Outer == newOuter.Inner.RawOuter);
+ Assert.IsTrue(newOuter.RawInner.Outer == newOuter.RawInner.RawOuter);
+
+ Assert.IsTrue(newOuter.Inner == newOuter.Inner.Outer.Inner);
+ Assert.IsTrue(newOuter.Inner == newOuter.Inner.Outer.RawInner);
+ Assert.IsTrue(newOuter.RawInner == newOuter.RawInner.Outer.Inner);
+ Assert.IsTrue(newOuter.RawInner == newOuter.RawInner.Outer.RawInner);
+ }
+
+ ///
+ /// <summary>Test KeepSerialized property</summary>
+ ///
+ [Test]
+ public void TestKeepSerializedDefault()
+ {
+ CheckKeepSerialized(new PortableConfiguration(), true);
+ }
+
+ ///
+ /// <summary>Test KeepSerialized property</summary>
+ ///
+ [Test]
+ public void TestKeepSerializedDefaultFalse()
+ {
+ PortableConfiguration cfg = new PortableConfiguration();
+
+ cfg.DefaultKeepDeserialized = false;
+
+ CheckKeepSerialized(cfg, false);
+ }
+
+ ///
+ /// <summary>Test KeepSerialized property</summary>
+ ///
+ [Test]
+ public void TestKeepSerializedTypeCfgFalse()
+ {
+ PortableTypeConfiguration typeCfg = new PortableTypeConfiguration(typeof(PropertyType));
+
+ typeCfg.KeepDeserialized = false;
+
+ PortableConfiguration cfg = new PortableConfiguration();
+
+ cfg.TypeConfigurations = new List<PortableTypeConfiguration> { typeCfg };
+
+ CheckKeepSerialized(cfg, false);
+ }
+
+ ///
+ /// <summary>Test KeepSerialized property</summary>
+ ///
+ [Test]
+ public void TestKeepSerializedTypeCfgTrue()
+ {
+ PortableTypeConfiguration typeCfg = new PortableTypeConfiguration(typeof(PropertyType));
+ typeCfg.KeepDeserialized = true;
+
+ PortableConfiguration cfg = new PortableConfiguration();
+ cfg.DefaultKeepDeserialized = false;
+
+ cfg.TypeConfigurations = new List<PortableTypeConfiguration> { typeCfg };
+
+ CheckKeepSerialized(cfg, true);
+ }
+
+ /// <summary>
+ /// Test correct serialization/deserialization of arrays of special types.
+ /// </summary>
+ [Test]
+ public void TestSpecialArrays()
+ {
+ ICollection<PortableTypeConfiguration> typeCfgs =
+ new List<PortableTypeConfiguration>();
+
+ typeCfgs.Add(new PortableTypeConfiguration(typeof(SpecialArray)));
+ typeCfgs.Add(new PortableTypeConfiguration(typeof(SpecialArrayMarshalAware)));
+
+ PortableConfiguration cfg = new PortableConfiguration();
+
+ cfg.TypeConfigurations = typeCfgs;
+
+ PortableMarshaller marsh = new PortableMarshaller(cfg);
+
+ Guid[] guidArr = { Guid.NewGuid() };
+ Guid?[] nGuidArr = { Guid.NewGuid() };
+ DateTime[] dateArr = { DateTime.Now.ToUniversalTime() };
+ DateTime?[] nDateArr = { DateTime.Now.ToUniversalTime() };
+
+ // Use special object.
+ SpecialArray obj1 = new SpecialArray();
+
+ obj1.GuidArr = guidArr;
+ obj1.NGuidArr = nGuidArr;
+ obj1.DateArr = dateArr;
+ obj1.NDateArr = nDateArr;
+
+ byte[] bytes = marsh.Marshal(obj1);
+
+ IPortableObject portObj = marsh.Unmarshal<IPortableObject>(bytes, PortableMode.ForcePortable);
+
+ Assert.AreEqual(guidArr, portObj.GetField<Guid[]>("guidArr"));
+ Assert.AreEqual(nGuidArr, portObj.GetField<Guid?[]>("nGuidArr"));
+ Assert.AreEqual(dateArr, portObj.GetField<DateTime[]>("dateArr"));
+ Assert.AreEqual(nDateArr, portObj.GetField<DateTime?[]>("nDateArr"));
+
+ obj1 = portObj.Deserialize<SpecialArray>();
+
+ Assert.AreEqual(guidArr, obj1.GuidArr);
+ Assert.AreEqual(nGuidArr, obj1.NGuidArr);
+ Assert.AreEqual(dateArr, obj1.DateArr);
+ Assert.AreEqual(nDateArr, obj1.NDateArr);
+
+ // Use special with IGridPortableMarshalAware.
+ SpecialArrayMarshalAware obj2 = new SpecialArrayMarshalAware();
+
+ obj2.GuidArr = guidArr;
+ obj2.NGuidArr = nGuidArr;
+ obj2.DateArr = dateArr;
+ obj2.NDateArr = nDateArr;
+
+ bytes = marsh.Marshal(obj2);
+
+ portObj = marsh.Unmarshal<IPortableObject>(bytes, PortableMode.ForcePortable);
+
+ Assert.AreEqual(guidArr, portObj.GetField<Guid[]>("a"));
+ Assert.AreEqual(nGuidArr, portObj.GetField<Guid?[]>("b"));
+ Assert.AreEqual(dateArr, portObj.GetField<DateTime[]>("c"));
+ Assert.AreEqual(nDateArr, portObj.GetField<DateTime?[]>("d"));
+
+ obj2 = portObj.Deserialize<SpecialArrayMarshalAware>();
+
+ Assert.AreEqual(guidArr, obj2.GuidArr);
+ Assert.AreEqual(nGuidArr, obj2.NGuidArr);
+ Assert.AreEqual(dateArr, obj2.DateArr);
+ Assert.AreEqual(nDateArr, obj2.NDateArr);
+ }
+
+ private static void CheckKeepSerialized(PortableConfiguration cfg, bool expKeep)
+ {
+ if (cfg.TypeConfigurations == null)
+ {
+ cfg.TypeConfigurations = new List<PortableTypeConfiguration>
+ {
+ new PortableTypeConfiguration(typeof(PropertyType))
+ };
+ }
+
+ PortableMarshaller marsh = new PortableMarshaller(cfg);
+
+ byte[] data = marsh.Marshal(new PropertyType());
+
+ IPortableObject portNewObj = marsh.Unmarshal<IPortableObject>(data, PortableMode.ForcePortable);
+
+ PropertyType deserialized1 = portNewObj.Deserialize<PropertyType>();
+ PropertyType deserialized2 = portNewObj.Deserialize<PropertyType>();
+
+ Assert.NotNull(deserialized1);
+
+ Assert.AreEqual(expKeep, deserialized1 == deserialized2);
+ }
+
+ private void CheckHandlesConsistency(HandleOuter outer, HandleInner inner, HandleOuter newOuter,
+ HandleInner newInner)
+ {
+ Assert.True(newOuter != null);
+ Assert.AreEqual(outer.Before, newOuter.Before);
+ Assert.True(newOuter.Inner == newInner);
+ Assert.AreEqual(outer.After, newOuter.After);
+ Assert.AreEqual(outer.RawBefore, newOuter.RawBefore);
+ Assert.True(newOuter.RawInner == newInner);
+ Assert.AreEqual(outer.RawAfter, newOuter.RawAfter);
+
+ Assert.True(newInner != null);
+ Assert.AreEqual(inner.Before, newInner.Before);
+ Assert.True(newInner.Outer == newOuter);
+ Assert.AreEqual(inner.After, newInner.After);
+ Assert.AreEqual(inner.RawBefore, newInner.RawBefore);
+ Assert.True(newInner.RawOuter == newOuter);
+ Assert.AreEqual(inner.RawAfter, newInner.RawAfter);
+ }
+
+ private static void CheckObject(PortableMarshaller marsh, OuterObjectType outObj, InnerObjectType inObj)
+ {
+ inObj.PInt1 = 1;
+ inObj.PInt2 = 2;
+
+ outObj.InObj = inObj;
+
+ byte[] bytes = marsh.Marshal(outObj);
+
+ IPortableObject portOutObj = marsh.Unmarshal<IPortableObject>(bytes, PortableMode.ForcePortable);
+
+ Assert.AreEqual(outObj.GetHashCode(), portOutObj.GetHashCode());
+
+ OuterObjectType newOutObj = portOutObj.Deserialize<OuterObjectType>();
+
+ Assert.AreEqual(outObj, newOutObj);
+ }
+
+ public class OuterObjectType
+ {
+ public InnerObjectType InObj { get; set; }
+
+ /** <inheritdoc /> */
+ public override bool Equals(object obj)
+ {
+ if (this == obj)
+ return true;
+
+ var type = obj as OuterObjectType;
+
+ return type != null && Equals(InObj, type.InObj);
+ }
+
+ /** <inheritdoc /> */
+ public override int GetHashCode()
+ {
+ return InObj != null ? InObj.GetHashCode() : 0;
+ }
+ }
+
+ public class InnerObjectType
+ {
+ public int PInt1 { get; set; }
+
+ public int PInt2 { get; set; }
+
+ /** <inheritdoc /> */
+ public override bool Equals(object obj)
+ {
+ if (this == obj)
+ return true;
+
+ var that = obj as InnerObjectType;
+
+ return that != null && (PInt1 == that.PInt1 && PInt2 == that.PInt2);
+ }
+
+ /** <inheritdoc /> */
+ public override int GetHashCode()
+ {
+ return 31 * PInt1 + PInt2;
+ }
+
+ /** <inheritdoc /> */
+ public override string ToString()
+ {
+ return "InnerObjectType[pInt1=" + PInt1 + ", pInt2=" + PInt2 + ']';
+ }
+ }
+
+ public class CollectionsType
+ {
+ public ICollection Col1 { get; set; }
+
+ public ArrayList Col2 { get; set; }
+
+ /** <inheritdoc /> */
+ public override bool Equals(object obj)
+ {
+ if (this == obj)
+ return true;
+
+ if (obj != null && obj is CollectionsType)
+ {
+ CollectionsType that = (CollectionsType)obj;
+
+ return CompareCollections(Col1, that.Col1) && CompareCollections(Col2, that.Col2);
+ }
+ return false;
+ }
+
+ /** <inheritdoc /> */
+ public override int GetHashCode()
+ {
+ int res = Col1 != null ? Col1.GetHashCode() : 0;
+
+ res = 31 * res + (Col2 != null ? Col2.GetHashCode() : 0);
+
+ return res;
+ }
+
+ /** <inheritdoc /> */
+ public override string ToString()
+ {
+ return "CollectoinsType[col1=" + CollectionAsString(Col1) +
+ ", col2=" + CollectionAsString(Col2) + ']';
+ }
+ }
+
+ private static string CollectionAsString(ICollection col)
+ {
+ if (col == null)
+ return null;
+ StringBuilder sb = new StringBuilder("[");
+
+ bool first = true;
+
+ foreach (object elem in col)
+ {
+ if (first)
+ first = false;
+ else
+ sb.Append(", ");
+
+ sb.Append(elem);
+ }
+
+ sb.Append("]");
+
+ return sb.ToString();
+ }
+
+ public class TestList : ArrayList
+ {
+
+ }
+
+ private static bool CompareCollections(ICollection col1, ICollection col2)
+ {
+ if (col1 == null && col2 == null)
+ return true;
+ if (col1 == null || col2 == null)
+ return false;
+
+ return col1.OfType<object>().SequenceEqual(col2.OfType<object>());
+ }
+
+ public class PrimitiveArrayFieldType
+ {
+ public bool[] PBool { get; set; }
+
+ public sbyte[] PSbyte { get; set; }
+
+ public byte[] PByte { get; set; }
+
+ public short[] PShort { get; set; }
+
+ public ushort[] PUshort { get; set; }
+
+ public char[] PChar { get; set; }
+
+ public int[] PInt { get; set; }
+
+ public uint[] PUint { get; set; }
+
+ public long[] PLong { get; set; }
+
+ public ulong[] PUlong { get; set; }
+
+ public float[] PFloat { get; set; }
+
+ public double[] PDouble { get; set; }
+
+ public string[] PString { get; set; }
+
+ public Guid?[] PGuid { get; set; }
+
+ /** <inheritdoc /> */
+ public override bool Equals(object obj)
+ {
+ if (this == obj)
+ return true;
+
+ var other = obj as PrimitiveArrayFieldType;
+
+ return other != null && (PBool == other.PBool &&
+ PByte == other.PByte &&
+ PSbyte == other.PSbyte &&
+ PShort == other.PShort &&
+ PUshort == other.PUshort &&
+ PInt == other.PInt &&
+ PUint == other.PUint &&
+ PLong == other.PLong &&
+ PUlong == other.PUlong &&
+ PChar == other.PChar &&
+ PFloat == other.PFloat &&
+ PDouble == other.PDouble &&
+ PString == other.PString &&
+ PGuid == other.PGuid);
+ }
+
+ /** <inheritdoc /> */
+ public override int GetHashCode()
+ {
+ return PInt != null && PInt.Length > 0 ? PInt[0].GetHashCode() : 0;
+ }
+ }
+
+ public class SpecialArray
+ {
+ public Guid[] GuidArr;
+ public Guid?[] NGuidArr;
+ public DateTime[] DateArr;
+ public DateTime?[] NDateArr;
+ }
+
+ public class SpecialArrayMarshalAware : SpecialArray, IPortableMarshalAware
+ {
+ public void WritePortable(IPortableWriter writer)
+ {
+ writer.WriteObjectArray("a", GuidArr);
+ writer.WriteObjectArray("b", NGuidArr);
+ writer.WriteObjectArray("c", DateArr);
+ writer.WriteObjectArray("d", NDateArr);
+ }
+
+ public void ReadPortable(IPortableReader reader)
+ {
+ GuidArr = reader.ReadObjectArray<Guid>("a");
+ NGuidArr = reader.ReadObjectArray<Guid?>("b");
+ DateArr = reader.ReadObjectArray<DateTime>("c");
+ NDateArr = reader.ReadObjectArray<DateTime?>("d");
+ }
+ }
+
+ public class EnumType
+ {
+ public TestEnum PEnum { get; set; }
+
+ public TestEnum[] PEnumArray { get; set; }
+ }
+
+ public class PrimitiveFieldType
+ {
+ private Guid _pGuid;
+
+ public bool PBool { get; set; }
+
+ public sbyte PSbyte { get; set; }
+
+ public byte PByte { get; set; }
+
+ public short PShort { get; set; }
+
+ public ushort PUshort { get; set; }
+
+ public char PChar { get; set; }
+
+ public int PInt { get; set; }
+
+ public uint PUint { get; set; }
+
+ public long PLong { get; set; }
+
+ public ulong PUlong { get; set; }
+
+ public float PFloat { get; set; }
+
+ public double PDouble { get; set; }
+
+ public string PString { get; set; }
+
+ public Guid PGuid
+ {
+ get { return _pGuid; }
+ set { _pGuid = value; }
+ }
+
+ public Guid? PnGuid { get; set; }
+
+ /** <inheritdoc /> */
+ public override bool Equals(object obj)
+ {
+ if (this == obj)
+ return true;
+
+ if (obj != null && obj is PrimitiveFieldType)
+ {
+ PrimitiveFieldType that = (PrimitiveFieldType)obj;
+
+ return PBool == that.PBool &&
+ PByte == that.PByte &&
+ PSbyte == that.PSbyte &&
+ PShort == that.PShort &&
+ PUshort == that.PUshort &&
+ PInt == that.PInt &&
+ PUint == that.PUint &&
+ PLong == that.PLong &&
+ PUlong == that.PUlong &&
+ PChar == that.PChar &&
+ PFloat == that.PFloat &&
+ PDouble == that.PDouble &&
+ (PString == null && that.PString == null || PString != null && PString.Equals(that.PString)) &&
+ _pGuid.Equals(that._pGuid) &&
+ (PnGuid == null && that.PnGuid == null || PnGuid != null && PnGuid.Equals(that.PnGuid));
+ }
+ return false;
+ }
+
+ /** <inheritdoc /> */
+ public override int GetHashCode()
+ {
+ return PInt;
+ }
+ }
+
+ public class PrimitiveFieldPortableType : PrimitiveFieldType, IPortableMarshalAware
+ {
+ public unsafe void WritePortable(IPortableWriter writer)
+ {
+ writer.WriteBoolean("bool", PBool);
+ writer.WriteByte("byte", PByte);
+ writer.WriteShort("short", PShort);
+ writer.WriteInt("int", PInt);
+ writer.WriteLong("long", PLong);
+ writer.WriteChar("char", PChar);
+ writer.WriteFloat("float", PFloat);
+ writer.WriteDouble("double", PDouble);
+
+ sbyte sByte = PSbyte;
+ ushort uShort = PUshort;
+ uint uInt = PUint;
+ ulong uLong = PUlong;
+
+ writer.WriteByte("sbyte", *(byte*)&sByte);
+ writer.WriteShort("ushort", *(short*)&uShort);
+ writer.WriteInt("uint", *(int*)&uInt);
+ writer.WriteLong("ulong", *(long*)&uLong);
+
+ writer.WriteString("string", PString);
+ writer.WriteGuid("guid", PGuid);
+ writer.WriteGuid("nguid", PnGuid);
+ }
+
+ public unsafe void ReadPortable(IPortableReader reader)
+ {
+ PBool = reader.ReadBoolean("bool");
+ PByte = reader.ReadByte("byte");
+ PShort = reader.ReadShort("short");
+ PInt = reader.ReadInt("int");
+
+ PLong = reader.ReadLong("long");
+ PChar = reader.ReadChar("char");
+ PFloat = reader.ReadFloat("float");
+ PDouble = reader.ReadDouble("double");
+
+ byte sByte = reader.ReadByte("sbyte");
+ short uShort = reader.ReadShort("ushort");
+ int uInt = reader.ReadInt("uint");
+ long uLong = reader.ReadLong("ulong");
+
+ PSbyte = *(sbyte*)&sByte;
+ PUshort = *(ushort*)&uShort;
+ PUint = *(uint*)&uInt;
+ PUlong = *(ulong*)&uLong;
+
+ PString = reader.ReadString("string");
+ PGuid = reader.ReadGuid("guid").Value;
+ PnGuid = reader.ReadGuid("nguid");
+ }
+ }
+
+ public class PrimitiveFieldRawPortableType : PrimitiveFieldType, IPortableMarshalAware
+ {
+ public unsafe void WritePortable(IPortableWriter writer)
+ {
+ IPortableRawWriter rawWriter = writer.RawWriter();
+
+ rawWriter.WriteBoolean(PBool);
+ rawWriter.WriteByte(PByte);
+ rawWriter.WriteShort(PShort);
+ rawWriter.WriteInt(PInt);
+ rawWriter.WriteLong(PLong);
+ rawWriter.WriteChar(PChar);
+ rawWriter.WriteFloat(PFloat);
+ rawWriter.WriteDouble(PDouble);
+
+ sbyte sByte = PSbyte;
+ ushort uShort = PUshort;
+ uint uInt = PUint;
+ ulong uLong = PUlong;
+
+ rawWriter.WriteByte(*(byte*)&sByte);
+ rawWriter.WriteShort(*(short*)&uShort);
+ rawWriter.WriteInt(*(int*)&uInt);
+ rawWriter.WriteLong(*(long*)&uLong);
+
+ rawWriter.WriteString(PString);
+ rawWriter.WriteGuid(PGuid);
+ rawWriter.WriteGuid(PnGuid);
+ }
+
+ public unsafe void ReadPortable(IPortableReader reader)
+ {
+ IPortableRawReader rawReader = reader.RawReader();
+
+ PBool = rawReader.ReadBoolean();
+ PByte = rawReader.ReadByte();
+ PShort = rawReader.ReadShort();
+ PInt = rawReader.ReadInt();
+
+ PLong = rawReader.ReadLong();
+ PChar = rawReader.ReadChar();
+ PFloat = rawReader.ReadFloat();
+ PDouble = rawReader.ReadDouble();
+
+ byte sByte = rawReader.ReadByte();
+ short uShort = rawReader.ReadShort();
+ int uInt = rawReader.ReadInt();
+ long uLong = rawReader.ReadLong();
+
+ PSbyte = *(sbyte*)&sByte;
+ PUshort = *(ushort*)&uShort;
+ PUint = *(uint*)&uInt;
+ PUlong = *(ulong*)&uLong;
+
+ PString = rawReader.ReadString();
+ PGuid = rawReader.ReadGuid().Value;
+ PnGuid = rawReader.ReadGuid();
+ }
+ }
+
+ public class PrimitiveFieldsSerializer : IPortableSerializer
+ {
+ public unsafe void WritePortable(object obj, IPortableWriter writer)
+ {
+ PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
+
+ writer.WriteBoolean("bool", obj0.PBool);
+ writer.WriteByte("byte", obj0.PByte);
+ writer.WriteShort("short", obj0.PShort);
+ writer.WriteInt("int", obj0.PInt);
+ writer.WriteLong("long", obj0.PLong);
+ writer.WriteChar("char", obj0.PChar);
+ writer.WriteFloat("float", obj0.PFloat);
+ writer.WriteDouble("double", obj0.PDouble);
+
+ sbyte sByte = obj0.PSbyte;
+ ushort uShort = obj0.PUshort;
+ uint uInt = obj0.PUint;
+ ulong uLong = obj0.PUlong;
+
+ writer.WriteByte("sbyte", *(byte*)&sByte);
+ writer.WriteShort("ushort", *(short*)&uShort);
+ writer.WriteInt("uint", *(int*)&uInt);
+ writer.WriteLong("ulong", *(long*)&uLong);
+
+ writer.WriteString("string", obj0.PString);
+ writer.WriteGuid("guid", obj0.PGuid);
+ writer.WriteGuid("nguid", obj0.PnGuid);
+ }
+
+ public unsafe void ReadPortable(object obj, IPortableReader reader)
+ {
+ PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
+
+ obj0.PBool = reader.ReadBoolean("bool");
+ obj0.PByte = reader.ReadByte("byte");
+ obj0.PShort = reader.ReadShort("short");
+ obj0.PInt = reader.ReadInt("int");
+
+ obj0.PLong = reader.ReadLong("long");
+ obj0.PChar = reader.ReadChar("char");
+ obj0.PFloat = reader.ReadFloat("float");
+ obj0.PDouble = reader.ReadDouble("double");
+
+ byte sByte = reader.ReadByte("sbyte");
+ short uShort = reader.ReadShort("ushort");
+ int uInt = reader.ReadInt("uint");
+ long uLong = reader.ReadLong("ulong");
+
+ obj0.PSbyte = *(sbyte*)&sByte;
+ obj0.PUshort = *(ushort*)&uShort;
+ obj0.PUint = *(uint*)&uInt;
+ obj0.PUlong = *(ulong*)&uLong;
+
+ obj0.PString = reader.ReadString("string");
+ obj0.PGuid = reader.ReadGuid("guid").Value;
+ obj0.PnGuid = reader.ReadGuid("nguid");
+ }
+ }
+
+ public class PrimitiveFieldsRawSerializer : IPortableSerializer
+ {
+ public unsafe void WritePortable(object obj, IPortableWriter writer)
+ {
+ PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
+
+ IPortableRawWriter rawWriter = writer.RawWriter();
+
+ rawWriter.WriteBoolean(obj0.PBool);
+ rawWriter.WriteByte(obj0.PByte);
+ rawWriter.WriteShort( obj0.PShort);
+ rawWriter.WriteInt( obj0.PInt);
+ rawWriter.WriteLong( obj0.PLong);
+ rawWriter.WriteChar(obj0.PChar);
+ rawWriter.WriteFloat(obj0.PFloat);
+ rawWriter.WriteDouble( obj0.PDouble);
+
+ sbyte sByte = obj0.PSbyte;
+ ushort uShort = obj0.PUshort;
+ uint uInt = obj0.PUint;
+ ulong uLong = obj0.PUlong;
+
+ rawWriter.WriteByte(*(byte*)&sByte);
+ rawWriter.WriteShort(*(short*)&uShort);
+ rawWriter.WriteInt(*(int*)&uInt);
+ rawWriter.WriteLong(*(long*)&uLong);
+
+ rawWriter.WriteString(obj0.PString);
+ rawWriter.WriteGuid(obj0.PGuid);
+ rawWriter.WriteGuid(obj0.PnGuid);
+ }
+
+ public unsafe void ReadPortable(object obj, IPortableReader reader)
+ {
+ PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
+
+ IPortableRawReader rawReader = reader.RawReader();
+
+ obj0.PBool = rawReader.ReadBoolean();
+ obj0.PByte = rawReader.ReadByte();
+ obj0.PShort = rawReader.ReadShort();
+ obj0.PInt = rawReader.ReadInt();
+ obj0.PLong = rawReader.ReadLong();
+ obj0.PChar = rawReader.ReadChar();
+ obj0.PFloat = rawReader.ReadFloat();
+ obj0.PDouble = rawReader.ReadDouble();
+
+ byte sByte = rawReader.ReadByte();
+ short uShort = rawReader.ReadShort();
+ int uInt = rawReader.ReadInt();
+ long uLong = rawReader.ReadLong();
+
+ obj0.PSbyte = *(sbyte*)&sByte;
+ obj0.PUshort = *(ushort*)&uShort;
+ obj0.PUint = *(uint*)&uInt;
+ obj0.PUlong = *(ulong*)&uLong;
+
+ obj0.PString = rawReader.ReadString();
+ obj0.PGuid = rawReader.ReadGuid().Value;
+ obj0.PnGuid = rawReader.ReadGuid();
+ }
+ }
+
+ public static string PrintBytes(byte[] bytes)
+ {
+ StringBuilder sb = new StringBuilder();
+
+ foreach (byte b in bytes)
+ sb.Append(b + " ");
+
+ return sb.ToString();
+ }
+
+ public class HandleOuter : IPortableMarshalAware
+ {
+ public string Before;
+ public HandleInner Inner;
+ public string After;
+
+ public string RawBefore;
+ public HandleInner RawInner;
+ public string RawAfter;
+
+ /** <inheritdoc /> */
+ virtual public void WritePortable(IPortableWriter writer)
+ {
+ writer.WriteString("before", Before);
+ writer.WriteObject("inner", Inner);
+ writer.WriteString("after", After);
+
+ IPortableRawWriter rawWriter = writer.RawWriter();
+
+ rawWriter.WriteString(RawBefore);
+ rawWriter.WriteObject(RawInner);
+ rawWriter.WriteString(RawAfter);
+ }
+
+ /** <inheritdoc /> */
+ virtual public void ReadPortable(IPortableReader reader)
+ {
+ Before = reader.ReadString("before");
+ Inner = reader.ReadObject<HandleInner>("inner");
+ After = reader.ReadString("after");
+
+ IPortableRawReader rawReader = reader.RawReader();
+
+ RawBefore = rawReader.ReadString();
+ RawInner = rawReader.ReadObject<HandleInner>();
+ RawAfter = rawReader.ReadString();
+ }
+ }
+
+ public class HandleInner : IPortableMarshalAware
+ {
+ public string Before;
+ public HandleOuter Outer;
+ public string After;
+
+ public string RawBefore;
+ public HandleOuter RawOuter;
+ public string RawAfter;
+
+ /** <inheritdoc /> */
+ virtual public void WritePortable(IPortableWriter writer)
+ {
+ writer.WriteString("before", Before);
+ writer.WriteObject("outer", Outer);
+ writer.WriteString("after", After);
+
+ IPortableRawWriter rawWriter = writer.RawWriter();
+
+ rawWriter.WriteString(RawBefore);
+ rawWriter.WriteObject(RawOuter);
+ rawWriter.WriteString(RawAfter);
+ }
+
+ /** <inheritdoc /> */
+ virtual public void ReadPortable(IPortableReader reader)
+ {
+ Before = reader.ReadString("before");
+ Outer = reader.ReadObject<HandleOuter>("outer");
+ After = reader.ReadString("after");
+
+ IPortableRawReader rawReader = reader.RawReader();
+
+ RawBefore = rawReader.ReadString();
+ RawOuter = rawReader.ReadObject<HandleOuter>();
+ RawAfter = rawReader.ReadString();
+ }
+ }
+
+
+ public class HandleOuterExclusive : HandleOuter
+ {
+ /** <inheritdoc /> */
+ override public void WritePortable(IPortableWriter writer)
+ {
+ PortableWriterImpl writer0 = (PortableWriterImpl)writer;
+
+ writer.WriteString("before", Before);
+
+ writer0.DetachNext();
+ writer.WriteObject("inner", Inner);
+
+ writer.WriteString("after", After);
+
+ IPortableRawWriter rawWriter = writer.RawWriter();
+
+ rawWriter.WriteString(RawBefore);
+
+ writer0.DetachNext();
+ rawWriter.WriteObject(RawInner);
+
+ rawWriter.WriteString(RawAfter);
+ }
+
+ /** <inheritdoc /> */
+ override public void ReadPortable(IPortableReader reader)
+ {
+ var reader0 = (PortableReaderImpl) reader;
+
+ Before = reader0.ReadString("before");
+
+ reader0.DetachNext();
+ Inner = reader0.ReadObject<HandleInner>("inner");
+
+ After = reader0.ReadString("after");
+
+ var rawReader = (PortableReaderImpl) reader.RawReader();
+
+ RawBefore = rawReader.ReadString();
+
+ reader0.DetachNext();
+ RawInner = rawReader.ReadObject<HandleInner>();
+
+ RawAfter = rawReader.ReadString();
+ }
+ }
+
+ public class PropertyType
+ {
+ public int Field1;
+
+ public int Field2
+ {
+ get;
+ set;
+ }
+ }
+
+ public enum TestEnum
+ {
+ Val1, Val2, Val3 = 10
+ }
+
+ public class DecimalReflective
+ {
+ /** */
+ public decimal Val;
+
+ /** */
+ public decimal[] ValArr;
+ }
+
+ public class DecimalMarshalAware : DecimalReflective, IPortableMarshalAware
+ {
+ /** */
+ public decimal RawVal;
+
+ /** */
+ public decimal[] RawValArr;
+
+ /** <inheritDoc /> */
+ public void WritePortable(IPortableWriter writer)
+ {
+ writer.WriteDecimal("val", Val);
+ writer.WriteDecimalArray("valArr", ValArr);
+
+ IPortableRawWriter rawWriter = writer.RawWriter();
+
+ rawWriter.WriteDecimal(RawVal);
+ rawWriter.WriteDecimalArray(RawValArr);
+ }
+
+ /** <inheritDoc /> */
+ public void ReadPortable(IPortableReader reader)
+ {
+ Val = reader.ReadDecimal("val");
+ ValArr = reader.ReadDecimalArray("valArr");
+
+ IPortableRawReader rawReader = reader.RawReader();
+
+ RawVal = rawReader.ReadDecimal();
+ RawValArr = rawReader.ReadDecimalArray();
+ }
+ }
+
+ /// <summary>
+ /// Date time type.
+ /// </summary>
+ public class DateTimeType : IPortableMarshalAware
+ {
+ public DateTime Loc;
+ public DateTime Utc;
+
+ public DateTime? LocNull;
+ public DateTime? UtcNull;
+
+ public DateTime?[] LocArr;
+ public DateTime?[] UtcArr;
+
+ public DateTime LocRaw;
+ public DateTime UtcRaw;
+
+ public DateTime? LocNullRaw;
+ public DateTime? UtcNullRaw;
+
+ public DateTime?[] LocArrRaw;
+ public DateTime?[] UtcArrRaw;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="now">Current local time.</param>
+ public DateTimeType(DateTime now)
+ {
+ Loc = now;
+ Utc = now.ToUniversalTime();
+
+ LocNull = Loc;
+ UtcNull = Utc;
+
+ LocArr = new DateTime?[] { Loc };
+ UtcArr = new DateTime?[] { Utc };
+
+ LocRaw = Loc;
+ UtcRaw = Utc;
+
+ LocNullRaw = LocNull;
+ UtcNullRaw = UtcNull;
+
+ LocArrRaw = new[] { LocArr[0] };
+ UtcArrRaw = new[] { UtcArr[0] };
+ }
+
+ /** <inheritDoc /> */
+ public void WritePortable(IPortableWriter writer)
+ {
+ writer.WriteDate("loc", Loc);
+ writer.WriteDate("utc", Utc);
+ writer.WriteDate("locNull", LocNull);
+ writer.WriteDate("utcNull", UtcNull);
+ writer.WriteDateArray("locArr", LocArr);
+ writer.WriteDateArray("utcArr", UtcArr);
+
+ IPortableRawWriter rawWriter = writer.RawWriter();
+
+ rawWriter.WriteDate(LocRaw);
+ rawWriter.WriteDate(UtcRaw);
+ rawWriter.WriteDate(LocNullRaw);
+ rawWriter.WriteDate(UtcNullRaw);
+ rawWriter.WriteDateArray(LocArrRaw);
+ rawWriter.WriteDateArray(UtcArrRaw);
+ }
+
+ /** <inheritDoc /> */
+ public void ReadPortable(IPortableReader reader)
+ {
+ Loc = reader.ReadDate("loc", true).Value;
+ Utc = reader.ReadDate("utc", false).Value;
+ LocNull = reader.ReadDate("loc", true).Value;
+ UtcNull = reader.ReadDate("utc", false).Value;
+ LocArr = reader.ReadDateArray("locArr", true);
+ UtcArr = reader.ReadDateArray("utcArr", false);
+
+ IPortableRawReader rawReader = reader.RawReader();
+
+ LocRaw = rawReader.ReadDate(true).Value;
+ UtcRaw = rawReader.ReadDate(false).Value;
+ LocNullRaw = rawReader.ReadDate(true).Value;
+ UtcNullRaw = rawReader.ReadDate(false).Value;
+ LocArrRaw = rawReader.ReadDateArray(true);
+ UtcArrRaw = rawReader.ReadDateArray(false);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/PortableConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/PortableConfigurationTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/PortableConfigurationTest.cs
new file mode 100644
index 0000000..26c9122
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/PortableConfigurationTest.cs
@@ -0,0 +1,173 @@
+/*
+ * 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 Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Portable;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Portable configuration tests.
+ /// </summary>
+ public class PortableConfigurationTest
+ {
+ /** Cache. */
+ private ICache<int, TestGenericPortableBase> _cache;
+
+ /** Random generator. */
+ private static readonly Random Rnd = new Random();
+
+ /** Test types for code config */
+ private static readonly Type[] TestTypes = {
+ typeof (TestGenericPortable<int>),
+ typeof (TestGenericPortable<string>),
+ typeof (TestGenericPortable<TestGenericPortable<int>>),
+ typeof (TestGenericPortable<List<Tuple<int, string>>>),
+ typeof (TestGenericPortable<int, string>),
+ typeof (TestGenericPortable<int, TestGenericPortable<string>>),
+ typeof (TestGenericPortable<int, string, Type>),
+ typeof (TestGenericPortable<int, string, TestGenericPortable<int, string, Type>>)
+ };
+
+ /** Test types for xml config */
+ private static readonly Type[] TestTypesXml = {
+ typeof (TestGenericPortable<long>),
+ typeof (TestGenericPortable<Type>),
+ typeof (TestGenericPortable<TestGenericPortable<long>>),
+ typeof (TestGenericPortable<List<Tuple<long, string>>>),
+ typeof (TestGenericPortable<long, string>),
+ typeof (TestGenericPortable<long, TestGenericPortable<string>>),
+ typeof (TestGenericPortable<long, string, Type>),
+ typeof (TestGenericPortable<long, string, TestGenericPortable<long, string, Type>>)
+ };
+
+ /// <summary>
+ /// Starts the grid with provided config.
+ /// </summary>
+ /// <param name="portableConfiguration">The portable configuration.</param>
+ private void StartGrid(PortableConfiguration portableConfiguration)
+ {
+ Ignition.StopAll(true);
+
+ var grid = Ignition.Start(new IgniteConfiguration
+ {
+ SpringConfigUrl = "config\\cache-portables.xml",
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = TestUtils.TestJavaOptions(),
+ PortableConfiguration = portableConfiguration
+ });
+
+ _cache = grid.GetCache<int, TestGenericPortableBase>(null);
+ }
+
+ /// <summary>
+ /// Test fixture tear-down routine.
+ /// </summary>
+ [TestFixtureTearDown]
+ public void TestFixtureTearDown()
+ {
+ TestUtils.KillProcesses();
+ }
+
+ /// <summary>
+ /// Tests the configuration set in code.
+ /// </summary>
+ [Test]
+ public void TestCodeConfiguration()
+ {
+ StartGrid(new PortableConfiguration
+ {
+ TypeConfigurations = TestTypes.Select(x => new PortableTypeConfiguration(x)).ToList()
+ });
+
+ CheckPortableTypes(TestTypes);
+ }
+
+ /// <summary>
+ /// Tests the configuration set in xml.
+ /// </summary>
+ [Test]
+ public void TestXmlConfiguration()
+ {
+ StartGrid(null);
+
+ CheckPortableTypes(TestTypesXml);
+ }
+
+ /// <summary>
+ /// Checks that specified types are portable and can be successfully used in cache.
+ /// </summary>
+ private void CheckPortableTypes(IEnumerable<Type> testTypes)
+ {
+ int key = 0;
+
+ foreach (var typ in testTypes)
+ {
+ key += 1;
+
+ var inst = CreateInstance(typ);
+
+ _cache.Put(key, inst);
+
+ var result = _cache.Get(key);
+
+ Assert.AreEqual(inst.Prop, result.Prop);
+
+ Assert.AreEqual(typ, result.GetType());
+ }
+ }
+
+ /// <summary>
+ /// Creates the instance of specified test portable type and sets a value on it.
+ /// </summary>
+ private static TestGenericPortableBase CreateInstance(Type type)
+ {
+ var inst = (TestGenericPortableBase)Activator.CreateInstance(type);
+
+ inst.Prop = Rnd.Next(int.MaxValue);
+
+ return inst;
+ }
+ }
+
+ public abstract class TestGenericPortableBase
+ {
+ public object Prop { get; set; }
+ }
+
+ public class TestGenericPortable<T> : TestGenericPortableBase
+ {
+ public T Prop1 { get; set; }
+ }
+
+ public class TestGenericPortable<T1, T2> : TestGenericPortableBase
+ {
+ public T1 Prop1 { get; set; }
+ public T2 Prop2 { get; set; }
+ }
+
+ public class TestGenericPortable<T1, T2, T3> : TestGenericPortableBase
+ {
+ public T1 Prop1 { get; set; }
+ public T2 Prop2 { get; set; }
+ public T3 Prop3 { get; set; }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Process/IIgniteProcessOutputReader.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Process/IIgniteProcessOutputReader.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Process/IIgniteProcessOutputReader.cs
new file mode 100644
index 0000000..d910c78
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Process/IIgniteProcessOutputReader.cs
@@ -0,0 +1,35 @@
+/*
+ * 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.Process
+{
+ using System.Diagnostics;
+
+ /// <summary>
+ /// Process output reader.
+ /// </summary>
+ public interface IIgniteProcessOutputReader
+ {
+ /// <summary>
+ /// Callback invoked when output data appear.
+ /// </summary>
+ /// <param name="proc">Process produced data.</param>
+ /// <param name="data">Data.</param>
+ /// <param name="err">Error flag.</param>
+ void OnOutput(Process proc, string data, bool err);
+ }
+}
[32/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
new file mode 100644
index 0000000..e46ec64
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
@@ -0,0 +1,246 @@
+/*
+ * 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.Compute
+{
+ using System;
+ using System.Collections.Generic;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Compute;
+ using Apache.Ignite.Core.Portable;
+ using Apache.Ignite.Core.Resource;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Test for task and job adapter.
+ /// </summary>
+ public class FailoverTaskSelfTest : AbstractTaskTest
+ {
+ /** */
+ static volatile string _gridName;
+
+ /** */
+ static volatile int _cnt;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public FailoverTaskSelfTest() : base(false) { }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="fork">Fork flag.</param>
+ protected FailoverTaskSelfTest(bool fork) : base(fork) { }
+
+ /// <summary>
+ /// Test for GridComputeJobFailoverException.
+ /// </summary>
+ [Test]
+ public void TestClosureFailoverException()
+ {
+ for (int i = 0; i < 20; i++)
+ {
+ int res = Grid1.GetCompute().Call(new TestClosure());
+
+ Assert.AreEqual(2, res);
+
+ Cleanup();
+ }
+ }
+
+ /// <summary>
+ /// Test for GridComputeJobFailoverException with serializable job.
+ /// </summary>
+ [Test]
+ public void TestTaskAdapterFailoverExceptionSerializable()
+ {
+ TestTaskAdapterFailoverException(true);
+ }
+
+ /// <summary>
+ /// Test for GridComputeJobFailoverException with portable job.
+ /// </summary>
+ [Test]
+ public void TestTaskAdapterFailoverExceptionPortable()
+ {
+ TestTaskAdapterFailoverException(false);
+ }
+
+ /// <summary>
+ /// Test for GridComputeJobFailoverException.
+ /// </summary>
+ private void TestTaskAdapterFailoverException(bool serializable)
+ {
+ int res = Grid1.GetCompute().Execute(new TestTask(),
+ new Tuple<bool, bool>(serializable, true));
+
+ Assert.AreEqual(2, res);
+
+ Cleanup();
+
+ res = Grid1.GetCompute().Execute(new TestTask(),
+ new Tuple<bool, bool>(serializable, false));
+
+ Assert.AreEqual(2, res);
+ }
+
+ /// <summary>
+ /// Cleanup.
+ /// </summary>
+ [TearDown]
+ public void Cleanup()
+ {
+ _cnt = 0;
+
+ _gridName = null;
+ }
+
+ /** <inheritDoc /> */
+ override protected void PortableTypeConfigurations(ICollection<PortableTypeConfiguration> portTypeCfgs)
+ {
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(TestPortableJob)));
+ }
+
+ /// <summary>
+ /// Test task.
+ /// </summary>
+ public class TestTask : ComputeTaskAdapter<Tuple<bool, bool>, int, int>
+ {
+ /** <inheritDoc /> */
+ override public IDictionary<IComputeJob<int>, IClusterNode> Map(IList<IClusterNode> subgrid, Tuple<bool, bool> arg)
+ {
+ Assert.AreEqual(3, subgrid.Count);
+
+ Tuple<bool, bool> t = arg;
+
+ bool serializable = t.Item1;
+ bool local = t.Item2;
+
+ IDictionary<IComputeJob<int>, IClusterNode> jobs = new Dictionary<IComputeJob<int>, IClusterNode>();
+
+ IComputeJob<int> job;
+
+ if (serializable)
+ job = new TestSerializableJob();
+ else
+ job = new TestPortableJob();
+
+ foreach (IClusterNode node in subgrid) {
+ bool add = local ? node.IsLocal : !node.IsLocal;
+
+ if (add)
+ {
+ jobs.Add(job, node);
+
+ break;
+ }
+ }
+
+ Assert.AreEqual(1, jobs.Count);
+
+ return jobs;
+ }
+
+ /** <inheritDoc /> */
+ override public int Reduce(IList<IComputeJobResult<int>> results)
+ {
+ Assert.AreEqual(1, results.Count);
+
+ return results[0].Data();
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Serializable]
+ class TestClosure : IComputeFunc<int>
+ {
+ [InstanceResource]
+ private IIgnite _grid = null;
+
+ /** <inheritDoc /> */
+ public int Invoke()
+ {
+ return FailoverJob(_grid);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Serializable]
+ class TestSerializableJob : IComputeJob<int>
+ {
+ [InstanceResource]
+ private IIgnite _grid = null;
+
+ /** <inheritDoc /> */
+ public int Execute()
+ {
+ return FailoverJob(_grid);
+ }
+
+ /** <inheritDoc /> */
+ public void Cancel()
+ {
+ // No-op.
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ class TestPortableJob : IComputeJob<int>
+ {
+ [InstanceResource]
+ private IIgnite _grid = null;
+
+ /** <inheritDoc /> */
+ public int Execute()
+ {
+ return FailoverJob(_grid);
+ }
+
+ public void Cancel()
+ {
+ // No-op.
+ }
+ }
+
+ /// <summary>
+ /// Throws GridComputeJobFailoverException on first call.
+ /// </summary>
+ private static int FailoverJob(IIgnite grid)
+ {
+ Assert.NotNull(grid);
+
+ _cnt++;
+
+ if (_gridName == null)
+ {
+ _gridName = grid.Name;
+
+ throw new ComputeJobFailoverException("Test error.");
+ }
+ Assert.AreNotEqual(_gridName, grid.Name);
+
+ return _cnt;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedPortableClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedPortableClosureTaskTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedPortableClosureTaskTest.cs
new file mode 100644
index 0000000..4ce917b
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedPortableClosureTaskTest.cs
@@ -0,0 +1,30 @@
+/*
+ * 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.Compute.Forked
+{
+ /// <summary>
+ /// Forked closure execution tests for portable objects.
+ /// </summary>
+ public class ForkedPortableClosureTaskTest : PortableClosureTaskTest
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public ForkedPortableClosureTaskTest() : base(true) { }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedResourceTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedResourceTaskTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedResourceTaskTest.cs
new file mode 100644
index 0000000..84c1ba2
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedResourceTaskTest.cs
@@ -0,0 +1,33 @@
+/*
+ * 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.Compute.Forked
+{
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Forked resource task test.
+ /// </summary>
+ [Ignore("IGNITE-1381")]
+ public class ForkedResourceTaskTest : ResourceTaskTest
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public ForkedResourceTaskTest() : base(true) { }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedSerializableClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedSerializableClosureTaskTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedSerializableClosureTaskTest.cs
new file mode 100644
index 0000000..0324125
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedSerializableClosureTaskTest.cs
@@ -0,0 +1,33 @@
+/*
+ * 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.Compute.Forked
+{
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Forked closure execution tests for serializable objects.
+ /// </summary>
+ [Ignore("IGNITE-1381")]
+ public class ForkedSerializableClosureTaskTest : SerializableClosureTaskTest
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public ForkedSerializableClosureTaskTest() : base(true) { }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedTaskAdapterTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedTaskAdapterTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedTaskAdapterTest.cs
new file mode 100644
index 0000000..a4cf182
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedTaskAdapterTest.cs
@@ -0,0 +1,30 @@
+/*
+ * 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.Compute.Forked
+{
+ /// <summary>
+ /// Forked task adapter test.
+ /// </summary>
+ public class ForkedTaskAdapterTest : TaskAdapterTest
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public ForkedTaskAdapterTest() : base(true) { }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
new file mode 100644
index 0000000..62f860d
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
@@ -0,0 +1,753 @@
+/*
+ * 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.Compute
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Runtime.Serialization;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Compute;
+ using Apache.Ignite.Core.Resource;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests for exception handling on various task execution stages.
+ /// </summary>
+ public class IgniteExceptionTaskSelfTest : AbstractTaskTest
+ {
+ /** Error mode. */
+ public static ErrorMode Mode;
+
+ /** Observed job errors. */
+ public static readonly ICollection<Exception> JobErrs = new List<Exception>();
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public IgniteExceptionTaskSelfTest() : base(false) { }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="fork">Fork flag.</param>
+ protected IgniteExceptionTaskSelfTest(bool fork) : base(fork) { }
+
+ /// <summary>
+ /// Test error occurred during map step.
+ /// </summary>
+ [Test]
+ public void TestMapError()
+ {
+ Mode = ErrorMode.MapErr;
+
+ GoodException e = ExecuteWithError() as GoodException;
+
+ Assert.IsNotNull(e);
+
+ Assert.AreEqual(ErrorMode.MapErr, e.Mode);
+ }
+
+ /// <summary>
+ /// Test not-marshalable error occurred during map step.
+ /// </summary>
+ [Test]
+ public void TestMapNotMarshalableError()
+ {
+ Mode = ErrorMode.MapErrNotMarshalable;
+
+ BadException e = ExecuteWithError() as BadException;
+
+ Assert.IsNotNull(e);
+
+ Assert.AreEqual(ErrorMode.MapErrNotMarshalable, e.Mode);
+ }
+
+ /// <summary>
+ /// Test task behavior when job produced by mapper is not marshalable.
+ /// </summary>
+ [Test]
+ public void TestMapNotMarshalableJob()
+ {
+ Mode = ErrorMode.MapJobNotMarshalable;
+
+ SerializationException e = ExecuteWithError() as SerializationException;
+
+ Assert.IsNotNull(e);
+ }
+
+ /// <summary>
+ /// Test local job error.
+ /// </summary>
+ [Test]
+ public void TestLocalJobError()
+ {
+ Mode = ErrorMode.LocJobErr;
+
+ int res = Execute();
+
+ Assert.AreEqual(2, res);
+
+ Assert.AreEqual(1, JobErrs.Count);
+ Assert.IsNotNull(JobErrs.First() as GoodException);
+ Assert.AreEqual(ErrorMode.LocJobErr, ((GoodException) JobErrs.First()).Mode);
+ }
+
+ /// <summary>
+ /// Test local not-marshalable job error.
+ /// </summary>
+ [Test]
+ public void TestLocalJobErrorNotMarshalable()
+ {
+ Mode = ErrorMode.LocJobErrNotMarshalable;
+
+ int res = Execute();
+
+ Assert.AreEqual(2, res);
+
+ Assert.AreEqual(1, JobErrs.Count);
+ Assert.IsNotNull(JobErrs.First() as BadException); // Local job exception is not marshalled.
+ }
+
+ /// <summary>
+ /// Test local not-marshalable job result.
+ /// </summary>
+ [Test]
+ public void TestLocalJobResultNotMarshalable()
+ {
+ Mode = ErrorMode.LocJobResNotMarshalable;
+
+ int res = Execute();
+
+ Assert.AreEqual(3, res); // Local job result is not marshalled.
+
+ Assert.AreEqual(0, JobErrs.Count);
+ }
+
+ /// <summary>
+ /// Test remote job error.
+ /// </summary>
+ [Test]
+ public void TestRemoteJobError()
+ {
+ Mode = ErrorMode.RmtJobErr;
+
+ int res = Execute();
+
+ Assert.AreEqual(1, res);
+
+ Assert.AreEqual(2, JobErrs.Count);
+
+ Assert.IsNotNull(JobErrs.ElementAt(0) as GoodException);
+ Assert.IsNotNull(JobErrs.ElementAt(1) as GoodException);
+
+ Assert.AreEqual(ErrorMode.RmtJobErr, ((GoodException) JobErrs.ElementAt(0)).Mode);
+ Assert.AreEqual(ErrorMode.RmtJobErr, ((GoodException) JobErrs.ElementAt(1)).Mode);
+ }
+
+ /// <summary>
+ /// Test remote not-marshalable job error.
+ /// </summary>
+ [Test]
+ public void TestRemoteJobErrorNotMarshalable()
+ {
+ Mode = ErrorMode.RmtJobErrNotMarshalable;
+
+ int res = Execute();
+
+ Assert.AreEqual(1, res);
+
+ Assert.AreEqual(2, JobErrs.Count);
+
+ Assert.IsNotNull(JobErrs.ElementAt(0) as IgniteException);
+ Assert.IsNotNull(JobErrs.ElementAt(1) as IgniteException);
+ }
+
+ /// <summary>
+ /// Test local not-marshalable job result.
+ /// </summary>
+ [Test]
+ public void TestRemoteJobResultNotMarshalable()
+ {
+ Mode = ErrorMode.RmtJobResNotMarshalable;
+
+ int res = Execute();
+
+ Assert.AreEqual(1, res);
+
+ Assert.AreEqual(2, JobErrs.Count);
+
+ Assert.IsNotNull(JobErrs.ElementAt(0) as IgniteException);
+ Assert.IsNotNull(JobErrs.ElementAt(1) as IgniteException);
+ }
+
+ /// <summary>
+ /// Test local result error.
+ /// </summary>
+ [Test]
+ public void TestLocalResultError()
+ {
+ Mode = ErrorMode.LocResErr;
+
+ GoodException e = ExecuteWithError() as GoodException;
+
+ Assert.IsNotNull(e);
+
+ Assert.AreEqual(ErrorMode.LocResErr, e.Mode);
+ }
+
+ /// <summary>
+ /// Test local result not-marshalable error.
+ /// </summary>
+ [Test]
+ public void TestLocalResultErrorNotMarshalable()
+ {
+ Mode = ErrorMode.LocResErrNotMarshalable;
+
+ BadException e = ExecuteWithError() as BadException;
+
+ Assert.IsNotNull(e);
+
+ Assert.AreEqual(ErrorMode.LocResErrNotMarshalable, e.Mode);
+ }
+
+ /// <summary>
+ /// Test remote result error.
+ /// </summary>
+ [Test]
+ public void TestRemoteResultError()
+ {
+ Mode = ErrorMode.RmtResErr;
+
+ GoodException e = ExecuteWithError() as GoodException;
+
+ Assert.IsNotNull(e);
+
+ Assert.AreEqual(ErrorMode.RmtResErr, e.Mode);
+ }
+
+ /// <summary>
+ /// Test remote result not-marshalable error.
+ /// </summary>
+ [Test]
+ public void TestRemoteResultErrorNotMarshalable()
+ {
+ Mode = ErrorMode.RmtResErrNotMarshalable;
+
+ BadException e = ExecuteWithError() as BadException;
+
+ Assert.IsNotNull(e);
+
+ Assert.AreEqual(ErrorMode.RmtResErrNotMarshalable, e.Mode);
+ }
+
+ /// <summary>
+ /// Test reduce with error.
+ /// </summary>
+ [Test]
+ public void TestReduceError()
+ {
+ Mode = ErrorMode.ReduceErr;
+
+ GoodException e = ExecuteWithError() as GoodException;
+
+ Assert.IsNotNull(e);
+
+ Assert.AreEqual(ErrorMode.ReduceErr, e.Mode);
+ }
+
+ /// <summary>
+ /// Test reduce with not-marshalable error.
+ /// </summary>
+ [Test]
+ public void TestReduceErrorNotMarshalable()
+ {
+ Mode = ErrorMode.ReduceErrNotMarshalable;
+
+ BadException e = ExecuteWithError() as BadException;
+
+ Assert.IsNotNull(e);
+
+ Assert.AreEqual(ErrorMode.ReduceErrNotMarshalable, e.Mode);
+ }
+
+ /// <summary>
+ /// Test reduce with not-marshalable result.
+ /// </summary>
+ [Test]
+ public void TestReduceResultNotMarshalable()
+ {
+ Mode = ErrorMode.ReduceResNotMarshalable;
+
+ int res = Execute();
+
+ Assert.AreEqual(3, res);
+ }
+
+ /// <summary>
+ /// Execute task successfully.
+ /// </summary>
+ /// <returns>Task result.</returns>
+ private int Execute()
+ {
+ JobErrs.Clear();
+
+ object res = Grid1.GetCompute().Execute(new Task());
+
+ return res is GoodTaskResult ? ((GoodTaskResult)res).Res : ((BadTaskResult)res).Res;
+ }
+
+ /// <summary>
+ /// Execute task with error.
+ /// </summary>
+ /// <returns>Task</returns>
+ private Exception ExecuteWithError()
+ {
+ JobErrs.Clear();
+
+ Exception err = null;
+
+ try
+ {
+ Grid1.GetCompute().Execute(new Task());
+
+ Assert.Fail();
+ }
+ catch (Exception e)
+ {
+ err = e;
+ }
+
+ return err;
+ }
+
+ /// <summary>
+ /// Error modes.
+ /// </summary>
+ public enum ErrorMode
+ {
+ /** Error during map step. */
+ MapErr,
+
+ /** Error during map step which is not marshalable. */
+ MapErrNotMarshalable,
+
+ /** Job created by mapper is not marshalable. */
+ MapJobNotMarshalable,
+
+ /** Error occurred in local job. */
+ LocJobErr,
+
+ /** Error occurred in local job and is not marshalable. */
+ LocJobErrNotMarshalable,
+
+ /** Local job result is not marshalable. */
+ LocJobResNotMarshalable,
+
+ /** Error occurred in remote job. */
+ RmtJobErr,
+
+ /** Error occurred in remote job and is not marshalable. */
+ RmtJobErrNotMarshalable,
+
+ /** Remote job result is not marshalable. */
+ RmtJobResNotMarshalable,
+
+ /** Error occurred during local result processing. */
+ LocResErr,
+
+ /** Error occurred during local result processing and is not marshalable. */
+ LocResErrNotMarshalable,
+
+ /** Error occurred during remote result processing. */
+ RmtResErr,
+
+ /** Error occurred during remote result processing and is not marshalable. */
+ RmtResErrNotMarshalable,
+
+ /** Error during reduce step. */
+ ReduceErr,
+
+ /** Error during reduce step and is not marshalable. */
+ ReduceErrNotMarshalable,
+
+ /** Reduce result is not marshalable. */
+ ReduceResNotMarshalable
+ }
+
+ /// <summary>
+ /// Task.
+ /// </summary>
+ public class Task : IComputeTask<object, object>
+ {
+ /** Grid. */
+ [InstanceResource]
+ private IIgnite _grid = null;
+
+ /** Result. */
+ private int _res;
+
+ /** <inheritDoc /> */
+ public IDictionary<IComputeJob<object>, IClusterNode> Map(IList<IClusterNode> subgrid, object arg)
+ {
+ switch (Mode)
+ {
+ case ErrorMode.MapErr:
+ throw new GoodException(ErrorMode.MapErr);
+
+ case ErrorMode.MapErrNotMarshalable:
+ throw new BadException(ErrorMode.MapErrNotMarshalable);
+
+ case ErrorMode.MapJobNotMarshalable:
+ {
+ var badJobs = new Dictionary<IComputeJob<object>, IClusterNode>();
+
+ foreach (IClusterNode node in subgrid)
+ badJobs.Add(new BadJob(), node);
+
+ return badJobs;
+ }
+ }
+
+ // Map completes sucessfully and we spread jobs to all nodes.
+ var jobs = new Dictionary<IComputeJob<object>, IClusterNode>();
+
+ foreach (IClusterNode node in subgrid)
+ jobs.Add(new GoodJob(!_grid.GetCluster().GetLocalNode().Id.Equals(node.Id)), node);
+
+ return jobs;
+ }
+
+ /** <inheritDoc /> */
+ public ComputeJobResultPolicy Result(IComputeJobResult<object> res, IList<IComputeJobResult<object>> rcvd)
+ {
+ if (res.Exception() != null)
+ JobErrs.Add(res.Exception());
+ else
+ {
+ object res0 = res.Data();
+
+ bool rmt = res0 is GoodJobResult ? ((GoodJobResult)res0).Rmt : ((BadJobResult)res0).Rmt;
+
+ if (rmt)
+ {
+ switch (Mode)
+ {
+ case ErrorMode.RmtResErr:
+ throw new GoodException(ErrorMode.RmtResErr);
+
+ case ErrorMode.RmtResErrNotMarshalable:
+ throw new BadException(ErrorMode.RmtResErrNotMarshalable);
+ }
+ }
+ else
+ {
+ switch (Mode)
+ {
+ case ErrorMode.LocResErr:
+ throw new GoodException(ErrorMode.LocResErr);
+
+ case ErrorMode.LocResErrNotMarshalable:
+ throw new BadException(ErrorMode.LocResErrNotMarshalable);
+ }
+ }
+
+ _res += 1;
+ }
+
+ return ComputeJobResultPolicy.Wait;
+ }
+
+ /** <inheritDoc /> */
+ public object Reduce(IList<IComputeJobResult<object>> results)
+ {
+ switch (Mode)
+ {
+ case ErrorMode.ReduceErr:
+ throw new GoodException(ErrorMode.ReduceErr);
+
+ case ErrorMode.ReduceErrNotMarshalable:
+ throw new BadException(ErrorMode.ReduceErrNotMarshalable);
+
+ case ErrorMode.ReduceResNotMarshalable:
+ return new BadTaskResult(_res);
+ }
+
+ return new GoodTaskResult(_res);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Serializable]
+ public class GoodJob : IComputeJob<object>
+ {
+ /** Whether the job is remote. */
+ private bool _rmt;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="rmt"></param>
+ public GoodJob(bool rmt)
+ {
+ _rmt = rmt;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="info"></param>
+ /// <param name="context"></param>
+ public GoodJob(SerializationInfo info, StreamingContext context)
+ {
+ _rmt = info.GetBoolean("rmt");
+ }
+
+ /** <inheritDoc /> */
+ public void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ info.AddValue("rmt", _rmt);
+ }
+
+ /** <inheritDoc /> */
+ public object Execute()
+ {
+ if (_rmt)
+ {
+ switch (Mode)
+ {
+ case ErrorMode.RmtJobErr:
+ throw new GoodException(ErrorMode.RmtJobErr);
+
+ case ErrorMode.RmtJobErrNotMarshalable:
+ throw new BadException(ErrorMode.RmtJobErr);
+
+ case ErrorMode.RmtJobResNotMarshalable:
+ return new BadJobResult(_rmt);
+ }
+ }
+ else
+ {
+ switch (Mode)
+ {
+ case ErrorMode.LocJobErr:
+ throw new GoodException(ErrorMode.LocJobErr);
+
+ case ErrorMode.LocJobErrNotMarshalable:
+ throw new BadException(ErrorMode.LocJobErr);
+
+ case ErrorMode.LocJobResNotMarshalable:
+ return new BadJobResult(_rmt);
+ }
+ }
+
+ return new GoodJobResult(_rmt);
+ }
+
+ /** <inheritDoc /> */
+ public void Cancel()
+ {
+ // No-op.
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public class BadJob : IComputeJob<object>
+ {
+ [InstanceResource]
+
+ /** <inheritDoc /> */
+ public object Execute()
+ {
+ throw new NotImplementedException();
+ }
+
+ /** <inheritDoc /> */
+ public void Cancel()
+ {
+ // No-op.
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Serializable]
+ public class GoodJobResult
+ {
+ /** */
+ public bool Rmt;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="rmt"></param>
+ public GoodJobResult(bool rmt)
+ {
+ Rmt = rmt;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="info"></param>
+ /// <param name="context"></param>
+ public GoodJobResult(SerializationInfo info, StreamingContext context)
+ {
+ Rmt = info.GetBoolean("rmt");
+ }
+
+ /** <inheritDoc /> */
+ public void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ info.AddValue("rmt", Rmt);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public class BadJobResult
+ {
+ /** */
+ public bool Rmt;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="rmt"></param>
+ public BadJobResult(bool rmt)
+ {
+ Rmt = rmt;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Serializable]
+ public class GoodTaskResult
+ {
+ /** */
+ public int Res;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="res"></param>
+ public GoodTaskResult(int res)
+ {
+ Res = res;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="info"></param>
+ /// <param name="context"></param>
+ public GoodTaskResult(SerializationInfo info, StreamingContext context)
+ {
+ Res = info.GetInt32("res");
+ }
+
+ /** <inheritDoc /> */
+ public void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ info.AddValue("res", Res);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public class BadTaskResult
+ {
+ /** */
+ public int Res;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="res"></param>
+ public BadTaskResult(int res)
+ {
+ Res = res;
+ }
+ }
+
+ /// <summary>
+ /// Marshalable exception.
+ /// </summary>
+ [Serializable]
+ public class GoodException : Exception
+ {
+ /** */
+ public ErrorMode Mode;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="mode"></param>
+ public GoodException(ErrorMode mode)
+ {
+ Mode = mode;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="info"></param>
+ /// <param name="context"></param>
+ public GoodException(SerializationInfo info, StreamingContext context)
+ {
+ Mode = (ErrorMode)info.GetInt32("mode");
+ }
+
+ /** <inheritDoc /> */
+ public override void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ info.AddValue("mode", (int)Mode);
+
+ base.GetObjectData(info, context);
+ }
+ }
+
+ /// <summary>
+ /// Not marshalable exception.
+ /// </summary>
+ public class BadException : Exception
+ {
+ /** */
+ public ErrorMode Mode;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="mode"></param>
+ public BadException(ErrorMode mode)
+ {
+ Mode = mode;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/PortableClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/PortableClosureTaskTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/PortableClosureTaskTest.cs
new file mode 100644
index 0000000..3ca933e
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/PortableClosureTaskTest.cs
@@ -0,0 +1,217 @@
+/*
+ * 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.Compute
+{
+ using System;
+ using System.Collections.Generic;
+ using Apache.Ignite.Core.Compute;
+ using Apache.Ignite.Core.Portable;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Closure execution tests for portable objects.
+ /// </summary>
+ public class PortableClosureTaskTest : ClosureTaskTest
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public PortableClosureTaskTest() : base(false) { }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="fork">Fork flag.</param>
+ protected PortableClosureTaskTest(bool fork) : base(fork) { }
+
+ /** <inheritDoc /> */
+ protected override void PortableTypeConfigurations(ICollection<PortableTypeConfiguration> portTypeCfgs)
+ {
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableOutFunc)));
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableFunc)));
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableResult)));
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableException)));
+ }
+
+ /** <inheritDoc /> */
+ protected override IComputeFunc<object> OutFunc(bool err)
+ {
+ return new PortableOutFunc(err);
+ }
+
+ /** <inheritDoc /> */
+ protected override IComputeFunc<object, object> Func(bool err)
+ {
+ return new PortableFunc(err);
+ }
+
+ /** <inheritDoc /> */
+ protected override void CheckResult(object res)
+ {
+ Assert.IsTrue(res != null);
+
+ PortableResult res0 = res as PortableResult;
+
+ Assert.IsTrue(res0 != null);
+ Assert.AreEqual(1, res0.Res);
+ }
+
+ /** <inheritDoc /> */
+ protected override void CheckError(Exception err)
+ {
+ Assert.IsTrue(err != null);
+
+ PortableException err0 = err as PortableException;
+
+ Assert.IsTrue(err0 != null);
+ Assert.AreEqual(ErrMsg, err0.Msg);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ private class PortableOutFunc : IComputeFunc<object>
+ {
+ /** Error. */
+ private bool _err;
+
+ /// <summary>
+ ///
+ /// </summary>
+ public PortableOutFunc()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="err"></param>
+ public PortableOutFunc(bool err)
+ {
+ _err = err;
+ }
+
+ /** <inheritDoc /> */
+ public object Invoke()
+ {
+ if (_err)
+ throw new PortableException(ErrMsg);
+ return new PortableResult(1);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ private class PortableFunc : IComputeFunc<object, object>
+ {
+ /** Error. */
+ private bool _err;
+
+ /// <summary>
+ ///
+ /// </summary>
+ public PortableFunc()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="err"></param>
+ public PortableFunc(bool err)
+ {
+ _err = err;
+ }
+
+ /** <inheritDoc /> */
+ public object Invoke(object arg)
+ {
+ if (_err)
+ throw new PortableException(ErrMsg);
+ return new PortableResult(1);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ private class PortableException : Exception, IPortableMarshalAware
+ {
+ /** */
+ public string Msg;
+
+ /// <summary>
+ ///
+ /// </summary>
+ public PortableException()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="msg"></param>
+ public PortableException(string msg) : this()
+ {
+ Msg = msg;
+ }
+
+ /** <inheritDoc /> */
+ public void WritePortable(IPortableWriter writer)
+ {
+ writer.RawWriter().WriteString(Msg);
+ }
+
+ /** <inheritDoc /> */
+ public void ReadPortable(IPortableReader reader)
+ {
+ Msg = reader.RawReader().ReadString();
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ private class PortableResult
+ {
+ /** */
+ public int Res;
+
+ /// <summary>
+ ///
+ /// </summary>
+ public PortableResult()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="res"></param>
+ public PortableResult(int res)
+ {
+ Res = res;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs
new file mode 100644
index 0000000..736aa61
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs
@@ -0,0 +1,253 @@
+/*
+ * 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.Compute
+{
+ using System.Collections.Generic;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Compute;
+ using Apache.Ignite.Core.Portable;
+ using Apache.Ignite.Core.Resource;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Task test result.
+ /// </summary>
+ public class PortableTaskTest : AbstractTaskTest
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public PortableTaskTest() : base(false) { }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="fork">Fork flag.</param>
+ protected PortableTaskTest(bool fork) : base(fork) { }
+
+ /// <summary>
+ /// Test for task result.
+ /// </summary>
+ [Test]
+ public void TestPortableObjectInTask()
+ {
+ IPortableObject taskArg = ToPortable(Grid1, new PortableTaskArgument(100));
+
+ TestTask task = new TestTask(Grid1, taskArg);
+
+ IPortableObject res = Grid1.GetCompute().Execute(task, taskArg);
+
+ Assert.NotNull(res);
+
+ Assert.AreEqual(400, res.GetField<int>("val"));
+
+ PortableTaskResult resObj = res.Deserialize<PortableTaskResult>();
+
+ Assert.AreEqual(400, resObj.Val);
+ }
+
+ private static IPortableObject ToPortable(IIgnite grid, object obj)
+ {
+ var cache = grid.GetCache<object, object>(Cache1Name).WithKeepPortable<object, object>();
+
+ cache.Put(1, obj);
+
+ return (IPortableObject) cache.Get(1);
+ }
+
+ /** <inheritDoc /> */
+ override protected void PortableTypeConfigurations(ICollection<PortableTypeConfiguration> portTypeCfgs)
+ {
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableJobArgument)));
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableJobResult)));
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableTaskArgument)));
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableTaskResult)));
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableJob)));
+ }
+
+ /// <summary>
+ /// Test task.
+ /// </summary>
+ public class TestTask : ComputeTaskAdapter<IPortableObject, IPortableObject, IPortableObject>
+ {
+ /** */
+ private readonly IIgnite _grid;
+
+ private readonly IPortableObject _taskArgField;
+
+ public TestTask(IIgnite grid, IPortableObject taskArgField)
+ {
+ _grid = grid;
+ _taskArgField = taskArgField;
+ }
+
+ /** <inheritDoc /> */
+ override public IDictionary<IComputeJob<IPortableObject>, IClusterNode> Map(IList<IClusterNode> subgrid, IPortableObject arg)
+ {
+ Assert.AreEqual(3, subgrid.Count);
+ Assert.NotNull(_grid);
+
+ IPortableObject taskArg = arg;
+
+ CheckTaskArgument(taskArg);
+
+ CheckTaskArgument(_taskArgField);
+
+ IDictionary<IComputeJob<IPortableObject>, IClusterNode> jobs = new Dictionary<IComputeJob<IPortableObject>, IClusterNode>();
+
+
+ foreach (IClusterNode node in subgrid)
+ {
+ if (!Grid3Name.Equals(node.GetAttribute<string>("org.apache.ignite.ignite.name"))) // Grid3 does not have cache.
+ {
+ PortableJob job = new PortableJob();
+
+ job.Arg = ToPortable(_grid, new PortableJobArgument(200));
+
+ jobs.Add(job, node);
+ }
+ }
+
+ Assert.AreEqual(2, jobs.Count);
+
+ return jobs;
+ }
+
+ private void CheckTaskArgument(IPortableObject taskArg)
+ {
+ Assert.IsNotNull(taskArg);
+
+ Assert.AreEqual(100, taskArg.GetField<int>("val"));
+
+ PortableTaskArgument taskArgObj = taskArg.Deserialize<PortableTaskArgument>();
+
+ Assert.AreEqual(100, taskArgObj.Val);
+ }
+
+ /** <inheritDoc /> */
+ override public IPortableObject Reduce(IList<IComputeJobResult<IPortableObject>> results)
+ {
+ Assert.NotNull(_grid);
+
+ Assert.AreEqual(2, results.Count);
+
+ foreach (IComputeJobResult<IPortableObject> res in results)
+ {
+ IPortableObject jobRes = res.Data();
+
+ Assert.NotNull(jobRes);
+
+ Assert.AreEqual(300, jobRes.GetField<int>("val"));
+
+ PortableJobResult jobResObj = jobRes.Deserialize<PortableJobResult>();
+
+ Assert.AreEqual(300, jobResObj.Val);
+ }
+
+ return ToPortable(_grid, new PortableTaskResult(400));
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ class PortableJobArgument
+ {
+ /** */
+ public int Val;
+
+ public PortableJobArgument(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ class PortableJobResult
+ {
+ /** */
+ public int Val;
+
+ public PortableJobResult(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ class PortableTaskArgument
+ {
+ /** */
+ public int Val;
+
+ public PortableTaskArgument(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ class PortableTaskResult
+ {
+ /** */
+ public int Val;
+
+ public PortableTaskResult(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ class PortableJob : IComputeJob<IPortableObject>
+ {
+ [InstanceResource]
+ private IIgnite _grid = null;
+
+ /** */
+ public IPortableObject Arg;
+
+ /** <inheritDoc /> */
+ public IPortableObject Execute()
+ {
+ Assert.IsNotNull(Arg);
+
+ Assert.AreEqual(200, Arg.GetField<int>("val"));
+
+ PortableJobArgument argObj = Arg.Deserialize<PortableJobArgument>();
+
+ Assert.AreEqual(200, argObj.Val);
+
+ return ToPortable(_grid, new PortableJobResult(300));
+ }
+
+ public void Cancel()
+ {
+ // No-op.
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ResourceTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ResourceTaskTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ResourceTaskTest.cs
new file mode 100644
index 0000000..55bb9d0
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ResourceTaskTest.cs
@@ -0,0 +1,568 @@
+/*
+ * 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.Compute
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Runtime.Serialization;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Compute;
+ using Apache.Ignite.Core.Resource;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Test resource injections in tasks and jobs.
+ /// </summary>
+ public class ResourceTaskTest : AbstractTaskTest
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public ResourceTaskTest() : base(false) { }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="fork">Fork flag.</param>
+ protected ResourceTaskTest(bool fork) : base(fork) { }
+
+ /// <summary>
+ /// Test Ignite injection into the task.
+ /// </summary>
+ [Test]
+ public void TestTaskInjection()
+ {
+ int res = Grid1.GetCompute().Execute(new InjectionTask(), 0);
+
+ Assert.AreEqual(Grid1.GetCluster().GetNodes().Count, res);
+ }
+
+ /// <summary>
+ /// Test Ignite injection into the closure.
+ /// </summary>
+ [Test]
+ public void TestClosureInjection()
+ {
+ var res = Grid1.GetCompute().Broadcast(new InjectionClosure(), 1);
+
+ Assert.AreEqual(Grid1.GetCluster().GetNodes().Count, res.Sum());
+ }
+
+ /// <summary>
+ /// Test Ignite injection into reducer.
+ /// </summary>
+ [Test]
+ public void TestReducerInjection()
+ {
+ int res = Grid1.GetCompute().Apply(new InjectionClosure(), new List<int> { 1, 1, 1 }, new InjectionReducer());
+
+ Assert.AreEqual(Grid1.GetCluster().GetNodes().Count, res);
+ }
+
+ /// <summary>
+ /// Test no-result-cache attribute.
+ /// </summary>
+ [Test]
+ public void TestNoResultCache()
+ {
+ int res = Grid1.GetCompute().Execute(new NoResultCacheTask(), 0);
+
+ Assert.AreEqual(Grid1.GetCluster().GetNodes().Count, res);
+ }
+
+ /// <summary>
+ /// Injection task.
+ /// </summary>
+ public class InjectionTask : Injectee, IComputeTask<object, int, int>
+ {
+ /** <inheritDoc /> */
+ public IDictionary<IComputeJob<int>, IClusterNode> Map(IList<IClusterNode> subgrid, object arg)
+ {
+ CheckInjection();
+
+ return subgrid.ToDictionary(x => (IComputeJob<int>) new InjectionJob(), x => x);
+ }
+
+ /** <inheritDoc /> */
+ public ComputeJobResultPolicy Result(IComputeJobResult<int> res, IList<IComputeJobResult<int>> rcvd)
+ {
+ return ComputeJobResultPolicy.Wait;
+ }
+
+ /** <inheritDoc /> */
+ public int Reduce(IList<IComputeJobResult<int>> results)
+ {
+ return results.Sum(res => res.Data());
+ }
+ }
+
+ /// <summary>
+ /// Injection job.
+ /// </summary>
+ [Serializable]
+ public class InjectionJob : Injectee, IComputeJob<int>
+ {
+ /// <summary>
+ ///
+ /// </summary>
+ public InjectionJob()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="info"></param>
+ /// <param name="context"></param>
+ public InjectionJob(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ // No-op.
+ }
+
+ /** <inheritDoc /> */
+ public int Execute()
+ {
+ CheckInjection();
+
+ return 1;
+ }
+
+ public void Cancel()
+ {
+ // No-op.
+ }
+ }
+
+ /// <summary>
+ /// Injection closure.
+ /// </summary>
+ [Serializable]
+ public class InjectionClosure : IComputeFunc<int, int>
+ {
+ /** */
+ [InstanceResource]
+ private static IIgnite _staticGrid1;
+
+ /** */
+ [InstanceResource]
+ public static IIgnite StaticGrid2;
+
+ /// <summary>
+ ///
+ /// </summary>
+ [InstanceResource]
+ public static IIgnite StaticPropGrid1
+ {
+ get { return _staticGrid1; }
+ set { _staticGrid1 = value; }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [InstanceResource]
+ private static IIgnite StaticPropGrid2
+ {
+ get { return StaticGrid2; }
+ set { StaticGrid2 = value; }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="grid"></param>
+ [InstanceResource]
+ public static void StaticMethod1(IIgnite grid)
+ {
+ _staticGrid1 = grid;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="grid"></param>
+ [InstanceResource]
+ private static void StaticMethod2(IIgnite grid)
+ {
+ StaticGrid2 = grid;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public InjectionClosure()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="info"></param>
+ /// <param name="context"></param>
+ public InjectionClosure(SerializationInfo info, StreamingContext context)
+ {
+ // No-op.
+ }
+
+ /** */
+ [InstanceResource]
+ private readonly IIgnite _grid1 = null;
+
+ /** */
+ [InstanceResource]
+ public IIgnite Grid2;
+
+ /** */
+ private IIgnite _mthdGrid1;
+
+ /** */
+ private IIgnite _mthdGrid2;
+
+ /// <summary>
+ ///
+ /// </summary>
+ [InstanceResource]
+ public IIgnite PropGrid1
+ {
+ get;
+ set;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [InstanceResource]
+ private IIgnite PropGrid2
+ {
+ get;
+ set;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="grid"></param>
+ [InstanceResource]
+ public void Method1(IIgnite grid)
+ {
+ _mthdGrid1 = grid;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="grid"></param>
+ [InstanceResource]
+ private void Method2(IIgnite grid)
+ {
+ _mthdGrid2 = grid;
+ }
+
+ /// <summary>
+ /// Check Ignite injections.
+ /// </summary>
+ protected void CheckInjection()
+ {
+ Assert.IsTrue(_staticGrid1 == null);
+ Assert.IsTrue(StaticGrid2 == null);
+
+ Assert.IsTrue(_grid1 != null);
+ Assert.IsTrue(Grid2 == _grid1);
+
+ Assert.IsTrue(PropGrid1 == _grid1);
+ Assert.IsTrue(PropGrid2 == _grid1);
+
+ Assert.IsTrue(_mthdGrid1 == _grid1);
+ Assert.IsTrue(_mthdGrid2 == _grid1);
+ }
+
+ /** <inheritDoc /> */
+ public void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ // No-op.
+ }
+
+ /** <inheritDoc /> */
+ public int Invoke(int arg)
+ {
+ CheckInjection();
+
+ return arg;
+ }
+ }
+
+ /// <summary>
+ /// Injection reducer.
+ /// </summary>
+ public class InjectionReducer : Injectee, IComputeReducer<int, int>
+ {
+ /** Collected results. */
+ private readonly ICollection<int> _ress = new List<int>();
+
+ /** <inheritDoc /> */
+ public bool Collect(int res)
+ {
+ CheckInjection();
+
+ lock (_ress)
+ {
+ _ress.Add(res);
+ }
+
+ return true;
+ }
+
+ /** <inheritDoc /> */
+ public int Reduce()
+ {
+ CheckInjection();
+
+ lock (_ress)
+ {
+ return _ress.Sum();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Injectee.
+ /// </summary>
+ [Serializable]
+ public class Injectee : ISerializable
+ {
+ /** */
+ [InstanceResource]
+ private static IIgnite _staticGrid1;
+
+ /** */
+ [InstanceResource]
+ public static IIgnite StaticGrid2;
+
+ /// <summary>
+ ///
+ /// </summary>
+ [InstanceResource]
+ public static IIgnite StaticPropGrid1
+ {
+ get { return _staticGrid1; }
+ set { _staticGrid1 = value; }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [InstanceResource]
+ private static IIgnite StaticPropGrid2
+ {
+ get { return StaticGrid2; }
+ set { StaticGrid2 = value; }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="grid"></param>
+ [InstanceResource]
+ public static void StaticMethod1(IIgnite grid)
+ {
+ _staticGrid1 = grid;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="grid"></param>
+ [InstanceResource]
+ private static void StaticMethod2(IIgnite grid)
+ {
+ StaticGrid2 = grid;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public Injectee()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="info"></param>
+ /// <param name="context"></param>
+ public Injectee(SerializationInfo info, StreamingContext context)
+ {
+ // No-op.
+ }
+
+ /** */
+ [InstanceResource]
+ private readonly IIgnite _grid1 = null;
+
+ /** */
+ [InstanceResource]
+ public IIgnite Grid2;
+
+ /** */
+ private IIgnite _mthdGrid1;
+
+ /** */
+ private IIgnite _mthdGrid2;
+
+ /// <summary>
+ ///
+ /// </summary>
+ [InstanceResource]
+ public IIgnite PropGrid1
+ {
+ get;
+ set;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [InstanceResource]
+ private IIgnite PropGrid2
+ {
+ get;
+ set;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="grid"></param>
+ [InstanceResource]
+ public void Method1(IIgnite grid)
+ {
+ _mthdGrid1 = grid;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="grid"></param>
+ [InstanceResource]
+ private void Method2(IIgnite grid)
+ {
+ _mthdGrid2 = grid;
+ }
+
+ /// <summary>
+ /// Check Ignite injections.
+ /// </summary>
+ protected void CheckInjection()
+ {
+ Assert.IsTrue(_staticGrid1 == null);
+ Assert.IsTrue(StaticGrid2 == null);
+
+ Assert.IsTrue(_grid1 != null);
+ Assert.IsTrue(Grid2 == _grid1);
+
+ Assert.IsTrue(PropGrid1 == _grid1);
+ Assert.IsTrue(PropGrid2 == _grid1);
+
+ Assert.IsTrue(_mthdGrid1 == _grid1);
+ Assert.IsTrue(_mthdGrid2 == _grid1);
+ }
+
+ /** <inheritDoc /> */
+ public void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ // No-op.
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [ComputeTaskNoResultCache]
+ public class NoResultCacheTask : IComputeTask<int, int, int>
+ {
+ /** Sum. */
+ private int _sum;
+
+ /** <inheritDoc /> */
+ public IDictionary<IComputeJob<int>, IClusterNode> Map(IList<IClusterNode> subgrid, int arg)
+ {
+ return subgrid.ToDictionary(x => (IComputeJob<int>) new NoResultCacheJob(), x => x);
+ }
+
+ /** <inheritDoc /> */
+ public ComputeJobResultPolicy Result(IComputeJobResult<int> res, IList<IComputeJobResult<int>> rcvd)
+ {
+ Assert.IsTrue(rcvd != null);
+ Assert.IsTrue(rcvd.Count == 0);
+
+ _sum += res.Data();
+
+ return ComputeJobResultPolicy.Wait;
+ }
+
+ /** <inheritDoc /> */
+ public int Reduce(IList<IComputeJobResult<int>> results)
+ {
+ Assert.IsTrue(results != null);
+ Assert.IsTrue(results.Count == 0);
+
+ return _sum;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Serializable]
+ public class NoResultCacheJob : IComputeJob<int>
+ {
+ /// <summary>
+ ///
+ /// </summary>
+ public NoResultCacheJob()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="info"></param>
+ /// <param name="context"></param>
+ public NoResultCacheJob(SerializationInfo info, StreamingContext context)
+ {
+ // No-op.
+ }
+
+ /** <inheritDoc /> */
+ public int Execute()
+ {
+ return 1;
+ }
+
+ public void Cancel()
+ {
+ // No-op.
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/SerializableClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/SerializableClosureTaskTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/SerializableClosureTaskTest.cs
new file mode 100644
index 0000000..ded56ed
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/SerializableClosureTaskTest.cs
@@ -0,0 +1,217 @@
+/*
+ * 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.Compute
+{
+ using System;
+ using System.Runtime.Serialization;
+ using Apache.Ignite.Core.Compute;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Closure execution tests for serializable objects.
+ /// </summary>
+ public class SerializableClosureTaskTest : ClosureTaskTest
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public SerializableClosureTaskTest() : base(false) { }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="fork">Fork flag.</param>
+ protected SerializableClosureTaskTest(bool fork) : base(fork) { }
+
+ /** <inheritDoc /> */
+ protected override IComputeFunc<object> OutFunc(bool err)
+ {
+ return new SerializableOutFunc(err);
+ }
+
+ /** <inheritDoc /> */
+ protected override IComputeFunc<object, object> Func(bool err)
+ {
+ return new SerializableFunc(err);
+ }
+
+ /** <inheritDoc /> */
+ protected override void CheckResult(object res)
+ {
+ Assert.IsTrue(res != null);
+
+ SerializableResult res0 = res as SerializableResult;
+
+ Assert.IsTrue(res0 != null);
+ Assert.AreEqual(1, res0.Res);
+ }
+
+ /** <inheritDoc /> */
+ protected override void CheckError(Exception err)
+ {
+ Assert.IsTrue(err != null);
+
+ SerializableException err0 = err as SerializableException;
+
+ Assert.IsTrue(err0 != null);
+ Assert.AreEqual(ErrMsg, err0.Msg);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Serializable]
+ private class SerializableOutFunc : IComputeFunc<object>
+ {
+ /** Error. */
+ private bool _err;
+
+ /// <summary>
+ ///
+ /// </summary>
+ public SerializableOutFunc()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="err"></param>
+ public SerializableOutFunc(bool err)
+ {
+ _err = err;
+ }
+
+ /** <inheritDoc /> */
+ public object Invoke()
+ {
+ if (_err)
+ throw new SerializableException(ErrMsg);
+ return new SerializableResult(1);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Serializable]
+ private class SerializableFunc : IComputeFunc<object, object>
+ {
+ /** Error. */
+ private bool _err;
+
+ /// <summary>
+ ///
+ /// </summary>
+ public SerializableFunc()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="err"></param>
+ public SerializableFunc(bool err)
+ {
+ _err = err;
+ }
+
+ /** <inheritDoc /> */
+ public object Invoke(object arg)
+ {
+ Console.WriteLine("INVOKED!");
+
+ if (_err)
+ throw new SerializableException(ErrMsg);
+ return new SerializableResult(1);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Serializable]
+ private class SerializableException : Exception
+ {
+ /** */
+ public string Msg;
+
+ /// <summary>
+ ///
+ /// </summary>
+ public SerializableException()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="msg"></param>
+ public SerializableException(string msg) : this()
+ {
+ Msg = msg;
+ }
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="info"></param>
+ /// <param name="context"></param>
+ public SerializableException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ Msg = info.GetString("msg");
+ }
+
+ /** <inheritDoc /> */
+ public override void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ info.AddValue("msg", Msg);
+
+ base.GetObjectData(info, context);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ [Serializable]
+ private class SerializableResult
+ {
+ public int Res;
+
+ /// <summary>
+ ///
+ /// </summary>
+ public SerializableResult()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="res"></param>
+ public SerializableResult(int res)
+ {
+ Res = res;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
new file mode 100644
index 0000000..f7fb422
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
@@ -0,0 +1,274 @@
+/*
+ * 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.Compute
+{
+ using System;
+ using System.Collections.Generic;
+ using Apache.Ignite.Core.Compute;
+ using Apache.Ignite.Core.Portable;
+ using Apache.Ignite.Core.Resource;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Test for task and job adapter.
+ /// </summary>
+ public class TaskAdapterTest : AbstractTaskTest
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public TaskAdapterTest() : base(false) { }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="fork">Fork flag.</param>
+ protected TaskAdapterTest(bool fork) : base(fork) { }
+
+ /// <summary>
+ /// Test for task adapter.
+ /// </summary>
+ [Test]
+ public void TestTaskAdapter()
+ {
+ Assert.AreEqual(3, Grid1.GetCluster().GetNodes().Count);
+
+ HashSet<Guid> allNodes = new HashSet<Guid>();
+
+ for (int i = 0; i < 20 && allNodes.Count < 3; i++)
+ {
+ HashSet<Guid> res = Grid1.GetCompute().Execute(new TestSplitTask(), 1);
+
+ Assert.AreEqual(1, res.Count);
+
+ allNodes.UnionWith(res);
+ }
+
+ Assert.AreEqual(3, allNodes.Count);
+
+ HashSet<Guid> res2 = Grid1.GetCompute().Execute<int, Guid, HashSet<Guid>>(typeof(TestSplitTask), 3);
+
+ Assert.IsTrue(res2.Count > 0);
+
+ Grid1.GetCompute().Execute(new TestSplitTask(), 100);
+
+ Assert.AreEqual(3, allNodes.Count);
+ }
+
+ /// <summary>
+ /// Test for job adapter.
+ /// </summary>
+ [Test]
+ public void TestSerializableJobAdapter()
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ bool res = Grid1.GetCompute().Execute(new TestJobAdapterTask(), true);
+
+ Assert.IsTrue(res);
+ }
+ }
+
+ /// <summary>
+ /// Test for job adapter.
+ /// </summary>
+ [Test]
+ public void TestPortableJobAdapter()
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ bool res = Grid1.GetCompute().Execute(new TestJobAdapterTask(), false);
+
+ Assert.IsTrue(res);
+ }
+ }
+
+ /** <inheritDoc /> */
+ override protected void PortableTypeConfigurations(ICollection<PortableTypeConfiguration> portTypeCfgs)
+ {
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableJob)));
+ }
+
+ /// <summary>
+ /// Test task.
+ /// </summary>
+ public class TestSplitTask : ComputeTaskSplitAdapter<int, Guid, HashSet<Guid>>
+ {
+ /** <inheritDoc /> */
+ override protected ICollection<IComputeJob<Guid>> Split(int gridSize, int arg)
+ {
+ Assert.AreEqual(3, gridSize);
+
+ int jobsNum = arg;
+
+ Assert.IsTrue(jobsNum > 0);
+
+ var jobs = new List<IComputeJob<Guid>>(jobsNum);
+
+ for (int i = 0; i < jobsNum; i++)
+ jobs.Add(new NodeIdJob());
+
+ return jobs;
+ }
+
+ /** <inheritDoc /> */
+ override public HashSet<Guid> Reduce(IList<IComputeJobResult<Guid>> results)
+ {
+ HashSet<Guid> nodes = new HashSet<Guid>();
+
+ foreach (var res in results) {
+ Guid id = res.Data();
+
+ Assert.NotNull(id);
+
+ nodes.Add(id);
+ }
+
+ return nodes;
+ }
+ }
+
+ /// <summary>
+ /// Test task.
+ /// </summary>
+ public class TestJobAdapterTask : ComputeTaskSplitAdapter<bool, bool, bool>
+ {
+ /** <inheritDoc /> */
+ override protected ICollection<IComputeJob<bool>> Split(int gridSize, bool arg)
+ {
+ bool serializable = arg;
+
+ ICollection<IComputeJob<bool>> jobs = new List<IComputeJob<bool>>(1);
+
+ if (serializable)
+ jobs.Add(new SerializableJob(100, "str"));
+ else
+ jobs.Add(new PortableJob(100, "str"));
+
+ return jobs;
+ }
+
+ /** <inheritDoc /> */
+ override public bool Reduce(IList<IComputeJobResult<bool>> results)
+ {
+ Assert.AreEqual(1, results.Count);
+
+ Assert.IsTrue(results[0].Data());
+
+ return true;
+ }
+ }
+
+ /// <summary>
+ /// Test job.
+ /// </summary>
+ [Serializable]
+ public class NodeIdJob : IComputeJob<Guid>
+ {
+ [InstanceResource]
+ private IIgnite _grid = null;
+
+ /** <inheritDoc /> */
+ public Guid Execute()
+ {
+ Assert.NotNull(_grid);
+
+ return _grid.GetCluster().GetLocalNode().Id;
+ }
+
+ /** <inheritDoc /> */
+ public void Cancel()
+ {
+ // No-op.
+ }
+ }
+
+ /// <summary>
+ /// Test serializable job.
+ /// </summary>
+ [Serializable]
+ public class SerializableJob : ComputeJobAdapter<bool>
+ {
+ [InstanceResource]
+ private IIgnite _grid = null;
+
+ public SerializableJob(params object[] args) : base(args)
+ {
+ // No-op.
+ }
+
+ /** <inheritDoc /> */
+ override public bool Execute()
+ {
+ Assert.IsFalse(IsCancelled());
+
+ Cancel();
+
+ Assert.IsTrue(IsCancelled());
+
+ Assert.NotNull(_grid);
+
+ int arg1 = Argument<int>(0);
+
+ Assert.AreEqual(100, arg1);
+
+ string arg2 = Argument<string>(1);
+
+ Assert.AreEqual("str", arg2);
+
+ return true;
+ }
+ }
+
+ /// <summary>
+ /// Test portable job.
+ /// </summary>
+ public class PortableJob : ComputeJobAdapter<bool>
+ {
+ [InstanceResource]
+ private IIgnite _grid = null;
+
+ public PortableJob(params object[] args) : base(args)
+ {
+ // No-op.
+ }
+
+ /** <inheritDoc /> */
+ override public bool Execute()
+ {
+ Assert.IsFalse(IsCancelled());
+
+ Cancel();
+
+ Assert.IsTrue(IsCancelled());
+
+ Assert.NotNull(_grid);
+
+ int arg1 = Argument<int>(0);
+
+ Assert.AreEqual(100, arg1);
+
+ string arg2 = Argument<string>(1);
+
+ Assert.AreEqual("str", arg2);
+
+ return true;
+ }
+ }
+ }
+}
[24/37] ignite git commit: IGNITE-1513: WIP on .Net.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTestAsync.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTestAsync.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTestAsync.cs
new file mode 100644
index 0000000..b0e507a
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTestAsync.cs
@@ -0,0 +1,33 @@
+/*
+ * 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.Services
+{
+ using Apache.Ignite.Core.Services;
+
+ /// <summary>
+ /// Services async tests.
+ /// </summary>
+ public class ServicesTestAsync : ServicesTest
+ {
+ /** <inheritdoc /> */
+ protected override IServices Services
+ {
+ get { return new ServicesAsyncWrapper(Grid1.GetServices()); }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
new file mode 100644
index 0000000..2b0ab8e
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
@@ -0,0 +1,71 @@
+/*
+ * 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.Diagnostics;
+ using System.Reflection;
+ using Apache.Ignite.Core.Tests.Memory;
+ using NUnit.ConsoleRunner;
+
+ public static class TestRunner
+ {
+ [STAThread]
+ static void Main()
+ {
+ Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
+ Debug.AutoFlush = true;
+
+ //TestOne(typeof(ContinuousQueryAtomiclBackupTest), "TestInitialQuery");
+
+ TestAll(typeof (ExecutableTest));
+ //TestAllInAssembly();
+ }
+
+ private static void TestOne(Type testClass, string method)
+ {
+ string[] args = { "/run:" + testClass.FullName + "." + method, Assembly.GetAssembly(testClass).Location };
+
+ int returnCode = Runner.Main(args);
+
+ if (returnCode != 0)
+ Console.Beep();
+ }
+
+ private static void TestAll(Type testClass)
+ {
+ string[] args = { "/run:" + testClass.FullName, Assembly.GetAssembly(testClass).Location };
+
+ int returnCode = Runner.Main(args);
+
+ if (returnCode != 0)
+ Console.Beep();
+ }
+
+ private static void TestAllInAssembly()
+ {
+ string[] args = { Assembly.GetAssembly(typeof(InteropMemoryTest)).Location };
+
+ int returnCode = Runner.Main(args);
+
+ if (returnCode != 0)
+ Console.Beep();
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs
new file mode 100644
index 0000000..3287e2f
--- /dev/null
+++ b/modules/platform/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;
+
+ /// <summary>
+ /// Test utility methods.
+ /// </summary>
+ 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<string> TestJvmOpts = Environment.Is64BitProcess
+ ? new List<string>
+ {
+ "-XX:+HeapDumpOnOutOfMemoryError",
+ "-Xms1g",
+ "-Xmx4g",
+ "-ea"
+ }
+ : new List<string>
+ {
+ "-XX:+HeapDumpOnOutOfMemoryError",
+ "-Xms512m",
+ "-Xmx512m",
+ "-ea",
+ "-DIGNITE_ATOMIC_CACHE_DELETE_HISTORY_SIZE=1000"
+ };
+
+ /** */
+ private static readonly IList<string> JvmDebugOpts =
+ new List<string> { "-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;
+
+ /// <summary>
+ /// Kill Ignite processes.
+ /// </summary>
+ public static void KillProcesses()
+ {
+ IgniteProcess.KillAll();
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public static Random Random
+ {
+ get { return _random ?? (_random = new Random(Interlocked.Increment(ref _seed))); }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <returns></returns>
+ public static IList<string> TestJavaOptions()
+ {
+ IList<string> ops = new List<string>(TestJvmOpts);
+
+ if (JvmDebug)
+ {
+ foreach (string opt in JvmDebugOpts)
+ ops.Add(opt);
+ }
+
+ return ops;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <returns></returns>
+ public static string CreateTestClasspath()
+ {
+ return IgniteManager.CreateClasspath(forceTestClasspath: true);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="action"></param>
+ /// <param name="threadNum"></param>
+ public static void RunMultiThreaded(Action action, int threadNum)
+ {
+ List<Thread> threads = new List<Thread>(threadNum);
+
+ var errors = new ConcurrentBag<Exception>();
+
+ 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);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="action"></param>
+ /// <param name="threadNum"></param>
+ /// <param name="duration">Duration of test execution in seconds</param>
+ public static void RunMultiThreaded(Action action, int threadNum, int duration)
+ {
+ List<Thread> threads = new List<Thread>(threadNum);
+
+ var errors = new ConcurrentBag<Exception>();
+
+ 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);
+ }
+
+ /// <summary>
+ /// Wait for particular topology size.
+ /// </summary>
+ /// <param name="grid">Grid.</param>
+ /// <param name="size">Size.</param>
+ /// <param name="timeout">Timeout.</param>
+ /// <returns>
+ /// <c>True</c> if topology took required size.
+ /// </returns>
+ public static bool WaitTopology(this IIgnite grid, int size, int timeout)
+ {
+ int left = timeout;
+
+ while (true)
+ {
+ if (grid.GetCluster().GetNodes().Count != size)
+ {
+ if (left > 0)
+ {
+ Thread.Sleep(100);
+
+ left -= 100;
+ }
+ else
+ break;
+ }
+ else
+ return true;
+ }
+
+ return false;
+ }
+
+ /// <summary>
+ /// Asserts that the handle registry is empty.
+ /// </summary>
+ /// <param name="timeout">Timeout, in milliseconds.</param>
+ /// <param name="grids">Grids to check.</param>
+ public static void AssertHandleRegistryIsEmpty(int timeout, params IIgnite[] grids)
+ {
+ foreach (var g in grids)
+ AssertHandleRegistryIsEmpty(g, timeout);
+ }
+
+ /// <summary>
+ /// Asserts that the handle registry is empty.
+ /// </summary>
+ /// <param name="grid">The grid to check.</param>
+ /// <param name="timeout">Timeout, in milliseconds.</param>
+ 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));
+ }
+
+ /// <summary>
+ /// Waits for condition, polling in busy wait loop.
+ /// </summary>
+ /// <param name="cond">Condition.</param>
+ /// <param name="timeout">Timeout, in milliseconds.</param>
+ /// <returns>True if condition predicate returned true within interval; false otherwise.</returns>
+ public static bool WaitForCondition(Func<bool> 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/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs
new file mode 100644
index 0000000..a49ee1b
--- /dev/null
+++ b/modules/platform/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;
+
+ /// <summary>
+ /// <see cref="TypeResolver"/> tests.
+ /// </summary>
+ public class TypeResolverTest
+ {
+ /// <summary>
+ /// Tests generic type resolve.
+ /// </summary>
+ [Test]
+ public void TestGenerics()
+ {
+ var testTypes = new[]
+ {
+ typeof (TestGenericPortable<int>),
+ typeof (TestGenericPortable<string>),
+ typeof (TestGenericPortable<TestGenericPortable<int>>),
+ typeof (TestGenericPortable<List<Tuple<int, string>>>),
+ typeof (TestGenericPortable<List<TestGenericPortable<List<Tuple<int, string>>>>>),
+ typeof (List<TestGenericPortable<List<TestGenericPortable<List<Tuple<int, string>>>>>>),
+ typeof (TestGenericPortable<int, string>),
+ typeof (TestGenericPortable<int, TestGenericPortable<string>>),
+ typeof (TestGenericPortable<int, string, Type>),
+ typeof (TestGenericPortable<int, string, TestGenericPortable<int, string, Type>>)
+ };
+
+ 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);
+ }
+ }
+
+ /// <summary>
+ /// Tests loading a type from referenced assembly that is not yet loaded.
+ /// </summary>
+ [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)));
+ }
+
+ /// <summary>
+ /// 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.
+ /// </summary>
+ public void UnusedMethod()
+ {
+ Assert.IsNotNull(typeof(TestClass));
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.sln
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.sln b/modules/platform/dotnet/Apache.Ignite.sln
index ebde1a8..8c099b2 100644
--- a/modules/platform/dotnet/Apache.Ignite.sln
+++ b/modules/platform/dotnet/Apache.Ignite.sln
@@ -3,11 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Core", "Apache.Ignite.Core\Apache.Ignite.Core.csproj", "{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Core.Tests", "..\..\test\dotnet\Apache.Ignite.Core.Tests\Apache.Ignite.Core.Tests.csproj", "{6A62F66C-DA5B-4FBB-8CE7-A95F740FDC7A}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Core.Tests", "Apache.Ignite.Core.Tests\Apache.Ignite.Core.Tests.csproj", "{6A62F66C-DA5B-4FBB-8CE7-A95F740FDC7A}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "..\cpp\common\project\vs\common.vcxproj", "{4F7E4917-4612-4B96-9838-025711ADE391}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Core.Tests.TestDll", "..\..\test\dotnet\Apache.Ignite.Core.Tests.TestDll\Apache.Ignite.Core.Tests.TestDll.csproj", "{F4A69E2D-908E-4F0F-A794-84D508D60E5F}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Core.Tests.TestDll", "Apache.Ignite.Core.Tests.TestDll\Apache.Ignite.Core.Tests.TestDll.csproj", "{F4A69E2D-908E-4F0F-A794-84D508D60E5F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite", "Apache.Ignite\Apache.Ignite.csproj", "{27F7F3C6-BDDE-43A9-B565-856F8395A04B}"
EndProject
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite/Apache.Ignite.csproj
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite/Apache.Ignite.csproj b/modules/platform/dotnet/Apache.Ignite/Apache.Ignite.csproj
index 7f6db3a..0f75069 100644
--- a/modules/platform/dotnet/Apache.Ignite/Apache.Ignite.csproj
+++ b/modules/platform/dotnet/Apache.Ignite/Apache.Ignite.csproj
@@ -63,8 +63,8 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
- <PostBuildEvent>copy $(TargetPath) $(SolutionDir)..\..\test\dotnet\Apache.Ignite.Core.Tests\$(OutDir)
-copy $(TargetPath).config $(SolutionDir)..\..\test\dotnet\Apache.Ignite.Core.Tests\$(OutDir)</PostBuildEvent>
+ <PostBuildEvent>copy $(TargetPath) $(SolutionDir)\Apache.Ignite.Core.Tests\$(OutDir)
+copy $(TargetPath).config $(SolutionDir)\Apache.Ignite.Core.Tests\$(OutDir)</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Apache.Ignite.Core.Tests.TestDll.csproj
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Apache.Ignite.Core.Tests.TestDll.csproj b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Apache.Ignite.Core.Tests.TestDll.csproj
deleted file mode 100644
index f213b34..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Apache.Ignite.Core.Tests.TestDll.csproj
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{F4A69E2D-908E-4F0F-A794-84D508D60E5F}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>Apache.Ignite.Core.Tests.TestDll</RootNamespace>
- <AssemblyName>Apache.Ignite.Core.Tests.TestDll</AssemblyName>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
- <PlatformTarget>x86</PlatformTarget>
- <OutputPath>bin\x86\Debug\</OutputPath>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
- <PlatformTarget>x86</PlatformTarget>
- <OutputPath>bin\x86\Release\</OutputPath>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
- <PlatformTarget>x64</PlatformTarget>
- <OutputPath>bin\x64\Debug\</OutputPath>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
- <PlatformTarget>x64</PlatformTarget>
- <OutputPath>bin\x64\Release\</OutputPath>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- <Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="Microsoft.CSharp" />
- <Reference Include="System.Data" />
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="TestClass.cs" />
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
deleted file mode 100644
index 22d74c9..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-[assembly: AssemblyTitle("Apache.Ignite.Core.Tests.TestDll")]
-[assembly: AssemblyDescription("Apache Ignite .NET Core Tests Testing Library")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Apache Software Foundation")]
-[assembly: AssemblyProduct("Apache.Ignite.Core.Tests.TestDll")]
-[assembly: AssemblyCopyright("Copyright © 2015")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("086e5873-013b-4ffb-93d2-d67881f75bc2")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.5.0")]
-[assembly: AssemblyFileVersion("1.5.0")]
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/TestClass.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/TestClass.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/TestClass.cs
deleted file mode 100644
index 1199f2c..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/TestClass.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.TestDll
-{
- /// <summary>
- /// Test class.
- /// </summary>
- public class TestClass
- {
- /// <summary>
- /// Gets or sets the Id.
- /// </summary>
- public int Id { get; set; }
-
- /// <summary>
- /// Gets or sets the Name.
- /// </summary>
- public string Name { get; set; }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
deleted file mode 100644
index faa5a61..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
+++ /dev/null
@@ -1,242 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{6A62F66C-DA5B-4FBB-8CE7-A95F740FDC7A}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>Apache.Ignite.Core.Tests</RootNamespace>
- <AssemblyName>Apache.Ignite.Core.Tests</AssemblyName>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- </PropertyGroup>
- <PropertyGroup>
- <StartupObject />
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
- <PlatformTarget>x64</PlatformTarget>
- <OutputPath>bin\x64\Debug\</OutputPath>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <DefineConstants>DEBUG</DefineConstants>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
- <PlatformTarget>x64</PlatformTarget>
- <OutputPath>bin\x64\Release\</OutputPath>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
- <PlatformTarget>x86</PlatformTarget>
- <OutputPath>bin\x86\Debug\</OutputPath>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <DefineConstants>DEBUG</DefineConstants>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
- <PlatformTarget>x86</PlatformTarget>
- <OutputPath>bin\x86\Release\</OutputPath>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="Microsoft.CSharp" />
- <Reference Include="nunit-console-runner">
- <HintPath>..\libs\nunit-console-runner.dll</HintPath>
- </Reference>
- <Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\libs\nunit.framework.dll</HintPath>
- </Reference>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- <Reference Include="System.Runtime.Serialization" />
- <Reference Include="System.XML" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Cache\CacheDynamicStartTest.cs" />
- <Compile Include="Cache\CacheTestAsyncWrapper.cs" />
- <Compile Include="Cache\CacheAbstractTest.cs" />
- <Compile Include="Cache\CacheAffinityTest.cs" />
- <Compile Include="Cache\CacheEntryTest.cs" />
- <Compile Include="Cache\CacheForkedTest.cs" />
- <Compile Include="Cache\CacheLocalAtomicTest.cs" />
- <Compile Include="Cache\CacheLocalTest.cs" />
- <Compile Include="Cache\CachePartitionedAtomicNearEnabledTest.cs" />
- <Compile Include="Cache\CachePartitionedAtomicTest.cs" />
- <Compile Include="Cache\CachePartitionedNearEnabledTest.cs" />
- <Compile Include="Cache\CachePartitionedTest.cs" />
- <Compile Include="Cache\CacheReplicatedAtomicTest.cs" />
- <Compile Include="Cache\CacheReplicatedTest.cs" />
- <Compile Include="Cache\Query\Continuous\ContinuousQueryAbstractTest.cs" />
- <Compile Include="Cache\Query\Continuous\ContinuousQueryAtomicBackupTest.cs" />
- <Compile Include="Cache\Query\Continuous\ContinuousQueryAtomicNoBackupTest.cs" />
- <Compile Include="Cache\Query\Continuous\ContinuousQueryNoBackupAbstractTest.cs" />
- <Compile Include="Cache\Query\Continuous\ContinuousQueryTransactionalBackupTest.cs" />
- <Compile Include="Cache\Query\Continuous\ContinuousQueryTransactionalNoBackupTest.cs" />
- <Compile Include="Cache\Query\CacheQueriesTest.cs" />
- <Compile Include="Cache\Store\CacheParallelLoadStoreTest.cs" />
- <Compile Include="Cache\Store\CacheStoreSessionTest.cs" />
- <Compile Include="Cache\Store\CacheStoreTest.cs" />
- <Compile Include="Cache\Store\CacheTestParallelLoadStore.cs" />
- <Compile Include="Cache\Store\CacheTestStore.cs" />
- <Compile Include="Compute\Forked\ForkedPortableClosureTaskTest.cs" />
- <Compile Include="Compute\Forked\ForkedResourceTaskTest.cs" />
- <Compile Include="Compute\Forked\ForkedSerializableClosureTaskTest.cs" />
- <Compile Include="Compute\Forked\ForkedTaskAdapterTest.cs" />
- <Compile Include="Compute\AbstractTaskTest.cs" />
- <Compile Include="Compute\ClosureTaskTest.cs" />
- <Compile Include="Compute\ComputeApiTest.cs" />
- <Compile Include="Compute\ComputeMultithreadedTest.cs" />
- <Compile Include="Compute\IgniteExceptionTaskSelfTest.cs" />
- <Compile Include="Compute\FailoverTaskSelfTest.cs" />
- <Compile Include="Compute\PortableClosureTaskTest.cs" />
- <Compile Include="Compute\PortableTaskTest.cs" />
- <Compile Include="Compute\ResourceTaskTest.cs" />
- <Compile Include="Compute\SerializableClosureTaskTest.cs" />
- <Compile Include="Compute\TaskAdapterTest.cs" />
- <Compile Include="Compute\TaskResultTest.cs" />
- <Compile Include="Dataload\DataStreamerTest.cs" />
- <Compile Include="EventsTest.cs" />
- <Compile Include="Examples\Example.cs" />
- <Compile Include="Examples\ExamplesTest.cs" />
- <Compile Include="Examples\PathUtil.cs" />
- <Compile Include="Examples\ProjectFilesTest.cs" />
- <Compile Include="ExceptionsTest.cs" />
- <Compile Include="ExecutableTest.cs" />
- <Compile Include="FutureTest.cs" />
- <Compile Include="LifecycleTest.cs" />
- <Compile Include="LoadDllTest.cs" />
- <Compile Include="IgniteManagerTest.cs" />
- <Compile Include="MarshallerTest.cs" />
- <Compile Include="MessagingTest.cs" />
- <Compile Include="PortableConfigurationTest.cs" />
- <Compile Include="SerializationTest.cs" />
- <Compile Include="IgniteStartStopTest.cs" />
- <Compile Include="TestUtils.cs" />
- <Compile Include="Memory\InteropMemoryTest.cs" />
- <Compile Include="Portable\PortableApiSelfTest.cs" />
- <Compile Include="Portable\PortableSelfTest.cs" />
- <Compile Include="Process\IgniteProcess.cs" />
- <Compile Include="Process\IgniteProcessConsoleOutputReader.cs" />
- <Compile Include="Process\IIgniteProcessOutputReader.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Query\ImplicitPortablePerson.cs" />
- <Compile Include="Query\NoDefPortablePerson.cs" />
- <Compile Include="Query\PortablePerson.cs" />
- <Compile Include="Services\ServicesTest.cs" />
- <Compile Include="Services\ServicesTestAsync.cs" />
- <Compile Include="Services\ServiceProxyTest.cs" />
- <Compile Include="Services\ServicesAsyncWrapper.cs" />
- <Compile Include="TestRunner.cs" />
- <Compile Include="TypeResolverTest.cs" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\main\dotnet\Apache.Ignite.Core\Apache.Ignite.Core.csproj">
- <Project>{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}</Project>
- <Name>Apache.Ignite.Core</Name>
- </ProjectReference>
- <ProjectReference Include="..\..\..\main\dotnet\Apache.Ignite\Apache.Ignite.csproj">
- <Project>{27F7F3C6-BDDE-43A9-B565-856F8395A04B}</Project>
- <Name>Apache.Ignite</Name>
- </ProjectReference>
- <ProjectReference Include="..\..\..\main\dotnet\Examples\Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj">
- <Project>{dfb08363-202e-412d-8812-349ef10a8702}</Project>
- <Name>Apache.Ignite.ExamplesDll</Name>
- </ProjectReference>
- <ProjectReference Include="..\..\..\main\dotnet\Examples\Apache.Ignite.Examples\Apache.Ignite.Examples.csproj">
- <Project>{069fa680-3c4d-43a9-b84f-e67513b87827}</Project>
- <Name>Apache.Ignite.Examples</Name>
- </ProjectReference>
- <ProjectReference Include="..\Apache.Ignite.Core.Tests.TestDll\Apache.Ignite.Core.Tests.TestDll.csproj">
- <Project>{F4A69E2D-908E-4F0F-A794-84D508D60E5F}</Project>
- <Name>Apache.Ignite.Core.Tests.TestDll</Name>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <Content Include="Config\cache-portables.xml">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="Config\cache-query-continuous.xml">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="Config\cache-query.xml">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- <SubType>Designer</SubType>
- </Content>
- <Content Include="Config\Cache\Store\cache-store-session.xml">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="Config\Compute\compute-grid1.xml">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="Config\Compute\compute-grid2.xml">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="Config\Compute\compute-grid3.xml">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="Config\Compute\compute-standalone.xml">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="Config\Dynamic\dynamic-client.xml">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="Config\Dynamic\dynamic-data-no-cfg.xml">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="Config\Dynamic\dynamic-data.xml">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="Config\Lifecycle\lifecycle-beans.xml">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="Config\Lifecycle\lifecycle-no-beans.xml">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="Config\marshaller-default.xml">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="Config\marshaller-invalid.xml">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="Config\marshaller-portable.xml">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="Config\native-client-test-cache-affinity.xml">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="Config\native-client-test-cache-parallel-store.xml">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="Config\native-client-test-cache-store.xml">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="Config\native-client-test-cache.xml">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="Config\portable.xml">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="Config\start-test-grid1.xml">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="Config\start-test-grid2.xml">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="Config\start-test-grid3.xml">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- </ItemGroup>
- <ItemGroup>
- <Content Include="Config\Apache.Ignite.exe.config.test">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project>
\ No newline at end of file