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 2016/02/02 14:20:08 UTC
[1/4] ignite git commit: IGNITE-1906: .NET: Implemented programmatic
configuration.
Repository: ignite
Updated Branches:
refs/heads/master 28a5247d3 -> ee20f1d9f
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Multicast/TcpDiscoveryMulticastIpFinder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Multicast/TcpDiscoveryMulticastIpFinder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Multicast/TcpDiscoveryMulticastIpFinder.cs
new file mode 100644
index 0000000..25adf56
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Multicast/TcpDiscoveryMulticastIpFinder.cs
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Discovery.Tcp.Multicast
+{
+ using System;
+ using System.ComponentModel;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Discovery.Tcp.Static;
+
+ /// <summary>
+ /// Multicast-based IP finder.
+ /// <para />
+ /// When TCP discovery starts this finder sends multicast request and waits
+ /// for some time when others nodes reply to this request with messages containing their addresses
+ /// </summary>
+ public class TcpDiscoveryMulticastIpFinder : TcpDiscoveryStaticIpFinder
+ {
+ /// <summary>
+ /// Default multicast port.
+ /// </summary>
+ public const int DefaultMulticastPort = 47400;
+
+ /// <summary>
+ /// Default address request attempts.
+ /// </summary>
+ public const int DefaultAddressRequestAttempts = 2;
+
+ /// <summary>
+ /// Default response timeout.
+ /// </summary>
+ public static readonly TimeSpan DefaultResponseTimeout = TimeSpan.FromMilliseconds(500);
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="TcpDiscoveryMulticastIpFinder"/> class.
+ /// </summary>
+ public TcpDiscoveryMulticastIpFinder()
+ {
+ MulticastPort = DefaultMulticastPort;
+ AddressRequestAttempts = DefaultAddressRequestAttempts;
+ ResponseTimeout = DefaultResponseTimeout;
+ }
+
+ /// <summary>
+ /// Gets or sets the local address.
+ /// If provided address is non-loopback then multicast socket is bound to this interface.
+ /// If local address is not set or is any local address then IP finder
+ /// creates multicast sockets for all found non-loopback addresses.
+ /// </summary>
+ public string LocalAddress { get; set; }
+
+ /// <summary>
+ /// Gets or sets the IP address of the multicast group.
+ /// </summary>
+ public string MulticastGroup { get; set; }
+
+ /// <summary>
+ /// Gets or sets the port number which multicast messages are sent to.
+ /// </summary>
+ [DefaultValue(DefaultMulticastPort)]
+ public int MulticastPort { get; set; }
+
+ /// <summary>
+ /// Gets or sets the number of attempts to send multicast address request. IP finder re-sends
+ /// request only in case if no reply for previous request is received.
+ /// </summary>
+ [DefaultValue(DefaultAddressRequestAttempts)]
+ public int AddressRequestAttempts { get; set; }
+
+ /// <summary>
+ /// Gets or sets the response timeout.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:00:00.5")]
+ public TimeSpan ResponseTimeout { get; set; }
+
+ /// <summary>
+ /// Gets or sets the time to live for multicast packets sent out on this
+ /// IP finder in order to control the scope of the multicast.
+ /// </summary>
+ public byte? TimeToLive { get; set; } // TODO: Nullable?
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="TcpDiscoveryMulticastIpFinder"/> class.
+ /// </summary>
+ /// <param name="reader">The reader.</param>
+ internal TcpDiscoveryMulticastIpFinder(IBinaryRawReader reader) : base(reader)
+ {
+ LocalAddress = reader.ReadString();
+ MulticastGroup = reader.ReadString();
+ MulticastPort = reader.ReadInt();
+ AddressRequestAttempts = reader.ReadInt();
+ ResponseTimeout = TimeSpan.FromMilliseconds(reader.ReadInt());
+ TimeToLive = reader.ReadBoolean() ? (byte?) reader.ReadInt() : null;
+ }
+
+ /** <inheritdoc /> */
+ internal override void Write(IBinaryRawWriter writer)
+ {
+ base.Write(writer);
+
+ writer.WriteString(LocalAddress);
+ writer.WriteString(MulticastGroup);
+ writer.WriteInt(MulticastPort);
+ writer.WriteInt(AddressRequestAttempts);
+ writer.WriteInt((int) ResponseTimeout.TotalMilliseconds);
+
+ writer.WriteBoolean(TimeToLive.HasValue);
+
+ if (TimeToLive.HasValue)
+ writer.WriteInt(TimeToLive.Value);
+ }
+
+ /** <inheritdoc /> */
+ protected override byte TypeCode
+ {
+ get { return TypeCodeMulticastIpFinder; }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Static/TcpDiscoveryStaticIpFinder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Static/TcpDiscoveryStaticIpFinder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Static/TcpDiscoveryStaticIpFinder.cs
new file mode 100644
index 0000000..331ca48
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Static/TcpDiscoveryStaticIpFinder.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.
+ */
+
+namespace Apache.Ignite.Core.Discovery.Tcp.Static
+{
+ using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
+ using Apache.Ignite.Core.Binary;
+
+ /// <summary>
+ /// IP Finder which works only with pre-configured list of IP addresses.
+ /// </summary>
+ public class TcpDiscoveryStaticIpFinder : TcpDiscoveryIpFinderBase
+ {
+ /// <summary>
+ /// Gets or sets the end points.
+ /// </summary>
+ [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+ public ICollection<string> Endpoints { get; set; }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="TcpDiscoveryStaticIpFinder"/> class.
+ /// </summary>
+ public TcpDiscoveryStaticIpFinder()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="TcpDiscoveryStaticIpFinder"/> class.
+ /// </summary>
+ /// <param name="reader">The reader.</param>
+ internal TcpDiscoveryStaticIpFinder(IBinaryRawReader reader)
+ {
+ var count = reader.ReadInt();
+
+ if (count > 0)
+ {
+ Endpoints = new List<string>(count);
+
+ for (int i = 0; i < count; i++)
+ Endpoints.Add(reader.ReadString());
+ }
+ }
+
+ /** <inheritdoc /> */
+ internal override void Write(IBinaryRawWriter writer)
+ {
+ base.Write(writer);
+
+ var eps = Endpoints;
+
+ if (eps != null)
+ {
+ writer.WriteInt(eps.Count);
+
+ foreach (var ep in eps)
+ writer.WriteString(ep);
+ }
+ else
+ writer.WriteInt(0);
+ }
+
+ /** <inheritdoc /> */
+ protected override byte TypeCode
+ {
+ get { return TypeCodeVmIpFinder; }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoveryIpFinderBase.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoveryIpFinderBase.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoveryIpFinderBase.cs
new file mode 100644
index 0000000..e06a88d
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoveryIpFinderBase.cs
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Discovery.Tcp
+{
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Discovery.Tcp.Multicast;
+ using Apache.Ignite.Core.Discovery.Tcp.Static;
+
+ /// <summary>
+ /// Base IpFinder class.
+ /// </summary>
+ public abstract class TcpDiscoveryIpFinderBase : ITcpDiscoveryIpFinder
+ {
+ /** */
+ protected const byte TypeCodeVmIpFinder = 1;
+
+ /** */
+ protected const byte TypeCodeMulticastIpFinder = 2;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="TcpDiscoveryIpFinderBase"/> class.
+ /// Prevents user-defined implementations.
+ /// </summary>
+ protected internal TcpDiscoveryIpFinderBase()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Writes this instance to the specified writer.
+ /// </summary>
+ /// <param name="writer">The writer.</param>
+ internal virtual void Write(IBinaryRawWriter writer)
+ {
+ writer.WriteByte(TypeCode);
+ }
+
+ /// <summary>
+ /// Gets the type code to be used in Java to determine ip finder type.
+ /// </summary>
+ protected abstract byte TypeCode { get; }
+
+ /// <summary>
+ /// Reads the instance.
+ /// </summary>
+ internal static TcpDiscoveryIpFinderBase ReadInstance(IBinaryRawReader reader)
+ {
+ var code = reader.ReadByte();
+
+ switch (code)
+ {
+ case TypeCodeVmIpFinder:
+ return new TcpDiscoveryStaticIpFinder(reader);
+
+ case TypeCodeMulticastIpFinder:
+ return new TcpDiscoveryMulticastIpFinder(reader);
+
+ default:
+ return null;
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs
new file mode 100644
index 0000000..ea946e8
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Discovery.Tcp
+{
+ using System;
+ using System.ComponentModel;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Impl.Binary;
+
+ /// <summary>
+ /// TCP discover service provider.
+ /// </summary>
+ public class TcpDiscoverySpi : IDiscoverySpi
+ {
+ /// <summary>
+ /// Default socket timeout.
+ /// </summary>
+ public static readonly TimeSpan DefaultSocketTimeout = TimeSpan.FromMilliseconds(5000);
+
+ /// <summary>
+ /// Default acknowledgement timeout.
+ /// </summary>
+ public static readonly TimeSpan DefaultAckTimeout = TimeSpan.FromMilliseconds(5000);
+
+ /// <summary>
+ /// Default maximum acknowledgement timeout.
+ /// </summary>
+ public static readonly TimeSpan DefaultMaxAckTimeout = TimeSpan.FromMinutes(10);
+
+ /// <summary>
+ /// Default network timeout.
+ /// </summary>
+ public static readonly TimeSpan DefaultNetworkTimeout = TimeSpan.FromMilliseconds(5000);
+
+ /// <summary>
+ /// Default join timeout.
+ /// </summary>
+ public static readonly TimeSpan DefaultJoinTimeout = TimeSpan.Zero;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="TcpDiscoverySpi"/> class.
+ /// </summary>
+ public TcpDiscoverySpi()
+ {
+ SocketTimeout = DefaultSocketTimeout;
+ AckTimeout = DefaultAckTimeout;
+ MaxAckTimeout = DefaultMaxAckTimeout;
+ NetworkTimeout = DefaultNetworkTimeout;
+ JoinTimeout = DefaultJoinTimeout;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="TcpDiscoverySpi"/> class.
+ /// </summary>
+ /// <param name="reader">The reader.</param>
+ internal TcpDiscoverySpi(BinaryReader reader)
+ {
+ IpFinder = reader.ReadBoolean() ? TcpDiscoveryIpFinderBase.ReadInstance(reader) : null;
+
+ SocketTimeout = reader.ReadLongAsTimespan();
+ AckTimeout = reader.ReadLongAsTimespan();
+ MaxAckTimeout = reader.ReadLongAsTimespan();
+ NetworkTimeout = reader.ReadLongAsTimespan();
+ JoinTimeout = reader.ReadLongAsTimespan();
+ }
+
+ /// <summary>
+ /// Gets or sets the IP finder which defines how nodes will find each other on the network.
+ /// </summary>
+ public ITcpDiscoveryIpFinder IpFinder { get; set; }
+
+ /// <summary>
+ /// Gets or sets the socket timeout.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:00:05")]
+ public TimeSpan SocketTimeout { get; set; }
+
+ /// <summary>
+ /// Gets or sets the timeout for receiving acknowledgement for sent message.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:00:05")]
+ public TimeSpan AckTimeout { get; set; }
+
+ /// <summary>
+ /// Gets or sets the maximum timeout for receiving acknowledgement for sent message.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:10:00")]
+ public TimeSpan MaxAckTimeout { get; set; }
+
+ /// <summary>
+ /// Gets or sets the network timeout.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:00:05")]
+ public TimeSpan NetworkTimeout { get; set; }
+
+ /// <summary>
+ /// Gets or sets the join timeout.
+ /// </summary>
+ public TimeSpan JoinTimeout { get; set; }
+
+ /// <summary>
+ /// Writes this instance to the specified writer.
+ /// </summary>
+ internal void Write(IBinaryRawWriter writer)
+ {
+ var ipFinder = IpFinder;
+
+ if (ipFinder != null)
+ {
+ writer.WriteBoolean(true);
+
+ var finder = ipFinder as TcpDiscoveryIpFinderBase;
+
+ if (finder == null)
+ throw new InvalidOperationException("Unsupported IP finder: " + ipFinder.GetType());
+
+ finder.Write(writer);
+ }
+ else
+ writer.WriteBoolean(false);
+
+ writer.WriteLong((long) SocketTimeout.TotalMilliseconds);
+ writer.WriteLong((long) AckTimeout.TotalMilliseconds);
+ writer.WriteLong((long) MaxAckTimeout.TotalMilliseconds);
+ writer.WriteLong((long) NetworkTimeout.TotalMilliseconds);
+ writer.WriteLong((long) JoinTimeout.TotalMilliseconds);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
index a85e24c..d18e790 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
@@ -21,6 +21,7 @@ namespace Apache.Ignite.Core
using System.Diagnostics.CodeAnalysis;
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cache.Configuration;
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Compute;
@@ -93,6 +94,15 @@ namespace Apache.Ignite.Core
ICache<TK, TV> GetOrCreateCache<TK, TV>(string name);
/// <summary>
+ /// Gets existing cache with the given name or creates new one using provided configuration.
+ /// </summary>
+ /// <typeparam name="TK">Cache key type.</typeparam>
+ /// <typeparam name="TV">Cache value type.</typeparam>
+ /// <param name="configuration">Cache configuration.</param>
+ /// <returns>Existing or newly created cache.</returns>
+ ICache<TK, TV> GetOrCreateCache<TK, TV>(CacheConfiguration configuration);
+
+ /// <summary>
/// Dynamically starts new cache using template configuration.
/// </summary>
/// <typeparam name="TK">Cache key type.</typeparam>
@@ -102,8 +112,17 @@ namespace Apache.Ignite.Core
ICache<TK, TV> CreateCache<TK, TV>(string name);
/// <summary>
- /// Destroys dynamically created (with <see cref="CreateCache{TK,TV}"/> or
- /// <see cref="GetOrCreateCache{TK,TV}"/>) cache.
+ /// Dynamically starts new cache using provided configuration.
+ /// </summary>
+ /// <typeparam name="TK">Cache key type.</typeparam>
+ /// <typeparam name="TV">Cache value type.</typeparam>
+ /// <param name="configuration">Cache configuration.</param>
+ /// <returns>Existing or newly created cache.</returns>
+ ICache<TK, TV> CreateCache<TK, TV>(CacheConfiguration configuration);
+
+ /// <summary>
+ /// Destroys dynamically created (with <see cref="CreateCache{TK,TV}(string)"/> or
+ /// <see cref="GetOrCreateCache{TK,TV}(string)"/>) cache.
/// </summary>
/// <param name="name">The name of the cache to stop.</param>
void DestroyCache(string name);
@@ -171,5 +190,11 @@ namespace Apache.Ignite.Core
/// or null if it does not exist and <c>create</c> flag is not set.</returns>
/// <exception cref="IgniteException">If atomic long could not be fetched or created.</exception>
IAtomicLong GetAtomicLong(string name, long initialValue, bool create);
+
+ /// <summary>
+ /// Gets the configuration of this Ignite instance.
+ /// </summary>
+ [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Semantics.")]
+ IgniteConfiguration GetConfiguration();
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
index a4c37d1..1dd22ea 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
@@ -15,12 +15,27 @@
* limitations under the License.
*/
-namespace Apache.Ignite.Core
+#pragma warning disable 618 // deprecated SpringConfigUrl
+ namespace Apache.Ignite.Core
{
+ using System;
using System.Collections.Generic;
+ using System.ComponentModel;
+ using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
+ using System.IO;
+ using System.Linq;
using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Cache.Configuration;
+ using Apache.Ignite.Core.Discovery;
+ using Apache.Ignite.Core.Discovery.Tcp;
+ using Apache.Ignite.Core.Events;
+ using Apache.Ignite.Core.Impl;
+ using Apache.Ignite.Core.Impl.Binary;
+ using Apache.Ignite.Core.Impl.Common;
using Apache.Ignite.Core.Lifecycle;
+ using BinaryReader = Apache.Ignite.Core.Impl.Binary.BinaryReader;
+ using BinaryWriter = Apache.Ignite.Core.Impl.Binary.BinaryWriter;
/// <summary>
/// Grid configuration.
@@ -38,40 +53,238 @@ namespace Apache.Ignite.Core
public const int DefaultJvmMaxMem = 1024;
/// <summary>
- /// Default constructor.
+ /// Default metrics expire time.
+ /// </summary>
+ public static readonly TimeSpan DefaultMetricsExpireTime = TimeSpan.MaxValue;
+
+ /// <summary>
+ /// Default metrics history size.
+ /// </summary>
+ public const int DefaultMetricsHistorySize = 10000;
+
+ /// <summary>
+ /// Default metrics log frequency.
+ /// </summary>
+ public static readonly TimeSpan DefaultMetricsLogFrequency = TimeSpan.FromMilliseconds(60000);
+
+ /// <summary>
+ /// Default metrics update frequency.
+ /// </summary>
+ public static readonly TimeSpan DefaultMetricsUpdateFrequency = TimeSpan.FromMilliseconds(2000);
+
+ /// <summary>
+ /// Default network timeout.
+ /// </summary>
+ public static readonly TimeSpan DefaultNetworkTimeout = TimeSpan.FromMilliseconds(5000);
+
+ /// <summary>
+ /// Default network retry delay.
+ /// </summary>
+ public static readonly TimeSpan DefaultNetworkSendRetryDelay = TimeSpan.FromMilliseconds(1000);
+
+ /// <summary>
+ /// Default network retry count.
+ /// </summary>
+ public const int DefaultNetworkSendRetryCount = 3;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="IgniteConfiguration"/> class.
/// </summary>
public IgniteConfiguration()
{
JvmInitialMemoryMb = DefaultJvmInitMem;
JvmMaxMemoryMb = DefaultJvmMaxMem;
+
+ MetricsExpireTime = DefaultMetricsExpireTime;
+ MetricsHistorySize = DefaultMetricsHistorySize;
+ MetricsLogFrequency = DefaultMetricsLogFrequency;
+ MetricsUpdateFrequency = DefaultMetricsUpdateFrequency;
+ NetworkTimeout = DefaultNetworkTimeout;
+ NetworkSendRetryCount = DefaultNetworkSendRetryCount;
+ NetworkSendRetryDelay = DefaultNetworkSendRetryDelay;
}
/// <summary>
- /// Copying constructor.
+ /// Initializes a new instance of the <see cref="IgniteConfiguration"/> class.
/// </summary>
- /// <param name="cfg">Configuration.</param>
- internal IgniteConfiguration(IgniteConfiguration cfg)
+ /// <param name="configuration">The configuration to copy.</param>
+ public IgniteConfiguration(IgniteConfiguration configuration)
{
- SpringConfigUrl = cfg.SpringConfigUrl;
- JvmDllPath = cfg.JvmDllPath;
- IgniteHome = cfg.IgniteHome;
- JvmClasspath = cfg.JvmClasspath;
- SuppressWarnings = cfg.SuppressWarnings;
+ IgniteArgumentCheck.NotNull(configuration, "configuration");
+
+ CopyLocalProperties(configuration);
+
+ using (var stream = IgniteManager.Memory.Allocate().GetStream())
+ {
+ var marsh = new Marshaller(configuration.BinaryConfiguration);
+
+ configuration.WriteCore(marsh.StartMarshal(stream));
+
+ stream.SynchronizeOutput();
+
+ stream.Seek(0, SeekOrigin.Begin);
+
+ ReadCore(marsh.StartUnmarshal(stream));
+ }
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="IgniteConfiguration"/> class from a reader.
+ /// </summary>
+ /// <param name="binaryReader">The binary reader.</param>
+ internal IgniteConfiguration(BinaryReader binaryReader)
+ {
+ Read(binaryReader);
+ }
+
+ /// <summary>
+ /// Writes this instance to a writer.
+ /// </summary>
+ /// <param name="writer">The writer.</param>
+ internal void Write(BinaryWriter writer)
+ {
+ Debug.Assert(writer != null);
+
+ if (!string.IsNullOrEmpty(SpringConfigUrl))
+ {
+ // Do not write details when there is Spring config.
+ writer.WriteBoolean(false);
+ return;
+ }
+
+ writer.WriteBoolean(true); // details are present
+
+ WriteCore(writer);
+ }
+
+ /// <summary>
+ /// Writes this instance to a writer.
+ /// </summary>
+ /// <param name="writer">The writer.</param>
+ private void WriteCore(BinaryWriter writer)
+ {
+ // Simple properties
+ writer.WriteBoolean(ClientMode);
+ writer.WriteIntArray(IncludedEventTypes == null ? null : IncludedEventTypes.ToArray());
+
+ writer.WriteLong((long) MetricsExpireTime.TotalMilliseconds);
+ writer.WriteInt(MetricsHistorySize);
+ writer.WriteLong((long) MetricsLogFrequency.TotalMilliseconds);
+ var metricsUpdateFreq = (long) MetricsUpdateFrequency.TotalMilliseconds;
+ writer.WriteLong(metricsUpdateFreq >= 0 ? metricsUpdateFreq : -1);
+ writer.WriteInt(NetworkSendRetryCount);
+ writer.WriteLong((long) NetworkSendRetryDelay.TotalMilliseconds);
+ writer.WriteLong((long) NetworkTimeout.TotalMilliseconds);
+ writer.WriteString(WorkDirectory);
+ writer.WriteString(Localhost);
+
+ // Cache config
+ var caches = CacheConfiguration;
+
+ if (caches == null)
+ writer.WriteInt(0);
+ else
+ {
+ writer.WriteInt(caches.Count);
+
+ foreach (var cache in caches)
+ cache.Write(writer);
+ }
+
+ // Discovery config
+ var disco = DiscoverySpi;
+
+ if (disco != null)
+ {
+ writer.WriteBoolean(true);
+
+ var tcpDisco = disco as TcpDiscoverySpi;
+
+ if (tcpDisco == null)
+ throw new InvalidOperationException("Unsupported discovery SPI: " + disco.GetType());
+
+ tcpDisco.Write(writer);
+ }
+ else
+ writer.WriteBoolean(false);
+ }
+
+ /// <summary>
+ /// Reads data from specified reader into current instance.
+ /// </summary>
+ /// <param name="r">The binary reader.</param>
+ private void ReadCore(BinaryReader r)
+ {
+ // Simple properties
+ ClientMode = r.ReadBoolean();
+ IncludedEventTypes = r.ReadIntArray();
- JvmOptions = cfg.JvmOptions != null ? new List<string>(cfg.JvmOptions) : null;
- Assemblies = cfg.Assemblies != null ? new List<string>(cfg.Assemblies) : null;
+ MetricsExpireTime = r.ReadLongAsTimespan();
+ MetricsHistorySize = r.ReadInt();
+ MetricsLogFrequency = r.ReadLongAsTimespan();
+ MetricsUpdateFrequency = r.ReadLongAsTimespan();
+ NetworkSendRetryCount = r.ReadInt();
+ NetworkSendRetryDelay = r.ReadLongAsTimespan();
+ NetworkTimeout = r.ReadLongAsTimespan();
+ WorkDirectory = r.ReadString();
+ Localhost = r.ReadString();
- BinaryConfiguration = cfg.BinaryConfiguration != null
- ? new BinaryConfiguration(cfg.BinaryConfiguration)
- : null;
+ // Cache config
+ var cacheCfgCount = r.ReadInt();
+ CacheConfiguration = new List<CacheConfiguration>(cacheCfgCount);
+ for (int i = 0; i < cacheCfgCount; i++)
+ CacheConfiguration.Add(new CacheConfiguration(r));
- LifecycleBeans = cfg.LifecycleBeans != null ? new List<ILifecycleBean>(cfg.LifecycleBeans) : null;
+ // Discovery config
+ DiscoverySpi = r.ReadBoolean() ? new TcpDiscoverySpi(r) : null;
+ }
+
+ /// <summary>
+ /// Reads data from specified reader into current instance.
+ /// </summary>
+ /// <param name="binaryReader">The binary reader.</param>
+ private void Read(BinaryReader binaryReader)
+ {
+ var r = binaryReader;
+
+ CopyLocalProperties(r.Marshaller.Ignite.Configuration);
+
+ ReadCore(r);
+
+ // Misc
+ IgniteHome = r.ReadString();
- JvmInitialMemoryMb = cfg.JvmInitialMemoryMb;
- JvmMaxMemoryMb = cfg.JvmMaxMemoryMb;
+ JvmInitialMemoryMb = (int) (r.ReadLong()/1024/2014);
+ JvmMaxMemoryMb = (int) (r.ReadLong()/1024/2014);
+
+ // Local data (not from reader)
+ JvmDllPath = Process.GetCurrentProcess().Modules.OfType<ProcessModule>()
+ .Single(x => string.Equals(x.ModuleName, IgniteUtils.FileJvmDll, StringComparison.OrdinalIgnoreCase))
+ .FileName;
+ }
+
+ /// <summary>
+ /// Copies the local properties (properties that are not written in Write method).
+ /// </summary>
+ private void CopyLocalProperties(IgniteConfiguration cfg)
+ {
+ GridName = cfg.GridName;
+ BinaryConfiguration = cfg.BinaryConfiguration == null
+ ? null
+ : new BinaryConfiguration(cfg.BinaryConfiguration);
+ JvmClasspath = cfg.JvmClasspath;
+ JvmOptions = cfg.JvmOptions;
+ Assemblies = cfg.Assemblies;
+ SuppressWarnings = cfg.SuppressWarnings;
+ LifecycleBeans = cfg.LifecycleBeans;
}
/// <summary>
+ /// Grid name which is used if not provided in configuration file.
+ /// </summary>
+ public string GridName { get; set; }
+
+ /// <summary>
/// Gets or sets the binary configuration.
/// </summary>
/// <value>
@@ -80,9 +293,22 @@ namespace Apache.Ignite.Core
public BinaryConfiguration BinaryConfiguration { get; set; }
/// <summary>
+ /// Gets or sets the cache configuration.
+ /// </summary>
+ /// <value>
+ /// The cache configuration.
+ /// </value>
+ [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+ public ICollection<CacheConfiguration> CacheConfiguration { get; set; }
+
+ /// <summary>
/// URL to Spring configuration file.
/// </summary>
[SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")]
+ [Obsolete("Ignite.NET can be configured natively without Spring. " +
+ "Setting this property will ignore all other properties except " +
+ "IgniteHome, Assemblies, SuppressWarnings, LifecycleBeans, JvmOptions, JvmdllPath, IgniteHome, " +
+ "JvmInitialMemoryMb, JvmMaxMemoryMb.")]
public string SpringConfigUrl { get; set; }
/// <summary>
@@ -115,7 +341,7 @@ namespace Apache.Ignite.Core
/// assemblies reside.
/// </summary>
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
- public IList<string> Assemblies { get; set; }
+ public ICollection<string> Assemblies { get; set; }
/// <summary>
/// Whether to suppress warnings.
@@ -132,12 +358,95 @@ namespace Apache.Ignite.Core
/// Initial amount of memory in megabytes given to JVM. Maps to -Xms Java option.
/// Defaults to <see cref="DefaultJvmInitMem"/>.
/// </summary>
+ [DefaultValue(DefaultJvmInitMem)]
public int JvmInitialMemoryMb { get; set; }
/// <summary>
/// Maximum amount of memory in megabytes given to JVM. Maps to -Xmx Java option.
/// Defaults to <see cref="DefaultJvmMaxMem"/>.
/// </summary>
+ [DefaultValue(DefaultJvmMaxMem)]
public int JvmMaxMemoryMb { get; set; }
+
+ /// <summary>
+ /// Gets or sets the discovery service provider.
+ /// Null for default discovery.
+ /// </summary>
+ public IDiscoverySpi DiscoverySpi { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether node should start in client mode.
+ /// Client node cannot hold data in the caches.
+ /// Default is null and takes this setting from Spring configuration.
+ /// </summary>
+ public bool ClientMode { get; set; }
+
+ /// <summary>
+ /// Gets or sets a set of event types (<see cref="EventType" />) to be recorded by Ignite.
+ /// </summary>
+ [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+ public ICollection<int> IncludedEventTypes { get; set; }
+
+ /// <summary>
+ /// Gets or sets the time after which a certain metric value is considered expired.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "10675199.02:48:05.4775807")]
+ public TimeSpan MetricsExpireTime { get; set; }
+
+ /// <summary>
+ /// Gets or sets the number of metrics kept in history to compute totals and averages.
+ /// </summary>
+ [DefaultValue(DefaultMetricsHistorySize)]
+ public int MetricsHistorySize { get; set; }
+
+ /// <summary>
+ /// Gets or sets the frequency of metrics log print out.
+ /// <see cref="TimeSpan.Zero"/> to disable metrics print out.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:01:00")]
+ public TimeSpan MetricsLogFrequency { get; set; }
+
+ /// <summary>
+ /// Gets or sets the job metrics update frequency.
+ /// <see cref="TimeSpan.Zero"/> to update metrics on job start/finish.
+ /// Negative value to never update metrics.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:00:02")]
+ public TimeSpan MetricsUpdateFrequency { get; set; }
+
+ /// <summary>
+ /// Gets or sets the network send retry count.
+ /// </summary>
+ [DefaultValue(DefaultNetworkSendRetryCount)]
+ public int NetworkSendRetryCount { get; set; }
+
+ /// <summary>
+ /// Gets or sets the network send retry delay.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:00:01")]
+ public TimeSpan NetworkSendRetryDelay { get; set; }
+
+ /// <summary>
+ /// Gets or sets the network timeout.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:00:05")]
+ public TimeSpan NetworkTimeout { get; set; }
+
+ /// <summary>
+ /// Gets or sets the work directory.
+ /// If not provided, a folder under <see cref="IgniteHome"/> will be used.
+ /// </summary>
+ public string WorkDirectory { get; set; }
+
+ /// <summary>
+ /// Gets or sets system-wide local address or host for all Ignite components to bind to.
+ /// If provided it will override all default local bind settings within Ignite.
+ /// <para />
+ /// If <c>null</c> then Ignite tries to use local wildcard address.That means that all services
+ /// will be available on all network interfaces of the host machine.
+ /// <para />
+ /// It is strongly recommended to set this parameter for all production environments.
+ /// </summary>
+ public string Localhost { get; set; }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
index 3a27ad1..0549010 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
@@ -15,6 +15,7 @@
* limitations under the License.
*/
+#pragma warning disable 618 // deprecated SpringConfigUrl
namespace Apache.Ignite.Core
{
using System;
@@ -41,7 +42,7 @@ namespace Apache.Ignite.Core
/// <summary>
/// This class defines a factory for the main Ignite API.
/// <p/>
- /// Use <see cref="Ignition.Start()"/> method to start Ignite with default configuration.
+ /// Use <see cref="Start()"/> method to start Ignite with default configuration.
/// <para/>
/// All members are thread-safe and may be used concurrently from multiple threads.
/// </summary>
@@ -51,9 +52,6 @@ namespace Apache.Ignite.Core
internal const string EnvIgniteSpringConfigUrlPrefix = "IGNITE_SPRING_CONFIG_URL_PREFIX";
/** */
- private const string DefaultCfg = "config/default-config.xml";
-
- /** */
private static readonly object SyncRoot = new object();
/** GC warning flag. */
@@ -125,15 +123,6 @@ namespace Apache.Ignite.Core
{
IgniteArgumentCheck.NotNull(cfg, "cfg");
- // Copy configuration to avoid changes to user-provided instance.
- IgniteConfigurationEx cfgEx = cfg as IgniteConfigurationEx;
-
- cfg = cfgEx == null ? new IgniteConfiguration(cfg) : new IgniteConfigurationEx(cfgEx);
-
- // Set default Spring config if needed.
- if (cfg.SpringConfigUrl == null)
- cfg.SpringConfigUrl = DefaultCfg;
-
lock (SyncRoot)
{
// 1. Check GC settings.
@@ -146,9 +135,11 @@ namespace Apache.Ignite.Core
IgniteManager.CreateJvmContext(cfg, cbs);
- var gridName = cfgEx != null ? cfgEx.GridName : null;
+ var gridName = cfg.GridName;
- var cfgPath = Environment.GetEnvironmentVariable(EnvIgniteSpringConfigUrlPrefix) + cfg.SpringConfigUrl;
+ var cfgPath = cfg.SpringConfigUrl == null
+ ? null
+ : Environment.GetEnvironmentVariable(EnvIgniteSpringConfigUrlPrefix) + cfg.SpringConfigUrl;
// 3. Create startup object which will guide us through the rest of the process.
_startup = new Startup(cfg, cbs);
@@ -229,7 +220,7 @@ namespace Apache.Ignite.Core
{
BinaryReader reader = BinaryUtils.Marshaller.StartUnmarshal(inStream);
- PrepareConfiguration(reader);
+ PrepareConfiguration(reader, outStream);
PrepareLifecycleBeans(reader, outStream, handleRegistry);
}
@@ -245,7 +236,8 @@ namespace Apache.Ignite.Core
/// Preapare configuration.
/// </summary>
/// <param name="reader">Reader.</param>
- private static void PrepareConfiguration(BinaryReader reader)
+ /// <param name="outStream">Response stream.</param>
+ private static void PrepareConfiguration(BinaryReader reader, PlatformMemoryStream outStream)
{
// 1. Load assemblies.
IgniteConfiguration cfg = _startup.Configuration;
@@ -264,6 +256,9 @@ namespace Apache.Ignite.Core
cfg.BinaryConfiguration = binaryCfg;
_startup.Marshaller = new Marshaller(cfg.BinaryConfiguration);
+
+ // 3. Send configuration details to Java
+ cfg.Write(_startup.Marshaller.StartMarshal(outStream));
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs
index 9b43564..efe1df4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs
@@ -104,9 +104,6 @@ namespace Apache.Ignite.Core.Impl.Binary
if (obj0 == null)
throw new ArgumentException("Unsupported object type: " + obj.GetType());
- if (obj0 is BinaryEnum)
- throw new InvalidOperationException("Builder cannot be created for enum.");
-
IBinaryTypeDescriptor desc = _marsh.GetDescriptor(true, obj0.TypeId);
return Builder0(null, obj0, desc);
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
index c3dcc3a..f3f8457 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
@@ -17,6 +17,7 @@
namespace Apache.Ignite.Core.Impl.Binary
{
+ using System;
using System.Collections.Generic;
using Apache.Ignite.Core.Binary;
@@ -48,5 +49,23 @@ namespace Apache.Ignite.Core.Impl.Binary
{
return (Dictionary<TKey, TValue>) reader.ReadDictionary(size => new Dictionary<TKey, TValue>(size));
}
+
+ /// <summary>
+ /// Reads long as timespan with range checks.
+ /// </summary>
+ /// <param name="reader">The reader.</param>
+ /// <returns>TimeSpan.</returns>
+ public static TimeSpan ReadLongAsTimespan(this IBinaryRawReader reader)
+ {
+ long ms = reader.ReadLong();
+
+ if (ms >= TimeSpan.MaxValue.TotalMilliseconds)
+ return TimeSpan.MaxValue;
+
+ if (ms <= TimeSpan.MinValue.TotalMilliseconds)
+ return TimeSpan.MinValue;
+
+ return TimeSpan.FromMilliseconds(ms);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/JavaTypes.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/JavaTypes.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/JavaTypes.cs
new file mode 100644
index 0000000..fccbfae
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/JavaTypes.cs
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Impl.Binary
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ /// <summary>
+ /// Provides mapping between Java and .NET basic types.
+ /// </summary>
+ internal static class JavaTypes
+ {
+ /** */
+ private static readonly Dictionary<Type, string> NetToJava = new Dictionary<Type, string>
+ {
+ {typeof (bool), "java.lang.Boolean"},
+ {typeof (byte), "java.lang.Byte"},
+ {typeof (sbyte), "java.lang.Byte"},
+ {typeof (short), "java.lang.Short"},
+ {typeof (ushort), "java.lang.Short"},
+ {typeof (char), "java.lang.Character"},
+ {typeof (int), "java.lang.Integer"},
+ {typeof (uint), "java.lang.Integer"},
+ {typeof (long), "java.lang.Long"},
+ {typeof (ulong), "java.lang.Long"},
+ {typeof (float), "java.lang.Float"},
+ {typeof (double), "java.lang.Double"},
+ {typeof (string), "java.lang.String"},
+ {typeof (decimal), "java.math.BigDecimal"},
+ {typeof (Guid), "java.util.UUID"}
+ };
+
+ /** */
+ private static readonly Dictionary<string, Type> JavaToNet =
+ NetToJava.GroupBy(x => x.Value).ToDictionary(g => g.Key, g => g.First().Key);
+
+ /** */
+ private static readonly string MappedTypes = string.Join(", ", NetToJava.Keys.Select(x => x.Name));
+
+ /// <summary>
+ /// Gets the corresponding Java type name.
+ /// </summary>
+ public static string GetJavaTypeName(Type type)
+ {
+ if (type == null)
+ return null;
+
+ string res;
+
+ return NetToJava.TryGetValue(type, out res) ? res : null;
+ }
+
+ /// <summary>
+ /// Gets .NET type that corresponds to specified Java type name.
+ /// </summary>
+ /// <param name="javaTypeName">Name of the java type.</param>
+ /// <returns></returns>
+ public static Type GetDotNetType(string javaTypeName)
+ {
+ if (string.IsNullOrEmpty(javaTypeName))
+ return null;
+
+ Type res;
+
+ return JavaToNet.TryGetValue(javaTypeName, out res) ? res : null;
+ }
+
+ /// <summary>
+ /// Gets the supported types as a comma-separated string.
+ /// </summary>
+ public static string SupportedTypesString
+ {
+ get { return MappedTypes; }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
index 4274744..73f3618 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
@@ -88,11 +88,11 @@ namespace Apache.Ignite.Core.Impl.Binary
foreach (BinaryTypeConfiguration typeCfg in typeCfgs)
AddUserType(cfg, typeCfg, typeResolver, dfltSerializer);
- ICollection<string> types = cfg.Types;
+ var typeNames = cfg.Types;
- if (types != null)
- foreach (string type in types)
- AddUserType(cfg, new BinaryTypeConfiguration(type), typeResolver, dfltSerializer);
+ if (typeNames != null)
+ foreach (string typeName in typeNames)
+ AddUserType(cfg, new BinaryTypeConfiguration(typeName), typeResolver, dfltSerializer);
if (cfg.DefaultSerializer == null)
cfg.DefaultSerializer = dfltSerializer;
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
index f55863e..d1296ec 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
@@ -25,6 +25,7 @@ namespace Apache.Ignite.Core.Impl.Cache
using System.Threading.Tasks;
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cache.Configuration;
using Apache.Ignite.Core.Cache.Expiry;
using Apache.Ignite.Core.Cache.Query;
using Apache.Ignite.Core.Cache.Query.Continuous;
@@ -68,7 +69,7 @@ namespace Apache.Ignite.Core.Impl.Cache
/** Async instance. */
private readonly Lazy<CacheImpl<TK, TV>> _asyncInstance;
-
+
/// <summary>
/// Constructor.
/// </summary>
@@ -152,6 +153,12 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
+ public CacheConfiguration GetConfiguration()
+ {
+ return DoInOp((int) CacheOp.GetConfig, stream => new CacheConfiguration(Marshaller.StartUnmarshal(stream)));
+ }
+
+ /** <inheritDoc /> */
public bool IsEmpty()
{
return GetSize() == 0;
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
index 1709dc5..61ccb5f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
@@ -59,6 +59,7 @@ namespace Apache.Ignite.Core.Impl.Cache
RemoveBool = 35,
RemoveObj = 36,
Replace2 = 37,
- Replace3 = 38
+ Replace3 = 38,
+ GetConfig = 39
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
index 5aa806b..7785280 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
@@ -101,15 +101,25 @@ namespace Apache.Ignite.Core.Impl.Cache.Store
{
using (var stream = IgniteManager.Memory.Get(memPtr).GetStream())
{
- var reader = BinaryUtils.Marshaller.StartUnmarshal(stream, BinaryMode.KeepBinary);
+ var reader = BinaryUtils.Marshaller.StartUnmarshal(stream);
- var className = reader.ReadString();
var convertBinary = reader.ReadBoolean();
- var propertyMap = reader.ReadDictionaryAsGeneric<string, object>();
+ var factory = reader.ReadObject<IFactory<ICacheStore>>();
- var store = IgniteUtils.CreateInstance<ICacheStore>(className);
+ ICacheStore store;
+
+ if (factory != null)
+ store = factory.CreateInstance();
+ else
+ {
+ var className = reader.ReadString();
+ var propertyMap = reader.ReadDictionaryAsGeneric<string, object>();
+
+ store = IgniteUtils.CreateInstance<ICacheStore>(className);
+
+ IgniteUtils.SetProperties(store, propertyMap);
+ }
- IgniteUtils.SetProperties(store, propertyMap);
return new CacheStore(store, convertBinary, registry);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
index ffc8be8..9d27117 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
@@ -25,6 +25,7 @@ namespace Apache.Ignite.Core.Impl
using System.Linq;
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cache.Configuration;
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Compute;
using Apache.Ignite.Core.Datastream;
@@ -339,12 +340,46 @@ namespace Apache.Ignite.Core.Impl
}
/** <inheritdoc /> */
+ public ICache<TK, TV> GetOrCreateCache<TK, TV>(CacheConfiguration configuration)
+ {
+ IgniteArgumentCheck.NotNull(configuration, "configuration");
+
+ using (var stream = IgniteManager.Memory.Allocate().GetStream())
+ {
+ var writer = Marshaller.StartMarshal(stream);
+
+ configuration.Write(writer);
+
+ stream.SynchronizeOutput();
+
+ return Cache<TK, TV>(UU.ProcessorGetOrCreateCache(_proc, stream.MemoryPointer));
+ }
+ }
+
+ /** <inheritdoc /> */
public ICache<TK, TV> CreateCache<TK, TV>(string name)
{
return Cache<TK, TV>(UU.ProcessorCreateCache(_proc, name));
}
/** <inheritdoc /> */
+ public ICache<TK, TV> CreateCache<TK, TV>(CacheConfiguration configuration)
+ {
+ IgniteArgumentCheck.NotNull(configuration, "configuration");
+
+ using (var stream = IgniteManager.Memory.Allocate().GetStream())
+ {
+ var writer = Marshaller.StartMarshal(stream);
+
+ configuration.Write(writer);
+
+ stream.SynchronizeOutput();
+
+ return Cache<TK, TV>(UU.ProcessorCreateCache(_proc, stream.MemoryPointer));
+ }
+ }
+
+ /** <inheritdoc /> */
public void DestroyCache(string name)
{
UU.ProcessorDestroyCache(_proc, name);
@@ -450,6 +485,19 @@ namespace Apache.Ignite.Core.Impl
return new AtomicLong(nativeLong, Marshaller, name);
}
+ /** <inheritdoc /> */
+ public IgniteConfiguration GetConfiguration()
+ {
+ using (var stream = IgniteManager.Memory.Allocate(1024).GetStream())
+ {
+ UU.ProcessorGetIgniteConfiguration(_proc, stream.MemoryPointer);
+
+ stream.SynchronizeInput();
+
+ return new IgniteConfiguration(_marsh.StartUnmarshal(stream));
+ }
+ }
+
/// <summary>
/// Gets internal projection.
/// </summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteConfigurationEx.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteConfigurationEx.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteConfigurationEx.cs
deleted file mode 100644
index 358e805..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteConfigurationEx.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.Impl
-{
- /// <summary>
- /// Internal extensions for IgniteConfiguration.
- /// </summary>
- internal class IgniteConfigurationEx : IgniteConfiguration
- {
- /// <summary>
- /// Default constructor.
- /// </summary>
- public IgniteConfigurationEx()
- {
- // No-op.
- }
-
- /// <summary>
- /// Copying constructor.
- /// </summary>
- /// <param name="cfg">Configuration.</param>
- public IgniteConfigurationEx(IgniteConfiguration cfg) : base(cfg)
- {
- // No-op.
- }
-
- /// <summary>
- /// Copying constructor.
- /// </summary>
- /// <param name="cfg">Configuration.</param>
- public IgniteConfigurationEx(IgniteConfigurationEx cfg)
- : this((IgniteConfiguration) cfg)
- {
- GridName = cfg.GridName;
- }
-
- /// <summary>
- /// Grid name which is used if not provided in configuration file.
- /// </summary>
- public string GridName { get; set; }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
index 6803772..a61edf4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
@@ -50,7 +50,7 @@ namespace Apache.Ignite.Core.Impl
private static JvmConfiguration _jvmCfg;
/** Memory manager. */
- private static PlatformMemoryManager _mem;
+ private static readonly PlatformMemoryManager Mem = new PlatformMemoryManager(1024);
/// <summary>
/// Create JVM.
@@ -86,7 +86,6 @@ namespace Apache.Ignite.Core.Impl
{
_ctx = ctx;
_jvmCfg = jvmCfg;
- _mem = new PlatformMemoryManager(1024);
}
}
}
@@ -96,7 +95,7 @@ namespace Apache.Ignite.Core.Impl
/// </summary>
internal static PlatformMemoryManager Memory
{
- get { return _mem; }
+ get { return Mem; }
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
index 16062e2..46bc3ca 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
@@ -22,6 +22,7 @@ namespace Apache.Ignite.Core.Impl
using System.Diagnostics.CodeAnalysis;
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cache.Configuration;
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Compute;
using Apache.Ignite.Core.Datastream;
@@ -232,19 +233,28 @@ namespace Apache.Ignite.Core.Impl
}
/** <inheritdoc /> */
+ public ICache<TK, TV> GetOrCreateCache<TK, TV>(CacheConfiguration configuration)
+ {
+ return _ignite.GetOrCreateCache<TK, TV>(configuration);
+ }
+
+ /** <inheritdoc /> */
public ICache<TK, TV> CreateCache<TK, TV>(string name)
{
return _ignite.CreateCache<TK, TV>(name);
}
/** <inheritdoc /> */
+ public ICache<TK, TV> CreateCache<TK, TV>(CacheConfiguration configuration)
+ {
+ return _ignite.CreateCache<TK, TV>(configuration);
+ }
public void DestroyCache(string name)
{
_ignite.DestroyCache(name);
}
/** <inheritdoc /> */
-
public IClusterNode GetLocalNode()
{
return _ignite.GetCluster().GetLocalNode();
@@ -324,6 +334,12 @@ namespace Apache.Ignite.Core.Impl
}
/** <inheritdoc /> */
+ public IgniteConfiguration GetConfiguration()
+ {
+ return _ignite.GetConfiguration();
+ }
+
+ /** <inheritdoc /> */
public void WriteBinary(IBinaryWriter writer)
{
// No-op.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
index fe4548c..3206fc8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
@@ -47,7 +47,7 @@ namespace Apache.Ignite.Core.Impl
private static readonly string[] JvmDllLookupPaths = {@"jre\bin\server", @"jre\bin\default"};
/** File: jvm.dll. */
- private const string FileJvmDll = "jvm.dll";
+ internal const string FileJvmDll = "jvm.dll";
/** File: Ignite.Common.dll. */
internal const string FileIgniteJniDll = "ignite.common.dll";
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs
index 851d24f..8e54261 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs
@@ -85,7 +85,7 @@ namespace Apache.Ignite.Core.Impl.Memory
/** <inheritdoc /> */
public void Release()
{
- throw new NotSupportedException();
+ // Memory can only be released by native platform.
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
index 229ff8c..51a49d0 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
@@ -70,7 +70,7 @@ namespace Apache.Ignite.Core.Impl.Transactions
concurrency = (TransactionConcurrency) reader.ReadInt();
isolation = (TransactionIsolation) reader.ReadInt();
- timeout = TimeSpan.FromMilliseconds(reader.ReadLong());
+ timeout = reader.ReadLongAsTimespan();
});
_dfltConcurrency = concurrency;
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
index 7a73bee..17df94a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
@@ -24,7 +24,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
/// Ignite JNI native methods.
/// </summary>
[SuppressUnmanagedCodeSecurity]
- internal unsafe static class IgniteJniNativeMethods
+ internal static unsafe class IgniteJniNativeMethods
{
[DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteReallocate")]
public static extern int Reallocate(long memPtr, int cap);
@@ -52,9 +52,15 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
[DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorCreateCache")]
public static extern void* ProcessorCreateCache(void* ctx, void* obj, sbyte* name);
+ [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorCreateCacheFromConfig")]
+ public static extern void* ProcessorCreateCacheFromConfig(void* ctx, void* obj, long memPtr);
+
[DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorGetOrCreateCache")]
public static extern void* ProcessorGetOrCreateCache(void* ctx, void* obj, sbyte* name);
+ [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorGetOrCreateCacheFromConfig")]
+ public static extern void* ProcessorGetOrCreateCacheFromConfig(void* ctx, void* obj, long memPtr);
+
[DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorDestroyCache")]
public static extern void ProcessorDestroyCache(void* ctx, void* obj, sbyte* name);
@@ -87,6 +93,9 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
public static extern void* ProcessorAtomicLong(void* ctx, void* obj, sbyte* name, long initVal,
[MarshalAs(UnmanagedType.U1)] bool create);
+ [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorGetIgniteConfiguration")]
+ public static extern void ProcessorGetIgniteConfiguration(void* ctx, void* obj, long memPtr);
+
[DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteTargetInStreamOutLong")]
public static extern long TargetInStreamOutLong(void* ctx, void* target, int opType, long memPtr);
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
index f460c9f..ad62f38 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
@@ -21,7 +21,6 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using Apache.Ignite.Core.Common;
-
using JNI = IgniteJniNativeMethods;
/// <summary>
@@ -102,7 +101,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
{
JNI.IgnitionStopAll(ctx, cancel);
}
-
+
internal static void ProcessorReleaseStart(IUnmanagedTarget target)
{
JNI.ProcessorReleaseStart(target.Context, target.Target);
@@ -147,6 +146,13 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
}
}
+ internal static IUnmanagedTarget ProcessorCreateCache(IUnmanagedTarget target, long memPtr)
+ {
+ void* res = JNI.ProcessorCreateCacheFromConfig(target.Context, target.Target, memPtr);
+
+ return target.ChangeTarget(res);
+ }
+
internal static IUnmanagedTarget ProcessorGetOrCreateCache(IUnmanagedTarget target, string name)
{
sbyte* name0 = IgniteUtils.StringToUtf8Unmanaged(name);
@@ -163,6 +169,13 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
}
}
+ internal static IUnmanagedTarget ProcessorGetOrCreateCache(IUnmanagedTarget target, long memPtr)
+ {
+ void* res = JNI.ProcessorGetOrCreateCacheFromConfig(target.Context, target.Target, memPtr);
+
+ return target.ChangeTarget(res);
+ }
+
internal static void ProcessorDestroyCache(IUnmanagedTarget target, string name)
{
sbyte* name0 = IgniteUtils.StringToUtf8Unmanaged(name);
@@ -268,6 +281,11 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
}
}
+ internal static void ProcessorGetIgniteConfiguration(IUnmanagedTarget target, long memPtr)
+ {
+ JNI.ProcessorGetIgniteConfiguration(target.Context, target.Target, memPtr);
+ }
+
#endregion
#region NATIVE METHODS: TARGET
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index c0f49c8..53eefdd 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -837,6 +837,7 @@
<exclude>**/*.slnrel</exclude>
<exclude>**/*.DotSettings</exclude>
<exclude>**/*.FxCop</exclude>
+ <exclude>**/*.ruleset</exclude>
<exclude>**/*.csproj</exclude>
<exclude>**/*.csprojrel</exclude>
<exclude>**/*.vcxproj</exclude>
[4/4] ignite git commit: IGNITE-1906: .NET: Implemented programmatic
configuration.
Posted by vo...@apache.org.
IGNITE-1906: .NET: Implemented programmatic configuration.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ee20f1d9
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ee20f1d9
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ee20f1d9
Branch: refs/heads/master
Commit: ee20f1d9fb94f792d0b62097499c7c3f976ff6f5
Parents: 28a5247
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Tue Feb 2 16:19:55 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Feb 2 16:19:55 2016 +0300
----------------------------------------------------------------------
.gitignore | 1 +
.../internal/binary/GridBinaryMarshaller.java | 23 +-
.../processors/cache/GridCacheProcessor.java | 43 +-
.../processors/platform/PlatformIgnition.java | 6 +-
.../platform/PlatformNoopProcessor.java | 15 +
.../processors/platform/PlatformProcessor.java | 25 +
.../platform/PlatformProcessorImpl.java | 34 +-
.../platform/cache/PlatformCache.java | 16 +-
.../dotnet/PlatformDotNetCacheStore.java | 39 +-
.../PlatformDotNetConfigurationClosure.java | 50 +-
.../utils/PlatformConfigurationUtils.java | 621 +++++++++++++++++++
.../platform/utils/PlatformUtils.java | 52 +-
.../PlatformDotNetCacheStoreFactoryNative.java | 58 ++
.../cpp/common/include/ignite/common/exports.h | 3 +
.../cpp/common/include/ignite/common/java.h | 9 +
.../platforms/cpp/common/project/vs/module.def | 5 +-
modules/platforms/cpp/common/src/exports.cpp | 12 +
modules/platforms/cpp/common/src/java.cpp | 44 ++
.../Apache.Ignite.Core.Tests.csproj | 3 +
.../Binary/BinarySelfTest.cs | 9 +
.../Cache/CacheAbstractTest.cs | 2 +-
.../Cache/CacheAffinityTest.cs | 2 +-
.../Cache/CacheConfigurationTest.cs | 538 ++++++++++++++++
.../Cache/CacheDynamicStartTest.cs | 4 +-
.../Cache/CacheTestAsyncWrapper.cs | 7 +
.../Query/CacheQueriesCodeConfigurationTest.cs | 295 +++++++++
.../Cache/Query/CacheQueriesTest.cs | 2 +-
.../Continuous/ContinuousQueryAbstractTest.cs | 2 +-
.../Cache/Store/CacheStoreSessionTest.cs | 2 +-
.../Cache/Store/CacheStoreTest.cs | 23 +-
.../Dataload/DataStreamerTest.cs | 4 +-
.../Apache.Ignite.Core.Tests/ExceptionsTest.cs | 2 +-
.../IgniteConfigurationTest.cs | 367 +++++++++++
.../Apache.Ignite.Core.Tests/MarshallerTest.cs | 4 +-
.../SerializationTest.cs | 2 +-
.../Apache.Ignite.Core.Tests/TestRunner.cs | 5 +-
.../Apache.Ignite.Core.csproj | 29 +-
.../Binary/BinaryConfiguration.cs | 27 +-
.../Configuration/CacheAtomicWriteOrderMode.cs | 43 ++
.../Cache/Configuration/CacheAtomicityMode.cs | 54 ++
.../Cache/Configuration/CacheConfiguration.cs | 601 ++++++++++++++++++
.../Cache/Configuration/CacheMemoryMode.cs | 60 ++
.../Cache/Configuration/CacheMode.cs | 52 ++
.../Cache/Configuration/CacheRebalanceMode.cs | 51 ++
.../CacheWriteSynchronizationMode.cs | 45 ++
.../Cache/Configuration/QueryAlias.cs | 59 ++
.../Cache/Configuration/QueryEntity.cs | 401 ++++++++++++
.../Cache/Configuration/QueryField.cs | 109 ++++
.../Cache/Configuration/QueryIndex.cs | 137 ++++
.../Cache/Configuration/QueryIndexField.cs | 66 ++
.../Cache/Configuration/QueryIndexType.cs | 40 ++
.../Configuration/QuerySqlFieldAttribute.cs | 60 ++
.../Configuration/QueryTextFieldAttribute.cs | 36 ++
.../dotnet/Apache.Ignite.Core/Cache/ICache.cs | 6 +
.../Apache.Ignite.Core/Common/IFactory.cs | 34 +
.../Discovery/IDiscoverySpi.cs | 32 +
.../Discovery/Tcp/ITcpDiscoveryIpFinder.cs | 34 +
.../Multicast/TcpDiscoveryMulticastIpFinder.cs | 133 ++++
.../Tcp/Static/TcpDiscoveryStaticIpFinder.cs | 84 +++
.../Discovery/Tcp/TcpDiscoveryIpFinderBase.cs | 78 +++
.../Discovery/Tcp/TcpDiscoverySpi.cs | 144 +++++
.../dotnet/Apache.Ignite.Core/IIgnite.cs | 29 +-
.../Apache.Ignite.Core/IgniteConfiguration.cs | 347 ++++++++++-
.../dotnet/Apache.Ignite.Core/Ignition.cs | 29 +-
.../Apache.Ignite.Core/Impl/Binary/Binary.cs | 3 -
.../Impl/Binary/BinaryReaderExtensions.cs | 19 +
.../Apache.Ignite.Core/Impl/Binary/JavaTypes.cs | 92 +++
.../Impl/Binary/Marshaller.cs | 8 +-
.../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 9 +-
.../Apache.Ignite.Core/Impl/Cache/CacheOp.cs | 3 +-
.../Impl/Cache/Store/CacheStore.cs | 20 +-
.../dotnet/Apache.Ignite.Core/Impl/Ignite.cs | 48 ++
.../Impl/IgniteConfigurationEx.cs | 57 --
.../Apache.Ignite.Core/Impl/IgniteManager.cs | 5 +-
.../Apache.Ignite.Core/Impl/IgniteProxy.cs | 18 +-
.../Apache.Ignite.Core/Impl/IgniteUtils.cs | 2 +-
.../Impl/Memory/PlatformRawMemory.cs | 2 +-
.../Impl/Transactions/TransactionsImpl.cs | 2 +-
.../Impl/Unmanaged/IgniteJniNativeMethods.cs | 11 +-
.../Impl/Unmanaged/UnmanagedUtils.cs | 22 +-
parent/pom.xml | 1 +
81 files changed, 5213 insertions(+), 258 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index ef12f3a..e4e061c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,6 +24,7 @@ git-patch-prop-local.sh
*.vcxproj.user
*.sdf
*.opensdf
+*.opendb
**/cpp/**/vs/x64/
**/cpp/**/vs/Win32/
**/dotnet/**/obj/
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
index da43558..8e138fc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
@@ -299,6 +299,15 @@ public class GridBinaryMarshaller {
/**
* Push binary context and return the old one.
*
+ * @return Old binary context.
+ */
+ public BinaryContext pushContext() {
+ return pushContext(ctx);
+ }
+
+ /**
+ * Push binary context and return the old one.
+ *
* @param ctx Binary context.
* @return Old binary context.
*/
@@ -315,11 +324,23 @@ public class GridBinaryMarshaller {
*
* @param oldCtx Old binary context.
*/
- private static void popContext(@Nullable BinaryContext oldCtx) {
+ public static void popContext(@Nullable BinaryContext oldCtx) {
BINARY_CTX.set(oldCtx);
}
/**
+ * Creates a reader.
+ *
+ * @param stream Stream.
+ * @return Reader.
+ */
+ public BinaryReaderExImpl reader(BinaryInputStream stream) {
+ assert stream != null;
+
+ return new BinaryReaderExImpl(ctx, stream, null);
+ }
+
+ /**
* Whether object must be deserialized anyway. I.e. it cannot be converted to BinaryObject.
*
* @param obj Object.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 26d3d4f..5acad6c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -69,10 +69,13 @@ import org.apache.ignite.internal.IgniteComponentType;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteNodeAttributes;
import org.apache.ignite.internal.IgniteTransactionsEx;
+import org.apache.ignite.internal.binary.BinaryContext;
import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.binary.GridBinaryMarshaller;
import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage;
import org.apache.ignite.internal.processors.GridProcessorAdapter;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
import org.apache.ignite.internal.processors.cache.datastructures.CacheDataStructuresManager;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCache;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter;
@@ -94,6 +97,7 @@ import org.apache.ignite.internal.processors.cache.store.CacheStoreManager;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTransactionsImpl;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersionManager;
+import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
import org.apache.ignite.internal.processors.plugin.CachePluginManager;
import org.apache.ignite.internal.processors.query.GridQueryProcessor;
import org.apache.ignite.internal.util.F0;
@@ -3409,23 +3413,38 @@ public class GridCacheProcessor extends GridProcessorAdapter {
if (val == null)
return null;
- if (val.getCacheStoreFactory() != null) {
+ IgniteCacheObjectProcessor objProc = ctx.cacheObjects();
+ BinaryContext oldCtx = null;
+
+ if (objProc instanceof CacheObjectBinaryProcessorImpl) {
+ GridBinaryMarshaller binMarsh = ((CacheObjectBinaryProcessorImpl)objProc).marshaller();
+
+ oldCtx = binMarsh == null ? null : binMarsh.pushContext();
+ }
+
+ try {
+ if (val.getCacheStoreFactory() != null) {
+ try {
+ marshaller.unmarshal(marshaller.marshal(val.getCacheStoreFactory()),
+ val.getCacheStoreFactory().getClass().getClassLoader());
+ }
+ catch (IgniteCheckedException e) {
+ throw new IgniteCheckedException("Failed to validate cache configuration. " +
+ "Cache store factory is not serializable. Cache name: " + U.maskName(val.getName()), e);
+ }
+ }
+
try {
- marshaller.unmarshal(marshaller.marshal(val.getCacheStoreFactory()),
- val.getCacheStoreFactory().getClass().getClassLoader());
+ return marshaller.unmarshal(marshaller.marshal(val), U.resolveClassLoader(ctx.config().getClassLoader()));
}
catch (IgniteCheckedException e) {
- throw new IgniteCheckedException("Failed to validate cache configuration. " +
- "Cache store factory is not serializable. Cache name: " + U.maskName(val.getName()), e);
+ throw new IgniteCheckedException("Failed to validate cache configuration " +
+ "(make sure all objects in cache configuration are serializable): " + U.maskName(val.getName()), e);
}
}
-
- try {
- return marshaller.unmarshal(marshaller.marshal(val), U.resolveClassLoader(ctx.config().getClassLoader()));
- }
- catch (IgniteCheckedException e) {
- throw new IgniteCheckedException("Failed to validate cache configuration " +
- "(make sure all objects in cache configuration are serializable): " + U.maskName(val.getName()), e);
+ finally {
+ if (objProc instanceof CacheObjectBinaryProcessorImpl)
+ GridBinaryMarshaller.popContext(oldCtx);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformIgnition.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformIgnition.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformIgnition.java
index e642b2d..d25acfc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformIgnition.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformIgnition.java
@@ -142,9 +142,11 @@ public class PlatformIgnition {
* @return Configuration.
*/
private static IgniteConfiguration configuration(@Nullable String springCfgPath) {
+ if (springCfgPath == null)
+ return new IgniteConfiguration();
+
try {
- URL url = springCfgPath == null ? U.resolveIgniteUrl(IgnitionEx.DFLT_CFG) :
- U.resolveSpringUrl(springCfgPath);
+ URL url = U.resolveSpringUrl(springCfgPath);
IgniteBiTuple<IgniteConfiguration, GridSpringResourceContext> t = IgnitionEx.loadConfiguration(url);
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java
index fb28008..b25e32e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java
@@ -74,6 +74,16 @@ public class PlatformNoopProcessor extends GridProcessorAdapter implements Platf
}
/** {@inheritDoc} */
+ @Override public PlatformTarget createCacheFromConfig(long memPtr) throws IgniteCheckedException {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public PlatformTarget getOrCreateCacheFromConfig(long memPtr) throws IgniteCheckedException {
+ return null;
+ }
+
+ /** {@inheritDoc} */
@Override public void destroyCache(@Nullable String name) throws IgniteCheckedException {
// No-op.
}
@@ -133,4 +143,9 @@ public class PlatformNoopProcessor extends GridProcessorAdapter implements Platf
@Override public PlatformTarget atomicLong(String name, long initVal, boolean create) throws IgniteException {
return null;
}
+
+ /** {@inheritDoc} */
+ @Override public void getIgniteConfiguration(long memPtr) {
+ // No-op.
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java
index 8e684e3..b59d93d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java
@@ -90,6 +90,24 @@ public interface PlatformProcessor extends GridProcessor {
public PlatformTarget getOrCreateCache(@Nullable String name) throws IgniteCheckedException;
/**
+ * Create cache.
+ *
+ * @param memPtr Stream with cache config.
+ * @return Cache.
+ * @throws IgniteCheckedException If failed.
+ */
+ public PlatformTarget createCacheFromConfig(long memPtr) throws IgniteCheckedException;
+
+ /**
+ * Get or create cache.
+ *
+ * @param memPtr Stream with cache config.
+ * @return Cache.
+ * @throws IgniteCheckedException If failed.
+ */
+ public PlatformTarget getOrCreateCacheFromConfig(long memPtr) throws IgniteCheckedException;
+
+ /**
* Destroy dynamically created cache.
*
* @param name Cache name.
@@ -188,4 +206,11 @@ public interface PlatformProcessor extends GridProcessor {
* @throws IgniteException
*/
public PlatformTarget atomicLong(String name, long initVal, boolean create) throws IgniteException;
+
+ /**
+ * Gets the configuration of the current Ignite instance.
+ *
+ * @param memPtr Stream to write data to.
+ */
+ public void getIgniteConfiguration(long memPtr);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
index dc6e0df..4ed8c25 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
@@ -22,11 +22,12 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.PlatformConfiguration;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteComputeImpl;
+import org.apache.ignite.internal.binary.*;
import org.apache.ignite.internal.cluster.ClusterGroupAdapter;
-import org.apache.ignite.internal.binary.BinaryRawWriterEx;
import org.apache.ignite.internal.processors.GridProcessorAdapter;
import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
import org.apache.ignite.internal.processors.datastreamer.DataStreamerImpl;
@@ -45,6 +46,7 @@ import org.apache.ignite.internal.processors.platform.memory.PlatformOutputStrea
import org.apache.ignite.internal.processors.platform.messaging.PlatformMessaging;
import org.apache.ignite.internal.processors.platform.services.PlatformServices;
import org.apache.ignite.internal.processors.platform.transactions.PlatformTransactions;
+import org.apache.ignite.internal.processors.platform.utils.PlatformConfigurationUtils;
import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -244,6 +246,26 @@ public class PlatformProcessorImpl extends GridProcessorAdapter implements Platf
}
/** {@inheritDoc} */
+ @Override public PlatformTarget createCacheFromConfig(long memPtr) throws IgniteCheckedException {
+ BinaryRawReaderEx reader = platformCtx.reader(platformCtx.memory().get(memPtr));
+ CacheConfiguration cfg = PlatformConfigurationUtils.readCacheConfiguration(reader);
+
+ IgniteCacheProxy cache = (IgniteCacheProxy)ctx.grid().createCache(cfg);
+
+ return new PlatformCache(platformCtx, cache.keepBinary(), false);
+ }
+
+ /** {@inheritDoc} */
+ @Override public PlatformTarget getOrCreateCacheFromConfig(long memPtr) throws IgniteCheckedException {
+ BinaryRawReaderEx reader = platformCtx.reader(platformCtx.memory().get(memPtr));
+ CacheConfiguration cfg = PlatformConfigurationUtils.readCacheConfiguration(reader);
+
+ IgniteCacheProxy cache = (IgniteCacheProxy)ctx.grid().getOrCreateCache(cfg);
+
+ return new PlatformCache(platformCtx, cache.keepBinary(), false);
+ }
+
+ /** {@inheritDoc} */
@Override public void destroyCache(@Nullable String name) throws IgniteCheckedException {
ctx.grid().destroyCache(name);
}
@@ -338,6 +360,16 @@ public class PlatformProcessorImpl extends GridProcessorAdapter implements Platf
return new PlatformAtomicLong(platformCtx, atomicLong);
}
+ /** {@inheritDoc} */
+ @Override public void getIgniteConfiguration(long memPtr) {
+ PlatformOutputStream stream = platformCtx.memory().get(memPtr).output();
+ BinaryRawWriterEx writer = platformCtx.writer(stream);
+
+ PlatformConfigurationUtils.writeIgniteConfiguration(writer, ignite().configuration());
+
+ stream.synchronize();
+ }
+
/**
* Internal store initialization routine.
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
index 8e7c51d..37fd335 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
@@ -28,6 +28,7 @@ import org.apache.ignite.cache.query.ScanQuery;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cache.query.SqlQuery;
import org.apache.ignite.cache.query.TextQuery;
+import org.apache.ignite.configuration.*;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.binary.BinaryRawReaderEx;
import org.apache.ignite.internal.binary.BinaryRawWriterEx;
@@ -41,6 +42,7 @@ import org.apache.ignite.internal.processors.platform.PlatformNativeException;
import org.apache.ignite.internal.processors.platform.cache.query.PlatformContinuousQuery;
import org.apache.ignite.internal.processors.platform.cache.query.PlatformFieldsQueryCursor;
import org.apache.ignite.internal.processors.platform.cache.query.PlatformQueryCursor;
+import org.apache.ignite.internal.processors.platform.utils.PlatformConfigurationUtils;
import org.apache.ignite.internal.processors.platform.utils.PlatformFutureUtils;
import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
import org.apache.ignite.internal.util.GridConcurrentFactory;
@@ -178,6 +180,9 @@ public class PlatformCache extends PlatformAbstractTarget {
/** */
public static final int OP_REPLACE_3 = 38;
+ /** */
+ public static final int OP_GET_CONFIG = 39;
+
/** Underlying JCache. */
private final IgniteCacheProxy cache;
@@ -516,6 +521,14 @@ public class PlatformCache extends PlatformAbstractTarget {
break;
+ case OP_GET_CONFIG:
+ CacheConfiguration ccfg = ((IgniteCache<Object, Object>)cache).
+ getConfiguration(CacheConfiguration.class);
+
+ PlatformConfigurationUtils.writeCacheConfiguration(writer, ccfg);
+
+ break;
+
default:
super.processOutStream(type, writer);
}
@@ -705,8 +718,7 @@ public class PlatformCache extends PlatformAbstractTarget {
}
/**
- * Clears the contents of the cache, without notifying listeners or
- * {@ignitelink javax.cache.integration.CacheWriter}s.
+ * Clears the contents of the cache, without notifying listeners or CacheWriters.
*
* @throws IllegalStateException if the cache is closed.
* @throws javax.cache.CacheException if there is a problem during the clear
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java
index 47b1110..45d9208 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java
@@ -29,11 +29,8 @@ import org.apache.ignite.internal.processors.platform.cache.store.PlatformCacheS
import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
import org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream;
import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
-import org.apache.ignite.internal.util.lang.GridMapEntry;
import org.apache.ignite.internal.util.lang.GridTuple;
import org.apache.ignite.internal.util.lang.IgniteInClosureX;
-import org.apache.ignite.internal.util.typedef.C1;
-import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiInClosure;
@@ -43,13 +40,9 @@ import org.jetbrains.annotations.Nullable;
import javax.cache.Cache;
import javax.cache.integration.CacheLoaderException;
import javax.cache.integration.CacheWriterException;
-import java.util.AbstractMap;
-import java.util.AbstractSet;
import java.util.Collection;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
-import java.util.Set;
/**
* Wrapper for .NET cache store implementations.
@@ -102,6 +95,9 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
/** Properties. */
private Map<String, ?> props;
+ /** Native factory. */
+ private final Object nativeFactory;
+
/** Interop processor. */
protected PlatformContext platformCtx;
@@ -109,6 +105,22 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
protected long ptr;
/**
+ * Default ctor.
+ */
+ public PlatformDotNetCacheStore() {
+ nativeFactory = null;
+ }
+
+ /**
+ * Native factory ctor.
+ */
+ public PlatformDotNetCacheStore(Object nativeFactory) {
+ assert nativeFactory != null;
+
+ this.nativeFactory = nativeFactory;
+ }
+
+ /**
* Gets .NET class name.
*
* @return .NET class name.
@@ -175,7 +187,7 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
writer.writeByte(OP_LOAD_ALL);
writer.writeLong(session());
writer.writeString(ses.cacheName());
- writer.writeCollection((Collection) keys);
+ writer.writeCollection((Collection)keys);
}
}, new LoadAllCallback<>(platformCtx, loaded));
@@ -305,7 +317,8 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
* @throws org.apache.ignite.IgniteCheckedException
*/
public void initialize(GridKernalContext ctx, boolean convertBinary) throws IgniteCheckedException {
- A.notNull(typName, "typName");
+ A.ensure(typName != null || nativeFactory != null,
+ "Either typName or nativeFactory must be set in PlatformDotNetCacheStore");
platformCtx = PlatformUtils.platformContext(ctx.grid());
@@ -329,9 +342,13 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
* @param convertBinary Convert binary flag.
*/
protected void write(BinaryRawWriterEx writer, boolean convertBinary) {
- writer.writeString(typName);
writer.writeBoolean(convertBinary);
- writer.writeMap(props);
+ writer.writeObjectDetached(nativeFactory);
+
+ if (nativeFactory == null) {
+ writer.writeString(typName);
+ writer.writeMap(props);
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
index 6b9b441..8728d77 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
@@ -19,31 +19,28 @@ package org.apache.ignite.internal.processors.platform.dotnet;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
-import org.apache.ignite.binary.BinaryIdMapper;
import org.apache.ignite.binary.BinaryBasicIdMapper;
-import org.apache.ignite.binary.BinaryNameMapper;
import org.apache.ignite.binary.BinaryBasicNameMapper;
+import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryNameMapper;
import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.PlatformConfiguration;
-import org.apache.ignite.internal.MarshallerContextImpl;
-import org.apache.ignite.internal.binary.BinaryNoopMetadataHandler;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
import org.apache.ignite.internal.binary.BinaryRawWriterEx;
+import org.apache.ignite.internal.binary.BinaryReaderExImpl;
import org.apache.ignite.internal.binary.GridBinaryMarshaller;
-import org.apache.ignite.internal.binary.BinaryContext;
import org.apache.ignite.internal.processors.platform.PlatformAbstractConfigurationClosure;
import org.apache.ignite.internal.processors.platform.lifecycle.PlatformLifecycleBean;
-import org.apache.ignite.internal.processors.platform.memory.PlatformInputStream;
import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
import org.apache.ignite.internal.processors.platform.memory.PlatformMemoryManagerImpl;
import org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream;
+import org.apache.ignite.internal.processors.platform.utils.PlatformConfigurationUtils;
import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lifecycle.LifecycleBean;
-import org.apache.ignite.logger.NullLogger;
import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration;
-import org.apache.ignite.internal.binary.BinaryMarshaller;
import org.apache.ignite.platform.dotnet.PlatformDotNetLifecycleBean;
import java.util.ArrayList;
@@ -177,15 +174,16 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
*/
@SuppressWarnings("ConstantConditions")
private void prepare(IgniteConfiguration igniteCfg, PlatformDotNetConfigurationEx interopCfg) {
- this.cfg = igniteCfg;
+ cfg = igniteCfg;
try (PlatformMemory outMem = memMgr.allocate()) {
try (PlatformMemory inMem = memMgr.allocate()) {
PlatformOutputStream out = outMem.output();
- BinaryRawWriterEx writer = marshaller().writer(out);
+ GridBinaryMarshaller marshaller = PlatformUtils.marshaller();
+ BinaryRawWriterEx writer = marshaller.writer(out);
- PlatformUtils.writeDotNetConfiguration(writer, interopCfg.unwrap());
+ PlatformConfigurationUtils.writeDotNetConfiguration(writer, interopCfg.unwrap());
List<PlatformDotNetLifecycleBean> beans = beans(igniteCfg);
@@ -201,7 +199,7 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
gate.extensionCallbackInLongLongOutLong(
PlatformUtils.OP_PREPARE_DOT_NET, outMem.pointer(), inMem.pointer());
- processPrepareResult(inMem.input());
+ processPrepareResult(marshaller.reader(inMem.input()));
}
}
}
@@ -211,9 +209,11 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
*
* @param in Input stream.
*/
- private void processPrepareResult(PlatformInputStream in) {
+ private void processPrepareResult(BinaryReaderExImpl in) {
assert cfg != null;
+ PlatformConfigurationUtils.readIgniteConfiguration(in, cfg);
+
List<PlatformDotNetLifecycleBean> beans = beans(cfg);
List<PlatformLifecycleBean> newBeans = new ArrayList<>();
@@ -265,28 +265,4 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
return res;
}
-
- /**
- * Create binary marshaller.
- *
- * @return Marshaller.
- */
- @SuppressWarnings("deprecation")
- private static GridBinaryMarshaller marshaller() {
- try {
- BinaryContext ctx =
- new BinaryContext(BinaryNoopMetadataHandler.instance(), new IgniteConfiguration(), new NullLogger());
-
- BinaryMarshaller marsh = new BinaryMarshaller();
-
- marsh.setContext(new MarshallerContextImpl(null));
-
- ctx.configure(marsh, new IgniteConfiguration());
-
- return new GridBinaryMarshaller(ctx);
- }
- catch (IgniteCheckedException e) {
- throw U.convertException(e);
- }
- }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
new file mode 100644
index 0000000..32ab812
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
@@ -0,0 +1,621 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.utils;
+
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.cache.CacheAtomicWriteOrderMode;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMemoryMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CacheRebalanceMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.cache.QueryEntity;
+import org.apache.ignite.cache.QueryIndex;
+import org.apache.ignite.cache.QueryIndexType;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.binary.*;
+import org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration;
+import org.apache.ignite.platform.dotnet.PlatformDotNetBinaryTypeConfiguration;
+import org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactoryNative;
+import org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration;
+import org.apache.ignite.spi.discovery.DiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+
+import java.lang.management.ManagementFactory;
+import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Configuration utils.
+ */
+@SuppressWarnings("unchecked") public class PlatformConfigurationUtils {
+ /**
+ * Write .Net configuration to the stream.
+ *
+ * @param writer Writer.
+ * @param cfg Configuration.
+ */
+ public static void writeDotNetConfiguration(BinaryRawWriterEx writer, PlatformDotNetConfiguration cfg) {
+ // 1. Write assemblies.
+ PlatformUtils.writeNullableCollection(writer, cfg.getAssemblies());
+
+ PlatformDotNetBinaryConfiguration binaryCfg = cfg.getBinaryConfiguration();
+
+ if (binaryCfg != null) {
+ writer.writeBoolean(true);
+
+ PlatformUtils.writeNullableCollection(writer, binaryCfg.getTypesConfiguration(),
+ new PlatformWriterClosure<PlatformDotNetBinaryTypeConfiguration>() {
+ @Override public void write(BinaryRawWriterEx writer, PlatformDotNetBinaryTypeConfiguration typ) {
+ writer.writeString(typ.getTypeName());
+ writer.writeString(typ.getNameMapper());
+ writer.writeString(typ.getIdMapper());
+ writer.writeString(typ.getSerializer());
+ writer.writeString(typ.getAffinityKeyFieldName());
+ writer.writeObject(typ.getKeepDeserialized());
+ writer.writeBoolean(typ.isEnum());
+ }
+ });
+
+ PlatformUtils.writeNullableCollection(writer, binaryCfg.getTypes());
+ writer.writeString(binaryCfg.getDefaultNameMapper());
+ writer.writeString(binaryCfg.getDefaultIdMapper());
+ writer.writeString(binaryCfg.getDefaultSerializer());
+ writer.writeBoolean(binaryCfg.isDefaultKeepDeserialized());
+ }
+ else
+ writer.writeBoolean(false);
+ }
+
+ /**
+ * Reads cache configuration from a stream.
+ *
+ * @param in Stream.
+ * @return Cache configuration.
+ */
+ public static CacheConfiguration readCacheConfiguration(BinaryRawReaderEx in) {
+ assert in != null;
+
+ CacheConfiguration ccfg = new CacheConfiguration();
+
+ ccfg.setAtomicityMode(CacheAtomicityMode.fromOrdinal(in.readInt()));
+ ccfg.setAtomicWriteOrderMode(CacheAtomicWriteOrderMode.fromOrdinal((byte)in.readInt()));
+ ccfg.setBackups(in.readInt());
+ ccfg.setCacheMode(CacheMode.fromOrdinal(in.readInt()));
+ ccfg.setCopyOnRead(in.readBoolean());
+ ccfg.setEagerTtl(in.readBoolean());
+ ccfg.setSwapEnabled(in.readBoolean());
+ ccfg.setEvictSynchronized(in.readBoolean());
+ ccfg.setEvictSynchronizedConcurrencyLevel(in.readInt());
+ ccfg.setEvictSynchronizedKeyBufferSize(in.readInt());
+ ccfg.setEvictSynchronizedTimeout(in.readLong());
+ ccfg.setInvalidate(in.readBoolean());
+ ccfg.setStoreKeepBinary(in.readBoolean());
+ ccfg.setLoadPreviousValue(in.readBoolean());
+ ccfg.setDefaultLockTimeout(in.readLong());
+ ccfg.setLongQueryWarningTimeout(in.readLong());
+ ccfg.setMaxConcurrentAsyncOperations(in.readInt());
+ ccfg.setEvictMaxOverflowRatio(in.readFloat());
+ ccfg.setMemoryMode(CacheMemoryMode.values()[in.readInt()]);
+ ccfg.setName(in.readString());
+ ccfg.setOffHeapMaxMemory(in.readLong());
+ ccfg.setReadFromBackup(in.readBoolean());
+ ccfg.setRebalanceBatchSize(in.readInt());
+ ccfg.setRebalanceDelay(in.readLong());
+ ccfg.setRebalanceMode(CacheRebalanceMode.fromOrdinal(in.readInt()));
+ ccfg.setRebalanceThrottle(in.readLong());
+ ccfg.setRebalanceTimeout(in.readLong());
+ ccfg.setSqlEscapeAll(in.readBoolean());
+ ccfg.setSqlOnheapRowCacheSize(in.readInt());
+ ccfg.setStartSize(in.readInt());
+ ccfg.setWriteBehindBatchSize(in.readInt());
+ ccfg.setWriteBehindEnabled(in.readBoolean());
+ ccfg.setWriteBehindFlushFrequency(in.readLong());
+ ccfg.setWriteBehindFlushSize(in.readInt());
+ ccfg.setWriteBehindFlushThreadCount(in.readInt());
+ ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.fromOrdinal(in.readInt()));
+
+ Object storeFactory = in.readObjectDetached();
+
+ if (storeFactory != null)
+ ccfg.setCacheStoreFactory(new PlatformDotNetCacheStoreFactoryNative(storeFactory));
+
+ int qryEntCnt = in.readInt();
+
+ if (qryEntCnt > 0) {
+ Collection<QueryEntity> entities = new ArrayList<>(qryEntCnt);
+
+ for (int i = 0; i < qryEntCnt; i++)
+ entities.add(readQueryEntity(in));
+
+ ccfg.setQueryEntities(entities);
+ }
+
+ return ccfg;
+ }
+
+ /**
+ * Reads the query entity.
+ *
+ * @param in Stream.
+ * @return QueryEntity.
+ */
+ public static QueryEntity readQueryEntity(BinaryRawReader in) {
+ QueryEntity res = new QueryEntity();
+
+ res.setKeyType(in.readString());
+ res.setValueType(in.readString());
+
+ // Fields
+ int cnt = in.readInt();
+
+ if (cnt > 0) {
+ LinkedHashMap<String, String> fields = new LinkedHashMap<>(cnt);
+
+ for (int i = 0; i < cnt; i++)
+ fields.put(in.readString(), in.readString());
+
+ res.setFields(fields);
+ }
+
+ // Aliases
+ cnt = in.readInt();
+
+ if (cnt > 0) {
+ Map<String, String> aliases = new HashMap<>(cnt);
+
+ for (int i = 0; i < cnt; i++)
+ aliases.put(in.readString(), in.readString());
+
+ res.setAliases(aliases);
+ }
+
+ // Indexes
+ cnt = in.readInt();
+
+ if (cnt > 0) {
+ Collection<QueryIndex> indexes = new ArrayList<>(cnt);
+
+ for (int i = 0; i < cnt; i++)
+ indexes.add(readQueryIndex(in));
+
+ res.setIndexes(indexes);
+ }
+
+ return res;
+ }
+
+ /**
+ * Reads the query index.
+ *
+ * @param in Reader.
+ * @return Query index.
+ */
+ public static QueryIndex readQueryIndex(BinaryRawReader in) {
+ QueryIndex res = new QueryIndex();
+
+ res.setName(in.readString());
+ res.setIndexType(QueryIndexType.values()[in.readByte()]);
+
+ int cnt = in.readInt();
+
+ if (cnt > 0) {
+ LinkedHashMap<String, Boolean> fields = new LinkedHashMap<>(cnt);
+
+ for (int i = 0; i < cnt; i++)
+ fields.put(in.readString(), !in.readBoolean());
+
+ res.setFields(fields);
+ }
+
+ return res;
+ }
+
+ /**
+ * Reads Ignite configuration.
+ * @param in Reader.
+ * @param cfg Configuration.
+ */
+ public static void readIgniteConfiguration(BinaryRawReaderEx in, IgniteConfiguration cfg) {
+ if (!in.readBoolean())
+ return; // there is no config
+
+ cfg.setClientMode(in.readBoolean());
+ cfg.setIncludeEventTypes(in.readIntArray());
+ cfg.setMetricsExpireTime(in.readLong());
+ cfg.setMetricsHistorySize(in.readInt());
+ cfg.setMetricsLogFrequency(in.readLong());
+ cfg.setMetricsUpdateFrequency(in.readLong());
+ cfg.setNetworkSendRetryCount(in.readInt());
+ cfg.setNetworkSendRetryDelay(in.readLong());
+ cfg.setNetworkTimeout(in.readLong());
+ cfg.setWorkDirectory(in.readString());
+ cfg.setLocalHost(in.readString());
+
+ readCacheConfigurations(in, cfg);
+ readDiscoveryConfiguration(in, cfg);
+ }
+
+ /**
+ * Reads cache configurations from a stream and updates provided IgniteConfiguration.
+ *
+ * @param cfg IgniteConfiguration to update.
+ * @param in Reader.
+ */
+ public static void readCacheConfigurations(BinaryRawReaderEx in, IgniteConfiguration cfg) {
+ int len = in.readInt();
+
+ if (len == 0)
+ return;
+
+ List<CacheConfiguration> caches = new ArrayList<>();
+
+ for (int i = 0; i < len; i++)
+ caches.add(readCacheConfiguration(in));
+
+ CacheConfiguration[] oldCaches = cfg.getCacheConfiguration();
+ CacheConfiguration[] caches0 = caches.toArray(new CacheConfiguration[caches.size()]);
+
+ if (oldCaches == null)
+ cfg.setCacheConfiguration(caches0);
+ else {
+ CacheConfiguration[] mergedCaches = new CacheConfiguration[oldCaches.length + caches.size()];
+
+ System.arraycopy(oldCaches, 0, mergedCaches, 0, oldCaches.length);
+ System.arraycopy(caches0, 0, mergedCaches, oldCaches.length, caches.size());
+
+ cfg.setCacheConfiguration(mergedCaches);
+ }
+ }
+
+ /**
+ * Reads discovery configuration from a stream and updates provided IgniteConfiguration.
+ *
+ * @param cfg IgniteConfiguration to update.
+ * @param in Reader.
+ */
+ public static void readDiscoveryConfiguration(BinaryRawReader in, IgniteConfiguration cfg) {
+ boolean hasConfig = in.readBoolean();
+
+ if (!hasConfig)
+ return;
+
+ TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+ boolean hasIpFinder = in.readBoolean();
+
+ if (hasIpFinder) {
+ byte ipFinderType = in.readByte();
+
+ int addrCount = in.readInt();
+
+ ArrayList<String> addrs = null;
+
+ if (addrCount > 0) {
+ addrs = new ArrayList<>(addrCount);
+
+ for (int i = 0; i < addrCount; i++)
+ addrs.add(in.readString());
+ }
+
+ TcpDiscoveryVmIpFinder finder = null;
+ if (ipFinderType == 1) {
+ finder = new TcpDiscoveryVmIpFinder();
+ }
+ else if (ipFinderType == 2) {
+ TcpDiscoveryMulticastIpFinder finder0 = new TcpDiscoveryMulticastIpFinder();
+
+ finder0.setLocalAddress(in.readString());
+ finder0.setMulticastGroup(in.readString());
+ finder0.setMulticastPort(in.readInt());
+ finder0.setAddressRequestAttempts(in.readInt());
+ finder0.setResponseWaitTime(in.readInt());
+
+ boolean hasTtl = in.readBoolean();
+
+ if (hasTtl)
+ finder0.setTimeToLive(in.readInt());
+
+ finder = finder0;
+ }
+ else {
+ assert false;
+ }
+
+ finder.setAddresses(addrs);
+
+ disco.setIpFinder(finder);
+ }
+
+ disco.setSocketTimeout(in.readLong());
+ disco.setAckTimeout(in.readLong());
+ disco.setMaxAckTimeout(in.readLong());
+ disco.setNetworkTimeout(in.readLong());
+ disco.setJoinTimeout(in.readLong());
+
+ cfg.setDiscoverySpi(disco);
+ }
+
+ /**
+ * Writes cache configuration.
+ *
+ * @param writer Writer.
+ * @param ccfg Configuration.
+ */
+ public static void writeCacheConfiguration(BinaryRawWriter writer, CacheConfiguration ccfg) {
+ assert writer != null;
+ assert ccfg != null;
+
+ writer.writeInt(ccfg.getAtomicityMode() == null ?
+ CacheConfiguration.DFLT_CACHE_ATOMICITY_MODE.ordinal() : ccfg.getAtomicityMode().ordinal());
+ writer.writeInt(ccfg.getAtomicWriteOrderMode() == null ? 0 : ccfg.getAtomicWriteOrderMode().ordinal());
+ writer.writeInt(ccfg.getBackups());
+ writer.writeInt(ccfg.getCacheMode() == null ?
+ CacheConfiguration.DFLT_CACHE_MODE.ordinal() : ccfg.getCacheMode().ordinal());
+ writer.writeBoolean(ccfg.isCopyOnRead());
+ writer.writeBoolean(ccfg.isEagerTtl());
+ writer.writeBoolean(ccfg.isSwapEnabled());
+ writer.writeBoolean(ccfg.isEvictSynchronized());
+ writer.writeInt(ccfg.getEvictSynchronizedConcurrencyLevel());
+ writer.writeInt(ccfg.getEvictSynchronizedKeyBufferSize());
+ writer.writeLong(ccfg.getEvictSynchronizedTimeout());
+ writer.writeBoolean(ccfg.isInvalidate());
+ writer.writeBoolean(ccfg.isStoreKeepBinary());
+ writer.writeBoolean(ccfg.isLoadPreviousValue());
+ writer.writeLong(ccfg.getDefaultLockTimeout());
+ writer.writeLong(ccfg.getLongQueryWarningTimeout());
+ writer.writeInt(ccfg.getMaxConcurrentAsyncOperations());
+ writer.writeFloat(ccfg.getEvictMaxOverflowRatio());
+ writer.writeInt(ccfg.getMemoryMode() == null ?
+ CacheConfiguration.DFLT_MEMORY_MODE.ordinal() : ccfg.getMemoryMode().ordinal());
+ writer.writeString(ccfg.getName());
+ writer.writeLong(ccfg.getOffHeapMaxMemory());
+ writer.writeBoolean(ccfg.isReadFromBackup());
+ writer.writeInt(ccfg.getRebalanceBatchSize());
+ writer.writeLong(ccfg.getRebalanceDelay());
+ writer.writeInt(ccfg.getRebalanceMode() == null ?
+ CacheConfiguration.DFLT_REBALANCE_MODE.ordinal() : ccfg.getRebalanceMode().ordinal());
+ writer.writeLong(ccfg.getRebalanceThrottle());
+ writer.writeLong(ccfg.getRebalanceTimeout());
+ writer.writeBoolean(ccfg.isSqlEscapeAll());
+ writer.writeInt(ccfg.getSqlOnheapRowCacheSize());
+ writer.writeInt(ccfg.getStartSize());
+ writer.writeInt(ccfg.getWriteBehindBatchSize());
+ writer.writeBoolean(ccfg.isWriteBehindEnabled());
+ writer.writeLong(ccfg.getWriteBehindFlushFrequency());
+ writer.writeInt(ccfg.getWriteBehindFlushSize());
+ writer.writeInt(ccfg.getWriteBehindFlushThreadCount());
+ writer.writeInt(ccfg.getWriteSynchronizationMode() == null ? 0 : ccfg.getWriteSynchronizationMode().ordinal());
+
+ if (ccfg.getCacheStoreFactory() instanceof PlatformDotNetCacheStoreFactoryNative)
+ writer.writeObject(((PlatformDotNetCacheStoreFactoryNative)ccfg.getCacheStoreFactory()).getNativeFactory());
+ else
+ writer.writeObject(null);
+
+ Collection<QueryEntity> qryEntities = ccfg.getQueryEntities();
+
+ if (qryEntities != null)
+ {
+ writer.writeInt(qryEntities.size());
+
+ for (QueryEntity e : qryEntities)
+ writeQueryEntity(writer, e);
+ }
+ else
+ writer.writeInt(0);
+ }
+
+ /**
+ * Write query entity.
+ *
+ * @param writer Writer.
+ * @param queryEntity Query entity.
+ */
+ private static void writeQueryEntity(BinaryRawWriter writer, QueryEntity queryEntity) {
+ assert queryEntity != null;
+
+ writer.writeString(queryEntity.getKeyType());
+ writer.writeString(queryEntity.getValueType());
+
+ // Fields
+ LinkedHashMap<String, String> fields = queryEntity.getFields();
+
+ if (fields != null) {
+ writer.writeInt(fields.size());
+
+ for (Map.Entry<String, String> field : fields.entrySet()) {
+ writer.writeString(field.getKey());
+ writer.writeString(field.getValue());
+ }
+ }
+ else
+ writer.writeInt(0);
+
+ // Aliases
+ Map<String, String> aliases = queryEntity.getAliases();
+
+ if (aliases != null) {
+ writer.writeInt(aliases.size());
+
+ for (Map.Entry<String, String> alias : aliases.entrySet()) {
+ writer.writeString(alias.getKey());
+ writer.writeString(alias.getValue());
+ }
+ }
+ else
+ writer.writeInt(0);
+
+ // Indexes
+ Collection<QueryIndex> indexes = queryEntity.getIndexes();
+
+ if (indexes != null) {
+ writer.writeInt(indexes.size());
+
+ for (QueryIndex index : indexes)
+ writeQueryIndex(writer, index);
+ }
+ else
+ writer.writeInt(0);
+ }
+
+ /**
+ * Writer query index.
+ *
+ * @param writer Writer.
+ * @param index Index.
+ */
+ private static void writeQueryIndex(BinaryRawWriter writer, QueryIndex index) {
+ assert index != null;
+
+ writer.writeString(index.getName());
+ writer.writeByte((byte)index.getIndexType().ordinal());
+
+ LinkedHashMap<String, Boolean> fields = index.getFields();
+
+ if (fields != null) {
+ writer.writeInt(fields.size());
+
+ for (Map.Entry<String, Boolean> field : fields.entrySet()) {
+ writer.writeString(field.getKey());
+ writer.writeBoolean(!field.getValue());
+ }
+ }
+ else
+ writer.writeInt(0);
+ }
+
+ /**
+ * Writes Ignite configuration.
+ *
+ * @param w Writer.
+ * @param cfg Configuration.
+ */
+ public static void writeIgniteConfiguration(BinaryRawWriter w, IgniteConfiguration cfg) {
+ assert w != null;
+ assert cfg != null;
+
+ w.writeBoolean(cfg.isClientMode());
+ w.writeIntArray(cfg.getIncludeEventTypes());
+ w.writeLong(cfg.getMetricsExpireTime());
+ w.writeInt(cfg.getMetricsHistorySize());
+ w.writeLong(cfg.getMetricsLogFrequency());
+ w.writeLong(cfg.getMetricsUpdateFrequency());
+ w.writeInt(cfg.getNetworkSendRetryCount());
+ w.writeLong(cfg.getNetworkSendRetryDelay());
+ w.writeLong(cfg.getNetworkTimeout());
+ w.writeString(cfg.getWorkDirectory());
+ w.writeString(cfg.getLocalHost());
+
+ CacheConfiguration[] cacheCfg = cfg.getCacheConfiguration();
+
+ if (cacheCfg != null) {
+ w.writeInt(cacheCfg.length);
+
+ for (CacheConfiguration ccfg : cacheCfg)
+ writeCacheConfiguration(w, ccfg);
+ }
+ else
+ w.writeInt(0);
+
+ writeDiscoveryConfiguration(w, cfg.getDiscoverySpi());
+
+ w.writeString(cfg.getIgniteHome());
+
+ w.writeLong(ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getInit());
+ w.writeLong(ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getMax());
+ }
+
+ /**
+ * Writes discovery configuration.
+ *
+ * @param w Writer.
+ * @param spi Disco.
+ */
+ private static void writeDiscoveryConfiguration(BinaryRawWriter w, DiscoverySpi spi) {
+ assert w != null;
+ assert spi != null;
+
+ if (!(spi instanceof TcpDiscoverySpi)) {
+ w.writeBoolean(false);
+ return;
+ }
+
+ w.writeBoolean(true);
+
+ TcpDiscoverySpi tcp = (TcpDiscoverySpi)spi;
+
+ TcpDiscoveryIpFinder finder = tcp.getIpFinder();
+
+ if (finder instanceof TcpDiscoveryVmIpFinder) {
+ w.writeBoolean(true);
+
+ boolean isMulticast = finder instanceof TcpDiscoveryMulticastIpFinder;
+
+ w.writeByte((byte)(isMulticast ? 2 : 1));
+
+ Collection<InetSocketAddress> addrs = finder.getRegisteredAddresses();
+
+ w.writeInt(addrs.size());
+
+ for (InetSocketAddress a : addrs)
+ w.writeString(a.toString());
+
+ if (isMulticast) {
+ TcpDiscoveryMulticastIpFinder multiFinder = (TcpDiscoveryMulticastIpFinder) finder;
+
+ w.writeString(multiFinder.getLocalAddress());
+ w.writeString(multiFinder.getMulticastGroup());
+ w.writeInt(multiFinder.getMulticastPort());
+ w.writeInt(multiFinder.getAddressRequestAttempts());
+ w.writeInt(multiFinder.getResponseWaitTime());
+
+ Integer ttl = multiFinder.getTimeToLive();
+ w.writeBoolean(ttl != null);
+
+ if (ttl != null)
+ w.writeInt(ttl);
+ }
+ }
+ else {
+ w.writeBoolean(false);
+ }
+
+ w.writeLong(tcp.getSocketTimeout());
+ w.writeLong(tcp.getAckTimeout());
+ w.writeLong(tcp.getMaxAckTimeout());
+ w.writeLong(tcp.getNetworkTimeout());
+ w.writeLong(tcp.getJoinTimeout());
+ }
+
+ /**
+ * Private constructor.
+ */
+ private PlatformConfigurationUtils() {
+ // No-op.
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
index 4a29637..d09b2c7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
@@ -22,10 +22,16 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.MarshallerContextImpl;
+import org.apache.ignite.internal.binary.BinaryContext;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.binary.BinaryNoopMetadataHandler;
import org.apache.ignite.internal.binary.BinaryRawReaderEx;
import org.apache.ignite.internal.binary.BinaryRawWriterEx;
+import org.apache.ignite.internal.binary.GridBinaryMarshaller;
import org.apache.ignite.internal.processors.platform.PlatformContext;
import org.apache.ignite.internal.processors.platform.PlatformExtendedException;
import org.apache.ignite.internal.processors.platform.PlatformNativeException;
@@ -38,9 +44,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.lang.IgniteUuid;
-import org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration;
-import org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration;
-import org.apache.ignite.platform.dotnet.PlatformDotNetBinaryTypeConfiguration;
+import org.apache.ignite.logger.NullLogger;
import org.jetbrains.annotations.Nullable;
import javax.cache.CacheException;
@@ -764,41 +768,27 @@ public class PlatformUtils {
}
/**
- * Write .Net configuration to the stream.
+ * Create binary marshaller.
*
- * @param writer Writer.
- * @param cfg Configuration.
+ * @return Marshaller.
*/
- public static void writeDotNetConfiguration(BinaryRawWriterEx writer, PlatformDotNetConfiguration cfg) {
- // 1. Write assemblies.
- writeNullableCollection(writer, cfg.getAssemblies());
+ @SuppressWarnings("deprecation")
+ public static GridBinaryMarshaller marshaller() {
+ try {
+ BinaryContext ctx =
+ new BinaryContext(BinaryNoopMetadataHandler.instance(), new IgniteConfiguration(), new NullLogger());
- PlatformDotNetBinaryConfiguration binaryCfg = cfg.getBinaryConfiguration();
+ BinaryMarshaller marsh = new BinaryMarshaller();
- if (binaryCfg != null) {
- writer.writeBoolean(true);
+ marsh.setContext(new MarshallerContextImpl(null));
- writeNullableCollection(writer, binaryCfg.getTypesConfiguration(),
- new PlatformWriterClosure<PlatformDotNetBinaryTypeConfiguration>() {
- @Override public void write(BinaryRawWriterEx writer, PlatformDotNetBinaryTypeConfiguration typ) {
- writer.writeString(typ.getTypeName());
- writer.writeString(typ.getNameMapper());
- writer.writeString(typ.getIdMapper());
- writer.writeString(typ.getSerializer());
- writer.writeString(typ.getAffinityKeyFieldName());
- writer.writeObject(typ.getKeepDeserialized());
- writer.writeBoolean(typ.isEnum());
- }
- });
+ ctx.configure(marsh, new IgniteConfiguration());
- writeNullableCollection(writer, binaryCfg.getTypes());
- writer.writeString(binaryCfg.getDefaultNameMapper());
- writer.writeString(binaryCfg.getDefaultIdMapper());
- writer.writeString(binaryCfg.getDefaultSerializer());
- writer.writeBoolean(binaryCfg.isDefaultKeepDeserialized());
+ return new GridBinaryMarshaller(ctx);
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
}
- else
- writer.writeBoolean(false);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetCacheStoreFactoryNative.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetCacheStoreFactoryNative.java b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetCacheStoreFactoryNative.java
new file mode 100644
index 0000000..ec01483
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetCacheStoreFactoryNative.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.platform.dotnet;
+
+import org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetCacheStore;
+
+import javax.cache.configuration.Factory;
+
+/**
+ * Cache store factory that wraps native factory object.
+ */
+public class PlatformDotNetCacheStoreFactoryNative implements Factory<PlatformDotNetCacheStore> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private final Object nativeFactory;
+
+ /**
+ * Ctor.
+ *
+ * @param nativeFactory Native factory object.
+ */
+ public PlatformDotNetCacheStoreFactoryNative(Object nativeFactory) {
+ assert nativeFactory != null;
+
+ this.nativeFactory = nativeFactory;
+ }
+
+ /**
+ * Gets the wrapped factory object.
+ *
+ * @return Factory object.
+ */
+ public Object getNativeFactory() {
+ return nativeFactory;
+ }
+
+ /** {@inheritDoc} */
+ @Override public PlatformDotNetCacheStore create() {
+ return new PlatformDotNetCacheStore(nativeFactory);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/cpp/common/include/ignite/common/exports.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/ignite/common/exports.h b/modules/platforms/cpp/common/include/ignite/common/exports.h
index 67583ed..66f918f 100644
--- a/modules/platforms/cpp/common/include/ignite/common/exports.h
+++ b/modules/platforms/cpp/common/include/ignite/common/exports.h
@@ -36,6 +36,8 @@ extern "C" {
void* IGNITE_CALL IgniteProcessorCache(gcj::JniContext* ctx, void* obj, char* name);
void* IGNITE_CALL IgniteProcessorCreateCache(gcj::JniContext* ctx, void* obj, char* name);
void* IGNITE_CALL IgniteProcessorGetOrCreateCache(gcj::JniContext* ctx, void* obj, char* name);
+ void* IGNITE_CALL IgniteProcessorCreateCacheFromConfig(gcj::JniContext* ctx, void* obj, long memPtr);
+ void* IGNITE_CALL IgniteProcessorGetOrCreateCacheFromConfig(gcj::JniContext* ctx, void* obj, long memPtr);
void IGNITE_CALL IgniteProcessorDestroyCache(gcj::JniContext* ctx, void* obj, char* name);
void* IGNITE_CALL IgniteProcessorAffinity(gcj::JniContext* ctx, void* obj, char* name);
void* IGNITE_CALL IgniteProcessorDataStreamer(gcj::JniContext* ctx, void* obj, char* name, bool keepPortable);
@@ -46,6 +48,7 @@ extern "C" {
void* IGNITE_CALL IgniteProcessorServices(gcj::JniContext* ctx, void* obj, void* prj);
void* IGNITE_CALL IgniteProcessorExtensions(gcj::JniContext* ctx, void* obj);
void* IGNITE_CALL IgniteProcessorAtomicLong(gcj::JniContext* ctx, void* obj, char* name, long long initVal, bool create);
+ void IGNITE_CALL IgniteProcessorGetIgniteConfiguration(gcj::JniContext* ctx, void* obj, long memPtr);
long long IGNITE_CALL IgniteTargetInStreamOutLong(gcj::JniContext* ctx, void* obj, int opType, long long memPtr);
void IGNITE_CALL IgniteTargetInStreamOutStream(gcj::JniContext* ctx, void* obj, int opType, long long inMemPtr, long long outMemPtr);
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/cpp/common/include/ignite/common/java.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/ignite/common/java.h b/modules/platforms/cpp/common/include/ignite/common/java.h
index 572f040..072a8ef 100644
--- a/modules/platforms/cpp/common/include/ignite/common/java.h
+++ b/modules/platforms/cpp/common/include/ignite/common/java.h
@@ -297,6 +297,8 @@ namespace ignite
jmethodID m_PlatformProcessor_cache;
jmethodID m_PlatformProcessor_createCache;
jmethodID m_PlatformProcessor_getOrCreateCache;
+ jmethodID m_PlatformProcessor_createCacheFromConfig;
+ jmethodID m_PlatformProcessor_getOrCreateCacheFromConfig;
jmethodID m_PlatformProcessor_destroyCache;
jmethodID m_PlatformProcessor_affinity;
jmethodID m_PlatformProcessor_dataStreamer;
@@ -308,6 +310,7 @@ namespace ignite
jmethodID m_PlatformProcessor_services;
jmethodID m_PlatformProcessor_extensions;
jmethodID m_PlatformProcessor_atomicLong;
+ jmethodID m_PlatformProcessor_getIgniteConfiguration;
jclass c_PlatformTarget;
jmethodID m_PlatformTarget_inStreamOutLong;
@@ -489,6 +492,10 @@ namespace ignite
jobject ProcessorCreateCache(jobject obj, const char* name, JniErrorInfo* errInfo);
jobject ProcessorGetOrCreateCache(jobject obj, const char* name);
jobject ProcessorGetOrCreateCache(jobject obj, const char* name, JniErrorInfo* errInfo);
+ jobject ProcessorCreateCacheFromConfig(jobject obj, long memPtr);
+ jobject ProcessorCreateCacheFromConfig(jobject obj, long memPtr, JniErrorInfo* errInfo);
+ jobject ProcessorGetOrCreateCacheFromConfig(jobject obj, long memPtr);
+ jobject ProcessorGetOrCreateCacheFromConfig(jobject obj, long memPtr, JniErrorInfo* errInfo);
void ProcessorDestroyCache(jobject obj, const char* name);
void ProcessorDestroyCache(jobject obj, const char* name, JniErrorInfo* errInfo);
jobject ProcessorAffinity(jobject obj, const char* name);
@@ -500,6 +507,7 @@ namespace ignite
jobject ProcessorServices(jobject obj, jobject prj);
jobject ProcessorExtensions(jobject obj);
jobject ProcessorAtomicLong(jobject obj, char* name, long long initVal, bool create);
+ void ProcessorGetIgniteConfiguration(jobject obj, long memPtr);
long long TargetInStreamOutLong(jobject obj, int type, long long memPtr, JniErrorInfo* errInfo = NULL);
void TargetInStreamOutStream(jobject obj, int opType, long long inMemPtr, long long outMemPtr, JniErrorInfo* errInfo = NULL);
@@ -618,6 +626,7 @@ namespace ignite
void ExceptionCheck(JNIEnv* env, JniErrorInfo* errInfo);
jobject LocalToGlobal(JNIEnv* env, jobject obj);
jobject ProcessorCache0(jobject proc, const char* name, jmethodID mthd, JniErrorInfo* errInfo);
+ jobject ProcessorCacheFromConfig0(jobject proc, long memPtr, jmethodID mthd, JniErrorInfo* errInfo);
};
JNIEXPORT jlong JNICALL JniCacheStoreCreate(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr);
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/cpp/common/project/vs/module.def
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/project/vs/module.def b/modules/platforms/cpp/common/project/vs/module.def
index c947128..81df027 100644
--- a/modules/platforms/cpp/common/project/vs/module.def
+++ b/modules/platforms/cpp/common/project/vs/module.def
@@ -113,4 +113,7 @@ IgniteListenableCancel @110
IgniteListenableIsCancelled @111
IgniteTargetListenFutureAndGet @112
IgniteTargetListenFutureForOperationAndGet @113
-IgniteProcessorDestroyCache @114
\ No newline at end of file
+IgniteProcessorCreateCacheFromConfig @114
+IgniteProcessorGetOrCreateCacheFromConfig @115
+IgniteProcessorGetIgniteConfiguration @116
+IgniteProcessorDestroyCache @117
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/cpp/common/src/exports.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/src/exports.cpp b/modules/platforms/cpp/common/src/exports.cpp
index d4ffa7e..e9ec519 100644
--- a/modules/platforms/cpp/common/src/exports.cpp
+++ b/modules/platforms/cpp/common/src/exports.cpp
@@ -66,6 +66,14 @@ extern "C" {
return ctx->ProcessorGetOrCreateCache(static_cast<jobject>(obj), name);
}
+ void* IGNITE_CALL IgniteProcessorCreateCacheFromConfig(gcj::JniContext* ctx, void* obj, long memPtr) {
+ return ctx->ProcessorCreateCacheFromConfig(static_cast<jobject>(obj), memPtr);
+ }
+
+ void* IGNITE_CALL IgniteProcessorGetOrCreateCacheFromConfig(gcj::JniContext* ctx, void* obj, long memPtr) {
+ return ctx->ProcessorGetOrCreateCacheFromConfig(static_cast<jobject>(obj), memPtr);
+ }
+
void IGNITE_CALL IgniteProcessorDestroyCache(gcj::JniContext* ctx, void* obj, char* name) {
ctx->ProcessorDestroyCache(static_cast<jobject>(obj), name);
}
@@ -106,6 +114,10 @@ extern "C" {
return ctx->ProcessorAtomicLong(static_cast<jobject>(obj), name, initVal, create);
}
+ void IGNITE_CALL IgniteProcessorGetIgniteConfiguration(gcj::JniContext* ctx, void* obj, long memPtr) {
+ return ctx->ProcessorGetIgniteConfiguration(static_cast<jobject>(obj), memPtr);
+ }
+
long long IGNITE_CALL IgniteTargetInStreamOutLong(gcj::JniContext* ctx, void* obj, int opType, long long memPtr) {
return ctx->TargetInStreamOutLong(static_cast<jobject>(obj), opType, memPtr);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/cpp/common/src/java.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/src/java.cpp b/modules/platforms/cpp/common/src/java.cpp
index 9e55742..e36c1e0 100644
--- a/modules/platforms/cpp/common/src/java.cpp
+++ b/modules/platforms/cpp/common/src/java.cpp
@@ -191,6 +191,8 @@ namespace ignite
JniMethod M_PLATFORM_PROCESSOR_CACHE = JniMethod("cache", "(Ljava/lang/String;)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
JniMethod M_PLATFORM_PROCESSOR_CREATE_CACHE = JniMethod("createCache", "(Ljava/lang/String;)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
JniMethod M_PLATFORM_PROCESSOR_GET_OR_CREATE_CACHE = JniMethod("getOrCreateCache", "(Ljava/lang/String;)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
+ JniMethod M_PLATFORM_PROCESSOR_CREATE_CACHE_FROM_CONFIG = JniMethod("createCacheFromConfig", "(J)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
+ JniMethod M_PLATFORM_PROCESSOR_GET_OR_CREATE_CACHE_FROM_CONFIG = JniMethod("getOrCreateCacheFromConfig", "(J)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
JniMethod M_PLATFORM_PROCESSOR_DESTROY_CACHE = JniMethod("destroyCache", "(Ljava/lang/String;)V", false);
JniMethod M_PLATFORM_PROCESSOR_AFFINITY = JniMethod("affinity", "(Ljava/lang/String;)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
JniMethod M_PLATFORM_PROCESSOR_DATA_STREAMER = JniMethod("dataStreamer", "(Ljava/lang/String;Z)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
@@ -201,6 +203,7 @@ namespace ignite
JniMethod M_PLATFORM_PROCESSOR_SERVICES = JniMethod("services", "(Lorg/apache/ignite/internal/processors/platform/PlatformTarget;)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
JniMethod M_PLATFORM_PROCESSOR_EXTENSIONS = JniMethod("extensions", "()Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
JniMethod M_PLATFORM_PROCESSOR_ATOMIC_LONG = JniMethod("atomicLong", "(Ljava/lang/String;JZ)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
+ JniMethod M_PLATFORM_PROCESSOR_GET_IGNITE_CONFIGURATION = JniMethod("getIgniteConfiguration", "(J)V", false);
const char* C_PLATFORM_TARGET = "org/apache/ignite/internal/processors/platform/PlatformTarget";
JniMethod M_PLATFORM_TARGET_IN_STREAM_OUT_LONG = JniMethod("inStreamOutLong", "(IJ)J", false);
@@ -636,6 +639,8 @@ namespace ignite
m_PlatformProcessor_cache = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_CACHE);
m_PlatformProcessor_createCache = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_CREATE_CACHE);
m_PlatformProcessor_getOrCreateCache = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_GET_OR_CREATE_CACHE);
+ m_PlatformProcessor_createCacheFromConfig = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_CREATE_CACHE_FROM_CONFIG);
+ m_PlatformProcessor_getOrCreateCacheFromConfig = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_GET_OR_CREATE_CACHE_FROM_CONFIG);
m_PlatformProcessor_destroyCache = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_DESTROY_CACHE);
m_PlatformProcessor_affinity = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_AFFINITY);
m_PlatformProcessor_dataStreamer = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_DATA_STREAMER);
@@ -647,6 +652,7 @@ namespace ignite
m_PlatformProcessor_services = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_SERVICES);
m_PlatformProcessor_extensions = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_EXTENSIONS);
m_PlatformProcessor_atomicLong = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_ATOMIC_LONG);
+ m_PlatformProcessor_getIgniteConfiguration = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_GET_IGNITE_CONFIGURATION);
c_PlatformTarget = FindClass(env, C_PLATFORM_TARGET);
m_PlatformTarget_inStreamOutLong = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_IN_STREAM_OUT_LONG);
@@ -1120,6 +1126,17 @@ namespace ignite
return LocalToGlobal(env, cache);
}
+ jobject JniContext::ProcessorCacheFromConfig0(jobject obj, long memPtr, jmethodID mthd, JniErrorInfo* errInfo)
+ {
+ JNIEnv* env = Attach();
+
+ jobject cache = env->CallObjectMethod(obj, mthd, memPtr);
+
+ ExceptionCheck(env, errInfo);
+
+ return LocalToGlobal(env, cache);
+ }
+
jobject JniContext::ProcessorCache(jobject obj, const char* name) {
return ProcessorCache(obj, name, NULL);
}
@@ -1164,6 +1181,24 @@ namespace ignite
ExceptionCheck(env, errInfo);
}
+ jobject JniContext::ProcessorCreateCacheFromConfig(jobject obj, long memPtr) {
+ return ProcessorCreateCacheFromConfig(obj, memPtr, NULL);
+ }
+
+ jobject JniContext::ProcessorCreateCacheFromConfig(jobject obj, long memPtr, JniErrorInfo* errInfo)
+ {
+ return ProcessorCacheFromConfig0(obj, memPtr, jvm->GetMembers().m_PlatformProcessor_createCacheFromConfig, errInfo);
+ }
+
+ jobject JniContext::ProcessorGetOrCreateCacheFromConfig(jobject obj, long memPtr) {
+ return ProcessorGetOrCreateCacheFromConfig(obj, memPtr, NULL);
+ }
+
+ jobject JniContext::ProcessorGetOrCreateCacheFromConfig(jobject obj, long memPtr, JniErrorInfo* errInfo)
+ {
+ return ProcessorCacheFromConfig0(obj, memPtr, jvm->GetMembers().m_PlatformProcessor_getOrCreateCacheFromConfig, errInfo);
+ }
+
jobject JniContext::ProcessorAffinity(jobject obj, const char* name) {
JNIEnv* env = Attach();
@@ -1272,6 +1307,15 @@ namespace ignite
return LocalToGlobal(env, res);
}
+ void JniContext::ProcessorGetIgniteConfiguration(jobject obj, long memPtr)
+ {
+ JNIEnv* env = Attach();
+
+ env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformProcessor_getIgniteConfiguration, memPtr);
+
+ ExceptionCheck(env);
+ }
+
long long JniContext::TargetInStreamOutLong(jobject obj, int opType, long long memPtr, JniErrorInfo* err) {
JNIEnv* env = Attach();
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
index 5a1e176..481adfb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -60,6 +60,7 @@
<Reference Include="System.XML" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Cache\CacheConfigurationTest.cs" />
<Compile Include="Cache\CacheDynamicStartTest.cs" />
<Compile Include="Cache\CacheTestAsyncWrapper.cs" />
<Compile Include="Cache\CacheAbstractTest.cs" />
@@ -74,6 +75,7 @@
<Compile Include="Cache\CachePartitionedTest.cs" />
<Compile Include="Cache\CacheReplicatedAtomicTest.cs" />
<Compile Include="Cache\CacheReplicatedTest.cs" />
+ <Compile Include="Cache\Query\CacheQueriesCodeConfigurationTest.cs" />
<Compile Include="Cache\Query\Continuous\ContinuousQueryAbstractTest.cs" />
<Compile Include="Cache\Query\Continuous\ContinuousQueryAtomicBackupTest.cs" />
<Compile Include="Cache\Query\Continuous\ContinuousQueryAtomicNoBackupTest.cs" />
@@ -113,6 +115,7 @@
<Compile Include="ExceptionsTest.cs" />
<Compile Include="ExecutableTest.cs" />
<Compile Include="FutureTest.cs" />
+ <Compile Include="IgniteConfigurationTest.cs" />
<Compile Include="IgniteTestBase.cs" />
<Compile Include="LifecycleTest.cs" />
<Compile Include="LoadDllTest.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
index 9232665..44db6f7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
@@ -1341,6 +1341,15 @@ namespace Apache.Ignite.Core.Tests.Binary
}
}
+ [Test]
+ public void TestBinaryConfigurationValidation()
+ {
+ var cfg = new BinaryConfiguration(typeof (PropertyType)) {Types = new[] {"PropertyType"}};
+
+ // ReSharper disable once ObjectCreationAsStatement
+ Assert.Throws<BinaryObjectException>(() => new Marshaller(cfg));
+ }
+
private static void CheckKeepSerialized(BinaryConfiguration cfg, bool expKeep)
{
if (cfg.TypeConfigurations == null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
index e57df6f..9f0528c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
@@ -292,7 +292,7 @@ namespace Apache.Ignite.Core.Tests.Cache
public virtual void StartGrids() {
TestUtils.KillProcesses();
- IgniteConfigurationEx cfg = new IgniteConfigurationEx();
+ IgniteConfiguration cfg = new IgniteConfiguration();
BinaryConfiguration portCfg = new BinaryConfiguration();
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
index 5a1af03..689804c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
@@ -36,7 +36,7 @@ namespace Apache.Ignite.Core.Tests.Cache
{
TestUtils.KillProcesses();
- IgniteConfigurationEx cfg = new IgniteConfigurationEx();
+ IgniteConfiguration cfg = new IgniteConfiguration();
cfg.JvmClasspath = TestUtils.CreateTestClasspath();
cfg.JvmOptions = TestUtils.TestJavaOptions();
[3/4] ignite git commit: IGNITE-1906: .NET: Implemented programmatic
configuration.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
new file mode 100644
index 0000000..2e6a8a1
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
@@ -0,0 +1,538 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Linq;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Cache.Configuration;
+ using Apache.Ignite.Core.Cache.Store;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Discovery.Tcp;
+ using Apache.Ignite.Core.Discovery.Tcp.Static;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests cache configuration propagation.
+ /// </summary>
+ public class CacheConfigurationTest
+ {
+ /** */
+ private IIgnite _ignite;
+
+ /** */
+ private const string CacheName = "cacheName";
+
+ /** */
+ private static int _factoryProp;
+
+
+ /// <summary>
+ /// Fixture set up.
+ /// </summary>
+ [TestFixtureSetUp]
+ public void FixtureSetUp()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ CacheConfiguration = new List<CacheConfiguration>
+ {
+ new CacheConfiguration(),
+ GetCustomCacheConfiguration()
+ },
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = TestUtils.TestJavaOptions(),
+ GridName = CacheName,
+ BinaryConfiguration = new BinaryConfiguration(typeof(Entity)),
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[] { "127.0.0.1:47500", "127.0.0.1:47501" }
+ }
+ }
+ };
+
+ _ignite = Ignition.Start(cfg);
+ }
+
+ /// <summary>
+ /// Fixture tear down.
+ /// </summary>
+ [TestFixtureTearDown]
+ public void FixtureTearDown()
+ {
+ Ignition.StopAll(true);
+ }
+
+ /// <summary>
+ /// Tests the default configuration.
+ /// </summary>
+ [Test]
+ public void TestDefaultConfiguration()
+ {
+ AssertConfigIsDefault(new CacheConfiguration());
+
+ AssertConfigIsDefault(_ignite.GetCache<int, int>(null).GetConfiguration());
+
+ AssertConfigIsDefault(_ignite.GetConfiguration().CacheConfiguration.Single(c => c.Name == null));
+ }
+
+ /// <summary>
+ /// Tests the custom configuration.
+ /// </summary>
+ [Test]
+ public void TestCustomConfiguration()
+ {
+ AssertConfigsAreEqual(GetCustomCacheConfiguration(),
+ _ignite.GetCache<int, int>(CacheName).GetConfiguration());
+
+ AssertConfigsAreEqual(GetCustomCacheConfiguration(),
+ _ignite.GetConfiguration().CacheConfiguration.Single(c => c.Name == CacheName));
+ }
+
+ /// <summary>
+ /// Tests the create from configuration.
+ /// </summary>
+ [Test]
+ public void TestCreateFromConfiguration()
+ {
+ var cacheName = Guid.NewGuid().ToString();
+ var cfg = GetCustomCacheConfiguration(cacheName);
+
+ var cache = _ignite.CreateCache<int, Entity>(cfg);
+ AssertConfigsAreEqual(cfg, cache.GetConfiguration());
+
+ // Can't create existing cache
+ Assert.Throws<IgniteException>(() => _ignite.CreateCache<int, int>(cfg));
+
+ // Check put-get
+ cache[1] = new Entity { Foo = 1 };
+ Assert.AreEqual(1, cache[1].Foo);
+ }
+
+ /// <summary>
+ /// Tests the get or create from configuration.
+ /// </summary>
+ [Test]
+ public void TestGetOrCreateFromConfiguration()
+ {
+ var cacheName = Guid.NewGuid().ToString();
+ var cfg = GetCustomCacheConfiguration(cacheName);
+
+ var cache = _ignite.GetOrCreateCache<int, Entity>(cfg);
+ AssertConfigsAreEqual(cfg, cache.GetConfiguration());
+
+ var cache2 = _ignite.GetOrCreateCache<int, Entity>(cfg);
+ AssertConfigsAreEqual(cfg, cache2.GetConfiguration());
+
+ // Check put-get
+ cache[1] = new Entity { Foo = 1 };
+ Assert.AreEqual(1, cache[1].Foo);
+ }
+
+ /// <summary>
+ /// Tests the cache store.
+ /// </summary>
+ [Test]
+ public void TestCacheStore()
+ {
+ _factoryProp = 0;
+
+ var factory = new CacheStoreFactoryTest {TestProperty = 15};
+
+ var cache = _ignite.CreateCache<int, int>(new CacheConfiguration("cacheWithStore")
+ {
+ CacheStoreFactory = factory
+ });
+
+ Assert.AreEqual(factory.TestProperty, _factoryProp);
+
+ var factory0 = cache.GetConfiguration().CacheStoreFactory as CacheStoreFactoryTest;
+
+ Assert.IsNotNull(factory0);
+ Assert.AreEqual(factory.TestProperty, factory0.TestProperty);
+ }
+
+ /// <summary>
+ /// Asserts the configuration is default.
+ /// </summary>
+ private static void AssertConfigIsDefault(CacheConfiguration cfg)
+ {
+ Assert.AreEqual(CacheConfiguration.DefaultBackups, cfg.Backups);
+ Assert.AreEqual(CacheConfiguration.DefaultAtomicityMode, cfg.AtomicityMode);
+ Assert.AreEqual(CacheConfiguration.DefaultCacheMode, cfg.CacheMode);
+ Assert.AreEqual(CacheConfiguration.DefaultCopyOnRead, cfg.CopyOnRead);
+ Assert.AreEqual(CacheConfiguration.DefaultStartSize, cfg.StartSize);
+ Assert.AreEqual(CacheConfiguration.DefaultEagerTtl, cfg.EagerTtl);
+ Assert.AreEqual(CacheConfiguration.DefaultEvictSynchronizedKeyBufferSize, cfg.EvictSynchronizedKeyBufferSize);
+ Assert.AreEqual(CacheConfiguration.DefaultEvictSynchronized, cfg.EvictSynchronized);
+ Assert.AreEqual(CacheConfiguration.DefaultEvictSynchronizedConcurrencyLevel, cfg.EvictSynchronizedConcurrencyLevel);
+ Assert.AreEqual(CacheConfiguration.DefaultEvictSynchronizedTimeout, cfg.EvictSynchronizedTimeout);
+ Assert.AreEqual(CacheConfiguration.DefaultInvalidate, cfg.Invalidate);
+ Assert.AreEqual(CacheConfiguration.DefaultKeepVinaryInStore, cfg.KeepBinaryInStore);
+ Assert.AreEqual(CacheConfiguration.DefaultLoadPreviousValue, cfg.LoadPreviousValue);
+ Assert.AreEqual(CacheConfiguration.DefaultLockTimeout, cfg.LockTimeout);
+ Assert.AreEqual(CacheConfiguration.DefaultLongQueryWarningTimeout, cfg.LongQueryWarningTimeout);
+ Assert.AreEqual(CacheConfiguration.DefaultMaxConcurrentAsyncOperations, cfg.MaxConcurrentAsyncOperations);
+ Assert.AreEqual(CacheConfiguration.DefaultMaxEvictionOverflowRatio, cfg.MaxEvictionOverflowRatio);
+ Assert.AreEqual(CacheConfiguration.DefaultMemoryMode, cfg.MemoryMode);
+ Assert.AreEqual(CacheConfiguration.DefaultOffHeapMaxMemory, cfg.OffHeapMaxMemory);
+ Assert.AreEqual(CacheConfiguration.DefaultReadFromBackup, cfg.ReadFromBackup);
+ Assert.AreEqual(CacheConfiguration.DefaultRebalanceBatchSize, cfg.RebalanceBatchSize);
+ Assert.AreEqual(CacheConfiguration.DefaultRebalanceMode, cfg.RebalanceMode);
+ Assert.AreEqual(CacheConfiguration.DefaultRebalanceThrottle, cfg.RebalanceThrottle);
+ Assert.AreEqual(CacheConfiguration.DefaultRebalanceTimeout, cfg.RebalanceTimeout);
+ Assert.AreEqual(CacheConfiguration.DefaultSqlOnheapRowCacheSize, cfg.SqlOnheapRowCacheSize);
+ Assert.AreEqual(CacheConfiguration.DefaultStartSize, cfg.StartSize);
+ Assert.AreEqual(CacheConfiguration.DefaultStartSize, cfg.StartSize);
+ Assert.AreEqual(CacheConfiguration.DefaultEnableSwap, cfg.EnableSwap);
+ Assert.AreEqual(CacheConfiguration.DefaultWriteBehindBatchSize, cfg.WriteBehindBatchSize);
+ Assert.AreEqual(CacheConfiguration.DefaultWriteBehindEnabled, cfg.WriteBehindEnabled);
+ Assert.AreEqual(CacheConfiguration.DefaultWriteBehindFlushFrequency, cfg.WriteBehindFlushFrequency);
+ Assert.AreEqual(CacheConfiguration.DefaultWriteBehindFlushSize, cfg.WriteBehindFlushSize);
+ }
+
+ /// <summary>
+ /// Asserts that two configurations have the same properties.
+ /// </summary>
+ private static void AssertConfigsAreEqual(CacheConfiguration x, CacheConfiguration y)
+ {
+ Assert.AreEqual(x.Backups, y.Backups);
+ Assert.AreEqual(x.AtomicityMode, y.AtomicityMode);
+ Assert.AreEqual(x.CacheMode, y.CacheMode);
+ Assert.AreEqual(x.CopyOnRead, y.CopyOnRead);
+ Assert.AreEqual(x.StartSize, y.StartSize);
+ Assert.AreEqual(x.EagerTtl, y.EagerTtl);
+ Assert.AreEqual(x.EvictSynchronizedKeyBufferSize, y.EvictSynchronizedKeyBufferSize);
+ Assert.AreEqual(x.EvictSynchronized, y.EvictSynchronized);
+ Assert.AreEqual(x.EvictSynchronizedConcurrencyLevel, y.EvictSynchronizedConcurrencyLevel);
+ Assert.AreEqual(x.EvictSynchronizedTimeout, y.EvictSynchronizedTimeout);
+ Assert.AreEqual(x.Invalidate, y.Invalidate);
+ Assert.AreEqual(x.KeepBinaryInStore, y.KeepBinaryInStore);
+ Assert.AreEqual(x.LoadPreviousValue, y.LoadPreviousValue);
+ Assert.AreEqual(x.LockTimeout, y.LockTimeout);
+ Assert.AreEqual(x.LongQueryWarningTimeout, y.LongQueryWarningTimeout);
+ Assert.AreEqual(x.MaxConcurrentAsyncOperations, y.MaxConcurrentAsyncOperations);
+ Assert.AreEqual(x.MaxEvictionOverflowRatio, y.MaxEvictionOverflowRatio);
+ Assert.AreEqual(x.MemoryMode, y.MemoryMode);
+ Assert.AreEqual(x.OffHeapMaxMemory, y.OffHeapMaxMemory);
+ Assert.AreEqual(x.ReadFromBackup, y.ReadFromBackup);
+ Assert.AreEqual(x.RebalanceBatchSize, y.RebalanceBatchSize);
+ Assert.AreEqual(x.RebalanceMode, y.RebalanceMode);
+ Assert.AreEqual(x.RebalanceThrottle, y.RebalanceThrottle);
+ Assert.AreEqual(x.RebalanceTimeout, y.RebalanceTimeout);
+ Assert.AreEqual(x.SqlOnheapRowCacheSize, y.SqlOnheapRowCacheSize);
+ Assert.AreEqual(x.StartSize, y.StartSize);
+ Assert.AreEqual(x.StartSize, y.StartSize);
+ Assert.AreEqual(x.EnableSwap, y.EnableSwap);
+ Assert.AreEqual(x.WriteBehindBatchSize, y.WriteBehindBatchSize);
+ Assert.AreEqual(x.WriteBehindEnabled, y.WriteBehindEnabled);
+ Assert.AreEqual(x.WriteBehindFlushFrequency, y.WriteBehindFlushFrequency);
+ Assert.AreEqual(x.WriteBehindFlushSize, y.WriteBehindFlushSize);
+
+ AssertConfigsAreEqual(x.QueryEntities, y.QueryEntities);
+ }
+
+ /// <summary>
+ /// Asserts that two configurations have the same properties.
+ /// </summary>
+ private static void AssertConfigsAreEqual(ICollection<QueryEntity> x, ICollection<QueryEntity> y)
+ {
+ if (x == null)
+ {
+ Assert.IsNull(y);
+ return;
+ }
+
+ Assert.AreEqual(x.Count, y.Count);
+
+ for (var i = 0; i < x.Count; i++)
+ AssertConfigsAreEqual(x.ElementAt(i), y.ElementAt(i));
+ }
+
+ /// <summary>
+ /// Asserts that two configurations have the same properties.
+ /// </summary>
+ private static void AssertConfigsAreEqual(QueryEntity x, QueryEntity y)
+ {
+ Assert.IsNotNull(x);
+ Assert.IsNotNull(y);
+
+ Assert.AreEqual(x.KeyTypeName, y.KeyTypeName);
+ Assert.AreEqual(x.ValueTypeName, y.ValueTypeName);
+
+ AssertConfigsAreEqual(x.Fields, y.Fields);
+ AssertConfigsAreEqual(x.Aliases, y.Aliases);
+
+ AssertConfigsAreEqual(x.Indexes, y.Indexes);
+ }
+
+ /// <summary>
+ /// Asserts that two configurations have the same properties.
+ /// </summary>
+ private static void AssertConfigsAreEqual(ICollection<QueryIndex> x, ICollection<QueryIndex> y)
+ {
+ if (x == null)
+ {
+ Assert.IsNull(y);
+ return;
+ }
+
+ Assert.AreEqual(x.Count, y.Count);
+
+ for (var i = 0; i < x.Count; i++)
+ AssertConfigsAreEqual(x.ElementAt(i), y.ElementAt(i));
+ }
+
+ /// <summary>
+ /// Asserts that two configurations have the same properties.
+ /// </summary>
+ private static void AssertConfigsAreEqual(ICollection<QueryField> x, ICollection<QueryField> y)
+ {
+ if (x == null)
+ {
+ Assert.IsNull(y);
+ return;
+ }
+
+ Assert.AreEqual(x.Count, y.Count);
+
+ for (var i = 0; i < x.Count; i++)
+ AssertConfigsAreEqual(x.ElementAt(i), y.ElementAt(i));
+ }
+
+ /// <summary>
+ /// Asserts that two configurations have the same properties.
+ /// </summary>
+ private static void AssertConfigsAreEqual(ICollection<QueryAlias> x, ICollection<QueryAlias> y)
+ {
+ if (x == null)
+ {
+ Assert.IsNull(y);
+ return;
+ }
+
+ Assert.AreEqual(x.Count, y.Count);
+
+ for (var i = 0; i < x.Count; i++)
+ AssertConfigsAreEqual(x.ElementAt(i), y.ElementAt(i));
+ }
+
+ /// <summary>
+ /// Asserts that two configurations have the same properties.
+ /// </summary>
+ private static void AssertConfigsAreEqual(ICollection<QueryIndexField> x, ICollection<QueryIndexField> y)
+ {
+ if (x == null)
+ {
+ Assert.IsNull(y);
+ return;
+ }
+
+ Assert.AreEqual(x.Count, y.Count);
+
+ for (var i = 0; i < x.Count; i++)
+ AssertConfigsAreEqual(x.ElementAt(i), y.ElementAt(i));
+ }
+
+ /// <summary>
+ /// Asserts that two configurations have the same properties.
+ /// </summary>
+ private static void AssertConfigsAreEqual(QueryIndex x, QueryIndex y)
+ {
+ Assert.IsNotNull(x);
+ Assert.IsNotNull(y);
+
+ Assert.AreEqual(x.Name, y.Name);
+ Assert.AreEqual(x.IndexType, y.IndexType);
+
+ AssertConfigsAreEqual(x.Fields, y.Fields);
+ }
+
+ /// <summary>
+ /// Asserts that two configurations have the same properties.
+ /// </summary>
+ private static void AssertConfigsAreEqual(QueryField x, QueryField y)
+ {
+ Assert.IsNotNull(x);
+ Assert.IsNotNull(y);
+
+ Assert.AreEqual(x.Name, y.Name);
+ Assert.AreEqual(x.FieldTypeName, y.FieldTypeName);
+ }
+
+ /// <summary>
+ /// Asserts that two configurations have the same properties.
+ /// </summary>
+ private static void AssertConfigsAreEqual(QueryAlias x, QueryAlias y)
+ {
+ Assert.IsNotNull(x);
+ Assert.IsNotNull(y);
+
+ Assert.AreEqual(x.FullName, y.FullName);
+ Assert.AreEqual(x.Alias, y.Alias);
+ }
+
+ /// <summary>
+ /// Asserts that two configurations have the same properties.
+ /// </summary>
+ private static void AssertConfigsAreEqual(QueryIndexField x, QueryIndexField y)
+ {
+ Assert.IsNotNull(x);
+ Assert.IsNotNull(y);
+
+ Assert.AreEqual(x.Name, y.Name);
+ Assert.AreEqual(x.IsDescending, y.IsDescending);
+ }
+
+ /// <summary>
+ /// Gets the custom cache configuration.
+ /// </summary>
+ private static CacheConfiguration GetCustomCacheConfiguration(string name = null)
+ {
+ return new CacheConfiguration
+ {
+ Name = name ?? CacheName,
+ OffHeapMaxMemory = 1,
+ StartSize = 2,
+ MaxConcurrentAsyncOperations = 3,
+ WriteBehindFlushThreadCount = 4,
+ LongQueryWarningTimeout = TimeSpan.FromSeconds(5),
+ LoadPreviousValue = true,
+ EvictSynchronizedKeyBufferSize = 6,
+ CopyOnRead = true,
+ WriteBehindFlushFrequency = TimeSpan.FromSeconds(6),
+ WriteBehindFlushSize = 7,
+ EvictSynchronized = true,
+ AtomicWriteOrderMode = CacheAtomicWriteOrderMode.Primary,
+ AtomicityMode = CacheAtomicityMode.Atomic,
+ Backups = 8,
+ CacheMode = CacheMode.Partitioned,
+ EagerTtl = true,
+ EnableSwap = true,
+ EvictSynchronizedConcurrencyLevel = 9,
+ EvictSynchronizedTimeout = TimeSpan.FromSeconds(10),
+ Invalidate = true,
+ KeepBinaryInStore = true,
+ LockTimeout = TimeSpan.FromSeconds(11),
+ MaxEvictionOverflowRatio = 0.5f,
+ MemoryMode = CacheMemoryMode.OnheapTiered,
+ ReadFromBackup = true,
+ RebalanceBatchSize = 12,
+ RebalanceDelay = TimeSpan.FromSeconds(13),
+ RebalanceMode = CacheRebalanceMode.Async,
+ RebalanceThrottle = TimeSpan.FromSeconds(15),
+ RebalanceTimeout = TimeSpan.FromSeconds(16),
+ SqlEscapeAll = true,
+ SqlOnheapRowCacheSize = 17,
+ WriteBehindBatchSize = 18,
+ WriteBehindEnabled = false,
+ WriteSynchronizationMode = CacheWriteSynchronizationMode.PrimarySync,
+ QueryEntities = new[]
+ {
+ new QueryEntity
+ {
+ KeyTypeName = "Integer",
+ ValueTypeName = "java.lang.String",
+ Fields = new[]
+ {
+ new QueryField("length", typeof(int)),
+ new QueryField("name", typeof(string)),
+ new QueryField("location", typeof(string)),
+ },
+ Aliases = new [] {new QueryAlias("length", "len") },
+ Indexes = new[]
+ {
+ new QueryIndex("name") {Name = "index1" },
+ new QueryIndex(new QueryIndexField("location", true))
+ {
+ Name= "index2",
+ IndexType = QueryIndexType.FullText
+ }
+ }
+ }
+ }
+ };
+ }
+
+ /// <summary>
+ /// Test factory.
+ /// </summary>
+ [Serializable]
+ private class CacheStoreFactoryTest : IFactory<ICacheStore>
+ {
+ /// <summary>
+ /// Gets or sets the test property.
+ /// </summary>
+ /// <value>
+ /// The test property.
+ /// </value>
+ public int TestProperty { get; set; }
+
+ /// <summary>
+ /// Creates an instance of the cache store.
+ /// </summary>
+ /// <returns>
+ /// New instance of the cache store.
+ /// </returns>
+ public ICacheStore CreateInstance()
+ {
+ _factoryProp = TestProperty;
+
+ return new CacheStoreTest();
+ }
+ }
+
+ /// <summary>
+ /// Test store.
+ /// </summary>
+ private class CacheStoreTest : CacheStoreAdapter
+ {
+ /** <inheritdoc /> */
+ public override object Load(object key)
+ {
+ return null;
+ }
+
+ /** <inheritdoc /> */
+ public override void Write(object key, object val)
+ {
+ // No-op.
+ }
+
+ /** <inheritdoc /> */
+ public override void Delete(object key)
+ {
+ // No-op.
+ }
+ }
+
+ /// <summary>
+ /// Test entity.
+ /// </summary>
+ private class Entity
+ {
+ /// <summary>
+ /// Gets or sets the foo.
+ /// </summary>
+ public int Foo { get; set; }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
index 63443b7..7c18a34 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
@@ -79,9 +79,9 @@ namespace Apache.Ignite.Core.Tests.Cache
/// <param name="name">Grid name.</param>
/// <param name="springCfg">Spring configuration.</param>
/// <returns>Configuration.</returns>
- private static IgniteConfigurationEx CreateConfiguration(string name, string springCfg)
+ private static IgniteConfiguration CreateConfiguration(string name, string springCfg)
{
- IgniteConfigurationEx cfg = new IgniteConfigurationEx();
+ var cfg = new IgniteConfiguration();
BinaryConfiguration portCfg = new BinaryConfiguration();
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
index 33c9f11..09e57dc 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
@@ -23,6 +23,7 @@ namespace Apache.Ignite.Core.Tests.Cache
using System.Diagnostics;
using System.Threading.Tasks;
using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cache.Configuration;
using Apache.Ignite.Core.Cache.Expiry;
using Apache.Ignite.Core.Cache.Query;
using Apache.Ignite.Core.Cache.Query.Continuous;
@@ -58,6 +59,12 @@ namespace Apache.Ignite.Core.Tests.Cache
}
/** <inheritDoc /> */
+ public CacheConfiguration GetConfiguration()
+ {
+ return _cache.GetConfiguration();
+ }
+
+ /** <inheritDoc /> */
public bool IsEmpty()
{
return _cache.IsEmpty();
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs
new file mode 100644
index 0000000..a969127
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs
@@ -0,0 +1,295 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 MemberCanBePrivate.Local
+// ReSharper disable UnusedAutoPropertyAccessor.Local
+// ReSharper disable UnusedMember.Local
+namespace Apache.Ignite.Core.Tests.Cache.Query
+{
+ using System;
+ using System.Linq;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Cache.Configuration;
+ using Apache.Ignite.Core.Cache.Query;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests queries with in-code configuration.
+ /// </summary>
+ public class CacheQueriesCodeConfigurationTest
+ {
+ const string CacheName = "personCache";
+
+ /// <summary>
+ /// Tests the SQL query.
+ /// </summary>
+ [Test]
+ public void TestQueryEntityConfiguration()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ JvmOptions = TestUtils.TestJavaOptions(),
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ BinaryConfiguration = new BinaryConfiguration(typeof (QueryPerson)),
+ CacheConfiguration = new[]
+ {
+ new CacheConfiguration(CacheName, new QueryEntity(typeof (int), typeof (QueryPerson))
+ {
+ Fields = new[]
+ {
+ new QueryField("Name", typeof (string)),
+ new QueryField("Age", typeof (int))
+ },
+ Indexes = new[]
+ {
+ new QueryIndex(false, QueryIndexType.FullText, "Name"), new QueryIndex("Age")
+ }
+ })
+ }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ var cache = ignite.GetCache<int, QueryPerson>(CacheName);
+
+ Assert.IsNotNull(cache);
+
+ cache[1] = new QueryPerson("Arnold", 10);
+ cache[2] = new QueryPerson("John", 20);
+
+ using (var cursor = cache.Query(new SqlQuery(typeof (QueryPerson), "age > 10")))
+ {
+ Assert.AreEqual(2, cursor.GetAll().Single().Key);
+ }
+
+ using (var cursor = cache.Query(new TextQuery(typeof (QueryPerson), "Ar*")))
+ {
+ Assert.AreEqual(1, cursor.GetAll().Single().Key);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Tests the attribute configuration.
+ /// </summary>
+ [Test]
+ public void TestAttributeConfiguration()
+ {
+ // ReSharper disable once ObjectCreationAsStatement
+ Assert.Throws<InvalidOperationException>(() => new QueryEntity(typeof (RecursiveQuery)));
+
+ var qe = new QueryEntity {ValueType = typeof(AttributeTest) };
+
+ Assert.AreEqual(typeof(AttributeTest), qe.ValueType);
+
+ var fields = qe.Fields.ToArray();
+
+ CollectionAssert.AreEquivalent(new[]
+ {
+ "SqlField", "IndexedField1", "FullTextField", "Inner", "Inner.Foo",
+ "GroupIndex1", "GroupIndex2", "GroupIndex3"
+ }, fields.Select(x => x.Name));
+
+ var idx = qe.Indexes.ToArray();
+
+ Assert.AreEqual(QueryIndexType.Sorted, idx[0].IndexType);
+ Assert.AreEqual(QueryIndexType.Sorted, idx[1].IndexType);
+ Assert.AreEqual(QueryIndexType.Sorted, idx[2].IndexType);
+ Assert.AreEqual(QueryIndexType.FullText, idx[3].IndexType);
+
+ CollectionAssert.AreEquivalent(new[] {"GroupIndex1", "GroupIndex2"}, idx[0].Fields.Select(f => f.Name));
+ CollectionAssert.AreEquivalent(new[] {"GroupIndex1", "GroupIndex3"}, idx[1].Fields.Select(f => f.Name));
+ CollectionAssert.AreEquivalent(new[] {"IndexedField1"}, idx[2].Fields.Select(f => f.Name));
+ CollectionAssert.AreEquivalent(new[] {"FullTextField"}, idx[3].Fields.Select(f => f.Name));
+ }
+
+ /// <summary>
+ /// Tests the attribute configuration query.
+ /// </summary>
+ [Test]
+ public void TestAttributeConfigurationQuery()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ JvmOptions = TestUtils.TestJavaOptions(),
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ BinaryConfiguration = new BinaryConfiguration(
+ typeof (AttributeQueryPerson), typeof (AttributeQueryAddress)),
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ var cache = ignite.GetOrCreateCache<int, AttributeQueryPerson>(new CacheConfiguration(CacheName,
+ typeof (AttributeQueryPerson)));
+
+ Assert.IsNotNull(cache);
+
+ cache[1] = new AttributeQueryPerson("Arnold", 10)
+ {
+ Address = new AttributeQueryAddress {Country = "USA", Street = "Pine Tree road"}
+ };
+
+ cache[2] = new AttributeQueryPerson("John", 20);
+
+ using (var cursor = cache.Query(new SqlQuery(typeof(AttributeQueryPerson), "age > ?", 10)))
+ {
+ Assert.AreEqual(2, cursor.GetAll().Single().Key);
+ }
+
+ using (var cursor = cache.Query(new SqlQuery(typeof(AttributeQueryPerson), "Country = ?", "USA")))
+ {
+ Assert.AreEqual(1, cursor.GetAll().Single().Key);
+ }
+
+ using (var cursor = cache.Query(new TextQuery(typeof(AttributeQueryPerson), "Ar*")))
+ {
+ Assert.AreEqual(1, cursor.GetAll().Single().Key);
+ }
+
+ using (var cursor = cache.Query(new TextQuery(typeof(AttributeQueryPerson), "Pin*")))
+ {
+ Assert.AreEqual(1, cursor.GetAll().Single().Key);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Test person.
+ /// </summary>
+ private class AttributeQueryPerson
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AttributeQueryPerson"/> class.
+ /// </summary>
+ /// <param name="name">The name.</param>
+ /// <param name="age">The age.</param>
+ public AttributeQueryPerson(string name, int age)
+ {
+ Name = name;
+ Age = age;
+ }
+
+ /// <summary>
+ /// Gets or sets the name.
+ /// </summary>
+ /// <value>
+ /// The name.
+ /// </value>
+ [QueryTextField]
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the age.
+ /// </summary>
+ /// <value>
+ /// The age.
+ /// </value>
+ [QuerySqlField]
+ public int Age { get; set; }
+
+ /// <summary>
+ /// Gets or sets the address.
+ /// </summary>
+ /// <value>
+ /// The address.
+ /// </value>
+ [QuerySqlField]
+ public AttributeQueryAddress Address { get; set; }
+ }
+
+ /// <summary>
+ /// Address.
+ /// </summary>
+ private class AttributeQueryAddress
+ {
+ /// <summary>
+ /// Gets or sets the country.
+ /// </summary>
+ /// <value>
+ /// The country.
+ /// </value>
+ [QuerySqlField]
+ public string Country { get; set; }
+
+ /// <summary>
+ /// Gets or sets the street.
+ /// </summary>
+ /// <value>
+ /// The street.
+ /// </value>
+ [QueryTextField]
+ public string Street { get; set; }
+ }
+
+ /// <summary>
+ /// Query.
+ /// </summary>
+ private class RecursiveQuery
+ {
+ /// <summary>
+ /// Gets or sets the inner.
+ /// </summary>
+ /// <value>
+ /// The inner.
+ /// </value>
+ [QuerySqlField]
+ public RecursiveQuery Inner { get; set; }
+ }
+
+ /// <summary>
+ /// Attribute test class.
+ /// </summary>
+ private class AttributeTest
+ {
+ [QuerySqlField]
+ public double SqlField { get; set; }
+
+ [QuerySqlField(IsIndexed = true, Name = "IndexedField1")]
+ public int IndexedField { get; set; }
+
+ [QueryTextField]
+ public string FullTextField { get; set; }
+
+ [QuerySqlField]
+ public AttributeTestInner Inner { get; set; }
+
+ [QuerySqlField(IsIndexed = true, IndexGroups = new[] {"group1", "group2"})]
+ public string GroupIndex1 { get; set; }
+
+ [QuerySqlField(IsIndexed = true, IndexGroups = new[] {"group1"})]
+ public string GroupIndex2 { get; set; }
+
+ [QuerySqlField(IsIndexed = true, IndexGroups = new[] {"group2"})]
+ public string GroupIndex3 { get; set; }
+ }
+
+ /// <summary>
+ /// Inner class.
+ /// </summary>
+ private class AttributeTestInner
+ {
+ /// <summary>
+ /// Gets or sets the foo.
+ /// </summary>
+ /// <value>
+ /// The foo.
+ /// </value>
+ [QuerySqlField]
+ public string Foo { get; set; }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
index 08a98f6..8020649 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
@@ -57,7 +57,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
TestUtils.JvmDebug = true;
TestUtils.KillProcesses();
- IgniteConfigurationEx cfg = new IgniteConfigurationEx
+ IgniteConfiguration cfg = new IgniteConfiguration
{
BinaryConfiguration = new BinaryConfiguration
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
index bdca918..0036abd 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
@@ -95,7 +95,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
GC.Collect();
TestUtils.JvmDebug = true;
- IgniteConfigurationEx cfg = new IgniteConfigurationEx();
+ IgniteConfiguration cfg = new IgniteConfiguration();
BinaryConfiguration portCfg = new BinaryConfiguration();
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs
index 137215e..5cc0849 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs
@@ -55,7 +55,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
TestUtils.JvmDebug = true;
- IgniteConfigurationEx cfg = new IgniteConfigurationEx
+ IgniteConfiguration cfg = new IgniteConfiguration
{
GridName = IgniteName,
JvmClasspath = TestUtils.CreateTestClasspath(),
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
index 1270138..b48cdc9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
@@ -23,7 +23,6 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Cache;
using Apache.Ignite.Core.Cache.Store;
- using Apache.Ignite.Core.Impl;
using NUnit.Framework;
/// <summary>
@@ -137,24 +136,18 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[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";
-
- BinaryConfiguration portCfg = new BinaryConfiguration();
-
- portCfg.Types = new List<string> { typeof(Key).FullName, typeof(Value).FullName };
-
- cfg.BinaryConfiguration = portCfg;
+ var cfg = new IgniteConfiguration
+ {
+ GridName = GridName,
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = TestUtils.TestJavaOptions(),
+ SpringConfigUrl = "config\\native-client-test-cache-store.xml",
+ BinaryConfiguration = new BinaryConfiguration(typeof (Key), typeof (Value))
+ };
Ignition.Start(cfg);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
index 20ae629..f5a04c1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
@@ -461,9 +461,9 @@ namespace Apache.Ignite.Core.Tests.Dataload
/// Gets the Ignite configuration.
/// </summary>
/// <param name="gridName">Grid name.</param>
- private static IgniteConfigurationEx GetIgniteConfiguration(string gridName)
+ private static IgniteConfiguration GetIgniteConfiguration(string gridName)
{
- return new IgniteConfigurationEx
+ return new IgniteConfiguration
{
GridName = gridName,
SpringConfigUrl = "config\\native-client-test-cache.xml",
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
index 79297da..50ecfac 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
@@ -285,7 +285,7 @@ namespace Apache.Ignite.Core.Tests
/// </summary>
private static IIgnite StartGrid(string gridName = null)
{
- return Ignition.Start(new IgniteConfigurationEx
+ return Ignition.Start(new IgniteConfiguration
{
SpringConfigUrl = "config\\native-client-test-cache.xml",
JvmOptions = TestUtils.TestJavaOptions(),
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
new file mode 100644
index 0000000..15f5804
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
@@ -0,0 +1,367 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma warning disable 618 // deprecated SpringConfigUrl
+namespace Apache.Ignite.Core.Tests
+{
+ using System;
+ using System.ComponentModel;
+ using System.IO;
+ using System.Linq;
+ using Apache.Ignite.Core.Cache.Configuration;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Discovery;
+ using Apache.Ignite.Core.Discovery.Tcp;
+ using Apache.Ignite.Core.Discovery.Tcp.Multicast;
+ using Apache.Ignite.Core.Discovery.Tcp.Static;
+ using Apache.Ignite.Core.Events;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests code-based configuration.
+ /// </summary>
+ public class IgniteConfigurationTest
+ {
+ /// <summary>
+ /// Fixture setup.
+ /// </summary>
+ [TestFixtureSetUp]
+ public void FixtureSetUp()
+ {
+ Ignition.StopAll(true);
+ }
+
+ /// <summary>
+ /// Tests the default configuration properties.
+ /// </summary>
+ [Test]
+ public void TestDefaultConfigurationProperties()
+ {
+ CheckDefaultProperties(new IgniteConfiguration());
+ }
+
+ /// <summary>
+ /// Tests the default value attributes.
+ /// </summary>
+ [Test]
+ public void TestDefaultValueAttributes()
+ {
+ CheckDefaultValueAttributes(new IgniteConfiguration());
+ CheckDefaultValueAttributes(new TcpDiscoverySpi());
+ CheckDefaultValueAttributes(new CacheConfiguration());
+ CheckDefaultValueAttributes(new TcpDiscoveryMulticastIpFinder());
+ }
+
+ /// <summary>
+ /// Tests all configuration properties.
+ /// </summary>
+ [Test]
+ public void TestAllConfigurationProperties()
+ {
+ var cfg = new IgniteConfiguration(GetCustomConfig());
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ var resCfg = ignite.GetConfiguration();
+
+ var disco = (TcpDiscoverySpi) cfg.DiscoverySpi;
+ var resDisco = (TcpDiscoverySpi) resCfg.DiscoverySpi;
+
+ Assert.AreEqual(disco.NetworkTimeout, resDisco.NetworkTimeout);
+ Assert.AreEqual(disco.AckTimeout, resDisco.AckTimeout);
+ Assert.AreEqual(disco.MaxAckTimeout, resDisco.MaxAckTimeout);
+ Assert.AreEqual(disco.SocketTimeout, resDisco.SocketTimeout);
+ Assert.AreEqual(disco.JoinTimeout, resDisco.JoinTimeout);
+
+ var ip = (TcpDiscoveryStaticIpFinder) disco.IpFinder;
+ var resIp = (TcpDiscoveryStaticIpFinder) resDisco.IpFinder;
+
+ // There can be extra IPv6 endpoints
+ Assert.AreEqual(ip.Endpoints, resIp.Endpoints.Take(2).Select(x => x.Trim('/')).ToArray());
+
+ Assert.AreEqual(cfg.GridName, resCfg.GridName);
+ Assert.AreEqual(cfg.IncludedEventTypes, resCfg.IncludedEventTypes);
+ Assert.AreEqual(cfg.MetricsExpireTime, resCfg.MetricsExpireTime);
+ Assert.AreEqual(cfg.MetricsHistorySize, resCfg.MetricsHistorySize);
+ Assert.AreEqual(cfg.MetricsLogFrequency, resCfg.MetricsLogFrequency);
+ Assert.AreEqual(cfg.MetricsUpdateFrequency, resCfg.MetricsUpdateFrequency);
+ Assert.AreEqual(cfg.NetworkSendRetryCount, resCfg.NetworkSendRetryCount);
+ Assert.AreEqual(cfg.NetworkTimeout, resCfg.NetworkTimeout);
+ Assert.AreEqual(cfg.NetworkSendRetryDelay, resCfg.NetworkSendRetryDelay);
+ Assert.AreEqual(cfg.WorkDirectory, resCfg.WorkDirectory);
+ Assert.AreEqual(cfg.JvmClasspath, resCfg.JvmClasspath);
+ Assert.AreEqual(cfg.JvmOptions, resCfg.JvmOptions);
+ Assert.IsTrue(File.Exists(resCfg.JvmDllPath));
+ Assert.AreEqual(cfg.Localhost, resCfg.Localhost);
+ }
+ }
+
+ /// <summary>
+ /// Tests the spring XML.
+ /// </summary>
+ [Test]
+ public void TestSpringXml()
+ {
+ // When Spring XML is used, all properties are ignored.
+ var cfg = GetCustomConfig();
+
+ cfg.SpringConfigUrl = "config\\marshaller-default.xml";
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ var resCfg = ignite.GetConfiguration();
+
+ CheckDefaultProperties(resCfg);
+ }
+ }
+
+ /// <summary>
+ /// Tests the client mode.
+ /// </summary>
+ [Test]
+ public void TestClientMode()
+ {
+ using (var ignite = Ignition.Start(new IgniteConfiguration
+ {
+ Localhost = "127.0.0.1",
+ DiscoverySpi = GetStaticDiscovery()
+ }))
+ using (var ignite2 = Ignition.Start(new IgniteConfiguration
+ {
+ Localhost = "127.0.0.1",
+ DiscoverySpi = GetStaticDiscovery(),
+ GridName = "client",
+ ClientMode = true
+ }))
+ {
+ const string cacheName = "cache";
+
+ ignite.CreateCache<int, int>(cacheName);
+
+ Assert.AreEqual(2, ignite2.GetCluster().GetNodes().Count);
+ Assert.AreEqual(1, ignite.GetCluster().ForCacheNodes(cacheName).GetNodes().Count);
+
+ Assert.AreEqual(false, ignite.GetConfiguration().ClientMode);
+ Assert.AreEqual(true, ignite2.GetConfiguration().ClientMode);
+ }
+ }
+
+ /// <summary>
+ /// Tests the default spi.
+ /// </summary>
+ [Test]
+ public void TestDefaultSpi()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ DiscoverySpi =
+ new TcpDiscoverySpi
+ {
+ AckTimeout = TimeSpan.FromDays(2),
+ MaxAckTimeout = TimeSpan.MaxValue,
+ JoinTimeout = TimeSpan.MaxValue,
+ NetworkTimeout = TimeSpan.MaxValue,
+ SocketTimeout = TimeSpan.MaxValue
+ },
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = TestUtils.TestJavaOptions(),
+ Localhost = "127.0.0.1"
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ cfg.GridName = "ignite2";
+ using (var ignite2 = Ignition.Start(cfg))
+ {
+ Assert.AreEqual(2, ignite.GetCluster().GetNodes().Count);
+ Assert.AreEqual(2, ignite2.GetCluster().GetNodes().Count);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Tests the invalid timeouts.
+ /// </summary>
+ [Test]
+ public void TestInvalidTimeouts()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ DiscoverySpi =
+ new TcpDiscoverySpi
+ {
+ AckTimeout = TimeSpan.FromMilliseconds(-5),
+ JoinTimeout = TimeSpan.MinValue,
+ },
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = TestUtils.TestJavaOptions(),
+ };
+
+ Assert.Throws<IgniteException>(() => Ignition.Start(cfg));
+ }
+
+ /// <summary>
+ /// Tests the static ip finder.
+ /// </summary>
+ [Test]
+ public void TestStaticIpFinder()
+ {
+ TestIpFinders(new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[] {"127.0.0.1:47500"}
+ }, new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[] {"127.0.0.1:47501"}
+ });
+ }
+
+ /// <summary>
+ /// Tests the multicast ip finder.
+ /// </summary>
+ [Test]
+ public void TestMulticastIpFinder()
+ {
+ TestIpFinders(
+ new TcpDiscoveryMulticastIpFinder {MulticastGroup = "228.111.111.222", MulticastPort = 54522},
+ new TcpDiscoveryMulticastIpFinder {MulticastGroup = "228.111.111.223", MulticastPort = 54522});
+ }
+
+ /// <summary>
+ /// Tests the ip finders.
+ /// </summary>
+ /// <param name="ipFinder">The ip finder.</param>
+ /// <param name="ipFinder2">The ip finder2.</param>
+ private static void TestIpFinders(TcpDiscoveryIpFinderBase ipFinder, TcpDiscoveryIpFinderBase ipFinder2)
+ {
+ var cfg = new IgniteConfiguration
+ {
+ DiscoverySpi =
+ new TcpDiscoverySpi
+ {
+ IpFinder = ipFinder
+ },
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = TestUtils.TestJavaOptions(),
+ Localhost = "127.0.0.1"
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ // Start with the same endpoint
+ cfg.GridName = "ignite2";
+ using (var ignite2 = Ignition.Start(cfg))
+ {
+ Assert.AreEqual(2, ignite.GetCluster().GetNodes().Count);
+ Assert.AreEqual(2, ignite2.GetCluster().GetNodes().Count);
+ }
+
+ // Start with incompatible endpoint and check that there are 2 topologies
+ ((TcpDiscoverySpi) cfg.DiscoverySpi).IpFinder = ipFinder2;
+
+ using (var ignite2 = Ignition.Start(cfg))
+ {
+ Assert.AreEqual(1, ignite.GetCluster().GetNodes().Count);
+ Assert.AreEqual(1, ignite2.GetCluster().GetNodes().Count);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Checks the default properties.
+ /// </summary>
+ /// <param name="cfg">The CFG.</param>
+ private static void CheckDefaultProperties(IgniteConfiguration cfg)
+ {
+ Assert.AreEqual(IgniteConfiguration.DefaultMetricsExpireTime, cfg.MetricsExpireTime);
+ Assert.AreEqual(IgniteConfiguration.DefaultMetricsHistorySize, cfg.MetricsHistorySize);
+ Assert.AreEqual(IgniteConfiguration.DefaultMetricsLogFrequency, cfg.MetricsLogFrequency);
+ Assert.AreEqual(IgniteConfiguration.DefaultMetricsUpdateFrequency, cfg.MetricsUpdateFrequency);
+ Assert.AreEqual(IgniteConfiguration.DefaultNetworkTimeout, cfg.NetworkTimeout);
+ Assert.AreEqual(IgniteConfiguration.DefaultNetworkSendRetryCount, cfg.NetworkSendRetryCount);
+ Assert.AreEqual(IgniteConfiguration.DefaultNetworkSendRetryDelay, cfg.NetworkSendRetryDelay);
+ }
+
+ /// <summary>
+ /// Checks the default value attributes.
+ /// </summary>
+ /// <param name="obj">The object.</param>
+ private static void CheckDefaultValueAttributes(object obj)
+ {
+ var props = obj.GetType().GetProperties();
+
+ foreach (var prop in props)
+ {
+ var attr = prop.GetCustomAttributes(true).OfType<DefaultValueAttribute>().FirstOrDefault();
+ var propValue = prop.GetValue(obj, null);
+
+ if (attr != null)
+ Assert.AreEqual(attr.Value, propValue);
+ else if (prop.PropertyType.IsValueType)
+ Assert.AreEqual(Activator.CreateInstance(prop.PropertyType), propValue);
+ else
+ Assert.IsNull(propValue);
+ }
+ }
+
+ /// <summary>
+ /// Gets the custom configuration.
+ /// </summary>
+ private static IgniteConfiguration GetCustomConfig()
+ {
+ return new IgniteConfiguration
+ {
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ NetworkTimeout = TimeSpan.FromSeconds(1),
+ AckTimeout = TimeSpan.FromSeconds(2),
+ MaxAckTimeout = TimeSpan.FromSeconds(3),
+ SocketTimeout = TimeSpan.FromSeconds(4),
+ JoinTimeout = TimeSpan.FromSeconds(5),
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[] { "127.0.0.1:47500", "127.0.0.1:47501" }
+ }
+ },
+ GridName = "gridName1",
+ IncludedEventTypes = EventType.SwapspaceAll,
+ MetricsExpireTime = TimeSpan.FromMinutes(7),
+ MetricsHistorySize = 125,
+ MetricsLogFrequency = TimeSpan.FromMinutes(8),
+ MetricsUpdateFrequency = TimeSpan.FromMinutes(9),
+ NetworkSendRetryCount = 54,
+ NetworkTimeout = TimeSpan.FromMinutes(10),
+ NetworkSendRetryDelay = TimeSpan.FromMinutes(11),
+ WorkDirectory = Path.GetTempPath(),
+ JvmOptions = TestUtils.TestJavaOptions(),
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ Localhost = "127.0.0.1"
+ };
+ }
+
+ /// <summary>
+ /// Gets the static discovery.
+ /// </summary>
+ /// <returns></returns>
+ private static IDiscoverySpi GetStaticDiscovery()
+ {
+ return new TcpDiscoverySpi
+ {
+ IpFinder = new TcpDiscoveryStaticIpFinder {Endpoints = new[] {"127.0.0.1:47500", "127.0.0.1:47501"}}
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
index 541de0c..7def56f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
@@ -34,7 +34,7 @@ namespace Apache.Ignite.Core.Tests
{
using (var grid = Ignition.Start("config\\marshaller-default.xml"))
{
- var cache = grid.GetOrCreateCache<int, int>(null);
+ var cache = grid.GetOrCreateCache<int, int>((string) null);
cache.Put(1, 1);
@@ -51,7 +51,7 @@ namespace Apache.Ignite.Core.Tests
{
using (var grid = Ignition.Start("config\\marshaller-explicit.xml"))
{
- var cache = grid.GetOrCreateCache<int, int>(null);
+ var cache = grid.GetOrCreateCache<int, int>((string) null);
cache.Put(1, 1);
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs
index 07caaf3..a36e30f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs
@@ -43,7 +43,7 @@ namespace Apache.Ignite.Core.Tests
[TestFixtureSetUp]
public void SetUp()
{
- var cfg = new IgniteConfigurationEx
+ var cfg = new IgniteConfiguration
{
GridName = GridName,
JvmClasspath = TestUtils.CreateTestClasspath(),
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
index 2b0ab8e..a1083b6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
@@ -20,6 +20,7 @@ namespace Apache.Ignite.Core.Tests
using System;
using System.Diagnostics;
using System.Reflection;
+ using Apache.Ignite.Core.Tests.Cache.Query;
using Apache.Ignite.Core.Tests.Memory;
using NUnit.ConsoleRunner;
@@ -31,9 +32,9 @@ namespace Apache.Ignite.Core.Tests
Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
Debug.AutoFlush = true;
- //TestOne(typeof(ContinuousQueryAtomiclBackupTest), "TestInitialQuery");
+ TestOne(typeof(IgniteConfigurationTest), "TestStaticIpFinder");
- TestAll(typeof (ExecutableTest));
+ //TestAll(typeof (CacheQueriesCodeConfigurationTest));
//TestAllInAssembly();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index 7de8330..1c83168 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -17,6 +17,7 @@
<OutputPath>bin\x64\Debug\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>DEBUG;CODE_ANALYSIS</DefineConstants>
+ <CodeAnalysisRuleSet>Apache.Ignite.Core.ruleset</CodeAnalysisRuleSet>
<DocumentationFile>bin\x64\Debug\Apache.Ignite.Core.XML</DocumentationFile>
<RunCodeAnalysis>true</RunCodeAnalysis>
<CodeAnalysisRuleSet>Apache.Ignite.Core.ruleset</CodeAnalysisRuleSet>
@@ -25,6 +26,7 @@
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Release\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <CodeAnalysisRuleSet>Apache.Ignite.Core.ruleset</CodeAnalysisRuleSet>
<Optimize>true</Optimize>
<DocumentationFile>bin\x64\Release\Apache.Ignite.Core.XML</DocumentationFile>
<CodeAnalysisRuleSet>Apache.Ignite.Core.ruleset</CodeAnalysisRuleSet>
@@ -34,6 +36,7 @@
<OutputPath>bin\x86\Debug\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>DEBUG;CODE_ANALYSIS</DefineConstants>
+ <CodeAnalysisRuleSet>Apache.Ignite.Core.ruleset</CodeAnalysisRuleSet>
<DocumentationFile>bin\x86\Debug\Apache.Ignite.Core.XML</DocumentationFile>
<CodeAnalysisRuleSet>Apache.Ignite.Core.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
@@ -41,6 +44,7 @@
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <CodeAnalysisRuleSet>Apache.Ignite.Core.ruleset</CodeAnalysisRuleSet>
<Optimize>true</Optimize>
<DocumentationFile>bin\x86\Release\Apache.Ignite.Core.XML</DocumentationFile>
<CodeAnalysisRuleSet>Apache.Ignite.Core.ruleset</CodeAnalysisRuleSet>
@@ -65,6 +69,8 @@
<Compile Include="Cache\CacheException.cs" />
<Compile Include="Cache\CachePartialUpdateException.cs" />
<Compile Include="Cache\CachePeekMode.cs" />
+ <Compile Include="Cache\Configuration\QueryAlias.cs" />
+ <Compile Include="Cache\Configuration\QueryTextFieldAttribute.cs" />
<Compile Include="Cache\Event\CacheEntryEventType.cs" />
<Compile Include="Cache\Event\ICacheEntryEvent.cs" />
<Compile Include="Cache\Event\ICacheEntryEventFilter.cs" />
@@ -98,6 +104,7 @@
<Compile Include="Cache\Store\CacheStoreAdapter.cs" />
<Compile Include="Cache\Store\CacheStoreException.cs" />
<Compile Include="Cache\Store\ICacheStore.cs" />
+ <Compile Include="Common\IFactory.cs" />
<Compile Include="Cache\Store\ICacheStoreSession.cs" />
<Compile Include="Cache\Store\Package-Info.cs" />
<Compile Include="Cluster\ClusterGroupEmptyException.cs" />
@@ -128,6 +135,25 @@
<Compile Include="Compute\IComputeJobResult.cs" />
<Compile Include="Compute\IComputeReducer.cs" />
<Compile Include="Compute\IComputeTask.cs" />
+ <Compile Include="Cache\Configuration\CacheAtomicityMode.cs" />
+ <Compile Include="Cache\Configuration\CacheAtomicWriteOrderMode.cs" />
+ <Compile Include="Cache\Configuration\CacheConfiguration.cs" />
+ <Compile Include="Cache\Configuration\CacheMemoryMode.cs" />
+ <Compile Include="Cache\Configuration\CacheMode.cs" />
+ <Compile Include="Cache\Configuration\CacheRebalanceMode.cs" />
+ <Compile Include="Cache\Configuration\CacheWriteSynchronizationMode.cs" />
+ <Compile Include="Discovery\Tcp\ITcpDiscoveryIpFinder.cs" />
+ <Compile Include="Discovery\Tcp\TcpDiscoverySpi.cs" />
+ <Compile Include="Cache\Configuration\QueryIndexField.cs" />
+ <Compile Include="Discovery\IDiscoverySpi.cs" />
+ <Compile Include="Discovery\Tcp\TcpDiscoveryIpFinderBase.cs" />
+ <Compile Include="Discovery\Tcp\Multicast\TcpDiscoveryMulticastIpFinder.cs" />
+ <Compile Include="Cache\Configuration\QueryEntity.cs" />
+ <Compile Include="Cache\Configuration\QueryField.cs" />
+ <Compile Include="Cache\Configuration\QueryIndex.cs" />
+ <Compile Include="Cache\Configuration\QueryIndexType.cs" />
+ <Compile Include="Cache\Configuration\QuerySqlFieldAttribute.cs" />
+ <Compile Include="Discovery\Tcp\Static\TcpDiscoveryStaticIpFinder.cs" />
<Compile Include="Compute\Package-Info.cs" />
<Compile Include="Datastream\IDataStreamer.cs" />
<Compile Include="Datastream\IStreamReceiver.cs" />
@@ -158,6 +184,7 @@
<Compile Include="Ignition.cs" />
<Compile Include="IIgnite.cs" />
<Compile Include="Impl\Binary\BinaryEnum.cs" />
+ <Compile Include="Impl\Binary\JavaTypes.cs" />
<Compile Include="Impl\Cache\CacheAffinityImpl.cs" />
<Compile Include="Impl\Cache\CacheEntry.cs" />
<Compile Include="Impl\Cache\CacheEntryFilterHolder.cs" />
@@ -235,7 +262,6 @@
<Compile Include="Impl\Events\Events.cs" />
<Compile Include="Impl\Events\RemoteListenEventFilter.cs" />
<Compile Include="Impl\ExceptionUtils.cs" />
- <Compile Include="Impl\IgniteConfigurationEx.cs" />
<Compile Include="Impl\Ignite.cs" />
<Compile Include="Impl\IgniteManager.cs" />
<Compile Include="Impl\IgniteProxy.cs" />
@@ -405,6 +431,7 @@
<None Include="Apache.Ignite.Core.ruleset" />
<None Include="Apache.Ignite.Core.snk" />
</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.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryConfiguration.cs
index 4d82a65..fa2fb1c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryConfiguration.cs
@@ -17,8 +17,10 @@
namespace Apache.Ignite.Core.Binary
{
+ using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
+ using System.Linq;
using Apache.Ignite.Core.Impl.Common;
/// <summary>
@@ -27,7 +29,7 @@ namespace Apache.Ignite.Core.Binary
public class BinaryConfiguration
{
/// <summary>
- /// Constructor.
+ /// Initializes a new instance of the <see cref="BinaryConfiguration"/> class.
/// </summary>
public BinaryConfiguration()
{
@@ -35,9 +37,9 @@ namespace Apache.Ignite.Core.Binary
}
/// <summary>
- /// Copying constructor.
+ /// Initializes a new instance of the <see cref="BinaryConfiguration" /> class.
/// </summary>
- /// <param name="cfg">Configuration to copy.</param>
+ /// <param name="cfg">The binary configuration to copy.</param>
public BinaryConfiguration(BinaryConfiguration cfg)
{
IgniteArgumentCheck.NotNull(cfg, "cfg");
@@ -47,15 +49,20 @@ namespace Apache.Ignite.Core.Binary
DefaultKeepDeserialized = cfg.DefaultKeepDeserialized;
DefaultSerializer = cfg.DefaultSerializer;
- Types = cfg.Types != null ? new List<string>(cfg.Types) : null;
+ TypeConfigurations = cfg.TypeConfigurations == null
+ ? null
+ : cfg.TypeConfigurations.Select(x => new BinaryTypeConfiguration(x)).ToList();
- if (cfg.TypeConfigurations != null)
- {
- TypeConfigurations = new List<BinaryTypeConfiguration>(cfg.TypeConfigurations.Count);
+ Types = cfg.Types == null ? null : cfg.Types.ToList();
+ }
- foreach (BinaryTypeConfiguration typeCfg in cfg.TypeConfigurations)
- TypeConfigurations.Add(new BinaryTypeConfiguration(typeCfg));
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="BinaryConfiguration"/> class.
+ /// </summary>
+ /// <param name="binaryTypes">Binary types to register.</param>
+ public BinaryConfiguration(params Type[] binaryTypes)
+ {
+ TypeConfigurations = binaryTypes.Select(t => new BinaryTypeConfiguration(t)).ToList();
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicWriteOrderMode.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicWriteOrderMode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicWriteOrderMode.cs
new file mode 100644
index 0000000..c9a41e8
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicWriteOrderMode.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.
+ */
+
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+ /// <summary>
+ /// Cache write ordering mode. This enumeration is taken into account only in
+ /// <see cref="CacheAtomicityMode.Atomic"/> atomicity mode.
+ /// Write ordering mode determines which node assigns the write version, sender or the primary node.
+ /// </summary>
+ public enum CacheAtomicWriteOrderMode
+ {
+ /// <summary>
+ /// In this mode, write versions are assigned on a sender node which generally leads to better
+ /// performance in <see cref="CacheWriteSynchronizationMode.FullSync"/> synchronization mode,
+ /// since in this case sender can send write requests to primary and backups at the same time.
+ /// <para/>
+ /// This mode will be automatically configured only with <see cref="CacheWriteSynchronizationMode.FullSync"/>
+ /// write synchronization mode, as for other synchronization modes it does not render better performance.
+ /// </summary>
+ Clock,
+
+ /// <summary>
+ /// Cache version is assigned only on primary node. This means that sender will only send write request
+ /// to primary node, which in turn will assign write version and forward it to backups.
+ /// </summary>
+ Primary
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicityMode.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicityMode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicityMode.cs
new file mode 100644
index 0000000..8c36a77
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicityMode.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.
+ */
+
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+ using Apache.Ignite.Core.Cache;
+
+ /// <summary>
+ /// Cache atomicity mode.
+ /// </summary>
+ public enum CacheAtomicityMode
+ {
+ /// <summary>
+ /// Specifies fully ACID-compliant transactional cache behavior.
+ /// </summary>
+ Transactional,
+
+ /// <summary>
+ /// Specifies atomic-only cache behaviour. In this mode distributed transactions and distributed
+ /// locking are not supported. Disabling transactions and locking allows to achieve much higher
+ /// performance and throughput ratios.
+ /// <para/>
+ /// In addition to transactions and locking, one of the main differences to <see cref="Atomic"/> mode
+ /// is that bulk writes, such as <see cref="ICache{TK,TV}.PutAll"/>
+ /// and <see cref="ICache{TK,TV}.RemoveAll(System.Collections.Generic.IEnumerable{TK})"/> methods,
+ /// become simple batch operations which can partially fail. In case of partial
+ /// failure, <see cref="CachePartialUpdateException"/>will be thrown which will contain a list of keys
+ /// for which the update failed. It is recommended that bulk writes are used
+ /// whenever multiple keys need to be inserted or updated in cache, as they reduce number of network trips and
+ /// provide better performance.
+ /// <para/>
+ /// Note that even without locking and transactions, <see cref="Atomic"/> mode still provides
+ /// full consistency guarantees across all cache nodes.
+ /// <para/>
+ /// Also note that all data modifications in <see cref="Atomic"/> mode are guaranteed to be atomic
+ /// and consistent with writes to the underlying persistent store, if one is configured.
+ /// </summary>
+ Atomic
+ }
+}
\ No newline at end of file
[2/4] ignite git commit: IGNITE-1906: .NET: Implemented programmatic
configuration.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
new file mode 100644
index 0000000..b319be9
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
@@ -0,0 +1,601 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 MemberCanBePrivate.Global
+// ReSharper disable UnusedMember.Global
+// ReSharper disable UnusedAutoPropertyAccessor.Global
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+ using System;
+ using System.Collections.Generic;
+ using System.ComponentModel;
+ using System.Diagnostics.CodeAnalysis;
+ using System.Linq;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cache.Store;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Impl.Binary;
+
+ /// <summary>
+ /// Defines grid cache configuration.
+ /// </summary>
+ public class CacheConfiguration
+ {
+ /// <summary> Default size of rebalance thread pool. </summary>
+ public const int DefaultRebalanceThreadPoolSize = 2;
+
+ /// <summary> Default rebalance timeout.</summary>
+ public static readonly TimeSpan DefaultRebalanceTimeout = TimeSpan.FromMilliseconds(10000);
+
+ /// <summary> Time to wait between rebalance messages to avoid overloading CPU. </summary>
+ public static readonly TimeSpan DefaultRebalanceThrottle = TimeSpan.Zero;
+
+ /// <summary> Default number of backups. </summary>
+ public const int DefaultBackups = 0;
+
+ /// <summary> Default caching mode. </summary>
+ public const CacheMode DefaultCacheMode = CacheMode.Partitioned;
+
+ /// <summary> Default atomicity mode. </summary>
+ public const CacheAtomicityMode DefaultAtomicityMode = CacheAtomicityMode.Atomic;
+
+ /// <summary> Default lock timeout. </summary>
+ public static readonly TimeSpan DefaultLockTimeout = TimeSpan.Zero;
+
+ /// <summary> Initial default cache size. </summary>
+ public const int DefaultStartSize = 1500000;
+
+ /// <summary> Default cache size to use with eviction policy. </summary>
+ public const int DefaultCacheSize = 100000;
+
+ /// <summary> Default value for 'invalidate' flag that indicates if this is invalidation-based cache. </summary>
+ public const bool DefaultInvalidate = false;
+
+ /// <summary> Default rebalance mode for distributed cache. </summary>
+ public const CacheRebalanceMode DefaultRebalanceMode = CacheRebalanceMode.Async;
+
+ /// <summary> Default rebalance batch size in bytes. </summary>
+ public const int DefaultRebalanceBatchSize = 512*1024; // 512K
+
+ /// <summary> Default maximum eviction queue ratio. </summary>
+ public const float DefaultMaxEvictionOverflowRatio = 10;
+
+ /// <summary> Default eviction synchronized flag. </summary>
+ public const bool DefaultEvictSynchronized = false;
+
+ /// <summary> Default eviction key buffer size for batching synchronized evicts. </summary>
+ public const int DefaultEvictSynchronizedKeyBufferSize = 1024;
+
+ /// <summary> Default synchronous eviction timeout. </summary>
+ public static readonly TimeSpan DefaultEvictSynchronizedTimeout = TimeSpan.FromMilliseconds(10000);
+
+ /// <summary> Default synchronous eviction concurrency level. </summary>
+ public const int DefaultEvictSynchronizedConcurrencyLevel = 4;
+
+ /// <summary> Default value for eager ttl flag. </summary>
+ public const bool DefaultEagerTtl = true;
+
+ /// <summary> Default off-heap storage size is {@code -1} which means that off-heap storage is disabled. </summary>
+ public const long DefaultOffHeapMaxMemory = -1;
+
+ /// <summary> Default value for 'swapEnabled' flag. </summary>
+ public const bool DefaultEnableSwap = false;
+
+ /// <summary> Default value for 'maxConcurrentAsyncOps'. </summary>
+ public const int DefaultMaxConcurrentAsyncOperations = 500;
+
+ /// <summary> Default value for 'writeBehindEnabled' flag. </summary>
+ public const bool DefaultWriteBehindEnabled = false;
+
+ /// <summary> Default flush size for write-behind cache store. </summary>
+ public const int DefaultWriteBehindFlushSize = 10240; // 10K
+
+ /// <summary> Default flush frequency for write-behind cache store. </summary>
+ public static readonly TimeSpan DefaultWriteBehindFlushFrequency = TimeSpan.FromMilliseconds(5000);
+
+ /// <summary> Default count of flush threads for write-behind cache store. </summary>
+ public const int DefaultWriteBehindFlushThreadCount = 1;
+
+ /// <summary> Default batch size for write-behind cache store. </summary>
+ public const int DefaultWriteBehindBatchSize = 512;
+
+ /// <summary> Default value for load previous value flag. </summary>
+ public const bool DefaultLoadPreviousValue = false;
+
+ /// <summary> Default memory mode. </summary>
+ public const CacheMemoryMode DefaultMemoryMode = CacheMemoryMode.OnheapTiered;
+
+ /// <summary> Default value for 'readFromBackup' flag. </summary>
+ public const bool DefaultReadFromBackup = true;
+
+ /// <summary> Default timeout after which long query warning will be printed. </summary>
+ public static readonly TimeSpan DefaultLongQueryWarningTimeout = TimeSpan.FromMilliseconds(3000);
+
+ /// <summary> Default size for onheap SQL row cache size. </summary>
+ public const int DefaultSqlOnheapRowCacheSize = 10*1024;
+
+ /// <summary> Default value for keep portable in store behavior .</summary>
+ public const bool DefaultKeepVinaryInStore = true;
+
+ /// <summary> Default value for 'copyOnRead' flag. </summary>
+ public const bool DefaultCopyOnRead = true;
+
+ /// <summary>
+ /// Gets or sets the cache name.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="CacheConfiguration"/> class.
+ /// </summary>
+ public CacheConfiguration() : this((string) null)
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="CacheConfiguration"/> class.
+ /// </summary>
+ /// <param name="name">Cache name.</param>
+ public CacheConfiguration(string name)
+ {
+ Name = name;
+
+ Backups = DefaultBackups;
+ AtomicityMode = DefaultAtomicityMode;
+ CacheMode = DefaultCacheMode;
+ CopyOnRead = DefaultCopyOnRead;
+ EagerTtl = DefaultEagerTtl;
+ EvictSynchronizedKeyBufferSize = DefaultEvictSynchronizedKeyBufferSize;
+ EvictSynchronized = DefaultEvictSynchronized;
+ EvictSynchronizedConcurrencyLevel = DefaultEvictSynchronizedConcurrencyLevel;
+ EvictSynchronizedTimeout = DefaultEvictSynchronizedTimeout;
+ Invalidate = DefaultInvalidate;
+ KeepBinaryInStore = DefaultKeepVinaryInStore;
+ LoadPreviousValue = DefaultLoadPreviousValue;
+ LockTimeout = DefaultLockTimeout;
+ LongQueryWarningTimeout = DefaultLongQueryWarningTimeout;
+ MaxConcurrentAsyncOperations = DefaultMaxConcurrentAsyncOperations;
+ MaxEvictionOverflowRatio = DefaultMaxEvictionOverflowRatio;
+ MemoryMode = DefaultMemoryMode;
+ OffHeapMaxMemory = DefaultOffHeapMaxMemory;
+ ReadFromBackup = DefaultReadFromBackup;
+ RebalanceBatchSize = DefaultRebalanceBatchSize;
+ RebalanceMode = DefaultRebalanceMode;
+ RebalanceThrottle = DefaultRebalanceThrottle;
+ RebalanceTimeout = DefaultRebalanceTimeout;
+ SqlOnheapRowCacheSize = DefaultSqlOnheapRowCacheSize;
+ StartSize = DefaultStartSize;
+ EnableSwap = DefaultEnableSwap;
+ WriteBehindBatchSize = DefaultWriteBehindBatchSize;
+ WriteBehindEnabled = DefaultWriteBehindEnabled;
+ WriteBehindFlushFrequency = DefaultWriteBehindFlushFrequency;
+ WriteBehindFlushSize = DefaultWriteBehindFlushSize;
+ WriteBehindFlushThreadCount= DefaultWriteBehindFlushThreadCount;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="CacheConfiguration"/> class
+ /// and populates <see cref="QueryEntities"/> according to provided query types.
+ /// </summary>
+ /// <param name="name">Cache name.</param>
+ /// <param name="queryTypes">
+ /// Collection of types to be registered as query entities. These types should use
+ /// <see cref="QuerySqlFieldAttribute"/> to configure query fields and properties.
+ /// </param>
+ public CacheConfiguration(string name, params Type[] queryTypes) : this(name)
+ {
+ QueryEntities = queryTypes.Select(type => new QueryEntity {ValueType = type}).ToArray();
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="CacheConfiguration"/> class.
+ /// </summary>
+ /// <param name="name">Cache name.</param>
+ /// <param name="queryEntities">Query entities.</param>
+ public CacheConfiguration(string name, params QueryEntity[] queryEntities) : this(name)
+ {
+ QueryEntities = queryEntities;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="CacheConfiguration"/> class.
+ /// </summary>
+ /// <param name="reader">The reader.</param>
+ internal CacheConfiguration(IBinaryRawReader reader)
+ {
+ AtomicityMode = (CacheAtomicityMode) reader.ReadInt();
+ AtomicWriteOrderMode = (CacheAtomicWriteOrderMode) reader.ReadInt();
+ Backups = reader.ReadInt();
+ CacheMode = (CacheMode) reader.ReadInt();
+ CopyOnRead = reader.ReadBoolean();
+ EagerTtl = reader.ReadBoolean();
+ EnableSwap = reader.ReadBoolean();
+ EvictSynchronized = reader.ReadBoolean();
+ EvictSynchronizedConcurrencyLevel = reader.ReadInt();
+ EvictSynchronizedKeyBufferSize = reader.ReadInt();
+ EvictSynchronizedTimeout = reader.ReadLongAsTimespan();
+ Invalidate = reader.ReadBoolean();
+ KeepBinaryInStore = reader.ReadBoolean();
+ LoadPreviousValue = reader.ReadBoolean();
+ LockTimeout = reader.ReadLongAsTimespan();
+ LongQueryWarningTimeout = reader.ReadLongAsTimespan();
+ MaxConcurrentAsyncOperations = reader.ReadInt();
+ MaxEvictionOverflowRatio = reader.ReadFloat();
+ MemoryMode = (CacheMemoryMode) reader.ReadInt();
+ Name = reader.ReadString();
+ OffHeapMaxMemory = reader.ReadLong();
+ ReadFromBackup = reader.ReadBoolean();
+ RebalanceBatchSize = reader.ReadInt();
+ RebalanceDelay = reader.ReadLongAsTimespan();
+ RebalanceMode = (CacheRebalanceMode) reader.ReadInt();
+ RebalanceThrottle = reader.ReadLongAsTimespan();
+ RebalanceTimeout = reader.ReadLongAsTimespan();
+ SqlEscapeAll = reader.ReadBoolean();
+ SqlOnheapRowCacheSize = reader.ReadInt();
+ StartSize = reader.ReadInt();
+ WriteBehindBatchSize = reader.ReadInt();
+ WriteBehindEnabled = reader.ReadBoolean();
+ WriteBehindFlushFrequency = reader.ReadLongAsTimespan();
+ WriteBehindFlushSize = reader.ReadInt();
+ WriteBehindFlushThreadCount = reader.ReadInt();
+ WriteSynchronizationMode = (CacheWriteSynchronizationMode) reader.ReadInt();
+ CacheStoreFactory = reader.ReadObject<IFactory<ICacheStore>>();
+
+ var count = reader.ReadInt();
+ QueryEntities = count == 0 ? null : Enumerable.Range(0, count).Select(x => new QueryEntity(reader)).ToList();
+ }
+
+ /// <summary>
+ /// Writes this instane to the specified writer.
+ /// </summary>
+ /// <param name="writer">The writer.</param>
+ internal void Write(IBinaryRawWriter writer)
+ {
+ writer.WriteInt((int) AtomicityMode);
+ writer.WriteInt((int) AtomicWriteOrderMode);
+ writer.WriteInt(Backups);
+ writer.WriteInt((int) CacheMode);
+ writer.WriteBoolean(CopyOnRead);
+ writer.WriteBoolean(EagerTtl);
+ writer.WriteBoolean(EnableSwap);
+ writer.WriteBoolean(EvictSynchronized);
+ writer.WriteInt(EvictSynchronizedConcurrencyLevel);
+ writer.WriteInt(EvictSynchronizedKeyBufferSize);
+ writer.WriteLong((long) EvictSynchronizedTimeout.TotalMilliseconds);
+ writer.WriteBoolean(Invalidate);
+ writer.WriteBoolean(KeepBinaryInStore);
+ writer.WriteBoolean(LoadPreviousValue);
+ writer.WriteLong((long) LockTimeout.TotalMilliseconds);
+ writer.WriteLong((long) LongQueryWarningTimeout.TotalMilliseconds);
+ writer.WriteInt(MaxConcurrentAsyncOperations);
+ writer.WriteFloat(MaxEvictionOverflowRatio);
+ writer.WriteInt((int) MemoryMode);
+ writer.WriteString(Name);
+ writer.WriteLong(OffHeapMaxMemory);
+ writer.WriteBoolean(ReadFromBackup);
+ writer.WriteInt(RebalanceBatchSize);
+ writer.WriteLong((long) RebalanceDelay.TotalMilliseconds);
+ writer.WriteInt((int) RebalanceMode);
+ writer.WriteLong((long) RebalanceThrottle.TotalMilliseconds);
+ writer.WriteLong((long) RebalanceTimeout.TotalMilliseconds);
+ writer.WriteBoolean(SqlEscapeAll);
+ writer.WriteInt(SqlOnheapRowCacheSize);
+ writer.WriteInt(StartSize);
+ writer.WriteInt(WriteBehindBatchSize);
+ writer.WriteBoolean(WriteBehindEnabled);
+ writer.WriteLong((long) WriteBehindFlushFrequency.TotalMilliseconds);
+ writer.WriteInt(WriteBehindFlushSize);
+ writer.WriteInt(WriteBehindFlushThreadCount);
+ writer.WriteInt((int) WriteSynchronizationMode);
+ writer.WriteObject(CacheStoreFactory);
+
+ if (QueryEntities != null)
+ {
+ writer.WriteInt(QueryEntities.Count);
+
+ foreach (var entity in QueryEntities)
+ {
+ if (entity == null)
+ throw new InvalidOperationException("Invalid cache configuration: QueryEntity can't be null.");
+
+ entity.Write(writer);
+ }
+ }
+ else
+ writer.WriteInt(0);
+ }
+
+ /// <summary>
+ /// Gets or sets write synchronization mode. This mode controls whether the main
+ /// caller should wait for update on other nodes to complete or not.
+ /// </summary>
+ public CacheWriteSynchronizationMode WriteSynchronizationMode { get; set; }
+
+ /// <summary>
+ /// Gets or sets flag indicating whether eviction is synchronized between primary, backup and near nodes.
+ /// If this parameter is true and swap is disabled then <see cref="ICache{TK,TV}.LocalEvict"/>
+ /// will involve all nodes where an entry is kept.
+ /// If this property is set to false then eviction is done independently on different cache nodes.
+ /// Note that it's not recommended to set this value to true if cache store is configured since it will allow
+ /// to significantly improve cache performance.
+ /// </summary>
+ [DefaultValue(DefaultEvictSynchronized)]
+ public bool EvictSynchronized { get; set; }
+
+ /// <summary>
+ /// Gets or sets size of the key buffer for synchronized evictions.
+ /// </summary>
+ [DefaultValue(DefaultEvictSynchronizedKeyBufferSize)]
+ public int EvictSynchronizedKeyBufferSize { get; set; }
+
+ /// <summary>
+ /// Gets or sets concurrency level for synchronized evictions.
+ /// This flag only makes sense with <see cref="EvictSynchronized"/> set to true.
+ /// When synchronized evictions are enabled, it is possible that local eviction policy will try
+ /// to evict entries faster than evictions can be synchronized with backup or near nodes.
+ /// This value specifies how many concurrent synchronous eviction sessions should be allowed
+ /// before the system is forced to wait and let synchronous evictions catch up with the eviction policy.
+ /// </summary>
+ [DefaultValue(DefaultEvictSynchronizedConcurrencyLevel)]
+ public int EvictSynchronizedConcurrencyLevel { get; set; }
+
+ /// <summary>
+ /// Gets or sets timeout for synchronized evictions
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:00:10")]
+ public TimeSpan EvictSynchronizedTimeout { get; set; }
+
+ /// <summary>
+ /// This value denotes the maximum size of eviction queue in percents of cache size
+ /// in case of distributed cache (replicated and partitioned) and using synchronized eviction
+ /// <para/>
+ /// That queue is used internally as a buffer to decrease network costs for synchronized eviction.
+ /// Once queue size reaches specified value all required requests for all entries in the queue
+ /// are sent to remote nodes and the queue is cleared.
+ /// </summary>
+ [DefaultValue(DefaultMaxEvictionOverflowRatio)]
+ public float MaxEvictionOverflowRatio { get; set; }
+
+ /// <summary>
+ /// Gets or sets flag indicating whether expired cache entries will be eagerly removed from cache.
+ /// When set to false, expired entries will be removed on next entry access.
+ /// </summary>
+ [DefaultValue(DefaultEagerTtl)]
+ public bool EagerTtl { get; set; }
+
+ /// <summary>
+ /// Gets or sets initial cache size which will be used to pre-create internal hash table after start.
+ /// </summary>
+ [DefaultValue(DefaultStartSize)]
+ public int StartSize { get; set; }
+
+ /// <summary>
+ /// Gets or sets flag indicating whether value should be loaded from store if it is not in the cache
+ /// for the following cache operations:
+ /// <list type="bullet">
+ /// <item><term><see cref="ICache{TK,TV}.PutIfAbsent"/></term></item>
+ /// <item><term><see cref="ICache{TK,TV}.Replace(TK,TV)"/></term></item>
+ /// <item><term><see cref="ICache{TK,TV}.Remove(TK)"/></term></item>
+ /// <item><term><see cref="ICache{TK,TV}.GetAndPut"/></term></item>
+ /// <item><term><see cref="ICache{TK,TV}.GetAndRemove"/></term></item>
+ /// <item><term><see cref="ICache{TK,TV}.GetAndReplace"/></term></item>
+ /// <item><term><see cref="ICache{TK,TV}.GetAndPutIfAbsent"/></term></item>
+ /// </list>
+ /// </summary>
+ [DefaultValue(DefaultLoadPreviousValue)]
+ public bool LoadPreviousValue { get; set; }
+
+ /// <summary>
+ /// Gets or sets the flag indicating whether <see cref="ICacheStore"/> is working with binary objects
+ /// instead of deserialized objects.
+ /// </summary>
+ [DefaultValue(DefaultKeepVinaryInStore)]
+ public bool KeepBinaryInStore { get; set; }
+
+ /// <summary>
+ /// Gets or sets caching mode to use.
+ /// </summary>
+ [DefaultValue(DefaultCacheMode)]
+ public CacheMode CacheMode { get; set; }
+
+ /// <summary>
+ /// Gets or sets cache atomicity mode.
+ /// </summary>
+ [DefaultValue(DefaultAtomicityMode)]
+ public CacheAtomicityMode AtomicityMode { get; set; }
+
+ /// <summary>
+ /// Gets or sets cache write ordering mode.
+ /// </summary>
+ public CacheAtomicWriteOrderMode AtomicWriteOrderMode { get; set; }
+
+ /// <summary>
+ /// Gets or sets number of nodes used to back up single partition for
+ /// <see cref="Configuration.CacheMode.Partitioned"/> cache.
+ /// </summary>
+ [DefaultValue(DefaultBackups)]
+ public int Backups { get; set; }
+
+ /// <summary>
+ /// Gets or sets default lock acquisition timeout.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:00:00")]
+ public TimeSpan LockTimeout { get; set; }
+
+ /// <summary>
+ /// Invalidation flag. If true, values will be invalidated (nullified) upon commit in near cache.
+ /// </summary>
+ [DefaultValue(DefaultInvalidate)]
+ public bool Invalidate { get; set; }
+
+ /// <summary>
+ /// Gets or sets cache rebalance mode.
+ /// </summary>
+ [DefaultValue(DefaultRebalanceMode)]
+ public CacheRebalanceMode RebalanceMode { get; set; }
+
+ /// <summary>
+ /// Gets or sets size (in number bytes) to be loaded within a single rebalance message.
+ /// Rebalancing algorithm will split total data set on every node into multiple batches prior to sending data.
+ /// </summary>
+ [DefaultValue(DefaultRebalanceBatchSize)]
+ public int RebalanceBatchSize { get; set; }
+
+ /// <summary>
+ /// Flag indicating whether Ignite should use swap storage by default.
+ /// </summary>
+ [DefaultValue(DefaultEnableSwap)]
+ public bool EnableSwap { get; set; }
+
+ /// <summary>
+ /// Gets or sets maximum number of allowed concurrent asynchronous operations, 0 for unlimited.
+ /// </summary>
+ [DefaultValue(DefaultMaxConcurrentAsyncOperations)]
+ public int MaxConcurrentAsyncOperations { get; set; }
+
+ /// <summary>
+ /// Flag indicating whether Ignite should use write-behind behaviour for the cache store.
+ /// </summary>
+ [DefaultValue(DefaultWriteBehindEnabled)]
+ public bool WriteBehindEnabled { get; set; }
+
+ /// <summary>
+ /// Maximum size of the write-behind cache. If cache size exceeds this value, all cached items are flushed
+ /// to the cache store and write cache is cleared.
+ /// </summary>
+ [DefaultValue(DefaultWriteBehindFlushSize)]
+ public int WriteBehindFlushSize { get; set; }
+
+ /// <summary>
+ /// Frequency with which write-behind cache is flushed to the cache store.
+ /// This value defines the maximum time interval between object insertion/deletion from the cache
+ /// at the moment when corresponding operation is applied to the cache store.
+ /// <para/>
+ /// If this value is 0, then flush is performed according to the flush size.
+ /// <para/>
+ /// Note that you cannot set both
+ /// <see cref="WriteBehindFlushSize"/> and <see cref="WriteBehindFlushFrequency"/> to 0.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:00:05")]
+ public TimeSpan WriteBehindFlushFrequency { get; set; }
+
+ /// <summary>
+ /// Number of threads that will perform cache flushing. Cache flushing is performed when cache size exceeds
+ /// value defined by <see cref="WriteBehindFlushSize"/>, or flush interval defined by
+ /// <see cref="WriteBehindFlushFrequency"/> is elapsed.
+ /// </summary>
+ [DefaultValue(DefaultWriteBehindFlushThreadCount)]
+ public int WriteBehindFlushThreadCount { get; set; }
+
+ /// <summary>
+ /// Maximum batch size for write-behind cache store operations.
+ /// Store operations (get or remove) are combined in a batch of this size to be passed to
+ /// <see cref="ICacheStore.WriteAll"/> or <see cref="ICacheStore.DeleteAll"/> methods.
+ /// </summary>
+ [DefaultValue(DefaultWriteBehindBatchSize)]
+ public int WriteBehindBatchSize { get; set; }
+
+ /// <summary>
+ /// Gets or sets rebalance timeout.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:00:10")]
+ public TimeSpan RebalanceTimeout { get; set; }
+
+ /// <summary>
+ /// Gets or sets delay upon a node joining or leaving topology (or crash)
+ /// after which rebalancing should be started automatically.
+ /// Rebalancing should be delayed if you plan to restart nodes
+ /// after they leave topology, or if you plan to start multiple nodes at once or one after another
+ /// and don't want to repartition and rebalance until all nodes are started.
+ /// </summary>
+ public TimeSpan RebalanceDelay { get; set; }
+
+ /// <summary>
+ /// Time to wait between rebalance messages to avoid overloading of CPU or network.
+ /// When rebalancing large data sets, the CPU or network can get over-consumed with rebalancing messages,
+ /// which consecutively may slow down the application performance. This parameter helps tune
+ /// the amount of time to wait between rebalance messages to make sure that rebalancing process
+ /// does not have any negative performance impact. Note that application will continue to work
+ /// properly while rebalancing is still in progress.
+ /// <para/>
+ /// Value of 0 means that throttling is disabled.
+ /// </summary>
+ public TimeSpan RebalanceThrottle { get; set; }
+
+ /// <summary>
+ /// Gets or sets maximum amount of memory available to off-heap storage. Possible values are
+ /// -1 means that off-heap storage is disabled. 0 means that Ignite will not limit off-heap storage
+ /// (it's up to user to properly add and remove entries from cache to ensure that off-heap storage
+ /// does not grow indefinitely.
+ /// Any positive value specifies the limit of off-heap storage in bytes.
+ /// </summary>
+ [DefaultValue(DefaultOffHeapMaxMemory)]
+ public long OffHeapMaxMemory { get; set; }
+
+ /// <summary>
+ /// Gets or sets memory mode for cache.
+ /// </summary>
+ [DefaultValue(DefaultMemoryMode)]
+ public CacheMemoryMode MemoryMode { get; set; }
+
+ /// <summary>
+ /// Gets or sets flag indicating whether data can be read from backup.
+ /// </summary>
+ [DefaultValue(DefaultReadFromBackup)]
+ public bool ReadFromBackup { get; set; }
+
+ /// <summary>
+ /// Gets or sets flag indicating whether copy of of the value stored in cache should be created
+ /// for cache operation implying return value.
+ /// </summary>
+ [DefaultValue(DefaultCopyOnRead)]
+ public bool CopyOnRead { get; set; }
+
+ /// <summary>
+ /// Gets or sets the timeout after which long query warning will be printed.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:00:03")]
+ public TimeSpan LongQueryWarningTimeout { get; set; }
+
+ /// <summary>
+ /// If true all the SQL table and field names will be escaped with double quotes like
+ /// ({ "tableName"."fieldsName"}). This enforces case sensitivity for field names and
+ /// also allows having special characters in table and field names.
+ /// </summary>
+ public bool SqlEscapeAll { get; set; }
+
+ /// <summary>
+ /// Number of SQL rows which will be cached onheap to avoid deserialization on each SQL index access.
+ /// This setting only makes sense when offheap is enabled for this cache.
+ /// </summary>
+ [DefaultValue(DefaultSqlOnheapRowCacheSize)]
+ public int SqlOnheapRowCacheSize { get; set; }
+
+ /// <summary>
+ /// Gets or sets the factory for underlying persistent storage for read-through and write-through operations.
+ /// </summary>
+ public IFactory<ICacheStore> CacheStoreFactory { get; set; }
+
+ /// <summary>
+ /// Gets or sets the query entity configuration.
+ /// </summary>
+ [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+ public ICollection<QueryEntity> QueryEntities { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheMemoryMode.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheMemoryMode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheMemoryMode.cs
new file mode 100644
index 0000000..a072302
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheMemoryMode.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.Cache.Configuration
+{
+ /// <summary>
+ /// Memory modes define whether cache entries are stored on heap memory, offheap memory, or in swap space.
+ /// </summary>
+ public enum CacheMemoryMode
+ {
+ /// <summary>
+ /// Entries will be stored on-heap first. The onheap tiered storage works as follows:
+ /// <list type="bullet">
+ /// <item><description>
+ /// Entries are cached on heap memory first.
+ /// </description></item>
+ /// <item><description>
+ /// If offheap memory is enabled and eviction policy evicts an entry from heap memory,
+ /// entry will be moved to offheap memory. If offheap memory is disabled, then entry is simply discarded.
+ /// </description></item>
+ /// <item><description>
+ /// If swap space is enabled and offheap memory fills up, then entry will be evicted into swap space.
+ /// If swap space is disabled, then entry will be discarded. If swap is enabled and offheap memory is disabled,
+ /// then entry will be evicted directly from heap memory into swap.
+ /// </description></item>
+ /// </list>
+ /// <para />
+ /// Note that heap memory evictions are handled by configured EvictionPolicy implementation. By default,
+ /// no eviction policy is enabled, so entries never leave heap memory space unless explicitly removed.
+ /// </summary>
+ OnheapTiered,
+
+ /// <summary>
+ /// Works the same as <see cref="OnheapTiered"/>, except that entries never end up in heap memory and get
+ /// stored in offheap memory right away. Entries get cached in offheap memory first and then
+ /// get evicted to swap, if one is configured.
+ /// </summary>
+ OffheapTiered,
+
+ /// <summary>
+ /// Entry keys will be stored on heap memory, and values will be stored in offheap memory.
+ /// Note that in this mode entries can be evicted only to swap.
+ /// </summary>
+ OffheapValues
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheMode.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheMode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheMode.cs
new file mode 100644
index 0000000..6608354
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheMode.cs
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Cache.Configuration
+{
+ /// <summary>
+ /// Caching modes.
+ /// </summary>
+ public enum CacheMode
+ {
+ /// <summary>
+ /// Specifies local-only cache behaviour. In this mode caches residing on
+ /// different grid nodes will not know about each other.
+ /// <para />
+ /// Other than distribution, <see cref="Local"/> caches still have all
+ /// the caching features, such as eviction, expiration, swapping,
+ /// querying, etc... This mode is very useful when caching read-only data
+ /// or data that automatically expires at a certain interval and
+ /// then automatically reloaded from persistence store.
+ /// </summary>
+ Local,
+
+ /// <summary>
+ /// Specifies fully replicated cache behavior. In this mode all the keys are distributed
+ /// to all participating nodes.
+ /// </summary>
+ Replicated,
+
+ /// <summary>
+ /// Specifies partitioned cache behaviour. In this mode the overall
+ /// key set will be divided into partitions and all partitions will be split
+ /// equally between participating nodes.
+ /// <para />
+ /// Note that partitioned cache is always fronted by local 'near' cache which stores most recent data.
+ /// </summary>
+ Partitioned
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheRebalanceMode.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheRebalanceMode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheRebalanceMode.cs
new file mode 100644
index 0000000..2ef2115
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheRebalanceMode.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.Cache.Configuration
+{
+ /// <summary>
+ /// Cache rebalance mode. When rebalancing is enabled (i.e. has value other than <see cref="None"/>),
+ /// distributed caches will attempt to rebalance all necessary values from other grid nodes.
+ /// <para />
+ /// Replicated caches will try to load the full set of cache entries from other nodes,
+ /// while partitioned caches will only load the entries for which current node is primary or backup.
+ /// <para />
+ /// Note that rebalance mode only makes sense for <see cref="CacheMode.Replicated"/>
+ /// and <see cref="CacheMode.Partitioned"/> caches. Caches with <see cref="CacheMode.Local"/>
+ /// mode are local by definition and therefore cannot rebalance any values from neighboring nodes.
+ /// </summary>
+ public enum CacheRebalanceMode
+ {
+ /// <summary>
+ /// Synchronous rebalance mode. Distributed caches will not start until all necessary data
+ /// is loaded from other available grid nodes.
+ /// </summary>
+ Sync,
+
+ /// <summary>
+ /// Asynchronous rebalance mode. Distributed caches will start immediately and will load all necessary
+ /// data from other available grid nodes in the background.
+ /// </summary>
+ Async,
+
+ /// <summary>
+ /// In this mode no rebalancing will take place which means that caches will be either loaded on
+ /// demand from persistent store whenever data is accessed, or will be populated explicitly.
+ /// </summary>
+ None
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheWriteSynchronizationMode.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheWriteSynchronizationMode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheWriteSynchronizationMode.cs
new file mode 100644
index 0000000..3257f15
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheWriteSynchronizationMode.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.Cache.Configuration
+{
+ /// <summary>
+ /// Mode indicating how Ignite should wait for write replies from other nodes.
+ /// </summary>
+ public enum CacheWriteSynchronizationMode
+ {
+ /// <summary>
+ /// Mode indicating that Ignite should wait for write or commit replies from all nodes.
+ /// This behavior guarantees that whenever any of the atomic or transactional writes
+ /// complete, all other participating nodes which cache the written data have been updated.
+ /// </summary>
+ FullSync,
+
+ /// <summary>
+ /// Flag indicating that Ignite will not wait for write or commit responses from participating nodes,
+ /// which means that remote nodes may get their state updated a bit after any of the cache write methods
+ /// complete, or after {@link Transaction#commit()} method completes.
+ /// </summary>
+ FullAsync,
+
+ /// <summary>
+ /// This flag only makes sense for {@link CacheMode#PARTITIONED} mode. When enabled, Ignite will wait
+ /// for write or commit to complete on primary node, but will not wait for backups to be updated.
+ /// </summary>
+ PrimarySync
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryAlias.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryAlias.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryAlias.cs
new file mode 100644
index 0000000..33849c7
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryAlias.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.
+ */
+
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+ using Apache.Ignite.Core.Impl.Common;
+
+ /// <summary>
+ /// Represents cache query configuration alias.
+ /// </summary>
+ public class QueryAlias
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryAlias"/> class.
+ /// </summary>
+ public QueryAlias()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryAlias"/> class.
+ /// </summary>
+ /// <param name="fullName">The full name.</param>
+ /// <param name="alias">The alias.</param>
+ public QueryAlias(string fullName, string alias)
+ {
+ IgniteArgumentCheck.NotNullOrEmpty(fullName, "fullName");
+ IgniteArgumentCheck.NotNullOrEmpty(alias, "alias");
+
+ FullName = fullName;
+ Alias = alias;
+ }
+
+ /// <summary>
+ /// Gets or sets the full name of the query field.
+ /// </summary>
+ public string FullName { get; set; }
+
+ /// <summary>
+ /// Gets or sets the alias for the full name.
+ /// </summary>
+ public string Alias { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs
new file mode 100644
index 0000000..4151540
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs
@@ -0,0 +1,401 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 UnusedAutoPropertyAccessor.Global
+// ReSharper disable MemberCanBePrivate.Global
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Diagnostics;
+ using System.Diagnostics.CodeAnalysis;
+ using System.Linq;
+ using System.Reflection;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Impl.Binary;
+
+ /// <summary>
+ /// Query entity is a description of cache entry (composed of key and value)
+ /// in a way of how it must be indexed and can be queried.
+ /// </summary>
+ public class QueryEntity
+ {
+ /** */
+ private Type _keyType;
+
+ /** */
+ private Type _valueType;
+
+ /** */
+ private string _valueTypeName;
+
+ /** */
+ private string _keyTypeName;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryEntity"/> class.
+ /// </summary>
+ public QueryEntity()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryEntity"/> class.
+ /// </summary>
+ /// <param name="valueType">Type of the cache entry value.</param>
+ public QueryEntity(Type valueType)
+ {
+ ValueType = valueType;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryEntity"/> class.
+ /// </summary>
+ /// <param name="keyType">Type of the key.</param>
+ /// <param name="valueType">Type of the value.</param>
+ public QueryEntity(Type keyType, Type valueType)
+ {
+ KeyType = keyType;
+ ValueType = valueType;
+ }
+
+ /// <summary>
+ /// Gets or sets key Java type name.
+ /// </summary>
+ public string KeyTypeName
+ {
+ get { return _keyTypeName; }
+ set
+ {
+ _keyTypeName = value;
+ _keyType = null;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the type of the key.
+ /// <para />
+ /// This is a shortcut for <see cref="KeyTypeName"/>. Getter will return null for non-primitive types.
+ /// <para />
+ /// Setting this property will overwrite <see cref="Fields"/> and <see cref="Indexes"/> according to
+ /// <see cref="QuerySqlFieldAttribute"/>, if any.
+ /// </summary>
+ public Type KeyType
+ {
+ get { return _keyType ?? JavaTypes.GetDotNetType(KeyTypeName); }
+ set
+ {
+ RescanAttributes(value, _valueType); // Do this first because it can throw
+
+ KeyTypeName = value == null
+ ? null
+ : (JavaTypes.GetJavaTypeName(value) ?? BinaryUtils.GetTypeName(value));
+
+ _keyType = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets value Java type name.
+ /// </summary>
+ public string ValueTypeName
+ {
+ get { return _valueTypeName; }
+ set
+ {
+ _valueTypeName = value;
+ _valueType = null;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the type of the value.
+ /// <para />
+ /// This is a shortcut for <see cref="ValueTypeName"/>. Getter will return null for non-primitive types.
+ /// <para />
+ /// Setting this property will overwrite <see cref="Fields"/> and <see cref="Indexes"/> according to
+ /// <see cref="QuerySqlFieldAttribute"/>, if any.
+ /// </summary>
+ public Type ValueType
+ {
+ get { return _valueType ?? JavaTypes.GetDotNetType(ValueTypeName); }
+ set
+ {
+ RescanAttributes(_keyType, value); // Do this first because it can throw
+
+ ValueTypeName = value == null
+ ? null
+ : (JavaTypes.GetJavaTypeName(value) ?? BinaryUtils.GetTypeName(value));
+
+ _valueType = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets query fields, a map from field name to Java type name.
+ /// The order of fields defines the order of columns returned by the 'select *' queries.
+ /// </summary>
+ [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+ public ICollection<QueryField> Fields { get; set; }
+
+ /// <summary>
+ /// Gets or sets field name aliases: mapping from full name in dot notation to an alias
+ /// that will be used as SQL column name.
+ /// Example: {"parent.name" -> "parentName"}.
+ /// </summary>
+ [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+ public ICollection<QueryAlias> Aliases { get; set; }
+
+ /// <summary>
+ /// Gets or sets the query indexes.
+ /// </summary>
+ [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+ public ICollection<QueryIndex> Indexes { get; set; }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryEntity"/> class.
+ /// </summary>
+ /// <param name="reader">The reader.</param>
+ internal QueryEntity(IBinaryRawReader reader)
+ {
+ KeyTypeName = reader.ReadString();
+ ValueTypeName = reader.ReadString();
+
+ var count = reader.ReadInt();
+ Fields = count == 0 ? null : Enumerable.Range(0, count).Select(x =>
+ new QueryField(reader.ReadString(), reader.ReadString())).ToList();
+
+ count = reader.ReadInt();
+ Aliases = count == 0 ? null : Enumerable.Range(0, count)
+ .Select(x=> new QueryAlias(reader.ReadString(), reader.ReadString())).ToList();
+
+ count = reader.ReadInt();
+ Indexes = count == 0 ? null : Enumerable.Range(0, count).Select(x => new QueryIndex(reader)).ToList();
+ }
+
+ /// <summary>
+ /// Writes this instance.
+ /// </summary>
+ internal void Write(IBinaryRawWriter writer)
+ {
+ writer.WriteString(KeyTypeName);
+ writer.WriteString(ValueTypeName);
+
+ if (Fields != null)
+ {
+ writer.WriteInt(Fields.Count);
+
+ foreach (var field in Fields)
+ {
+ writer.WriteString(field.Name);
+ writer.WriteString(field.FieldTypeName);
+ }
+ }
+ else
+ writer.WriteInt(0);
+
+
+ if (Aliases != null)
+ {
+ writer.WriteInt(Aliases.Count);
+
+ foreach (var queryAlias in Aliases)
+ {
+ writer.WriteString(queryAlias.FullName);
+ writer.WriteString(queryAlias.Alias);
+ }
+ }
+ else
+ writer.WriteInt(0);
+
+ if (Indexes != null)
+ {
+ writer.WriteInt(Indexes.Count);
+
+ foreach (var index in Indexes)
+ {
+ if (index == null)
+ throw new InvalidOperationException("Invalid cache configuration: QueryIndex can't be null.");
+
+ index.Write(writer);
+ }
+ }
+ else
+ writer.WriteInt(0);
+ }
+
+
+ /// <summary>
+ /// Rescans the attributes in <see cref="KeyType"/> and <see cref="ValueType"/>.
+ /// </summary>
+ private void RescanAttributes(params Type[] types)
+ {
+ if (types.Length == 0 || types.All(t => t == null))
+ return;
+
+ var fields = new List<QueryField>();
+ var indexes = new List<QueryIndexEx>();
+
+ foreach (var type in types.Where(t => t != null))
+ ScanAttributes(type, fields, indexes, null, new HashSet<Type>());
+
+ if (fields.Any())
+ Fields = fields;
+
+ if (indexes.Any())
+ Indexes = GetGroupIndexes(indexes).ToArray();
+ }
+
+ /// <summary>
+ /// Gets the group indexes.
+ /// </summary>
+ /// <param name="indexes">Ungrouped indexes with their group names.</param>
+ /// <returns></returns>
+ private static IEnumerable<QueryIndex> GetGroupIndexes(List<QueryIndexEx> indexes)
+ {
+ return indexes.Where(idx => idx.IndexGroups != null)
+ .SelectMany(idx => idx.IndexGroups.Select(g => new {Index = idx, GroupName = g}))
+ .GroupBy(x => x.GroupName)
+ .Select(g =>
+ {
+ var idxs = g.Select(pair => pair.Index).ToArray();
+
+ var first = idxs.First();
+
+ return new QueryIndex(idxs.SelectMany(i => i.Fields).ToArray())
+ {
+ IndexType = first.IndexType,
+ Name = first.Name
+ };
+ })
+ .Concat(indexes.Where(idx => idx.IndexGroups == null));
+ }
+
+ /// <summary>
+ /// Scans specified type for occurences of <see cref="QuerySqlFieldAttribute"/>.
+ /// </summary>
+ /// <param name="type">The type.</param>
+ /// <param name="fields">The fields.</param>
+ /// <param name="indexes">The indexes.</param>
+ /// <param name="parentPropName">Name of the parent property.</param>
+ /// <param name="visitedTypes">The visited types.</param>
+ private static void ScanAttributes(Type type, List<QueryField> fields, List<QueryIndexEx> indexes,
+ string parentPropName, ISet<Type> visitedTypes)
+ {
+ Debug.Assert(type != null);
+ Debug.Assert(fields != null);
+ Debug.Assert(indexes != null);
+
+ if (visitedTypes.Contains(type))
+ throw new InvalidOperationException("Recursive Query Field definition detected: " + type);
+
+ visitedTypes.Add(type);
+
+ foreach (var memberInfo in GetFieldsAndProperties(type))
+ {
+ var customAttributes = memberInfo.Key.GetCustomAttributes(true);
+
+ foreach (var attr in customAttributes.OfType<QuerySqlFieldAttribute>())
+ {
+ var columnName = attr.Name ?? memberInfo.Key.Name;
+
+ // Dot notation is required for nested SQL fields
+ if (parentPropName != null)
+ columnName = parentPropName + "." + columnName;
+
+ fields.Add(new QueryField(columnName, memberInfo.Value));
+
+ if (attr.IsIndexed)
+ indexes.Add(new QueryIndexEx(columnName, attr.IsDescending, QueryIndexType.Sorted,
+ attr.IndexGroups));
+
+ ScanAttributes(memberInfo.Value, fields, indexes, columnName, visitedTypes);
+ }
+
+ foreach (var attr in customAttributes.OfType<QueryTextFieldAttribute>())
+ {
+ var columnName = attr.Name ?? memberInfo.Key.Name;
+
+ // No dot notation for FullText index names
+ indexes.Add(new QueryIndexEx(columnName, false, QueryIndexType.FullText, null));
+
+ if (parentPropName != null)
+ columnName = parentPropName + "." + columnName;
+
+ fields.Add(new QueryField(columnName, memberInfo.Value));
+
+ ScanAttributes(memberInfo.Value, fields, indexes, columnName, visitedTypes);
+ }
+ }
+
+ visitedTypes.Remove(type);
+ }
+
+ /// <summary>
+ /// Gets the fields and properties.
+ /// </summary>
+ /// <param name="type">The type.</param>
+ /// <returns></returns>
+ private static IEnumerable<KeyValuePair<MemberInfo, Type>> GetFieldsAndProperties(Type type)
+ {
+ Debug.Assert(type != null);
+
+ if (type.IsPrimitive)
+ yield break;
+
+ var bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance |
+ BindingFlags.DeclaredOnly;
+
+ while (type != typeof (object) && type != null)
+ {
+ foreach (var fieldInfo in type.GetFields(bindingFlags))
+ yield return new KeyValuePair<MemberInfo, Type>(fieldInfo, fieldInfo.FieldType);
+
+ foreach (var propertyInfo in type.GetProperties(bindingFlags))
+ yield return new KeyValuePair<MemberInfo, Type>(propertyInfo, propertyInfo.PropertyType);
+
+ type = type.BaseType;
+ }
+ }
+
+ /// <summary>
+ /// Extended index with group names.
+ /// </summary>
+ private class QueryIndexEx : QueryIndex
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryIndexEx"/> class.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="isDescending">if set to <c>true</c> [is descending].</param>
+ /// <param name="indexType">Type of the index.</param>
+ /// <param name="groups">The groups.</param>
+ public QueryIndexEx(string fieldName, bool isDescending, QueryIndexType indexType,
+ ICollection<string> groups)
+ : base(isDescending, indexType, fieldName)
+ {
+ IndexGroups = groups;
+ }
+
+ /// <summary>
+ /// Gets or sets the index groups.
+ /// </summary>
+ public ICollection<string> IndexGroups { get; set; }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryField.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryField.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryField.cs
new file mode 100644
index 0000000..8c70a29
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryField.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.
+ */
+
+// ReSharper disable UnusedAutoPropertyAccessor.Global
+// ReSharper disable MemberCanBePrivate.Global
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+ using System;
+ using Apache.Ignite.Core.Impl.Binary;
+ using Apache.Ignite.Core.Impl.Common;
+
+ /// <summary>
+ /// Represents a queryable field.
+ /// </summary>
+ public class QueryField
+ {
+ /** */
+ private Type _type;
+
+ /** */
+ private string _fieldTypeName;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryField"/> class.
+ /// </summary>
+ public QueryField()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryField"/> class.
+ /// </summary>
+ /// <param name="name">Name.</param>
+ /// <param name="javaFieldTypeName">Java type name.</param>
+ public QueryField(string name, string javaFieldTypeName)
+ {
+ IgniteArgumentCheck.NotNullOrEmpty(name, "name");
+ IgniteArgumentCheck.NotNullOrEmpty(javaFieldTypeName, "typeName");
+
+ Name = name;
+ FieldTypeName = javaFieldTypeName;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryField" /> class.
+ /// </summary>
+ /// <param name="name">Name.</param>
+ /// <param name="fieldType">Type.</param>
+ public QueryField(string name, Type fieldType)
+ {
+ IgniteArgumentCheck.NotNullOrEmpty(name, "name");
+ IgniteArgumentCheck.NotNull(fieldType, "type");
+
+ Name = name;
+ FieldType = fieldType;
+ }
+
+ /// <summary>
+ /// Gets the field name.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the type of the value.
+ /// <para />
+ /// This is a shortcut for <see cref="FieldTypeName"/>. Getter will return null for non-primitive types.
+ /// </summary>
+ public Type FieldType
+ {
+ get { return _type ?? JavaTypes.GetDotNetType(FieldTypeName); }
+ set
+ {
+ FieldTypeName = value == null
+ ? null
+ : (JavaTypes.GetJavaTypeName(value) ?? BinaryUtils.GetTypeName(value));
+
+ _type = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets the Java type name.
+ /// </summary>
+ public string FieldTypeName
+ {
+ get { return _fieldTypeName; }
+ set
+ {
+ _fieldTypeName = value;
+ _type = null;
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndex.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndex.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndex.cs
new file mode 100644
index 0000000..7079606
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndex.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.
+ */
+
+// ReSharper disable UnusedMember.Global
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using Apache.Ignite.Core.Binary;
+
+ /// <summary>
+ /// Represents cache query index configuration.
+ /// </summary>
+ public class QueryIndex
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryIndex"/> class.
+ /// </summary>
+ public QueryIndex()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryIndex" /> class.
+ /// </summary>
+ /// <param name="fieldNames">Names of the fields to index.</param>
+ public QueryIndex(params string[] fieldNames) : this(false, fieldNames)
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryIndex" /> class.
+ /// </summary>
+ /// <param name="isDescending">Sort direction.</param>
+ /// <param name="fieldNames">Names of the fields to index.</param>
+ public QueryIndex(bool isDescending, params string[] fieldNames)
+ {
+ Fields = fieldNames.Select(f => new QueryIndexField(f, isDescending)).ToArray();
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryIndex" /> class.
+ /// </summary>
+ /// <param name="isDescending">Sort direction.</param>
+ /// <param name="indexType">Type of the index.</param>
+ /// <param name="fieldNames">Names of the fields to index.</param>
+ public QueryIndex(bool isDescending, QueryIndexType indexType, params string[] fieldNames)
+ : this(isDescending, fieldNames)
+ {
+ IndexType = indexType;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryIndex"/> class.
+ /// </summary>
+ /// <param name="fields">The fields.</param>
+ public QueryIndex(params QueryIndexField[] fields)
+ {
+ if (fields == null || fields.Length == 0)
+ throw new ArgumentException("Query index must have at least one field");
+
+ if (fields.Any(f => f == null))
+ throw new ArgumentException("IndexField cannot be null.");
+
+ Fields = fields;
+ }
+
+ /// <summary>
+ /// Gets or sets the index name.
+ /// Will be set automatically if not specified.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the type of the index.
+ /// </summary>
+ public QueryIndexType IndexType { get; set; }
+
+ /// <summary>
+ /// Gets or sets a collection of fields to be indexed.
+ /// </summary>
+ public ICollection<QueryIndexField> Fields { get; private set; }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryIndex"/> class.
+ /// </summary>
+ /// <param name="reader">The reader.</param>
+ internal QueryIndex(IBinaryRawReader reader)
+ {
+ Name = reader.ReadString();
+ IndexType = (QueryIndexType) reader.ReadByte();
+
+ var count = reader.ReadInt();
+ Fields = count == 0 ? null : Enumerable.Range(0, count).Select(x =>
+ new QueryIndexField(reader.ReadString(), reader.ReadBoolean())).ToList();
+ }
+
+ /// <summary>
+ /// Writes this instance.
+ /// </summary>
+ internal void Write(IBinaryRawWriter writer)
+ {
+ writer.WriteString(Name);
+ writer.WriteByte((byte) IndexType);
+
+ if (Fields != null)
+ {
+ writer.WriteInt(Fields.Count);
+
+ foreach (var field in Fields)
+ {
+ writer.WriteString(field.Name);
+ writer.WriteBoolean(field.IsDescending);
+ }
+ }
+ else
+ writer.WriteInt(0);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndexField.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndexField.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndexField.cs
new file mode 100644
index 0000000..0b11e9c
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndexField.cs
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Cache.Configuration
+{
+ using Apache.Ignite.Core.Impl.Common;
+
+ /// <summary>
+ /// Represents an indexed field.
+ /// </summary>
+ public class QueryIndexField
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryIndexField"/> class.
+ /// </summary>
+ public QueryIndexField()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryIndexField"/> class.
+ /// </summary>
+ /// <param name="name">The name.</param>
+ public QueryIndexField(string name)
+ {
+ IgniteArgumentCheck.NotNullOrEmpty(name, "name");
+
+ Name = name;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryIndexField"/> class.
+ /// </summary>
+ /// <param name="name">The name.</param>
+ /// <param name="isDescending">Sort direction.</param>
+ public QueryIndexField(string name, bool isDescending) : this (name)
+ {
+ IsDescending = isDescending;
+ }
+
+ /// <summary>
+ /// Gets the name.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets a value indicating whether this index is descending. Default is false.
+ /// </summary>
+ public bool IsDescending { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndexType.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndexType.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndexType.cs
new file mode 100644
index 0000000..25fed62
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndexType.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.Cache.Configuration
+{
+ /// <summary>
+ /// Query index type.
+ /// </summary>
+ public enum QueryIndexType
+ {
+ /// <summary>
+ /// Sorted index.
+ /// </summary>
+ Sorted,
+
+ /// <summary>
+ /// Fulltext index.
+ /// </summary>
+ FullText,
+
+ /// <summary>
+ /// Geo-spatial index.
+ /// </summary>
+ Geospatial
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QuerySqlFieldAttribute.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QuerySqlFieldAttribute.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QuerySqlFieldAttribute.cs
new file mode 100644
index 0000000..a522115
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QuerySqlFieldAttribute.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.Cache.Configuration
+{
+ using System;
+ using System.Diagnostics.CodeAnalysis;
+
+ /// <summary>
+ /// Marks field or property for SQL queries.
+ /// <para />
+ /// Using this attribute is an alternative to <see cref="QueryEntity.Fields"/> in <see cref="CacheConfiguration"/>.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
+ public sealed class QuerySqlFieldAttribute : Attribute
+ {
+ /// <summary>
+ /// Gets or sets the sql field name.
+ /// If not provided, property or field name will be used.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether corresponding field should be indexed.
+ /// Just like with databases, field indexing may require additional overhead during updates,
+ /// but makes select operations faster.
+ /// </summary>
+ public bool IsIndexed { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether index for this field should be descending.
+ /// Ignored when <see cref="IsIndexed"/> is <c>false</c>.
+ /// </summary>
+ public bool IsDescending { get; set; }
+
+ /// <summary>
+ /// Gets or sets the collection of index groups this field belongs to.
+ /// Groups are used for compound indexes,
+ /// whenever index should be created on more than one field.
+ /// All fields within the same group will belong to the same index.
+ /// </summary>
+ [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays",
+ Justification = "Attribute initializers do not allow collections")]
+ public string[] IndexGroups { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryTextFieldAttribute.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryTextFieldAttribute.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryTextFieldAttribute.cs
new file mode 100644
index 0000000..6386496
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryTextFieldAttribute.cs
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Cache.Configuration
+{
+ using System;
+
+ /// <summary>
+ /// Marks field or property for Text queries.
+ /// <para />
+ /// Using this attribute is an alternative to <see cref="QueryEntity.Fields"/> in <see cref="CacheConfiguration"/>.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
+ public sealed class QueryTextFieldAttribute : Attribute
+ {
+ /// <summary>
+ /// Gets or sets the text field name.
+ /// If not provided, property or field name will be used.
+ /// </summary>
+ public string Name { get; set; }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
index 192dabf..f5e7cd2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
@@ -22,6 +22,7 @@ namespace Apache.Ignite.Core.Cache
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
+ using Apache.Ignite.Core.Cache.Configuration;
using Apache.Ignite.Core.Cache.Expiry;
using Apache.Ignite.Core.Cache.Query;
using Apache.Ignite.Core.Cache.Query.Continuous;
@@ -66,6 +67,11 @@ namespace Apache.Ignite.Core.Cache
IIgnite Ignite { get; }
/// <summary>
+ /// Gets the cache configuration.
+ /// </summary>
+ CacheConfiguration GetConfiguration();
+
+ /// <summary>
/// Checks whether this cache contains no key-value mappings.
/// <para />
/// Semantically equals to <c>ICache.Size(CachePeekMode.PRIMARY) == 0</c>.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Common/IFactory.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Common/IFactory.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Common/IFactory.cs
new file mode 100644
index 0000000..67c2683
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Common/IFactory.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.Common
+{
+ using System;
+
+ /// <summary>
+ /// Factory that produces instances of a specific type.
+ /// Implementation can be passed over the wire and thus should be marked with <see cref="SerializableAttribute"/>.
+ /// </summary>
+ public interface IFactory<out T>
+ {
+ /// <summary>
+ /// Creates an instance of the cache store.
+ /// </summary>
+ /// <returns>New instance of the cache store.</returns>
+ T CreateInstance();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/IDiscoverySpi.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/IDiscoverySpi.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/IDiscoverySpi.cs
new file mode 100644
index 0000000..2fcafbf
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/IDiscoverySpi.cs
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Discovery
+{
+ using System.Diagnostics.CodeAnalysis;
+ using Apache.Ignite.Core.Discovery.Tcp;
+
+ /// <summary>
+ /// Represents a discovery service provider interface.
+ /// Only predefined implementation is supported now: <see cref="TcpDiscoverySpi"/>.
+ /// </summary>
+ [SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces")]
+ public interface IDiscoverySpi
+ {
+ // No-op.
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/ITcpDiscoveryIpFinder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/ITcpDiscoveryIpFinder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/ITcpDiscoveryIpFinder.cs
new file mode 100644
index 0000000..c2f4329
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/ITcpDiscoveryIpFinder.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.Discovery.Tcp
+{
+ using System.Diagnostics.CodeAnalysis;
+ using Apache.Ignite.Core.Discovery.Tcp.Multicast;
+ using Apache.Ignite.Core.Discovery.Tcp.Static;
+
+ /// <summary>
+ /// Represents an IP finder for <see cref="TcpDiscoverySpi"/>.
+ /// Only predefined implementations are supported now:
+ /// <see cref="TcpDiscoveryStaticIpFinder"/>, <see cref="TcpDiscoveryMulticastIpFinder"/>.
+ /// </summary>
+ [SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces")]
+ public interface ITcpDiscoveryIpFinder
+ {
+ // No-op.
+ }
+}
\ No newline at end of file