You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/10/22 11:26:53 UTC
[01/50] [abbrv] ignite git commit: IGNITE-1282: .Net: Minor method
renames.
Repository: ignite
Updated Branches:
refs/heads/ignite-1651 4f8236440 -> 03cbca56f
IGNITE-1282: .Net: Minor method renames.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b1c64af1
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b1c64af1
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b1c64af1
Branch: refs/heads/ignite-1651
Commit: b1c64af196c29daed39aa854751bcb8eaa46941d
Parents: 13db2da
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Oct 8 17:16:41 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Oct 8 17:16:41 2015 +0300
----------------------------------------------------------------------
.../dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs | 2 +-
.../dotnet/Apache.Ignite.Core/Impl/Cluster/IClusterGroupEx.cs | 4 ++--
modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs | 4 ++--
modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs | 4 ++--
.../Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs | 2 +-
5 files changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b1c64af1/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
index 94dd595..b1f19ab 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
@@ -538,7 +538,7 @@ namespace Apache.Ignite.Core.Impl.Cluster
}
/** <inheritDoc /> */
- public IPortableMetadata Metadata(int typeId)
+ public IPortableMetadata GetMetadata(int typeId)
{
return DoOutInOp<IPortableMetadata>(OpMetadata,
writer =>
http://git-wip-us.apache.org/repos/asf/ignite/blob/b1c64af1/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/IClusterGroupEx.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/IClusterGroupEx.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/IClusterGroupEx.cs
index 554eb0a..8a766da 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/IClusterGroupEx.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/IClusterGroupEx.cs
@@ -21,7 +21,7 @@ namespace Apache.Ignite.Core.Impl.Cluster
using Apache.Ignite.Core.Portable;
/// <summary>
- ///
+ /// Extended internal Ignite interface.
/// </summary>
internal interface IClusterGroupEx : IClusterGroup
{
@@ -30,6 +30,6 @@ namespace Apache.Ignite.Core.Impl.Cluster
/// </summary>
/// <param name="typeId">Type ID.</param>
/// <returns>Metadata.</returns>
- IPortableMetadata Metadata(int typeId);
+ IPortableMetadata GetMetadata(int typeId);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b1c64af1/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 9f3d9b1..2ed7a75 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
@@ -480,9 +480,9 @@ namespace Apache.Ignite.Core.Impl
}
/** <inheritDoc /> */
- public IPortableMetadata Metadata(int typeId)
+ public IPortableMetadata GetMetadata(int typeId)
{
- return _prj.Metadata(typeId);
+ return _prj.GetMetadata(typeId);
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/b1c64af1/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 4f9e369..86021c8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
@@ -335,9 +335,9 @@ namespace Apache.Ignite.Core.Impl
}
/** <inheritdoc /> */
- public IPortableMetadata Metadata(int typeId)
+ public IPortableMetadata GetMetadata(int typeId)
{
- return ((IClusterGroupEx)_ignite).Metadata(typeId);
+ return ((IClusterGroupEx)_ignite).GetMetadata(typeId);
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b1c64af1/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
index 2b87fbb..e1cd4c5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
@@ -264,7 +264,7 @@ namespace Apache.Ignite.Core.Impl.Portable
{
if (Ignite != null)
{
- IPortableMetadata meta = Ignite.Metadata(typeId);
+ IPortableMetadata meta = Ignite.GetMetadata(typeId);
if (meta != null)
return meta;
[08/50] [abbrv] ignite git commit: IGNITE-1682 .Net: Remove
RemoteListen from Events API.
Posted by vo...@apache.org.
IGNITE-1682 .Net: Remove RemoteListen from Events API.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/91eeab7a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/91eeab7a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/91eeab7a
Branch: refs/heads/ignite-1651
Commit: 91eeab7ac3e29cdba4cdb9679a0c083aea8fc959
Parents: 6695e6c
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Thu Oct 15 15:04:21 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Oct 15 15:04:21 2015 +0300
----------------------------------------------------------------------
.../Apache.Ignite.Core.Tests/EventsTest.cs | 38 ++++----
.../Apache.Ignite.Core.csproj | 1 +
.../Apache.Ignite.Core/Events/IEventFilter.cs | 9 +-
.../Apache.Ignite.Core/Events/IEventListener.cs | 34 +++++++
.../dotnet/Apache.Ignite.Core/Events/IEvents.cs | 97 ++------------------
.../Impl/Common/DelegateTypeDescriptor.cs | 8 +-
.../Apache.Ignite.Core/Impl/Events/Events.cs | 37 +++++---
.../Impl/Events/RemoteListenEventFilter.cs | 10 +-
.../Events/EventsExample.cs | 18 ----
.../Apache.Ignite.ExamplesDll.csproj | 1 -
.../Events/LocalListener.cs | 5 +-
.../Events/RemoteFilter.cs | 42 ---------
12 files changed, 102 insertions(+), 198 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/91eeab7a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
index b325d36..33841ad 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
@@ -348,7 +348,7 @@ namespace Apache.Ignite.Core.Tests
// Filter
waitTask = getWaitTask(() => events.WaitForLocal(
- new EventFilter<IEvent>((g, e) => e.Type == EventType.TaskReduced)));
+ new EventFilter<IEvent>(e => e.Type == EventType.TaskReduced)));
Assert.IsTrue(waitTask.Wait(timeout));
Assert.IsInstanceOf(typeof(TaskEvent), waitTask.Result);
@@ -356,13 +356,14 @@ namespace Apache.Ignite.Core.Tests
// Filter & types
waitTask = getWaitTask(() => events.WaitForLocal(
- new EventFilter<IEvent>((g, e) => e.Type == EventType.TaskReduced), EventType.TaskReduced));
+ new EventFilter<IEvent>(e => e.Type == EventType.TaskReduced), EventType.TaskReduced));
Assert.IsTrue(waitTask.Wait(timeout));
Assert.IsInstanceOf(typeof(TaskEvent), waitTask.Result);
Assert.AreEqual(EventType.TaskReduced, waitTask.Result.Type);
}
+ /*
/// <summary>
/// Tests RemoteListen.
/// </summary>
@@ -426,7 +427,7 @@ namespace Apache.Ignite.Core.Tests
CheckSend(1, typeof(JobEvent), expectedType); // one last event
CheckNoEvent();
- }
+ }*/
/// <summary>
/// Tests RemoteQuery.
@@ -788,7 +789,7 @@ namespace Apache.Ignite.Core.Tests
/// Gets the event listener.
/// </summary>
/// <returns>New instance of event listener.</returns>
- public static IEventFilter<IEvent> GetListener()
+ public static IEventListener<IEvent> GetListener()
{
return new EventFilter<IEvent>(Listen);
}
@@ -813,13 +814,12 @@ namespace Apache.Ignite.Core.Tests
/// <summary>
/// Listen method.
/// </summary>
- /// <param name="id">Originating node ID.</param>
/// <param name="evt">Event.</param>
- private static bool Listen(Guid? id, IEvent evt)
+ private static bool Listen(IEvent evt)
{
try
{
- LastNodeIds.Push(id);
+ LastNodeIds.Push(evt.Node.Id);
ReceivedEvents.Push(evt);
ReceivedEvent.Signal();
@@ -830,7 +830,7 @@ namespace Apache.Ignite.Core.Tests
{
// When executed on remote nodes, these exceptions will not go to sender,
// so we have to accumulate them.
- Failures.Push(string.Format("Exception in Listen (msg: {0}, id: {1}): {2}", evt, id, ex));
+ Failures.Push(string.Format("Exception in Listen (msg: {0}, id: {1}): {2}", evt, evt.Node.Id, ex));
throw;
}
}
@@ -840,28 +840,34 @@ namespace Apache.Ignite.Core.Tests
/// Test event filter.
/// </summary>
[Serializable]
- public class EventFilter<T> : IEventFilter<T> where T : IEvent
+ public class EventFilter<T> : IEventFilter<T>, IEventListener<T> where T : IEvent
{
/** */
- private readonly Func<Guid?, T, bool> _invoke;
+ private readonly Func<T, bool> _invoke;
/// <summary>
/// Initializes a new instance of the <see cref="RemoteListenEventFilter"/> class.
/// </summary>
/// <param name="invoke">The invoke delegate.</param>
- public EventFilter(Func<Guid?, T, bool> invoke)
+ public EventFilter(Func<T, bool> invoke)
{
_invoke = invoke;
}
/** <inheritdoc /> */
- bool IEventFilter<T>.Invoke(Guid? nodeId, T evt)
+ bool IEventFilter<T>.Invoke(T evt)
+ {
+ return _invoke(evt);
+ }
+
+ /** <inheritdoc /> */
+ bool IEventListener<T>.Invoke(T evt)
{
- return _invoke(nodeId, evt);
+ return _invoke(evt);
}
/** <inheritdoc /> */
- public bool Invoke(Guid nodeId, T evt)
+ public bool Invoke(T evt)
{
throw new Exception("Invalid method");
}
@@ -882,7 +888,7 @@ namespace Apache.Ignite.Core.Tests
}
/** <inheritdoc /> */
- public bool Invoke(Guid? nodeId, IEvent evt)
+ public bool Invoke(IEvent evt)
{
return evt.Type == _type;
}
@@ -906,7 +912,7 @@ namespace Apache.Ignite.Core.Tests
}
/** <inheritdoc /> */
- public bool Invoke(Guid? nodeId, IEvent evt)
+ public bool Invoke(IEvent evt)
{
return evt.Type == _type;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/91eeab7a/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 a10a0a5..401b46c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -125,6 +125,7 @@
<Compile Include="Events\EventType.cs" />
<Compile Include="Events\IEvent.cs" />
<Compile Include="Events\IEventFilter.cs" />
+ <Compile Include="Events\IEventListener.cs" />
<Compile Include="Events\IEvents.cs" />
<Compile Include="Events\JobEvent.cs" />
<Compile Include="Events\SwapSpaceEvent.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/91eeab7a/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEventFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEventFilter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEventFilter.cs
index 83aca53..8c80cec 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEventFilter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEventFilter.cs
@@ -17,8 +17,6 @@
namespace Apache.Ignite.Core.Events
{
- using System;
-
/// <summary>
/// Represents an event filter.
/// </summary>
@@ -26,11 +24,10 @@ namespace Apache.Ignite.Core.Events
public interface IEventFilter<in T> where T : IEvent
{
/// <summary>
- /// Determines whether specified event passes this filtger.
+ /// Determines whether specified event passes this filter.
/// </summary>
- /// <param name="nodeId">Node identifier.</param>
/// <param name="evt">Event.</param>
- /// <returns>Value indicating whether specified event passes this filtger.</returns>
- bool Invoke(Guid? nodeId, T evt);
+ /// <returns>Value indicating whether specified event passes this filter.</returns>
+ bool Invoke(T evt);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/91eeab7a/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEventListener.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEventListener.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEventListener.cs
new file mode 100644
index 0000000..06e9ecc
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEventListener.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.Events
+{
+ /// <summary>
+ /// Represents an event listener.
+ /// </summary>
+ /// <typeparam name="T">Event type.</typeparam>
+ public interface IEventListener<in T> where T : IEvent
+ {
+ /// <summary>
+ /// Invoked when event occurs.
+ /// </summary>
+ /// <param name="evt">Event.</param>
+ /// <returns>Value indicating whether this listener should be kept subscribed.
+ /// Returning false unsubscribes this listener from future notifications.</returns>
+ bool Invoke(T evt);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/91eeab7a/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEvents.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEvents.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEvents.cs
index b2f07d4..e8459c6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEvents.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEvents.cs
@@ -23,7 +23,7 @@ namespace Apache.Ignite.Core.Events
using Apache.Ignite.Core.Common;
/// <summary>
- /// Provides functionality for local and remote event notifications on nodes defined by <see cref="ClusterGroup"/>.
+ /// Provides functionality for event notifications on nodes defined by <see cref="ClusterGroup"/>.
/// <para/>
/// All members are thread-safe and may be used concurrently from multiple threads.
/// </summary>
@@ -59,91 +59,6 @@ namespace Apache.Ignite.Core.Events
where T : IEvent;
/// <summary>
- /// Adds event listener for specified events to all nodes in the cluster group (possibly including local node
- /// if it belongs to the cluster group as well). This means that all events occurring on any node within this
- /// cluster group that pass remote filter will be sent to local node for local listener notifications.
- /// <para/>
- /// The listener can be unsubscribed automatically if local node stops, if localListener callback
- /// returns false or if <see cref="StopRemoteListen"/> is called.
- /// </summary>
- /// <typeparam name="T">Type of events.</typeparam>
- /// <param name="bufSize">Remote events buffer size. Events from remote nodes won't be sent until buffer
- /// is full or time interval is exceeded.</param>
- /// <param name="interval">Maximum time interval after which events from remote node will be sent. Events
- /// from remote nodes won't be sent until buffer is full or time interval is exceeded.</param>
- /// <param name="autoUnsubscribe">Flag indicating that event listeners on remote nodes should be automatically
- /// unregistered if master node (node that initiated event listening) leaves topology.
- /// If this flag is false, listeners will be unregistered only when <see cref="StopRemoteListen"/>
- /// method is called, or the localListener returns false.</param>
- /// <param name="localListener"> Listener callback that is called on local node. If null, these events will
- /// be handled on remote nodes by passed in remoteFilter.</param>
- /// <param name="remoteFilter">
- /// Filter callback that is called on remote node. Only events that pass the remote filter will be
- /// sent to local node. If null, all events of specified types will be sent to local node.
- /// This remote filter can be used to pre-handle events remotely, before they are passed in to local callback.
- /// It will be auto-unsubscribed on the node where event occurred in case if it returns false.
- /// </param>
- /// <param name="types">
- /// Types of events to listen for. If not provided, all events that pass the provided remote filter
- /// will be sent to local node.
- /// </param>
- /// <returns>
- /// Operation ID that can be passed to <see cref="StopRemoteListen"/> method to stop listening.
- /// </returns>
- [AsyncSupported]
- Guid? RemoteListen<T>(int bufSize = 1, TimeSpan? interval = null, bool autoUnsubscribe = true,
- IEventFilter<T> localListener = null, IEventFilter<T> remoteFilter = null, params int[] types)
- where T : IEvent;
-
- /// <summary>
- /// Adds event listener for specified events to all nodes in the cluster group (possibly including local node
- /// if it belongs to the cluster group as well). This means that all events occurring on any node within this
- /// cluster group that pass remote filter will be sent to local node for local listener notifications.
- /// <para/>
- /// The listener can be unsubscribed automatically if local node stops, if localListener callback
- /// returns false or if <see cref="StopRemoteListen"/> is called.
- /// </summary>
- /// <typeparam name="T">Type of events.</typeparam>
- /// <param name="bufSize">Remote events buffer size. Events from remote nodes won't be sent until buffer
- /// is full or time interval is exceeded.</param>
- /// <param name="interval">Maximum time interval after which events from remote node will be sent. Events
- /// from remote nodes won't be sent until buffer is full or time interval is exceeded.</param>
- /// <param name="autoUnsubscribe">Flag indicating that event listeners on remote nodes should be automatically
- /// unregistered if master node (node that initiated event listening) leaves topology.
- /// If this flag is false, listeners will be unregistered only when <see cref="StopRemoteListen"/>
- /// method is called, or the localListener returns false.</param>
- /// <param name="localListener"> Listener callback that is called on local node. If null, these events will
- /// be handled on remote nodes by passed in remoteFilter.</param>
- /// <param name="remoteFilter">
- /// Filter callback that is called on remote node. Only events that pass the remote filter will be
- /// sent to local node. If null, all events of specified types will be sent to local node.
- /// This remote filter can be used to pre-handle events remotely, before they are passed in to local callback.
- /// It will be auto-unsubscribed on the node where event occurred in case if it returns false.
- /// </param>
- /// <param name="types">
- /// Types of events to listen for. If not provided, all events that pass the provided remote filter
- /// will be sent to local node.
- /// </param>
- /// <returns>
- /// Operation ID that can be passed to <see cref="StopRemoteListen"/> method to stop listening.
- /// </returns>
- [AsyncSupported]
- Guid? RemoteListen<T>(int bufSize = 1, TimeSpan? interval = null, bool autoUnsubscribe = true,
- IEventFilter<T> localListener = null, IEventFilter<T> remoteFilter = null, IEnumerable<int> types = null)
- where T : IEvent;
-
- /// <summary>
- /// Stops listening to remote events. This will unregister all listeners identified with provided operation ID
- /// on all nodes defined by <see cref="ClusterGroup"/>.
- /// </summary>
- /// <param name="opId">
- /// Operation ID that was returned from
- /// <see cref="RemoteListen{T}(int, TimeSpan?, bool, IEventFilter{T},IEventFilter{T},int[])"/>.
- /// </param>
- [AsyncSupported]
- void StopRemoteListen(Guid opId);
-
- /// <summary>
/// Waits for the specified events.
/// </summary>
/// <param name="types">Types of the events to wait for.
@@ -205,7 +120,7 @@ namespace Apache.Ignite.Core.Events
/// Attempt to record internal event with this method will cause <see cref="ArgumentException"/> to be thrown.
/// </summary>
/// <param name="evt">Locally generated event.</param>
- /// <exception cref="ArgumentException">If event type is within Ignite reserved range (1 � 1000)</exception>
+ /// <exception cref="ArgumentException">If event type is within Ignite reserved range (1 to 1000)</exception>
void RecordLocal(IEvent evt);
/// <summary>
@@ -216,7 +131,7 @@ namespace Apache.Ignite.Core.Events
/// <param name="listener">Predicate that is called on each received event. If predicate returns false,
/// it will be unregistered and will stop receiving events.</param>
/// <param name="types">Event types for which this listener will be notified, should not be empty.</param>
- void LocalListen<T>(IEventFilter<T> listener, params int[] types) where T : IEvent;
+ void LocalListen<T>(IEventListener<T> listener, params int[] types) where T : IEvent;
/// <summary>
/// Adds an event listener for local events. Note that listener will be added regardless of whether
@@ -226,7 +141,7 @@ namespace Apache.Ignite.Core.Events
/// <param name="listener">Predicate that is called on each received event. If predicate returns false,
/// it will be unregistered and will stop receiving events.</param>
/// <param name="types">Event types for which this listener will be notified, should not be empty.</param>
- void LocalListen<T>(IEventFilter<T> listener, IEnumerable<int> types) where T : IEvent;
+ void LocalListen<T>(IEventListener<T> listener, IEnumerable<int> types) where T : IEvent;
/// <summary>
/// Removes local event listener.
@@ -236,7 +151,7 @@ namespace Apache.Ignite.Core.Events
/// <param name="types">Types of events for which to remove listener. If not specified, then listener
/// will be removed for all types it was registered for.</param>
/// <returns>True if listener was removed, false otherwise.</returns>
- bool StopLocalListen<T>(IEventFilter<T> listener, params int[] types) where T : IEvent;
+ bool StopLocalListen<T>(IEventListener<T> listener, params int[] types) where T : IEvent;
/// <summary>
/// Removes local event listener.
@@ -246,7 +161,7 @@ namespace Apache.Ignite.Core.Events
/// <param name="types">Types of events for which to remove listener. If not specified, then listener
/// will be removed for all types it was registered for.</param>
/// <returns>True if listener was removed, false otherwise.</returns>
- bool StopLocalListen<T>(IEventFilter<T> listener, IEnumerable<int> types) where T : IEvent;
+ bool StopLocalListen<T>(IEventListener<T> listener, IEnumerable<int> types) where T : IEvent;
/// <summary>
/// Enables provided events. Allows to start recording events that were disabled before.
http://git-wip-us.apache.org/repos/asf/ignite/blob/91eeab7a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
index 0f2b3c1..fb55d8e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
@@ -48,7 +48,7 @@ namespace Apache.Ignite.Core.Impl.Common
private readonly Func<object, object, object> _computeFunc;
/** */
- private readonly Func<object, Guid?, object, bool> _eventFilter;
+ private readonly Func<object, object, bool> _eventFilter;
/** */
private readonly Func<object, object, object, bool> _cacheEntryFilter;
@@ -100,7 +100,7 @@ namespace Apache.Ignite.Core.Impl.Common
/// </summary>
/// <param name="type">Type.</param>
/// <returns>Precompiled invocator delegate.</returns>
- public static Func<object, Guid?, object, bool> GetEventFilter(Type type)
+ public static Func<object, object, bool> GetEventFilter(Type type)
{
return Get(type)._eventFilter;
}
@@ -245,8 +245,8 @@ namespace Apache.Ignite.Core.Impl.Common
var args = iface.GetGenericArguments();
- _eventFilter = DelegateConverter.CompileFunc<Func<object, Guid?, object, bool>>(iface,
- new[] {typeof (Guid?), args[0]}, new[] {false, true, false});
+ _eventFilter = DelegateConverter.CompileFunc<Func<object, object, bool>>(iface,
+ new[] {args[0]}, new[] {true, false});
}
else if (genericTypeDefinition == typeof (ICacheEntryFilter<,>))
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/91eeab7a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
index 08936e4..6898a58 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
@@ -148,7 +148,7 @@ namespace Apache.Ignite.Core.Impl.Events
if (localListener != null)
{
- var listener = new RemoteListenEventFilter(Ignite, (id, e) => localListener.Invoke(id, (T) e));
+ var listener = new RemoteListenEventFilter(Ignite, e => localListener.Invoke((T) e));
writer.WriteLong(Ignite.HandleRegistry.Allocate(listener));
}
@@ -230,11 +230,11 @@ namespace Apache.Ignite.Core.Impl.Events
/** <inheritDoc /> */
public void RecordLocal(IEvent evt)
{
- throw new NotImplementedException("GG-10244");
+ throw new NotImplementedException("IGNITE-1410");
}
/** <inheritDoc /> */
- public void LocalListen<T>(IEventFilter<T> listener, params int[] types) where T : IEvent
+ public void LocalListen<T>(IEventListener<T> listener, params int[] types) where T : IEvent
{
IgniteArgumentCheck.NotNull(listener, "listener");
IgniteArgumentCheck.NotNullOrEmpty(types, "types");
@@ -244,13 +244,13 @@ namespace Apache.Ignite.Core.Impl.Events
}
/** <inheritDoc /> */
- public void LocalListen<T>(IEventFilter<T> listener, IEnumerable<int> types) where T : IEvent
+ public void LocalListen<T>(IEventListener<T> listener, IEnumerable<int> types) where T : IEvent
{
LocalListen(listener, TypesToArray(types));
}
/** <inheritDoc /> */
- public bool StopLocalListen<T>(IEventFilter<T> listener, params int[] types) where T : IEvent
+ public bool StopLocalListen<T>(IEventListener<T> listener, params int[] types) where T : IEvent
{
lock (_localFilters)
{
@@ -271,7 +271,7 @@ namespace Apache.Ignite.Core.Impl.Events
}
/** <inheritDoc /> */
- public bool StopLocalListen<T>(IEventFilter<T> listener, IEnumerable<int> types) where T : IEvent
+ public bool StopLocalListen<T>(IEventListener<T> listener, IEnumerable<int> types) where T : IEvent
{
return StopLocalListen(listener, TypesToArray(types));
}
@@ -415,7 +415,7 @@ namespace Apache.Ignite.Core.Impl.Events
/// <typeparam name="T">Type of events.</typeparam>
/// <param name="listener">Predicate that is called on each received event.</param>
/// <param name="type">Event type for which this listener will be notified</param>
- private void LocalListen<T>(IEventFilter<T> listener, int type) where T : IEvent
+ private void LocalListen<T>(IEventListener<T> listener, int type) where T : IEvent
{
lock (_localFilters)
{
@@ -432,7 +432,7 @@ namespace Apache.Ignite.Core.Impl.Events
if (!filters.TryGetValue(type, out localFilter))
{
- localFilter = CreateLocalFilter(listener, type);
+ localFilter = CreateLocalListener(listener, type);
filters[type] = localFilter;
}
@@ -448,10 +448,10 @@ namespace Apache.Ignite.Core.Impl.Events
/// <param name="listener">Listener.</param>
/// <param name="type">Event type.</param>
/// <returns>Created wrapper.</returns>
- private LocalHandledEventFilter CreateLocalFilter<T>(IEventFilter<T> listener, int type) where T : IEvent
+ private LocalHandledEventFilter CreateLocalListener<T>(IEventListener<T> listener, int type) where T : IEvent
{
var result = new LocalHandledEventFilter(
- stream => InvokeLocalFilter(stream, listener),
+ stream => InvokeLocalListener(stream, listener),
unused =>
{
lock (_localFilters)
@@ -484,8 +484,21 @@ namespace Apache.Ignite.Core.Impl.Events
{
var evt = EventReader.Read<T>(Marshaller.StartUnmarshal(stream));
- // No guid in local mode
- return listener.Invoke(Guid.Empty, evt);
+ return listener.Invoke(evt);
+ }
+
+ /// <summary>
+ /// Invokes local filter using data from specified stream.
+ /// </summary>
+ /// <typeparam name="T">Event object type.</typeparam>
+ /// <param name="stream">The stream.</param>
+ /// <param name="listener">The listener.</param>
+ /// <returns>Filter invocation result.</returns>
+ private bool InvokeLocalListener<T>(IPortableStream stream, IEventListener<T> listener) where T : IEvent
+ {
+ var evt = EventReader.Read<T>(Marshaller.StartUnmarshal(stream));
+
+ return listener.Invoke(evt);
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/91eeab7a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
index ac50b35..f8e2f95 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
@@ -33,14 +33,14 @@ namespace Apache.Ignite.Core.Impl.Events
private readonly Ignite _ignite;
/** */
- private readonly Func<Guid?, IEvent, bool> _filter;
+ private readonly Func<IEvent, bool> _filter;
/// <summary>
/// Initializes a new instance of the <see cref="RemoteListenEventFilter"/> class.
/// </summary>
/// <param name="ignite">The grid.</param>
/// <param name="filter">The filter.</param>
- public RemoteListenEventFilter(Ignite ignite, Func<Guid?, IEvent, bool> filter)
+ public RemoteListenEventFilter(Ignite ignite, Func<IEvent, bool> filter)
{
_ignite = ignite;
_filter = filter;
@@ -53,9 +53,9 @@ namespace Apache.Ignite.Core.Impl.Events
var evt = EventReader.Read<IEvent>(reader);
- var nodeId = reader.ReadGuid();
+ reader.ReadGuid(); // unused node id
- return _filter(nodeId, evt) ? 1 : 0;
+ return _filter(evt) ? 1 : 0;
}
/// <summary>
@@ -78,7 +78,7 @@ namespace Apache.Ignite.Core.Impl.Events
var func = DelegateTypeDescriptor.GetEventFilter(pred.GetType());
- return new RemoteListenEventFilter(grid, (id, evt) => func(pred, id, evt));
+ return new RemoteListenEventFilter(grid, evt => func(pred, evt));
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/91eeab7a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
index c1f3035..f9d54b9 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
@@ -71,24 +71,6 @@ namespace Apache.Ignite.Examples.Events
Console.WriteLine(">>> Received events count: " + listener.EventsReceived);
Console.WriteLine();
-
- // Remote listen example (start standalone nodes for better demonstration)
- Console.WriteLine(">>> Listening for remote events...");
-
- var localListener = new LocalListener();
- var remoteFilter = new RemoteFilter();
-
- var listenId = ignite.GetEvents().RemoteListen(localListener: localListener,
- remoteFilter: remoteFilter, types: EventType.JobExecutionAll);
-
- if (listenId == null)
- throw new InvalidOperationException("Subscription failed.");
-
- ExecuteTask(ignite);
-
- ignite.GetEvents().StopRemoteListen(listenId.Value);
-
- Console.WriteLine(">>> Received events count: " + localListener.EventsReceived);
}
Console.WriteLine();
http://git-wip-us.apache.org/repos/asf/ignite/blob/91eeab7a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
index d579a77..441e4e0 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
@@ -49,7 +49,6 @@
<Compile Include="Datagrid\ContinuousQueryFilter.cs" />
<Compile Include="Datagrid\EmployeeStore.cs" />
<Compile Include="Events\LocalListener.cs" />
- <Compile Include="Events\RemoteFilter.cs" />
<Compile Include="Messaging\LocalListener.cs" />
<Compile Include="Messaging\RemoteOrderedListener.cs" />
<Compile Include="Messaging\RemoteUnorderedListener.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/91eeab7a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
index 067bd2a..8c689dc 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
@@ -24,7 +24,7 @@ namespace Apache.Ignite.ExamplesDll.Events
/// <summary>
/// Local event listener.
/// </summary>
- public class LocalListener : IEventFilter<IEvent>
+ public class LocalListener : IEventListener<IEvent>
{
/** Сount of received events. */
private int _eventsReceived;
@@ -40,10 +40,9 @@ namespace Apache.Ignite.ExamplesDll.Events
/// <summary>
/// Determines whether specified event passes this filter.
/// </summary>
- /// <param name="nodeId">Node identifier.</param>
/// <param name="evt">Event.</param>
/// <returns>Value indicating whether specified event passes this filter.</returns>
- public bool Invoke(Guid? nodeId, IEvent evt)
+ public bool Invoke(IEvent evt)
{
Interlocked.Increment(ref _eventsReceived);
http://git-wip-us.apache.org/repos/asf/ignite/blob/91eeab7a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs
deleted file mode 100644
index 45a957c..0000000
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using Apache.Ignite.Core.Events;
-
-namespace Apache.Ignite.ExamplesDll.Events
-{
- /// <summary>
- /// Remote event filter.
- /// </summary>
- [Serializable]
- public class RemoteFilter : IEventFilter<IEvent>
- {
- /// <summary>
- /// Determines whether specified event passes this filter.
- /// </summary>
- /// <param name="nodeId">Node identifier.</param>
- /// <param name="evt">Event.</param>
- /// <returns>Value indicating whether specified event passes this filter.</returns>
- public bool Invoke(Guid? nodeId, IEvent evt)
- {
- Console.WriteLine("Remote filter received event [evt={0}]", evt.Name);
-
- return evt is JobEvent;
- }
- }
-}
\ No newline at end of file
[30/50] [abbrv] ignite git commit: Merge remote-tracking branch
'apache/master'
Posted by vo...@apache.org.
Merge remote-tracking branch 'apache/master'
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/43b40f4c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/43b40f4c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/43b40f4c
Branch: refs/heads/ignite-1651
Commit: 43b40f4c405eac860b75c0648a0656dbb12eec92
Parents: 6ffd5ce f619e09
Author: ashutak <as...@gridgain.com>
Authored: Tue Oct 20 15:56:50 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Tue Oct 20 15:56:50 2015 +0300
----------------------------------------------------------------------
.../ignite/internal/processors/igfs/IgfsMetaManager.java | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
[20/50] [abbrv] ignite git commit: ignite-1698 - test
Posted by vo...@apache.org.
ignite-1698 - test
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bc6bf5fc
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bc6bf5fc
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bc6bf5fc
Branch: refs/heads/ignite-1651
Commit: bc6bf5fcd2c6fd996c3f3d2b1731afed26338091
Parents: 7d3621b
Author: S.Vladykin <sv...@gridgain.com>
Authored: Sat Oct 17 18:53:16 2015 +0300
Committer: S.Vladykin <sv...@gridgain.com>
Committed: Sat Oct 17 18:53:16 2015 +0300
----------------------------------------------------------------------
.../ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java | 4 ++++
.../apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java | 2 ++
2 files changed, 6 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/bc6bf5fc/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
index 7b1c87c..a8c8388 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
@@ -21,6 +21,7 @@ import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.query.QueryCursor;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
@@ -102,6 +103,9 @@ public class SqlFieldsQuerySelfTest extends GridCommonAbstractTest {
private IgniteCache<Integer, Person> createAndFillCache() {
CacheConfiguration<Integer, Person> cacheConf = new CacheConfiguration<>();
+ cacheConf.setCacheMode(CacheMode.PARTITIONED);
+ cacheConf.setBackups(0);
+
cacheConf.setIndexedTypes(Integer.class, Person.class);
cacheConf.setName("person");
http://git-wip-us.apache.org/repos/asf/ignite/blob/bc6bf5fc/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
index fe54b63..6cb1a52 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
@@ -45,6 +45,7 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheQueryMultiThreaded
import org.apache.ignite.internal.processors.cache.IgniteCacheQueryOffheapEvictsMultiThreadedSelfTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheQueryOffheapMultiThreadedSelfTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheSqlQueryMultiThreadedSelfTest;
+import org.apache.ignite.internal.processors.cache.SqlFieldsQuerySelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicFieldsQuerySelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicNearEnabledFieldsQuerySelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicNearEnabledQuerySelfTest;
@@ -137,6 +138,7 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
suite.addTestSuite(CacheScanPartitionQueryFallbackSelfTest.class);
// Fields queries.
+ suite.addTestSuite(SqlFieldsQuerySelfTest.class);
suite.addTestSuite(IgniteCacheLocalFieldsQuerySelfTest.class);
suite.addTestSuite(IgniteCacheReplicatedFieldsQuerySelfTest.class);
suite.addTestSuite(IgniteCacheReplicatedFieldsQueryP2PEnabledSelfTest.class);
[32/50] [abbrv] ignite git commit: IGNITE-1645: Throw exception on
null flag in PortableReader when reading non-nullable value types.
Posted by vo...@apache.org.
IGNITE-1645: Throw exception on null flag in PortableReader when reading non-nullable value types.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2ed4794f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2ed4794f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2ed4794f
Branch: refs/heads/ignite-1651
Commit: 2ed4794f7aeae28bdd51662a810309f1156090d9
Parents: 2730097
Author: thatcoach <pp...@list.ru>
Authored: Tue Oct 20 16:56:44 2015 +0300
Committer: thatcoach <pp...@list.ru>
Committed: Tue Oct 20 16:56:44 2015 +0300
----------------------------------------------------------------------
.../Cache/CacheAbstractTest.cs | 159 +++++++++------
.../Cache/CacheTestAsyncWrapper.cs | 35 +++-
.../Dataload/DataStreamerTest.cs | 6 +-
.../Apache.Ignite.Core.csproj | 1 +
.../Apache.Ignite.Core/Cache/CacheResult.cs | 98 +++++++++
.../dotnet/Apache.Ignite.Core/Cache/ICache.cs | 62 +++++-
.../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 204 ++++++++++++++++---
.../Apache.Ignite.Core/Impl/Cache/CacheOp.cs | 1 +
.../Impl/Cache/CacheProxyImpl.cs | 33 ++-
.../Apache.Ignite.Core/Impl/Common/Future.cs | 16 +-
.../Impl/Common/FutureConverter.cs | 4 +-
.../Impl/Common/IFutureConverter.cs | 1 +
.../Apache.Ignite.Core/Impl/PlatformTarget.cs | 1 +
.../Impl/Portable/PortableReaderImpl.cs | 4 +
14 files changed, 503 insertions(+), 122 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2ed4794f/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 964f4e8..94ec2d6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
@@ -487,11 +487,15 @@ namespace Apache.Ignite.Core.Tests.Cache
cache.Put(key1, 1);
+ int val;
+
Assert.AreEqual(1, cache.LocalPeek(key1));
- Assert.AreEqual(0, cache.LocalPeek(-1));
+ Assert.Throws<KeyNotFoundException>(() => cache.LocalPeek(-1));
+ Assert.IsFalse(cache.TryLocalPeek(-1, out val));
Assert.AreEqual(1, cache.LocalPeek(key1, CachePeekMode.All));
- Assert.AreEqual(0, cache.LocalPeek(-1, CachePeekMode.All));
+ Assert.Throws<KeyNotFoundException>(() => cache.LocalPeek(-1, CachePeekMode.All));
+ Assert.AreEqual(false, cache.TryLocalPeek(-1, out val, CachePeekMode.All));
}
[Test]
@@ -504,7 +508,19 @@ namespace Apache.Ignite.Core.Tests.Cache
Assert.AreEqual(1, cache.Get(1));
Assert.AreEqual(2, cache.Get(2));
- Assert.AreEqual(0, cache.Get(3));
+
+ Assert.Throws<KeyNotFoundException>(() => cache.Get(3));
+
+ int value;
+
+ Assert.IsTrue(cache.TryGet(1, out value));
+ Assert.AreEqual(1, value);
+
+ Assert.IsTrue(cache.TryGet(2, out value));
+ Assert.AreEqual(2, value);
+
+ Assert.IsFalse(cache.TryGet(3, out value));
+ Assert.AreEqual(0, value);
}
[Test]
@@ -517,7 +533,8 @@ namespace Apache.Ignite.Core.Tests.Cache
Assert.AreEqual(1, cache.Get(1));
Assert.AreEqual(2, cache.Get(2));
- Assert.AreEqual(0, cache.Get(3));
+ Assert.IsFalse(cache.ContainsKey(3));
+ Assert.Throws<KeyNotFoundException>(() => cache.Get(3));
}
[Test]
@@ -561,17 +578,17 @@ namespace Apache.Ignite.Core.Tests.Cache
{
var cache = Cache();
- Assert.AreEqual(0, cache.Get(1));
+ Assert.AreEqual(false, cache.ContainsKey(1));
- int old = cache.GetAndPut(1, 1);
+ var old = cache.GetAndPut(1, 1);
- Assert.AreEqual(0, old);
+ Assert.IsFalse(old.Success);
Assert.AreEqual(1, cache.Get(1));
old = cache.GetAndPut(1, 2);
- Assert.AreEqual(1, old);
+ Assert.AreEqual(1, old.Value);
Assert.AreEqual(2, cache.Get(1));
}
@@ -583,11 +600,11 @@ namespace Apache.Ignite.Core.Tests.Cache
cache.Put(1, 10);
- Assert.AreEqual(10, cache.GetAndReplace(1, 100));
+ Assert.AreEqual(10, cache.GetAndReplace(1, 100).Value);
- Assert.AreEqual(0, cache.GetAndReplace(2, 2));
+ Assert.AreEqual(false, cache.GetAndReplace(2, 2).Success);
- Assert.AreEqual(0, cache.Get(2));
+ Assert.AreEqual(false, cache.ContainsKey(2));
Assert.AreEqual(100, cache.Get(1));
@@ -603,13 +620,13 @@ namespace Apache.Ignite.Core.Tests.Cache
Assert.AreEqual(1, cache.Get(1));
- Assert.AreEqual(0, cache.GetAndRemove(0));
-
- Assert.AreEqual(1, cache.GetAndRemove(1));
+ Assert.IsFalse(cache.GetAndRemove(0).Success);
- Assert.AreEqual(0, cache.GetAndRemove(1));
+ Assert.AreEqual(1, cache.GetAndRemove(1).Value);
+
+ Assert.IsFalse(cache.GetAndRemove(1).Success);
- Assert.AreEqual(0, cache.Get(1));
+ Assert.IsFalse(cache.ContainsKey(1));
}
[Test]
@@ -617,17 +634,17 @@ namespace Apache.Ignite.Core.Tests.Cache
{
var cache = Cache().WithAsync().WrapAsync();
- Assert.AreEqual(0, cache.Get(1));
+ Assert.AreEqual(false, cache.ContainsKey(1));
- int old = cache.GetAndPut(1, 1);
+ var old = cache.GetAndPut(1, 1);
- Assert.AreEqual(0, old);
+ Assert.IsFalse(old.Success);
Assert.AreEqual(1, cache.Get(1));
old = cache.GetAndPut(1, 2);
- Assert.AreEqual(1, old);
+ Assert.AreEqual(1, old.Value);
Assert.AreEqual(2, cache.Get(1));
}
@@ -657,7 +674,7 @@ namespace Apache.Ignite.Core.Tests.Cache
{
var cache = Cache();
- Assert.AreEqual(0, cache.Get(1));
+ Assert.IsFalse(cache.ContainsKey(1));
Assert.AreEqual(true, cache.PutIfAbsent(1, 1));
@@ -673,13 +690,13 @@ namespace Apache.Ignite.Core.Tests.Cache
{
var cache = Cache();
- Assert.AreEqual(0, cache.Get(1));
+ Assert.IsFalse(cache.ContainsKey(1));
- Assert.AreEqual(0, cache.GetAndPutIfAbsent(1, 1));
+ Assert.IsFalse(cache.GetAndPutIfAbsent(1, 1).Success);
Assert.AreEqual(1, cache.Get(1));
- Assert.AreEqual(1, cache.GetAndPutIfAbsent(1, 2));
+ Assert.AreEqual(1, cache.GetAndPutIfAbsent(1, 2).Value);
Assert.AreEqual(1, cache.Get(1));
}
@@ -689,17 +706,17 @@ namespace Apache.Ignite.Core.Tests.Cache
{
var cache = Cache().WithAsync().WrapAsync();
- Assert.AreEqual(0, cache.Get(1));
+ Assert.IsFalse(cache.ContainsKey(1));
- int old = cache.GetAndPutIfAbsent(1, 1);
+ var old = cache.GetAndPutIfAbsent(1, 1);
- Assert.AreEqual(0, old);
+ Assert.IsFalse(old.Success);
Assert.AreEqual(1, cache.Get(1));
old = cache.GetAndPutIfAbsent(1, 2);
- Assert.AreEqual(1, old);
+ Assert.AreEqual(1, old.Value);
Assert.AreEqual(1, cache.Get(1));
}
@@ -709,7 +726,8 @@ namespace Apache.Ignite.Core.Tests.Cache
{
var cache = Cache().WithAsync().WrapAsync();
- Assert.AreEqual(0, cache.Get(1));
+ Assert.Throws<KeyNotFoundException>(() => cache.Get(1));
+ Assert.IsFalse(cache.ContainsKey(1));
Assert.IsTrue(cache.PutIfAbsent(1, 1));
@@ -725,13 +743,13 @@ namespace Apache.Ignite.Core.Tests.Cache
{
var cache = Cache();
- Assert.AreEqual(0, cache.Get(1));
+ Assert.IsFalse(cache.ContainsKey(1));
bool success = cache.Replace(1, 1);
Assert.AreEqual(false, success);
- Assert.AreEqual(0, cache.Get(1));
+ Assert.IsFalse(cache.ContainsKey(1));
cache.Put(1, 1);
@@ -757,13 +775,13 @@ namespace Apache.Ignite.Core.Tests.Cache
{
var cache = Cache().WithAsync().WrapAsync();
- Assert.AreEqual(0, cache.Get(1));
+ Assert.IsFalse(cache.ContainsKey(1));
- int old = cache.GetAndReplace(1, 1);
+ var old = cache.GetAndReplace(1, 1);
- Assert.AreEqual(0, old);
+ Assert.IsFalse(old.Success);
- Assert.AreEqual(0, cache.Get(1));
+ Assert.IsFalse(cache.ContainsKey(1));
cache.Put(1, 1);
@@ -771,7 +789,7 @@ namespace Apache.Ignite.Core.Tests.Cache
old = cache.GetAndReplace(1, 2);
- Assert.AreEqual(1, old);
+ Assert.AreEqual(1, old.Value);
Assert.AreEqual(2, cache.Get(1));
@@ -789,11 +807,11 @@ namespace Apache.Ignite.Core.Tests.Cache
{
var cache = Cache();
- Assert.AreEqual(0, cache.Get(1));
+ Assert.IsFalse(cache.ContainsKey(1));
Assert.IsFalse(cache.Replace(1, 1));
- Assert.AreEqual(0, cache.Get(1));
+ Assert.IsFalse(cache.ContainsKey(1));
cache.Put(1, 1);
@@ -809,11 +827,11 @@ namespace Apache.Ignite.Core.Tests.Cache
{
var cache = Cache().WithAsync().WrapAsync();
- Assert.AreEqual(0, cache.Get(1));
+ Assert.IsFalse(cache.ContainsKey(1));
Assert.IsFalse(cache.Replace(1, 1));
- Assert.AreEqual(0, cache.Get(1));
+ Assert.IsFalse(cache.ContainsKey(1));
cache.Put(1, 1);
@@ -1092,7 +1110,8 @@ namespace Apache.Ignite.Core.Tests.Cache
{
cache.Clear(key);
- Assert.AreEqual(0, cache.Get(key));
+ Assert.IsFalse(cache.ContainsKey(key));
+ Assert.Throws<KeyNotFoundException>(() => cache.Get(key));
Assert.Less(cache.GetSize(), i);
@@ -1111,8 +1130,7 @@ namespace Apache.Ignite.Core.Tests.Cache
cache.ClearAll(keys);
- foreach (var key in keys)
- Assert.AreEqual(0, cache.Get(key));
+ Assert.IsFalse(cache.ContainsKeys(keys));
}
[Test]
@@ -1130,7 +1148,8 @@ namespace Apache.Ignite.Core.Tests.Cache
{
cache.LocalClear(key);
- Assert.AreEqual(0, cache.LocalPeek(key));
+ int val;
+ Assert.IsFalse(cache.TryLocalPeek(key, out val));
Assert.Less(cache.GetSize(), i);
@@ -1151,8 +1170,10 @@ namespace Apache.Ignite.Core.Tests.Cache
cache.LocalClearAll(keys);
+ int val;
+
foreach (var key in keys)
- Assert.AreEqual(0, cache.LocalPeek(key));
+ Assert.IsFalse(cache.TryLocalPeek(key, out val));
cache.Clear();
}
@@ -1170,7 +1191,7 @@ namespace Apache.Ignite.Core.Tests.Cache
Assert.AreEqual(0, cache.GetSize());
- Assert.AreEqual(0, cache.Get(1));
+ Assert.IsFalse(cache.ContainsKey(1));
cache.Put(1, 1);
@@ -1181,7 +1202,7 @@ namespace Apache.Ignite.Core.Tests.Cache
Assert.AreEqual(0, cache.GetSize());
- Assert.AreEqual(0, cache.Get(1));
+ Assert.IsFalse(cache.ContainsKey(1));
}
[Test]
@@ -1193,11 +1214,11 @@ namespace Apache.Ignite.Core.Tests.Cache
Assert.AreEqual(1, cache.Get(1));
- Assert.AreEqual(1, cache.GetAndRemove(1));
+ Assert.AreEqual(1, cache.GetAndRemove(1).Value);
Assert.AreEqual(0, cache.GetSize());
- Assert.AreEqual(0, cache.Get(1));
+ Assert.IsFalse(cache.ContainsKey(1));
cache.Put(1, 1);
@@ -1208,7 +1229,7 @@ namespace Apache.Ignite.Core.Tests.Cache
Assert.AreEqual(0, cache.GetSize());
- Assert.AreEqual(0, cache.Get(1));
+ Assert.IsFalse(cache.ContainsKey(1));
}
[Test]
@@ -1225,7 +1246,7 @@ namespace Apache.Ignite.Core.Tests.Cache
Assert.AreEqual(0, cache.GetSize());
- Assert.AreEqual(0, cache.Get(1));
+ Assert.IsFalse(cache.ContainsKey(1));
}
[Test]
@@ -1242,7 +1263,7 @@ namespace Apache.Ignite.Core.Tests.Cache
Assert.AreEqual(0, cache.GetSize());
- Assert.AreEqual(0, cache.Get(1));
+ Assert.IsFalse(cache.ContainsKey(1));
}
[Test]
@@ -1250,7 +1271,7 @@ namespace Apache.Ignite.Core.Tests.Cache
{
var cache = Cache();
- List<int> keys = PrimaryKeysForCache(cache, 2);
+ var keys = PrimaryKeysForCache(cache, 2);
cache.Put(keys[0], 1);
cache.Put(keys[1], 2);
@@ -1262,8 +1283,7 @@ namespace Apache.Ignite.Core.Tests.Cache
Assert.AreEqual(0, cache.GetSize());
- Assert.AreEqual(0, cache.Get(keys[0]));
- Assert.AreEqual(0, cache.Get(keys[1]));
+ Assert.IsFalse(cache.ContainsKeys(keys));
}
[Test]
@@ -1283,8 +1303,7 @@ namespace Apache.Ignite.Core.Tests.Cache
Assert.AreEqual(0, cache.GetSize());
- Assert.AreEqual(0, cache.Get(keys[0]));
- Assert.AreEqual(0, cache.Get(keys[1]));
+ Assert.IsFalse(cache.ContainsKeys(keys));
}
[Test]
@@ -1306,8 +1325,7 @@ namespace Apache.Ignite.Core.Tests.Cache
Assert.AreEqual(1, cache.GetSize(CachePeekMode.Primary));
- Assert.AreEqual(0, cache.Get(1));
- Assert.AreEqual(0, cache.Get(2));
+ Assert.IsFalse(cache.ContainsKeys(new[] {1, 2}));
Assert.AreEqual(3, cache.Get(3));
}
@@ -1330,8 +1348,7 @@ namespace Apache.Ignite.Core.Tests.Cache
Assert.AreEqual(1, cache.GetSize(CachePeekMode.Primary));
- Assert.AreEqual(0, cache.Get(1));
- Assert.AreEqual(0, cache.Get(2));
+ Assert.IsFalse(cache.ContainsKeys(new[] {1, 2}));
Assert.AreEqual(3, cache.Get(3));
}
@@ -2860,7 +2877,7 @@ namespace Apache.Ignite.Core.Tests.Cache
// Remove entry
Assert.AreEqual(0, cache.Invoke(key, new T {Remove = true}, arg));
- Assert.AreEqual(0, cache.Get(key));
+ Assert.AreEqual(false, cache.ContainsKey(key));
// Test exceptions
AssertThrowsCacheEntryProcessorException(() => cache.Invoke(key, new T {ThrowErr = true}, arg));
@@ -3079,6 +3096,18 @@ namespace Apache.Ignite.Core.Tests.Cache
Assert.AreEqual(10, cache1.Get(1));
}
+ [Test]
+ public void TestIndexer()
+ {
+ var cache = Cache();
+
+ Assert.Throws<KeyNotFoundException>(() => Console.WriteLine(cache[0])); // missing key throws
+
+ cache[1] = 5;
+
+ Assert.AreEqual(5, cache[1]);
+ }
+
private void TestKeepPortableFlag(bool async)
{
var cache0 = async ? Cache().WithAsync().WrapAsync() : Cache();
@@ -3246,7 +3275,11 @@ namespace Apache.Ignite.Core.Tests.Cache
private static int PeekInt(ICache<int, int> cache, int key)
{
- return cache.LocalPeek(key, CachePeekMode.Onheap);
+ int val;
+
+ cache.TryLocalPeek(key, out val, CachePeekMode.Onheap);
+
+ return val;
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2ed4794f/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 c4e8d7e..1b5321c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
@@ -149,6 +149,19 @@ namespace Apache.Ignite.Core.Tests.Cache
}
/** <inheritDoc /> */
+ public bool TryLocalPeek(TK key, out TV value, params CachePeekMode[] modes)
+ {
+ return _cache.TryLocalPeek(key, out value, modes);
+ }
+
+ /** <inheritDoc /> */
+ public TV this[TK key]
+ {
+ get { return _cache[key]; }
+ set { _cache[key] = value; }
+ }
+
+ /** <inheritDoc /> */
public TV Get(TK key)
{
_cache.Get(key);
@@ -156,6 +169,12 @@ namespace Apache.Ignite.Core.Tests.Cache
}
/** <inheritDoc /> */
+ public bool TryGet(TK key, out TV value)
+ {
+ return _cache.TryGet(key, out value);
+ }
+
+ /** <inheritDoc /> */
public IDictionary<TK, TV> GetAll(IEnumerable<TK> keys)
{
_cache.GetAll(keys);
@@ -170,24 +189,24 @@ namespace Apache.Ignite.Core.Tests.Cache
}
/** <inheritDoc /> */
- public TV GetAndPut(TK key, TV val)
+ public CacheResult<TV> GetAndPut(TK key, TV val)
{
_cache.GetAndPut(key, val);
- return GetResult<TV>();
+ return GetResult<CacheResult<TV>>();
}
/** <inheritDoc /> */
- public TV GetAndReplace(TK key, TV val)
+ public CacheResult<TV> GetAndReplace(TK key, TV val)
{
_cache.GetAndReplace(key, val);
- return GetResult<TV>();
+ return GetResult<CacheResult<TV>>();
}
/** <inheritDoc /> */
- public TV GetAndRemove(TK key)
+ public CacheResult<TV> GetAndRemove(TK key)
{
_cache.GetAndRemove(key);
- return GetResult<TV>();
+ return GetResult<CacheResult<TV>>();
}
/** <inheritDoc /> */
@@ -198,10 +217,10 @@ namespace Apache.Ignite.Core.Tests.Cache
}
/** <inheritDoc /> */
- public TV GetAndPutIfAbsent(TK key, TV val)
+ public CacheResult<TV> GetAndPutIfAbsent(TK key, TV val)
{
_cache.GetAndPutIfAbsent(key, val);
- return GetResult<TV>();
+ return GetResult<CacheResult<TV>>();
}
/** <inheritDoc /> */
http://git-wip-us.apache.org/repos/asf/ignite/blob/2ed4794f/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 0195f19..bad2cf7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
@@ -143,7 +143,7 @@ namespace Apache.Ignite.Core.Tests.Dataload
// Removal.
ldr.RemoveData(1);
ldr.Flush();
- Assert.IsNull(_cache.Get(1));
+ Assert.IsFalse(_cache.ContainsKey(1));
// Mixed.
ldr.AddData(5, 5);
@@ -159,7 +159,7 @@ namespace Apache.Ignite.Core.Tests.Dataload
ldr.Flush();
for (int i = 2; i < 5; i++)
- Assert.IsNull(_cache.Get(i));
+ Assert.IsFalse(_cache.ContainsKey(i));
for (int i = 5; i < 13; i++)
Assert.AreEqual(i, _cache.Get(i));
@@ -257,7 +257,7 @@ namespace Apache.Ignite.Core.Tests.Dataload
fut.Get();
- Assert.IsNull(_cache.Get(1));
+ Assert.IsFalse(_cache.ContainsKey(1));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2ed4794f/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 401b46c..9bcb41a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -68,6 +68,7 @@
<Compile Include="Cache\ICacheEntryProcessorResult.cs" />
<Compile Include="Cache\ICacheLock.cs" />
<Compile Include="Cache\ICacheMetrics.cs" />
+ <Compile Include="Cache\CacheResult.cs" />
<Compile Include="Cache\IMutableCacheEntry.cs" />
<Compile Include="Cache\Query\Continuous\ContinuousQuery.cs" />
<Compile Include="Cache\Query\Continuous\IContinuousQueryHandle.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/2ed4794f/modules/platforms/dotnet/Apache.Ignite.Core/Cache/CacheResult.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/CacheResult.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/CacheResult.cs
new file mode 100644
index 0000000..75208cd
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/CacheResult.cs
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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
+{
+ using System;
+ using System.Collections.Generic;
+
+ /// <summary>
+ /// Represents a cache operation result with a success flag.
+ /// </summary>
+ /// <typeparam name="T">Operation result value type.</typeparam>
+ public struct CacheResult<T> : IEquatable<CacheResult<T>>
+ {
+ /** Value. */
+ private readonly T _value;
+
+ /** Success flag. */
+ private readonly bool _success;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="CacheResult{T}"/> struct with a specified value
+ /// and sets success flag to true.
+ /// </summary>
+ /// <param name="value">The value.</param>
+ public CacheResult(T value)
+ {
+ _value = value;
+ _success = true;
+ }
+
+ /// <summary>
+ /// Gets the cache value.
+ /// </summary>
+ public T Value
+ {
+ get { return _value; }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether the operation completed successfully.
+ /// </summary>
+ public bool Success
+ {
+ get { return _success; }
+ }
+
+ /** <inehritdoc /> */
+ public bool Equals(CacheResult<T> other)
+ {
+ return EqualityComparer<T>.Default.Equals(_value, other._value) && _success == other._success;
+ }
+
+ /** <inehritdoc /> */
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj))
+ return false;
+
+ return obj is CacheResult<T> && Equals((CacheResult<T>) obj);
+ }
+
+ /** <inehritdoc /> */
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return (EqualityComparer<T>.Default.GetHashCode(_value) * 397) ^ _success.GetHashCode();
+ }
+ }
+
+ /** <inehritdoc /> */
+ public static bool operator ==(CacheResult<T> left, CacheResult<T> right)
+ {
+ return left.Equals(right);
+ }
+
+ /** <inehritdoc /> */
+ public static bool operator !=(CacheResult<T> left, CacheResult<T> right)
+ {
+ return !left.Equals(right);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2ed4794f/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 98ac254..204c56c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
@@ -153,6 +153,7 @@ namespace Apache.Ignite.Core.Cache
/// non-null value is found, it will be immediately returned.
/// This method does not participate in any transactions, however, it may peek at transactional
/// value depending on the peek modes used.
+ /// If key is not present in cache, KeyNotFoundException will be thrown.
/// </summary>
/// <param name="key">Key.</param>
/// <param name="modes">Peek modes.</param>
@@ -160,11 +161,38 @@ namespace Apache.Ignite.Core.Cache
TV LocalPeek(TK key, params CachePeekMode[] modes);
/// <summary>
- /// Retrieves value mapped to the specified key from cache.
+ /// Peeks at cached value using optional set of peek modes. This method will sequentially
+ /// iterate over given peek modes, and try to peek at value using each peek mode. Once a
+ /// non-null value is found, it will be immediately returned.
+ /// This method does not participate in any transactions, however, it may peek at transactional
+ /// value depending on the peek modes used.
+ /// </summary>
+ /// <param name="key">Key.</param>
+ /// <param name="value">When this method returns, the value associated with the specified key,
+ /// if the key is found; otherwise, the default value for the type of the value parameter.
+ /// This parameter is passed uninitialized.</param>
+ /// <param name="modes">Peek modes.</param>
+ /// <returns>
+ /// true if the cache contains an element with the specified key; otherwise, false.
+ /// </returns>
+ bool TryLocalPeek(TK key, out TV value, params CachePeekMode[] modes);
+
+ /// <summary>
+ /// Gets or sets a cache value with the specified key.
+ /// Shortcut to <see cref="Get"/> and <see cref="Put"/>
+ /// </summary>
+ /// <param name="key">Key.</param>
+ /// <returns>Cache value with the specified key.</returns>
+ TV this[TK key] { get; set; }
+
+ /// <summary>
+ /// Retrieves value mapped to the specified key from cache. Throws an exception if t
+ ///
/// If the value is not present in cache, then it will be looked up from swap storage. If
/// it's not present in swap, or if swap is disable, and if read-through is allowed, value
/// will be loaded from persistent store.
/// This method is transactional and will enlist the entry into ongoing transaction if there is one.
+ /// If key is not present in cache, KeyNotFoundException will be thrown.
/// </summary>
/// <param name="key">Key.</param>
/// <returns>Value.</returns>
@@ -172,6 +200,22 @@ namespace Apache.Ignite.Core.Cache
TV Get(TK key);
/// <summary>
+ /// Retrieves value mapped to the specified key from cache.
+ /// If the value is not present in cache, then it will be looked up from swap storage. If
+ /// it's not present in swap, or if swap is disable, and if read-through is allowed, value
+ /// will be loaded from persistent store.
+ /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
+ /// </summary>
+ /// <param name="key">Key.</param>
+ /// <param name="value">When this method returns, the value associated with the specified key,
+ /// if the key is found; otherwise, the default value for the type of the value parameter.
+ /// This parameter is passed uninitialized.</param>
+ /// <returns>
+ /// true if the cache contains an element with the specified key; otherwise, false.
+ /// </returns>
+ bool TryGet(TK key, out TV value);
+
+ /// <summary>
/// Retrieves values mapped to the specified keys from cache.
/// If some value is not present in cache, then it will be looked up from swap storage. If
/// it's not present in swap, or if swap is disabled, and if read-through is allowed, value
@@ -201,10 +245,10 @@ namespace Apache.Ignite.Core.Cache
/// <param name="key">Key with which the specified value is to be associated.</param>
/// <param name="val">Value to be associated with the specified key.</param>
/// <returns>
- /// The value associated with the key at the start of the operation or null if none was associated.
+ /// The value associated with the key at the start of the operation.
/// </returns>
[AsyncSupported]
- TV GetAndPut(TK key, TV val);
+ CacheResult<TV> GetAndPut(TK key, TV val);
/// <summary>
/// Atomically replaces the value for a given key if and only if there is a value currently mapped by the key.
@@ -212,18 +256,18 @@ namespace Apache.Ignite.Core.Cache
/// <param name="key">Key with which the specified value is to be associated.</param>
/// <param name="val">Value to be associated with the specified key.</param>
/// <returns>
- /// The previous value associated with the specified key, or null if there was no mapping for the key.
+ /// The previous value associated with the specified key.
/// </returns>
[AsyncSupported]
- TV GetAndReplace(TK key, TV val);
+ CacheResult<TV> GetAndReplace(TK key, TV val);
/// <summary>
/// Atomically removes the entry for a key only if currently mapped to some value.
/// </summary>
/// <param name="key">Key with which the specified value is associated.</param>
- /// <returns>The value if one existed or null if no mapping existed for this key.</returns>
+ /// <returns>The value if one existed.</returns>
[AsyncSupported]
- TV GetAndRemove(TK key);
+ CacheResult<TV> GetAndRemove(TK key);
/// <summary>
/// Atomically associates the specified key with the given value if it is not already associated with a value.
@@ -248,10 +292,10 @@ namespace Apache.Ignite.Core.Cache
/// <param name="key">Key to store in cache.</param>
/// <param name="val">Value to be associated with the given key.</param>
/// <returns>
- /// Previously contained value regardless of whether put happened or not (null if there was no previous value).
+ /// Previously contained value regardless of whether put happened or not.
/// </returns>
[AsyncSupported]
- TV GetAndPutIfAbsent(TK key, TV val);
+ CacheResult<TV> GetAndPutIfAbsent(TK key, TV val);
/// <summary>
/// Stores given key-value pair in cache only if there is a previous mapping for it.
http://git-wip-us.apache.org/repos/asf/ignite/blob/2ed4794f/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 dcecc52..5a01006 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
@@ -20,6 +20,7 @@ namespace Apache.Ignite.Core.Impl.Cache
using System;
using System.Collections;
using System.Collections.Generic;
+ using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using Apache.Ignite.Core.Cache;
@@ -124,22 +125,22 @@ namespace Apache.Ignite.Core.Impl.Cache
/// <summary>
/// Gets and resets future for previous asynchronous operation.
/// </summary>
- /// <param name="lastAsyncOpId">The last async op id.</param>
+ /// <param name="lastAsyncOp">The last async op id.</param>
/// <returns>
/// Future for previous asynchronous operation.
/// </returns>
/// <exception cref="System.InvalidOperationException">Asynchronous mode is disabled</exception>
- internal IFuture<TResult> GetFuture<TResult>(int lastAsyncOpId)
+ internal IFuture<TResult> GetFuture<TResult>(CacheOp lastAsyncOp)
{
if (!_flagAsync)
throw IgniteUtils.GetAsyncModeDisabledException();
- var converter = GetFutureResultConverter<TResult>(lastAsyncOpId);
+ var converter = GetFutureResultConverter<TResult>(lastAsyncOp);
_invokeAllConverter.Value = null;
- return GetFuture((futId, futTypeId) => UU.TargetListenFutureForOperation(Target, futId, futTypeId, lastAsyncOpId),
- _flagKeepPortable, converter);
+ return GetFuture((futId, futTypeId) => UU.TargetListenFutureForOperation(Target, futId, futTypeId,
+ (int) lastAsyncOp), _flagKeepPortable, converter);
}
/** <inheritDoc /> */
@@ -290,11 +291,47 @@ namespace Apache.Ignite.Core.Impl.Cache
{
IgniteArgumentCheck.NotNull(key, "key");
- return DoOutInOp<TV>((int)CacheOp.Peek, writer =>
+ TV res;
+
+ if (TryLocalPeek(key, out res))
+ return res;
+
+ throw GetKeyNotFoundException();
+ }
+
+ /** <inheritDoc /> */
+ public bool TryLocalPeek(TK key, out TV value, params CachePeekMode[] modes)
+ {
+ IgniteArgumentCheck.NotNull(key, "key");
+
+ var res = DoOutInOpNullable<TV>((int)CacheOp.Peek, writer =>
{
writer.Write(key);
writer.WriteInt(EncodePeekModes(modes));
});
+
+ value = res.Success ? res.Value : default(TV);
+
+ return res.Success;
+ }
+
+ /** <inheritDoc /> */
+ public TV this[TK key]
+ {
+ get
+ {
+ if (IsAsync)
+ throw new InvalidOperationException("Indexer can't be used in async mode.");
+
+ return Get(key);
+ }
+ set
+ {
+ if (IsAsync)
+ throw new InvalidOperationException("Indexer can't be used in async mode.");
+
+ Put(key, value);
+ }
}
/** <inheritDoc /> */
@@ -302,7 +339,34 @@ namespace Apache.Ignite.Core.Impl.Cache
{
IgniteArgumentCheck.NotNull(key, "key");
- return DoOutInOp<TK, TV>((int)CacheOp.Get, key);
+ var result = DoOutInOpNullable<TK, TV>((int) CacheOp.Get, key);
+
+ if (!IsAsync)
+ {
+ if (!result.Success)
+ throw GetKeyNotFoundException();
+
+ return result.Value;
+ }
+
+ Debug.Assert(!result.Success);
+
+ return default(TV);
+ }
+
+ /** <inheritDoc /> */
+ public bool TryGet(TK key, out TV value)
+ {
+ IgniteArgumentCheck.NotNull(key, "key");
+
+ if (IsAsync)
+ throw new InvalidOperationException("TryGet can't be used in async mode.");
+
+ var res = DoOutInOpNullable<TK, TV>((int) CacheOp.Get, key);
+
+ value = res.Value;
+
+ return res.Success;
}
/** <inheritDoc /> */
@@ -331,31 +395,31 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
- public TV GetAndPut(TK key, TV val)
+ public CacheResult<TV> GetAndPut(TK key, TV val)
{
IgniteArgumentCheck.NotNull(key, "key");
IgniteArgumentCheck.NotNull(val, "val");
- return DoOutInOp<TK, TV, TV>((int)CacheOp.GetAndPut, key, val);
+ return DoOutInOpNullable<TK, TV, TV>((int)CacheOp.GetAndPut, key, val);
}
/** <inheritDoc /> */
- public TV GetAndReplace(TK key, TV val)
+ public CacheResult<TV> GetAndReplace(TK key, TV val)
{
IgniteArgumentCheck.NotNull(key, "key");
IgniteArgumentCheck.NotNull(val, "val");
- return DoOutInOp<TK, TV, TV>((int)CacheOp.GetAndReplace, key, val);
+ return DoOutInOpNullable<TK, TV, TV>((int)CacheOp.GetAndReplace, key, val);
}
/** <inheritDoc /> */
- public TV GetAndRemove(TK key)
+ public CacheResult<TV> GetAndRemove(TK key)
{
IgniteArgumentCheck.NotNull(key, "key");
- return DoOutInOp<TK, TV>((int)CacheOp.GetAndRemove, key);
+ return DoOutInOpNullable<TK, TV>((int)CacheOp.GetAndRemove, key);
}
/** <inheritdoc /> */
@@ -369,13 +433,13 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritdoc /> */
- public TV GetAndPutIfAbsent(TK key, TV val)
+ public CacheResult<TV> GetAndPutIfAbsent(TK key, TV val)
{
IgniteArgumentCheck.NotNull(key, "key");
IgniteArgumentCheck.NotNull(val, "val");
- return DoOutInOp<TK, TV, TV>((int)CacheOp.GetAndPutIfAbsent, key, val);
+ return DoOutInOpNullable<TK, TV, TV>((int)CacheOp.GetAndPutIfAbsent, key, val);
}
/** <inheritdoc /> */
@@ -916,26 +980,108 @@ namespace Apache.Ignite.Core.Impl.Cache
/// <typeparam name="TResult">The type of the future result.</typeparam>
/// <param name="lastAsyncOpId">The last op id.</param>
/// <returns>Future result converter.</returns>
- private Func<PortableReaderImpl, TResult> GetFutureResultConverter<TResult>(int lastAsyncOpId)
+ private Func<PortableReaderImpl, TResult> GetFutureResultConverter<TResult>(CacheOp lastAsyncOpId)
{
- if (lastAsyncOpId == (int) CacheOp.GetAll)
- return reader => (TResult)ReadGetAllDictionary(reader);
-
- if (lastAsyncOpId == (int)CacheOp.Invoke)
- return reader =>
- {
- var hasError = reader.ReadBoolean();
+ switch (lastAsyncOpId)
+ {
+ case CacheOp.Get:
+ return reader =>
+ {
+ if (reader != null)
+ return reader.ReadObject<TResult>();
+
+ throw GetKeyNotFoundException();
+ };
+
+ case CacheOp.GetAll:
+ return reader => reader == null ? default(TResult) : (TResult) ReadGetAllDictionary(reader);
+
+ case CacheOp.Invoke:
+ return reader =>
+ {
+ if (reader == null)
+ return default(TResult);
+
+ var hasError = reader.ReadBoolean();
+
+ if (hasError)
+ throw ReadException(reader.Stream);
- if (hasError)
- throw ReadException(reader.Stream);
+ return reader.ReadObject<TResult>();
+ };
- return reader.ReadObject<TResult>();
- };
+ case CacheOp.InvokeAll:
+ return _invokeAllConverter.Value as Func<PortableReaderImpl, TResult>;
- if (lastAsyncOpId == (int) CacheOp.InvokeAll)
- return _invokeAllConverter.Value as Func<PortableReaderImpl, TResult>;
+ case CacheOp.GetAndPut:
+ case CacheOp.GetAndPutIfAbsent:
+ case CacheOp.GetAndRemove:
+ case CacheOp.GetAndReplace:
+ return reader =>
+ {
+ var res = reader == null
+ ? new CacheResult<TV>()
+ : new CacheResult<TV>(reader.ReadObject<TV>());
+
+ return TypeCaster<TResult>.Cast(res);
+ };
+ }
return null;
}
+
+ /// <summary>
+ /// Throws the key not found exception.
+ /// </summary>
+ private static KeyNotFoundException GetKeyNotFoundException()
+ {
+ return new KeyNotFoundException("The given key was not present in the cache.");
+ }
+
+ /// <summary>
+ /// Perform simple out-in operation accepting single argument.
+ /// </summary>
+ /// <param name="type">Operation type.</param>
+ /// <param name="val">Value.</param>
+ /// <returns>Result.</returns>
+ private CacheResult<TR> DoOutInOpNullable<T1, TR>(int type, T1 val)
+ {
+ var res = DoOutInOp<T1, object>(type, val);
+
+ return res == null
+ ? new CacheResult<TR>()
+ : new CacheResult<TR>((TR)res);
+ }
+
+ /// <summary>
+ /// Perform out-in operation.
+ /// </summary>
+ /// <param name="type">Operation type.</param>
+ /// <param name="outAction">Out action.</param>
+ /// <returns>Result.</returns>
+ private CacheResult<TR> DoOutInOpNullable<TR>(int type, Action<PortableWriterImpl> outAction)
+ {
+ var res = DoOutInOp<object>(type, outAction);
+
+ return res == null
+ ? new CacheResult<TR>()
+ : new CacheResult<TR>((TR)res);
+ }
+
+ /// <summary>
+ /// Perform simple out-in operation accepting single argument.
+ /// </summary>
+ /// <param name="type">Operation type.</param>
+ /// <param name="val1">Value.</param>
+ /// <param name="val2">Value.</param>
+ /// <returns>Result.</returns>
+ private CacheResult<TR> DoOutInOpNullable<T1, T2, TR>(int type, T1 val1, T2 val2)
+ {
+ var res = DoOutInOp<T1, T2, object>(type, val1, val2);
+
+ return res == null
+ ? new CacheResult<TR>()
+ : new CacheResult<TR>((TR)res);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2ed4794f/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 3eb63ca..1709dc5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
@@ -22,6 +22,7 @@ namespace Apache.Ignite.Core.Impl.Cache
/// </summary>
internal enum CacheOp
{
+ None = 0,
Clear = 1,
ClearAll = 2,
ContainsKey = 3,
http://git-wip-us.apache.org/repos/asf/ignite/blob/2ed4794f/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs
index 0f868d8..aaaf8c3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs
@@ -38,7 +38,7 @@ namespace Apache.Ignite.Core.Impl.Cache
private readonly CacheImpl<TK, TV> _cache;
/** */
- private readonly ThreadLocal<int> _lastAsyncOp = new ThreadLocal<int>(() => PlatformTarget.OpNone);
+ private readonly ThreadLocal<CacheOp> _lastAsyncOp = new ThreadLocal<CacheOp>(() => CacheOp.None);
/// <summary>
/// Initializes a new instance of the <see cref="CacheProxyImpl{K, V}"/> class.
@@ -185,6 +185,19 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
+ public bool TryLocalPeek(TK key, out TV value, params CachePeekMode[] modes)
+ {
+ return _cache.TryLocalPeek(key, out value, modes);
+ }
+
+ /** <inheritDoc /> */
+ public TV this[TK key]
+ {
+ get { return _cache[key]; }
+ set { _cache[key] = value; }
+ }
+
+ /** <inheritDoc /> */
public TV Get(TK key)
{
var result = _cache.Get(key);
@@ -195,6 +208,12 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
+ public bool TryGet(TK key, out TV value)
+ {
+ return _cache.TryGet(key, out value);
+ }
+
+ /** <inheritDoc /> */
public IDictionary<TK, TV> GetAll(IEnumerable<TK> keys)
{
var result = _cache.GetAll(keys);
@@ -213,7 +232,7 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
- public TV GetAndPut(TK key, TV val)
+ public CacheResult<TV> GetAndPut(TK key, TV val)
{
var result = _cache.GetAndPut(key, val);
@@ -223,7 +242,7 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
- public TV GetAndReplace(TK key, TV val)
+ public CacheResult<TV> GetAndReplace(TK key, TV val)
{
var result = _cache.GetAndReplace(key, val);
@@ -233,7 +252,7 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
- public TV GetAndRemove(TK key)
+ public CacheResult<TV> GetAndRemove(TK key)
{
var result = _cache.GetAndRemove(key);
@@ -253,7 +272,7 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
- public TV GetAndPutIfAbsent(TK key, TV val)
+ public CacheResult<TV> GetAndPutIfAbsent(TK key, TV val)
{
var result = _cache.GetAndPutIfAbsent(key, val);
@@ -484,7 +503,7 @@ namespace Apache.Ignite.Core.Impl.Cache
private void SetLastAsyncOp(CacheOp opId)
{
if (IsAsync)
- _lastAsyncOp.Value = (int) opId;
+ _lastAsyncOp.Value = opId;
}
/// <summary>
@@ -494,7 +513,7 @@ namespace Apache.Ignite.Core.Impl.Cache
private void ClearLastAsyncOp()
{
if (IsAsync)
- _lastAsyncOp.Value = PlatformTarget.OpNone;
+ _lastAsyncOp.Value = CacheOp.None;
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/2ed4794f/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
index a25bada..70bebc4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
@@ -215,7 +215,21 @@ namespace Apache.Ignite.Core.Impl.Common
/** <inheritdoc /> */
public void OnNullResult()
{
- OnResult(default(T));
+ if (_converter == null)
+ {
+ OnResult(default(T));
+
+ return;
+ }
+
+ try
+ {
+ OnResult(_converter.Convert(null));
+ }
+ catch (Exception ex)
+ {
+ OnError(ex);
+ }
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/2ed4794f/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/FutureConverter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/FutureConverter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/FutureConverter.cs
index a07d954..5d158ec 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/FutureConverter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/FutureConverter.cs
@@ -46,7 +46,7 @@ namespace Apache.Ignite.Core.Impl.Common
{
_marsh = marsh;
_keepPortable = keepPortable;
- _func = func ?? (reader => reader.ReadObject<T>());
+ _func = func ?? (reader => reader == null ? default(T) : reader.ReadObject<T>());
}
/// <summary>
@@ -54,7 +54,7 @@ namespace Apache.Ignite.Core.Impl.Common
/// </summary>
public T Convert(IPortableStream stream)
{
- var reader = _marsh.StartUnmarshal(stream, _keepPortable);
+ var reader = stream == null ? null : _marsh.StartUnmarshal(stream, _keepPortable);
return _func(reader);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2ed4794f/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.cs
index e07597d..d97adeb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.cs
@@ -28,6 +28,7 @@ namespace Apache.Ignite.Core.Impl.Common
{
/// <summary>
/// Reads and converts a value.
+ /// Null stream means null value.
/// </summary>
T Convert(IPortableStream stream);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2ed4794f/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
index 03ccf8b..6d0a324 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
@@ -22,6 +22,7 @@ namespace Apache.Ignite.Core.Impl
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
+ using Apache.Ignite.Core.Cache;
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Impl.Common;
using Apache.Ignite.Core.Impl.Memory;
http://git-wip-us.apache.org/repos/asf/ignite/blob/2ed4794f/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
index dfc7c74..fe5f5c9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
@@ -600,6 +600,10 @@ namespace Apache.Ignite.Core.Impl.Portable
switch (hdr)
{
case PortableUtils.HdrNull:
+ if (default(T) != null)
+ throw new PortableException(string.Format("Invalid data on deserialization. " +
+ "Expected: '{0}' But was: null", typeof (T)));
+
return default(T);
case PortableUtils.HdrHnd:
[15/50] [abbrv] ignite git commit: Merge remote-tracking branch
'apache/master'
Posted by vo...@apache.org.
Merge remote-tracking branch 'apache/master'
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8217be6a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8217be6a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8217be6a
Branch: refs/heads/ignite-1651
Commit: 8217be6a0f7a3a0e564203e9ace52697833863ed
Parents: 4d1c026 f4d8ea9
Author: ashutak <as...@gridgain.com>
Authored: Thu Oct 15 17:12:53 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Thu Oct 15 17:12:53 2015 +0300
----------------------------------------------------------------------
assembly/release-fabric-lgpl.xml | 63 +++++
assembly/release-hadoop-lgpl.xml | 39 +++
examples-lgpl/README.txt | 27 ++
examples-lgpl/config/example-cache.xml | 73 ++++++
examples-lgpl/config/example-ignite.xml | 83 +++++++
examples-lgpl/config/filesystem/README.txt | 8 +
examples-lgpl/config/filesystem/core-site.xml | 42 ++++
.../config/filesystem/example-igfs.xml | 151 ++++++++++++
examples-lgpl/config/hibernate/README.txt | 8 +
.../hibernate/example-hibernate-L2-cache.xml | 64 +++++
examples-lgpl/config/servlet/README.txt | 8 +
examples-lgpl/config/servlet/WEB-INF/web.xml | 36 +++
examples-lgpl/pom-standalone.xml | 141 +++++++++++
examples-lgpl/pom.xml | 128 ++++++++++
.../hibernate/HibernateL2CacheExample.java | 245 +++++++++++++++++++
.../examples/datagrid/hibernate/Post.java | 130 ++++++++++
.../examples/datagrid/hibernate/User.java | 154 ++++++++++++
.../datagrid/hibernate/package-info.java | 22 ++
.../hibernate/CacheHibernatePersonStore.java | 122 +++++++++
.../hibernate/CacheHibernateStoreExample.java | 151 ++++++++++++
.../datagrid/store/hibernate/Person.hbm.xml | 34 +++
.../datagrid/store/hibernate/hibernate.cfg.xml | 41 ++++
.../datagrid/store/hibernate/package-info.java | 22 ++
.../java8/cluster/ClusterGroupExample.java | 86 +++++++
.../examples/java8/cluster/package-info.java | 22 ++
.../java8/computegrid/ComputeAsyncExample.java | 75 ++++++
.../computegrid/ComputeBroadcastExample.java | 102 ++++++++
.../computegrid/ComputeCallableExample.java | 75 ++++++
.../computegrid/ComputeClosureExample.java | 71 ++++++
.../computegrid/ComputeRunnableExample.java | 64 +++++
.../java8/computegrid/package-info.java | 22 ++
.../java8/datagrid/CacheAffinityExample.java | 137 +++++++++++
.../java8/datagrid/CacheApiExample.java | 105 ++++++++
.../java8/datagrid/CacheAsyncApiExample.java | 85 +++++++
.../examples/java8/datagrid/package-info.java | 22 ++
.../IgniteExecutorServiceExample.java | 70 ++++++
.../java8/datastructures/package-info.java | 22 ++
.../examples/java8/events/EventsExample.java | 135 ++++++++++
.../examples/java8/events/package-info.java | 22 ++
.../java8/messaging/MessagingExample.java | 166 +++++++++++++
.../messaging/MessagingPingPongExample.java | 113 +++++++++
.../examples/java8/messaging/package-info.java | 22 ++
.../misc/schedule/ComputeScheduleExample.java | 68 +++++
.../java8/misc/schedule/package-info.java | 22 ++
.../ignite/examples/java8/package-info.java | 23 ++
.../streaming/StreamTransformerExample.java | 101 ++++++++
.../java8/streaming/StreamVisitorExample.java | 172 +++++++++++++
.../examples/java8/streaming/package-info.java | 22 ++
...ibernateL2CacheExampleMultiNodeSelfTest.java | 31 +++
.../HibernateL2CacheExampleSelfTest.java | 33 +++
.../IgniteLgplExamplesSelfTestSuite.java | 48 ++++
...ibernateL2CacheExampleMultiNodeSelfTest.java | 29 +++
.../HibernateL2CacheExampleSelfTest.java | 37 +++
.../IgniteLgplExamplesJ8SelfTestSuite.java | 46 ++++
examples/pom-standalone.xml | 12 -
examples/pom.xml | 12 -
.../hibernate/HibernateL2CacheExample.java | 245 -------------------
.../examples/datagrid/hibernate/Post.java | 130 ----------
.../examples/datagrid/hibernate/User.java | 154 ------------
.../datagrid/hibernate/package-info.java | 22 --
.../hibernate/CacheHibernatePersonStore.java | 122 ---------
.../hibernate/CacheHibernateStoreExample.java | 151 ------------
.../datagrid/store/hibernate/Person.hbm.xml | 34 ---
.../datagrid/store/hibernate/hibernate.cfg.xml | 41 ----
.../datagrid/store/hibernate/package-info.java | 22 --
...ibernateL2CacheExampleMultiNodeSelfTest.java | 31 ---
.../HibernateL2CacheExampleSelfTest.java | 33 ---
.../testsuites/IgniteExamplesSelfTestSuite.java | 4 -
...ibernateL2CacheExampleMultiNodeSelfTest.java | 29 ---
.../HibernateL2CacheExampleSelfTest.java | 37 ---
pom.xml | 65 ++++-
71 files changed, 3904 insertions(+), 1080 deletions(-)
----------------------------------------------------------------------
[43/50] [abbrv] ignite git commit: Merge branch 'ignite-1486' into
ignite-1282
Posted by vo...@apache.org.
Merge branch 'ignite-1486' into ignite-1282
Conflicts:
modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
pom.xml
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/dedf283a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/dedf283a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/dedf283a
Branch: refs/heads/ignite-1651
Commit: dedf283a5ac21356ec53ba8320c0d9407f06e522
Parents: d8c5145 4f1120f
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Oct 22 12:12:10 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Oct 22 12:12:10 2015 +0300
----------------------------------------------------------------------
DEVNOTES.txt | 3 +-
RELEASE_NOTES.txt | 2 +
assembly/dependencies-fabric.xml | 2 +-
assembly/dependencies-hadoop.xml | 1 +
assembly/release-fabric-lgpl.xml | 63 +
assembly/release-fabric.xml | 10 +-
assembly/release-hadoop-lgpl.xml | 39 +
bin/igniterouter.bat | 2 +-
bin/igniterouter.sh | 2 +-
examples-lgpl/README.txt | 27 +
examples-lgpl/config/example-cache.xml | 73 +
examples-lgpl/config/example-ignite.xml | 83 ++
examples-lgpl/config/hibernate/README.txt | 8 +
.../hibernate/example-hibernate-L2-cache.xml | 64 +
examples-lgpl/pom-standalone.xml | 186 +++
examples-lgpl/pom.xml | 128 ++
.../hibernate/HibernateL2CacheExample.java | 245 ++++
.../examples/datagrid/hibernate/Post.java | 130 ++
.../examples/datagrid/hibernate/User.java | 154 ++
.../datagrid/hibernate/package-info.java | 22 +
.../hibernate/CacheHibernatePersonStore.java | 122 ++
.../hibernate/CacheHibernateStoreExample.java | 151 ++
.../datagrid/store/hibernate/Person.hbm.xml | 34 +
.../datagrid/store/hibernate/hibernate.cfg.xml | 41 +
.../datagrid/store/hibernate/package-info.java | 22 +
.../misc/schedule/ComputeScheduleExample.java | 82 ++
.../examples/misc/schedule/package-info.java | 22 +
.../misc/schedule/ComputeScheduleExample.java | 68 +
.../java8/misc/schedule/package-info.java | 22 +
.../ignite/examples/java8/package-info.java | 23 +
.../scalar/examples/ScalarScheduleExample.scala | 66 +
...ibernateL2CacheExampleMultiNodeSelfTest.java | 31 +
.../HibernateL2CacheExampleSelfTest.java | 33 +
.../IgniteLgplExamplesSelfTestSuite.java | 48 +
...ibernateL2CacheExampleMultiNodeSelfTest.java | 29 +
.../HibernateL2CacheExampleSelfTest.java | 37 +
.../IgniteLgplExamplesJ8SelfTestSuite.java | 46 +
.../ScalarLgplExamplesMultiNodeSelfTest.scala | 33 +
.../examples/ScalarLgplExamplesSelfTest.scala | 36 +
.../ScalarLgplExamplesSelfTestSuite.scala | 37 +
examples/config/hibernate/README.txt | 8 -
.../hibernate/example-hibernate-L2-cache.xml | 64 -
examples/pom-standalone.xml | 12 -
examples/pom.xml | 12 -
examples/schema-import/pom-standalone.xml | 90 ++
examples/schema-import/pom.xml | 23 +-
.../computegrid/ComputeClosureExample.java | 2 +-
.../hibernate/HibernateL2CacheExample.java | 245 ----
.../examples/datagrid/hibernate/Post.java | 130 --
.../examples/datagrid/hibernate/User.java | 154 --
.../datagrid/hibernate/package-info.java | 22 -
.../hibernate/CacheHibernatePersonStore.java | 122 --
.../hibernate/CacheHibernateStoreExample.java | 151 --
.../datagrid/store/hibernate/Person.hbm.xml | 34 -
.../datagrid/store/hibernate/hibernate.cfg.xml | 41 -
.../datagrid/store/hibernate/package-info.java | 22 -
.../misc/schedule/ComputeScheduleExample.java | 82 --
.../examples/misc/schedule/package-info.java | 22 -
.../misc/schedule/ComputeScheduleExample.java | 68 -
.../java8/misc/schedule/package-info.java | 22 -
.../scalar/examples/ScalarScheduleExample.scala | 66 -
...ibernateL2CacheExampleMultiNodeSelfTest.java | 31 -
.../HibernateL2CacheExampleSelfTest.java | 33 -
.../testsuites/IgniteExamplesSelfTestSuite.java | 4 -
...ibernateL2CacheExampleMultiNodeSelfTest.java | 29 -
.../HibernateL2CacheExampleSelfTest.java | 37 -
.../tests/examples/ScalarExamplesSelfTest.scala | 5 -
modules/apache-license-gen/README.txt | 33 +
modules/apache-license-gen/pom.xml | 3 +
.../JettyRestProcessorAbstractSelfTest.java | 252 +++-
.../TcpDiscoveryCloudIpFinderSelfTest.java | 2 +
.../org/apache/ignite/IgniteAtomicLong.java | 2 +-
.../org/apache/ignite/IgniteFileSystem.java | 4 +-
.../apache/ignite/IgniteSystemProperties.java | 3 +
.../org/apache/ignite/IgniteTransactions.java | 4 -
.../configuration/CacheConfiguration.java | 9 +-
.../java/org/apache/ignite/igfs/IgfsPath.java | 2 +-
.../apache/ignite/internal/IgniteKernal.java | 75 +-
.../managers/discovery/CustomEventListener.java | 4 +-
.../discovery/GridDiscoveryManager.java | 91 +-
.../internal/portable/PortableContext.java | 19 +-
.../cache/DynamicCacheChangeRequest.java | 19 +
.../cache/DynamicCacheDescriptor.java | 46 +-
.../processors/cache/GridCacheAdapter.java | 357 +++--
.../cache/GridCacheClearAllRunnable.java | 18 +-
.../cache/GridCacheConcurrentMap.java | 4 +-
.../processors/cache/GridCacheContext.java | 2 +-
.../processors/cache/GridCacheEventManager.java | 12 +-
.../cache/GridCacheExplicitLockSpan.java | 13 +-
.../processors/cache/GridCacheIoManager.java | 105 +-
.../processors/cache/GridCacheMessage.java | 7 -
.../cache/GridCacheMvccCandidate.java | 5 +-
.../processors/cache/GridCacheMvccManager.java | 67 +-
.../GridCachePartitionExchangeManager.java | 98 +-
.../processors/cache/GridCacheProcessor.java | 157 +-
.../processors/cache/GridCacheProxyImpl.java | 14 +-
.../cache/GridCacheSharedContext.java | 32 -
.../processors/cache/GridCacheUtils.java | 8 -
.../processors/cache/IgniteCacheProxy.java | 6 +-
.../processors/cache/IgniteInternalCache.java | 19 +-
.../distributed/GridDistributedCacheEntry.java | 2 +-
.../dht/GridClientPartitionTopology.java | 13 +-
.../dht/GridDhtAffinityAssignmentRequest.java | 5 -
.../dht/GridDhtAffinityAssignmentResponse.java | 5 -
.../distributed/dht/GridDhtCacheAdapter.java | 6 +-
.../cache/distributed/dht/GridDhtGetFuture.java | 4 +-
.../distributed/dht/GridDhtLocalPartition.java | 3 +-
.../distributed/dht/GridDhtLockRequest.java | 10 +-
.../dht/GridDhtPartitionTopologyImpl.java | 12 +-
.../distributed/dht/GridDhtTxFinishRequest.java | 5 -
.../distributed/dht/GridDhtTxPrepareFuture.java | 6 +-
.../dht/GridDhtTxPrepareRequest.java | 7 +-
.../dht/GridPartitionedGetFuture.java | 5 +-
.../dht/atomic/GridDhtAtomicUpdateFuture.java | 5 +
.../dht/atomic/GridNearAtomicUpdateFuture.java | 17 +-
.../dht/colocated/GridDhtColocatedCache.java | 12 +-
.../colocated/GridDhtColocatedLockFuture.java | 27 +-
.../dht/preloader/GridDhtForceKeysRequest.java | 5 -
.../dht/preloader/GridDhtForceKeysResponse.java | 5 -
.../GridDhtPartitionDemandMessage.java | 9 +-
.../GridDhtPartitionSupplyMessage.java | 8 +-
.../GridDhtPartitionsAbstractMessage.java | 5 -
.../GridDhtPartitionsExchangeFuture.java | 12 +-
.../preloader/GridDhtPartitionsFullMessage.java | 12 +-
.../GridDhtPartitionsSingleMessage.java | 11 +-
.../dht/preloader/GridDhtPreloader.java | 26 +-
.../distributed/near/GridNearCacheAdapter.java | 21 +-
.../near/GridNearCacheClearAllRunnable.java | 9 +-
.../distributed/near/GridNearGetFuture.java | 2 +
.../distributed/near/GridNearLockFuture.java | 11 +-
.../near/GridNearOptimisticTxPrepareFuture.java | 24 +-
.../near/GridNearTxFinishFuture.java | 4 +-
.../cache/distributed/near/GridNearTxLocal.java | 21 +-
.../cache/local/GridLocalCacheEntry.java | 2 +-
.../cache/query/GridCacheQueryManager.java | 33 +-
.../cache/query/GridCacheSqlIndexMetadata.java | 7 +-
.../cache/query/GridCacheSqlMetadata.java | 22 +-
.../continuous/CacheContinuousQueryHandler.java | 10 +-
.../continuous/CacheContinuousQueryManager.java | 66 +-
.../transactions/IgniteTxLocalAdapter.java | 35 +-
.../continuous/GridContinuousProcessor.java | 20 +-
.../datastructures/DataStructuresProcessor.java | 54 +-
.../processors/igfs/IgfsDataManager.java | 2 -
.../processors/igfs/IgfsDeleteWorker.java | 102 +-
.../internal/processors/igfs/IgfsFileInfo.java | 15 +-
.../internal/processors/igfs/IgfsImpl.java | 372 +----
.../processors/igfs/IgfsMetaManager.java | 1255 ++++++++++++----
.../processors/igfs/IgfsOutputStreamImpl.java | 2 +
.../internal/processors/igfs/IgfsUtils.java | 23 +
.../processors/rest/GridRestCommand.java | 8 +-
.../processors/rest/GridRestProcessor.java | 364 ++++-
.../handlers/cache/GridCacheCommandHandler.java | 364 ++---
.../handlers/query/QueryCommandHandler.java | 195 ++-
.../top/GridTopologyCommandHandler.java | 31 +-
.../rest/request/RestQueryRequest.java | 175 +++
.../rest/request/RestSqlQueryRequest.java | 125 --
.../ignite/internal/util/GridArgumentCheck.java | 5 +-
.../ignite/internal/util/GridJavaProcess.java | 12 +-
.../ignite/internal/util/IgniteUtils.java | 2 +-
.../ignite/internal/util/lang/GridFunc.java | 12 +
.../util/nio/GridNioRecoveryDescriptor.java | 4 +-
.../apache/ignite/marshaller/Marshaller.java | 2 +-
.../optimized/OptimizedMarshallerUtils.java | 6 +-
.../marshaller/portable/PortableMarshaller.java | 40 +-
.../org/apache/ignite/mxbean/IgniteMXBean.java | 8 +-
.../portable/PortableProtocolVersion.java | 41 -
.../communication/tcp/TcpCommunicationSpi.java | 29 +-
.../ignite/spi/deployment/DeploymentSpi.java | 8 +-
.../discovery/DiscoverySpiCustomMessage.java | 12 +-
.../ignite/spi/discovery/tcp/ServerImpl.java | 398 +++--
.../spi/discovery/tcp/TcpDiscoveryImpl.java | 6 +-
.../spi/discovery/tcp/TcpDiscoverySpi.java | 2 +-
.../tcp/internal/TcpDiscoveryNodesRing.java | 94 +-
.../messages/TcpDiscoveryDiscardMessage.java | 15 +-
.../TcpDiscoveryNodeAddFinishedMessage.java | 2 +-
.../messages/TcpDiscoveryNodeAddedMessage.java | 19 +-
.../resources/META-INF/classnames.properties | 1 -
modules/core/src/test/config/tests.properties | 3 +
.../ignite/igfs/IgfsEventsAbstractSelfTest.java | 6 +-
.../ignite/igfs/IgfsFragmentizerSelfTest.java | 2 +-
.../internal/GridUpdateNotifierSelfTest.java | 1 +
.../IgniteClientReconnectAbstractTest.java | 35 +-
.../IgniteClientReconnectCacheTest.java | 154 ++
.../GridDiscoveryManagerAliveCacheSelfTest.java | 2 +
.../GridDiscoveryManagerAttributesSelfTest.java | 50 -
.../cache/CacheAffinityCallSelfTest.java | 4 +-
.../processors/cache/CrossCacheLockTest.java | 142 ++
.../GridCacheAbstractFailoverSelfTest.java | 3 +
.../cache/GridCacheAbstractFullApiSelfTest.java | 486 ++++---
.../GridCacheAbstractRemoveFailureTest.java | 9 +-
.../cache/GridCacheClearSelfTest.java | 308 ++++
.../GridCacheDeploymentOffHeapSelfTest.java | 15 +
.../GridCacheFinishPartitionsSelfTest.java | 5 +-
.../GridCacheVariableTopologySelfTest.java | 3 +-
...IgniteCacheAtomicPutAllFailoverSelfTest.java | 4 +
.../IgniteCacheConfigurationTemplateTest.java | 31 +
.../cache/IgniteCacheCreateRestartSelfTest.java | 3 +
.../cache/IgniteCacheEntryListenerTxTest.java | 4 +
.../IgniteCacheP2pUnmarshallingErrorTest.java | 7 +
...CacheP2pUnmarshallingRebalanceErrorTest.java | 12 +-
.../cache/IgniteCachePutAllRestartTest.java | 4 +-
.../cache/IgniteDynamicCacheFilterTest.java | 150 ++
.../IgniteTxExceptionAbstractSelfTest.java | 3 +
...omicOffheapQueueCreateMultiNodeSelfTest.java | 5 -
...ionedAtomicQueueCreateMultiNodeSelfTest.java | 9 +-
...artitionedOffHeapValuesQueueApiSelfTest.java | 4 +
...PartitionedQueueCreateMultiNodeSelfTest.java | 16 +-
...nedQueueFailoverDataConsistencySelfTest.java | 5 -
...GridCachePartitionedSetFailoverSelfTest.java | 4 +
.../CacheAbstractRestartSelfTest.java | 247 ++++
.../distributed/CacheAffEarlySelfTest.java | 245 ----
.../distributed/CacheAffinityEarlyTest.java | 168 +++
...acheAsyncOperationsFailoverAbstractTest.java | 11 +
.../CacheGetFutureHangsSelfTest.java | 159 +-
...NearDisabledAtomicInvokeRestartSelfTest.java | 179 +++
...abledTransactionalInvokeRestartSelfTest.java | 173 +++
...edTransactionalWriteReadRestartSelfTest.java | 124 ++
.../CacheNoValueClassOnServerNodeTest.java | 1 +
.../CachePutAllFailoverAbstractTest.java | 11 +
.../IgniteCacheAtomicNodeRestartTest.java | 8 +
...niteCacheClientNodeChangingTopologyTest.java | 10 +-
.../IgniteCacheCreatePutMultiNodeSelfTest.java | 151 ++
.../distributed/IgniteCacheCreatePutTest.java | 125 ++
.../IgniteCachePutGetRestartAbstractTest.java | 3 +
.../IgniteCacheSizeFailoverTest.java | 3 +
.../IgniteTxPreloadAbstractTest.java | 43 +-
.../GridCacheColocatedTxExceptionSelfTest.java | 5 -
.../dht/GridCacheDhtEntrySelfTest.java | 2 +-
.../dht/GridCacheDhtPreloadPerformanceTest.java | 133 ++
.../dht/GridCacheTxNodeFailureSelfTest.java | 2 +
.../dht/GridNearCacheTxNodeFailureSelfTest.java | 4 +
...gniteAtomicLongChangingTopologySelfTest.java | 190 ++-
.../IgniteCacheCrossCacheTxFailoverTest.java | 3 +
.../IgniteCrossCacheTxNearEnabledSelfTest.java | 28 +
.../dht/IgniteCrossCacheTxSelfTest.java | 213 +++
...GridCacheValueConsistencyAtomicSelfTest.java | 2 +-
...tomicClientOnlyMultiNodeFullApiSelfTest.java | 71 +-
...ledFairAffinityMultiNodeFullApiSelfTest.java | 12 +-
...icOffHeapTieredMultiNodeFullApiSelfTest.java | 7 +-
.../near/GridCacheNearTxExceptionSelfTest.java | 9 +-
.../near/GridCacheNearTxForceKeyTest.java | 2 +-
...achePartitionedMultiNodeFullApiSelfTest.java | 129 +-
.../near/NearCacheMultithreadedUpdateTest.java | 217 +++
.../GridCacheReplicatedInvalidateSelfTest.java | 249 ----
.../GridCacheReplicatedTxExceptionSelfTest.java | 5 -
.../replicated/GridReplicatedTxPreloadTest.java | 9 +-
...eCacheExpiryPolicyWithStoreAbstractTest.java | 5 +-
.../GridCacheLocalTxExceptionSelfTest.java | 5 -
...bledFairAffinityMultiJvmFullApiSelfTest.java | 5 +
...tomicNearEnabledMultiJvmFullApiSelfTest.java | 5 +
...ontinuousQueryReplicatedOneNodeSelfTest.java | 120 ++
.../DataStreamerMultiThreadedSelfTest.java | 4 +-
.../DataStreamerMultinodeCreateCacheTest.java | 2 +
.../processors/igfs/IgfsAbstractSelfTest.java | 927 +++++++++---
.../igfs/IgfsClientCacheSelfTest.java | 15 +-
.../igfs/IgfsDataManagerSelfTest.java | 13 +-
.../igfs/IgfsMetaManagerSelfTest.java | 258 ++--
.../processors/igfs/IgfsMetricsSelfTest.java | 2 +-
.../processors/igfs/IgfsProcessorSelfTest.java | 41 +-
.../igfs/UniversalFileSystemAdapter.java | 1 -
...lientDiscoverySpiFailureTimeoutSelfTest.java | 33 +-
.../tcp/TcpClientDiscoverySpiSelfTest.java | 2 +
.../tcp/TcpDiscoveryMultiThreadedTest.java | 53 +-
.../spi/discovery/tcp/TcpDiscoverySelfTest.java | 315 +++-
.../testframework/junits/GridAbstractTest.java | 116 +-
.../junits/IgniteTestResources.java | 8 +-
.../junits/common/GridCommonAbstractTest.java | 15 +-
.../junits/multijvm/AffinityProcessProxy.java | 440 ++++--
.../multijvm/IgniteCacheProcessProxy.java | 1357 ++++++++++++++----
.../multijvm/IgniteClusterProcessProxy.java | 115 +-
.../multijvm/IgniteEventsProcessProxy.java | 50 +-
.../junits/multijvm/IgniteNodeRunner.java | 39 +-
.../junits/multijvm/IgniteProcessProxy.java | 105 +-
.../IgniteCacheFailoverTestSuite.java | 4 -
.../IgniteCacheFailoverTestSuite3.java | 28 +-
.../IgniteCacheFullApiSelfTestSuite.java | 8 +-
.../IgniteCacheLoadConsistencyTestSuite.java | 42 +
.../testsuites/IgniteCacheTestSuite3.java | 2 -
.../testsuites/IgniteCacheTestSuite4.java | 24 +
.../ignite/testsuites/IgniteIgfsTestSuite.java | 6 +
modules/extdata/uri/pom.xml | 11 +-
.../processors/hadoop/igfs/HadoopIgfsUtils.java | 36 +
.../hadoop/igfs/HadoopIgfsWrapper.java | 54 +-
...oopFileSystemUniversalFileSystemAdapter.java | 4 +-
.../HadoopIgfs20FileSystemAbstractSelfTest.java | 34 +-
.../IgniteHadoopFileSystemAbstractSelfTest.java | 7 +-
.../testsuites/IgniteHadoopTestSuite.java | 19 +-
.../CacheHibernateBlobStoreSelfTest.java | 6 +-
.../processors/query/h2/sql/GridSqlArray.java | 52 +
.../processors/query/h2/sql/GridSqlElement.java | 2 +-
.../query/h2/sql/GridSqlFunction.java | 60 +-
.../query/h2/sql/GridSqlFunctionType.java | 3 +
.../query/h2/sql/GridSqlPlaceholder.java | 7 +-
.../query/h2/sql/GridSqlQueryParser.java | 84 +-
.../processors/query/h2/sql/GridSqlType.java | 29 +-
.../cache/CacheConfigurationP2PTest.java | 3 +
.../cache/SqlFieldsQuerySelfTest.java | 172 +++
.../query/h2/sql/GridQueryParsingTest.java | 27 +
.../IgniteCacheQuerySelfTestSuite.java | 6 +-
.../http/jetty/GridJettyJsonConfig.java | 158 +-
.../http/jetty/GridJettyRestHandler.java | 186 +--
.../spi/deployment/uri/UriDeploymentSpi.java | 93 +-
.../scanners/http/UriDeploymentHttpScanner.java | 10 +-
.../http/GridHttpDeploymentSelfTest.java | 132 +-
.../visor/commands/kill/VisorKillCommand.scala | 2 +-
.../scala/org/apache/ignite/visor/visor.scala | 1 -
modules/yardstick/pom.xml | 10 +-
pom.xml | 109 +-
308 files changed, 13724 insertions(+), 5779 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/dedf283a/assembly/release-fabric.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/dedf283a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 98f9fe1,fd71c1c..2eb7b8d
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@@ -17,17 -17,17 +17,24 @@@
package org.apache.ignite.configuration;
+ import java.io.Serializable;
+ import java.util.Collection;
+ import javax.cache.Cache;
+ import javax.cache.configuration.CompleteConfiguration;
+ import javax.cache.configuration.Factory;
+ import javax.cache.configuration.MutableConfiguration;
+ import javax.cache.expiry.ExpiryPolicy;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.cache.*;
+import org.apache.ignite.cache.CacheAtomicWriteOrderMode;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheEntryProcessor;
+import org.apache.ignite.cache.CacheInterceptor;
+import org.apache.ignite.cache.CacheMemoryMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CacheRebalanceMode;
+import org.apache.ignite.cache.CacheTypeMetadata;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
import org.apache.ignite.cache.affinity.AffinityFunction;
import org.apache.ignite.cache.affinity.AffinityKeyMapper;
import org.apache.ignite.cache.eviction.EvictionFilter;
http://git-wip-us.apache.org/repos/asf/ignite/blob/dedf283a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/dedf283a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/dedf283a/pom.xml
----------------------------------------------------------------------
diff --cc pom.xml
index df383ef,6eeb006..26374fe
--- a/pom.xml
+++ b/pom.xml
@@@ -299,8 -366,18 +365,13 @@@
<substitution expression="${project.version}" />
</replaceregexp>
+ <replaceregexp file="${basedir}/target/release-package/examples/schema-import/pom.xml" byline="true">
+ <regexp pattern="to_be_replaced_by_ignite_version" />
+ <substitution expression="${project.version}" />
+ </replaceregexp>
+
<chmod dir="${basedir}/target/release-package" perm="755" includes="**/*.sh" />
- <!-- hotfix according to https://issues.apache.org/jira/browse/IGNITE-1399. Remove at 1.5 -->
- <move todir="${basedir}/target/temp/release-package/libs/optional/ignite-platform" failonerror="false">
- <fileset dir="${basedir}/target/release-package/libs/optional/ignite-platform" />
- </move>
-
<zip destfile="${basedir}/target/bin/${ignite.zip.pattern}.zip" encoding="UTF-8">
<zipfileset dir="${basedir}/target/release-package" prefix="${ignite.zip.pattern}" filemode="755">
<include name="**/*.sh" />
[09/50] [abbrv] ignite git commit: ignite-1635,
ignite-1616 Added unit-tests for the bugs.
Posted by vo...@apache.org.
ignite-1635, ignite-1616 Added unit-tests for the bugs.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/077af17f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/077af17f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/077af17f
Branch: refs/heads/ignite-1651
Commit: 077af17f7e62ed1c4d0f699c9fd39b9d8161ae1f
Parents: 3a29b97
Author: ashutak <as...@gridgain.com>
Authored: Thu Oct 15 16:58:23 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Thu Oct 15 16:58:23 2015 +0300
----------------------------------------------------------------------
.../CacheAbstractRestartSelfTest.java | 247 +++++++++++++++++++
...NearDisabledAtomicInvokeRestartSelfTest.java | 179 ++++++++++++++
...abledTransactionalInvokeRestartSelfTest.java | 173 +++++++++++++
...edTransactionalWriteReadRestartSelfTest.java | 124 ++++++++++
.../IgniteCacheLoadConsistencyTestSuite.java | 42 ++++
5 files changed, 765 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/077af17f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAbstractRestartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAbstractRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAbstractRestartSelfTest.java
new file mode 100644
index 0000000..7537af1
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAbstractRestartSelfTest.java
@@ -0,0 +1,247 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT 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.cache.distributed;
+
+import java.util.ArrayList;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractTest;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
+import org.apache.ignite.testframework.GridTestUtils;
+
+/**
+ * Abstract restart test.
+ */
+public abstract class CacheAbstractRestartSelfTest extends IgniteCacheAbstractTest {
+ /** */
+ private volatile CountDownLatch cacheCheckedLatch = new CountDownLatch(1);
+
+ /** */
+ private final ReentrantReadWriteLock rwl = new ReentrantReadWriteLock(true);
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ if (gridName.equals(getTestGridName(gridCount() - 1)))
+ cfg.setClientMode(true);
+
+ cfg.setPeerClassLoadingEnabled(false);
+
+ ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected long getTestTimeout() {
+ return 8 * 60_000;
+ }
+
+ /**
+ * @return Number of updaters threads.
+ */
+ protected int updatersNumber() {
+ return 64;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testRestart() throws Exception {
+ final int clientGrid = gridCount() - 1;
+
+ assertTrue(ignite(clientGrid).configuration().isClientMode());
+
+ final IgniteEx grid = grid(clientGrid);
+
+ final IgniteCache cache = jcache(clientGrid);
+
+ updateCache(grid, cache);
+
+ final AtomicBoolean stop = new AtomicBoolean();
+
+ ArrayList<IgniteInternalFuture> updaterFuts = new ArrayList<>();
+
+ for (int i = 0; i < updatersNumber(); i++) {
+ final int threadIdx = i;
+
+ IgniteInternalFuture<?> updateFut = GridTestUtils.runAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ Thread.currentThread().setName("update-thread-" + threadIdx);
+
+ assertTrue(cacheCheckedLatch.await(30_000, TimeUnit.MILLISECONDS));
+
+ int iter = 0;
+
+ while (!stop.get()) {
+ log.info("Start update: " + iter);
+
+ rwl.readLock().lock();
+
+ try {
+ updateCache(grid, cache);
+ }
+ finally {
+ rwl.readLock().unlock();
+ }
+
+ log.info("End update: " + iter++);
+ }
+
+ log.info("Update iterations: " + iter);
+
+ return null;
+ }
+ });
+
+ updaterFuts.add(updateFut);
+ }
+
+ IgniteInternalFuture<?> restartFut = GridTestUtils.runAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ Thread.currentThread().setName("restart-thread");
+
+ ThreadLocalRandom rnd = ThreadLocalRandom.current();
+
+ while (!stop.get()) {
+ assertTrue(cacheCheckedLatch.await(30_000, TimeUnit.MILLISECONDS));
+
+ int node = rnd.nextInt(0, gridCount() - 1);
+
+ log.info("Stop node: " + node);
+
+ stopGrid(node);
+
+ U.sleep(restartSleep());
+
+ log.info("Start node: " + node);
+
+ startGrid(node);
+
+ cacheCheckedLatch = new CountDownLatch(1);
+
+ U.sleep(restartDelay());
+
+ awaitPartitionMapExchange();
+ }
+
+ return null;
+ }
+ });
+
+ long endTime = System.currentTimeMillis() + getTestDuration();
+
+ try {
+ int iter = 0;
+
+ while (System.currentTimeMillis() < endTime && !isAnyDone(updaterFuts) && !restartFut.isDone()) {
+ try {
+ log.info("Start of cache checking: " + iter);
+
+ rwl.writeLock().lock();
+
+ try {
+ checkCache(grid, cache);
+ }
+ finally {
+ rwl.writeLock().unlock();
+ }
+
+ log.info("End of cache checking: " + iter++);
+ }
+ finally {
+ cacheCheckedLatch.countDown();
+ }
+ }
+
+ log.info("Checking iteration: " + iter);
+ }
+ finally {
+ cacheCheckedLatch.countDown();
+
+ stop.set(true);
+ }
+
+ for (IgniteInternalFuture fut : updaterFuts)
+ fut.get();
+
+ restartFut.get();
+
+ checkCache(grid, cache);
+ }
+
+ /**
+ * @return Test duration.
+ * @see #getTestTimeout()
+ */
+ protected int getTestDuration() {
+ return 60_000;
+ }
+
+ /**
+ * @return Restart sleep in milliseconds.
+ */
+ private int restartSleep() {
+ return 100;
+ }
+
+ /**
+ * @return Restart delay in milliseconds.
+ */
+ private int restartDelay() {
+ return 100;
+ }
+
+ /**
+ * Checks cache in one thread. All update operations are not executed.
+ *
+ * @param cache Cache.
+ */
+ protected abstract void checkCache(IgniteEx grid, IgniteCache cache) throws Exception ;
+
+ /**
+ * Updates cache in many threads.
+ *
+ * @param grid Grid.
+ * @param cache Cache.
+ */
+ protected abstract void updateCache(IgniteEx grid, IgniteCache cache) throws Exception ;
+
+ /**
+ * @param futs Futers.
+ * @return {@code True} if all futures are done.
+ */
+ private static boolean isAnyDone(ArrayList<IgniteInternalFuture> futs) {
+ for (IgniteInternalFuture fut : futs) {
+ if (fut.isDone())
+ return true;
+ }
+
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/077af17f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledAtomicInvokeRestartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledAtomicInvokeRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledAtomicInvokeRestartSelfTest.java
new file mode 100644
index 0000000..90427f5
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledAtomicInvokeRestartSelfTest.java
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.cache.distributed;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.atomic.AtomicLong;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicWriteOrderMode;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheEntryProcessor;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.U;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+
+/**
+ * Invoke retry consistency test.
+ */
+public class CacheNearDisabledAtomicInvokeRestartSelfTest extends CacheAbstractRestartSelfTest {
+ /** */
+ public static final int RANGE = 50;
+
+ /** */
+ private static final long FIRST_VAL = 1;
+
+ /** */
+ private final ConcurrentMap<String, AtomicLong> nextValMap = new ConcurrentHashMap<>();
+
+ /** {@inheritDoc} */
+ @Override protected int gridCount() {
+ return 4;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheMode cacheMode() {
+ return PARTITIONED;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheAtomicityMode atomicityMode() {
+ return ATOMIC;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheAtomicWriteOrderMode atomicWriteOrderMode() {
+ return CacheAtomicWriteOrderMode.PRIMARY;
+ }
+
+ /** */
+ @Override protected NearCacheConfiguration nearConfiguration() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ protected void checkCache(IgniteEx ignite, IgniteCache cache) throws Exception {
+ log.info("Start cache validation.");
+
+ long startTime = U.currentTimeMillis();
+
+ Map<String, Set> badCacheEntries = new HashMap<>();
+
+ for (Map.Entry<String, AtomicLong> e : nextValMap.entrySet()) {
+ String key = e.getKey();
+
+ Set set = (Set)cache.get(key);
+
+ if (set == null || e.getValue() == null || !Objects.equals(e.getValue().get(), (long)set.size()))
+ badCacheEntries.put(key, set);
+ }
+
+ if (!badCacheEntries.isEmpty()) {
+ // Print all usefull information and finish.
+ for (Map.Entry<String, Set> e : badCacheEntries.entrySet()) {
+ String key = e.getKey();
+
+ U.error(log, "Got unexpected set size [key='" + key + "', expSize=" + nextValMap.get(key)
+ + ", cacheVal=" + e.getValue() + "]");
+ }
+
+ log.info("Next values map contant:");
+ for (Map.Entry<String, AtomicLong> e : nextValMap.entrySet())
+ log.info("Map Entry [key=" + e.getKey() + ", val=" + e.getValue() + "]");
+
+ log.info("Cache content:");
+
+ for (int k2 = 0; k2 < RANGE; k2++) {
+ String key2 = "key-" + k2;
+
+ Object val = cache.get(key2);
+
+ if (val != null)
+ log.info("Cache Entry [key=" + key2 + ", val=" + val + "]");
+
+ }
+
+ fail("Cache and local map are in inconsistent state [badKeys=" + badCacheEntries.keySet() + ']');
+ }
+
+ log.info("Clearing all data.");
+
+ cache.removeAll();
+ nextValMap.clear();
+
+ log.info("Cache validation successfully finished in "
+ + (U.currentTimeMillis() - startTime) / 1000 + " sec.");
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void updateCache(IgniteEx ignite, IgniteCache cache) {
+ final int k = ThreadLocalRandom.current().nextInt(RANGE);
+
+ String key = "key-" + k;
+
+ AtomicLong nextAtomicVal = nextValMap.putIfAbsent(key, new AtomicLong(FIRST_VAL));
+
+ Long nextVal = FIRST_VAL;
+
+ if (nextAtomicVal != null)
+ nextVal = nextAtomicVal.incrementAndGet();
+
+ cache.invoke(key, new AddInSetEntryProcessor(), nextVal);
+ }
+
+ /**
+ */
+ private static class AddInSetEntryProcessor implements CacheEntryProcessor<String, Set, Object> {
+ /** */
+ private static final long serialVersionUID = 0;
+
+ /** {@inheritDoc} */
+ @Override public Object process(MutableEntry<String, Set> entry,
+ Object... arguments) throws EntryProcessorException {
+ assert !F.isEmpty(arguments);
+
+ Object val = arguments[0];
+
+ Set set;
+
+ if (!entry.exists())
+ set = new HashSet<>();
+ else
+ set = entry.getValue();
+
+ set.add(val);
+
+ entry.setValue(set);
+
+ return null;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/077af17f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalInvokeRestartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalInvokeRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalInvokeRestartSelfTest.java
new file mode 100644
index 0000000..f4eea6c
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalInvokeRestartSelfTest.java
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.distributed;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.atomic.AtomicLong;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheEntryProcessor;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.util.typedef.internal.U;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+
+/**
+ * Invoke retry consistency test.
+ */
+public class CacheNearDisabledTransactionalInvokeRestartSelfTest extends CacheAbstractRestartSelfTest {
+ /** */
+ public static final int RANGE = 100;
+
+ /** */
+ private static final int KEYS_CNT = 5;
+
+ /** */
+ protected final ConcurrentMap<String, AtomicLong> map = new ConcurrentHashMap<>();
+
+ /** {@inheritDoc} */
+ @Override protected int gridCount() {
+ return 4;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheMode cacheMode() {
+ return PARTITIONED;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheAtomicityMode atomicityMode() {
+ return TRANSACTIONAL;
+ }
+
+ /** */
+ @Override protected NearCacheConfiguration nearConfiguration() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ protected void checkCache(IgniteEx ignite, IgniteCache cache) {
+ log.info("Start cache validation.");
+
+ long startTime = U.currentTimeMillis();
+
+ Map<String, Long> notEqualsCacheVals = new HashMap<>();
+ Map<String, Long> notEqualsLocMapVals = new HashMap<>();
+
+ for (int k = 0; k < RANGE; k++) {
+ if (k % 10_000 == 0)
+ log.info("Start validation for keys like 'key-" + k + "-*'");
+
+ for (int i = 0; i < KEYS_CNT; i++) {
+ String key = "key-" + k + "-" + i;
+
+ Long cacheVal = (Long)cache.get(key);
+
+ AtomicLong aVal = map.get(key);
+ Long mapVal = aVal != null ? aVal.get() : null;
+
+ if (!Objects.equals(cacheVal, mapVal)) {
+ notEqualsCacheVals.put(key, cacheVal);
+ notEqualsLocMapVals.put(key, mapVal);
+ }
+ }
+ }
+
+ assert notEqualsCacheVals.size() == notEqualsLocMapVals.size() : "Invalid state " +
+ "[cacheMapVals=" + notEqualsCacheVals + ", mapVals=" + notEqualsLocMapVals + "]";
+
+ if (!notEqualsCacheVals.isEmpty()) {
+ // Print all usefull information and finish.
+ for (Map.Entry<String, Long> eLocMap : notEqualsLocMapVals.entrySet()) {
+ String key = eLocMap.getKey();
+ Long mapVal = eLocMap.getValue();
+ Long cacheVal = notEqualsCacheVals.get(key);
+
+ U.error(log, "Got different values [key='" + key
+ + "', cacheVal=" + cacheVal + ", localMapVal=" + mapVal + "]");
+ }
+
+ log.info("Local driver map contant:\n " + map);
+
+ log.info("Cache content:");
+
+ for (int k2 = 0; k2 < RANGE; k2++) {
+ for (int i2 = 0; i2 < KEYS_CNT; i2++) {
+ String key2 = "key-" + k2 + "-" + i2;
+
+ Long val = (Long)cache.get(key2);
+
+ if (val != null)
+ log.info("Entry [key=" + key2 + ", val=" + val + "]");
+ }
+ }
+
+ throw new IllegalStateException("Cache and local map are in inconsistent state [badKeys="
+ + notEqualsCacheVals.keySet() + ']');
+ }
+
+ log.info("Cache validation successfully finished in "
+ + (U.currentTimeMillis() - startTime) / 1000 + " sec.");
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void updateCache(IgniteEx ignite, IgniteCache cache) {
+ final int k = ThreadLocalRandom.current().nextInt(RANGE);
+
+ final String[] keys = new String[KEYS_CNT];
+
+ for (int i = 0; i < keys.length; i++)
+ keys[i] = "key-" + k + "-" + i;
+
+ for (String key : keys) {
+ cache.invoke(key, new IncrementCacheEntryProcessor());
+
+ AtomicLong prevVal = map.putIfAbsent(key, new AtomicLong(0));
+
+ if (prevVal != null)
+ prevVal.incrementAndGet();
+ }
+ }
+
+ /**
+ */
+ private static class IncrementCacheEntryProcessor implements CacheEntryProcessor<String, Long, Long> {
+ /** */
+ private static final long serialVersionUID = 0;
+
+ /** {@inheritDoc} */
+ @Override public Long process(MutableEntry<String, Long> entry,
+ Object... arguments) throws EntryProcessorException {
+ long newVal = entry.getValue() == null ? 0 : entry.getValue() + 1;
+
+ entry.setValue(newVal);
+
+ return newVal;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/077af17f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalWriteReadRestartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalWriteReadRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalWriteReadRestartSelfTest.java
new file mode 100644
index 0000000..875aef3
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalWriteReadRestartSelfTest.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.cache.distributed;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ThreadLocalRandom;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.util.typedef.internal.U;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+
+/**
+ * Transactional write read consistency test.
+ */
+public class CacheNearDisabledTransactionalWriteReadRestartSelfTest extends CacheAbstractRestartSelfTest{
+ /** */
+ public static final int RANGE = 100;
+
+ /** */
+ private static final int KEYS_CNT = 5;
+
+ /** {@inheritDoc} */
+ @Override protected int gridCount() {
+ return 4;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheMode cacheMode() {
+ return PARTITIONED;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheAtomicityMode atomicityMode() {
+ return TRANSACTIONAL;
+ }
+
+ /** */
+ @Override protected NearCacheConfiguration nearConfiguration() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void checkCache(IgniteEx ignite, IgniteCache cache) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void updateCache(IgniteEx ignite, IgniteCache cache) throws Exception {
+ final int k = ThreadLocalRandom.current().nextInt(RANGE);
+
+ final String[] keys = new String[KEYS_CNT];
+
+ for (int i = 0; i < keys.length; i++)
+ keys[i] = "key-" + k + "-" + i;
+
+ doInTransaction(ignite, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ Map<String, Long> map = new HashMap<>();
+
+ for (String key : keys) {
+ Long val = (Long)cache.get(key);
+
+ map.put(key, val);
+ }
+
+ Set<Long> values = new HashSet<>(map.values());
+
+ if (values.size() != 1) {
+ // Print all usefull information and finish.
+ U.error(log, "Got different values for keys [map=" + map + "]");
+
+ log.info("Cache content:");
+
+ for (int k = 0; k < RANGE; k++) {
+ for (int i = 0; i < KEYS_CNT; i++) {
+ String key = "key-" + k + "-" + i;
+
+ Long val = (Long)cache.get(key);
+
+ if (val != null)
+ log.info("Entry [key=" + key + ", val=" + val + "]");
+ }
+ }
+
+ throw new IllegalStateException("Found different values for keys (see above information) [map="
+ + map + ']');
+ }
+
+ final Long oldVal = map.get(keys[0]);
+
+ final Long newVal = oldVal == null ? 0 : oldVal + 1;
+
+ for (String key : keys)
+ cache.put(key, newVal);
+
+ return null;
+ }
+ });
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/077af17f/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheLoadConsistencyTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheLoadConsistencyTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheLoadConsistencyTestSuite.java
new file mode 100644
index 0000000..cd0be9c
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheLoadConsistencyTestSuite.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.internal.processors.cache.distributed.CacheNearDisabledAtomicInvokeRestartSelfTest;
+import org.apache.ignite.internal.processors.cache.distributed.CacheNearDisabledTransactionalInvokeRestartSelfTest;
+import org.apache.ignite.internal.processors.cache.distributed.CacheNearDisabledTransactionalWriteReadRestartSelfTest;
+
+/**
+ * Test suite.
+ */
+public class IgniteCacheLoadConsistencyTestSuite extends TestSuite {
+ /**
+ * @return Ignite Cache Failover test suite.
+ * @throws Exception Thrown in case of the failure.
+ */
+ public static TestSuite suite() throws Exception {
+ TestSuite suite = new TestSuite("Cache Load Consistency Test Suite");
+
+ suite.addTestSuite(CacheNearDisabledAtomicInvokeRestartSelfTest.class);
+ suite.addTestSuite(CacheNearDisabledTransactionalInvokeRestartSelfTest.class);
+ suite.addTestSuite(CacheNearDisabledTransactionalWriteReadRestartSelfTest.class);
+
+ return suite;
+ }
+}
[28/50] [abbrv] ignite git commit: IGNITE-1480: Added "IsClient" flag
to IClusterNode interface.
Posted by vo...@apache.org.
IGNITE-1480: Added "IsClient" flag to IClusterNode interface.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9879bed8
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9879bed8
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9879bed8
Branch: refs/heads/ignite-1651
Commit: 9879bed8026d2ac181d146e537de4ae407951fb5
Parents: 91eeab7
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Tue Oct 20 15:54:41 2015 +0300
Committer: thatcoach <pp...@list.ru>
Committed: Tue Oct 20 15:54:41 2015 +0300
----------------------------------------------------------------------
.../platform/PlatformContextImpl.java | 1 +
.../IgniteStartStopTest.cs | 6 ++-
.../Apache.Ignite.Core/Cluster/IClusterNode.cs | 11 +++++
.../Impl/Cluster/ClusterNodeImpl.cs | 45 +++++++++-----------
4 files changed, 37 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9879bed8/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
index 3895506..0999f6a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
@@ -221,6 +221,7 @@ public class PlatformContextImpl implements PlatformContext {
w.writeLong(node.order());
w.writeBoolean(node.isLocal());
w.writeBoolean(node.isDaemon());
+ w.writeBoolean(node.isClient());
writeClusterMetrics(w, node.metrics());
out.synchronize();
http://git-wip-us.apache.org/repos/asf/ignite/blob/9879bed8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
index d16063f..d302046 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
@@ -311,12 +311,16 @@ namespace Apache.Ignite.Core.Tests
try
{
- using (Ignition.Start(servCfg)) // start server-mode ignite first
+ using (var serv = Ignition.Start(servCfg)) // start server-mode ignite first
{
+ Assert.IsFalse(serv.GetCluster().GetLocalNode().IsClient);
+
Ignition.ClientMode = true;
using (var grid = Ignition.Start(clientCfg))
{
+ Assert.IsTrue(grid.GetCluster().GetLocalNode().IsClient);
+
UseIgnite(grid);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9879bed8/modules/platforms/dotnet/Apache.Ignite.Core/Cluster/IClusterNode.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cluster/IClusterNode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cluster/IClusterNode.cs
index 8287821..ccb0e03 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cluster/IClusterNode.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cluster/IClusterNode.cs
@@ -109,6 +109,17 @@ namespace Apache.Ignite.Core.Cluster
bool IsDaemon { get; }
/// <summary>
+ /// Gets a value indicating whether or not this node is connected to cluster as a client.
+ /// <para />
+ /// Do not confuse client in terms of discovery and client in terms of cache.
+ /// Cache clients cannot carry data, while topology clients connect to the topology in a different way.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if this node is a client node, <c>false otherwise.</c>.
+ /// </value>
+ bool IsClient { get; }
+
+ /// <summary>
/// Gets metrics snapshot for this node. Note that node metrics are constantly updated
/// and provide up to date information about nodes. For example, you can get
/// an idea about CPU load on remote node via <see cref="IClusterMetrics.CurrentCpuLoad"/>.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9879bed8/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs
index 1b6358a..1913cef 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs
@@ -46,10 +46,13 @@ namespace Apache.Ignite.Core.Impl.Cluster
private readonly long _order;
/** Local flag. */
- private readonly bool _local;
+ private readonly bool _isLocal;
/** Daemon flag. */
- private readonly bool _daemon;
+ private readonly bool _isDaemon;
+
+ /** Client flag. */
+ private readonly bool _isClient;
/** Metrics. */
private volatile ClusterMetricsImpl _metrics;
@@ -73,8 +76,9 @@ namespace Apache.Ignite.Core.Impl.Cluster
_addrs = reader.ReadGenericCollection<string>().AsReadOnly();
_hosts = reader.ReadGenericCollection<string>().AsReadOnly();
_order = reader.ReadLong();
- _local = reader.ReadBoolean();
- _daemon = reader.ReadBoolean();
+ _isLocal = reader.ReadBoolean();
+ _isDaemon = reader.ReadBoolean();
+ _isClient = reader.ReadBoolean();
_metrics = reader.ReadBoolean() ? new ClusterMetricsImpl(reader) : null;
}
@@ -120,46 +124,31 @@ namespace Apache.Ignite.Core.Impl.Cluster
/** <inheritDoc /> */
public ICollection<string> Addresses
{
- get
- {
- return _addrs;
- }
+ get { return _addrs; }
}
/** <inheritDoc /> */
public ICollection<string> HostNames
{
- get
- {
- return _hosts;
- }
+ get { return _hosts; }
}
/** <inheritDoc /> */
public long Order
{
- get
- {
- return _order;
- }
+ get { return _order; }
}
/** <inheritDoc /> */
public bool IsLocal
{
- get
- {
- return _local;
- }
+ get { return _isLocal; }
}
/** <inheritDoc /> */
public bool IsDaemon
{
- get
- {
- return _daemon;
- }
+ get { return _isDaemon; }
}
/** <inheritDoc /> */
@@ -189,7 +178,13 @@ namespace Apache.Ignite.Core.Impl.Cluster
return oldMetrics;
}
-
+
+ /** <inheritDoc /> */
+ public bool IsClient
+ {
+ get { return _isClient; }
+ }
+
/** <inheritDoc /> */
public override string ToString()
{
[41/50] [abbrv] ignite git commit: Merge branch 'master' into
ignite-1486
Posted by vo...@apache.org.
Merge branch 'master' into ignite-1486
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e4dba7bf
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e4dba7bf
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e4dba7bf
Branch: refs/heads/ignite-1651
Commit: e4dba7bfca2316eedfb476ba98253dbc943f7db6
Parents: 27ae688 e9524ce
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Oct 22 12:01:46 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Oct 22 12:01:46 2015 +0300
----------------------------------------------------------------------
DEVNOTES.txt | 3 +-
assembly/dependencies-hadoop.xml | 1 +
assembly/release-fabric-lgpl.xml | 63 ++++
assembly/release-hadoop-lgpl.xml | 39 ++
examples-lgpl/README.txt | 27 ++
examples-lgpl/config/example-cache.xml | 73 ++++
examples-lgpl/config/example-ignite.xml | 83 +++++
examples-lgpl/config/hibernate/README.txt | 8 +
.../hibernate/example-hibernate-L2-cache.xml | 64 ++++
examples-lgpl/pom-standalone.xml | 186 ++++++++++
examples-lgpl/pom.xml | 128 +++++++
.../hibernate/HibernateL2CacheExample.java | 245 +++++++++++++
.../examples/datagrid/hibernate/Post.java | 130 +++++++
.../examples/datagrid/hibernate/User.java | 154 ++++++++
.../datagrid/hibernate/package-info.java | 22 ++
.../hibernate/CacheHibernatePersonStore.java | 122 +++++++
.../hibernate/CacheHibernateStoreExample.java | 151 ++++++++
.../datagrid/store/hibernate/Person.hbm.xml | 34 ++
.../datagrid/store/hibernate/hibernate.cfg.xml | 41 +++
.../datagrid/store/hibernate/package-info.java | 22 ++
.../misc/schedule/ComputeScheduleExample.java | 82 +++++
.../examples/misc/schedule/package-info.java | 22 ++
.../misc/schedule/ComputeScheduleExample.java | 68 ++++
.../java8/misc/schedule/package-info.java | 22 ++
.../ignite/examples/java8/package-info.java | 23 ++
.../scalar/examples/ScalarScheduleExample.scala | 66 ++++
...ibernateL2CacheExampleMultiNodeSelfTest.java | 31 ++
.../HibernateL2CacheExampleSelfTest.java | 33 ++
.../IgniteLgplExamplesSelfTestSuite.java | 48 +++
...ibernateL2CacheExampleMultiNodeSelfTest.java | 29 ++
.../HibernateL2CacheExampleSelfTest.java | 37 ++
.../IgniteLgplExamplesJ8SelfTestSuite.java | 46 +++
.../ScalarLgplExamplesMultiNodeSelfTest.scala | 33 ++
.../examples/ScalarLgplExamplesSelfTest.scala | 36 ++
.../ScalarLgplExamplesSelfTestSuite.scala | 37 ++
examples/config/hibernate/README.txt | 8 -
.../hibernate/example-hibernate-L2-cache.xml | 64 ----
examples/pom-standalone.xml | 12 -
examples/pom.xml | 12 -
.../hibernate/HibernateL2CacheExample.java | 245 -------------
.../examples/datagrid/hibernate/Post.java | 130 -------
.../examples/datagrid/hibernate/User.java | 154 --------
.../datagrid/hibernate/package-info.java | 22 --
.../hibernate/CacheHibernatePersonStore.java | 122 -------
.../hibernate/CacheHibernateStoreExample.java | 151 --------
.../datagrid/store/hibernate/Person.hbm.xml | 34 --
.../datagrid/store/hibernate/hibernate.cfg.xml | 41 ---
.../datagrid/store/hibernate/package-info.java | 22 --
.../misc/schedule/ComputeScheduleExample.java | 82 -----
.../examples/misc/schedule/package-info.java | 22 --
.../misc/schedule/ComputeScheduleExample.java | 68 ----
.../java8/misc/schedule/package-info.java | 22 --
.../scalar/examples/ScalarScheduleExample.scala | 66 ----
...ibernateL2CacheExampleMultiNodeSelfTest.java | 31 --
.../HibernateL2CacheExampleSelfTest.java | 33 --
.../testsuites/IgniteExamplesSelfTestSuite.java | 4 -
...ibernateL2CacheExampleMultiNodeSelfTest.java | 29 --
.../HibernateL2CacheExampleSelfTest.java | 37 --
.../tests/examples/ScalarExamplesSelfTest.scala | 5 -
.../internal/portable/PortableContext.java | 12 +-
.../processors/cache/GridCacheAdapter.java | 357 +++++++++++--------
.../cache/GridCacheClearAllRunnable.java | 18 +-
.../cache/GridCacheConcurrentMap.java | 4 +-
.../processors/cache/GridCacheProxyImpl.java | 14 +-
.../processors/cache/IgniteCacheProxy.java | 2 +-
.../processors/cache/IgniteInternalCache.java | 19 +-
.../distributed/dht/GridDhtCacheAdapter.java | 6 +-
.../distributed/near/GridNearCacheAdapter.java | 21 +-
.../near/GridNearCacheClearAllRunnable.java | 9 +-
.../processors/igfs/IgfsMetaManager.java | 10 +-
.../ignite/spi/deployment/DeploymentSpi.java | 8 +-
modules/core/src/test/config/tests.properties | 3 +
.../cache/CacheAffinityCallSelfTest.java | 4 +-
.../cache/GridCacheClearSelfTest.java | 308 ++++++++++++++++
.../CacheAbstractRestartSelfTest.java | 247 +++++++++++++
...NearDisabledAtomicInvokeRestartSelfTest.java | 179 ++++++++++
...abledTransactionalInvokeRestartSelfTest.java | 173 +++++++++
...edTransactionalWriteReadRestartSelfTest.java | 124 +++++++
...niteCacheClientNodeChangingTopologyTest.java | 4 +-
.../dht/GridCacheDhtEntrySelfTest.java | 2 +-
.../dht/GridCacheTxNodeFailureSelfTest.java | 2 +
...gniteAtomicLongChangingTopologySelfTest.java | 4 +-
...ledFairAffinityMultiNodeFullApiSelfTest.java | 8 +-
...icOffHeapTieredMultiNodeFullApiSelfTest.java | 7 +-
.../replicated/GridReplicatedTxPreloadTest.java | 7 +-
.../IgniteCacheFullApiSelfTestSuite.java | 8 +-
.../IgniteCacheLoadConsistencyTestSuite.java | 42 +++
modules/extdata/uri/pom.xml | 11 +-
.../CacheHibernateBlobStoreSelfTest.java | 6 +-
.../cache/SqlFieldsQuerySelfTest.java | 172 +++++++++
.../IgniteCacheQuerySelfTestSuite.java | 2 +
.../spi/deployment/uri/UriDeploymentSpi.java | 93 +++--
.../scanners/http/UriDeploymentHttpScanner.java | 10 +-
.../http/GridHttpDeploymentSelfTest.java | 132 ++++++-
pom.xml | 79 +++-
95 files changed, 4057 insertions(+), 1675 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4dba7bf/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java
----------------------------------------------------------------------
diff --cc examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java
index baa23fc,57ff3ff..f68ce95
--- a/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java
+++ b/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java
@@@ -93,12 -88,7 +90,11 @@@ public class IgniteExamplesSelfTestSuit
suite.addTest(new TestSuite(TaskExamplesMultiNodeSelfTest.class));
suite.addTest(new TestSuite(MemcacheRestExamplesMultiNodeSelfTest.class));
suite.addTest(new TestSuite(MonteCarloExamplesMultiNodeSelfTest.class));
- suite.addTest(new TestSuite(HibernateL2CacheExampleMultiNodeSelfTest.class));
+ // Portable.
+ suite.addTest(new TestSuite(CacheClientPortableExampleTest.class));
+ suite.addTest(new TestSuite(ComputeClientPortableExampleTest.class));
+
return suite;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4dba7bf/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4dba7bf/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
[38/50] [abbrv] ignite git commit: Muted
CacheHibernateBlobStoreSelfTest.testSimpleMultithreading muted
Posted by vo...@apache.org.
Muted CacheHibernateBlobStoreSelfTest.testSimpleMultithreading muted
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c28af3c4
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c28af3c4
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c28af3c4
Branch: refs/heads/ignite-1651
Commit: c28af3c43b172279c4c25d46bca471ecea9d4c36
Parents: 9ffe402
Author: ashutak <as...@gridgain.com>
Authored: Wed Oct 21 15:03:28 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Wed Oct 21 15:03:28 2015 +0300
----------------------------------------------------------------------
.../cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c28af3c4/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java b/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
index c900405..d3d2b52 100644
--- a/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
+++ b/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
@@ -106,4 +106,8 @@ public class CacheHibernateBlobStoreSelfTest extends
// Store will be implicitly initialized.
store.load("key");
}
-}
\ No newline at end of file
+
+ @Override public void testSimpleMultithreading() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1757");
+ }
+}
[48/50] [abbrv] ignite git commit: Merge branch 'ignite-1282' into
ignite-1651
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ec58b87c/modules/platforms/cpp/core-test/src/portable_reader_writer_test.cpp
----------------------------------------------------------------------
diff --cc modules/platforms/cpp/core-test/src/portable_reader_writer_test.cpp
index 0000000,0825ecc..1b7c319
mode 000000,100644..100644
--- a/modules/platforms/cpp/core-test/src/portable_reader_writer_test.cpp
+++ b/modules/platforms/cpp/core-test/src/portable_reader_writer_test.cpp
@@@ -1,0 -1,2016 +1,2017 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ #ifndef _MSC_VER
+ #define BOOST_TEST_DYN_LINK
+ #endif
+
+ #include <boost/test/unit_test.hpp>
+
+ #include "ignite/impl/interop/interop.h"
+ #include "ignite/portable/portable.h"
+
+ #include "ignite/portable_test_defs.h"
+ #include "ignite/portable_test_utils.h"
+
+ using namespace ignite;
+ using namespace ignite::impl::interop;
+ using namespace ignite::impl::portable;
+ using namespace ignite::portable;
+ using namespace ignite_test::core::portable;
+
+ template<typename T>
+ void CheckPrimitive(T val)
+ {
+ TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
- out.Position(18);
++ out.Position(19);
+
+ PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+ PortableWriter writer(&writerImpl);
+
+ try
+ {
+ Write<T>(writer, NULL, val);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ Write<T>(writer, "test", val);
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
- in.Position(18);
++ in.Position(19);
+
+ PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100);
+ PortableReader reader(&readerImpl);
+
+ try
+ {
+ Read<T>(reader, NULL);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ T readVal = Read<T>(reader, "test");
+
+ BOOST_REQUIRE(readVal == val);
+ }
+
+ template<typename T>
+ void CheckPrimitiveArray(T dflt, T val1, T val2)
+ {
+ const char* fieldName = "test";
+
+ TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+ PortableWriter writer(&writerImpl);
+
+ InteropInputStream in(&mem);
+ PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100);
+ PortableReader reader(&readerImpl);
+
- out.Position(18);
++ out.Position(19);
+
+ try
+ {
+ T nullFieldArr[2];
+
+ nullFieldArr[0] = val1;
+ nullFieldArr[1] = val2;
+
+ WriteArray<T>(writer, NULL, nullFieldArr, 2);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ // 1. Write NULL and see what happens.
+ WriteArray<T>(writer, fieldName, NULL, 0);
+
+ out.Synchronize();
+ in.Synchronize();
+
- in.Position(18);
++ in.Position(19);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 0) == -1);
+
- in.Position(18);
++ in.Position(19);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 2) == -1);
+
+ T arr1[2];
+ arr1[0] = dflt;
+ arr1[1] = dflt;
+
- in.Position(18);
++ in.Position(19);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 1) == -1);
+
+ BOOST_REQUIRE(arr1[0] == dflt);
+ BOOST_REQUIRE(arr1[1] == dflt);
+
+ // 2. Write empty array.
+ T arr2[2];
+ arr2[0] = val1;
+ arr2[1] = val2;
+
- out.Position(18);
++ out.Position(19);
+
+ WriteArray<T>(writer, fieldName, arr2, 0);
+
+ out.Synchronize();
+ in.Synchronize();
+
- in.Position(18);
++ in.Position(19);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 0) == 0);
+
- in.Position(18);
++ in.Position(19);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 2) == 0);
+
- in.Position(18);
++ in.Position(19);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 0) == 0);
+ BOOST_REQUIRE(arr1[0] == dflt);
+ BOOST_REQUIRE(arr1[1] == dflt);
+
- in.Position(18);
++ in.Position(19);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 2) == 0);
+ BOOST_REQUIRE(arr1[0] == dflt);
+ BOOST_REQUIRE(arr1[1] == dflt);
+
+ // 3. Partial array write.
- out.Position(18);
++ out.Position(19);
+
+ WriteArray<T>(writer, fieldName, arr2, 1);
+
+ out.Synchronize();
+ in.Synchronize();
+
- in.Position(18);
++ in.Position(19);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 0) == 1);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 2) == 1);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 0) == 1);
+ BOOST_REQUIRE(arr1[0] == dflt);
+ BOOST_REQUIRE(arr1[1] == dflt);
+
- in.Position(18);
++ in.Position(19);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 1) == 1);
+ BOOST_REQUIRE(arr1[0] == val1);
+ BOOST_REQUIRE(arr1[1] == dflt);
+ arr1[0] = dflt;
+
- in.Position(18);
++ in.Position(19);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 2) == 1);
+ BOOST_REQUIRE(arr1[0] == val1);
+ BOOST_REQUIRE(arr1[1] == dflt);
+ arr1[0] = dflt;
+
+ // 4. Full array write.
- out.Position(18);
++ out.Position(19);
+
+ WriteArray<T>(writer, fieldName, arr2, 2);
+
+ out.Synchronize();
+ in.Synchronize();
+
- in.Position(18);
++ in.Position(19);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 0) == 2);
+
- in.Position(18);
++ in.Position(19);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 2) == 2);
+
+ try
+ {
+ ReadArray<T>(reader, NULL, arr1, 2);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 0) == 2);
+ BOOST_REQUIRE(arr1[0] == dflt);
+ BOOST_REQUIRE(arr1[1] == dflt);
+
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 1) == 2);
+ BOOST_REQUIRE(arr1[0] == dflt);
+ BOOST_REQUIRE(arr1[1] == dflt);
+
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 2) == 2);
+ BOOST_REQUIRE(arr1[0] == val1);
+ BOOST_REQUIRE(arr1[1] == val2);
+ }
+
+ void CheckWritesRestricted(PortableWriter& writer)
+ {
+ try
+ {
+ writer.WriteInt8("field", 1);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ int8_t arr[1];
+
+ writer.WriteInt8Array("field", arr, 1);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ Guid val(1, 1);
+
+ writer.WriteGuid("field", val);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ writer.WriteString("field", "test");
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ writer.WriteArray<int8_t>("field");
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ writer.WriteCollection<int8_t>("field");
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ writer.WriteMap<int8_t, int8_t>("field");
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+ }
+
+ void CheckReadsRestricted(PortableReader& reader)
+ {
+ try
+ {
+ reader.ReadInt8("field");
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ int8_t arr[1];
+
+ reader.ReadInt8Array("field", arr, 1);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ reader.ReadGuid("field");
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ reader.ReadString("field");
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ reader.ReadArray<int8_t>("field");
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ reader.ReadCollection<int8_t>("field");
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ reader.ReadMap<int8_t, int8_t>("field");
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+ }
+
+ void CheckCollectionEmpty(CollectionType* colType)
+ {
+ TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+ PortableWriter writer(&writerImpl);
+
- out.Position(18);
++ out.Position(19);
+
+ PortableCollectionWriter<PortableInner> colWriter = colType ?
+ writer.WriteCollection<PortableInner>("field1", *colType) : writer.WriteCollection<PortableInner>("field1");
+
+ CheckWritesRestricted(writer);
+
+ colWriter.Close();
+
+ writer.WriteInt8("field2", 1);
+
+ try
+ {
+ colWriter.Write(1);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ colWriter.Close();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+ PortableReader reader(&readerImpl);
+
- in.Position(18);
++ in.Position(19);
+
+ PortableCollectionReader<PortableInner> colReader = reader.ReadCollection<PortableInner>("field1");
+
+ if (colType)
+ BOOST_REQUIRE(colReader.GetType() == *colType);
+ else
+ BOOST_REQUIRE(colReader.GetType() == IGNITE_COLLECTION_UNDEFINED);
+
+ BOOST_REQUIRE(colReader.GetSize() == 0);
+ BOOST_REQUIRE(!colReader.HasNext());
+ BOOST_REQUIRE(!colReader.IsNull());
+
+ try
+ {
+ colReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+ }
+
+ void CheckCollection(CollectionType* colType)
+ {
+ PortableInner writeVal1 = PortableInner(1);
+ PortableInner writeVal2 = PortableInner(0);
+ PortableInner writeVal3 = PortableInner(2);
+
+ TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+ PortableWriter writer(&writerImpl);
+
- out.Position(18);
++ out.Position(19);
+
+ PortableCollectionWriter<PortableInner> colWriter = colType ?
+ writer.WriteCollection<PortableInner>("field1", *colType) : writer.WriteCollection<PortableInner>("field1");
+
+ colWriter.Write(writeVal1);
+ colWriter.Write(writeVal2);
+ colWriter.Write(writeVal3);
+
+ CheckWritesRestricted(writer);
+
+ colWriter.Close();
+
+ writer.WriteInt8("field2", 1);
+
+ try
+ {
+ colWriter.Write(1);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ colWriter.Close();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+ PortableReader reader(&readerImpl);
+
- in.Position(18);
++ in.Position(19);
+
+ PortableCollectionReader<PortableInner> colReader = reader.ReadCollection<PortableInner>("field1");
+
+ CheckReadsRestricted(reader);
+
+ if (colType)
+ BOOST_REQUIRE(colReader.GetType() == *colType);
+ else
+ BOOST_REQUIRE(colReader.GetType() == IGNITE_COLLECTION_UNDEFINED);
+
+ BOOST_REQUIRE(colReader.GetSize() == 3);
+ BOOST_REQUIRE(!colReader.IsNull());
+
+ BOOST_REQUIRE(colReader.HasNext());
+ BOOST_REQUIRE(colReader.GetNext().GetValue() == writeVal1.GetValue());
+
+ BOOST_REQUIRE(colReader.HasNext());
+ BOOST_REQUIRE(colReader.GetNext().GetValue() == writeVal2.GetValue());
+
+ BOOST_REQUIRE(colReader.HasNext());
+ BOOST_REQUIRE(colReader.GetNext().GetValue() == writeVal3.GetValue());
+
+ BOOST_REQUIRE(!colReader.HasNext());
+
+ try
+ {
+ colReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+ }
+
+ void CheckCollectionIterators(CollectionType* colType)
+ {
+ typedef std::vector<PortableInner> PortableInnerVector;
+ PortableInnerVector writeValues;
+
+ writeValues.push_back(1);
+ writeValues.push_back(0);
+ writeValues.push_back(2);
+
+ TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+ PortableWriter writer(&writerImpl);
+
+ out.Position(18);
+
+ if (colType)
+ writer.WriteCollection("field1", writeValues.begin(), writeValues.end(), *colType);
+ else
+ writer.WriteCollection("field1", writeValues.begin(), writeValues.end());
+
+ writer.WriteInt8("field2", 1);
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+ PortableReader reader(&readerImpl);
+
+ in.Position(18);
+
+ BOOST_REQUIRE(reader.ReadCollectionSize("field1") == writeValues.size());
+
+ CollectionType expectedCollectionType = colType ? *colType : IGNITE_COLLECTION_UNDEFINED;
+ BOOST_REQUIRE(reader.ReadCollectionType("field1") == expectedCollectionType);
+
+ PortableInnerVector readValues;
+ std::back_insert_iterator<PortableInnerVector> readInsertIterator(readValues);
+
+ reader.ReadCollection<PortableInner>("field1", readInsertIterator);
+
+ BOOST_REQUIRE(readValues.size() == 3);
+
+ BOOST_REQUIRE(readValues[0].GetValue() == writeValues[0].GetValue());
+ BOOST_REQUIRE(readValues[1].GetValue() == writeValues[1].GetValue());
+ BOOST_REQUIRE(readValues[2].GetValue() == writeValues[2].GetValue());
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+ }
+
+ void CheckMapEmpty(MapType* mapType)
+ {
+ TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+ PortableWriter writer(&writerImpl);
+
- out.Position(18);
++ out.Position(19);
+
+ PortableMapWriter<int8_t, PortableInner> mapWriter = mapType ?
+ writer.WriteMap<int8_t, PortableInner>("field1", *mapType) : writer.WriteMap<int8_t, PortableInner>("field1");
+
+ CheckWritesRestricted(writer);
+
+ mapWriter.Close();
+
+ writer.WriteInt8("field2", 1);
+
+ try
+ {
+ mapWriter.Write(1, PortableInner(1));
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ mapWriter.Close();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+ PortableReader reader(&readerImpl);
+
- in.Position(18);
++ in.Position(19);
+
+ PortableMapReader<int8_t, PortableInner> mapReader = reader.ReadMap<int8_t, PortableInner>("field1");
+
+ if (mapType)
+ BOOST_REQUIRE(mapReader.GetType() == *mapType);
+ else
+ BOOST_REQUIRE(mapReader.GetType() == IGNITE_MAP_UNDEFINED);
+
+ BOOST_REQUIRE(mapReader.GetSize() == 0);
+ BOOST_REQUIRE(!mapReader.HasNext());
+ BOOST_REQUIRE(!mapReader.IsNull());
+
+ try
+ {
+ int8_t key;
+ PortableInner val;
+
+ mapReader.GetNext(&key, &val);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+ }
+
+ void CheckMap(MapType* mapType)
+ {
+ PortableInner writeVal1 = PortableInner(1);
+ PortableInner writeVal2 = PortableInner(0);
+ PortableInner writeVal3 = PortableInner(2);
+
+ TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+ PortableWriter writer(&writerImpl);
+
- out.Position(18);
++ out.Position(19);
+
+ PortableMapWriter<int8_t, PortableInner> mapWriter = mapType ?
+ writer.WriteMap<int8_t, PortableInner>("field1", *mapType) : writer.WriteMap<int8_t, PortableInner>("field1");
+
+ mapWriter.Write(1, writeVal1);
+ mapWriter.Write(2, writeVal2);
+ mapWriter.Write(3, writeVal3);
+
+ CheckWritesRestricted(writer);
+
+ mapWriter.Close();
+
+ writer.WriteInt8("field2", 1);
+
+ try
+ {
+ mapWriter.Write(4, PortableInner(4));
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ mapWriter.Close();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+ PortableReader reader(&readerImpl);
+
- in.Position(18);
++ in.Position(19);
+
+ PortableMapReader<int8_t, PortableInner> mapReader = reader.ReadMap<int8_t, PortableInner>("field1");
+
+ CheckReadsRestricted(reader);
+
+ if (mapType)
+ BOOST_REQUIRE(mapReader.GetType() == *mapType);
+ else
+ BOOST_REQUIRE(mapReader.GetType() == IGNITE_MAP_UNDEFINED);
+
+ BOOST_REQUIRE(mapReader.GetSize() == 3);
+ BOOST_REQUIRE(!mapReader.IsNull());
+
+ int8_t key;
+ PortableInner val;
+
+ BOOST_REQUIRE(mapReader.HasNext());
+
+ mapReader.GetNext(&key, &val);
+ BOOST_REQUIRE(key == 1);
+ BOOST_REQUIRE(val.GetValue() == writeVal1.GetValue());
+
+ mapReader.GetNext(&key, &val);
+ BOOST_REQUIRE(key == 2);
+ BOOST_REQUIRE(val.GetValue() == writeVal2.GetValue());
+
+ mapReader.GetNext(&key, &val);
+ BOOST_REQUIRE(key == 3);
+ BOOST_REQUIRE(val.GetValue() == writeVal3.GetValue());
+
+ BOOST_REQUIRE(!mapReader.HasNext());
+
+ try
+ {
+ mapReader.GetNext(&key, &val);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+ }
+
+ BOOST_AUTO_TEST_SUITE(PortableReaderWriterTestSuite)
+
+ BOOST_AUTO_TEST_CASE(TestPrimitiveInt8)
+ {
+ CheckPrimitive<int8_t>(1);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestPrimitiveBool)
+ {
+ CheckPrimitive<bool>(true);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestPrimitiveInt16)
+ {
+ CheckPrimitive<int16_t>(1);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestPrimitiveUInt16)
+ {
+ CheckPrimitive<uint16_t>(1);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestPrimitiveInt32)
+ {
+ CheckPrimitive<int32_t>(1);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestPrimitiveInt64)
+ {
+ CheckPrimitive<int64_t>(1);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestPrimitiveFloat)
+ {
+ CheckPrimitive<float>(1.1f);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestPrimitiveDouble)
+ {
+ CheckPrimitive<double>(1.1);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestPrimitiveGuid)
+ {
+ Guid val(1, 2);
+
+ CheckPrimitive<Guid>(val);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt8)
+ {
+ CheckPrimitiveArray<int8_t>(1, 2, 3);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestPrimitiveArrayBool)
+ {
+ CheckPrimitiveArray<bool>(false, true, false);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt16)
+ {
+ CheckPrimitiveArray<int16_t>(1, 2, 3);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestPrimitiveArrayUInt16)
+ {
+ CheckPrimitiveArray<uint16_t>(1, 2, 3);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt32)
+ {
+ CheckPrimitiveArray<int32_t>(1, 2, 3);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt64)
+ {
+ CheckPrimitiveArray<int64_t>(1, 2, 3);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestPrimitiveArrayFloat)
+ {
+ CheckPrimitiveArray<float>(1.1f, 2.2f, 3.3f);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestPrimitiveArrayDouble)
+ {
+ CheckPrimitiveArray<double>(1.1, 2.2, 3.3);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestPrimitiveArrayGuid)
+ {
+ Guid dflt(1, 2);
+ Guid val1(3, 4);
+ Guid val2(5, 6);
+
+ CheckPrimitiveArray<Guid>(dflt, val1, val2);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestGuidNull)
+ {
+ TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+ PortableWriter writer(&writerImpl);
+
- out.Position(18);
++ out.Position(19);
+
+ try
+ {
+ writer.WriteNull(NULL);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ writer.WriteNull("test");
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100);
+ PortableReader reader(&readerImpl);
+
- in.Position(18);
++ in.Position(19);
+
+ try
+ {
+ reader.ReadGuid(NULL);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ Guid expVal;
+ Guid actualVal = reader.ReadGuid("test");
+
+ BOOST_REQUIRE(actualVal == expVal);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestString) {
+ TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+ PortableWriter writer(&writerImpl);
+
- out.Position(18);
++ out.Position(19);
+
+ const char* writeVal1 = "testtest";
+ const char* writeVal2 = "test";
+ std::string writeVal3 = writeVal1;
+
+ try
+ {
+ writer.WriteString(NULL, writeVal1);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ writer.WriteString(NULL, writeVal1, 4);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ writer.WriteString(NULL, writeVal3);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ writer.WriteString("field1", writeVal1);
+ writer.WriteString("field2", writeVal1, 4);
+ writer.WriteString("field3", writeVal3);
+ writer.WriteString("field4", NULL);
+ writer.WriteString("field5", NULL, 4);
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+ PortableReader reader(&readerImpl);
+
- in.Position(18);
++ in.Position(19);
+
+ try
+ {
+ char nullCheckRes[9];
+
+ reader.ReadString(NULL, nullCheckRes, 9);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ reader.ReadString(NULL);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ char readVal1[9];
+ char readVal2[5];
+
+ BOOST_REQUIRE(reader.ReadString("field1", NULL, 0) == 8);
+ BOOST_REQUIRE(reader.ReadString("field1", NULL, 8) == 8);
+ BOOST_REQUIRE(reader.ReadString("field1", readVal1, 0) == 8);
+ BOOST_REQUIRE(reader.ReadString("field1", readVal1, 4) == 8);
+
+ BOOST_REQUIRE(reader.ReadString("field1", readVal1, 9) == 8);
+ std::string writeVal1Str = writeVal1;
+ std::string readVal1Str = readVal1;
+ BOOST_REQUIRE(readVal1Str.compare(writeVal1Str) == 0);
+
+ BOOST_REQUIRE(reader.ReadString("field2", readVal2, 5) == 4);
+ std::string writeVal2Str = writeVal2;
+ std::string readVal2Str = readVal2;
+ BOOST_REQUIRE(readVal2Str.compare(writeVal2Str) == 0);
+
+ std::string readVal3 = reader.ReadString("field3");
+ BOOST_REQUIRE(readVal3.compare(writeVal3) == 0);
+
+ BOOST_REQUIRE(reader.ReadString("field4", readVal1, 9) == -1);
+ BOOST_REQUIRE(reader.ReadString("field5", readVal1, 9) == -1);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestStringArrayNull)
+ {
+ TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+ PortableWriter writer(&writerImpl);
+
- out.Position(18);
++ out.Position(19);
+
+ writer.WriteNull("field1");
+ writer.WriteInt8("field2", 1);
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+ PortableReader reader(&readerImpl);
+
- in.Position(18);
++ in.Position(19);
+
+ PortableStringArrayReader arrReader = reader.ReadStringArray("field1");
+
+ BOOST_REQUIRE(arrReader.GetSize() == -1);
+ BOOST_REQUIRE(!arrReader.HasNext());
+ BOOST_REQUIRE(arrReader.IsNull());
+
+ try
+ {
+ char res[100];
+
+ arrReader.GetNext(res, 100);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ arrReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestStringArrayEmpty)
+ {
+ TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+ PortableWriter writer(&writerImpl);
+
- out.Position(18);
++ out.Position(19);
+
+ PortableStringArrayWriter arrWriter = writer.WriteStringArray("field1");
+
+ CheckWritesRestricted(writer);
+
+ arrWriter.Close();
+
+ writer.WriteInt8("field2", 1);
+
+ try
+ {
+ const char* val = "test";
+
+ arrWriter.Write(val, 4);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ const char* val = "test";
+
+ arrWriter.Write(val);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ std::string val = "test";
+
+ arrWriter.Write(val);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ arrWriter.Close();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+ PortableReader reader(&readerImpl);
+
- in.Position(18);
++ in.Position(19);
+
+ PortableStringArrayReader arrReader = reader.ReadStringArray("field1");
+
+ BOOST_REQUIRE(arrReader.GetSize() == 0);
+ BOOST_REQUIRE(!arrReader.HasNext());
+ BOOST_REQUIRE(!arrReader.IsNull());
+
+ try
+ {
+ char res[100];
+
+ arrReader.GetNext(res, 100);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ arrReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestStringArray)
+ {
+ const char* writeVal1 = "testtest";
+ const char* writeVal2 = "test";
+ std::string writeVal3 = "test2";
+
+ TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+ PortableWriter writer(&writerImpl);
+
- out.Position(18);
++ out.Position(19);
+
+ PortableStringArrayWriter arrWriter = writer.WriteStringArray("field1");
+
+ arrWriter.Write(writeVal1);
+ arrWriter.Write(writeVal1, 4);
+ arrWriter.Write(NULL); // NULL value.
+ arrWriter.Write(NULL, 100); // NULL value again.
+ arrWriter.Write(writeVal3);
+
+ CheckWritesRestricted(writer);
+
+ arrWriter.Close();
+
+ writer.WriteInt8("field2", 1);
+
+ try
+ {
+ const char* val = "test";
+
+ arrWriter.Write(val, 4);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ const char* val = "test";
+
+ arrWriter.Write(val);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ std::string val = "test";
+
+ arrWriter.Write(val);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ arrWriter.Close();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+ PortableReader reader(&readerImpl);
+
- in.Position(18);
++ in.Position(19);
+
+ PortableStringArrayReader arrReader = reader.ReadStringArray("field1");
+
+ CheckReadsRestricted(reader);
+
+ BOOST_REQUIRE(arrReader.GetSize() == 5);
+ BOOST_REQUIRE(!arrReader.IsNull());
+
+ // 1. Read first value.
+ BOOST_REQUIRE(arrReader.HasNext());
+
+ char readVal1[9];
+
+ BOOST_REQUIRE(arrReader.GetNext(NULL, 0) == 8);
+ BOOST_REQUIRE(arrReader.GetNext(NULL, 8) == 8);
+ BOOST_REQUIRE(arrReader.GetNext(readVal1, 0) == 8);
+ BOOST_REQUIRE(arrReader.GetNext(readVal1, 4) == 8);
+
+ BOOST_REQUIRE(arrReader.GetNext(readVal1, 9) == 8);
+ std::string writeVal1Str = writeVal1;
+ std::string readVal1Str = readVal1;
+ BOOST_REQUIRE(readVal1Str.compare(writeVal1Str) == 0);
+
+ // 2. Read second value.
+ BOOST_REQUIRE(arrReader.HasNext());
+
+ char readVal2[5];
+
+ BOOST_REQUIRE(arrReader.GetNext(readVal2, 5) == 4);
+ std::string writeVal2Str = writeVal2;
+ std::string readVal2Str = readVal2;
+ BOOST_REQUIRE(readVal2Str.compare(writeVal2Str) == 0);
+
+ // 3. Read NULL.
+ BOOST_REQUIRE(arrReader.HasNext());
+
+ BOOST_REQUIRE(arrReader.GetNext(readVal1, 4) == -1);
+ readVal1Str = readVal1;
+ BOOST_REQUIRE(readVal1Str.compare(writeVal1Str) == 0);
+
+ // 4. Read NULL again, this time through another method.
+ BOOST_REQUIRE(arrReader.HasNext());
+
+ std::string readNullVal = arrReader.GetNext();
+
+ BOOST_REQUIRE(readNullVal.length() == 0);
+
+ // 5. Read third value.
+ BOOST_REQUIRE(arrReader.HasNext());
+
+ std::string readVal3 = arrReader.GetNext();
+ BOOST_REQUIRE(readVal3.compare(writeVal3) == 0);
+
+ BOOST_REQUIRE(!arrReader.HasNext());
+
+ try
+ {
+ char res[100];
+
+ arrReader.GetNext(res, 100);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ arrReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestObject)
+ {
+ PortableInner writeVal1(1);
+ PortableInner writeVal2(0);
+
+ TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+ PortableWriter writer(&writerImpl);
+
- out.Position(18);
++ out.Position(19);
+
+ writer.WriteObject("field1", writeVal1);
+ writer.WriteObject("field2", writeVal2);
+ writer.WriteNull("field3");
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+ PortableReader reader(&readerImpl);
+
- in.Position(18);
++ in.Position(19);
+
+ PortableInner readVal1 = reader.ReadObject<PortableInner>("field1");
+ BOOST_REQUIRE(writeVal1.GetValue() == readVal1.GetValue());
+
+ PortableInner readVal2 = reader.ReadObject<PortableInner>("field2");
+ BOOST_REQUIRE(writeVal2.GetValue() == readVal2.GetValue());
+
+ PortableInner readVal3 = reader.ReadObject<PortableInner>("field3");
+ BOOST_REQUIRE(0 == readVal3.GetValue());
+ }
+
+ BOOST_AUTO_TEST_CASE(TestNestedObject)
+ {
+ PortableOuter writeVal1(1, 2);
+ PortableOuter writeVal2(0, 0);
+
+ TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+ PortableWriter writer(&writerImpl);
+
- out.Position(18);
++ out.Position(19);
+
+ writer.WriteObject("field1", writeVal1);
+ writer.WriteObject("field2", writeVal2);
+ writer.WriteNull("field3");
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+ PortableReader reader(&readerImpl);
+
- in.Position(18);
++ in.Position(19);
+
+ PortableOuter readVal1 = reader.ReadObject<PortableOuter>("field1");
+ BOOST_REQUIRE(writeVal1.GetValue() == readVal1.GetValue());
+ BOOST_REQUIRE(writeVal1.GetInner().GetValue() == readVal1.GetInner().GetValue());
+
+ PortableOuter readVal2 = reader.ReadObject<PortableOuter>("field2");
+ BOOST_REQUIRE(writeVal2.GetValue() == readVal2.GetValue());
+ BOOST_REQUIRE(writeVal2.GetInner().GetValue() == readVal2.GetInner().GetValue());
+
+ PortableOuter readVal3 = reader.ReadObject<PortableOuter>("field3");
+ BOOST_REQUIRE(0 == readVal3.GetValue());
+ BOOST_REQUIRE(0 == readVal3.GetInner().GetValue());
+ }
+
+ BOOST_AUTO_TEST_CASE(TestArrayNull)
+ {
+ TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+ PortableWriter writer(&writerImpl);
+
- out.Position(18);
++ out.Position(19);
+
+ writer.WriteNull("field1");
+ writer.WriteInt8("field2", 1);
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+ PortableReader reader(&readerImpl);
+
- in.Position(18);
++ in.Position(19);
+
+ PortableArrayReader<PortableInner> arrReader = reader.ReadArray<PortableInner>("field1");
+
+ BOOST_REQUIRE(arrReader.GetSize() == -1);
+ BOOST_REQUIRE(!arrReader.HasNext());
+ BOOST_REQUIRE(arrReader.IsNull());
+
+ try
+ {
+ arrReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestArrayEmpty)
+ {
+ TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+ PortableWriter writer(&writerImpl);
+
- out.Position(18);
++ out.Position(19);
+
+ PortableArrayWriter<PortableInner> arrWriter = writer.WriteArray<PortableInner>("field1");
+
+ CheckWritesRestricted(writer);
+
+ arrWriter.Close();
+
+ writer.WriteInt8("field2", 1);
+
+ try
+ {
+ arrWriter.Write(1);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ arrWriter.Close();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+ PortableReader reader(&readerImpl);
+
- in.Position(18);
++ in.Position(19);
+
+ PortableArrayReader<PortableInner> arrReader = reader.ReadArray<PortableInner>("field1");
+
+ BOOST_REQUIRE(arrReader.GetSize() == 0);
+ BOOST_REQUIRE(!arrReader.HasNext());
+ BOOST_REQUIRE(!arrReader.IsNull());
+
+ try
+ {
+ arrReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestArray)
+ {
+ PortableInner writeVal1 = PortableInner(1);
+ PortableInner writeVal2 = PortableInner(0);
+ PortableInner writeVal3 = PortableInner(2);
+
+ TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+ PortableWriter writer(&writerImpl);
+
- out.Position(18);
++ out.Position(19);
+
+ PortableArrayWriter<PortableInner> arrWriter = writer.WriteArray<PortableInner>("field1");
+
+ arrWriter.Write(writeVal1);
+ arrWriter.Write(writeVal2);
+ arrWriter.Write(writeVal3);
+
+ CheckWritesRestricted(writer);
+
+ arrWriter.Close();
+
+ writer.WriteInt8("field2", 1);
+
+ try
+ {
+ arrWriter.Write(1);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ try
+ {
+ arrWriter.Close();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+ PortableReader reader(&readerImpl);
+
- in.Position(18);
++ in.Position(19);
+
+ PortableArrayReader<PortableInner> arrReader = reader.ReadArray<PortableInner>("field1");
+
+ CheckReadsRestricted(reader);
+
+ BOOST_REQUIRE(arrReader.GetSize() == 3);
+ BOOST_REQUIRE(!arrReader.IsNull());
+
+ BOOST_REQUIRE(arrReader.HasNext());
+ BOOST_REQUIRE(arrReader.GetNext().GetValue() == writeVal1.GetValue());
+
+ BOOST_REQUIRE(arrReader.HasNext());
+ BOOST_REQUIRE(arrReader.GetNext().GetValue() == writeVal2.GetValue());
+
+ BOOST_REQUIRE(arrReader.HasNext());
+ BOOST_REQUIRE(arrReader.GetNext().GetValue() == writeVal3.GetValue());
+
+ BOOST_REQUIRE(!arrReader.HasNext());
+
+ try
+ {
+ arrReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestCollectionNull)
+ {
+ TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+ PortableWriter writer(&writerImpl);
+
- out.Position(18);
++ out.Position(19);
+
+ writer.WriteNull("field1");
+ writer.WriteInt8("field2", 1);
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+ PortableReader reader(&readerImpl);
+
- in.Position(18);
++ in.Position(19);
+
+ PortableCollectionReader<PortableInner> colReader = reader.ReadCollection<PortableInner>("field1");
+
+ BOOST_REQUIRE(colReader.GetType() == IGNITE_COLLECTION_UNDEFINED);
+ BOOST_REQUIRE(colReader.GetSize() == -1);
+ BOOST_REQUIRE(!colReader.HasNext());
+ BOOST_REQUIRE(colReader.IsNull());
+
+ try
+ {
+ colReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestCollectionEmpty)
+ {
+ CheckCollectionEmpty(NULL);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestCollectionEmptyTyped)
+ {
+ CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
+
+ CheckCollectionEmpty(&typ);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestCollection)
+ {
+ CheckCollection(NULL);
+ }
+
+ BOOST_AUTO_TEST_CASE(testCollectionTyped)
+ {
+ CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
+
+ CheckCollection(&typ);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestCollectionIterators)
+ {
+ CheckCollectionIterators(NULL);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestCollectionIteratorsTyped)
+ {
+ CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
+
+ CheckCollectionIterators(&typ);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestMapNull)
+ {
+ TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+ PortableWriter writer(&writerImpl);
+
- out.Position(18);
++ out.Position(19);
+
+ writer.WriteNull("field1");
+ writer.WriteInt8("field2", 1);
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+ PortableReader reader(&readerImpl);
+
- in.Position(18);
++ in.Position(19);
+
+ PortableMapReader<int8_t, PortableInner> mapReader = reader.ReadMap<int8_t, PortableInner>("field1");
+
+ BOOST_REQUIRE(mapReader.GetType() == IGNITE_MAP_UNDEFINED);
+ BOOST_REQUIRE(mapReader.GetSize() == -1);
+ BOOST_REQUIRE(!mapReader.HasNext());
+ BOOST_REQUIRE(mapReader.IsNull());
+
+ try
+ {
+ int8_t key;
+ PortableInner val;
+
+ mapReader.GetNext(&key, &val);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestMapEmpty)
+ {
+ CheckMapEmpty(NULL);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestMapEmptyTyped)
+ {
+ MapType typ = IGNITE_MAP_CONCURRENT_HASH_MAP;
+
+ CheckMapEmpty(&typ);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestMap)
+ {
+ CheckMap(NULL);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestMapTyped)
+ {
+ MapType typ = IGNITE_MAP_CONCURRENT_HASH_MAP;
+
+ CheckMap(&typ);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestRawMode)
+ {
+ TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+ PortableWriter writer(&writerImpl);
+
- out.Position(18);
++ out.Position(19);
+
+ PortableRawWriter rawWriter = writer.RawWriter();
+
+ try
+ {
+ writer.RawWriter();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ rawWriter.WriteInt8(1);
+
+ CheckWritesRestricted(writer);
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 18);
++ PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 19);
+ PortableReader reader(&readerImpl);
+
- in.Position(18);
++ in.Position(19);
+
+ PortableRawReader rawReader = reader.RawReader();
+
+ try
+ {
+ reader.RawReader();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+
+ CheckReadsRestricted(reader);
+ }
+
+ BOOST_AUTO_TEST_CASE(TestFieldSeek)
+ {
+ TemplatedPortableIdResolver<PortableFields> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ PortableWriterImpl writer(&out, NULL);
+
+ PortableFields writeVal(1, 2, 3, 4);
+
+ writer.WriteTopObject<PortableFields>(writeVal);
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t pos = in.Position();
+ in.ReadInt8(); // We do not need a header here.
++ in.ReadInt8(); // We do not need proto ver here.
+ bool usrType = in.ReadBool();
+ int32_t typeId = in.ReadInt32();
+ int32_t hashCode = in.ReadInt32();
+ int32_t len = in.ReadInt32();
+ int32_t rawOff = in.ReadInt32();
+
+ PortableReaderImpl readerImpl(&in, &idRslvr, pos, usrType, typeId, hashCode, len, rawOff);
+ PortableReader reader(&readerImpl);
+
+ // 1. Clockwise.
+ BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+ BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+ BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+ BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+
+ // 2. Counter closkwise.
- in.Position(18);
++ in.Position(19);
+ BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+ BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+ BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+ BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+
+ // 3. Same field twice.
- in.Position(18);
++ in.Position(19);
+ BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+ BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+
- in.Position(18);
++ in.Position(19);
+ BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+ BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+
+ // 4. Read missing field in between.
- in.Position(18);
++ in.Position(19);
+ BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+ BOOST_REQUIRE(reader.ReadInt32("missing") == 0);
+ BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+
- in.Position(18);
++ in.Position(19);
+ BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+ BOOST_REQUIRE(reader.ReadInt32("missing") == 0);
+ BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+
+ // 5. Invalid field type.
- in.Position(18);
++ in.Position(19);
+ BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+
+ try
+ {
+ reader.ReadInt64("val2");
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+
+ // 6. Read missing primitive fields.
+ BOOST_REQUIRE(reader.ReadInt8("missing") == 0);
+ BOOST_REQUIRE(reader.ReadBool("missing") == false);
+ BOOST_REQUIRE(reader.ReadInt16("missing") == 0);
+ BOOST_REQUIRE(reader.ReadUInt16("missing") == 0);
+ BOOST_REQUIRE(reader.ReadInt32("missing") == 0);
+ BOOST_REQUIRE(reader.ReadInt64("missing") == 0);
+ BOOST_REQUIRE(reader.ReadFloat("missing") == 0);
+ BOOST_REQUIRE(reader.ReadDouble("missing") == 0);
+
+ BOOST_REQUIRE(reader.ReadGuid("missing").GetMostSignificantBits() == 0);
+ BOOST_REQUIRE(reader.ReadGuid("missing").GetLeastSignificantBits() == 0);
+
+ // 7. Read missing primitive array fields.
+ BOOST_REQUIRE(reader.ReadInt8Array("missing", NULL, 1) == -1);
+ BOOST_REQUIRE(reader.ReadBoolArray("missing", NULL, 1) == -1);
+ BOOST_REQUIRE(reader.ReadInt16Array("missing", NULL, 1) == -1);
+ BOOST_REQUIRE(reader.ReadUInt16Array("missing", NULL, 1) == -1);
+ BOOST_REQUIRE(reader.ReadInt32Array("missing", NULL, 1) == -1);
+ BOOST_REQUIRE(reader.ReadInt64Array("missing", NULL, 1) == -1);
+ BOOST_REQUIRE(reader.ReadFloatArray("missing", NULL, 1) == -1);
+ BOOST_REQUIRE(reader.ReadDoubleArray("missing", NULL, 1) == -1);
+
+ BOOST_REQUIRE(reader.ReadGuidArray("missing", NULL, 1) == -1);
+
+ // 8. Read missing string fields.
+ BOOST_REQUIRE(reader.ReadString("missing", NULL, 1) == -1);
+ BOOST_REQUIRE(reader.ReadString("missing").length() == 0);
+
+ // 9. Read missing object fields.
+ BOOST_REQUIRE(reader.ReadObject<PortableFields*>("missing") == NULL);
+
+ // 10. Read missing container fields.
+ PortableStringArrayReader stringArrReader = reader.ReadStringArray("missing");
+ BOOST_REQUIRE(stringArrReader.IsNull());
+
+ PortableArrayReader<PortableFields> arrReader = reader.ReadArray<PortableFields>("missing");
+ BOOST_REQUIRE(arrReader.IsNull());
+
+ PortableCollectionReader<PortableFields> colReader = reader.ReadCollection<PortableFields>("missing");
+ BOOST_REQUIRE(colReader.IsNull());
+
+ PortableMapReader<int32_t, PortableFields> mapReader = reader.ReadMap<int32_t, PortableFields>("missing");
+ BOOST_REQUIRE(mapReader.IsNull());
+ }
+
+ BOOST_AUTO_TEST_SUITE_END()
http://git-wip-us.apache.org/repos/asf/ignite/blob/ec58b87c/modules/platforms/cpp/core/include/ignite/impl/portable/portable_common.h
----------------------------------------------------------------------
diff --cc modules/platforms/cpp/core/include/ignite/impl/portable/portable_common.h
index 0000000,622cb54..9efaa28
mode 000000,100644..100644
--- a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_common.h
+++ b/modules/platforms/cpp/core/include/ignite/impl/portable/portable_common.h
@@@ -1,0 -1,146 +1,155 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ #ifndef _IGNITE_IMPL_PORTABLE_COMMON
+ #define _IGNITE_IMPL_PORTABLE_COMMON
+
+ #include <stdint.h>
+
+ namespace ignite
+ {
+ namespace impl
+ {
+ namespace portable
+ {
+ /** Header: null. */
+ const int8_t IGNITE_HDR_NULL = 101;
+
+ /** Header: handle. */
+ const int8_t IGNITE_HDR_HND = 102;
+
+ /** Header: fulle form. */
+ const int8_t IGNITE_HDR_FULL = 103;
+
++ /** Portable protocol version. */
++ const int8_t IGNITE_PROTO_VER = 1;
++
+ /** Full header length. */
- const int32_t IGNITE_FULL_HDR_LEN = 18;
++ const int32_t IGNITE_FULL_HDR_LEN = 19;
++
++ /** Header offset: length. */
++ const int32_t IGNITE_OFFSET_LEN = 11;
++
++ /** Header offset: raw offset. */
++ const int32_t IGNITE_OFFSET_RAW = 15;
+
+ /** Type: object. */
+ const int8_t IGNITE_TYPE_OBJECT = IGNITE_HDR_FULL;
+
+ /** Type: unsigned byte. */
+ const int8_t IGNITE_TYPE_BYTE = 1;
+
+ /** Type: short. */
+ const int8_t IGNITE_TYPE_SHORT = 2;
+
+ /** Type: int. */
+ const int8_t IGNITE_TYPE_INT = 3;
+
+ /** Type: long. */
+ const int8_t IGNITE_TYPE_LONG = 4;
+
+ /** Type: float. */
+ const int8_t IGNITE_TYPE_FLOAT = 5;
+
+ /** Type: double. */
+ const int8_t IGNITE_TYPE_DOUBLE = 6;
+
+ /** Type: char. */
+ const int8_t IGNITE_TYPE_CHAR = 7;
+
+ /** Type: boolean. */
+ const int8_t IGNITE_TYPE_BOOL = 8;
+
+ /** Type: decimal. */
+ const int8_t IGNITE_TYPE_DECIMAL = 30;
+
+ /** Type: string. */
+ const int8_t IGNITE_TYPE_STRING = 9;
+
+ /** Type: UUID. */
+ const int8_t IGNITE_TYPE_UUID = 10;
+
+ /** Type: date. */
+ const int8_t IGNITE_TYPE_DATE = 11;
+
+ /** Type: unsigned byte array. */
+ const int8_t IGNITE_TYPE_ARRAY_BYTE = 12;
+
+ /** Type: short array. */
+ const int8_t IGNITE_TYPE_ARRAY_SHORT = 13;
+
+ /** Type: int array. */
+ const int8_t IGNITE_TYPE_ARRAY_INT = 14;
+
+ /** Type: long array. */
+ const int8_t IGNITE_TYPE_ARRAY_LONG = 15;
+
+ /** Type: float array. */
+ const int8_t IGNITE_TYPE_ARRAY_FLOAT = 16;
+
+ /** Type: double array. */
+ const int8_t IGNITE_TYPE_ARRAY_DOUBLE = 17;
+
+ /** Type: char array. */
+ const int8_t IGNITE_TYPE_ARRAY_CHAR = 18;
+
+ /** Type: boolean array. */
+ const int8_t IGNITE_TYPE_ARRAY_BOOL = 19;
+
+ /** Type: decimal array. */
+ const int8_t IGNITE_TYPE_ARRAY_DECIMAL = 31;
+
+ /** Type: string array. */
+ const int8_t IGNITE_TYPE_ARRAY_STRING = 20;
+
+ /** Type: UUID array. */
+ const int8_t IGNITE_TYPE_ARRAY_UUID = 21;
+
+ /** Type: date array. */
+ const int8_t IGNITE_TYPE_ARRAY_DATE = 22;
+
+ /** Type: object array. */
+ const int8_t IGNITE_TYPE_ARRAY = 23;
+
+ /** Type: collection. */
+ const int8_t IGNITE_TYPE_COLLECTION = 24;
+
+ /** Type: map. */
+ const int8_t IGNITE_TYPE_MAP = 25;
+
+ /** Type: map entry. */
+ const int8_t IGNITE_TYPE_MAP_ENTRY = 26;
+
+ /** Type: portable object. */
+ const int8_t IGNITE_TYPE_PORTABLE = 27;
+
+ /** Read/write single object. */
+ const int32_t IGNITE_PORTABLE_MODE_SINGLE = 0;
+
+ /** Read/write array. */
+ const int32_t IGNITE_PORTABLE_MODE_ARRAY = 1;
+
+ /** Read/write collection. */
+ const int32_t IGNITE_PORTABLE_MODE_COL = 2;
+
+ /** Read/write map. */
+ const int32_t IGNITE_PORTABLE_MODE_MAP = 3;
+ }
+ }
+ }
+
+ #endif
[13/50] [abbrv] ignite git commit: Merge remote-tracking branch
'origin/master'
Posted by vo...@apache.org.
Merge remote-tracking branch 'origin/master'
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f4d8ea91
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f4d8ea91
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f4d8ea91
Branch: refs/heads/ignite-1651
Commit: f4d8ea914e61981ff33e41aee498168b56063834
Parents: c4b0877 077af17
Author: Anton Vinogradov <av...@apache.org>
Authored: Thu Oct 15 17:00:01 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Thu Oct 15 17:00:01 2015 +0300
----------------------------------------------------------------------
.../CacheAbstractRestartSelfTest.java | 247 +++++++++++++++++++
...NearDisabledAtomicInvokeRestartSelfTest.java | 179 ++++++++++++++
...abledTransactionalInvokeRestartSelfTest.java | 173 +++++++++++++
...edTransactionalWriteReadRestartSelfTest.java | 124 ++++++++++
.../IgniteCacheLoadConsistencyTestSuite.java | 42 ++++
5 files changed, 765 insertions(+)
----------------------------------------------------------------------
[07/50] [abbrv] ignite git commit: IGNITE-1610: Implemented portable
reader and writer for iterators.
Posted by vo...@apache.org.
IGNITE-1610: Implemented portable reader and writer for iterators.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6695e6c3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6695e6c3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6695e6c3
Branch: refs/heads/ignite-1651
Commit: 6695e6c3e46473c8b17d5a8fddd720ec7c6d91df
Parents: 2a77dd3
Author: isapego <is...@gridgain.com>
Authored: Thu Oct 15 13:38:31 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Oct 15 13:38:31 2015 +0300
----------------------------------------------------------------------
.../src/portable_reader_writer_raw_test.cpp | 63 ++++++++++-
.../src/portable_reader_writer_test.cpp | 65 ++++++++++++
.../interop/interop_stream_position_guard.h | 79 ++++++++++++++
.../ignite/impl/portable/portable_reader_impl.h | 104 +++++++++++++++++++
.../ignite/impl/portable/portable_writer_impl.h | 55 ++++++++++
.../ignite/portable/portable_raw_reader.h | 26 +++++
.../ignite/portable/portable_raw_writer.h | 30 +++++-
.../include/ignite/portable/portable_reader.h | 29 ++++++
.../include/ignite/portable/portable_writer.h | 27 +++++
.../platforms/cpp/core/project/vs/core.vcxproj | 1 +
.../cpp/core/project/vs/core.vcxproj.filters | 3 +
.../src/impl/portable/portable_reader_impl.cpp | 75 +++++++++++++
.../core/src/portable/portable_raw_reader.cpp | 10 ++
.../cpp/core/src/portable/portable_reader.cpp | 10 ++
14 files changed, 574 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/6695e6c3/modules/platforms/cpp/core-test/src/portable_reader_writer_raw_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/portable_reader_writer_raw_test.cpp b/modules/platforms/cpp/core-test/src/portable_reader_writer_raw_test.cpp
index c3a98aa..e93796f 100644
--- a/modules/platforms/cpp/core-test/src/portable_reader_writer_raw_test.cpp
+++ b/modules/platforms/cpp/core-test/src/portable_reader_writer_raw_test.cpp
@@ -495,6 +495,55 @@ void CheckRawCollection(CollectionType* colType)
BOOST_REQUIRE(rawReader.ReadInt8() == 1);
}
+void CheckRawCollectionIterators(CollectionType* colType)
+{
+ typedef std::vector<PortableInner> PortableInnerVector;
+
+ PortableInnerVector writeValues;
+ writeValues.push_back(1);
+ writeValues.push_back(0);
+ writeValues.push_back(2);
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ PortableWriterImpl writer(&out, NULL);
+ PortableRawWriter rawWriter(&writer);
+
+ if (colType)
+ rawWriter.WriteCollection(writeValues.begin(), writeValues.end(), *colType);
+ else
+ rawWriter.WriteCollection(writeValues.begin(), writeValues.end());
+
+ rawWriter.WriteInt8(1);
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ PortableReaderImpl reader(&in);
+ PortableRawReader rawReader(&reader);
+
+ int32_t collectionSize = rawReader.ReadCollectionSize();
+ BOOST_REQUIRE(collectionSize == writeValues.size());
+
+ if (colType)
+ BOOST_REQUIRE(rawReader.ReadCollectionType() == *colType);
+ else
+ BOOST_REQUIRE(rawReader.ReadCollectionType() == IGNITE_COLLECTION_UNDEFINED);
+
+ PortableInnerVector readValues(collectionSize);
+
+ int32_t elementsRead = rawReader.ReadCollection<PortableInner>(readValues.begin());
+
+ BOOST_REQUIRE(elementsRead == 3);
+
+ BOOST_REQUIRE(readValues[0].GetValue() == writeValues[0].GetValue());
+ BOOST_REQUIRE(readValues[1].GetValue() == writeValues[1].GetValue());
+ BOOST_REQUIRE(readValues[2].GetValue() == writeValues[2].GetValue());
+
+ BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
void CheckRawMapEmpty(MapType* mapType)
{
InteropUnpooledMemory mem(1024);
@@ -1457,13 +1506,25 @@ BOOST_AUTO_TEST_CASE(TestCollection)
CheckRawCollection(NULL);
}
-BOOST_AUTO_TEST_CASE(testCollectionTyped)
+BOOST_AUTO_TEST_CASE(TestCollectionTyped)
{
CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
CheckRawCollection(&typ);
}
+BOOST_AUTO_TEST_CASE(TestCollectionIterators)
+{
+ CheckRawCollectionIterators(NULL);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollectionIteratorsTyped)
+{
+ CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
+
+ CheckRawCollectionIterators(&typ);
+}
+
BOOST_AUTO_TEST_CASE(TestMapNull)
{
InteropUnpooledMemory mem(1024);
http://git-wip-us.apache.org/repos/asf/ignite/blob/6695e6c3/modules/platforms/cpp/core-test/src/portable_reader_writer_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/portable_reader_writer_test.cpp b/modules/platforms/cpp/core-test/src/portable_reader_writer_test.cpp
index aff929b..0825ecc 100644
--- a/modules/platforms/cpp/core-test/src/portable_reader_writer_test.cpp
+++ b/modules/platforms/cpp/core-test/src/portable_reader_writer_test.cpp
@@ -572,6 +572,59 @@ void CheckCollection(CollectionType* colType)
BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
}
+void CheckCollectionIterators(CollectionType* colType)
+{
+ typedef std::vector<PortableInner> PortableInnerVector;
+ PortableInnerVector writeValues;
+
+ writeValues.push_back(1);
+ writeValues.push_back(0);
+ writeValues.push_back(2);
+
+ TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+ PortableWriter writer(&writerImpl);
+
+ out.Position(18);
+
+ if (colType)
+ writer.WriteCollection("field1", writeValues.begin(), writeValues.end(), *colType);
+ else
+ writer.WriteCollection("field1", writeValues.begin(), writeValues.end());
+
+ writer.WriteInt8("field2", 1);
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+ PortableReader reader(&readerImpl);
+
+ in.Position(18);
+
+ BOOST_REQUIRE(reader.ReadCollectionSize("field1") == writeValues.size());
+
+ CollectionType expectedCollectionType = colType ? *colType : IGNITE_COLLECTION_UNDEFINED;
+ BOOST_REQUIRE(reader.ReadCollectionType("field1") == expectedCollectionType);
+
+ PortableInnerVector readValues;
+ std::back_insert_iterator<PortableInnerVector> readInsertIterator(readValues);
+
+ reader.ReadCollection<PortableInner>("field1", readInsertIterator);
+
+ BOOST_REQUIRE(readValues.size() == 3);
+
+ BOOST_REQUIRE(readValues[0].GetValue() == writeValues[0].GetValue());
+ BOOST_REQUIRE(readValues[1].GetValue() == writeValues[1].GetValue());
+ BOOST_REQUIRE(readValues[2].GetValue() == writeValues[2].GetValue());
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
void CheckMapEmpty(MapType* mapType)
{
TemplatedPortableIdResolver<PortableDummy> idRslvr;
@@ -1698,6 +1751,18 @@ BOOST_AUTO_TEST_CASE(testCollectionTyped)
CheckCollection(&typ);
}
+BOOST_AUTO_TEST_CASE(TestCollectionIterators)
+{
+ CheckCollectionIterators(NULL);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollectionIteratorsTyped)
+{
+ CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
+
+ CheckCollectionIterators(&typ);
+}
+
BOOST_AUTO_TEST_CASE(TestMapNull)
{
TemplatedPortableIdResolver<PortableDummy> idRslvr;
http://git-wip-us.apache.org/repos/asf/ignite/blob/6695e6c3/modules/platforms/cpp/core/include/ignite/impl/interop/interop_stream_position_guard.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/interop/interop_stream_position_guard.h b/modules/platforms/cpp/core/include/ignite/impl/interop/interop_stream_position_guard.h
new file mode 100644
index 0000000..17ecf53
--- /dev/null
+++ b/modules/platforms/cpp/core/include/ignite/impl/interop/interop_stream_position_guard.h
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _IGNITE_IMPL_INTEROP_STREAM_POSITION_GUARD
+#define _IGNITE_IMPL_INTEROP_OUTPUT_POSITION_GUARD
+
+#include "ignite/impl/interop/interop_memory.h"
+
+namespace ignite
+{
+ namespace impl
+ {
+ namespace interop
+ {
+ /**
+ * Interop stream position guard.
+ */
+ template<typename T>
+ class IGNITE_IMPORT_EXPORT InteropStreamPositionGuard {
+ public:
+ /**
+ * Create new position guard and saves current stream position.
+ *
+ * @param stream Stream which position should be saved.
+ */
+ InteropStreamPositionGuard(T& stream) : stream(&stream), pos(stream.Position())
+ {
+ //No-op
+ }
+
+ /**
+ * Destructor.
+ *
+ * Restores stream's position to a saved one on destruction.
+ */
+ ~InteropStreamPositionGuard()
+ {
+ if (stream)
+ stream->Position(pos);
+ }
+
+ /**
+ * Releases guard so it will not restore streams position on destruction.
+ *
+ * @param val Value.
+ */
+ void Release()
+ {
+ stream = NULL;
+ }
+
+ private:
+ /** Stream. */
+ T* stream;
+
+ /** Saved position. */
+ int32_t pos;
+
+ IGNITE_NO_COPY_ASSIGNMENT(InteropStreamPositionGuard)
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/6695e6c3/modules/platforms/cpp/core/include/ignite/impl/portable/portable_reader_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_reader_impl.h b/modules/platforms/cpp/core/include/ignite/impl/portable/portable_reader_impl.h
index ab93d10..5050a04 100644
--- a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_reader_impl.h
+++ b/modules/platforms/cpp/core/include/ignite/impl/portable/portable_reader_impl.h
@@ -518,6 +518,66 @@ namespace ignite
int32_t ReadCollection(const char* fieldName, ignite::portable::CollectionType* typ, int32_t* size);
/**
+ * Read values and insert them to specified position.
+ *
+ * @param out Output iterator to the initial position in the destination sequence.
+ * @return Actual amount of elements read.
+ */
+ template<typename T, typename OutputIterator>
+ int32_t ReadCollection(OutputIterator out)
+ {
+ int32_t size;
+ int32_t id = StartContainerSession(true, IGNITE_TYPE_COLLECTION, &size);
+
+ // Reading collection type. We don't need it here but it should be read.
+ if (size != -1)
+ stream->ReadInt8();
+
+ while (HasNextElement(id))
+ {
+ *out = ReadElement<T>(id);
+ ++out;
+ }
+
+ return size;
+ }
+
+ /**
+ * Read values and insert them to specified position.
+ *
+ * @param fieldName Field name.
+ * @param out Output iterator to the initial position in the destination sequence.
+ * @return Actual amount of elements read.
+ */
+ template<typename T, typename OutputIterator>
+ int32_t ReadCollection(const char* fieldName, OutputIterator out)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+ int32_t fieldLen = SeekField(fieldId);
+
+ if (fieldLen <= 0)
+ return -1;
+
+ int32_t size;
+ int32_t id = StartContainerSession(false, IGNITE_TYPE_COLLECTION, &size);
+
+ // Reading collection type. We don't need it here but it should be read.
+ if (size != -1)
+ stream->ReadInt8();
+
+ while (HasNextElement(id))
+ {
+ *out = ReadElement<T>(id);
+ ++out;
+ }
+
+ return size;
+ }
+
+ /**
* Start map read.
*
* @param typ Map type.
@@ -537,6 +597,36 @@ namespace ignite
int32_t ReadMap(const char* fieldName, ignite::portable::MapType* typ, int32_t* size);
/**
+ * Read type of the collection.
+ *
+ * @return Collection type.
+ */
+ ignite::portable::CollectionType ReadCollectionType();
+
+ /**
+ * Read type of the collection.
+ *
+ * @param fieldName Field name.
+ * @return Collection type.
+ */
+ ignite::portable::CollectionType ReadCollectionType(const char* fieldName);
+
+ /**
+ * Read size of the collection.
+ *
+ * @return Collection size.
+ */
+ int32_t ReadCollectionSize();
+
+ /**
+ * Read size of the collection.
+ *
+ * @param fieldName Field name.
+ * @return Collection size.
+ */
+ int32_t ReadCollectionSize(const char* fieldName);
+
+ /**
* Check whether next value exists.
*
* @param id Session ID.
@@ -1014,6 +1104,20 @@ namespace ignite
int32_t ReadStringInternal(char* res, const int32_t len);
/**
+ * Read type of the collection. Do not preserve stream position.
+ *
+ * @return Collection type.
+ */
+ ignite::portable::CollectionType ReadCollectionTypeUnprotected();
+
+ /**
+ * Read size of the collection. Do not preserve stream position.
+ *
+ * @return Collection size.
+ */
+ int32_t ReadCollectionSizeUnprotected();
+
+ /**
* Read value.
*
* @param expHdr Expected header.
http://git-wip-us.apache.org/repos/asf/ignite/blob/6695e6c3/modules/platforms/cpp/core/include/ignite/impl/portable/portable_writer_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_writer_impl.h b/modules/platforms/cpp/core/include/ignite/impl/portable/portable_writer_impl.h
index 2e5a0e7..0259a7e 100644
--- a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_writer_impl.h
+++ b/modules/platforms/cpp/core/include/ignite/impl/portable/portable_writer_impl.h
@@ -440,6 +440,40 @@ namespace ignite
* @return Session ID.
*/
int32_t WriteCollection(const char* fieldName, ignite::portable::CollectionType typ);
+
+ /**
+ * Write values in interval [first, last).
+ *
+ * @param first Iterator pointing to the beginning of the interval.
+ * @param last Iterator pointing to the end of the interval.
+ * @param typ Collection type.
+ */
+ template<typename InputIterator>
+ void WriteCollection(InputIterator first, InputIterator last, ignite::portable::CollectionType typ)
+ {
+ StartContainerSession(true);
+
+ WriteCollectionWithinSession(first, last, typ);
+ }
+
+ /**
+ * Write values in interval [first, last).
+ *
+ * @param fieldName Field name.
+ * @param first Iterator pointing to the beginning of the interval.
+ * @param last Iterator pointing to the end of the interval.
+ * @param typ Collection type.
+ */
+ template<typename InputIterator>
+ void WriteCollection(const char* fieldName, InputIterator first, InputIterator last,
+ ignite::portable::CollectionType typ)
+ {
+ StartContainerSession(false);
+
+ WriteFieldIdSkipLength(fieldName, IGNITE_TYPE_COLLECTION);
+
+ WriteCollectionWithinSession(first, last, typ);
+ }
/**
* Start map write.
@@ -747,6 +781,27 @@ namespace ignite
}
/**
+ * Write values in interval [first, last).
+ * New session should be started prior to call to this method.
+ * @param first Iterator pointing to the beginning of the interval.
+ * @param last Iterator pointing to the end of the interval.
+ * @param typ Collection type.
+ */
+ template<typename InputIterator>
+ void WriteCollectionWithinSession(InputIterator first, InputIterator last,
+ ignite::portable::CollectionType typ)
+ {
+ stream->WriteInt8(IGNITE_TYPE_COLLECTION);
+ stream->Position(stream->Position() + 4);
+ stream->WriteInt8(typ);
+
+ for (InputIterator i = first; i != last; ++i)
+ WriteElement(elemId, *i);
+
+ CommitContainer(elemId);
+ }
+
+ /**
* Check raw mode.
*
* @param expected Expected raw mode of the reader.
http://git-wip-us.apache.org/repos/asf/ignite/blob/6695e6c3/modules/platforms/cpp/core/include/ignite/portable/portable_raw_reader.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/portable/portable_raw_reader.h b/modules/platforms/cpp/core/include/ignite/portable/portable_raw_reader.h
index 0ecaa4d..40abe8b 100644
--- a/modules/platforms/cpp/core/include/ignite/portable/portable_raw_reader.h
+++ b/modules/platforms/cpp/core/include/ignite/portable/portable_raw_reader.h
@@ -289,6 +289,18 @@ namespace ignite
}
/**
+ * Read values and insert them to specified position.
+ *
+ * @param out Output iterator to the initial position in the destination sequence.
+ * @return Number of elements that have been read.
+ */
+ template<typename T, typename OutputIterator>
+ int32_t ReadCollection(OutputIterator out)
+ {
+ return impl->ReadCollection<T>(out);
+ }
+
+ /**
* Start map read.
*
* @return Map reader.
@@ -305,6 +317,20 @@ namespace ignite
}
/**
+ * Read type of the collection.
+ *
+ * @return Collection type.
+ */
+ CollectionType ReadCollectionType();
+
+ /**
+ * Read type of the collection.
+ *
+ * @return Collection size.
+ */
+ int32_t ReadCollectionSize();
+
+ /**
* Read object.
*
* @return Object.
http://git-wip-us.apache.org/repos/asf/ignite/blob/6695e6c3/modules/platforms/cpp/core/include/ignite/portable/portable_raw_writer.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/portable/portable_raw_writer.h b/modules/platforms/cpp/core/include/ignite/portable/portable_raw_writer.h
index 4cf2f00..7d0c118 100644
--- a/modules/platforms/cpp/core/include/ignite/portable/portable_raw_writer.h
+++ b/modules/platforms/cpp/core/include/ignite/portable/portable_raw_writer.h
@@ -247,7 +247,7 @@ namespace ignite
* @return Collection writer.
*/
template<typename T>
- PortableCollectionWriter<T> WriteCollection(ignite::portable::CollectionType typ)
+ PortableCollectionWriter<T> WriteCollection(CollectionType typ)
{
int32_t id = impl->WriteCollection(typ);
@@ -255,6 +255,32 @@ namespace ignite
}
/**
+ * Write values in interval [first, last).
+ *
+ * @param first Iterator pointing to the beginning of the interval.
+ * @param last Iterator pointing to the end of the interval.
+ * @param typ Collection type.
+ */
+ template<typename InputIterator>
+ void WriteCollection(InputIterator first, InputIterator last)
+ {
+ impl->WriteCollection(first, last, IGNITE_COLLECTION_UNDEFINED);
+ }
+
+ /**
+ * Write values in interval [first, last).
+ *
+ * @param first Iterator pointing to the beginning of the interval.
+ * @param last Iterator pointing to the end of the interval.
+ * @param typ Collection type.
+ */
+ template<typename InputIterator>
+ void WriteCollection(InputIterator first, InputIterator last, CollectionType typ)
+ {
+ impl->WriteCollection(first, last, typ);
+ }
+
+ /**
* Start map write.
*
* @param typ Map type.
@@ -273,7 +299,7 @@ namespace ignite
* @return Map writer.
*/
template<typename K, typename V>
- PortableMapWriter<K, V> WriteMap(ignite::portable::MapType typ)
+ PortableMapWriter<K, V> WriteMap(MapType typ)
{
int32_t id = impl->WriteMap(typ);
http://git-wip-us.apache.org/repos/asf/ignite/blob/6695e6c3/modules/platforms/cpp/core/include/ignite/portable/portable_reader.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/portable/portable_reader.h b/modules/platforms/cpp/core/include/ignite/portable/portable_reader.h
index 8a04f0f..d0533fd 100644
--- a/modules/platforms/cpp/core/include/ignite/portable/portable_reader.h
+++ b/modules/platforms/cpp/core/include/ignite/portable/portable_reader.h
@@ -311,6 +311,19 @@ namespace ignite
}
/**
+ * Read values and insert them to specified position.
+ *
+ * @param fieldName Field name.
+ * @param out Output iterator to the initial position in the destination sequence.
+ * @return Number of elements that have been read.
+ */
+ template<typename T, typename OutputIterator>
+ int32_t ReadCollection(const char* fieldName, OutputIterator out)
+ {
+ return impl->ReadCollection<T>(fieldName, out);
+ }
+
+ /**
* Start map read.
*
* @param fieldName Field name.
@@ -328,6 +341,22 @@ namespace ignite
}
/**
+ * Read type of the collection.
+ *
+ * @param fieldName Field name.
+ * @return Collection type.
+ */
+ CollectionType ReadCollectionType(const char* fieldName);
+
+ /**
+ * Read type of the collection.
+ *
+ * @param fieldName Field name.
+ * @return Collection size.
+ */
+ int32_t ReadCollectionSize(const char* fieldName);
+
+ /**
* Read object.
*
* @param fieldName Field name.
http://git-wip-us.apache.org/repos/asf/ignite/blob/6695e6c3/modules/platforms/cpp/core/include/ignite/portable/portable_writer.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/portable/portable_writer.h b/modules/platforms/cpp/core/include/ignite/portable/portable_writer.h
index d5009ac..c225340 100644
--- a/modules/platforms/cpp/core/include/ignite/portable/portable_writer.h
+++ b/modules/platforms/cpp/core/include/ignite/portable/portable_writer.h
@@ -280,6 +280,33 @@ namespace ignite
}
/**
+ * Write values in interval [first, last).
+ *
+ * @param fieldName Field name.
+ * @param first Iterator pointing to the beginning of the interval.
+ * @param last Iterator pointing to the end of the interval.
+ */
+ template<typename InputIterator>
+ void WriteCollection(const char* fieldName, InputIterator first, InputIterator last)
+ {
+ WriteCollection(fieldName, first, last, IGNITE_COLLECTION_UNDEFINED);
+ }
+
+ /**
+ * Write values in interval [first, last).
+ *
+ * @param fieldName Field name.
+ * @param first Iterator pointing to the beginning of the interval.
+ * @param last Iterator pointing to the end of the interval.
+ * @param typ Collection type.
+ */
+ template<typename InputIterator>
+ void WriteCollection(const char* fieldName, InputIterator first, InputIterator last, CollectionType typ)
+ {
+ impl->WriteCollection(fieldName, first, last, typ);
+ }
+
+ /**
* Start map write.
*
* @param fieldName Field name.
http://git-wip-us.apache.org/repos/asf/ignite/blob/6695e6c3/modules/platforms/cpp/core/project/vs/core.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/project/vs/core.vcxproj b/modules/platforms/cpp/core/project/vs/core.vcxproj
index 58fa283..b7e4f7c 100644
--- a/modules/platforms/cpp/core/project/vs/core.vcxproj
+++ b/modules/platforms/cpp/core/project/vs/core.vcxproj
@@ -211,6 +211,7 @@
<ClInclude Include="..\..\include\ignite\impl\interop\interop_input_stream.h" />
<ClInclude Include="..\..\include\ignite\impl\interop\interop_memory.h" />
<ClInclude Include="..\..\include\ignite\impl\interop\interop_output_stream.h" />
+ <ClInclude Include="..\..\include\ignite\impl\interop\interop_stream_position_guard.h" />
<ClInclude Include="..\..\include\ignite\impl\operations.h" />
<ClInclude Include="..\..\include\ignite\impl\portable\portable_common.h" />
<ClInclude Include="..\..\include\ignite\impl\portable\portable_id_resolver.h" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/6695e6c3/modules/platforms/cpp/core/project/vs/core.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/project/vs/core.vcxproj.filters b/modules/platforms/cpp/core/project/vs/core.vcxproj.filters
index d18599d..83f2fc7 100644
--- a/modules/platforms/cpp/core/project/vs/core.vcxproj.filters
+++ b/modules/platforms/cpp/core/project/vs/core.vcxproj.filters
@@ -213,6 +213,9 @@
<ClInclude Include="..\..\include\ignite\cache\query\query_scan.h">
<Filter>Code\cache\query</Filter>
</ClInclude>
+ <ClInclude Include="..\..\include\ignite\impl\interop\interop_stream_position_guard.h">
+ <Filter>Code\impl\interop</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="Code">
http://git-wip-us.apache.org/repos/asf/ignite/blob/6695e6c3/modules/platforms/cpp/core/src/impl/portable/portable_reader_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/portable/portable_reader_impl.cpp b/modules/platforms/cpp/core/src/impl/portable/portable_reader_impl.cpp
index e41dafc..a8196a1 100644
--- a/modules/platforms/cpp/core/src/impl/portable/portable_reader_impl.cpp
+++ b/modules/platforms/cpp/core/src/impl/portable/portable_reader_impl.cpp
@@ -22,6 +22,7 @@
#include "ignite/impl/portable/portable_utils.h"
#include "ignite/portable/portable_type.h"
#include "ignite/ignite_error.h"
+#include "ignite/impl/interop/interop_stream_position_guard.h"
using namespace ignite::impl::interop;
using namespace ignite::impl::portable;
@@ -477,6 +478,80 @@ namespace ignite
}
}
+ CollectionType PortableReaderImpl::ReadCollectionTypeUnprotected()
+ {
+ int32_t size = ReadCollectionSizeUnprotected();
+ if (size == -1)
+ return IGNITE_COLLECTION_UNDEFINED;
+
+ CollectionType typ = static_cast<CollectionType>(stream->ReadInt8());
+
+ return typ;
+ }
+
+ CollectionType PortableReaderImpl::ReadCollectionType()
+ {
+ InteropStreamPositionGuard<InteropInputStream> positionGuard(*stream);
+
+ return ReadCollectionTypeUnprotected();
+ }
+
+ CollectionType PortableReaderImpl::ReadCollectionType(const char* fieldName)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ InteropStreamPositionGuard<InteropInputStream> positionGuard(*stream);
+
+ int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+ int32_t fieldLen = SeekField(fieldId);
+
+ if (fieldLen <= 0)
+ return IGNITE_COLLECTION_UNDEFINED;
+
+ return ReadCollectionTypeUnprotected();
+ }
+
+ int32_t PortableReaderImpl::ReadCollectionSizeUnprotected()
+ {
+ int8_t hdr = stream->ReadInt8();
+
+ if (hdr != IGNITE_TYPE_COLLECTION)
+ {
+ if (hdr != IGNITE_HDR_NULL)
+ ThrowOnInvalidHeader(IGNITE_TYPE_COLLECTION, hdr);
+
+ return -1;
+ }
+
+ int32_t size = stream->ReadInt32();
+
+ return size;
+ }
+
+ int32_t PortableReaderImpl::ReadCollectionSize()
+ {
+ InteropStreamPositionGuard<InteropInputStream> positionGuard(*stream);
+
+ return ReadCollectionSizeUnprotected();
+ }
+
+ int32_t PortableReaderImpl::ReadCollectionSize(const char* fieldName)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ InteropStreamPositionGuard<InteropInputStream> positionGuard(*stream);
+
+ int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+ int32_t fieldLen = SeekField(fieldId);
+
+ if (fieldLen <= 0)
+ return -1;
+
+ return ReadCollectionSizeUnprotected();
+ }
+
bool PortableReaderImpl::HasNextElement(int32_t id) const
{
return elemId == id && elemRead < elemCnt;
http://git-wip-us.apache.org/repos/asf/ignite/blob/6695e6c3/modules/platforms/cpp/core/src/portable/portable_raw_reader.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/portable/portable_raw_reader.cpp b/modules/platforms/cpp/core/src/portable/portable_raw_reader.cpp
index f659913..775c561 100644
--- a/modules/platforms/cpp/core/src/portable/portable_raw_reader.cpp
+++ b/modules/platforms/cpp/core/src/portable/portable_raw_reader.cpp
@@ -131,5 +131,15 @@ namespace ignite
return PortableStringArrayReader(impl, id, size);
}
+
+ CollectionType PortableRawReader::ReadCollectionType()
+ {
+ return impl->ReadCollectionType();
+ }
+
+ int32_t PortableRawReader::ReadCollectionSize()
+ {
+ return impl->ReadCollectionSize();
+ }
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/6695e6c3/modules/platforms/cpp/core/src/portable/portable_reader.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/portable/portable_reader.cpp b/modules/platforms/cpp/core/src/portable/portable_reader.cpp
index fe8fba1..62c1e67 100644
--- a/modules/platforms/cpp/core/src/portable/portable_reader.cpp
+++ b/modules/platforms/cpp/core/src/portable/portable_reader.cpp
@@ -132,6 +132,16 @@ namespace ignite
return PortableStringArrayReader(impl, id, size);
}
+ CollectionType PortableReader::ReadCollectionType(const char* fieldName)
+ {
+ return impl->ReadCollectionType(fieldName);
+ }
+
+ int32_t PortableReader::ReadCollectionSize(const char* fieldName)
+ {
+ return impl->ReadCollectionSize(fieldName);
+ }
+
PortableRawReader PortableReader::RawReader()
{
impl->SetRawMode();
[19/50] [abbrv] ignite git commit: ignite-1698 SqlFieldsQuery works
incorrectly in case of topology changes - Fixes #162.
Posted by vo...@apache.org.
ignite-1698 SqlFieldsQuery works incorrectly in case of topology changes - Fixes #162.
Signed-off-by: S.Vladykin <sv...@gridgain.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7d3621b6
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7d3621b6
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7d3621b6
Branch: refs/heads/ignite-1651
Commit: 7d3621b6907ca4fadae6134593e6a67dd389ff54
Parents: 02b59e4
Author: agura <ag...@gridgain.com>
Authored: Sat Oct 17 18:22:55 2015 +0300
Committer: S.Vladykin <sv...@gridgain.com>
Committed: Sat Oct 17 18:22:55 2015 +0300
----------------------------------------------------------------------
.../cache/SqlFieldsQuerySelfTest.java | 166 +++++++++++++++++++
1 file changed, 166 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7d3621b6/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
new file mode 100644
index 0000000..7b1c87c
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.cache;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.List;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class SqlFieldsQuerySelfTest extends GridCommonAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setLocalHost("127.0.0.1");
+
+ cfg.setPeerClassLoadingEnabled(true);
+
+ TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+ ipFinder.setAddresses(Collections.singletonList("127.0.0.1:47500..47509"));
+
+ TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+ discoSpi.setIpFinder(ipFinder);
+
+ cfg.setDiscoverySpi(discoSpi);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If error.
+ */
+ public void testSqlFieldsQuery() throws Exception {
+ startGrids(2);
+
+ createAndFillCache();
+
+ executeQuery();
+ }
+
+ /**
+ * @throws Exception If error.
+ */
+ public void testSqlFieldsQueryWithTopologyChanges() throws Exception {
+ startGrid(0);
+
+ createAndFillCache();
+
+ startGrid(1);
+
+ executeQuery();
+ }
+
+ /**
+ *
+ */
+ private void executeQuery() {
+ IgniteCache<?, ?> cache = grid(1).cache("person");
+
+ SqlFieldsQuery qry = new SqlFieldsQuery("select name, age from person where age > 10");
+
+ QueryCursor<List<?>> qryCursor = cache.query(qry);
+
+ assertEquals(2, qryCursor.getAll().size());
+ }
+
+
+ /**
+ *
+ */
+ private IgniteCache<Integer, Person> createAndFillCache() {
+ CacheConfiguration<Integer, Person> cacheConf = new CacheConfiguration<>();
+
+ cacheConf.setIndexedTypes(Integer.class, Person.class);
+
+ cacheConf.setName("person");
+
+ IgniteCache<Integer, Person> cache = grid(0).createCache(cacheConf);
+
+ cache.put(1, new Person("sun", 100));
+ cache.put(2, new Person("moon", 50));
+
+ return cache;
+ }
+
+ /**
+ *
+ */
+ public static class Person implements Serializable {
+ /** Name. */
+ @QuerySqlField
+ private String name;
+
+ /** Age. */
+ @QuerySqlField
+ private int age;
+
+ /**
+ * @param name Name.
+ * @param age Age.
+ */
+ public Person(String name, int age) {
+ this.name = name;
+ this.age = age;
+ }
+
+ /**
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name Name.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ *
+ */
+ public int getAge() {
+ return age;
+ }
+
+ /**
+ * @param age Age.
+ */
+ public void setAge(int age) {
+ this.age = age;
+ }
+ }
+}
[29/50] [abbrv] ignite git commit: Muted test
CacheAffinityCallSelfTest.testAffinityCallNoServerNode
Posted by vo...@apache.org.
Muted test CacheAffinityCallSelfTest.testAffinityCallNoServerNode
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6ffd5ce3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6ffd5ce3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6ffd5ce3
Branch: refs/heads/ignite-1651
Commit: 6ffd5ce310b13bd63d4eee3abfb434cd7f76e0eb
Parents: 75fb19d
Author: ashutak <as...@gridgain.com>
Authored: Tue Oct 20 15:55:58 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Tue Oct 20 15:55:58 2015 +0300
----------------------------------------------------------------------
.../internal/processors/cache/CacheAffinityCallSelfTest.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/6ffd5ce3/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheAffinityCallSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheAffinityCallSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheAffinityCallSelfTest.java
index b9ff46c..8530fbb 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheAffinityCallSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheAffinityCallSelfTest.java
@@ -134,6 +134,8 @@ public class CacheAffinityCallSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testAffinityCallNoServerNode() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1741");
+
startGridsMultiThreaded(SERVERS_COUNT + 1);
final Integer key = 1;
@@ -210,4 +212,4 @@ public class CacheAffinityCallSelfTest extends GridCommonAbstractTest {
return null;
}
}
-}
\ No newline at end of file
+}
[44/50] [abbrv] ignite git commit: Merge branch 'ignite-1282' into
ignite-1651
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ec58b87c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
----------------------------------------------------------------------
diff --cc modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
index 0000000,b490460..6146362
mode 000000,100644..100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
@@@ -1,0 -1,1619 +1,1620 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Portable
+ {
+ using System;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.IO;
+
+ using Apache.Ignite.Core.Impl.Portable.IO;
+ using Apache.Ignite.Core.Impl.Portable.Metadata;
+ using Apache.Ignite.Core.Impl.Portable.Structure;
+ using Apache.Ignite.Core.Portable;
+
+ using PU = PortableUtils;
+
+ /// <summary>
+ /// Portable writer implementation.
+ /// </summary>
+ internal class PortableWriterImpl : IPortableWriter, IPortableRawWriter
+ {
+ /** Marshaller. */
+ private readonly PortableMarshaller _marsh;
+
+ /** Stream. */
+ private readonly IPortableStream _stream;
+
+ /** Builder (used only during build). */
+ private PortableBuilderImpl _builder;
+
+ /** Handles. */
+ private PortableHandleDictionary<object, long> _hnds;
+
+ /** Metadatas collected during this write session. */
+ private IDictionary<int, IPortableMetadata> _metas;
+
+ /** Current type ID. */
+ private int _curTypeId;
+
+ /** Current name converter */
+ private IPortableNameMapper _curConverter;
+
+ /** Current mapper. */
+ private IPortableIdMapper _curMapper;
+
+ /** Current raw position. */
+ private long _curRawPos;
+
+ /** Current type structure. */
+ private PortableStructure _curStruct;
+
+ /** Current type structure path index. */
+ private int _curStructPath;
+
+ /** Current type structure action index. */
+ private int _curStructAction;
+
+ /** Current type structure updates. */
+ private List<PortableStructureUpdate> _curStructUpdates;
+
+ /** Whether we are currently detaching an object. */
+ private bool _detaching;
+
+ /// <summary>
+ /// Gets the marshaller.
+ /// </summary>
+ internal PortableMarshaller Marshaller
+ {
+ get { return _marsh; }
+ }
+
+ /// <summary>
+ /// Write named boolean value.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Boolean value.</param>
+ public void WriteBoolean(string fieldName, bool val)
+ {
+ WriteFieldId(fieldName, PU.TypeBool);
+
+ _stream.WriteInt(PU.LengthTypeId + 1);
+ _stream.WriteByte(PU.TypeBool);
+ _stream.WriteBool(val);
+ }
+
+ /// <summary>
+ /// Write boolean value.
+ /// </summary>
+ /// <param name="val">Boolean value.</param>
+ public void WriteBoolean(bool val)
+ {
+ _stream.WriteBool(val);
+ }
+
+ /// <summary>
+ /// Write named boolean array.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Boolean array.</param>
+ public void WriteBooleanArray(string fieldName, bool[] val)
+ {
+ WriteFieldId(fieldName, PU.TypeArrayBool);
+
+ if (val == null)
+ WriteNullField();
+ else
+ {
+ _stream.WriteInt(PU.LengthTypeId + PU.LengthArraySize + val.Length);
+ _stream.WriteByte(PU.TypeArrayBool);
+ PU.WriteBooleanArray(val, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write boolean array.
+ /// </summary>
+ /// <param name="val">Boolean array.</param>
+ public void WriteBooleanArray(bool[] val)
+ {
+ if (val == null)
+ WriteNullRawField();
+ else
+ {
+ _stream.WriteByte(PU.TypeArrayBool);
+ PU.WriteBooleanArray(val, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write named byte value.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Byte value.</param>
+ public void WriteByte(string fieldName, byte val)
+ {
+ WriteFieldId(fieldName, PU.TypeBool);
+
+ _stream.WriteInt(PU.LengthTypeId + 1);
+ _stream.WriteByte(PU.TypeByte);
+ _stream.WriteByte(val);
+ }
+
+ /// <summary>
+ /// Write byte value.
+ /// </summary>
+ /// <param name="val">Byte value.</param>
+ public void WriteByte(byte val)
+ {
+ _stream.WriteByte(val);
+ }
+
+ /// <summary>
+ /// Write named byte array.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Byte array.</param>
+ public void WriteByteArray(string fieldName, byte[] val)
+ {
+ WriteFieldId(fieldName, PU.TypeArrayByte);
+
+ if (val == null)
+ WriteNullField();
+ else
+ {
+ _stream.WriteInt(PU.LengthTypeId + PU.LengthArraySize + val.Length);
+ _stream.WriteByte(PU.TypeArrayByte);
+ PU.WriteByteArray(val, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write byte array.
+ /// </summary>
+ /// <param name="val">Byte array.</param>
+ public void WriteByteArray(byte[] val)
+ {
+ if (val == null)
+ WriteNullRawField();
+ else
+ {
+ _stream.WriteByte(PU.TypeArrayByte);
+ PU.WriteByteArray(val, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write named short value.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Short value.</param>
+ public void WriteShort(string fieldName, short val)
+ {
+ WriteFieldId(fieldName, PU.TypeShort);
+
+ _stream.WriteInt(PU.LengthTypeId + 2);
+ _stream.WriteByte(PU.TypeShort);
+ _stream.WriteShort(val);
+ }
+
+ /// <summary>
+ /// Write short value.
+ /// </summary>
+ /// <param name="val">Short value.</param>
+ public void WriteShort(short val)
+ {
+ _stream.WriteShort(val);
+ }
+
+ /// <summary>
+ /// Write named short array.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Short array.</param>
+ public void WriteShortArray(string fieldName, short[] val)
+ {
+ WriteFieldId(fieldName, PU.TypeArrayShort);
+
+ if (val == null)
+ WriteNullField();
+ else
+ {
+ _stream.WriteInt(PU.LengthTypeId + PU.LengthArraySize + (val.Length << 1));
+ _stream.WriteByte(PU.TypeArrayShort);
+ PU.WriteShortArray(val, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write short array.
+ /// </summary>
+ /// <param name="val">Short array.</param>
+ public void WriteShortArray(short[] val)
+ {
+ if (val == null)
+ WriteNullRawField();
+ else
+ {
+ _stream.WriteByte(PU.TypeArrayShort);
+ PU.WriteShortArray(val, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write named char value.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Char value.</param>
+ public void WriteChar(string fieldName, char val)
+ {
+ WriteFieldId(fieldName, PU.TypeChar);
+
+ _stream.WriteInt(PU.LengthTypeId + 2);
+ _stream.WriteByte(PU.TypeChar);
+ _stream.WriteChar(val);
+ }
+
+ /// <summary>
+ /// Write char value.
+ /// </summary>
+ /// <param name="val">Char value.</param>
+ public void WriteChar(char val)
+ {
+ _stream.WriteChar(val);
+ }
+
+ /// <summary>
+ /// Write named char array.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Char array.</param>
+ public void WriteCharArray(string fieldName, char[] val)
+ {
+ WriteFieldId(fieldName, PU.TypeArrayChar);
+
+ if (val == null)
+ WriteNullField();
+ else
+ {
+ _stream.WriteInt(PU.LengthTypeId + PU.LengthArraySize + (val.Length << 1));
+ _stream.WriteByte(PU.TypeArrayChar);
+ PU.WriteCharArray(val, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write char array.
+ /// </summary>
+ /// <param name="val">Char array.</param>
+ public void WriteCharArray(char[] val)
+ {
+ if (val == null)
+ WriteNullRawField();
+ else
+ {
+ _stream.WriteByte(PU.TypeArrayChar);
+ PU.WriteCharArray(val, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write named int value.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Int value.</param>
+ public void WriteInt(string fieldName, int val)
+ {
+ WriteFieldId(fieldName, PU.TypeInt);
+
+ _stream.WriteInt(PU.LengthTypeId + 4);
+ _stream.WriteByte(PU.TypeInt);
+ _stream.WriteInt(val);
+ }
+
+ /// <summary>
+ /// Write int value.
+ /// </summary>
+ /// <param name="val">Int value.</param>
+ public void WriteInt(int val)
+ {
+ _stream.WriteInt(val);
+ }
+
+ /// <summary>
+ /// Write named int array.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Int array.</param>
+ public void WriteIntArray(string fieldName, int[] val)
+ {
+ WriteFieldId(fieldName, PU.TypeArrayInt);
+
+ if (val == null)
+ WriteNullField();
+ else
+ {
+ _stream.WriteInt(PU.LengthTypeId + PU.LengthArraySize + (val.Length << 2));
+ _stream.WriteByte(PU.TypeArrayInt);
+ PU.WriteIntArray(val, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write int array.
+ /// </summary>
+ /// <param name="val">Int array.</param>
+ public void WriteIntArray(int[] val)
+ {
+ if (val == null)
+ WriteNullRawField();
+ else
+ {
+ _stream.WriteByte(PU.TypeArrayInt);
+ PU.WriteIntArray(val, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write named long value.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Long value.</param>
+ public void WriteLong(string fieldName, long val)
+ {
+ WriteFieldId(fieldName, PU.TypeLong);
+
+ _stream.WriteInt(PU.LengthTypeId + 8);
+ _stream.WriteByte(PU.TypeLong);
+ _stream.WriteLong(val);
+ }
+
+ /// <summary>
+ /// Write long value.
+ /// </summary>
+ /// <param name="val">Long value.</param>
+ public void WriteLong(long val)
+ {
+ _stream.WriteLong(val);
+ }
+
+ /// <summary>
+ /// Write named long array.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Long array.</param>
+ public void WriteLongArray(string fieldName, long[] val)
+ {
+ WriteFieldId(fieldName, PU.TypeArrayLong);
+
+ if (val == null)
+ WriteNullField();
+ else
+ {
+ _stream.WriteInt(PU.LengthTypeId + PU.LengthArraySize + (val.Length << 3));
+ _stream.WriteByte(PU.TypeArrayLong);
+ PU.WriteLongArray(val, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write long array.
+ /// </summary>
+ /// <param name="val">Long array.</param>
+ public void WriteLongArray(long[] val)
+ {
+ if (val == null)
+ WriteNullRawField();
+ else
+ {
+ _stream.WriteByte(PU.TypeArrayLong);
+ PU.WriteLongArray(val, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write named float value.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Float value.</param>
+ public void WriteFloat(string fieldName, float val)
+ {
+ WriteFieldId(fieldName, PU.TypeFloat);
+
+ _stream.WriteInt(PU.LengthTypeId + 4);
+ _stream.WriteByte(PU.TypeFloat);
+ _stream.WriteFloat(val);
+ }
+
+ /// <summary>
+ /// Write float value.
+ /// </summary>
+ /// <param name="val">Float value.</param>
+ public void WriteFloat(float val)
+ {
+ _stream.WriteFloat(val);
+ }
+
+ /// <summary>
+ /// Write named float array.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Float array.</param>
+ public void WriteFloatArray(string fieldName, float[] val)
+ {
+ WriteFieldId(fieldName, PU.TypeArrayFloat);
+
+ if (val == null)
+ WriteNullField();
+ else
+ {
+ _stream.WriteInt(PU.LengthTypeId + PU.LengthArraySize + (val.Length << 2));
+ _stream.WriteByte(PU.TypeArrayFloat);
+ PU.WriteFloatArray(val, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write float array.
+ /// </summary>
+ /// <param name="val">Float array.</param>
+ public void WriteFloatArray(float[] val)
+ {
+ if (val == null)
+ WriteNullRawField();
+ else
+ {
+ _stream.WriteByte(PU.TypeArrayFloat);
+ PU.WriteFloatArray(val, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write named double value.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Double value.</param>
+ public void WriteDouble(string fieldName, double val)
+ {
+ WriteFieldId(fieldName, PU.TypeDouble);
+
+ _stream.WriteInt(PU.LengthTypeId + 8);
+ _stream.WriteByte(PU.TypeDouble);
+ _stream.WriteDouble(val);
+ }
+
+ /// <summary>
+ /// Write double value.
+ /// </summary>
+ /// <param name="val">Double value.</param>
+ public void WriteDouble(double val)
+ {
+ _stream.WriteDouble(val);
+ }
+
+ /// <summary>
+ /// Write named double array.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Double array.</param>
+ public void WriteDoubleArray(string fieldName, double[] val)
+ {
+ WriteFieldId(fieldName, PU.TypeArrayDouble);
+
+ if (val == null)
+ WriteNullField();
+ else
+ {
+ _stream.WriteInt(PU.LengthTypeId + PU.LengthArraySize + (val.Length << 3));
+ _stream.WriteByte(PU.TypeArrayDouble);
+ PU.WriteDoubleArray(val, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write double array.
+ /// </summary>
+ /// <param name="val">Double array.</param>
+ public void WriteDoubleArray(double[] val)
+ {
+ if (val == null)
+ WriteNullRawField();
+ else
+ {
+ _stream.WriteByte(PU.TypeArrayDouble);
+ PU.WriteDoubleArray(val, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write named decimal value.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Decimal value.</param>
+ public void WriteDecimal(string fieldName, decimal? val)
+ {
+ WriteFieldId(fieldName, PU.TypeDecimal);
+
+ if (val == null)
+ WriteNullField();
+ else
+ {
+ int pos = SkipFieldLength();
+
+ _stream.WriteByte(PU.TypeDecimal);
+ PortableUtils.WriteDecimal(val.Value, _stream);
+
+ WriteFieldLength(_stream, pos);
+ }
+ }
+
+ /// <summary>
+ /// Write decimal value.
+ /// </summary>
+ /// <param name="val">Decimal value.</param>
+ public void WriteDecimal(decimal? val)
+ {
+ if (val == null)
+ WriteNullRawField();
+ else
+ {
+ _stream.WriteByte(PU.TypeDecimal);
+ PortableUtils.WriteDecimal(val.Value, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write named decimal array.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Decimal array.</param>
+ public void WriteDecimalArray(string fieldName, decimal?[] val)
+ {
+ WriteFieldId(fieldName, PU.TypeArrayDecimal);
+
+ if (val == null)
+ WriteNullField();
+ else
+ {
+ int pos = SkipFieldLength();
+
+ _stream.WriteByte(PU.TypeArrayDecimal);
+ PU.WriteDecimalArray(val, _stream);
+
+ WriteFieldLength(_stream, pos);
+ }
+ }
+
+ /// <summary>
+ /// Write decimal array.
+ /// </summary>
+ /// <param name="val">Decimal array.</param>
+ public void WriteDecimalArray(decimal?[] val)
+ {
+ if (val == null)
+ WriteNullRawField();
+ else
+ {
+ _stream.WriteByte(PU.TypeArrayDecimal);
+ PU.WriteDecimalArray(val, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write named date value.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Date value.</param>
+ public void WriteDate(string fieldName, DateTime? val)
+ {
+ WriteFieldId(fieldName, PU.TypeDate);
+
+ if (val == null)
+ WriteNullField();
+ else
+ {
+ _stream.WriteInt(PU.LengthTypeId + 12);
+
+ _stream.WriteByte(PortableUtils.TypeDate);
+ PortableUtils.WriteDate(val.Value, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write date value.
+ /// </summary>
+ /// <param name="val">Date value.</param>
+ public void WriteDate(DateTime? val)
+ {
+ if (val == null)
+ WriteNullRawField();
+ else
+ {
+ _stream.WriteByte(PortableUtils.TypeDate);
+ PortableUtils.WriteDate(val.Value, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write named date array.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Date array.</param>
+ public void WriteDateArray(string fieldName, DateTime?[] val)
+ {
+ WriteFieldId(fieldName, PU.TypeDate);
+
+ if (val == null)
+ WriteNullField();
+ else
+ {
+ int pos = SkipFieldLength();
+
+ _stream.WriteByte(PortableUtils.TypeArrayDate);
+ PortableUtils.WriteDateArray(val, _stream);
+
+ WriteFieldLength(_stream, pos);
+ }
+ }
+
+ /// <summary>
+ /// Write date array.
+ /// </summary>
+ /// <param name="val">Date array.</param>
+ public void WriteDateArray(DateTime?[] val)
+ {
+ if (val == null)
+ WriteNullRawField();
+ else
+ {
+ _stream.WriteByte(PortableUtils.TypeArrayDate);
+ PortableUtils.WriteDateArray(val, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write named string value.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">String value.</param>
+ public void WriteString(string fieldName, string val)
+ {
+ WriteFieldId(fieldName, PU.TypeString);
+
+ if (val == null)
+ WriteNullField();
+ else
+ {
+ int pos = SkipFieldLength();
+
+ _stream.WriteByte(PU.TypeString);
+ PU.WriteString(val, _stream);
+
+ WriteFieldLength(_stream, pos);
+ }
+ }
+
+ /// <summary>
+ /// Write string value.
+ /// </summary>
+ /// <param name="val">String value.</param>
+ public void WriteString(string val)
+ {
+ if (val == null)
+ WriteNullRawField();
+ else
+ {
+ _stream.WriteByte(PU.TypeString);
+ PU.WriteString(val, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write named string array.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">String array.</param>
+ public void WriteStringArray(string fieldName, string[] val)
+ {
+ WriteFieldId(fieldName, PU.TypeArrayString);
+
+ if (val == null)
+ WriteNullField();
+ else
+ {
+ int pos = SkipFieldLength();
+
+ _stream.WriteByte(PU.TypeArrayString);
+ PU.WriteStringArray(val, _stream);
+
+ WriteFieldLength(_stream, pos);
+ }
+ }
+
+ /// <summary>
+ /// Write string array.
+ /// </summary>
+ /// <param name="val">String array.</param>
+ public void WriteStringArray(string[] val)
+ {
+ if (val == null)
+ WriteNullRawField();
+ else
+ {
+ _stream.WriteByte(PU.TypeArrayString);
+ PU.WriteStringArray(val, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write named GUID value.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">GUID value.</param>
+ public void WriteGuid(string fieldName, Guid? val)
+ {
+ WriteFieldId(fieldName, PU.TypeGuid);
+
+ if (val == null)
+ WriteNullField();
+ else
+ {
+ _stream.WriteInt(PU.LengthTypeId + 16);
+
+ _stream.WriteByte(PU.TypeGuid);
+ PU.WriteGuid(val.Value, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write GUID value.
+ /// </summary>
+ /// <param name="val">GUID value.</param>
+ public void WriteGuid(Guid? val)
+ {
+ if (val == null)
+ WriteNullRawField();
+ else
+ {
+ _stream.WriteByte(PU.TypeGuid);
+ PU.WriteGuid(val.Value, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write named GUID array.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">GUID array.</param>
+ public void WriteGuidArray(string fieldName, Guid?[] val)
+ {
+ WriteFieldId(fieldName, PU.TypeArrayGuid);
+
+ if (val == null)
+ WriteNullField();
+ else
+ {
+ int pos = SkipFieldLength();
+
+ _stream.WriteByte(PU.TypeArrayGuid);
+ PU.WriteGuidArray(val, _stream);
+
+ WriteFieldLength(_stream, pos);
+ }
+ }
+
+ /// <summary>
+ /// Write GUID array.
+ /// </summary>
+ /// <param name="val">GUID array.</param>
+ public void WriteGuidArray(Guid?[] val)
+ {
+ if (val == null)
+ WriteNullRawField();
+ else
+ {
+ _stream.WriteByte(PU.TypeArrayGuid);
+ PU.WriteGuidArray(val, _stream);
+ }
+ }
+
+ /// <summary>
+ /// Write named enum value.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Enum value.</param>
+ public void WriteEnum<T>(string fieldName, T val)
+ {
+ WriteFieldId(fieldName, PU.TypeEnum);
+
+ _stream.WriteInt(PU.LengthTypeId + 16);
+
+ _stream.WriteByte(PU.TypeEnum);
+ PortableUtils.WriteEnum(_stream, (Enum)(object)val);
+ }
+
+ /// <summary>
+ /// Write enum value.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="val">Enum value.</param>
+ public void WriteEnum<T>(T val)
+ {
+ _stream.WriteByte(PU.TypeEnum);
+ PortableUtils.WriteEnum(_stream, (Enum)(object)val);
+ }
+
+ /// <summary>
+ /// Write named enum array.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Enum array.</param>
+ public void WriteEnumArray<T>(string fieldName, T[] val)
+ {
+ WriteFieldId(fieldName, PU.TypeArrayEnum);
+
+ if (val == null)
+ WriteNullField();
+ else
+ {
+ int pos = SkipFieldLength();
+
+ _stream.WriteByte(PU.TypeArrayEnum);
+ PortableUtils.WriteArray(val, this, true);
+
+ WriteFieldLength(_stream, pos);
+ }
+ }
+
+ /// <summary>
+ /// Write enum array.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="val">Enum array.</param>
+ public void WriteEnumArray<T>(T[] val)
+ {
+ if (val == null)
+ WriteNullRawField();
+ else
+ {
+ _stream.WriteByte(PU.TypeArrayEnum);
+ PortableUtils.WriteArray(val, this, true);
+ }
+ }
+
+ /// <summary>
+ /// Write named object value.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Object value.</param>
+ public void WriteObject<T>(string fieldName, T val)
+ {
+ WriteFieldId(fieldName, PU.TypeObject);
+
+ if (val == null)
+ WriteNullField();
+ else
+ {
+ int pos = SkipFieldLength();
+
+ Write(val);
+
+ WriteFieldLength(_stream, pos);
+ }
+ }
+
+ /// <summary>
+ /// Write object value.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="val">Object value.</param>
+ public void WriteObject<T>(T val)
+ {
+ Write(val);
+ }
+
+ /// <summary>
+ /// Write named object array.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Object array.</param>
+ public void WriteObjectArray<T>(string fieldName, T[] val)
+ {
+ WriteFieldId(fieldName, PU.TypeArray);
+
+ if (val == null)
+ WriteNullField();
+ else
+ {
+ int pos = SkipFieldLength();
+
+ _stream.WriteByte(PU.TypeArray);
+ PortableUtils.WriteArray(val, this, true);
+
+ WriteFieldLength(_stream, pos);
+ }
+ }
+
+ /// <summary>
+ /// Write object array.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="val">Object array.</param>
+ public void WriteObjectArray<T>(T[] val)
+ {
+ if (val == null)
+ WriteNullRawField();
+ else
+ {
+ _stream.WriteByte(PU.TypeArray);
+ PortableUtils.WriteArray(val, this, true);
+ }
+ }
+
+ /// <summary>
+ /// Write named collection.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Collection.</param>
+ public void WriteCollection(string fieldName, ICollection val)
+ {
+ WriteFieldId(fieldName, PU.TypeCollection);
+
+ if (val == null)
+ WriteNullField();
+ else
+ {
+ int pos = SkipFieldLength();
+
+ Write(val);
+
+ WriteFieldLength(_stream, pos);
+ }
+ }
+
+ /// <summary>
+ /// Write collection.
+ /// </summary>
+ /// <param name="val">Collection.</param>
+ public void WriteCollection(ICollection val)
+ {
+ Write(val);
+ }
+
+ /// <summary>
+ /// Write named generic collection.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Collection.</param>
+ public void WriteGenericCollection<T>(string fieldName, ICollection<T> val)
+ {
+ WriteFieldId(fieldName, PU.TypeCollection);
+
+ if (val == null)
+ WriteNullField();
+ else
+ {
+ int pos = SkipFieldLength();
+
+ Write(val);
+
+ WriteFieldLength(_stream, pos);
+ }
+ }
+
+ /// <summary>
+ /// Write generic collection.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="val">Collection.</param>
+ public void WriteGenericCollection<T>(ICollection<T> val)
+ {
+ Write(val);
+ }
+
+ /// <summary>
+ /// Write named dictionary.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Dictionary.</param>
+ public void WriteDictionary(string fieldName, IDictionary val)
+ {
+ WriteFieldId(fieldName, PU.TypeDictionary);
+
+ if (val == null)
+ WriteNullField();
+ else
+ {
+ int pos = SkipFieldLength();
+
+ Write(val);
+
+ WriteFieldLength(_stream, pos);
+ }
+ }
+
+ /// <summary>
+ /// Write dictionary.
+ /// </summary>
+ /// <param name="val">Dictionary.</param>
+ public void WriteDictionary(IDictionary val)
+ {
+ Write(val);
+ }
+
+ /// <summary>
+ /// Write named generic dictionary.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="val">Dictionary.</param>
+ public void WriteGenericDictionary<TK, TV>(string fieldName, IDictionary<TK, TV> val)
+ {
+ WriteFieldId(fieldName, PU.TypeDictionary);
+
+ if (val == null)
+ WriteNullField();
+ else
+ {
+ int pos = SkipFieldLength();
+
+ Write(val);
+
+ WriteFieldLength(_stream, pos);
+ }
+ }
+
+ /// <summary>
+ /// Write generic dictionary.
+ /// </summary>
+ /// <param name="val">Dictionary.</param>
+ public void WriteGenericDictionary<TK, TV>(IDictionary<TK, TV> val)
+ {
+ Write(val);
+ }
+
+ /// <summary>
+ /// Write NULL field.
+ /// </summary>
+ public void WriteNullField()
+ {
+ _stream.WriteInt(1);
+ _stream.WriteByte(PU.HdrNull);
+ }
+
+ /// <summary>
+ /// Write NULL raw field.
+ /// </summary>
+ public void WriteNullRawField()
+ {
+ _stream.WriteByte(PU.HdrNull);
+ }
+
+ /// <summary>
+ /// Get raw writer.
+ /// </summary>
+ /// <returns>
+ /// Raw writer.
+ /// </returns>
+ public IPortableRawWriter GetRawWriter()
+ {
+ if (_curRawPos == 0)
+ _curRawPos = _stream.Position;
+
+ return this;
+ }
+
+ /// <summary>
+ /// Set new builder.
+ /// </summary>
+ /// <param name="builder">Builder.</param>
+ /// <returns>Previous builder.</returns>
+ internal PortableBuilderImpl Builder(PortableBuilderImpl builder)
+ {
+ PortableBuilderImpl ret = _builder;
+
+ _builder = builder;
+
+ return ret;
+ }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="marsh">Marshaller.</param>
+ /// <param name="stream">Stream.</param>
+ internal PortableWriterImpl(PortableMarshaller marsh, IPortableStream stream)
+ {
+ _marsh = marsh;
+ _stream = stream;
+ }
+
+ /// <summary>
+ /// Write object.
+ /// </summary>
+ /// <param name="obj">Object.</param>
+ public void Write<T>(T obj)
+ {
+ // Handle special case for null.
+ if (obj == null)
+ {
+ _stream.WriteByte(PU.HdrNull);
+
+ return;
+ }
+
+ // We use GetType() of a real object instead of typeof(T) to take advantage of
+ // automatic Nullable'1 unwrapping.
+ Type type = obj.GetType();
+
+ // Handle common case when primitive is written.
+ if (type.IsPrimitive)
+ {
+ WritePrimitive(obj, type);
+
+ return;
+ }
+
+ // Handle special case for builder.
+ if (WriteBuilderSpecials(obj))
+ return;
+
+ // Suppose that we faced normal object and perform descriptor lookup.
+ IPortableTypeDescriptor desc = _marsh.GetDescriptor(type);
+
+ if (desc != null)
+ {
+ // Writing normal object.
+ var pos = _stream.Position;
+
+ // Dealing with handles.
+ if (!(desc.Serializer is IPortableSystemTypeSerializer) && WriteHandle(pos, obj))
+ return;
+
+ // Write header.
+ _stream.WriteByte(PU.HdrFull);
++ _stream.WriteByte(PU.ProtoVer);
+ _stream.WriteBool(desc.UserType);
+ _stream.WriteInt(desc.TypeId);
+ _stream.WriteInt(obj.GetHashCode());
+
+ // Skip length as it is not known in the first place.
+ _stream.Seek(8, SeekOrigin.Current);
+
+ // Preserve old frame.
+ int oldTypeId = _curTypeId;
+ IPortableNameMapper oldConverter = _curConverter;
+ IPortableIdMapper oldMapper = _curMapper;
+ long oldRawPos = _curRawPos;
+
+ PortableStructure oldStruct = _curStruct;
+ int oldStructPath = _curStructPath;
+ int oldStructAction = _curStructAction;
+ var oldStructUpdates = _curStructUpdates;
+
+ // Push new frame.
+ _curTypeId = desc.TypeId;
+ _curConverter = desc.NameConverter;
+ _curMapper = desc.Mapper;
+ _curRawPos = 0;
+
+ _curStruct = desc.TypeStructure;
+ _curStructPath = 0;
+ _curStructAction = 0;
+ _curStructUpdates = null;
+
+ // Write object fields.
+ desc.Serializer.WritePortable(obj, this);
+
+ // Calculate and write length.
+ int len = _stream.Position - pos;
+
- _stream.WriteInt(pos + 10, len);
++ _stream.Seek(pos + PU.OffsetLen, SeekOrigin.Begin);
+
+ if (_curRawPos != 0)
- _stream.WriteInt(pos + 14, (int)(_curRawPos - pos));
++ _stream.WriteInt(pos + PU.OffsetRaw, (int)(_curRawPos - pos));
+ else
- _stream.WriteInt(pos + 14, len);
++ _stream.WriteInt(pos + PU.OffsetRaw, len);
+
+ // Apply structure updates if any.
+ if (_curStructUpdates != null)
+ {
+ desc.UpdateStructure(_curStruct, _curStructPath, _curStructUpdates);
+
+ IPortableMetadataHandler metaHnd = _marsh.GetMetadataHandler(desc);
+
+ if (metaHnd != null)
+ {
+ foreach (var u in _curStructUpdates)
+ metaHnd.OnFieldWrite(u.FieldId, u.FieldName, u.FieldType);
+
+ IDictionary<string, int> meta = metaHnd.OnObjectWriteFinished();
+
+ if (meta != null)
+ SaveMetadata(_curTypeId, desc.TypeName, desc.AffinityKeyFieldName, meta);
+ }
+ }
+
+ // Restore old frame.
+ _curTypeId = oldTypeId;
+ _curConverter = oldConverter;
+ _curMapper = oldMapper;
+ _curRawPos = oldRawPos;
+
+ _curStruct = oldStruct;
+ _curStructPath = oldStructPath;
+ _curStructAction = oldStructAction;
+ _curStructUpdates = oldStructUpdates;
+ }
+ else
+ {
+ // Are we dealing with a well-known type?
+ PortableSystemWriteDelegate handler = PortableSystemHandlers.GetWriteHandler(type);
+
+ if (handler != null)
+ handler.Invoke(this, obj);
+ else
+ {
+ // Last chance: is object seializable?
+ if (type.IsSerializable)
+ Write(new SerializableObjectHolder(obj));
+ else
+ // We did our best, object cannot be marshalled.
+ throw new PortableException("Unsupported object type [type=" + type + ", object=" + obj + ']');
+ }
+ }
+ }
+
+ /// <summary>
+ /// Write primitive type.
+ /// </summary>
+ /// <param name="val">Object.</param>
+ /// <param name="type">Type.</param>
+ public unsafe void WritePrimitive<T>(T val, Type type)
+ {
+ // .Net defines 14 primitive types. We support 12 - excluding IntPtr and UIntPtr.
+ // Types check sequence is designed to minimize comparisons for the most frequent types.
+
+ if (type == typeof(int))
+ {
+ _stream.WriteByte(PU.TypeInt);
+ _stream.WriteInt((int)(object)val);
+ }
+ else if (type == typeof(long))
+ {
+ _stream.WriteByte(PU.TypeLong);
+ _stream.WriteLong((long)(object)val);
+ }
+ else if (type == typeof(bool))
+ {
+ _stream.WriteByte(PU.TypeBool);
+ _stream.WriteBool((bool)(object)val);
+ }
+ else if (type == typeof(byte))
+ {
+ _stream.WriteByte(PU.TypeByte);
+ _stream.WriteByte((byte)(object)val);
+ }
+ else if (type == typeof(short))
+ {
+ _stream.WriteByte(PU.TypeShort);
+ _stream.WriteShort((short)(object)val);
+ }
+ else if (type == typeof (char))
+ {
+ _stream.WriteByte(PU.TypeChar);
+ _stream.WriteChar((char)(object)val);
+ }
+ else if (type == typeof(float))
+ {
+ _stream.WriteByte(PU.TypeFloat);
+ _stream.WriteFloat((float)(object)val);
+ }
+ else if (type == typeof(double))
+ {
+ _stream.WriteByte(PU.TypeDouble);
+ _stream.WriteDouble((double)(object)val);
+ }
+ else if (type == typeof(sbyte))
+ {
+ sbyte val0 = (sbyte)(object)val;
+
+ _stream.WriteByte(PU.TypeByte);
+ _stream.WriteByte(*(byte*)&val0);
+ }
+ else if (type == typeof(ushort))
+ {
+ ushort val0 = (ushort)(object)val;
+
+ _stream.WriteByte(PU.TypeShort);
+ _stream.WriteShort(*(short*)&val0);
+ }
+ else if (type == typeof(uint))
+ {
+ uint val0 = (uint)(object)val;
+
+ _stream.WriteByte(PU.TypeInt);
+ _stream.WriteInt(*(int*)&val0);
+ }
+ else if (type == typeof(ulong))
+ {
+ ulong val0 = (ulong)(object)val;
+
+ _stream.WriteByte(PU.TypeLong);
+ _stream.WriteLong(*(long*)&val0);
+ }
+ else
+ throw new PortableException("Unsupported object type [type=" + type.FullName + ", object=" + val + ']');
+ }
+
+ /// <summary>
+ /// Try writing object as special builder type.
+ /// </summary>
+ /// <param name="obj">Object.</param>
+ /// <returns>True if object was written, false otherwise.</returns>
+ private bool WriteBuilderSpecials<T>(T obj)
+ {
+ if (_builder != null)
+ {
+ // Special case for portable object during build.
+ PortableUserObject portObj = obj as PortableUserObject;
+
+ if (portObj != null)
+ {
+ if (!WriteHandle(_stream.Position, portObj))
+ _builder.ProcessPortable(_stream, portObj);
+
+ return true;
+ }
+
+ // Special case for builder during build.
+ PortableBuilderImpl portBuilder = obj as PortableBuilderImpl;
+
+ if (portBuilder != null)
+ {
+ if (!WriteHandle(_stream.Position, portBuilder))
+ _builder.ProcessBuilder(_stream, portBuilder);
+
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /// <summary>
+ /// Add handle to handles map.
+ /// </summary>
+ /// <param name="pos">Position in stream.</param>
+ /// <param name="obj">Object.</param>
+ /// <returns><c>true</c> if object was written as handle.</returns>
+ private bool WriteHandle(long pos, object obj)
+ {
+ if (_hnds == null)
+ {
+ // Cache absolute handle position.
+ _hnds = new PortableHandleDictionary<object, long>(obj, pos);
+
+ return false;
+ }
+
+ long hndPos;
+
+ if (!_hnds.TryGetValue(obj, out hndPos))
+ {
+ // Cache absolute handle position.
+ _hnds.Add(obj, pos);
+
+ return false;
+ }
+
+ _stream.WriteByte(PU.HdrHnd);
+
+ // Handle is written as difference between position before header and handle position.
+ _stream.WriteInt((int)(pos - hndPos));
+
+ return true;
+ }
+
+ /// <summary>
+ /// Perform action with detached semantics.
+ /// </summary>
+ /// <param name="a"></param>
+ internal void WithDetach(Action<PortableWriterImpl> a)
+ {
+ if (_detaching)
+ a(this);
+ else
+ {
+ _detaching = true;
+
+ PortableHandleDictionary<object, long> oldHnds = _hnds;
+ _hnds = null;
+
+ try
+ {
+ a(this);
+ }
+ finally
+ {
+ _detaching = false;
+
+ if (oldHnds != null)
+ {
+ // Merge newly recorded handles with old ones and restore old on the stack.
+ // Otherwise we can use current handles right away.
+ if (_hnds != null)
+ oldHnds.Merge(_hnds);
+
+ _hnds = oldHnds;
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// Stream.
+ /// </summary>
+ internal IPortableStream Stream
+ {
+ get { return _stream; }
+ }
+
+ /// <summary>
+ /// Gets collected metadatas.
+ /// </summary>
+ /// <returns>Collected metadatas (if any).</returns>
+ internal IDictionary<int, IPortableMetadata> Metadata()
+ {
+ return _metas;
+ }
+
+ /// <summary>
+ /// Check whether the given object is portable, i.e. it can be
+ /// serialized with portable marshaller.
+ /// </summary>
+ /// <param name="obj">Object.</param>
+ /// <returns>True if portable.</returns>
+ internal bool IsPortable(object obj)
+ {
+ if (obj != null)
+ {
+ Type type = obj.GetType();
+
+ // We assume object as portable only in case it has descriptor.
+ // Collections, Enums and non-primitive arrays do not have descriptors
+ // and this is fine here because we cannot know whether their members
+ // are portable.
+ return _marsh.GetDescriptor(type) != null || PortableSystemHandlers.GetWriteHandler(type) != null;
+ }
+
+ return true;
+ }
+
+ /// <summary>
+ /// Write field ID.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="fieldTypeId">Field type ID.</param>
+ private void WriteFieldId(string fieldName, byte fieldTypeId)
+ {
+ if (_curRawPos != 0)
+ throw new PortableException("Cannot write named fields after raw data is written.");
+
+ int action = _curStructAction++;
+
+ int fieldId;
+
+ if (_curStructUpdates == null)
+ {
+ fieldId = _curStruct.GetFieldId(fieldName, fieldTypeId, ref _curStructPath, action);
+
+ if (fieldId == 0)
+ fieldId = GetNewFieldId(fieldName, fieldTypeId, action);
+ }
+ else
+ fieldId = GetNewFieldId(fieldName, fieldTypeId, action);
+
+ _stream.WriteInt(fieldId);
+ }
+
+ /// <summary>
+ /// Get ID for the new field and save structure update.
+ /// </summary>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="fieldTypeId">Field type ID.</param>
+ /// <param name="action">Action index.</param>
+ /// <returns>Field ID.</returns>
+ private int GetNewFieldId(string fieldName, byte fieldTypeId, int action)
+ {
+ int fieldId = PU.FieldId(_curTypeId, fieldName, _curConverter, _curMapper);
+
+ if (_curStructUpdates == null)
+ _curStructUpdates = new List<PortableStructureUpdate>();
+
+ _curStructUpdates.Add(new PortableStructureUpdate(fieldName, fieldId, fieldTypeId, action));
+
+ return fieldId;
+ }
+
+ /// <summary>
+ /// Skip field lenght and return position where it is to be written.
+ /// </summary>
+ /// <returns></returns>
+ private int SkipFieldLength()
+ {
+ int pos = _stream.Position;
+
+ _stream.Seek(4, SeekOrigin.Current);
+
+ return pos;
+ }
+
+ /// <summary>
+ /// Write field length.
+ /// </summary>
+ /// <param name="stream">Stream.</param>
+ /// <param name="pos">Position where length should reside</param>
+ private static void WriteFieldLength(IPortableStream stream, int pos)
+ {
+ // Length is is a difference between current position and previously recorder
+ // length placeholder position minus 4 bytes for the length itself.
+ stream.WriteInt(pos, stream.Position - pos - 4);
+ }
+
+ /// <summary>
+ /// Saves metadata for this session.
+ /// </summary>
+ /// <param name="typeId">Type ID.</param>
+ /// <param name="typeName">Type name.</param>
+ /// <param name="affKeyFieldName">Affinity key field name.</param>
+ /// <param name="fields">Fields metadata.</param>
+ internal void SaveMetadata(int typeId, string typeName, string affKeyFieldName, IDictionary<string, int> fields)
+ {
+ if (_metas == null)
+ {
+ PortableMetadataImpl meta =
+ new PortableMetadataImpl(typeId, typeName, fields, affKeyFieldName);
+
+ _metas = new Dictionary<int, IPortableMetadata>(1);
+
+ _metas[typeId] = meta;
+ }
+ else
+ {
+ IPortableMetadata meta;
+
+ if (_metas.TryGetValue(typeId, out meta))
+ {
+ IDictionary<string, int> existingFields = ((PortableMetadataImpl)meta).FieldsMap();
+
+ foreach (KeyValuePair<string, int> field in fields)
+ {
+ if (!existingFields.ContainsKey(field.Key))
+ existingFields[field.Key] = field.Value;
+ }
+ }
+ else
+ _metas[typeId] = new PortableMetadataImpl(typeId, typeName, fields, affKeyFieldName);
+ }
+ }
+ }
+ }
http://git-wip-us.apache.org/repos/asf/ignite/blob/ec58b87c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortablesImpl.cs
----------------------------------------------------------------------
diff --cc modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortablesImpl.cs
index 0000000,5b73171..451386b
mode 000000,100644..100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortablesImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortablesImpl.cs
@@@ -1,0 -1,192 +1,193 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Portable
+ {
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Impl.Common;
+ using Apache.Ignite.Core.Impl.Portable.IO;
+ using Apache.Ignite.Core.Portable;
+
+ /// <summary>
+ /// Portables implementation.
+ /// </summary>
+ internal class PortablesImpl : IPortables
+ {
+ /** Owning grid. */
+ private readonly PortableMarshaller _marsh;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="marsh">Marshaller.</param>
+ internal PortablesImpl(PortableMarshaller marsh)
+ {
+ _marsh = marsh;
+ }
+
+ /** <inheritDoc /> */
+ public T ToPortable<T>(object obj)
+ {
+ if (obj is IPortableObject)
+ return (T)obj;
+
+ IPortableStream stream = new PortableHeapStream(1024);
+
+ // Serialize.
+ PortableWriterImpl writer = _marsh.StartMarshal(stream);
+
+ try
+ {
+ writer.Write(obj);
+ }
+ finally
+ {
+ // Save metadata.
+ _marsh.FinishMarshal(writer);
+ }
+
+ // Deserialize.
+ stream.Seek(0, SeekOrigin.Begin);
+
+ return _marsh.Unmarshal<T>(stream, PortableMode.ForcePortable);
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder GetBuilder(Type type)
+ {
+ IgniteArgumentCheck.NotNull(type, "type");
+
+ IPortableTypeDescriptor desc = _marsh.GetDescriptor(type);
+
+ if (desc == null)
+ throw new IgniteException("Type is not portable (add it to PortableConfiguration): " +
+ type.FullName);
+
+ return Builder0(null, PortableFromDescriptor(desc), desc);
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder GetBuilder(string typeName)
+ {
+ IgniteArgumentCheck.NotNullOrEmpty(typeName, "typeName");
+
+ IPortableTypeDescriptor desc = _marsh.GetDescriptor(typeName);
+
+ return Builder0(null, PortableFromDescriptor(desc), desc);
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder GetBuilder(IPortableObject obj)
+ {
+ IgniteArgumentCheck.NotNull(obj, "obj");
+
+ PortableUserObject obj0 = obj as PortableUserObject;
+
+ if (obj0 == null)
+ throw new ArgumentException("Unsupported object type: " + obj.GetType());
+
+ IPortableTypeDescriptor desc = _marsh.GetDescriptor(true, obj0.TypeId);
+
+ return Builder0(null, obj0, desc);
+ }
+
+ /** <inheritDoc /> */
+ public int GetTypeId(string typeName)
+ {
+ IgniteArgumentCheck.NotNullOrEmpty(typeName, "typeName");
+
+ return Marshaller.GetDescriptor(typeName).TypeId;
+ }
+
+ /** <inheritDoc /> */
+ public ICollection<IPortableMetadata> GetMetadata()
+ {
+ return Marshaller.Ignite.ClusterGroup.Metadata();
+ }
+
+ /** <inheritDoc /> */
+ public IPortableMetadata GetMetadata(int typeId)
+ {
+ return Marshaller.GetMetadata(typeId);
+ }
+
+ /** <inheritDoc /> */
+ public IPortableMetadata GetMetadata(string typeName)
+ {
+ IgniteArgumentCheck.NotNullOrEmpty(typeName, "typeName");
+
+ return GetMetadata(GetTypeId(typeName));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableMetadata GetMetadata(Type type)
+ {
+ IgniteArgumentCheck.NotNull(type, "type");
+
+ var desc = Marshaller.GetDescriptor(type);
+
+ return desc == null ? null : Marshaller.GetMetadata(desc.TypeId);
+ }
+
+ /// <summary>
+ /// Marshaller.
+ /// </summary>
+ internal PortableMarshaller Marshaller
+ {
+ get
+ {
+ return _marsh;
+ }
+ }
+
+ /// <summary>
+ /// Create empty portable object from descriptor.
+ /// </summary>
+ /// <param name="desc">Descriptor.</param>
+ /// <returns>Empty portable object.</returns>
+ private PortableUserObject PortableFromDescriptor(IPortableTypeDescriptor desc)
+ {
+ PortableHeapStream stream = new PortableHeapStream(18);
+
+ stream.WriteByte(PortableUtils.HdrFull);
++ stream.WriteByte(PortableUtils.ProtoVer);
+ stream.WriteBool(true);
+ stream.WriteInt(desc.TypeId);
+ stream.WriteInt(0); // Hash.
+ stream.WriteInt(PortableUtils.FullHdrLen); // Length.
+ stream.WriteInt(PortableUtils.FullHdrLen); // Raw data offset.
+
+ return new PortableUserObject(_marsh, stream.InternalArray, 0, desc.TypeId, 0);
+ }
+
+ /// <summary>
+ /// Internal builder creation routine.
+ /// </summary>
+ /// <param name="parent">Parent builder.</param>
+ /// <param name="obj">Portable object.</param>
+ /// <param name="desc">Type descriptor.</param>
+ /// <returns>Builder.</returns>
+ private PortableBuilderImpl Builder0(PortableBuilderImpl parent, PortableUserObject obj,
+ IPortableTypeDescriptor desc)
+ {
+ return new PortableBuilderImpl(this, parent, obj, desc);
+ }
+ }
+ }
[17/50] [abbrv] ignite git commit: IGNITE-1622 - Fixed cache.clear()
with near cache
Posted by vo...@apache.org.
IGNITE-1622 - Fixed cache.clear() with near cache
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a228c246
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a228c246
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a228c246
Branch: refs/heads/ignite-1651
Commit: a228c246ae58894d0939887218252c2bde882fce
Parents: c9eb539
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Thu Oct 15 16:02:38 2015 -0700
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Thu Oct 15 16:02:38 2015 -0700
----------------------------------------------------------------------
.../processors/cache/GridCacheAdapter.java | 357 +++++++++++--------
.../cache/GridCacheClearAllRunnable.java | 18 +-
.../cache/GridCacheConcurrentMap.java | 4 +-
.../processors/cache/GridCacheProxyImpl.java | 14 +-
.../processors/cache/IgniteCacheProxy.java | 2 +-
.../processors/cache/IgniteInternalCache.java | 19 +-
.../distributed/dht/GridDhtCacheAdapter.java | 6 +-
.../distributed/near/GridNearCacheAdapter.java | 21 +-
.../near/GridNearCacheClearAllRunnable.java | 9 +-
.../cache/GridCacheClearSelfTest.java | 308 ++++++++++++++++
.../dht/GridCacheDhtEntrySelfTest.java | 2 +-
.../IgniteCacheFullApiSelfTestSuite.java | 8 +-
12 files changed, 587 insertions(+), 181 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a228c246/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index ae987b7..417b396 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -129,6 +129,7 @@ import org.apache.ignite.lang.IgniteCallable;
import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.lang.IgniteOutClosure;
+import org.apache.ignite.lang.IgniteProductVersion;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.mxbean.CacheMetricsMXBean;
import org.apache.ignite.plugin.security.SecurityPermission;
@@ -149,7 +150,6 @@ import static org.apache.ignite.internal.processors.dr.GridDrType.DR_LOAD;
import static org.apache.ignite.internal.processors.dr.GridDrType.DR_NONE;
import static org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.TC_NO_FAILOVER;
import static org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.TC_SUBGRID;
-import static org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.TC_TIMEOUT;
import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED;
@@ -1057,44 +1057,52 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
/**
* Split clearLocally all task into multiple runnables.
*
+ * @param srv Whether to clear server cache.
+ * @param near Whether to clear near cache.
+ * @param readers Whether to clear readers.
* @return Split runnables.
*/
- public List<GridCacheClearAllRunnable<K, V>> splitClearLocally() {
- assert CLEAR_ALL_SPLIT_THRESHOLD > 0;
+ public List<GridCacheClearAllRunnable<K, V>> splitClearLocally(boolean srv, boolean near, boolean readers) {
+ if ((isNear() && near) || (!isNear() && srv)) {
+ int keySize = size();
- int keySize = size();
+ int cnt = Math.min(keySize / CLEAR_ALL_SPLIT_THRESHOLD + (keySize % CLEAR_ALL_SPLIT_THRESHOLD != 0 ? 1 : 0),
+ Runtime.getRuntime().availableProcessors());
- int cnt = Math.min(keySize / CLEAR_ALL_SPLIT_THRESHOLD + (keySize % CLEAR_ALL_SPLIT_THRESHOLD != 0 ? 1 : 0),
- Runtime.getRuntime().availableProcessors());
+ if (cnt == 0)
+ cnt = 1; // Still perform cleanup since there could be entries in swap.
- if (cnt == 0)
- cnt = 1; // Still perform cleanup since there could be entries in swap.
+ GridCacheVersion obsoleteVer = ctx.versions().next();
- GridCacheVersion obsoleteVer = ctx.versions().next();
-
- List<GridCacheClearAllRunnable<K, V>> res = new ArrayList<>(cnt);
+ List<GridCacheClearAllRunnable<K, V>> res = new ArrayList<>(cnt);
- for (int i = 0; i < cnt; i++)
- res.add(new GridCacheClearAllRunnable<>(this, obsoleteVer, i, cnt));
+ for (int i = 0; i < cnt; i++)
+ res.add(new GridCacheClearAllRunnable<>(this, obsoleteVer, i, cnt, readers));
- return res;
+ return res;
+ }
+ else
+ return null;
}
/** {@inheritDoc} */
@Override public boolean clearLocally(K key) {
- return clearLocally0(key);
+ return clearLocally0(key, false);
}
/** {@inheritDoc} */
- @Override public void clearLocallyAll(Set<? extends K> keys) {
- clearLocally0(keys);
+ @Override public void clearLocallyAll(Set<? extends K> keys, boolean srv, boolean near, boolean readers) {
+ if (keys != null && ((isNear() && near) || (!isNear() && srv))) {
+ for (K key : keys)
+ clearLocally0(key, readers);
+ }
}
/** {@inheritDoc} */
- @Override public void clearLocally() {
+ @Override public void clearLocally(boolean srv, boolean near, boolean readers) {
ctx.checkSecurity(SecurityPermission.CACHE_REMOVE);
- List<GridCacheClearAllRunnable<K, V>> jobs = splitClearLocally();
+ List<GridCacheClearAllRunnable<K, V>> jobs = splitClearLocally(srv, near, readers);
if (!F.isEmpty(jobs)) {
ExecutorService execSvc = null;
@@ -1128,135 +1136,102 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
}
}
- /**
- * @param keys Keys.
- * @param readers Readers flag.
- */
- public void clearLocally(Collection<KeyCacheObject> keys, boolean readers) {
- if (F.isEmpty(keys))
- return;
-
- GridCacheVersion obsoleteVer = ctx.versions().next();
-
- for (KeyCacheObject key : keys) {
- GridCacheEntryEx e = peekEx(key);
-
- try {
- if (e != null)
- e.clear(obsoleteVer, readers, null);
- }
- catch (IgniteCheckedException ex) {
- U.error(log, "Failed to clearLocally entry (will continue to clearLocally other entries): " + e,
- ex);
- }
- }
- }
-
- /**
- * Clears entry from cache.
- *
- * @param obsoleteVer Obsolete version to set.
- * @param key Key to clearLocally.
- * @param filter Optional filter.
- * @return {@code True} if cleared.
- */
- private boolean clearLocally(GridCacheVersion obsoleteVer, K key, @Nullable CacheEntryPredicate[] filter) {
- try {
- KeyCacheObject cacheKey = ctx.toCacheKeyObject(key);
-
- GridCacheEntryEx entry = ctx.isSwapOrOffheapEnabled() ? entryEx(cacheKey) : peekEx(cacheKey);
-
- if (entry != null)
- return entry.clear(obsoleteVer, false, filter);
- }
- catch (GridDhtInvalidPartitionException ignored) {
- return false;
- }
- catch (IgniteCheckedException ex) {
- U.error(log, "Failed to clearLocally entry for key: " + key, ex);
- }
-
- return false;
- }
-
/** {@inheritDoc} */
@Override public void clear() throws IgniteCheckedException {
- // Clear local cache synchronously.
- clearLocally();
-
- clearRemotes(0, null);
+ clear((Set<? extends K>)null);
}
/** {@inheritDoc} */
@Override public void clear(K key) throws IgniteCheckedException {
- // Clear local cache synchronously.
- clearLocally(key);
-
- clearRemotes(0, Collections.singleton(key));
+ clear(Collections.singleton(key));
}
/** {@inheritDoc} */
@Override public void clearAll(Set<? extends K> keys) throws IgniteCheckedException {
- // Clear local cache synchronously.
- clearLocallyAll(keys);
+ clear(keys);
+ }
- clearRemotes(0, keys);
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<?> clearAsync() {
+ return clearAsync((Set<? extends K>)null);
}
/** {@inheritDoc} */
@Override public IgniteInternalFuture<?> clearAsync(K key) {
- return clearKeysAsync(Collections.singleton(key));
+ return clearAsync(Collections.singleton(key));
}
/** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> clearAsync(Set<? extends K> keys) {
- return clearKeysAsync(keys);
+ @Override public IgniteInternalFuture<?> clearAllAsync(Set<? extends K> keys) {
+ return clearAsync(keys);
}
/**
- * @param timeout Timeout for clearLocally all task in milliseconds (0 for never).
- * Set it to larger value for large caches.
- * @param keys Keys to clear or {@code null} if all cache should be cleared.
- * @throws IgniteCheckedException In case of cache could not be cleared on any of the nodes.
+ * @param keys Keys to clear.
+ * @throws IgniteCheckedException In case of error.
*/
- private void clearRemotes(long timeout, @Nullable final Set<? extends K> keys) throws IgniteCheckedException {
- // Send job to remote nodes only.
- Collection<ClusterNode> nodes =
- ctx.grid().cluster().forCacheNodes(name(), true, true, false).forRemotes().nodes();
-
- if (!nodes.isEmpty()) {
- ctx.kernalContext().task().setThreadContext(TC_TIMEOUT, timeout);
-
- ctx.kernalContext().task().setThreadContext(TC_SUBGRID, nodes);
-
- ctx.kernalContext().task().execute(
- new ClearTask(ctx.name(), ctx.affinity().affinityTopologyVersion(), keys), null).get();
- }
+ private void clear(@Nullable Set<? extends K> keys) throws IgniteCheckedException {
+ executeClearTask(keys, false).get();
+ executeClearTask(keys, true).get();
}
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> clearAsync() {
- return clearKeysAsync(null);
+ /**
+ * @param keys Keys to clear or {@code null} if all cache should be cleared.
+ * @return Future.
+ */
+ private IgniteInternalFuture<?> clearAsync(@Nullable final Set<? extends K> keys) {
+ return executeClearTask(keys, false).chain(new CX1<IgniteInternalFuture<?>, Object>() {
+ @Override public Object applyx(IgniteInternalFuture<?> fut) throws IgniteCheckedException {
+ executeClearTask(keys, true).get();
+
+ return null;
+ }
+ });
}
/**
- * @param keys Keys to clear or {@code null} if all cache should be cleared.
+ * @param keys Keys to clear.
+ * @param near Near cache flag.
* @return Future.
*/
- private IgniteInternalFuture<?> clearKeysAsync(final Set<? extends K> keys) {
- Collection<ClusterNode> nodes = ctx.grid().cluster().forCacheNodes(name(), true, true, false).nodes();
+ private IgniteInternalFuture<?> executeClearTask(@Nullable Set<? extends K> keys, boolean near) {
+ Collection<ClusterNode> srvNodes = ctx.grid().cluster().forCacheNodes(name(), !near, near, false).nodes();
- if (!nodes.isEmpty()) {
- ctx.kernalContext().task().setThreadContext(TC_SUBGRID, nodes);
+ if (!srvNodes.isEmpty()) {
+ ctx.kernalContext().task().setThreadContext(TC_SUBGRID, srvNodes);
return ctx.kernalContext().task().execute(
- new ClearTask(ctx.name(), ctx.affinity().affinityTopologyVersion(), keys), null);
+ new ClearTask(ctx.name(), ctx.affinity().affinityTopologyVersion(), keys, near), null);
}
else
return new GridFinishedFuture<>();
}
/**
+ * @param keys Keys.
+ * @param readers Readers flag.
+ */
+ public void clearLocally(Collection<KeyCacheObject> keys, boolean readers) {
+ if (F.isEmpty(keys))
+ return;
+
+ GridCacheVersion obsoleteVer = ctx.versions().next();
+
+ for (KeyCacheObject key : keys) {
+ GridCacheEntryEx e = peekEx(key);
+
+ try {
+ if (e != null)
+ e.clear(obsoleteVer, readers, null);
+ }
+ catch (IgniteCheckedException ex) {
+ U.error(log, "Failed to clearLocally entry (will continue to clearLocally other entries): " + e,
+ ex);
+ }
+ }
+ }
+
+ /**
* @param entry Removes entry from cache if currently mapped value is the same as passed.
*/
public void removeEntry(GridCacheEntryEx entry) {
@@ -4427,39 +4402,33 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
}
/**
- * @param keys Keys.
- * @param filter Filters to evaluate.
+ * @param key Key.
+ * @param readers Whether to clear readers.
*/
- public void clearLocally0(Collection<? extends K> keys,
- @Nullable CacheEntryPredicate... filter) {
+ private boolean clearLocally0(K key, boolean readers) {
ctx.checkSecurity(SecurityPermission.CACHE_REMOVE);
- if (F.isEmpty(keys))
- return;
-
if (keyCheck)
- validateCacheKeys(keys);
+ validateCacheKey(key);
GridCacheVersion obsoleteVer = ctx.versions().next();
- for (K k : keys)
- clearLocally(obsoleteVer, k, filter);
- }
-
- /**
- * @param key Key.
- * @param filter Filters to evaluate.
- * @return {@code True} if cleared.
- */
- public boolean clearLocally0(K key, @Nullable CacheEntryPredicate... filter) {
- A.notNull(key, "key");
+ try {
+ KeyCacheObject cacheKey = ctx.toCacheKeyObject(key);
- if (keyCheck)
- validateCacheKey(key);
+ GridCacheEntryEx entry = ctx.isSwapOrOffheapEnabled() ? entryEx(cacheKey) : peekEx(cacheKey);
- ctx.checkSecurity(SecurityPermission.CACHE_REMOVE);
+ if (entry != null)
+ return entry.clear(obsoleteVer, readers, null);
+ }
+ catch (GridDhtInvalidPartitionException ignored) {
+ // No-op.
+ }
+ catch (IgniteCheckedException ex) {
+ U.error(log, "Failed to clearLocally entry for key: " + key, ex);
+ }
- return clearLocally(ctx.versions().next(), key, filter);
+ return false;
}
/** {@inheritDoc} */
@@ -5178,10 +5147,24 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
/** {@inheritDoc} */
@Nullable @Override public Object localExecute(@Nullable IgniteInternalCache cache) {
if (cache != null)
- cache.clearLocally();
+ cache.clearLocally(clearServerCache(), clearNearCache(), true);
return null;
}
+
+ /**
+ * @return Whether to clear server cache.
+ */
+ protected boolean clearServerCache() {
+ return true;
+ }
+
+ /**
+ * @return Whether to clear near cache.
+ */
+ protected boolean clearNearCache() {
+ return false;
+ }
}
/**
@@ -5209,10 +5192,87 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
/** {@inheritDoc} */
@Nullable @Override public Object localExecute(@Nullable IgniteInternalCache cache) {
if (cache != null)
- cache.clearLocallyAll(keys);
+ cache.clearLocallyAll(keys, clearServerCache(), clearNearCache(), true);
return null;
}
+
+ /**
+ * @return Whether to clear server cache.
+ */
+ protected boolean clearServerCache() {
+ return true;
+ }
+
+ /**
+ * @return Whether to clear near cache.
+ */
+ protected boolean clearNearCache() {
+ return false;
+ }
+ }
+
+ /**
+ * Global clear all for near cache.
+ */
+ @GridInternal
+ private static class GlobalClearAllNearJob extends GlobalClearAllJob {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ * @param cacheName Cache name.
+ * @param topVer Affinity topology version.
+ */
+ private GlobalClearAllNearJob(String cacheName, AffinityTopologyVersion topVer) {
+ super(cacheName, topVer);
+ }
+
+ /**
+ * @return Whether to clear server cache.
+ */
+ @Override protected boolean clearServerCache() {
+ return false;
+ }
+
+ /**
+ * @return Whether to clear near cache.
+ */
+ @Override protected boolean clearNearCache() {
+ return true;
+ }
+ }
+
+ /**
+ * Global clear keys for near cache.
+ */
+ @GridInternal
+ private static class GlobalClearKeySetNearJob<K> extends GlobalClearKeySetJob<K> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ * @param cacheName Cache name.
+ * @param topVer Affinity topology version.
+ * @param keys Keys to clear.
+ */
+ private GlobalClearKeySetNearJob(String cacheName, AffinityTopologyVersion topVer, Set<? extends K> keys) {
+ super(cacheName, topVer, keys);
+ }
+
+ /**
+ * @return Whether to clear server cache.
+ */
+ protected boolean clearServerCache() {
+ return false;
+ }
+
+ /**
+ * @return Whether to clear near cache.
+ */
+ protected boolean clearNearCache() {
+ return true;
+ }
}
/**
@@ -5972,6 +6032,9 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
/** */
private static final long serialVersionUID = 0L;
+ /** */
+ public static final IgniteProductVersion NEAR_JOB_SINCE = IgniteProductVersion.fromString("1.5.0");
+
/** Cache name. */
private final String cacheName;
@@ -5981,26 +6044,40 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
/** Keys to clear. */
private final Set<? extends K> keys;
+ /** Near cache flag. */
+ private final boolean near;
+
/**
* @param cacheName Cache name.
* @param topVer Affinity topology version.
* @param keys Keys to clear.
+ * @param near Near cache flag.
*/
- public ClearTask(String cacheName, AffinityTopologyVersion topVer, Set<? extends K> keys) {
+ public ClearTask(String cacheName, AffinityTopologyVersion topVer, Set<? extends K> keys, boolean near) {
this.cacheName = cacheName;
this.topVer = topVer;
this.keys = keys;
+ this.near = near;
}
/** {@inheritDoc} */
@Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid,
@Nullable Object arg) throws IgniteException {
- Map<ComputeJob, ClusterNode> jobs = new HashMap();
+ Map<ComputeJob, ClusterNode> jobs = new HashMap<>();
for (ClusterNode node : subgrid) {
- jobs.put(keys == null ? new GlobalClearAllJob(cacheName, topVer) :
- new GlobalClearKeySetJob<K>(cacheName, topVer, keys),
- node);
+ ComputeJob job;
+
+ if (near && node.version().compareTo(NEAR_JOB_SINCE) >= 0) {
+ job = keys == null ? new GlobalClearAllNearJob(cacheName, topVer) :
+ new GlobalClearKeySetNearJob<>(cacheName, topVer, keys);
+ }
+ else {
+ job = keys == null ? new GlobalClearAllJob(cacheName, topVer) :
+ new GlobalClearKeySetJob<>(cacheName, topVer, keys);
+ }
+
+ jobs.put(job, node);
}
return jobs;
http://git-wip-us.apache.org/repos/asf/ignite/blob/a228c246/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllRunnable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllRunnable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllRunnable.java
index feafc58..77c5a55 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllRunnable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllRunnable.java
@@ -28,7 +28,7 @@ import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
/**
- * Base runnable for {@link GridCacheAdapter#clearLocally()} routine.
+ * Base runnable for {@link IgniteInternalCache#clearLocally(boolean, boolean, boolean)} routine.
*/
public class GridCacheClearAllRunnable<K, V> implements Runnable {
/** Cache to be cleared. */
@@ -43,6 +43,9 @@ public class GridCacheClearAllRunnable<K, V> implements Runnable {
/** Mods count across all spawned clearLocally runnables. */
protected final int totalCnt;
+ /** Whether to clear readers. */
+ protected final boolean readers;
+
/** Cache context. */
protected final GridCacheContext<K, V> ctx;
@@ -57,7 +60,8 @@ public class GridCacheClearAllRunnable<K, V> implements Runnable {
* @param id Mod for the given runnable.
* @param totalCnt Mods count across all spawned clearLocally runnables.
*/
- public GridCacheClearAllRunnable(GridCacheAdapter<K, V> cache, GridCacheVersion obsoleteVer, int id, int totalCnt) {
+ public GridCacheClearAllRunnable(GridCacheAdapter<K, V> cache, GridCacheVersion obsoleteVer,
+ int id, int totalCnt, boolean readers) {
assert cache != null;
assert obsoleteVer != null;
assert id >= 0;
@@ -68,6 +72,7 @@ public class GridCacheClearAllRunnable<K, V> implements Runnable {
this.obsoleteVer = obsoleteVer;
this.id = id;
this.totalCnt = totalCnt;
+ this.readers = readers;
ctx = cache.context();
log = ctx.logger(getClass());
@@ -138,7 +143,7 @@ public class GridCacheClearAllRunnable<K, V> implements Runnable {
*/
protected void clearEntry(GridCacheEntryEx e) {
try {
- e.clear(obsoleteVer, false, CU.empty0());
+ e.clear(obsoleteVer, readers, CU.empty0());
}
catch (IgniteCheckedException ex) {
U.error(log, "Failed to clearLocally entry from cache (will continue to clearLocally other entries): " + e, ex);
@@ -172,6 +177,13 @@ public class GridCacheClearAllRunnable<K, V> implements Runnable {
return totalCnt;
}
+ /**
+ * @return Whether to clean readers.
+ */
+ public boolean readers() {
+ return readers;
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(GridCacheClearAllRunnable.class, this);
http://git-wip-us.apache.org/repos/asf/ignite/blob/a228c246/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java
index a1fc585..1be7c07 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java
@@ -1968,7 +1968,7 @@ public class GridCacheConcurrentMap {
/** {@inheritDoc} */
@Override public void clear() {
- ctx.cache().clearLocally0(new KeySet<K, V>(map, filter, false));
+ ctx.cache().clearLocallyAll(new KeySet<K, V>(map, filter, false), true, true, false);
}
/** {@inheritDoc} */
@@ -2413,4 +2413,4 @@ public class GridCacheConcurrentMap {
set = (Set0<K, V>)in.readObject();
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a228c246/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
index 4d26bd8..cd779f2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
@@ -937,11 +937,11 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
}
/** {@inheritDoc} */
- @Override public void clearLocally() {
+ @Override public void clearLocally(boolean srv, boolean near, boolean readers) {
CacheOperationContext prev = gate.enter(opCtx);
try {
- delegate.clearLocally();
+ delegate.clearLocally(srv, near, readers);
}
finally {
gate.leave(prev);
@@ -985,11 +985,11 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
}
/** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> clearAsync(Set<? extends K> keys) {
+ @Override public IgniteInternalFuture<?> clearAllAsync(Set<? extends K> keys) {
CacheOperationContext prev = gate.enter(opCtx);
try {
- return delegate.clearAsync(keys);
+ return delegate.clearAllAsync(keys);
}
finally {
gate.leave(prev);
@@ -1009,11 +1009,11 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
}
/** {@inheritDoc} */
- @Override public void clearLocallyAll(Set<? extends K> keys) {
+ @Override public void clearLocallyAll(Set<? extends K> keys, boolean srv, boolean near, boolean readers) {
CacheOperationContext prev = gate.enter(opCtx);
try {
- delegate.clearLocallyAll(keys);
+ delegate.clearLocallyAll(keys, srv, near, readers);
}
finally {
gate.leave(prev);
@@ -1536,4 +1536,4 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
@Override public String toString() {
return S.toString(GridCacheProxyImpl.class, this);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a228c246/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index ae96f23..c563e59 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -1311,7 +1311,7 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
try {
if (isAsync())
- setFuture(delegate.clearAsync(keys));
+ setFuture(delegate.clearAllAsync(keys));
else
delegate.clearAll(keys);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a228c246/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
index 07650da..167cc8e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
@@ -925,8 +925,12 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
* Note that this operation is local as it merely clears
* entries from local cache. It does not remove entries from
* remote caches or from underlying persistent storage.
+ *
+ * @param srv Whether to clear server cache.
+ * @param near Whether to clear near cache.
+ * @param readers Whether to clear readers.
*/
- public void clearLocally();
+ public void clearLocally(boolean srv, boolean near, boolean readers);
/**
* Clears an entry from this cache and swap storage only if the entry
@@ -958,8 +962,11 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
* remote caches or from underlying persistent storage.
*
* @param keys Keys to clearLocally.
+ * @param srv Whether to clear server cache.
+ * @param near Whether to clear near cache.
+ * @param readers Whether to clear readers.
*/
- public void clearLocallyAll(Set<? extends K> keys);
+ public void clearLocallyAll(Set<? extends K> keys, boolean srv, boolean near, boolean readers);
/**
* Clears key on all nodes that store it's data. That is, caches are cleared on remote
@@ -976,7 +983,7 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
/**
* Clears keys on all nodes that store it's data. That is, caches are cleared on remote
- * nodes and local node, as opposed to {@link IgniteInternalCache#clearLocallyAll(Set)} method which only
+ * nodes and local node, as opposed to {@link IgniteInternalCache#clearLocallyAll(Set, boolean, boolean, boolean)} method which only
* clears local node's cache.
* <p>
* Ignite will make the best attempt to clear caches on all nodes. If some caches
@@ -989,7 +996,7 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
/**
* Clears cache on all nodes that store it's data. That is, caches are cleared on remote
- * nodes and local node, as opposed to {@link IgniteInternalCache#clearLocally()} method which only
+ * nodes and local node, as opposed to {@link IgniteInternalCache#clearLocally(boolean, boolean, boolean)} method which only
* clears local node's cache.
* <p>
* Ignite will make the best attempt to clear caches on all nodes. If some caches
@@ -1015,7 +1022,7 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
* @param keys Keys to clear.
* @return Clear future.
*/
- public IgniteInternalFuture<?> clearAsync(Set<? extends K> keys);
+ public IgniteInternalFuture<?> clearAllAsync(Set<? extends K> keys);
/**
* Removes given key mapping from cache. If cache previously contained value for the given key,
@@ -1802,4 +1809,4 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
* @return Future to be completed whenever loading completes.
*/
public IgniteInternalFuture<?> localLoadCacheAsync(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args);
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a228c246/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
index 3ce9ee9..333bce2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
@@ -972,8 +972,8 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
}
/** {@inheritDoc} */
- @Override public List<GridCacheClearAllRunnable<K, V>> splitClearLocally() {
- return ctx.affinityNode() ? super.splitClearLocally() :
+ @Override public List<GridCacheClearAllRunnable<K, V>> splitClearLocally(boolean srv, boolean near, boolean readers) {
+ return ctx.affinityNode() ? super.splitClearLocally(srv, near, readers) :
Collections.<GridCacheClearAllRunnable<K, V>>emptyList();
}
@@ -1184,4 +1184,4 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
return topVer;
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a228c246/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
index 01c3e2b..fe519a7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
@@ -99,7 +99,7 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda
/** {@inheritDoc} */
@Override public GridCacheMapEntry create(
GridCacheContext ctx,
- AffinityTopologyVersion topVer,
+ AffinityTopologyVersion topVer,
KeyCacheObject key,
int hash,
CacheObject val,
@@ -450,16 +450,15 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda
}
/** {@inheritDoc} */
- @Override public boolean clearLocally0(K key, @Nullable CacheEntryPredicate[] filter) {
- return super.clearLocally0(key, filter) | dht().clearLocally0(key, filter);
+ @Override public boolean clearLocally(K key) {
+ return super.clearLocally(key) | dht().clearLocally(key);
}
/** {@inheritDoc} */
- @Override public void clearLocally0(Collection<? extends K> keys,
- @Nullable CacheEntryPredicate[] filter) {
- super.clearLocally0(keys, filter);
+ @Override public void clearLocallyAll(Set<? extends K> keys, boolean srv, boolean near, boolean readers) {
+ super.clearLocallyAll(keys, srv, near, readers);
- dht().clearLocally0(keys, filter);
+ dht().clearLocallyAll(keys, srv, near, readers);
}
/** {@inheritDoc} */
@@ -532,13 +531,13 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda
}
/** {@inheritDoc} */
- @Override public List<GridCacheClearAllRunnable<K, V>> splitClearLocally() {
+ @Override public List<GridCacheClearAllRunnable<K, V>> splitClearLocally(boolean srv, boolean near, boolean readers) {
assert configuration().getNearConfiguration() != null;
if (ctx.affinityNode()) {
GridCacheVersion obsoleteVer = ctx.versions().next();
- List<GridCacheClearAllRunnable<K, V>> dhtJobs = dht().splitClearLocally();
+ List<GridCacheClearAllRunnable<K, V>> dhtJobs = dht().splitClearLocally(srv, near, readers);
List<GridCacheClearAllRunnable<K, V>> res = new ArrayList<>(dhtJobs.size());
@@ -548,7 +547,7 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda
return res;
}
else
- return super.splitClearLocally();
+ return super.splitClearLocally(srv, near, readers);
}
/**
@@ -662,4 +661,4 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda
@Override public String toString() {
return S.toString(GridNearCacheAdapter.class, this);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a228c246/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheClearAllRunnable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheClearAllRunnable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheClearAllRunnable.java
index 675ea8d..eea0b6e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheClearAllRunnable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheClearAllRunnable.java
@@ -19,11 +19,12 @@ package org.apache.ignite.internal.processors.cache.distributed.near;
import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
import org.apache.ignite.internal.processors.cache.GridCacheClearAllRunnable;
+import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.typedef.internal.S;
/**
- * Runnable for {@link GridCacheAdapter#clearLocally()} routine for near cache.
+ * Runnable for {@link IgniteInternalCache#clearLocally(boolean, boolean, boolean)} routine for near cache.
*/
public class GridNearCacheClearAllRunnable<K, V> extends GridCacheClearAllRunnable<K, V> {
/** Runnable for DHT cache. */
@@ -38,9 +39,7 @@ public class GridNearCacheClearAllRunnable<K, V> extends GridCacheClearAllRunnab
*/
public GridNearCacheClearAllRunnable(GridCacheAdapter<K, V> cache, GridCacheVersion obsoleteVer,
GridCacheClearAllRunnable<K, V> dhtJob) {
- super(cache, obsoleteVer, dhtJob.id(), dhtJob.totalCount());
-
- assert dhtJob != null;
+ super(cache, obsoleteVer, dhtJob.id(), dhtJob.totalCount(), dhtJob.readers());
this.dhtJob = dhtJob;
}
@@ -61,4 +60,4 @@ public class GridNearCacheClearAllRunnable<K, V> extends GridCacheClearAllRunnab
@Override public String toString() {
return S.toString(GridNearCacheClearAllRunnable.class, this);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a228c246/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearSelfTest.java
new file mode 100644
index 0000000..5e14f14
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearSelfTest.java
@@ -0,0 +1,308 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.cache;
+
+import java.util.Collections;
+import java.util.Set;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheMemoryMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.util.typedef.F;
+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.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Tests for cache clear.
+ */
+public class GridCacheClearSelfTest extends GridCommonAbstractTest {
+ /** */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+ disco.setIpFinder(IP_FINDER);
+
+ cfg.setDiscoverySpi(disco);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ startGridsMultiThreaded(3);
+
+ Ignition.setClientMode(true);
+
+ startGrid("client1");
+ startGrid("client2");
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClearPartitioned() throws Exception {
+ testClear(CacheMode.PARTITIONED, CacheMemoryMode.ONHEAP_TIERED, false, null);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClearPartitionedOffHeap() throws Exception {
+ testClear(CacheMode.PARTITIONED, CacheMemoryMode.OFFHEAP_TIERED, false, null);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClearPartitionedNear() throws Exception {
+ testClear(CacheMode.PARTITIONED, CacheMemoryMode.ONHEAP_TIERED, true, null);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClearPartitionedOffHeapNear() throws Exception {
+ testClear(CacheMode.PARTITIONED, CacheMemoryMode.OFFHEAP_TIERED, true, null);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClearReplicated() throws Exception {
+ testClear(CacheMode.REPLICATED, CacheMemoryMode.ONHEAP_TIERED, false, null);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClearReplicatedOffHeap() throws Exception {
+ testClear(CacheMode.REPLICATED, CacheMemoryMode.OFFHEAP_TIERED, false, null);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClearReplicatedNear() throws Exception {
+ testClear(CacheMode.REPLICATED, CacheMemoryMode.ONHEAP_TIERED, true, null);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClearReplicatedOffHeapNear() throws Exception {
+ testClear(CacheMode.REPLICATED, CacheMemoryMode.OFFHEAP_TIERED, true, null);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClearKeyPartitioned() throws Exception {
+ testClear(CacheMode.PARTITIONED, CacheMemoryMode.ONHEAP_TIERED, false, Collections.singleton(3));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClearKeyPartitionedOffHeap() throws Exception {
+ testClear(CacheMode.PARTITIONED, CacheMemoryMode.OFFHEAP_TIERED, false, Collections.singleton(3));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClearKeyPartitionedNear() throws Exception {
+ testClear(CacheMode.PARTITIONED, CacheMemoryMode.ONHEAP_TIERED, true, Collections.singleton(3));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClearKeyPartitionedOffHeapNear() throws Exception {
+ testClear(CacheMode.PARTITIONED, CacheMemoryMode.OFFHEAP_TIERED, true, Collections.singleton(3));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClearKeyReplicated() throws Exception {
+ testClear(CacheMode.REPLICATED, CacheMemoryMode.ONHEAP_TIERED, false, Collections.singleton(3));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClearKeyReplicatedOffHeap() throws Exception {
+ testClear(CacheMode.REPLICATED, CacheMemoryMode.OFFHEAP_TIERED, false, Collections.singleton(3));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClearKeyReplicatedNear() throws Exception {
+ testClear(CacheMode.REPLICATED, CacheMemoryMode.ONHEAP_TIERED, true, Collections.singleton(3));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClearKeyReplicatedOffHeapNear() throws Exception {
+ testClear(CacheMode.REPLICATED, CacheMemoryMode.OFFHEAP_TIERED, true, Collections.singleton(3));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClearKeysPartitioned() throws Exception {
+ testClear(CacheMode.PARTITIONED, CacheMemoryMode.ONHEAP_TIERED, false, F.asSet(2, 6, 9));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClearKeysPartitionedOffHeap() throws Exception {
+ testClear(CacheMode.PARTITIONED, CacheMemoryMode.OFFHEAP_TIERED, false, F.asSet(2, 6, 9));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClearKeysPartitionedNear() throws Exception {
+ testClear(CacheMode.PARTITIONED, CacheMemoryMode.ONHEAP_TIERED, true, F.asSet(2, 6, 9));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClearKeysPartitionedOffHeapNear() throws Exception {
+ testClear(CacheMode.PARTITIONED, CacheMemoryMode.OFFHEAP_TIERED, true, F.asSet(2, 6, 9));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClearKeysReplicated() throws Exception {
+ testClear(CacheMode.REPLICATED, CacheMemoryMode.ONHEAP_TIERED, false, F.asSet(2, 6, 9));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClearKeysReplicatedOffHeap() throws Exception {
+ testClear(CacheMode.REPLICATED, CacheMemoryMode.OFFHEAP_TIERED, false, F.asSet(2, 6, 9));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClearKeysReplicatedNear() throws Exception {
+ testClear(CacheMode.REPLICATED, CacheMemoryMode.ONHEAP_TIERED, true, F.asSet(2, 6, 9));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClearKeysReplicatedOffHeapNear() throws Exception {
+ testClear(CacheMode.REPLICATED, CacheMemoryMode.OFFHEAP_TIERED, true, F.asSet(2, 6, 9));
+ }
+
+ /**
+ * @param cacheMode Cache mode.
+ * @param memMode Memory mode.
+ * @param near Near cache flag.
+ * @param keys Keys to clear.
+ */
+ private void testClear(CacheMode cacheMode, CacheMemoryMode memMode, boolean near, @Nullable Set<Integer> keys) {
+ Ignite client1 = client1();
+ Ignite client2 = client2();
+
+ try {
+ CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>("cache");
+
+ cfg.setCacheMode(cacheMode);
+ cfg.setMemoryMode(memMode);
+
+ IgniteCache<Integer, Integer> cache1 = near ?
+ client1.createCache(cfg, new NearCacheConfiguration<Integer, Integer>()) :
+ client1.createCache(cfg);
+
+ IgniteCache<Integer, Integer> cache2 = near ?
+ client2.createNearCache("cache", new NearCacheConfiguration<Integer, Integer>()) :
+ client2.<Integer, Integer>cache("cache");
+
+ for (int i = 0; i < 10; i++)
+ cache1.put(i, i);
+
+ for (int i = 0; i < 10; i++)
+ cache2.get(i);
+
+ assertEquals(10, cache1.size(CachePeekMode.PRIMARY));
+ assertEquals(10, cache2.size(CachePeekMode.PRIMARY));
+ assertEquals(near ? 10 : 0, cache1.localSize(CachePeekMode.NEAR));
+ assertEquals(near ? 10 : 0, cache2.localSize(CachePeekMode.NEAR));
+
+ if (F.isEmpty(keys))
+ cache1.clear();
+ else if (keys.size() == 1)
+ cache1.clear(F.first(keys));
+ else
+ cache1.clearAll(keys);
+
+ int expSize = F.isEmpty(keys) ? 0 : 10 - keys.size();
+
+ assertEquals(expSize, cache1.size(CachePeekMode.PRIMARY));
+ assertEquals(expSize, cache2.size(CachePeekMode.PRIMARY));
+ assertEquals(near ? expSize : 0, cache1.localSize(CachePeekMode.NEAR));
+ assertEquals(near ? expSize : 0, cache2.localSize(CachePeekMode.NEAR));
+ }
+ finally {
+ client1.destroyCache("cache");
+ }
+ }
+
+ /**
+ * @return Client 1.
+ */
+ private Ignite client1() {
+ return grid("client1");
+ }
+
+ /**
+ * @return Client 2.
+ */
+ private Ignite client2() {
+ return grid("client2");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a228c246/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java
index 26548b9..62fee5e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java
@@ -314,4 +314,4 @@ public class GridCacheDhtEntrySelfTest extends GridCommonAbstractTest {
return F.t(primary, other);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a228c246/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java
index ff53250..c2f27fe 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java
@@ -18,6 +18,7 @@
package org.apache.ignite.testsuites;
import junit.framework.TestSuite;
+import org.apache.ignite.internal.processors.cache.GridCacheClearSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheAtomicFullApiSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheAtomicNearEnabledFullApiSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheAtomicNearEnabledPrimaryWriteOrderFullApiSelfTest;
@@ -204,11 +205,14 @@ public class IgniteCacheFullApiSelfTestSuite extends TestSuite {
suite.addTestSuite(GridCachePartitionedNearDisabledOffHeapTieredMultiNodeFullApiSelfTest.class);
suite.addTestSuite(GridCachePartitionedNearDisabledAtomicOffHeapTieredMultiNodeFullApiSelfTest.class);
- // Multithreaded
+ // Multithreaded.
suite.addTestSuite(GridCacheLocalFullApiMultithreadedSelfTest.class);
suite.addTestSuite(GridCacheReplicatedFullApiMultithreadedSelfTest.class);
suite.addTestSuite(GridCachePartitionedFullApiMultithreadedSelfTest.class);
+ // Other.
+ suite.addTestSuite(GridCacheClearSelfTest.class);
+
return suite;
}
-}
\ No newline at end of file
+}
[05/50] [abbrv] ignite git commit: IGNITE-1664 .Net: Reviewed and
fixed generic type arguments in the API.
Posted by vo...@apache.org.
IGNITE-1664 .Net: Reviewed and fixed generic type arguments in the API.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/81feb959
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/81feb959
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/81feb959
Branch: refs/heads/ignite-1651
Commit: 81feb9596657c432efe404e6046a142b8f831df3
Parents: 52534c3
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Wed Oct 14 14:56:17 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Oct 14 14:56:17 2015 +0300
----------------------------------------------------------------------
.../Cache/CacheTestAsyncWrapper.cs | 10 +--
.../dotnet/Apache.Ignite.Core/Cache/ICache.cs | 14 ++--
.../Cache/ICacheEntryProcessor.cs | 8 +-
.../Compute/ComputeTaskAdapter.cs | 16 ++--
.../Compute/ComputeTaskSplitAdapter.cs | 8 +-
.../Apache.Ignite.Core/Compute/ICompute.cs | 82 ++++++++++----------
.../Apache.Ignite.Core/Compute/IComputeFunc.cs | 8 +-
.../Apache.Ignite.Core/Compute/IComputeJob.cs | 4 +-
.../Compute/IComputeJobResult.cs | 6 +-
.../Compute/IComputeReducer.cs | 8 +-
.../Apache.Ignite.Core/Compute/IComputeTask.cs | 24 +++---
.../Datastream/StreamTransformer.cs | 12 +--
.../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 18 ++---
.../Impl/Cache/CacheProxyImpl.cs | 6 +-
.../Apache.Ignite.Core/Impl/Compute/Compute.cs | 40 +++++-----
.../Impl/Compute/ComputeAsync.cs | 61 ++++++++-------
.../Impl/Compute/ComputeImpl.cs | 79 ++++++++++---------
17 files changed, 209 insertions(+), 195 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/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 52a856a..c4e8d7e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
@@ -340,20 +340,20 @@ namespace Apache.Ignite.Core.Tests.Cache
}
/** <inheritDoc /> */
- public TR Invoke<TR, TA>(TK key, ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg)
+ public TRes Invoke<TArg, TRes>(TK key, ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg)
{
_cache.Invoke(key, processor, arg);
- return GetResult<TR>();
+ return GetResult<TRes>();
}
/** <inheritDoc /> */
- public IDictionary<TK, ICacheEntryProcessorResult<TR>> InvokeAll<TR, TA>(IEnumerable<TK> keys,
- ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg)
+ public IDictionary<TK, ICacheEntryProcessorResult<TRes>> InvokeAll<TArg, TRes>(IEnumerable<TK> keys,
+ ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg)
{
_cache.InvokeAll(keys, processor, arg);
- return GetResult<IDictionary<TK, ICacheEntryProcessorResult<TR>>>();
+ return GetResult<IDictionary<TK, ICacheEntryProcessorResult<TRes>>>();
}
/** <inheritDoc /> */
http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/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 097ab66..98ac254 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
@@ -451,15 +451,15 @@ namespace Apache.Ignite.Core.Cache
/// If an entry does not exist for the specified key, an attempt is made to load it (if a loader is configured)
/// or a surrogate entry, consisting of the key with a null value is used instead.
/// </summary>
- /// <typeparam name="TR">The type of the result.</typeparam>
- /// <typeparam name="TA">The type of the argument.</typeparam>
+ /// <typeparam name="TArg">The type of the argument.</typeparam>
+ /// <typeparam name="TRes">The type of the result.</typeparam>
/// <param name="key">The key.</param>
/// <param name="processor">The processor.</param>
/// <param name="arg">The argument.</param>
/// <returns>Result of the processing.</returns>
/// <exception cref="CacheEntryProcessorException">If an exception has occured during processing.</exception>
[AsyncSupported]
- TR Invoke<TR, TA>(TK key, ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg);
+ TRes Invoke<TArg, TRes>(TK key, ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg);
/// <summary>
/// Invokes an <see cref="ICacheEntryProcessor{K, V, A, R}"/> against a set of keys.
@@ -471,8 +471,8 @@ namespace Apache.Ignite.Core.Cache
/// Furthermore there is no guarantee implementations will use the same processor instance
/// to process each entry, as the case may be in a non-local cache topology.
/// </summary>
- /// <typeparam name="TR">The type of the result.</typeparam>
- /// <typeparam name="TA">The type of the argument.</typeparam>
+ /// <typeparam name="TArg">The type of the argument.</typeparam>
+ /// <typeparam name="TRes">The type of the result.</typeparam>
/// <param name="keys">The keys.</param>
/// <param name="processor">The processor.</param>
/// <param name="arg">The argument.</param>
@@ -483,8 +483,8 @@ namespace Apache.Ignite.Core.Cache
/// </returns>
/// <exception cref="CacheEntryProcessorException">If an exception has occured during processing.</exception>
[AsyncSupported]
- IDictionary<TK, ICacheEntryProcessorResult<TR>> InvokeAll<TR, TA>(IEnumerable<TK> keys,
- ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg);
+ IDictionary<TK, ICacheEntryProcessorResult<TRes>> InvokeAll<TArg, TRes>(IEnumerable<TK> keys,
+ ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg);
/// <summary>
/// Creates an <see cref="ICacheLock"/> instance associated with passed key.
http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessor.cs
index c8614c0..7a0fff1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessor.cs
@@ -30,9 +30,9 @@ namespace Apache.Ignite.Core.Cache
/// </summary>
/// <typeparam name="TK">Key type.</typeparam>
/// <typeparam name="TV">Value type.</typeparam>
- /// <typeparam name="TA">The type of the processor argument.</typeparam>
- /// <typeparam name="TR">The type of the processor result.</typeparam>
- public interface ICacheEntryProcessor<in TK, TV, in TA, out TR>
+ /// <typeparam name="TArg">The type of the processor argument.</typeparam>
+ /// <typeparam name="TRes">The type of the processor result.</typeparam>
+ public interface ICacheEntryProcessor<in TK, TV, in TArg, out TRes>
{
/// <summary>
/// Process an entry.
@@ -40,6 +40,6 @@ namespace Apache.Ignite.Core.Cache
/// <param name="entry">The entry to process.</param>
/// <param name="arg">The argument.</param>
/// <returns>Processing result.</returns>
- TR Process(IMutableCacheEntry<TK, TV> entry, TA arg);
+ TRes Process(IMutableCacheEntry<TK, TV> entry, TArg arg);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs
index 67f7432..5965d2b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs
@@ -23,9 +23,9 @@ namespace Apache.Ignite.Core.Compute
using Apache.Ignite.Core.Common;
/// <summary>
- /// Convenience adapter for <see cref="IComputeTask{A,T,R}"/> interface
+ /// Convenience adapter for <see cref="IComputeTask{TArg,TJobRes,TTaskRes}"/> interface
/// </summary>
- public abstract class ComputeTaskAdapter<TA, T, TR> : IComputeTask<TA, T, TR>
+ public abstract class ComputeTaskAdapter<TArg, TJobRes, TTaskRes> : IComputeTask<TArg, TJobRes, TTaskRes>
{
/// <summary>
/// Default implementation which will wait for all jobs to complete before
@@ -42,7 +42,8 @@ namespace Apache.Ignite.Core.Compute
/// <param name="res">Received remote Ignite executable result.</param>
/// <param name="rcvd">All previously received results.</param>
/// <returns>Result policy that dictates how to process further upcoming job results.</returns>
- public virtual ComputeJobResultPolicy Result(IComputeJobResult<T> res, IList<IComputeJobResult<T>> rcvd)
+ public virtual ComputeJobResultPolicy Result(IComputeJobResult<TJobRes> res,
+ IList<IComputeJobResult<TJobRes>> rcvd)
{
Exception err = res.Exception();
@@ -52,8 +53,9 @@ namespace Apache.Ignite.Core.Compute
err is ComputeJobFailoverException)
return ComputeJobResultPolicy.Failover;
- throw new IgniteException("Remote job threw user exception (override or implement IComputeTask.result(..) " +
- "method if you would like to have automatic failover for this exception).", err);
+ throw new IgniteException("Remote job threw user exception (override or implement " +
+ "IComputeTask.result(..) method if you would like to have automatic failover for this exception).",
+ err);
}
return ComputeJobResultPolicy.Wait;
@@ -73,7 +75,7 @@ namespace Apache.Ignite.Core.Compute
/// Map of Ignite jobs assigned to subgrid node. If <c>null</c> or empty map is returned,
/// exception will be thrown.
/// </returns>
- public abstract IDictionary<IComputeJob<T>, IClusterNode> Map(IList<IClusterNode> subgrid, TA arg);
+ public abstract IDictionary<IComputeJob<TJobRes>, IClusterNode> Map(IList<IClusterNode> subgrid, TArg arg);
/// <summary>
/// Reduces (or aggregates) results received so far into one compound result to be returned to
@@ -88,6 +90,6 @@ namespace Apache.Ignite.Core.Compute
/// <returns>
/// Task result constructed from results of remote executions.
/// </returns>
- public abstract TR Reduce(IList<IComputeJobResult<T>> results);
+ public abstract TTaskRes Reduce(IList<IComputeJobResult<TJobRes>> results);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskSplitAdapter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskSplitAdapter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskSplitAdapter.cs
index bf4685a..14651b1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskSplitAdapter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskSplitAdapter.cs
@@ -30,7 +30,7 @@ namespace Apache.Ignite.Core.Compute
/// in most homogeneous environments where all nodes are equally suitable for executing grid
/// job, see <see cref="Split"/> method for more details.
/// </summary>
- public abstract class ComputeTaskSplitAdapter<TA, T, TR> : ComputeTaskAdapter<TA, T, TR>
+ public abstract class ComputeTaskSplitAdapter<TArg, TJobRes, TTaskRes> : ComputeTaskAdapter<TArg, TJobRes, TTaskRes>
{
/** Random generator */
[ThreadStatic]
@@ -49,7 +49,7 @@ namespace Apache.Ignite.Core.Compute
/// <param name="gridSize">Number of available Ignite nodes. Note that returned number of jobs can be less,
/// equal or greater than this grid size.</param>
/// <param name="arg">Task execution argument. Can be <c>null</c>.</param>
- protected abstract ICollection<IComputeJob<T>> Split(int gridSize, TA arg);
+ protected abstract ICollection<IComputeJob<TJobRes>> Split(int gridSize, TArg arg);
/// <summary>
/// This method is called to map or split Ignite task into multiple Ignite jobs. This is the
@@ -66,7 +66,7 @@ namespace Apache.Ignite.Core.Compute
/// exception will be thrown.
/// </returns>
/// <exception cref="IgniteException">Split returned no jobs.</exception>
- override public IDictionary<IComputeJob<T>, IClusterNode> Map(IList<IClusterNode> subgrid, TA arg)
+ override public IDictionary<IComputeJob<TJobRes>, IClusterNode> Map(IList<IClusterNode> subgrid, TArg arg)
{
Debug.Assert(subgrid != null && subgrid.Count > 0);
@@ -75,7 +75,7 @@ namespace Apache.Ignite.Core.Compute
if (jobs == null || jobs.Count == 0)
throw new IgniteException("Split returned no jobs.");
- var map = new Dictionary<IComputeJob<T>, IClusterNode>(jobs.Count);
+ var map = new Dictionary<IComputeJob<TJobRes>, IClusterNode>(jobs.Count);
if (_rnd == null)
_rnd = new Random();
http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ICompute.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ICompute.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ICompute.cs
index c124f84..28471aa 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ICompute.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ICompute.cs
@@ -84,8 +84,8 @@ namespace Apache.Ignite.Core.Compute
/// <param name="taskName">Java task name</param>
/// <param name="taskArg">Optional argument of task execution, can be null.</param>
/// <returns>Task result.</returns>
- /// <typeparam name="T">Type of task result.</typeparam>
- T ExecuteJavaTask<T>(string taskName, object taskArg);
+ /// <typeparam name="TRes">Type of task result.</typeparam>
+ TRes ExecuteJavaTask<TRes>(string taskName, object taskArg);
/// <summary>
/// Executes given task on the grid projection. For step-by-step explanation of task execution process
@@ -94,11 +94,11 @@ namespace Apache.Ignite.Core.Compute
/// <param name="task">Task to execute.</param>
/// <param name="taskArg">Optional task argument.</param>
/// <returns>Task result.</returns>
- /// <typeparam name="TA">Argument type.</typeparam>
- /// <typeparam name="T">Type of job result.</typeparam>
- /// <typeparam name="TR">Type of reduce result.</typeparam>
+ /// <typeparam name="TArg">Argument type.</typeparam>
+ /// <typeparam name="TJobRes">Type of job result.</typeparam>
+ /// <typeparam name="TRes">Type of final task result.</typeparam>
[AsyncSupported]
- TR Execute<TA, T, TR>(IComputeTask<TA, T, TR> task, TA taskArg);
+ TRes Execute<TArg, TJobRes, TRes>(IComputeTask<TArg, TJobRes, TRes> task, TArg taskArg);
/// <summary>
/// Executes given task on the grid projection. For step-by-step explanation of task execution process
@@ -106,10 +106,10 @@ namespace Apache.Ignite.Core.Compute
/// </summary>
/// <param name="task">Task to execute.</param>
/// <returns>Task result.</returns>
- /// <typeparam name="T">Type of job result.</typeparam>
- /// <typeparam name="TR">Type of reduce result.</typeparam>
+ /// <typeparam name="TJobRes">Type of job result.</typeparam>
+ /// <typeparam name="TRes">Type of reduce result.</typeparam>
[AsyncSupported]
- TR Execute<T, TR>(IComputeTask<T, TR> task);
+ TRes Execute<TJobRes, TRes>(IComputeTask<TJobRes, TRes> task);
/// <summary>
/// Executes given task on the grid projection. For step-by-step explanation of task execution process
@@ -118,11 +118,11 @@ namespace Apache.Ignite.Core.Compute
/// <param name="taskType">Task type.</param>
/// <param name="taskArg">Optional task argument.</param>
/// <returns>Task result.</returns>
- /// <typeparam name="TA">Argument type.</typeparam>
- /// <typeparam name="T">Type of job result.</typeparam>
- /// <typeparam name="TR">Type of reduce result.</typeparam>
+ /// <typeparam name="TArg">Argument type.</typeparam>
+ /// <typeparam name="TJobRes">Type of job result.</typeparam>
+ /// <typeparam name="TRes">Type of reduce result.</typeparam>
[AsyncSupported]
- TR Execute<TA, T, TR>(Type taskType, TA taskArg);
+ TRes Execute<TArg, TJobRes, TRes>(Type taskType, TArg taskArg);
/// <summary>
/// Executes given task on the grid projection. For step-by-step explanation of task execution process
@@ -130,10 +130,10 @@ namespace Apache.Ignite.Core.Compute
/// </summary>
/// <param name="taskType">Task type.</param>
/// <returns>Task result.</returns>
- /// <typeparam name="T">Type of job result.</typeparam>
- /// <typeparam name="TR">Type of reduce result.</typeparam>
+ /// <typeparam name="TJobRes">Type of job result.</typeparam>
+ /// <typeparam name="TRes">Type of reduce result.</typeparam>
[AsyncSupported]
- TR Execute<T, TR>(Type taskType);
+ TRes Execute<TJobRes, TRes>(Type taskType);
/// <summary>
/// Executes provided job on a node in this grid projection. The result of the
@@ -141,9 +141,9 @@ namespace Apache.Ignite.Core.Compute
/// </summary>
/// <param name="clo">Job to execute.</param>
/// <returns>Job result for this execution.</returns>
- /// <typeparam name="TR">Type of job result.</typeparam>
+ /// <typeparam name="TRes">Type of job result.</typeparam>
[AsyncSupported]
- TR Call<TR>(IComputeFunc<TR> clo);
+ TRes Call<TRes>(IComputeFunc<TRes> clo);
/// <summary>
/// Executes given job on the node where data for provided affinity key is located
@@ -153,29 +153,30 @@ namespace Apache.Ignite.Core.Compute
/// <param name="affinityKey">Affinity key.</param>
/// <param name="clo">Job to execute.</param>
/// <returns>Job result for this execution.</returns>
- /// <typeparam name="TR">Type of job result.</typeparam>
+ /// <typeparam name="TRes">Type of job result.</typeparam>
[AsyncSupported]
- TR AffinityCall<TR>(string cacheName, object affinityKey, IComputeFunc<TR> clo);
+ TRes AffinityCall<TRes>(string cacheName, object affinityKey, IComputeFunc<TRes> clo);
/// <summary>
/// Executes collection of jobs on nodes within this grid projection.
/// </summary>
/// <param name="clos">Collection of jobs to execute.</param>
- /// <param name="rdc">Reducer to reduce all job results into one individual return value.</param>
+ /// <param name="reducer">Reducer to reduce all job results into one individual return value.</param>
/// <returns>Reduced job result for this execution.</returns>
- /// <typeparam name="TR1">Type of job result.</typeparam>
- /// <typeparam name="TR2">Type of reduced result.</typeparam>
+ /// <typeparam name="TFuncRes">Type of function result.</typeparam>
+ /// <typeparam name="TRes">Type of result after reduce.</typeparam>
[AsyncSupported]
- TR2 Call<TR1, TR2>(IEnumerable<IComputeFunc<TR1>> clos, IComputeReducer<TR1, TR2> rdc);
+ TRes Call<TFuncRes, TRes>(IEnumerable<IComputeFunc<TFuncRes>> clos,
+ IComputeReducer<TFuncRes, TRes> reducer);
/// <summary>
/// Executes collection of jobs on nodes within this grid projection.
/// </summary>
/// <param name="clos">Collection of jobs to execute.</param>
/// <returns>Collection of job results for this execution.</returns>
- /// <typeparam name="TR">Type of job result.</typeparam>
+ /// <typeparam name="TRes">Type of job result.</typeparam>
[AsyncSupported]
- ICollection<TR> Call<TR>(IEnumerable<IComputeFunc<TR>> clos);
+ ICollection<TRes> Call<TRes>(IEnumerable<IComputeFunc<TRes>> clos);
/// <summary>
/// Broadcasts given job to all nodes in grid projection. Every participating node will return a job result.
@@ -183,7 +184,7 @@ namespace Apache.Ignite.Core.Compute
/// <param name="clo">Job to broadcast to all projection nodes.</param>
/// <returns>Collection of results for this execution.</returns>
[AsyncSupported]
- ICollection<TR> Broadcast<TR>(IComputeFunc<TR> clo);
+ ICollection<TRes> Broadcast<TRes>(IComputeFunc<TRes> clo);
/// <summary>
/// Broadcasts given closure job with passed in argument to all nodes in grid projection.
@@ -192,10 +193,10 @@ namespace Apache.Ignite.Core.Compute
/// <param name="clo">Job to broadcast to all projection nodes.</param>
/// <param name="arg">Job closure argument.</param>
/// <returns>Collection of results for this execution.</returns>
- /// <typeparam name="T">Type of argument.</typeparam>
- /// <typeparam name="TR">Type of job result.</typeparam>
+ /// <typeparam name="TArg">Type of argument.</typeparam>
+ /// <typeparam name="TRes">Type of job result.</typeparam>
[AsyncSupported]
- ICollection<TR> Broadcast<T, TR>(IComputeFunc<T, TR> clo, T arg);
+ ICollection<TRes> Broadcast<TArg, TRes>(IComputeFunc<TArg, TRes> clo, TArg arg);
/// <summary>
/// Broadcasts given job to all nodes in grid projection.
@@ -234,10 +235,10 @@ namespace Apache.Ignite.Core.Compute
/// <param name="clo">Job to run.</param>
/// <param name="arg">Job argument.</param>
/// <returns>Job result for this execution.</returns>
- /// <typeparam name="T">Type of argument.</typeparam>
- /// <typeparam name="TR">Type of job result.</typeparam>
+ /// <typeparam name="TArg">Type of argument.</typeparam>
+ /// <typeparam name="TRes">Type of job result.</typeparam>
[AsyncSupported]
- TR Apply<T, TR>(IComputeFunc<T, TR> clo, T arg);
+ TRes Apply<TArg, TRes>(IComputeFunc<TArg, TRes> clo, TArg arg);
/// <summary>
/// Executes provided closure job on nodes within this grid projection. A new job is executed for
@@ -247,10 +248,10 @@ namespace Apache.Ignite.Core.Compute
/// <param name="clo">Job to run.</param>
/// <param name="args">Job arguments.</param>
/// <returns>Сollection of job results.</returns>
- /// <typeparam name="T">Type of argument.</typeparam>
- /// <typeparam name="TR">Type of job result.</typeparam>
+ /// <typeparam name="TArg">Type of argument.</typeparam>
+ /// <typeparam name="TRes">Type of job result.</typeparam>
[AsyncSupported]
- ICollection<TR> Apply<T, TR>(IComputeFunc<T, TR> clo, IEnumerable<T> args);
+ ICollection<TRes> Apply<TArg, TRes>(IComputeFunc<TArg, TRes> clo, IEnumerable<TArg> args);
/// <summary>
/// Executes provided closure job on nodes within this grid projection. A new job is executed for
@@ -262,10 +263,11 @@ namespace Apache.Ignite.Core.Compute
/// <param name="args">Job arguments.</param>
/// <param name="rdc">Reducer to reduce all job results into one individual return value.</param>
/// <returns>Reduced job result for this execution.</returns>
- /// <typeparam name="T">Type of argument.</typeparam>
- /// <typeparam name="TR1">Type of job result.</typeparam>
- /// <typeparam name="TR2">Type of reduced result.</typeparam>
+ /// <typeparam name="TArg">Type of argument.</typeparam>
+ /// <typeparam name="TFuncRes">Type of function result.</typeparam>
+ /// <typeparam name="TRes">Type of result after reduce.</typeparam>
[AsyncSupported]
- TR2 Apply<T, TR1, TR2>(IComputeFunc<T, TR1> clo, IEnumerable<T> args, IComputeReducer<TR1, TR2> rdc);
+ TRes Apply<TArg, TFuncRes, TRes>(IComputeFunc<TArg, TFuncRes> clo, IEnumerable<TArg> args,
+ IComputeReducer<TFuncRes, TRes> rdc);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeFunc.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeFunc.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeFunc.cs
index 4a43f11..9c6cdf7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeFunc.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeFunc.cs
@@ -20,26 +20,26 @@ namespace Apache.Ignite.Core.Compute
/// <summary>
/// Defines function having a single argument.
/// </summary>
- public interface IComputeFunc<in T, out TR>
+ public interface IComputeFunc<in TArg, out TRes>
{
/// <summary>
/// Invoke function.
/// </summary>
/// <param name="arg">Argument.</param>
/// <returns>Result.</returns>
- TR Invoke(T arg);
+ TRes Invoke(TArg arg);
}
/// <summary>
/// Defines function having no arguments.
/// </summary>
- public interface IComputeFunc<out T>
+ public interface IComputeFunc<out TRes>
{
/// <summary>
/// Invoke function.
/// </summary>
/// <returns>Result.</returns>
- T Invoke();
+ TRes Invoke();
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJob.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJob.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJob.cs
index a755bac..684ff95 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJob.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJob.cs
@@ -35,7 +35,7 @@ namespace Apache.Ignite.Core.Compute
/// Ignite job implementation can be injected with <see cref="IIgnite"/> using
/// <see cref="InstanceResourceAttribute"/> attribute.
/// </summary>
- public interface IComputeJob<out T>
+ public interface IComputeJob<out TRes>
{
/// <summary>
/// Executes this job.
@@ -44,7 +44,7 @@ namespace Apache.Ignite.Core.Compute
/// in <see cref="IComputeJobResult{T}"/> object passed into
/// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/>
/// on caller node.</returns>
- T Execute();
+ TRes Execute();
/// <summary>
/// This method is called when system detects that completion of this
http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJobResult.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJobResult.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJobResult.cs
index 5891fd7..6369eb5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJobResult.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJobResult.cs
@@ -25,7 +25,7 @@ namespace Apache.Ignite.Core.Compute
/// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/>
/// method.
/// </summary>
- public interface IComputeJobResult<out T>
+ public interface IComputeJobResult<out TRes>
{
/// <summary>
/// Gets data returned by remote job if it didn't fail. This data is the
@@ -39,13 +39,13 @@ namespace Apache.Ignite.Core.Compute
///
/// </summary>
/// <returns>Data returned by job.</returns>
- T Data();
+ TRes Data();
/// <summary>
/// Gets local instance of remote job produced this result.
/// </summary>
/// <returns></returns>
- IComputeJob<T> Job();
+ IComputeJob<TRes> Job();
/// <summary>
/// Gets exception produced by execution of remote job, or <c>null</c> if no
http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeReducer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeReducer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeReducer.cs
index 46dcbd9..c2e6087 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeReducer.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeReducer.cs
@@ -20,7 +20,9 @@ namespace Apache.Ignite.Core.Compute
/// <summary>
/// Compute reducer which is capable of result collecting and reducing.
/// </summary>
- public interface IComputeReducer<in TR1, out TR2>
+ /// <typeparam name="TRes">Type of results passed for reducing.</typeparam>
+ /// <typeparam name="TReduceRes">Type of reduced result.</typeparam>
+ public interface IComputeReducer<in TRes, out TReduceRes>
{
/// <summary>
/// Collect closure execution result.
@@ -28,12 +30,12 @@ namespace Apache.Ignite.Core.Compute
/// <param name="res">Result.</param>
/// <returns><c>True</c> to continue collecting results until all closures are finished,
/// <c>false</c> to start reducing.</returns>
- bool Collect(TR1 res);
+ bool Collect(TRes res);
/// <summary>
/// Reduce closure execution results collected earlier.
/// </summary>
/// <returns>Reduce result.</returns>
- TR2 Reduce();
+ TReduceRes Reduce();
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs
index 21b6c48..d3d7ccf 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs
@@ -33,7 +33,7 @@ namespace Apache.Ignite.Core.Compute
/// <description>Inject annotated resources into task instance.</description>
/// </item>
/// <item>
- /// <description>Apply <see cref="IComputeTask{A,T,R}.Map(IList{IClusterNode}, TA)"/>.
+ /// <description>Apply <see cref="IComputeTask{A,T,R}.Map(IList{IClusterNode}, TArg)"/>.
/// This method is responsible for splitting business logic into multiple jobs
/// (units of execution) and mapping them to Ignite nodes.</description>
/// </item>
@@ -42,7 +42,7 @@ namespace Apache.Ignite.Core.Compute
/// </item>
/// <item>
/// <description>Once job execution results become available method
- /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/>
+ /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{TJobRes}, IList{IComputeJobResult{TJobRes}})"/>
/// will be called for ech received job result. The policy returned by this method will
/// determine the way task reacts to every job result.
/// <para />
@@ -66,19 +66,19 @@ namespace Apache.Ignite.Core.Compute
/// </item>
/// <item>
/// <description>Once all results are received or
- /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/>
+ /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{TJobRes}, IList{IComputeJobResult{TJobRes}})"/>
/// method returned <see cref="ComputeJobResultPolicy.Reduce"/> policy, method
- /// <see cref="IComputeTask{A,T,R}.Reduce(IList{IComputeJobResult{T}})"/>
+ /// <see cref="IComputeTask{A,T,R}.Reduce(IList{IComputeJobResult{TJobRes}})"/>
/// is called to aggregate received results into one final result. Once this method is finished the
/// execution of the Ignite task is complete. This result will be returned to the user through future.
/// </description>
/// </item>
/// </list>
/// </summary>
- /// <typeparam name="TA">Argument type.</typeparam>
- /// <typeparam name="T">Type of job result.</typeparam>
- /// <typeparam name="TR">Type of reduce result.</typeparam>
- public interface IComputeTask<in TA, T, out TR>
+ /// <typeparam name="TArg">Argument type.</typeparam>
+ /// <typeparam name="TJobRes">Type of job result.</typeparam>
+ /// <typeparam name="TRes">Type of final task result after reduce.</typeparam>
+ public interface IComputeTask<in TArg, TJobRes, out TRes>
{
/// <summary>
/// This method is called to map or split Ignite task into multiple Ignite jobs. This is the
@@ -92,7 +92,7 @@ namespace Apache.Ignite.Core.Compute
/// as the one passed into <c>ICompute.Execute()</c> methods.</param>
/// <returns>Map of Ignite jobs assigned to subgrid node. If <c>null</c> or empty map is returned,
/// exception will be thrown.</returns>
- IDictionary<IComputeJob<T>, IClusterNode> Map(IList<IClusterNode> subgrid, TA arg);
+ IDictionary<IComputeJob<TJobRes>, IClusterNode> Map(IList<IClusterNode> subgrid, TArg arg);
/// <summary>
/// Asynchronous callback invoked every time a result from remote execution is
@@ -105,7 +105,7 @@ namespace Apache.Ignite.Core.Compute
/// <param name="rcvd">All previously received results. Note that if task class has
/// <see cref="ComputeTaskNoResultCacheAttribute"/> attribute, then this list will be empty.</param>
/// <returns>Result policy that dictates how to process further upcoming job results.</returns>
- ComputeJobResultPolicy Result(IComputeJobResult<T> res, IList<IComputeJobResult<T>> rcvd);
+ ComputeJobResultPolicy Result(IComputeJobResult<TJobRes> res, IList<IComputeJobResult<TJobRes>> rcvd);
/// <summary>
/// Reduces (or aggregates) results received so far into one compound result to be returned to
@@ -118,14 +118,14 @@ namespace Apache.Ignite.Core.Compute
/// <param name="results">Received job results. Note that if task class has
/// <see cref="ComputeTaskNoResultCacheAttribute"/> attribute, then this list will be empty.</param>
/// <returns>Task result constructed from results of remote executions.</returns>
- TR Reduce(IList<IComputeJobResult<T>> results);
+ TRes Reduce(IList<IComputeJobResult<TJobRes>> results);
}
/// <summary>
/// IComputeTask without an argument.
/// </summary>
[SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces")]
- public interface IComputeTask<T, out TR> : IComputeTask<object, T, TR>
+ public interface IComputeTask<TJobRes, out TReduceRes> : IComputeTask<object, TJobRes, TReduceRes>
{
// No-op.
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs
index 0398342..d8b4620 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs
@@ -30,19 +30,19 @@ namespace Apache.Ignite.Core.Datastream
/// </summary>
/// <typeparam name="TK">Key type.</typeparam>
/// <typeparam name="TV">Value type.</typeparam>
- /// <typeparam name="TA">The type of the processor argument.</typeparam>
- /// <typeparam name="TR">The type of the processor result.</typeparam>
- public sealed class StreamTransformer<TK, TV, TA, TR> : IStreamReceiver<TK, TV>,
+ /// <typeparam name="TArg">The type of the processor argument.</typeparam>
+ /// <typeparam name="TRes">The type of the processor result.</typeparam>
+ public sealed class StreamTransformer<TK, TV, TArg, TRes> : IStreamReceiver<TK, TV>,
IPortableWriteAware
{
/** Entry processor. */
- private readonly ICacheEntryProcessor<TK, TV, TA, TR> _proc;
+ private readonly ICacheEntryProcessor<TK, TV, TArg, TRes> _proc;
/// <summary>
/// Initializes a new instance of the <see cref="StreamTransformer{K, V, A, R}"/> class.
/// </summary>
/// <param name="proc">Entry processor.</param>
- public StreamTransformer(ICacheEntryProcessor<TK, TV, TA, TR> proc)
+ public StreamTransformer(ICacheEntryProcessor<TK, TV, TArg, TRes> proc)
{
IgniteArgumentCheck.NotNull(proc, "proc");
@@ -57,7 +57,7 @@ namespace Apache.Ignite.Core.Datastream
foreach (var entry in entries)
keys.Add(entry.Key);
- cache.InvokeAll(keys, _proc, default(TA));
+ cache.InvokeAll(keys, _proc, default(TArg));
}
/** <inheritdoc /> */
http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/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 27c53ad..dcecc52 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
@@ -520,33 +520,33 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritdoc /> */
- public TR Invoke<TR, TA>(TK key, ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg)
+ public TRes Invoke<TArg, TRes>(TK key, ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg)
{
IgniteArgumentCheck.NotNull(key, "key");
IgniteArgumentCheck.NotNull(processor, "processor");
var holder = new CacheEntryProcessorHolder(processor, arg,
- (e, a) => processor.Process((IMutableCacheEntry<TK, TV>)e, (TA)a), typeof(TK), typeof(TV));
+ (e, a) => processor.Process((IMutableCacheEntry<TK, TV>)e, (TArg)a), typeof(TK), typeof(TV));
return DoOutInOp((int)CacheOp.Invoke, writer =>
{
writer.Write(key);
writer.Write(holder);
},
- input => GetResultOrThrow<TR>(Unmarshal<object>(input)));
+ input => GetResultOrThrow<TRes>(Unmarshal<object>(input)));
}
/** <inheritdoc /> */
- public IDictionary<TK, ICacheEntryProcessorResult<TR>> InvokeAll<TR, TA>(IEnumerable<TK> keys,
- ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg)
+ public IDictionary<TK, ICacheEntryProcessorResult<TRes>> InvokeAll<TArg, TRes>(IEnumerable<TK> keys,
+ ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg)
{
IgniteArgumentCheck.NotNull(keys, "keys");
IgniteArgumentCheck.NotNull(processor, "processor");
var holder = new CacheEntryProcessorHolder(processor, arg,
- (e, a) => processor.Process((IMutableCacheEntry<TK, TV>)e, (TA)a), typeof(TK), typeof(TV));
+ (e, a) => processor.Process((IMutableCacheEntry<TK, TV>)e, (TArg)a), typeof(TK), typeof(TV));
return DoOutInOp((int)CacheOp.InvokeAll, writer =>
{
@@ -556,10 +556,10 @@ namespace Apache.Ignite.Core.Impl.Cache
input =>
{
if (IsAsync)
- _invokeAllConverter.Value = (Func<PortableReaderImpl, IDictionary<TK, ICacheEntryProcessorResult<TR>>>)
- (reader => ReadInvokeAllResults<TR>(reader.Stream));
+ _invokeAllConverter.Value = (Func<PortableReaderImpl, IDictionary<TK, ICacheEntryProcessorResult<TRes>>>)
+ (reader => ReadInvokeAllResults<TRes>(reader.Stream));
- return ReadInvokeAllResults<TR>(input);
+ return ReadInvokeAllResults<TRes>(input);
});
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs
index bfd7866..0f868d8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs
@@ -421,7 +421,7 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
- public TR Invoke<TR, TA>(TK key, ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg)
+ public TRes Invoke<TArg, TRes>(TK key, ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg)
{
var result = _cache.Invoke(key, processor, arg);
@@ -431,8 +431,8 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
- public IDictionary<TK, ICacheEntryProcessorResult<TR>> InvokeAll<TR, TA>(IEnumerable<TK> keys,
- ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg)
+ public IDictionary<TK, ICacheEntryProcessorResult<TRes>> InvokeAll<TArg, TRes>(IEnumerable<TK> keys,
+ ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg)
{
var result = _cache.InvokeAll(keys, processor, arg);
http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs
index 7efabd1..d7fc59f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs
@@ -98,72 +98,73 @@ namespace Apache.Ignite.Core.Impl.Compute
}
/** <inheritDoc /> */
- public T ExecuteJavaTask<T>(string taskName, object taskArg)
+ public TReduceRes ExecuteJavaTask<TReduceRes>(string taskName, object taskArg)
{
- return _compute.ExecuteJavaTask<T>(taskName, taskArg);
+ return _compute.ExecuteJavaTask<TReduceRes>(taskName, taskArg);
}
/** <inheritDoc /> */
- public TR Execute<TA, T, TR>(IComputeTask<TA, T, TR> task, TA taskArg)
+ public TReduceRes Execute<TArg, TJobRes, TReduceRes>(IComputeTask<TArg, TJobRes, TReduceRes> task, TArg taskArg)
{
return _compute.Execute(task, taskArg).Get();
}
/** <inheritDoc /> */
- public TR Execute<T, TR>(IComputeTask<T, TR> task)
+ public TJobRes Execute<TArg, TJobRes>(IComputeTask<TArg, TJobRes> task)
{
return _compute.Execute(task, null).Get();
}
/** <inheritDoc /> */
- public TR Execute<TA, T, TR>(Type taskType, TA taskArg)
+ public TReduceRes Execute<TArg, TJobRes, TReduceRes>(Type taskType, TArg taskArg)
{
- return _compute.Execute<TA, T, TR>(taskType, taskArg).Get();
+ return _compute.Execute<TArg, TJobRes, TReduceRes>(taskType, taskArg).Get();
}
- public TR Execute<T, TR>(Type taskType)
+ public TReduceRes Execute<TArg, TReduceRes>(Type taskType)
{
- return _compute.Execute<object, T, TR>(taskType, null).Get();
+ return _compute.Execute<object, TArg, TReduceRes>(taskType, null).Get();
}
/** <inheritDoc /> */
- public TR Call<TR>(IComputeFunc<TR> clo)
+ public TJobRes Call<TJobRes>(IComputeFunc<TJobRes> clo)
{
return _compute.Execute(clo).Get();
}
/** <inheritDoc /> */
- public TR AffinityCall<TR>(string cacheName, object affinityKey, IComputeFunc<TR> clo)
+ public TJobRes AffinityCall<TJobRes>(string cacheName, object affinityKey, IComputeFunc<TJobRes> clo)
{
return _compute.AffinityCall(cacheName, affinityKey, clo).Get();
}
/** <inheritDoc /> */
- public TR Call<TR>(Func<TR> func)
+ public TJobRes Call<TJobRes>(Func<TJobRes> func)
{
return _compute.Execute(func).Get();
}
/** <inheritDoc /> */
- public ICollection<TR> Call<TR>(IEnumerable<IComputeFunc<TR>> clos)
+ public ICollection<TJobRes> Call<TJobRes>(IEnumerable<IComputeFunc<TJobRes>> clos)
{
return _compute.Execute(clos).Get();
}
/** <inheritDoc /> */
- public TR2 Call<TR1, TR2>(IEnumerable<IComputeFunc<TR1>> clos, IComputeReducer<TR1, TR2> rdc)
+ public TReduceRes Call<TJobRes, TReduceRes>(IEnumerable<IComputeFunc<TJobRes>> clos,
+ IComputeReducer<TJobRes, TReduceRes> reducer)
{
- return _compute.Execute(clos, rdc).Get();
+ return _compute.Execute(clos, reducer).Get();
}
/** <inheritDoc /> */
- public ICollection<TR> Broadcast<TR>(IComputeFunc<TR> clo)
+ public ICollection<TJobRes> Broadcast<TJobRes>(IComputeFunc<TJobRes> clo)
{
return _compute.Broadcast(clo).Get();
}
/** <inheritDoc /> */
- public ICollection<TR> Broadcast<T, TR>(IComputeFunc<T, TR> clo, T arg)
+ public ICollection<TJobRes> Broadcast<T, TJobRes>(IComputeFunc<T, TJobRes> clo, T arg)
{
return _compute.Broadcast(clo, arg).Get();
}
@@ -193,19 +194,20 @@ namespace Apache.Ignite.Core.Impl.Compute
}
/** <inheritDoc /> */
- public TR Apply<T, TR>(IComputeFunc<T, TR> clo, T arg)
+ public TJobRes Apply<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo, TArg arg)
{
return _compute.Apply(clo, arg).Get();
}
/** <inheritDoc /> */
- public ICollection<TR> Apply<T, TR>(IComputeFunc<T, TR> clo, IEnumerable<T> args)
+ public ICollection<TJobRes> Apply<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo, IEnumerable<TArg> args)
{
return _compute.Apply(clo, args).Get();
}
/** <inheritDoc /> */
- public TR2 Apply<T, TR1, TR2>(IComputeFunc<T, TR1> clo, IEnumerable<T> args, IComputeReducer<TR1, TR2> rdc)
+ public TReduceRes Apply<TArg, TJobRes, TReduceRes>(IComputeFunc<TArg, TJobRes> clo,
+ IEnumerable<TArg> args, IComputeReducer<TJobRes, TReduceRes> rdc)
{
return _compute.Apply(clo, args, rdc).Get();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs
index 26c9bf4..89c5b83 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs
@@ -117,71 +117,71 @@ namespace Apache.Ignite.Core.Impl.Compute
}
/** <inheritDoc /> */
- public T ExecuteJavaTask<T>(string taskName, object taskArg)
+ public TReduceRes ExecuteJavaTask<TReduceRes>(string taskName, object taskArg)
{
- _curFut.Value = Compute.ExecuteJavaTaskAsync<T>(taskName, taskArg);
+ _curFut.Value = Compute.ExecuteJavaTaskAsync<TReduceRes>(taskName, taskArg);
- return default(T);
+ return default(TReduceRes);
}
/** <inheritDoc /> */
- public TR Execute<TA, T, TR>(IComputeTask<TA, T, TR> task, TA taskArg)
+ public TReduceRes Execute<TArg, TJobRes, TReduceRes>(IComputeTask<TArg, TJobRes, TReduceRes> task, TArg taskArg)
{
_curFut.Value = Compute.Execute(task, taskArg);
- return default(TR);
+ return default(TReduceRes);
}
/** <inheritDoc /> */
- public TR Execute<T, TR>(IComputeTask<T, TR> task)
+ public TReduceRes Execute<TJobRes, TReduceRes>(IComputeTask<TJobRes, TReduceRes> task)
{
_curFut.Value = Compute.Execute(task, null);
- return default(TR);
+ return default(TReduceRes);
}
/** <inheritDoc /> */
- public TR Execute<TA, T, TR>(Type taskType, TA taskArg)
+ public TReduceRes Execute<TArg, TJobRes, TReduceRes>(Type taskType, TArg taskArg)
{
- _curFut.Value = Compute.Execute<TA, T, TR>(taskType, taskArg);
+ _curFut.Value = Compute.Execute<TArg, TJobRes, TReduceRes>(taskType, taskArg);
- return default(TR);
+ return default(TReduceRes);
}
/** <inheritDoc /> */
- public TR Execute<T, TR>(Type taskType)
+ public TReduceRes Execute<TJobRes, TReduceRes>(Type taskType)
{
- _curFut.Value = Compute.Execute<object, T, TR>(taskType, null);
+ _curFut.Value = Compute.Execute<object, TJobRes, TReduceRes>(taskType, null);
- return default(TR);
+ return default(TReduceRes);
}
/** <inheritDoc /> */
- public TR Call<TR>(IComputeFunc<TR> clo)
+ public TJobRes Call<TJobRes>(IComputeFunc<TJobRes> clo)
{
_curFut.Value = Compute.Execute(clo);
- return default(TR);
+ return default(TJobRes);
}
/** <inheritDoc /> */
- public TR AffinityCall<TR>(string cacheName, object affinityKey, IComputeFunc<TR> clo)
+ public TJobRes AffinityCall<TJobRes>(string cacheName, object affinityKey, IComputeFunc<TJobRes> clo)
{
Compute.AffinityCall(cacheName, affinityKey, clo);
- return default(TR);
+ return default(TJobRes);
}
/** <inheritDoc /> */
- public TR Call<TR>(Func<TR> func)
+ public TJobRes Call<TJobRes>(Func<TJobRes> func)
{
_curFut.Value = Compute.Execute(func);
- return default(TR);
+ return default(TJobRes);
}
/** <inheritDoc /> */
- public ICollection<TR> Call<TR>(IEnumerable<IComputeFunc<TR>> clos)
+ public ICollection<TJobRes> Call<TJobRes>(IEnumerable<IComputeFunc<TJobRes>> clos)
{
_curFut.Value = Compute.Execute(clos);
@@ -189,15 +189,15 @@ namespace Apache.Ignite.Core.Impl.Compute
}
/** <inheritDoc /> */
- public TR2 Call<TR1, TR2>(IEnumerable<IComputeFunc<TR1>> clos, IComputeReducer<TR1, TR2> rdc)
+ public TReduceRes Call<TJobRes, TReduceRes>(IEnumerable<IComputeFunc<TJobRes>> clos, IComputeReducer<TJobRes, TReduceRes> reducer)
{
- _curFut.Value = Compute.Execute(clos, rdc);
+ _curFut.Value = Compute.Execute(clos, reducer);
- return default(TR2);
+ return default(TReduceRes);
}
/** <inheritDoc /> */
- public ICollection<TR> Broadcast<TR>(IComputeFunc<TR> clo)
+ public ICollection<TJobRes> Broadcast<TJobRes>(IComputeFunc<TJobRes> clo)
{
_curFut.Value = Compute.Broadcast(clo);
@@ -205,7 +205,7 @@ namespace Apache.Ignite.Core.Impl.Compute
}
/** <inheritDoc /> */
- public ICollection<TR> Broadcast<T, TR>(IComputeFunc<T, TR> clo, T arg)
+ public ICollection<TJobRes> Broadcast<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo, TArg arg)
{
_curFut.Value = Compute.Broadcast(clo, arg);
@@ -237,15 +237,15 @@ namespace Apache.Ignite.Core.Impl.Compute
}
/** <inheritDoc /> */
- public TR Apply<T, TR>(IComputeFunc<T, TR> clo, T arg)
+ public TJobRes Apply<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo, TArg arg)
{
_curFut.Value = Compute.Apply(clo, arg);
- return default(TR);
+ return default(TJobRes);
}
/** <inheritDoc /> */
- public ICollection<TR> Apply<T, TR>(IComputeFunc<T, TR> clo, IEnumerable<T> args)
+ public ICollection<TJobRes> Apply<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo, IEnumerable<TArg> args)
{
_curFut.Value = Compute.Apply(clo, args);
@@ -253,11 +253,12 @@ namespace Apache.Ignite.Core.Impl.Compute
}
/** <inheritDoc /> */
- public TR2 Apply<T, TR1, TR2>(IComputeFunc<T, TR1> clo, IEnumerable<T> args, IComputeReducer<TR1, TR2> rdc)
+ public TReduceRes Apply<TArg, TJobRes, TReduceRes>(IComputeFunc<TArg, TJobRes> clo,
+ IEnumerable<TArg> args, IComputeReducer<TJobRes, TReduceRes> rdc)
{
_curFut.Value = Compute.Apply(clo, args, rdc);
- return default(TR2);
+ return default(TReduceRes);
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs
index f0ff968..abd54da 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs
@@ -124,7 +124,7 @@ namespace Apache.Ignite.Core.Impl.Compute
/// Executes given Java task on the grid projection. If task for given name has not been deployed yet,
/// then 'taskName' will be used as task class name to auto-deploy the task.
/// </summary>
- public T ExecuteJavaTask<T>(string taskName, object taskArg)
+ public TReduceRes ExecuteJavaTask<TReduceRes>(string taskName, object taskArg)
{
IgniteArgumentCheck.NotNullOrEmpty(taskName, "taskName");
@@ -132,7 +132,7 @@ namespace Apache.Ignite.Core.Impl.Compute
try
{
- T res = DoOutInOp<T>(OpExec, writer =>
+ TReduceRes res = DoOutInOp<TReduceRes>(OpExec, writer =>
{
WriteTask(writer, taskName, taskArg, nodes);
});
@@ -150,7 +150,7 @@ namespace Apache.Ignite.Core.Impl.Compute
/// If task for given name has not been deployed yet,
/// then 'taskName' will be used as task class name to auto-deploy the task.
/// </summary>
- public IFuture<T> ExecuteJavaTaskAsync<T>(string taskName, object taskArg)
+ public IFuture<TReduceRes> ExecuteJavaTaskAsync<TReduceRes>(string taskName, object taskArg)
{
IgniteArgumentCheck.NotNullOrEmpty(taskName, "taskName");
@@ -158,14 +158,14 @@ namespace Apache.Ignite.Core.Impl.Compute
try
{
- IFuture<T> fut = null;
+ IFuture<TReduceRes> fut = null;
DoOutInOp(OpExecAsync, writer =>
{
WriteTask(writer, taskName, taskArg, nodes);
}, input =>
{
- fut = GetFuture<T>((futId, futTyp) => UU.TargetListenFuture(Target, futId, futTyp), _keepPortable.Value);
+ fut = GetFuture<TReduceRes>((futId, futTyp) => UU.TargetListenFuture(Target, futId, futTyp), _keepPortable.Value);
});
return fut;
@@ -183,11 +183,12 @@ namespace Apache.Ignite.Core.Impl.Compute
/// <param name="task">Task to execute.</param>
/// <param name="taskArg">Optional task argument.</param>
/// <returns>Task result.</returns>
- public IFuture<TR> Execute<TA, T, TR>(IComputeTask<TA, T, TR> task, TA taskArg)
+ public IFuture<TReduceRes> Execute<TArg, TJobRes, TReduceRes>(IComputeTask<TArg, TJobRes, TReduceRes> task,
+ TArg taskArg)
{
IgniteArgumentCheck.NotNull(task, "task");
- var holder = new ComputeTaskHolder<TA, T, TR>((Ignite) _prj.Ignite, this, task, taskArg);
+ var holder = new ComputeTaskHolder<TArg, TJobRes, TReduceRes>((Ignite) _prj.Ignite, this, task, taskArg);
long ptr = Marshaller.Ignite.HandleRegistry.Allocate(holder);
@@ -203,13 +204,13 @@ namespace Apache.Ignite.Core.Impl.Compute
/// <param name="taskType">Task type.</param>
/// <param name="taskArg">Optional task argument.</param>
/// <returns>Task result.</returns>
- public IFuture<TR> Execute<TA, T, TR>(Type taskType, TA taskArg)
+ public IFuture<TReduceRes> Execute<TArg, TJobRes, TReduceRes>(Type taskType, TArg taskArg)
{
IgniteArgumentCheck.NotNull(taskType, "taskType");
object task = FormatterServices.GetUninitializedObject(taskType);
- var task0 = task as IComputeTask<TA, T, TR>;
+ var task0 = task as IComputeTask<TArg, TJobRes, TReduceRes>;
if (task0 == null)
throw new IgniteException("Task type doesn't implement IComputeTask: " + taskType.Name);
@@ -223,11 +224,11 @@ namespace Apache.Ignite.Core.Impl.Compute
/// </summary>
/// <param name="clo">Job to execute.</param>
/// <returns>Job result for this execution.</returns>
- public IFuture<TR> Execute<TR>(IComputeFunc<TR> clo)
+ public IFuture<TJobRes> Execute<TJobRes>(IComputeFunc<TJobRes> clo)
{
IgniteArgumentCheck.NotNull(clo, "clo");
- return ExecuteClosures0(new ComputeSingleClosureTask<object, TR, TR>(),
+ return ExecuteClosures0(new ComputeSingleClosureTask<object, TJobRes, TJobRes>(),
new ComputeOutFuncJob(clo.ToNonGeneric()), null, false);
}
@@ -237,13 +238,13 @@ namespace Apache.Ignite.Core.Impl.Compute
/// </summary>
/// <param name="func">Func to execute.</param>
/// <returns>Job result for this execution.</returns>
- public IFuture<TR> Execute<TR>(Func<TR> func)
+ public IFuture<TJobRes> Execute<TJobRes>(Func<TJobRes> func)
{
IgniteArgumentCheck.NotNull(func, "func");
var wrappedFunc = new ComputeOutFuncWrapper(func, () => func());
- return ExecuteClosures0(new ComputeSingleClosureTask<object, TR, TR>(),
+ return ExecuteClosures0(new ComputeSingleClosureTask<object, TJobRes, TJobRes>(),
new ComputeOutFuncJob(wrappedFunc), null, false);
}
@@ -252,16 +253,16 @@ namespace Apache.Ignite.Core.Impl.Compute
/// </summary>
/// <param name="clos">Collection of jobs to execute.</param>
/// <returns>Collection of job results for this execution.</returns>
- public IFuture<ICollection<TR>> Execute<TR>(IEnumerable<IComputeFunc<TR>> clos)
+ public IFuture<ICollection<TJobRes>> Execute<TJobRes>(IEnumerable<IComputeFunc<TJobRes>> clos)
{
IgniteArgumentCheck.NotNull(clos, "clos");
ICollection<IComputeJob> jobs = new List<IComputeJob>(GetCountOrZero(clos));
- foreach (IComputeFunc<TR> clo in clos)
+ foreach (IComputeFunc<TJobRes> clo in clos)
jobs.Add(new ComputeOutFuncJob(clo.ToNonGeneric()));
- return ExecuteClosures0(new ComputeMultiClosureTask<object, TR, ICollection<TR>>(jobs.Count),
+ return ExecuteClosures0(new ComputeMultiClosureTask<object, TJobRes, ICollection<TJobRes>>(jobs.Count),
null, jobs, false);
}
@@ -271,7 +272,8 @@ namespace Apache.Ignite.Core.Impl.Compute
/// <param name="clos">Collection of jobs to execute.</param>
/// <param name="rdc">Reducer to reduce all job results into one individual return value.</param>
/// <returns>Collection of job results for this execution.</returns>
- public IFuture<TR2> Execute<TR1, TR2>(IEnumerable<IComputeFunc<TR1>> clos, IComputeReducer<TR1, TR2> rdc)
+ public IFuture<TReduceRes> Execute<TJobRes, TReduceRes>(IEnumerable<IComputeFunc<TJobRes>> clos,
+ IComputeReducer<TJobRes, TReduceRes> rdc)
{
IgniteArgumentCheck.NotNull(clos, "clos");
@@ -280,7 +282,7 @@ namespace Apache.Ignite.Core.Impl.Compute
foreach (var clo in clos)
jobs.Add(new ComputeOutFuncJob(clo.ToNonGeneric()));
- return ExecuteClosures0(new ComputeReducingClosureTask<object, TR1, TR2>(rdc), null, jobs, false);
+ return ExecuteClosures0(new ComputeReducingClosureTask<object, TJobRes, TReduceRes>(rdc), null, jobs, false);
}
/// <summary>
@@ -288,11 +290,11 @@ namespace Apache.Ignite.Core.Impl.Compute
/// </summary>
/// <param name="clo">Job to broadcast to all projection nodes.</param>
/// <returns>Collection of results for this execution.</returns>
- public IFuture<ICollection<TR>> Broadcast<TR>(IComputeFunc<TR> clo)
+ public IFuture<ICollection<TJobRes>> Broadcast<TJobRes>(IComputeFunc<TJobRes> clo)
{
IgniteArgumentCheck.NotNull(clo, "clo");
- return ExecuteClosures0(new ComputeMultiClosureTask<object, TR, ICollection<TR>>(1),
+ return ExecuteClosures0(new ComputeMultiClosureTask<object, TJobRes, ICollection<TJobRes>>(1),
new ComputeOutFuncJob(clo.ToNonGeneric()), null, true);
}
@@ -303,11 +305,11 @@ namespace Apache.Ignite.Core.Impl.Compute
/// <param name="clo">Job to broadcast to all projection nodes.</param>
/// <param name="arg">Job closure argument.</param>
/// <returns>Collection of results for this execution.</returns>
- public IFuture<ICollection<TR>> Broadcast<T, TR>(IComputeFunc<T, TR> clo, T arg)
+ public IFuture<ICollection<TJobRes>> Broadcast<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo, TArg arg)
{
IgniteArgumentCheck.NotNull(clo, "clo");
- return ExecuteClosures0(new ComputeMultiClosureTask<object, TR, ICollection<TR>>(1),
+ return ExecuteClosures0(new ComputeMultiClosureTask<object, TJobRes, ICollection<TJobRes>>(1),
new ComputeFuncJob(clo.ToNonGeneric(), arg), null, true);
}
@@ -367,11 +369,11 @@ namespace Apache.Ignite.Core.Impl.Compute
/// <param name="clo">Job to run.</param>
/// <param name="arg">Job argument.</param>
/// <returns>Job result for this execution.</returns>
- public IFuture<TR> Apply<T, TR>(IComputeFunc<T, TR> clo, T arg)
+ public IFuture<TJobRes> Apply<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo, TArg arg)
{
IgniteArgumentCheck.NotNull(clo, "clo");
- return ExecuteClosures0(new ComputeSingleClosureTask<T, TR, TR>(),
+ return ExecuteClosures0(new ComputeSingleClosureTask<TArg, TJobRes, TJobRes>(),
new ComputeFuncJob(clo.ToNonGeneric(), arg), null, false);
}
@@ -383,7 +385,8 @@ namespace Apache.Ignite.Core.Impl.Compute
/// <param name="clo">Job to run.</param>
/// <param name="args">Job arguments.</param>
/// <returns>Collection of job results.</returns>
- public IFuture<ICollection<TR>> Apply<T, TR>(IComputeFunc<T, TR> clo, IEnumerable<T> args)
+ public IFuture<ICollection<TJobRes>> Apply<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo,
+ IEnumerable<TArg> args)
{
IgniteArgumentCheck.NotNull(clo, "clo");
@@ -393,10 +396,10 @@ namespace Apache.Ignite.Core.Impl.Compute
var func = clo.ToNonGeneric();
- foreach (T arg in args)
+ foreach (TArg arg in args)
jobs.Add(new ComputeFuncJob(func, arg));
- return ExecuteClosures0(new ComputeMultiClosureTask<T, TR, ICollection<TR>>(jobs.Count),
+ return ExecuteClosures0(new ComputeMultiClosureTask<TArg, TJobRes, ICollection<TJobRes>>(jobs.Count),
null, jobs, false);
}
@@ -410,8 +413,8 @@ namespace Apache.Ignite.Core.Impl.Compute
/// <param name="args">Job arguments.</param>
/// <param name="rdc">Reducer to reduce all job results into one individual return value.</param>
/// <returns>Reduced job result for this execution.</returns>
- public IFuture<TR2> Apply<T, TR1, TR2>(IComputeFunc<T, TR1> clo, IEnumerable<T> args,
- IComputeReducer<TR1, TR2> rdc)
+ public IFuture<TReduceRes> Apply<TArg, TJobRes, TReduceRes>(IComputeFunc<TArg, TJobRes> clo,
+ IEnumerable<TArg> args, IComputeReducer<TJobRes, TReduceRes> rdc)
{
IgniteArgumentCheck.NotNull(clo, "clo");
@@ -423,10 +426,10 @@ namespace Apache.Ignite.Core.Impl.Compute
var func = clo.ToNonGeneric();
- foreach (T arg in args)
+ foreach (TArg arg in args)
jobs.Add(new ComputeFuncJob(func, arg));
- return ExecuteClosures0(new ComputeReducingClosureTask<T, TR1, TR2>(rdc),
+ return ExecuteClosures0(new ComputeReducingClosureTask<TArg, TJobRes, TReduceRes>(rdc),
null, jobs, false);
}
@@ -454,12 +457,12 @@ namespace Apache.Ignite.Core.Impl.Compute
/// <param name="affinityKey">Affinity key.</param>
/// <param name="clo">Job to execute.</param>
/// <returns>Job result for this execution.</returns>
- /// <typeparam name="TR">Type of job result.</typeparam>
- public IFuture<TR> AffinityCall<TR>(string cacheName, object affinityKey, IComputeFunc<TR> clo)
+ /// <typeparam name="TJobRes">Type of job result.</typeparam>
+ public IFuture<TJobRes> AffinityCall<TJobRes>(string cacheName, object affinityKey, IComputeFunc<TJobRes> clo)
{
IgniteArgumentCheck.NotNull(clo, "clo");
- return ExecuteClosures0(new ComputeSingleClosureTask<object, TR, TR>(),
+ return ExecuteClosures0(new ComputeSingleClosureTask<object, TJobRes, TJobRes>(),
new ComputeOutFuncJob(clo.ToNonGeneric()), opId: OpAffinity,
writeAction: w => WriteAffinity(w, cacheName, affinityKey));
}
@@ -480,7 +483,8 @@ namespace Apache.Ignite.Core.Impl.Compute
/// <param name="jobs">Jobs.</param>
/// <param name="broadcast">Broadcast flag.</param>
/// <returns>Future.</returns>
- private IFuture<TR> ExecuteClosures0<TA, T, TR>(IComputeTask<TA, T, TR> task, IComputeJob job,
+ private IFuture<TReduceRes> ExecuteClosures0<TArg, TJobRes, TReduceRes>(
+ IComputeTask<TArg, TJobRes, TReduceRes> task, IComputeJob job,
ICollection<IComputeJob> jobs, bool broadcast)
{
return ExecuteClosures0(task, job, jobs, broadcast ? OpBroadcast : OpUnicast,
@@ -499,13 +503,14 @@ namespace Apache.Ignite.Core.Impl.Compute
/// <returns>Future.</returns>
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
Justification = "User code can throw any exception")]
- private IFuture<TR> ExecuteClosures0<TA, T, TR>(IComputeTask<TA, T, TR> task, IComputeJob job = null,
+ private IFuture<TReduceRes> ExecuteClosures0<TArg, TJobRes, TReduceRes>(
+ IComputeTask<TArg, TJobRes, TReduceRes> task, IComputeJob job = null,
IEnumerable<IComputeJob> jobs = null, int opId = OpUnicast, int jobsCount = 0,
Action<PortableWriterImpl> writeAction = null)
{
Debug.Assert(job != null || jobs != null);
- var holder = new ComputeTaskHolder<TA, T, TR>((Ignite) _prj.Ignite, this, task, default(TA));
+ var holder = new ComputeTaskHolder<TArg, TJobRes, TReduceRes>((Ignite) _prj.Ignite, this, task, default(TArg));
var taskHandle = Marshaller.Ignite.HandleRegistry.Allocate(holder);
[22/50] [abbrv] ignite git commit: IGNITE-1653 fixes
Posted by vo...@apache.org.
IGNITE-1653 fixes
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/50cf42a3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/50cf42a3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/50cf42a3
Branch: refs/heads/ignite-1651
Commit: 50cf42a3137fe31c00177042eb65001253aad518
Parents: bc6bf5f
Author: Anton Vinogradov <av...@apache.org>
Authored: Mon Oct 19 11:54:49 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Mon Oct 19 11:54:49 2015 +0300
----------------------------------------------------------------------
examples-lgpl/config/filesystem/README.txt | 8 -
examples-lgpl/config/filesystem/core-site.xml | 42 -----
.../config/filesystem/example-igfs.xml | 151 ----------------
examples-lgpl/config/servlet/README.txt | 8 -
examples-lgpl/config/servlet/WEB-INF/web.xml | 36 ----
.../java8/cluster/ClusterGroupExample.java | 86 ----------
.../examples/java8/cluster/package-info.java | 22 ---
.../java8/computegrid/ComputeAsyncExample.java | 75 --------
.../computegrid/ComputeBroadcastExample.java | 102 -----------
.../computegrid/ComputeCallableExample.java | 75 --------
.../computegrid/ComputeClosureExample.java | 71 --------
.../computegrid/ComputeRunnableExample.java | 64 -------
.../java8/computegrid/package-info.java | 22 ---
.../java8/datagrid/CacheAffinityExample.java | 137 ---------------
.../java8/datagrid/CacheApiExample.java | 105 -----------
.../java8/datagrid/CacheAsyncApiExample.java | 85 ---------
.../examples/java8/datagrid/package-info.java | 22 ---
.../IgniteExecutorServiceExample.java | 70 --------
.../java8/datastructures/package-info.java | 22 ---
.../examples/java8/events/EventsExample.java | 135 ---------------
.../examples/java8/events/package-info.java | 22 ---
.../java8/messaging/MessagingExample.java | 166 ------------------
.../messaging/MessagingPingPongExample.java | 113 ------------
.../examples/java8/messaging/package-info.java | 22 ---
.../misc/schedule/ComputeScheduleExample.java | 68 --------
.../java8/misc/schedule/package-info.java | 22 ---
.../streaming/StreamTransformerExample.java | 101 -----------
.../java8/streaming/StreamVisitorExample.java | 172 -------------------
.../examples/java8/streaming/package-info.java | 22 ---
examples/config/hibernate/README.txt | 8 -
.../hibernate/example-hibernate-L2-cache.xml | 64 -------
pom.xml | 132 +++++++-------
32 files changed, 66 insertions(+), 2184 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/config/filesystem/README.txt
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/filesystem/README.txt b/examples-lgpl/config/filesystem/README.txt
deleted file mode 100644
index 4f6ae88..0000000
--- a/examples-lgpl/config/filesystem/README.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-FileSystem Configuration Example
---------------------------------
-
-This folder contains configuration files for IgniteFs examples located in
-org.apache.ignite.examples.igfs package.
-
-- example-igfs.xml file is used to start Apache Ignite nodes with IgniteFS configured
-- core-site.xml file is used to run Hadoop FS driver over IgniteFs
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/config/filesystem/core-site.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/filesystem/core-site.xml b/examples-lgpl/config/filesystem/core-site.xml
deleted file mode 100644
index a7a027c..0000000
--- a/examples-lgpl/config/filesystem/core-site.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0"?>
-<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
-
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to You under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<!--
- Example configuration of the Hadoop FS driver over Ignite FS API.
- Copy this file into '$HADOOP_HOME/conf/core-site.xml'.
--->
-<configuration>
- <property>
- <name>fs.default.name</name>
- <value>igfs:///</value>
- </property>
-
- <property>
- <!-- FS driver class for the 'igfs://' URIs. -->
- <name>fs.igfs.impl</name>
- <value>org.apache.ignite.hadoop.fs.v1.IgniteHadoopFileSystem</value>
- </property>
-
- <property>
- <!-- FS driver class for the 'igfs://' URIs in Hadoop2.x -->
- <name>fs.AbstractFileSystem.igfs.impl</name>
- <value>org.apache.ignite.hadoop.fs.v2.IgniteHadoopFileSystem</value>
- </property>
-</configuration>
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/config/filesystem/example-igfs.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/filesystem/example-igfs.xml b/examples-lgpl/config/filesystem/example-igfs.xml
deleted file mode 100644
index d009d46..0000000
--- a/examples-lgpl/config/filesystem/example-igfs.xml
+++ /dev/null
@@ -1,151 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to You under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<!--
- Ignite Spring configuration file to startup ignite cache.
-
- When starting a standalone node, you need to execute the following command:
- {IGNITE_HOME}/bin/ignite.{bat|sh} examples/config/filesystem/example-igfs.xml
-
- When starting Ignite from Java IDE, pass path to this file into Ignition:
- Ignition.start("examples/config/filesystem/example-igfs.xml");
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
-
- <!--
- Optional description.
- -->
- <description>
- Spring file for ignite configuration with client available endpoints.
- </description>
-
- <!--
- Initialize property configurer so we can reference environment variables.
- -->
- <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_FALLBACK"/>
- <property name="searchSystemEnvironment" value="true"/>
- </bean>
-
- <!--
- Configuration below demonstrates how to setup a IgniteFs node with file data.
- -->
- <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <!-- Set to true to enable cluster-aware class loading for examples, default is false. -->
- <property name="peerClassLoadingEnabled" value="true"/>
-
- <property name="marshaller">
- <bean class="org.apache.ignite.marshaller.optimized.OptimizedMarshaller">
- <!-- Set to false to allow non-serializable objects in examples, default is true. -->
- <property name="requireSerializable" value="false"/>
- </bean>
- </property>
-
- <property name="fileSystemConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.FileSystemConfiguration">
- <property name="name" value="igfs"/>
- <property name="metaCacheName" value="igfs-meta"/>
- <property name="dataCacheName" value="igfs-data"/>
-
- <!-- Must correlate with cache affinity mapper. -->
- <property name="blockSize" value="#{128 * 1024}"/>
- <property name="perNodeBatchSize" value="512"/>
- <property name="perNodeParallelBatchCount" value="16"/>
-
- <!-- Set number of prefetch blocks. -->
- <property name="prefetchBlocks" value="32"/>
-
- <!--
- Example of configured IPC loopback endpoint.
- -->
- <!--
- <property name="ipcEndpointConfiguration">
- <bean class="org.apache.ignite.igfs.IgfsIpcEndpointConfiguration">
- <property name="type" value="TCP" />
- </bean>
- </property>
- -->
-
- <!--
- Example of configured shared memory endpoint.
- -->
- <!--
- <property name="ipcEndpointConfiguration">
- <bean class="org.apache.ignite.igfs.IgfsIpcEndpointConfiguration">
- <property name="type" value="SHMEM" />
- </bean>
- </property>
- -->
- </bean>
- </list>
- </property>
-
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="igfs-data"/>
- <property name="cacheMode" value="PARTITIONED"/>
- <property name="atomicityMode" value="TRANSACTIONAL"/>
- <property name="writeSynchronizationMode" value="FULL_SYNC"/>
- <property name="backups" value="0"/>
- <property name="affinityMapper">
- <bean class="org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper">
- <!-- Haw many blocks in row will be stored on the same node. -->
- <constructor-arg value="512"/>
- </bean>
- </property>
- </bean>
-
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="igfs-meta"/>
- <property name="cacheMode" value="REPLICATED"/>
- <property name="atomicityMode" value="TRANSACTIONAL"/>
- <property name="writeSynchronizationMode" value="FULL_SYNC"/>
- </bean>
- </list>
- </property>
-
- <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <!--
- Ignition provides several options for automatic discovery that can be used
- instead os static IP based discovery. For information on all options refer
- to our documentation: http://apacheignite.readme.io/docs/cluster-config
- -->
- <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
- <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47509</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/config/servlet/README.txt
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/servlet/README.txt b/examples-lgpl/config/servlet/README.txt
deleted file mode 100644
index 20d4b90..0000000
--- a/examples-lgpl/config/servlet/README.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-Servlet Configuration Example
------------------------------
-
-This folder contains web.xml file that demonstrates how to configure any servlet container
-to start a Apache Ignite node inside a Web application.
-
-For more information on available configuration properties, etc. refer to our documentation:
-http://apacheignite.readme.io/docs/web-session-clustering
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/config/servlet/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/servlet/WEB-INF/web.xml b/examples-lgpl/config/servlet/WEB-INF/web.xml
deleted file mode 100644
index de4b3a0..0000000
--- a/examples-lgpl/config/servlet/WEB-INF/web.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to You under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<!--
- Example web.xml to startup Ignite from Servlet container, like Tomcat.
--->
-<web-app xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
- http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
- <context-param>
- <param-name>IgniteConfigurationFilePath</param-name>
- <param-value>config/default-config.xml</param-value>
- </context-param>
-
- <listener>
- <listener-class>org.apache.ignite.startup.servlet.ServletContextListenerStartup</listener-class>
- </listener>
-</web-app>
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/ClusterGroupExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/ClusterGroupExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/ClusterGroupExample.java
deleted file mode 100644
index caea8a7..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/ClusterGroupExample.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.cluster;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCluster;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cluster.ClusterGroup;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.examples.ExamplesUtils;
-
-/**
- * Demonstrates new functional APIs.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class ClusterGroupExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws IgniteException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- if (!ExamplesUtils.checkMinTopologySize(ignite.cluster(), 2))
- return;
-
- System.out.println();
- System.out.println("Compute example started.");
-
- IgniteCluster cluster = ignite.cluster();
-
- // Say hello to all nodes in the cluster, including local node.
- sayHello(ignite, cluster);
-
- // Say hello to all remote nodes.
- sayHello(ignite, cluster.forRemotes());
-
- // Pick random node out of remote nodes.
- ClusterGroup randomNode = cluster.forRemotes().forRandom();
-
- // Say hello to a random node.
- sayHello(ignite, randomNode);
-
- // Say hello to all nodes residing on the same host with random node.
- sayHello(ignite, cluster.forHost(randomNode.node()));
-
- // Say hello to all nodes that have current CPU load less than 50%.
- sayHello(ignite, cluster.forPredicate(n -> n.metrics().getCurrentCpuLoad() < 0.5));
- }
- }
-
- /**
- * Print 'Hello' message on remote nodes.
- *
- * @param ignite Ignite.
- * @param grp Cluster group.
- * @throws IgniteException If failed.
- */
- private static void sayHello(Ignite ignite, final ClusterGroup grp) throws IgniteException {
- // Print out hello message on all cluster nodes.
- ignite.compute(grp).broadcast(
- () -> System.out.println(">>> Hello Node: " + grp.ignite().cluster().localNode().id()));
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/package-info.java
deleted file mode 100644
index b96e98a..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Cluster group example.
- */
-package org.apache.ignite.examples.java8.cluster;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeAsyncExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeAsyncExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeAsyncExample.java
deleted file mode 100644
index 8d9cc64..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeAsyncExample.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.computegrid;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCompute;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.lang.IgniteFuture;
-import org.apache.ignite.lang.IgniteRunnable;
-
-/**
- * Demonstrates a simple use of {@link IgniteRunnable}.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class ComputeAsyncExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws IgniteException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println("Compute asynchronous example started.");
-
- // Enable asynchronous mode.
- IgniteCompute compute = ignite.compute().withAsync();
-
- Collection<IgniteFuture<?>> futs = new ArrayList<>();
-
- // Iterate through all words in the sentence and create runnable jobs.
- for (final String word : "Print words using runnable".split(" ")) {
- // Execute runnable on some node.
- compute.run(() -> {
- System.out.println();
- System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
- });
-
- futs.add(compute.future());
- }
-
- // Wait for completion of all futures.
- futs.forEach(IgniteFuture::get);
-
- System.out.println();
- System.out.println(">>> Finished printing words using runnable execution.");
- System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeBroadcastExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeBroadcastExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeBroadcastExample.java
deleted file mode 100644
index 1aed33b..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeBroadcastExample.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.computegrid;
-
-import java.util.Collection;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-
-/**
- * Demonstrates broadcasting computations within cluster.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class ComputeBroadcastExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws IgniteException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println(">>> Compute broadcast example started.");
-
- // Print hello message on all nodes.
- hello(ignite);
-
- // Gather system info from all nodes.
- gatherSystemInfo(ignite);
- }
- }
-
- /**
- * Print 'Hello' message on all nodes.
- *
- * @param ignite Ignite instance.
- * @throws IgniteException If failed.
- */
- private static void hello(Ignite ignite) throws IgniteException {
- // Print out hello message on all nodes.
- ignite.compute().broadcast(() -> {
- System.out.println();
- System.out.println(">>> Hello Node! :)");
- });
-
- System.out.println();
- System.out.println(">>> Check all nodes for hello message output.");
- }
-
- /**
- * Gather system info from all nodes and print it out.
- *
- * @param ignite Ignite instance.
- * @throws IgniteException if failed.
- */
- private static void gatherSystemInfo(Ignite ignite) throws IgniteException {
- // Gather system info from all nodes.
- Collection<String> res = ignite.compute().broadcast(() -> {
- System.out.println();
- System.out.println("Executing task on node: " + ignite.cluster().localNode().id());
-
- return "Node ID: " + ignite.cluster().localNode().id() + "\n" +
- "OS: " + System.getProperty("os.name") + " " + System.getProperty("os.version") + " " +
- System.getProperty("os.arch") + "\n" +
- "User: " + System.getProperty("user.name") + "\n" +
- "JRE: " + System.getProperty("java.runtime.name") + " " +
- System.getProperty("java.runtime.version");
- });
-
- // Print result.
- System.out.println();
- System.out.println("Nodes system information:");
- System.out.println();
-
- res.forEach(r -> {
- System.out.println(r);
- System.out.println();
- });
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeCallableExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeCallableExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeCallableExample.java
deleted file mode 100644
index cadb447..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeCallableExample.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.computegrid;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.lang.IgniteCallable;
-
-/**
- * Demonstrates using of {@link IgniteCallable} job execution on the cluster.
- * <p>
- * This example takes a sentence composed of multiple words and counts number of non-space
- * characters in the sentence by having each compute job count characters in each individual
- * word.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class ComputeCallableExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws IgniteException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println(">>> Compute callable example started.");
-
- Collection<IgniteCallable<Integer>> calls = new ArrayList<>();
-
- // Iterate through all words in the sentence and create callable jobs.
- for (String word : "Count characters using callable".split(" ")) {
- calls.add(() -> {
- System.out.println();
- System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
-
- return word.length();
- });
- }
-
- // Execute collection of callables on the ignite.
- Collection<Integer> res = ignite.compute().call(calls);
-
- int sum = res.stream().mapToInt(i -> i).sum();
-
- System.out.println();
- System.out.println(">>> Total number of characters in the phrase is '" + sum + "'.");
- System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeClosureExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeClosureExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeClosureExample.java
deleted file mode 100644
index c4d3c94..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeClosureExample.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.computegrid;
-
-import java.util.Arrays;
-import java.util.Collection;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-
-/**
- * Demonstrates a simple use of Ignite with reduce closure.
- * <p>
- * This example splits a phrase into collection of words, computes their length on different
- * nodes and then computes total amount of non-whitespaces characters in the phrase.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class ComputeClosureExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws IgniteException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println(">>> Compute closure example started.");
-
- // Execute closure on all cluster nodes.
- Collection<Integer> res = ignite.compute().apply(
- (String word) -> {
- System.out.println();
- System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
-
- // Return number of letters in the word.
- return word.length();
- },
- // Job parameters. Ignite will create as many jobs as there are parameters.
- Arrays.asList("Count characters using closure".split(" "))
- );
-
- int sum = res.stream().mapToInt(i -> i).sum();
-
- System.out.println();
- System.out.println(">>> Total number of characters in the phrase is '" + sum + "'.");
- System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeRunnableExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeRunnableExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeRunnableExample.java
deleted file mode 100644
index acb9893..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeRunnableExample.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.computegrid;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCompute;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.lang.IgniteRunnable;
-
-/**
- * Demonstrates a simple use of {@link IgniteRunnable}.
- * <p>
- * Remote nodes should always be 0started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class ComputeRunnableExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws IgniteException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println("Compute runnable example started.");
-
- IgniteCompute compute = ignite.compute();
-
- // Iterate through all words in the sentence and create runnable jobs.
- for (final String word : "Print words using runnable".split(" ")) {
- // Execute runnable on some node.
- compute.run(() -> {
- System.out.println();
- System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
- });
- }
-
- System.out.println();
- System.out.println(">>> Finished printing words using runnable execution.");
- System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/package-info.java
deleted file mode 100644
index cda49ef..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Basic examples for computational ignite functionality.
- */
-package org.apache.ignite.examples.java8.computegrid;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java
deleted file mode 100644
index f4a3b03..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.datagrid;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteCluster;
-import org.apache.ignite.IgniteCompute;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.lang.IgniteRunnable;
-
-/**
- * This example demonstrates the simplest code that populates the distributed cache
- * and co-locates simple closure execution with each key. The goal of this particular
- * example is to provide the simplest code example of this logic.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-ignite.xml} configuration.
- */
-public final class CacheAffinityExample {
- /** Cache name. */
- private static final String CACHE_NAME = CacheAffinityExample.class.getSimpleName();
-
- /** Number of keys. */
- private static final int KEY_CNT = 20;
-
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws IgniteException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println(">>> Cache affinity example started.");
-
- CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
-
- cfg.setCacheMode(CacheMode.PARTITIONED);
- cfg.setName(CACHE_NAME);
-
- try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg)) {
- for (int i = 0; i < KEY_CNT; i++)
- cache.put(i, Integer.toString(i));
-
- // Co-locates jobs with data using IgniteCompute.affinityRun(...) method.
- visitUsingAffinityRun();
-
- // Co-locates jobs with data using IgniteCluster.mapKeysToNodes(...) method.
- visitUsingMapKeysToNodes();
- }
- }
- }
-
- /**
- * Collocates jobs with keys they need to work on using
- * {@link IgniteCompute#affinityRun(String, Object, IgniteRunnable)} method.
- */
- private static void visitUsingAffinityRun() {
- Ignite ignite = Ignition.ignite();
-
- final IgniteCache<Integer, String> cache = ignite.cache(CACHE_NAME);
-
- for (int i = 0; i < KEY_CNT; i++) {
- int key = i;
-
- // This runnable will execute on the remote node where
- // data with the given key is located. Since it will be co-located
- // we can use local 'peek' operation safely.
- ignite.compute().affinityRun(CACHE_NAME, key,
- () -> System.out.println("Co-located using affinityRun [key= " + key + ", value=" + cache.localPeek(key) + ']'));
- }
- }
-
- /**
- * Collocates jobs with keys they need to work on using {@link IgniteCluster#mapKeysToNodes(String, Collection)}
- * method. The difference from {@code affinityRun(...)} method is that here we process multiple keys
- * in a single job.
- */
- private static void visitUsingMapKeysToNodes() {
- final Ignite ignite = Ignition.ignite();
-
- Collection<Integer> keys = new ArrayList<>(KEY_CNT);
-
- for (int i = 0; i < KEY_CNT; i++)
- keys.add(i);
-
- // Map all keys to nodes.
- Map<ClusterNode, Collection<Integer>> mappings = ignite.cluster().mapKeysToNodes(CACHE_NAME, keys);
-
- for (Map.Entry<ClusterNode, Collection<Integer>> mapping : mappings.entrySet()) {
- ClusterNode node = mapping.getKey();
-
- final Collection<Integer> mappedKeys = mapping.getValue();
-
- if (node != null) {
- // Bring computations to the nodes where the data resides (i.e. collocation).
- ignite.compute(ignite.cluster().forNode(node)).run(() -> {
- IgniteCache<Integer, String> cache = ignite.cache(CACHE_NAME);
-
- // Peek is a local memory lookup, however, value should never be 'null'
- // as we are co-located with node that has a given key.
- for (Integer key : mappedKeys)
- System.out.println("Co-located using mapKeysToNodes [key= " + key +
- ", value=" + cache.localPeek(key) + ']');
- });
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheApiExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheApiExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheApiExample.java
deleted file mode 100644
index 1891a35..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheApiExample.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.datagrid;
-
-import java.util.concurrent.ConcurrentMap;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ExampleNodeStartup;
-
-/**
- * This example demonstrates some of the cache rich API capabilities.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-ignite.xml} configuration.
- */
-public class CacheApiExample {
- /** Cache name. */
- private static final String CACHE_NAME = CacheApiExample.class.getSimpleName();
-
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws IgniteException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println(">>> Cache API example started.");
-
- CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
-
- cfg.setCacheMode(CacheMode.PARTITIONED);
- cfg.setName(CACHE_NAME);
-
- try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg)) {
- // Demonstrate atomic map operations.
- atomicMapOperations(cache);
- }
- }
- }
-
- /**
- * Demonstrates cache operations similar to {@link ConcurrentMap} API. Note that
- * cache API is a lot richer than the JDK {@link ConcurrentMap}.
- *
- * @throws IgniteException If failed.
- */
- private static void atomicMapOperations(final IgniteCache<Integer, String> cache) throws IgniteException {
- System.out.println();
- System.out.println(">>> Cache atomic map operation examples.");
-
- // Put and return previous value.
- String v = cache.getAndPut(1, "1");
- assert v == null;
-
- // Put and do not return previous value (all methods ending with 'x' return boolean).
- // Performs better when previous value is not needed.
- cache.put(2, "2");
-
- // Put-if-absent.
- boolean b1 = cache.putIfAbsent(4, "4");
- boolean b2 = cache.putIfAbsent(4, "44");
- assert b1 && !b2;
-
- // Invoke - assign new value based on previous value.
- cache.put(6, "6");
-
- cache.invoke(6, (entry, args) -> {
- String val = entry.getValue();
-
- entry.setValue(val + "6"); // Set new value based on previous value.
-
- return null;
- });
-
- // Replace.
- cache.put(7, "7");
- b1 = cache.replace(7, "7", "77");
- b2 = cache.replace(7, "7", "777");
- assert b1 & !b2;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAsyncApiExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAsyncApiExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAsyncApiExample.java
deleted file mode 100644
index b457b27..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAsyncApiExample.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.datagrid;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.lang.IgniteFuture;
-
-/**
- * This example demonstrates some of the cache rich API capabilities.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-ignite.xml} configuration.
- */
-public class CacheAsyncApiExample {
- /** Cache name. */
- private static final String CACHE_NAME = CacheAsyncApiExample.class.getSimpleName();
-
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws IgniteException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println(">>> Cache asynchronous API example started.");
-
- CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
-
- cfg.setCacheMode(CacheMode.PARTITIONED);
- cfg.setName(CACHE_NAME);
-
- try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg)) {
- // Enable asynchronous mode.
- IgniteCache<Integer, String> asyncCache = cache.withAsync();
-
- Collection<IgniteFuture<?>> futs = new ArrayList<>();
-
- // Execute several puts asynchronously.
- for (int i = 0; i < 10; i++) {
- asyncCache.put(i, String.valueOf(i));
-
- futs.add(asyncCache.future());
- }
-
- // Wait for completion of all futures.
- futs.forEach(IgniteFuture::get);
-
- // Execute get operation asynchronously.
- asyncCache.get(1);
-
- // Asynchronously wait for result.
- asyncCache.<String>future().listen(fut ->
- System.out.println("Get operation completed [value=" + fut.get() + ']'));
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/package-info.java
deleted file mode 100644
index 0bd86a0..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Demonstrates data ignite cache usage.
- */
-package org.apache.ignite.examples.java8.datagrid;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/IgniteExecutorServiceExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/IgniteExecutorServiceExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/IgniteExecutorServiceExample.java
deleted file mode 100644
index 0155144..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/IgniteExecutorServiceExample.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.datastructures;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.TimeUnit;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.lang.IgniteRunnable;
-
-/**
- * Simple example to demonstrate usage of distributed executor service provided by Ignite.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public final class IgniteExecutorServiceExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws Exception If example execution failed.
- */
- @SuppressWarnings({"TooBroadScope"})
- public static void main(String[] args) throws Exception {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println(">>> Compute executor service example started.");
-
- // Get ignite-enabled executor service.
- ExecutorService exec = ignite.executorService();
-
- // Iterate through all words in the sentence and create callable jobs.
- for (final String word : "Print words using runnable".split(" ")) {
- // Execute runnable on some node.
- exec.submit((IgniteRunnable)() -> {
- System.out.println();
- System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
- });
- }
-
- exec.shutdown();
-
- // Wait for all jobs to complete (0 means no limit).
- exec.awaitTermination(0, TimeUnit.MILLISECONDS);
-
- System.out.println();
- System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/package-info.java
deleted file mode 100644
index 86f3423..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Demonstrates using of blocking and non-blocking queues and atomic data structures.
- */
-package org.apache.ignite.examples.java8.datastructures;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/EventsExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/EventsExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/EventsExample.java
deleted file mode 100644
index df2d52b..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/EventsExample.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.events;
-
-import java.util.UUID;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.compute.ComputeTaskSession;
-import org.apache.ignite.events.TaskEvent;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.lang.IgniteBiPredicate;
-import org.apache.ignite.lang.IgnitePredicate;
-import org.apache.ignite.lang.IgniteRunnable;
-import org.apache.ignite.resources.TaskSessionResource;
-
-import static org.apache.ignite.events.EventType.EVTS_TASK_EXECUTION;
-
-/**
- * Demonstrates event consume API that allows to register event listeners on remote nodes.
- * Note that ignite events are disabled by default and must be specifically enabled,
- * just like in {@code examples/config/example-ignite.xml} file.
- * <p>
- * Remote nodes should always be started with configuration: {@code 'ignite.sh examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start
- * node with {@code examples/config/example-ignite.xml} configuration.
- */
-public class EventsExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws Exception If example execution failed.
- */
- public static void main(String[] args) throws Exception {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println(">>> Events API example started.");
-
- // Listen to events happening on local node.
- localListen();
-
- // Listen to events happening on all cluster nodes.
- remoteListen();
-
- // Wait for a while while callback is notified about remaining puts.
- Thread.sleep(1000);
- }
- }
-
- /**
- * Listen to events that happen only on local node.
- *
- * @throws IgniteException If failed.
- */
- private static void localListen() throws IgniteException {
- System.out.println();
- System.out.println(">>> Local event listener example.");
-
- Ignite ignite = Ignition.ignite();
-
- IgnitePredicate<TaskEvent> lsnr = evt -> {
- System.out.println("Received task event [evt=" + evt.name() + ", taskName=" + evt.taskName() + ']');
-
- return true; // Return true to continue listening.
- };
-
- // Register event listener for all local task execution events.
- ignite.events().localListen(lsnr, EVTS_TASK_EXECUTION);
-
- // Generate task events.
- ignite.compute().withName("example-event-task").run(() -> System.out.println("Executing sample job."));
-
- // Unsubscribe local task event listener.
- ignite.events().stopLocalListen(lsnr);
- }
-
- /**
- * Listen to events coming from all cluster nodes.
- *
- * @throws IgniteException If failed.
- */
- private static void remoteListen() throws IgniteException {
- System.out.println();
- System.out.println(">>> Remote event listener example.");
-
- // This optional local callback is called for each event notification
- // that passed remote predicate listener.
- IgniteBiPredicate<UUID, TaskEvent> locLsnr = (nodeId, evt) -> {
- // Remote filter only accepts tasks whose name being with "good-task" prefix.
- assert evt.taskName().startsWith("good-task");
-
- System.out.println("Received task event [evt=" + evt.name() + ", taskName=" + evt.taskName());
-
- return true; // Return true to continue listening.
- };
-
- // Remote filter which only accepts tasks whose name begins with "good-task" prefix.
- IgnitePredicate<TaskEvent> rmtLsnr = evt -> evt.taskName().startsWith("good-task");
-
- Ignite ignite = Ignition.ignite();
-
- // Register event listeners on all nodes to listen for task events.
- ignite.events().remoteListen(locLsnr, rmtLsnr, EVTS_TASK_EXECUTION);
-
- // Generate task events.
- for (int i = 0; i < 10; i++) {
- ignite.compute().withName(i < 5 ? "good-task-" + i : "bad-task-" + i).run(new IgniteRunnable() {
- // Auto-inject task session.
- @TaskSessionResource
- private ComputeTaskSession ses;
-
- @Override public void run() {
- System.out.println("Executing sample job for task: " + ses.getTaskName());
- }
- });
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/package-info.java
deleted file mode 100644
index b402e78..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Demonstrates events management API.
- */
-package org.apache.ignite.examples.java8.events;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
deleted file mode 100644
index 8b88708..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.messaging;
-
-import java.util.concurrent.CountDownLatch;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.IgniteMessaging;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cluster.ClusterGroup;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.examples.ExamplesUtils;
-
-/**
- * Example that demonstrates how to exchange messages between nodes. Use such
- * functionality for cases when you need to communicate to other nodes outside
- * of ignite task.
- * <p>
- * To run this example you must have at least one remote node started.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public final class MessagingExample {
- /** Number of messages. */
- private static final int MESSAGES_NUM = 10;
-
- /** Message topics. */
- private enum TOPIC { ORDERED, UNORDERED }
-
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws Exception {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- if (!ExamplesUtils.checkMinTopologySize(ignite.cluster(), 2)) {
- System.out.println();
- System.out.println(">>> Please start at least 2 cluster nodes to run example.");
- System.out.println();
-
- return;
- }
-
- System.out.println();
- System.out.println(">>> Messaging example started.");
-
- // Group for remote nodes.
- ClusterGroup rmtGrp = ignite.cluster().forRemotes();
-
- // Listen for messages from remote nodes to make sure that they received all the messages.
- int msgCnt = rmtGrp.nodes().size() * MESSAGES_NUM;
-
- CountDownLatch orderedLatch = new CountDownLatch(msgCnt);
- CountDownLatch unorderedLatch = new CountDownLatch(msgCnt);
-
- localListen(ignite.message(ignite.cluster().forLocal()), orderedLatch, unorderedLatch);
-
- // Register listeners on all cluster nodes.
- startListening(ignite, ignite.message(rmtGrp));
-
- // Send unordered messages to all remote nodes.
- for (int i = 0; i < MESSAGES_NUM; i++)
- ignite.message(rmtGrp).send(TOPIC.UNORDERED, Integer.toString(i));
-
- System.out.println(">>> Finished sending unordered messages.");
-
- // Send ordered messages to all remote nodes.
- for (int i = 0; i < MESSAGES_NUM; i++)
- ignite.message(rmtGrp).sendOrdered(TOPIC.ORDERED, Integer.toString(i), 0);
-
- System.out.println(">>> Finished sending ordered messages.");
- System.out.println(">>> Check output on all nodes for message printouts.");
- System.out.println(">>> Will wait for messages acknowledgements from all remote nodes.");
-
- orderedLatch.await();
- unorderedLatch.await();
-
- System.out.println(">>> Messaging example finished.");
- }
- }
-
- /**
- * Start listening to messages on remote cluster nodes.
- *
- * @param ignite Ignite.
- * @param imsg Ignite messaging.
- * @throws IgniteException If failed.
- */
- private static void startListening(final Ignite ignite, IgniteMessaging imsg) throws IgniteException {
- // Add ordered message listener.
- imsg.remoteListen(TOPIC.ORDERED, (nodeId, msg) -> {
- System.out.println("Received ordered message [msg=" + msg + ", fromNodeId=" + nodeId + ']');
-
- try {
- ignite.message(ignite.cluster().forNodeId(nodeId)).send(TOPIC.ORDERED, msg);
- }
- catch (IgniteException e) {
- e.printStackTrace();
- }
-
- return true; // Return true to continue listening.
- });
-
- // Add unordered message listener.
- imsg.remoteListen(TOPIC.UNORDERED, (nodeId, msg) -> {
- System.out.println("Received unordered message [msg=" + msg + ", fromNodeId=" + nodeId + ']');
-
- try {
- ignite.message(ignite.cluster().forNodeId(nodeId)).send(TOPIC.UNORDERED, msg);
- }
- catch (IgniteException e) {
- e.printStackTrace();
- }
-
- return true; // Return true to continue listening.
- });
- }
-
- /**
- * Listen for messages from remote nodes.
- *
- * @param imsg Ignite messaging.
- * @param orderedLatch Latch for ordered messages acks.
- * @param unorderedLatch Latch for unordered messages acks.
- */
- private static void localListen(
- IgniteMessaging imsg,
- final CountDownLatch orderedLatch,
- final CountDownLatch unorderedLatch
- ) {
- imsg.localListen(TOPIC.ORDERED, (nodeId, msg) -> {
- orderedLatch.countDown();
-
- // Return true to continue listening, false to stop.
- return orderedLatch.getCount() > 0;
- });
-
- imsg.localListen(TOPIC.UNORDERED, (nodeId, msg) -> {
- unorderedLatch.countDown();
-
- // Return true to continue listening, false to stop.
- return unorderedLatch.getCount() > 0;
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingPingPongExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingPingPongExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingPingPongExample.java
deleted file mode 100644
index b19b476..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingPingPongExample.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.messaging;
-
-import java.util.concurrent.CountDownLatch;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cluster.ClusterGroup;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.examples.ExamplesUtils;
-
-/**
- * Demonstrates simple message exchange between local and remote nodes.
- * <p>
- * To run this example you must have at least one remote node started.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class MessagingPingPongExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws Exception If example execution failed.
- */
- public static void main(String[] args) throws Exception {
- // Game is played over the default ignite.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- if (!ExamplesUtils.checkMinTopologySize(ignite.cluster(), 2))
- return;
-
- System.out.println();
- System.out.println(">>> Messaging ping-pong example started.");
-
- // Pick random remote node as a partner.
- ClusterGroup nodeB = ignite.cluster().forRemotes().forRandom();
-
- // Note that both nodeA and nodeB will always point to
- // same nodes regardless of whether they were implicitly
- // serialized and deserialized on another node as part of
- // anonymous closure's state during its remote execution.
-
- // Set up remote player.
- ignite.message(nodeB).remoteListen(null, (nodeId, rcvMsg) -> {
- System.out.println("Received message [msg=" + rcvMsg + ", sender=" + nodeId + ']');
-
- if ("PING".equals(rcvMsg)) {
- ignite.message(ignite.cluster().forNodeId(nodeId)).send(null, "PONG");
-
- return true; // Continue listening.
- }
-
- return false; // Unsubscribe.
- });
-
- int MAX_PLAYS = 10;
-
- final CountDownLatch cnt = new CountDownLatch(MAX_PLAYS);
-
- // Set up local player.
- ignite.message().localListen(null, (nodeId, rcvMsg) -> {
- System.out.println("Received message [msg=" + rcvMsg + ", sender=" + nodeId + ']');
-
- if (cnt.getCount() == 1) {
- ignite.message(ignite.cluster().forNodeId(nodeId)).send(null, "STOP");
-
- cnt.countDown();
-
- return false; // Stop listening.
- }
- else if ("PONG".equals(rcvMsg))
- ignite.message(ignite.cluster().forNodeId(nodeId)).send(null, "PING");
- else
- throw new IgniteException("Received unexpected message: " + rcvMsg);
-
- cnt.countDown();
-
- return true; // Continue listening.
- });
-
- // Serve!
- ignite.message(nodeB).send(null, "PING");
-
- // Wait til the game is over.
- try {
- cnt.await();
- }
- catch (InterruptedException e) {
- System.err.println("Hm... let us finish the game!\n" + e);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/package-info.java
deleted file mode 100644
index 75180cf..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Demonstrates how to exchange messages between nodes.
- */
-package org.apache.ignite.examples.java8.messaging;
\ No newline at end of file
[12/50] [abbrv] ignite git commit: IGNITE-1653
Posted by vo...@apache.org.
IGNITE-1653
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c4b0877f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c4b0877f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c4b0877f
Branch: refs/heads/ignite-1651
Commit: c4b0877f29c6e35c57491324837849c420f2b884
Parents: 3a29b97
Author: Anton Vinogradov <av...@apache.org>
Authored: Thu Oct 15 16:59:02 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Thu Oct 15 16:59:02 2015 +0300
----------------------------------------------------------------------
assembly/release-fabric-lgpl.xml | 63 +++++
assembly/release-hadoop-lgpl.xml | 39 +++
examples-lgpl/README.txt | 27 ++
examples-lgpl/config/example-cache.xml | 73 ++++++
examples-lgpl/config/example-ignite.xml | 83 +++++++
examples-lgpl/config/filesystem/README.txt | 8 +
examples-lgpl/config/filesystem/core-site.xml | 42 ++++
.../config/filesystem/example-igfs.xml | 151 ++++++++++++
examples-lgpl/config/hibernate/README.txt | 8 +
.../hibernate/example-hibernate-L2-cache.xml | 64 +++++
examples-lgpl/config/servlet/README.txt | 8 +
examples-lgpl/config/servlet/WEB-INF/web.xml | 36 +++
examples-lgpl/pom-standalone.xml | 141 +++++++++++
examples-lgpl/pom.xml | 128 ++++++++++
.../hibernate/HibernateL2CacheExample.java | 245 +++++++++++++++++++
.../examples/datagrid/hibernate/Post.java | 130 ++++++++++
.../examples/datagrid/hibernate/User.java | 154 ++++++++++++
.../datagrid/hibernate/package-info.java | 22 ++
.../hibernate/CacheHibernatePersonStore.java | 122 +++++++++
.../hibernate/CacheHibernateStoreExample.java | 151 ++++++++++++
.../datagrid/store/hibernate/Person.hbm.xml | 34 +++
.../datagrid/store/hibernate/hibernate.cfg.xml | 41 ++++
.../datagrid/store/hibernate/package-info.java | 22 ++
.../java8/cluster/ClusterGroupExample.java | 86 +++++++
.../examples/java8/cluster/package-info.java | 22 ++
.../java8/computegrid/ComputeAsyncExample.java | 75 ++++++
.../computegrid/ComputeBroadcastExample.java | 102 ++++++++
.../computegrid/ComputeCallableExample.java | 75 ++++++
.../computegrid/ComputeClosureExample.java | 71 ++++++
.../computegrid/ComputeRunnableExample.java | 64 +++++
.../java8/computegrid/package-info.java | 22 ++
.../java8/datagrid/CacheAffinityExample.java | 137 +++++++++++
.../java8/datagrid/CacheApiExample.java | 105 ++++++++
.../java8/datagrid/CacheAsyncApiExample.java | 85 +++++++
.../examples/java8/datagrid/package-info.java | 22 ++
.../IgniteExecutorServiceExample.java | 70 ++++++
.../java8/datastructures/package-info.java | 22 ++
.../examples/java8/events/EventsExample.java | 135 ++++++++++
.../examples/java8/events/package-info.java | 22 ++
.../java8/messaging/MessagingExample.java | 166 +++++++++++++
.../messaging/MessagingPingPongExample.java | 113 +++++++++
.../examples/java8/messaging/package-info.java | 22 ++
.../misc/schedule/ComputeScheduleExample.java | 68 +++++
.../java8/misc/schedule/package-info.java | 22 ++
.../ignite/examples/java8/package-info.java | 23 ++
.../streaming/StreamTransformerExample.java | 101 ++++++++
.../java8/streaming/StreamVisitorExample.java | 172 +++++++++++++
.../examples/java8/streaming/package-info.java | 22 ++
...ibernateL2CacheExampleMultiNodeSelfTest.java | 31 +++
.../HibernateL2CacheExampleSelfTest.java | 33 +++
.../IgniteLgplExamplesSelfTestSuite.java | 48 ++++
...ibernateL2CacheExampleMultiNodeSelfTest.java | 29 +++
.../HibernateL2CacheExampleSelfTest.java | 37 +++
.../IgniteLgplExamplesJ8SelfTestSuite.java | 46 ++++
examples/pom-standalone.xml | 12 -
examples/pom.xml | 12 -
.../hibernate/HibernateL2CacheExample.java | 245 -------------------
.../examples/datagrid/hibernate/Post.java | 130 ----------
.../examples/datagrid/hibernate/User.java | 154 ------------
.../datagrid/hibernate/package-info.java | 22 --
.../hibernate/CacheHibernatePersonStore.java | 122 ---------
.../hibernate/CacheHibernateStoreExample.java | 151 ------------
.../datagrid/store/hibernate/Person.hbm.xml | 34 ---
.../datagrid/store/hibernate/hibernate.cfg.xml | 41 ----
.../datagrid/store/hibernate/package-info.java | 22 --
...ibernateL2CacheExampleMultiNodeSelfTest.java | 31 ---
.../HibernateL2CacheExampleSelfTest.java | 33 ---
.../testsuites/IgniteExamplesSelfTestSuite.java | 4 -
...ibernateL2CacheExampleMultiNodeSelfTest.java | 29 ---
.../HibernateL2CacheExampleSelfTest.java | 37 ---
pom.xml | 65 ++++-
71 files changed, 3904 insertions(+), 1080 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/assembly/release-fabric-lgpl.xml
----------------------------------------------------------------------
diff --git a/assembly/release-fabric-lgpl.xml b/assembly/release-fabric-lgpl.xml
new file mode 100644
index 0000000..b8757db
--- /dev/null
+++ b/assembly/release-fabric-lgpl.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2
+ http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+ <id>fabric</id>
+
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <formats>
+ <format>dir</format>
+ </formats>
+
+ <files>
+ <file>
+ <source>examples-lgpl/pom-standalone.xml</source>
+ <outputDirectory>/examples-lgpl</outputDirectory>
+ <destName>pom.xml</destName>
+ </file>
+ </files>
+
+ <fileSets>
+ <fileSet>
+ <directory>examples-lgpl</directory>
+ <outputDirectory>/examples-lgpl</outputDirectory>
+ <includes>
+ <include>README.txt</include>
+ </includes>
+ </fileSet>
+
+ <fileSet>
+ <directory>examples-lgpl</directory>
+ <outputDirectory>/examples-lgpl</outputDirectory>
+ <includes>
+ <include>config/**</include>
+ <include>src/**</include>
+ </includes>
+ <excludes>
+ <exclude>**/package.html</exclude>
+ <exclude>pom-standalone.xml</exclude>
+ <exclude>src/test/**</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+</assembly>
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/assembly/release-hadoop-lgpl.xml
----------------------------------------------------------------------
diff --git a/assembly/release-hadoop-lgpl.xml b/assembly/release-hadoop-lgpl.xml
new file mode 100644
index 0000000..ac2fc31
--- /dev/null
+++ b/assembly/release-hadoop-lgpl.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2
+ http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+ <id>fabric</id>
+
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <formats>
+ <format>dir</format>
+ </formats>
+
+ <files>
+ <file>
+ <source>assembly/LICENSE_HADOOP</source><!--assembly should contain at least one file. copied from release-hadoop.xml -->
+ <destName>LICENSE</destName>
+ <outputDirectory>/</outputDirectory>
+ </file>
+ </files>
+</assembly>
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/README.txt
----------------------------------------------------------------------
diff --git a/examples-lgpl/README.txt b/examples-lgpl/README.txt
new file mode 100644
index 0000000..8c8982e
--- /dev/null
+++ b/examples-lgpl/README.txt
@@ -0,0 +1,27 @@
+Apache Ignite LGPL Examples
+======================
+
+This folder contains code examples for various Apache Ignite functionality.
+
+Examples are shipped as a separate Maven project, so to start running you simply need
+to import provided `pom.xml` file into your favourite IDE.
+
+The examples folder contains he following subfolders:
+
+- `config` - contains Ignite configuration files needed for examples.
+- `src/main/java` - contains Java examples for different Ignite modules and features.
+- `src/main/java8` - contains additional set of Java examples utilizing Java 8 lambdas. These examples
+ are excluded by default, enable `java8-examples` Maven profile to include them (JDK8 is required).
+
+
+Starting Remote Nodes
+=====================
+
+Remote nodes for examples should always be started with special configuration file which enables P2P
+class loading: `examples/config/example-ignite.xml`. To run a remote node in IDE use `ExampleNodeStartup` class.
+
+
+Java7 vs Java8
+===============
+Some examples (not all) which can benefit from Java8 Lambda support were re-written with Java8 lambdas.
+For full set of examples, look at both Java7 and Java8 packages.
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/config/example-cache.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/example-cache.xml b/examples-lgpl/config/example-cache.xml
new file mode 100644
index 0000000..dcb8e75
--- /dev/null
+++ b/examples-lgpl/config/example-cache.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<!--
+ Ignite Spring configuration file to startup Ignite cache.
+
+ This file demonstrates how to configure cache using Spring. Provided cache
+ will be created on node startup.
+
+ Use this configuration file when running HTTP REST examples (see 'examples/rest' folder).
+
+ When starting a standalone node, you need to execute the following command:
+ {IGNITE_HOME}/bin/ignite.{bat|sh} examples/config/example-cache.xml
+
+ When starting Ignite from Java IDE, pass path to this file to Ignition:
+ Ignition.start("examples/config/example-cache.xml");
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="cacheConfiguration">
+ <list>
+ <!-- Partitioned cache example configuration (Atomic mode). -->
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="atomicityMode" value="ATOMIC"/>
+ <property name="backups" value="1"/>
+ </bean>
+ </list>
+ </property>
+
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <!--
+ Ignite provides several options for automatic discovery that can be used
+ instead os static IP based discovery. For information on all options refer
+ to our documentation: http://apacheignite.readme.io/docs/cluster-config
+ -->
+ <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
+ <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47509</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/config/example-ignite.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/example-ignite.xml b/examples-lgpl/config/example-ignite.xml
new file mode 100644
index 0000000..e870106
--- /dev/null
+++ b/examples-lgpl/config/example-ignite.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<!--
+ Ignite configuration with all defaults and enabled p2p deployment and enabled events.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <!-- Set to true to enable distributed class loading for examples, default is false. -->
+ <property name="peerClassLoadingEnabled" value="true"/>
+
+ <property name="marshaller">
+ <bean class="org.apache.ignite.marshaller.optimized.OptimizedMarshaller">
+ <!-- Set to false to allow non-serializable objects in examples, default is true. -->
+ <property name="requireSerializable" value="false"/>
+ </bean>
+ </property>
+
+ <!-- Enable task execution events for examples. -->
+ <property name="includeEventTypes">
+ <list>
+ <!--Task execution events-->
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED"/>
+
+ <!--Cache events-->
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_REMOVED"/>
+ </list>
+ </property>
+
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <!--
+ Ignite provides several options for automatic discovery that can be used
+ instead os static IP based discovery. For information on all options refer
+ to our documentation: http://apacheignite.readme.io/docs/cluster-config
+ -->
+ <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
+ <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47509</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/config/filesystem/README.txt
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/filesystem/README.txt b/examples-lgpl/config/filesystem/README.txt
new file mode 100644
index 0000000..4f6ae88
--- /dev/null
+++ b/examples-lgpl/config/filesystem/README.txt
@@ -0,0 +1,8 @@
+FileSystem Configuration Example
+--------------------------------
+
+This folder contains configuration files for IgniteFs examples located in
+org.apache.ignite.examples.igfs package.
+
+- example-igfs.xml file is used to start Apache Ignite nodes with IgniteFS configured
+- core-site.xml file is used to run Hadoop FS driver over IgniteFs
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/config/filesystem/core-site.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/filesystem/core-site.xml b/examples-lgpl/config/filesystem/core-site.xml
new file mode 100644
index 0000000..a7a027c
--- /dev/null
+++ b/examples-lgpl/config/filesystem/core-site.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<!--
+ Example configuration of the Hadoop FS driver over Ignite FS API.
+ Copy this file into '$HADOOP_HOME/conf/core-site.xml'.
+-->
+<configuration>
+ <property>
+ <name>fs.default.name</name>
+ <value>igfs:///</value>
+ </property>
+
+ <property>
+ <!-- FS driver class for the 'igfs://' URIs. -->
+ <name>fs.igfs.impl</name>
+ <value>org.apache.ignite.hadoop.fs.v1.IgniteHadoopFileSystem</value>
+ </property>
+
+ <property>
+ <!-- FS driver class for the 'igfs://' URIs in Hadoop2.x -->
+ <name>fs.AbstractFileSystem.igfs.impl</name>
+ <value>org.apache.ignite.hadoop.fs.v2.IgniteHadoopFileSystem</value>
+ </property>
+</configuration>
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/config/filesystem/example-igfs.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/filesystem/example-igfs.xml b/examples-lgpl/config/filesystem/example-igfs.xml
new file mode 100644
index 0000000..d009d46
--- /dev/null
+++ b/examples-lgpl/config/filesystem/example-igfs.xml
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<!--
+ Ignite Spring configuration file to startup ignite cache.
+
+ When starting a standalone node, you need to execute the following command:
+ {IGNITE_HOME}/bin/ignite.{bat|sh} examples/config/filesystem/example-igfs.xml
+
+ When starting Ignite from Java IDE, pass path to this file into Ignition:
+ Ignition.start("examples/config/filesystem/example-igfs.xml");
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <!--
+ Optional description.
+ -->
+ <description>
+ Spring file for ignite configuration with client available endpoints.
+ </description>
+
+ <!--
+ Initialize property configurer so we can reference environment variables.
+ -->
+ <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_FALLBACK"/>
+ <property name="searchSystemEnvironment" value="true"/>
+ </bean>
+
+ <!--
+ Configuration below demonstrates how to setup a IgniteFs node with file data.
+ -->
+ <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <!-- Set to true to enable cluster-aware class loading for examples, default is false. -->
+ <property name="peerClassLoadingEnabled" value="true"/>
+
+ <property name="marshaller">
+ <bean class="org.apache.ignite.marshaller.optimized.OptimizedMarshaller">
+ <!-- Set to false to allow non-serializable objects in examples, default is true. -->
+ <property name="requireSerializable" value="false"/>
+ </bean>
+ </property>
+
+ <property name="fileSystemConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.FileSystemConfiguration">
+ <property name="name" value="igfs"/>
+ <property name="metaCacheName" value="igfs-meta"/>
+ <property name="dataCacheName" value="igfs-data"/>
+
+ <!-- Must correlate with cache affinity mapper. -->
+ <property name="blockSize" value="#{128 * 1024}"/>
+ <property name="perNodeBatchSize" value="512"/>
+ <property name="perNodeParallelBatchCount" value="16"/>
+
+ <!-- Set number of prefetch blocks. -->
+ <property name="prefetchBlocks" value="32"/>
+
+ <!--
+ Example of configured IPC loopback endpoint.
+ -->
+ <!--
+ <property name="ipcEndpointConfiguration">
+ <bean class="org.apache.ignite.igfs.IgfsIpcEndpointConfiguration">
+ <property name="type" value="TCP" />
+ </bean>
+ </property>
+ -->
+
+ <!--
+ Example of configured shared memory endpoint.
+ -->
+ <!--
+ <property name="ipcEndpointConfiguration">
+ <bean class="org.apache.ignite.igfs.IgfsIpcEndpointConfiguration">
+ <property name="type" value="SHMEM" />
+ </bean>
+ </property>
+ -->
+ </bean>
+ </list>
+ </property>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="igfs-data"/>
+ <property name="cacheMode" value="PARTITIONED"/>
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="writeSynchronizationMode" value="FULL_SYNC"/>
+ <property name="backups" value="0"/>
+ <property name="affinityMapper">
+ <bean class="org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper">
+ <!-- Haw many blocks in row will be stored on the same node. -->
+ <constructor-arg value="512"/>
+ </bean>
+ </property>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="igfs-meta"/>
+ <property name="cacheMode" value="REPLICATED"/>
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="writeSynchronizationMode" value="FULL_SYNC"/>
+ </bean>
+ </list>
+ </property>
+
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <!--
+ Ignition provides several options for automatic discovery that can be used
+ instead os static IP based discovery. For information on all options refer
+ to our documentation: http://apacheignite.readme.io/docs/cluster-config
+ -->
+ <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
+ <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47509</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/config/hibernate/README.txt
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/hibernate/README.txt b/examples-lgpl/config/hibernate/README.txt
new file mode 100644
index 0000000..5b7ab29
--- /dev/null
+++ b/examples-lgpl/config/hibernate/README.txt
@@ -0,0 +1,8 @@
+Hibernate L2 Cache Configuration Example
+----------------------------------------
+
+This folder contains example-hibernate-L2-cache.xml file that demonstrates
+how to configure Hibernate to use Apache Ignite cache as an L2 cache provider.
+
+This file is also used in Hibernate example located in org.apache.ignite.examples.datagrid.hibernate
+package.
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/config/hibernate/example-hibernate-L2-cache.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/hibernate/example-hibernate-L2-cache.xml b/examples-lgpl/config/hibernate/example-hibernate-L2-cache.xml
new file mode 100644
index 0000000..a2f7e89
--- /dev/null
+++ b/examples-lgpl/config/hibernate/example-hibernate-L2-cache.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+
+<!DOCTYPE hibernate-configuration PUBLIC
+ "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+ "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
+
+<!--
+ Configuration file for HibernateL2CacheExample.
+-->
+
+<hibernate-configuration>
+ <session-factory>
+ <!-- Database connection settings -->
+ <property name="connection.url">jdbc:h2:mem:example;DB_CLOSE_DELAY=-1</property>
+
+ <!-- Drop and re-create the database schema on startup. -->
+ <property name="hbm2ddl.auto">create</property>
+
+ <!-- Enable L2 cache. -->
+ <property name="cache.use_second_level_cache">true</property>
+
+ <!-- Enable query cache. -->
+ <property name="cache.use_query_cache">true</property>
+
+ <!-- Generate L2 cache statistics. -->
+ <property name="generate_statistics">true</property>
+
+ <!-- Specify Ignite as L2 cache provider. -->
+ <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
+
+ <!-- Specify connection release mode. -->
+ <property name="connection.release_mode">on_close</property>
+
+ <!-- Set default L2 cache access type. -->
+ <property name="org.apache.ignite.hibernate.default_access_type">READ_ONLY</property>
+
+ <!-- Specify the entity classes for mapping. -->
+ <mapping class="org.apache.ignite.examples.datagrid.hibernate.User"/>
+ <mapping class="org.apache.ignite.examples.datagrid.hibernate.Post"/>
+
+ <!-- Per-class L2 cache settings. -->
+ <class-cache class="org.apache.ignite.examples.datagrid.hibernate.User" usage="read-only"/>
+ <class-cache class="org.apache.ignite.examples.datagrid.hibernate.Post" usage="read-only"/>
+ <collection-cache collection="org.apache.ignite.examples.datagrid.hibernate.User.posts" usage="read-only"/>
+ </session-factory>
+</hibernate-configuration>
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/config/servlet/README.txt
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/servlet/README.txt b/examples-lgpl/config/servlet/README.txt
new file mode 100644
index 0000000..20d4b90
--- /dev/null
+++ b/examples-lgpl/config/servlet/README.txt
@@ -0,0 +1,8 @@
+Servlet Configuration Example
+-----------------------------
+
+This folder contains web.xml file that demonstrates how to configure any servlet container
+to start a Apache Ignite node inside a Web application.
+
+For more information on available configuration properties, etc. refer to our documentation:
+http://apacheignite.readme.io/docs/web-session-clustering
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/config/servlet/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/servlet/WEB-INF/web.xml b/examples-lgpl/config/servlet/WEB-INF/web.xml
new file mode 100644
index 0000000..de4b3a0
--- /dev/null
+++ b/examples-lgpl/config/servlet/WEB-INF/web.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<!--
+ Example web.xml to startup Ignite from Servlet container, like Tomcat.
+-->
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
+ <context-param>
+ <param-name>IgniteConfigurationFilePath</param-name>
+ <param-value>config/default-config.xml</param-value>
+ </context-param>
+
+ <listener>
+ <listener-class>org.apache.ignite.startup.servlet.ServletContextListenerStartup</listener-class>
+ </listener>
+</web-app>
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/pom-standalone.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/pom-standalone.xml b/examples-lgpl/pom-standalone.xml
new file mode 100644
index 0000000..d2a00d1
--- /dev/null
+++ b/examples-lgpl/pom-standalone.xml
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--
+ POM file.
+-->
+<project
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-examples-lgpl</artifactId>
+ <version>to_be_replaced_by_ignite_version</version>
+ <packaging>pom</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-examples</artifactId>
+ <version>to_be_replaced_by_ignite_version</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-hibernate</artifactId>
+ <version>to_be_replaced_by_ignite_version</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-schedule</artifactId>
+ <version>to_be_replaced_by_ignite_version</version>
+ </dependency>
+ </dependencies>
+
+ <modules>
+ <module>../examples</module>
+ </modules>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/java</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ <resource>
+ <directory>config</directory>
+ </resource>
+ </resources>
+
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.7</source>
+ <target>1.7</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>java8-examples</id>
+
+ <activation>
+ <jdk>[1.8,)</jdk>
+ </activation>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.9.1</version>
+ <executions>
+ <execution>
+ <id>add-sources</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>src/main/java8</source>
+ </sources>
+ </configuration>
+ </execution>
+ <execution>
+ <id>add-tests</id>
+ <phase>generate-test-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>src/test/java8</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/pom.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/pom.xml b/examples-lgpl/pom.xml
new file mode 100644
index 0000000..019dc23
--- /dev/null
+++ b/examples-lgpl/pom.xml
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-parent</artifactId>
+ <version>1</version>
+ <relativePath>../parent</relativePath>
+ </parent>
+
+ <artifactId>ignite-examples-lgpl</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-hibernate</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-schedule</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-examples</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/java</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ <resource>
+ <directory>config</directory>
+ </resource>
+ </resources>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>java8-examples</id>
+
+ <activation>
+ <jdk>[1.8,)</jdk>
+ </activation>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.9.1</version>
+ <executions>
+ <execution>
+ <id>add-sources</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>src/main/java8</source>
+ </sources>
+ </configuration>
+ </execution>
+ <execution>
+ <id>add-tests</id>
+ <phase>generate-test-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>src/test/java8</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
new file mode 100644
index 0000000..2f271c8
--- /dev/null
+++ b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
@@ -0,0 +1,245 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.examples.datagrid.hibernate;
+
+import java.net.URL;
+import java.util.Arrays;
+import java.util.List;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.examples.ExamplesUtils;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.cache.spi.access.AccessType;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.service.ServiceRegistryBuilder;
+import org.hibernate.stat.SecondLevelCacheStatistics;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ * This example demonstrates the use of Ignite In-Memory Data Ignite cluster as a Hibernate
+ * Second-Level cache provider.
+ * <p>
+ * The Hibernate Second-Level cache (or "L2 cache" shortly) lets you significantly
+ * reduce the number of requests to the underlying SQL database. Because database
+ * access is known to be an expansive operation, using L2 cache may improve
+ * performance dramatically.
+ * <p>
+ * This example defines 2 entity classes: {@link User} and {@link Post}, with
+ * 1 <-> N relation, and marks them with appropriate annotations for Hibernate
+ * object-relational mapping to SQL tables of an underlying H2 in-memory database.
+ * The example launches node in the same JVM and registers it in
+ * Hibernate configuration as an L2 cache implementation. It then stores and
+ * queries instances of the entity classes to and from the database, having
+ * Hibernate SQL output, L2 cache statistics output, and Ignite cache metrics
+ * output enabled.
+ * <p>
+ * When running example, it's easy to notice that when an object is first
+ * put into a database, the L2 cache is not used and it's contents is empty.
+ * However, when an object is first read from the database, it is immediately
+ * stored in L2 cache (which is Ignite In-Memory Data Ignite cluster in fact), which can
+ * be seen in stats output. Further requests of the same object only read the data
+ * from L2 cache and do not hit the database.
+ * <p>
+ * In this example, the Hibernate query cache is also enabled. Query cache lets you
+ * avoid hitting the database in case of repetitive queries with the same parameter
+ * values. You may notice that when the example runs the same query repeatedly in
+ * loop, only the first query hits the database and the successive requests take the
+ * data from L2 cache.
+ * <p>
+ * Note: this example uses {@link AccessType#READ_ONLY} L2 cache access type, but you
+ * can experiment with other access types by modifying the Hibernate configuration file
+ * {@code IGNITE_HOME/examples/config/hibernate/example-hibernate-L2-cache.xml}, used by the example.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
+ * start node with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class HibernateL2CacheExample {
+ /** JDBC URL for backing database (an H2 in-memory database is used). */
+ private static final String JDBC_URL = "jdbc:h2:mem:example;DB_CLOSE_DELAY=-1";
+
+ /** Path to hibernate configuration file (will be resolved from application {@code CLASSPATH}). */
+ private static final String HIBERNATE_CFG = "hibernate/example-hibernate-L2-cache.xml";
+
+ /** Entity names for stats output. */
+ private static final List<String> ENTITY_NAMES =
+ Arrays.asList(User.class.getName(), Post.class.getName(), User.class.getName() + ".posts");
+
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ * @throws IgniteException If example execution failed.
+ */
+ public static void main(String[] args) throws IgniteException {
+ // Start the node, run the example, and stop the node when finished.
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ // We use a single session factory, but create a dedicated session
+ // for each transaction or query. This way we ensure that L1 cache
+ // is not used (L1 cache has per-session scope only).
+ System.out.println();
+ System.out.println(">>> Hibernate L2 cache example started.");
+
+ try (
+ // Create all required caches.
+ IgniteCache c1 = createCache("org.hibernate.cache.spi.UpdateTimestampsCache", ATOMIC);
+ IgniteCache c2 = createCache("org.hibernate.cache.internal.StandardQueryCache", ATOMIC);
+ IgniteCache c3 = createCache("org.apache.ignite.examples.datagrid.hibernate.User", TRANSACTIONAL);
+ IgniteCache c4 = createCache("org.apache.ignite.examples.datagrid.hibernate.User.posts", TRANSACTIONAL);
+ IgniteCache c5 = createCache("org.apache.ignite.examples.datagrid.hibernate.Post", TRANSACTIONAL)
+ ) {
+ URL hibernateCfg = ExamplesUtils.url(HIBERNATE_CFG);
+
+ SessionFactory sesFactory = createHibernateSessionFactory(hibernateCfg);
+
+ System.out.println();
+ System.out.println(">>> Creating objects.");
+
+ final long userId;
+
+ Session ses = sesFactory.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ User user = new User("jedi", "Luke", "Skywalker");
+
+ user.getPosts().add(new Post(user, "Let the Force be with you."));
+
+ ses.save(user);
+
+ tx.commit();
+
+ // Create a user object, store it in DB, and save the database-generated
+ // object ID. You may try adding more objects in a similar way.
+ userId = user.getId();
+ }
+ finally {
+ ses.close();
+ }
+
+ // Output L2 cache and Ignite cache stats. You may notice that
+ // at this point the object is not yet stored in L2 cache, because
+ // the read was not yet performed.
+ printStats(sesFactory);
+
+ System.out.println();
+ System.out.println(">>> Querying object by ID.");
+
+ // Query user by ID several times. First time we get an L2 cache
+ // miss, and the data is queried from DB, but it is then stored
+ // in cache and successive queries hit the cache and return
+ // immediately, no SQL query is made.
+ for (int i = 0; i < 3; i++) {
+ ses = sesFactory.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ User user = (User)ses.get(User.class, userId);
+
+ System.out.println("User: " + user);
+
+ for (Post post : user.getPosts())
+ System.out.println("\tPost: " + post);
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+ }
+
+ // Output the stats. We should see 1 miss and 2 hits for
+ // User and Collection object (stored separately in L2 cache).
+ // The Post is loaded with the collection, so it won't imply
+ // a miss.
+ printStats(sesFactory);
+ }
+ }
+ }
+
+ /**
+ * Creates cache.
+ *
+ * @param name Cache name.
+ * @param atomicityMode Atomicity mode.
+ * @return Cache configuration.
+ */
+ private static IgniteCache createCache(String name, CacheAtomicityMode atomicityMode) {
+ CacheConfiguration ccfg = new CacheConfiguration(name);
+
+ ccfg.setAtomicityMode(atomicityMode);
+ ccfg.setWriteSynchronizationMode(FULL_SYNC);
+
+ return Ignition.ignite().getOrCreateCache(ccfg);
+ }
+
+ /**
+ * Creates a new Hibernate {@link SessionFactory} using a programmatic
+ * configuration.
+ *
+ * @param hibernateCfg Hibernate configuration file.
+ * @return New Hibernate {@link SessionFactory}.
+ */
+ private static SessionFactory createHibernateSessionFactory(URL hibernateCfg) {
+ ServiceRegistryBuilder builder = new ServiceRegistryBuilder();
+
+ builder.applySetting("hibernate.connection.url", JDBC_URL);
+ builder.applySetting("hibernate.show_sql", true);
+
+ return new Configuration()
+ .configure(hibernateCfg)
+ .buildSessionFactory(builder.buildServiceRegistry());
+ }
+
+ /**
+ * Prints Hibernate L2 cache statistics to standard output.
+ *
+ * @param sesFactory Hibernate {@link SessionFactory}, for which to print
+ * statistics.
+ */
+ private static void printStats(SessionFactory sesFactory) {
+ System.out.println("=== Hibernate L2 cache statistics ===");
+
+ for (String entityName : ENTITY_NAMES) {
+ System.out.println("\tEntity: " + entityName);
+
+ SecondLevelCacheStatistics stats =
+ sesFactory.getStatistics().getSecondLevelCacheStatistics(entityName);
+
+ System.out.println("\t\tL2 cache entries: " + stats.getEntries());
+ System.out.println("\t\tHits: " + stats.getHitCount());
+ System.out.println("\t\tMisses: " + stats.getMissCount());
+ }
+
+ System.out.println("=====================================");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/Post.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/Post.java b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/Post.java
new file mode 100644
index 0000000..8e98835
--- /dev/null
+++ b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/Post.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.examples.datagrid.hibernate;
+
+import java.util.Date;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+
+/**
+ * An entity class representing a post, that a
+ * {@link User} has made on some public service.
+ */
+@Entity
+class Post {
+ /** ID. */
+ @Id
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ private long id;
+
+ /** Author. */
+ @ManyToOne
+ private User author;
+
+ /** Text. */
+ private String text;
+
+ /** Created timestamp. */
+ private Date created;
+
+ /**
+ * Default constructor (required by Hibernate).
+ */
+ Post() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param author Author.
+ * @param text Text.
+ */
+ Post(User author, String text) {
+ this.author = author;
+ this.text = text;
+ created = new Date();
+ }
+
+ /**
+ * @return ID.
+ */
+ public long getId() {
+ return id;
+ }
+
+ /**
+ * @param id New ID.
+ */
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ /**
+ * @return Author.
+ */
+ public User getAuthor() {
+ return author;
+ }
+
+ /**
+ * @param author New author.
+ */
+ public void setAuthor(User author) {
+ this.author = author;
+ }
+
+ /**
+ * @return Text.
+ */
+ public String getText() {
+ return text;
+ }
+
+ /**
+ * @param text New text.
+ */
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ /**
+ * @return Created timestamp.
+ */
+ public Date getCreated() {
+ return (Date)created.clone();
+ }
+
+ /**
+ * @param created New created timestamp.
+ */
+ public void setCreated(Date created) {
+ this.created = (Date)created.clone();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return "Post [id=" + id +
+ ", text=" + text +
+ ", created=" + created +
+ ']';
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/User.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/User.java b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/User.java
new file mode 100644
index 0000000..d0486f5
--- /dev/null
+++ b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/User.java
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.examples.datagrid.hibernate;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import org.hibernate.annotations.NaturalId;
+
+/**
+ * A user entity class. Represents a user of some public service,
+ * having a number of personal information fields as well as a
+ * number of posts written.
+ */
+@Entity
+class User {
+ /** ID. */
+ @Id
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ private long id;
+
+ /** Login. */
+ @NaturalId
+ private String login;
+
+ /** First name. */
+ private String firstName;
+
+ /** Last name. */
+ private String lastName;
+
+ /** Posts. */
+ @OneToMany(mappedBy = "author", cascade = CascadeType.ALL)
+ private Set<Post> posts = new HashSet<>();
+
+ /**
+ * Default constructor (required by Hibernate).
+ */
+ User() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param login Login.
+ * @param firstName First name.
+ * @param lastName Last name.
+ */
+ User(String login, String firstName, String lastName) {
+ this.login = login;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
+
+ /**
+ * @return ID.
+ */
+ public long getId() {
+ return id;
+ }
+
+ /**
+ * @param id New ID.
+ */
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ /**
+ * @return Login.
+ */
+ public String getLogin() {
+ return login;
+ }
+
+ /**
+ * @param login New login.
+ */
+ public void setLogin(String login) {
+ this.login = login;
+ }
+
+ /**
+ * @return First name.
+ */
+ public String getFirstName() {
+ return firstName;
+ }
+
+ /**
+ * @param firstName New first name.
+ */
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ /**
+ * @return Last name.
+ */
+ public String getLastName() {
+ return lastName;
+ }
+
+ /**
+ * @param lastName New last name.
+ */
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ /**
+ * @return Posts.
+ */
+ public Set<Post> getPosts() {
+ return posts;
+ }
+
+ /**
+ * @param posts New posts.
+ */
+ public void setPosts(Set<Post> posts) {
+ this.posts = posts;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return "User [id=" + id +
+ ", login=" + login +
+ ", firstName=" + firstName +
+ ", lastName=" + lastName +
+ ']';
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/package-info.java b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/package-info.java
new file mode 100644
index 0000000..7bddaaf
--- /dev/null
+++ b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 description. -->
+ * Hibernate example.
+ */
+package org.apache.ignite.examples.datagrid.hibernate;
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java
new file mode 100644
index 0000000..d040b88
--- /dev/null
+++ b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.examples.datagrid.store.hibernate;
+
+import java.util.List;
+import java.util.UUID;
+import javax.cache.integration.CacheLoaderException;
+import javax.cache.integration.CacheWriterException;
+import org.apache.ignite.cache.store.CacheStore;
+import org.apache.ignite.cache.store.CacheStoreAdapter;
+import org.apache.ignite.cache.store.CacheStoreSession;
+import org.apache.ignite.examples.datagrid.store.Person;
+import org.apache.ignite.lang.IgniteBiInClosure;
+import org.apache.ignite.resources.CacheStoreSessionResource;
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+
+/**
+ * Example of {@link CacheStore} implementation that uses Hibernate
+ * and deals with maps {@link UUID} to {@link Person}.
+ */
+public class CacheHibernatePersonStore extends CacheStoreAdapter<Long, Person> {
+ /** Auto-injected store session. */
+ @CacheStoreSessionResource
+ private CacheStoreSession ses;
+
+ /** {@inheritDoc} */
+ @Override public Person load(Long key) {
+ System.out.println(">>> Store load [key=" + key + ']');
+
+ Session hibSes = ses.attachment();
+
+ try {
+ return (Person)hibSes.get(Person.class, key);
+ }
+ catch (HibernateException e) {
+ throw new CacheLoaderException("Failed to load value from cache store [key=" + key + ']', e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void write(javax.cache.Cache.Entry<? extends Long, ? extends Person> entry) {
+ Long key = entry.getKey();
+ Person val = entry.getValue();
+
+ System.out.println(">>> Store write [key=" + key + ", val=" + val + ']');
+
+ Session hibSes = ses.attachment();
+
+ try {
+ hibSes.saveOrUpdate(val);
+ }
+ catch (HibernateException e) {
+ throw new CacheWriterException("Failed to put value to cache store [key=" + key + ", val" + val + "]", e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings({"JpaQueryApiInspection"})
+ @Override public void delete(Object key) {
+ System.out.println(">>> Store delete [key=" + key + ']');
+
+ Session hibSes = ses.attachment();
+
+ try {
+ hibSes.createQuery("delete " + Person.class.getSimpleName() + " where key = :key").
+ setParameter("key", key).
+ executeUpdate();
+ }
+ catch (HibernateException e) {
+ throw new CacheWriterException("Failed to remove value from cache store [key=" + key + ']', e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void loadCache(IgniteBiInClosure<Long, Person> clo, Object... args) {
+ if (args == null || args.length == 0 || args[0] == null)
+ throw new CacheLoaderException("Expected entry count parameter is not provided.");
+
+ final int entryCnt = (Integer)args[0];
+
+ Session hibSes = ses.attachment();
+
+ try {
+ int cnt = 0;
+
+ List list = hibSes.createCriteria(Person.class).
+ setMaxResults(entryCnt).
+ list();
+
+ if (list != null) {
+ for (Object obj : list) {
+ Person person = (Person)obj;
+
+ clo.apply(person.getId(), person);
+
+ cnt++;
+ }
+ }
+
+ System.out.println(">>> Loaded " + cnt + " values into cache.");
+ }
+ catch (HibernateException e) {
+ throw new CacheLoaderException("Failed to load values from cache store.", e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java
new file mode 100644
index 0000000..f993d81
--- /dev/null
+++ b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.examples.datagrid.store.hibernate;
+
+import java.util.UUID;
+import javax.cache.configuration.Factory;
+import javax.cache.configuration.FactoryBuilder;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.store.CacheStoreSessionListener;
+import org.apache.ignite.cache.store.hibernate.CacheHibernateStoreSessionListener;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.examples.ExamplesUtils;
+import org.apache.ignite.examples.datagrid.store.Person;
+import org.apache.ignite.transactions.Transaction;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+
+/**
+ * Demonstrates usage of cache with underlying persistent store configured.
+ * <p>
+ * This example uses {@link CacheHibernatePersonStore} as a persistent store.
+ * <p>
+ * Remote nodes can be started with {@link ExampleNodeStartup} in another JVM which will
+ * start node with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class CacheHibernateStoreExample {
+ /** Hibernate configuration resource path. */
+ private static final String HIBERNATE_CFG =
+ "/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml";
+
+ /** Cache name. */
+ private static final String CACHE_NAME = CacheHibernateStoreExample.class.getSimpleName();
+
+ /** Heap size required to run this example. */
+ public static final int MIN_MEMORY = 1024 * 1024 * 1024;
+
+ /** Number of entries to load. */
+ private static final int ENTRY_COUNT = 100_000;
+
+ /** Global person ID to use across entire example. */
+ private static final Long id = Math.abs(UUID.randomUUID().getLeastSignificantBits());
+
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ * @throws IgniteException If example execution failed.
+ */
+ public static void main(String[] args) throws IgniteException {
+ ExamplesUtils.checkMinMemory(MIN_MEMORY);
+
+ // To start ignite with desired configuration uncomment the appropriate line.
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ System.out.println();
+ System.out.println(">>> Cache store example started.");
+
+ CacheConfiguration<Long, Person> cacheCfg = new CacheConfiguration<>(CACHE_NAME);
+
+ // Set atomicity as transaction, since we are showing transactions in example.
+ cacheCfg.setAtomicityMode(TRANSACTIONAL);
+
+ // Configure Hibernate store.
+ cacheCfg.setCacheStoreFactory(FactoryBuilder.factoryOf(CacheHibernatePersonStore.class));
+
+ // Configure Hibernate session listener.
+ cacheCfg.setCacheStoreSessionListenerFactories(new Factory<CacheStoreSessionListener>() {
+ @Override public CacheStoreSessionListener create() {
+ CacheHibernateStoreSessionListener lsnr = new CacheHibernateStoreSessionListener();
+
+ lsnr.setHibernateConfigurationPath(HIBERNATE_CFG);
+
+ return lsnr;
+ }
+ });
+
+ cacheCfg.setReadThrough(true);
+ cacheCfg.setWriteThrough(true);
+
+ try (IgniteCache<Long, Person> cache = ignite.getOrCreateCache(cacheCfg)) {
+ // Make initial cache loading from persistent store. This is a
+ // distributed operation and will call CacheStore.loadCache(...)
+ // method on all nodes in topology.
+ loadCache(cache);
+
+ // Start transaction and execute several cache operations with
+ // read/write-through to persistent store.
+ executeTransaction(cache);
+ }
+ }
+ }
+
+ /**
+ * Makes initial cache loading.
+ *
+ * @param cache Cache to load.
+ */
+ private static void loadCache(IgniteCache<Long, Person> cache) {
+ long start = System.currentTimeMillis();
+
+ // Start loading cache from persistent store on all caching nodes.
+ cache.loadCache(null, ENTRY_COUNT);
+
+ long end = System.currentTimeMillis();
+
+ System.out.println(">>> Loaded " + cache.size() + " keys with backups in " + (end - start) + "ms.");
+ }
+
+ /**
+ * Executes transaction with read/write-through to persistent store.
+ *
+ * @param cache Cache to execute transaction on.
+ */
+ private static void executeTransaction(IgniteCache<Long, Person> cache) {
+ try (Transaction tx = Ignition.ignite().transactions().txStart()) {
+ Person val = cache.get(id);
+
+ System.out.println("Read value: " + val);
+
+ val = cache.getAndPut(id, new Person(id, "Isaac", "Newton"));
+
+ System.out.println("Overwrote old value: " + val);
+
+ val = cache.get(id);
+
+ System.out.println("Read value: " + val);
+
+ tx.commit();
+ }
+
+ System.out.println("Read value after commit: " + cache.get(id));
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml
new file mode 100644
index 0000000..035ab98
--- /dev/null
+++ b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping default-access="field">
+ <class name="org.apache.ignite.examples.datagrid.store.Person" table="PERSONS">
+ <!-- ID. -->
+ <id name="id"/>
+
+ <!-- We only map data we are interested in. -->
+ <property name="firstName"/>
+ <property name="lastName"/>
+ </class>
+</hibernate-mapping>
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml
new file mode 100644
index 0000000..80a43e7
--- /dev/null
+++ b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml
@@ -0,0 +1,41 @@
+<?xml version='1.0' encoding='utf-8'?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!DOCTYPE hibernate-configuration PUBLIC
+ "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+ "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
+
+<!--
+ Hibernate configuration.
+-->
+<hibernate-configuration>
+ <session-factory>
+ <!-- Database connection settings (private in-memory database). -->
+ <property name="connection.url">jdbc:h2:mem:example;DB_CLOSE_DELAY=-1</property>
+
+ <!-- Only validate the database schema on startup in production mode. -->
+ <property name="hbm2ddl.auto">update</property>
+
+ <!-- Do not output SQL. -->
+ <property name="show_sql">false</property>
+
+ <!-- Mappings. -->
+ <mapping resource="org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml"/>
+ </session-factory>
+</hibernate-configuration>
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/package-info.java b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/package-info.java
new file mode 100644
index 0000000..7210b49
--- /dev/null
+++ b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 description. -->
+ * Contains Hibernate-based cache store implementation.
+ */
+package org.apache.ignite.examples.datagrid.store.hibernate;
[18/50] [abbrv] ignite git commit: ignite-1559:
UriDeploymentHttpScanner tests and javadoc
Posted by vo...@apache.org.
ignite-1559: UriDeploymentHttpScanner tests and javadoc
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/02b59e43
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/02b59e43
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/02b59e43
Branch: refs/heads/ignite-1651
Commit: 02b59e433bce7a4c3eece7a80e7a053ae0d69373
Parents: a228c24
Author: Artem SHutak <as...@gridgain.com>
Authored: Thu Oct 15 17:18:15 2015 -0700
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Thu Oct 15 17:18:15 2015 -0700
----------------------------------------------------------------------
.../ignite/spi/deployment/DeploymentSpi.java | 8 +-
modules/core/src/test/config/tests.properties | 3 +
modules/extdata/uri/pom.xml | 11 +-
.../spi/deployment/uri/UriDeploymentSpi.java | 93 ++++++++-----
.../scanners/http/UriDeploymentHttpScanner.java | 10 +-
.../http/GridHttpDeploymentSelfTest.java | 132 +++++++++++++++++--
6 files changed, 204 insertions(+), 53 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/02b59e43/modules/core/src/main/java/org/apache/ignite/spi/deployment/DeploymentSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/deployment/DeploymentSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/deployment/DeploymentSpi.java
index 7a1f709..af09e48 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/deployment/DeploymentSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/deployment/DeploymentSpi.java
@@ -46,13 +46,13 @@ import org.jetbrains.annotations.Nullable;
* local deployment.
* </strong>
* <p>
- * Ignite provides the following {@code GridDeploymentSpi} implementations:
+ * Ignite provides following {@code GridDeploymentSpi} implementations out of the box:
* <ul>
* <li>{@link org.apache.ignite.spi.deployment.local.LocalDeploymentSpi}</li>
* <li>{@ignitelink org.apache.ignite.spi.deployment.uri.UriDeploymentSpi}</li>
* </ul>
- * <b>NOTE:</b> this SPI (i.e. methods in this interface) should never be used directly. SPIs provide
- * internal view on the subsystem and is used internally by Ignite kernal. In rare use cases when
+ * <b>NOTE:</b> SPI methods should never be used directly. SPIs provide
+ * internal view on the subsystem and is used internally by Ignite. In rare use cases when
* access to a specific implementation of this SPI is required - an instance of this SPI can be obtained
* via {@link org.apache.ignite.Ignite#configuration()} method to check its configuration properties or call other non-SPI
* methods. Note again that calling methods from this interface on the obtained instance can lead
@@ -104,4 +104,4 @@ public interface DeploymentSpi extends IgniteSpi {
* @param lsnr Listener for deployment events. {@code null} to unset the listener.
*/
public void setListener(@Nullable DeploymentListener lsnr);
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/02b59e43/modules/core/src/test/config/tests.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/test/config/tests.properties b/modules/core/src/test/config/tests.properties
index ce6d4d8..49e616e 100644
--- a/modules/core/src/test/config/tests.properties
+++ b/modules/core/src/test/config/tests.properties
@@ -67,7 +67,10 @@ ant.gar.srcdir=@{IGNITE_HOME}/modules/extdata/uri/target/classes/
# GAR paths to use in URI deployment SPI tests
ant.urideployment.gar.uri=file://freq=5000@localhost/EXTDATA/uri/target/deploy
ant.urideployment.gar.file=modules/extdata/uri/target/deploy/uri.gar
+ant.urideployment.gar.libs-file=modules/extdata/uri/target/deploy/uri-libs.gar
+ant.urideployment.gar.classes-file=modules/extdata/uri/target/deploy/uri-classes.gar
ant.urideployment.gar.path=modules/extdata/uri/target/deploy/
+ant.urideployment.gar.path.tmp=modules/extdata/uri/target/deploy_tmp/
# Classpath directory for GridP2PUserVersionChangeSelfTest
ant.userversion.class.dir=@{IGNITE_HOME}/modules/tests/java/
http://git-wip-us.apache.org/repos/asf/ignite/blob/02b59e43/modules/extdata/uri/pom.xml
----------------------------------------------------------------------
diff --git a/modules/extdata/uri/pom.xml b/modules/extdata/uri/pom.xml
index d9a9297..d5e6349 100644
--- a/modules/extdata/uri/pom.xml
+++ b/modules/extdata/uri/pom.xml
@@ -144,14 +144,23 @@
</fileset>
</copy>
- <copy file="${settings.localRepository}/com/sun/mail/javax.mail/1.5.2/javax.mail-1.5.2.jar" todir="${basedir}/target/classes/lib" />
+ <copy file="${settings.localRepository}/com/sun/mail/javax.mail/1.5.2/javax.mail-1.5.2.jar" todir="${basedir}/target/libs" />
<zip destfile="${basedir}/target/classes/lib/depend.jar" encoding="UTF-8">
<zipfileset dir="modules/uri-dependency/target/classes" />
</zip>
+ <copy file="${basedir}/target/classes/lib/depend.jar" todir="${basedir}/target/libs" />
+
+ <mkdir dir="${basedir}/target/deploy_tmp/"/>
+
<taskdef name="gar" classname="org.apache.ignite.util.antgar.IgniteDeploymentGarAntTask" />
+ <gar destfile="${basedir}/target/deploy/uri-classes.gar" basedir="${basedir}/target/classes" />
+ <gar destfile="${basedir}/target/deploy/uri-libs.gar" basedir="${basedir}/target/libs" />
+
+ <copy file="${settings.localRepository}/com/sun/mail/javax.mail/1.5.2/javax.mail-1.5.2.jar" todir="${basedir}/target/classes/lib" />
+
<gar destfile="${basedir}/target/deploy/uri.gar" basedir="${basedir}/target/classes" />
<!--
http://git-wip-us.apache.org/repos/asf/ignite/blob/02b59e43/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/UriDeploymentSpi.java
----------------------------------------------------------------------
diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/UriDeploymentSpi.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/UriDeploymentSpi.java
index c48398d..5f65731 100644
--- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/UriDeploymentSpi.java
+++ b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/UriDeploymentSpi.java
@@ -80,7 +80,7 @@ import org.jetbrains.annotations.Nullable;
* <p>
* SPI tracks all changes of every given URI. This means that if any file is
* changed or deleted, SPI will re-deploy or delete corresponding tasks.
- * Note that the very first apply to {@link #findResource(String)} findClassLoader(String)}
+ * Note that the very first apply to {@link #findResource(String)}
* is blocked until SPI finishes scanning all URI's at least once.
* <p>
* There are several deployable unit types supported:
@@ -145,11 +145,33 @@ import org.jetbrains.annotations.Nullable;
* URI 'path' field will be automatically encoded. By default this flag is
* set to {@code true}.
* <p>
+ * <h1 class="header">Code Example</h1>
+ * The following example demonstrates how the deployment SPI can be used. It expects that you have a GAR file
+ * in 'home/username/ignite/work/my_deployment/file' folder which contains 'myproject.HelloWorldTask' class.
+ * <pre name="code" class="java">
+ * IgniteConfiguration cfg = new IgniteConfiguration();
+ *
+ * DeploymentSpi deploymentSpi = new UriDeploymentSpi();
+ *
+ * deploymentSpi.setUriList(Arrays.asList("file:///home/username/ignite/work/my_deployment/file"));
+ *
+ * cfg.setDeploymentSpi(deploymentSpi);
+ *
+ * try (Ignite ignite = Ignition.start(cfg)) {
+ * ignite.compute().execute("myproject.HelloWorldTask", "my args");
+ * }
+ * </pre>
* <h1 class="header">Configuration</h1>
* {@code UriDeploymentSpi} has the following optional configuration
* parameters (there are no mandatory parameters):
* <ul>
* <li>
+ * Array of {@link UriDeploymentScanner}-s which will be used to deploy resources
+ * (see {@link #setScanners(UriDeploymentScanner...)}). If not specified, preconfigured {@link UriDeploymentFileScanner}
+ * and {@link UriDeploymentHttpScanner} are used. You can implement your own scanner
+ * by implementing {@link UriDeploymentScanner} interface.
+ * </li>
+ * <li>
* Temporary directory path where scanned GAR files and directories are
* copied to (see {@link #setTemporaryDirectoryPath(String) setTemporaryDirectoryPath(String)}).
* </li>
@@ -163,25 +185,28 @@ import org.jetbrains.annotations.Nullable;
* </li>
* </ul>
* <h1 class="header">Protocols</h1>
- * Following protocols are supported in SPI:
+ * Following protocols are supported by this SPI out of the box:
* <ul>
* <li><a href="#file">file://</a> - File protocol</li>
- * <li><a href="#classes">classes://</a> - Custom File protocol.</li>
* <li><a href="#http">http://</a> - HTTP protocol</li>
* <li><a href="#http">https://</a> - Secure HTTP protocol</li>
* </ul>
+ * <strong>Custom Protocols.</strong>
+ * <p>
+ * You can add support for additional protocols if needed. To do this implement UriDeploymentScanner interface and
+ * plug your implementation into the SPI via {@link #setScanners(UriDeploymentScanner...)} method.
+ * <p>
* In addition to SPI configuration parameters, all necessary configuration
* parameters for selected URI should be defined in URI. Different protocols
* have different configuration parameters described below. Parameters are
* separated by '{@code ;}' character.
* <p>
- * <a name="file"></a>
* <h1 class="header">File</h1>
* For this protocol SPI will scan folder specified by URI on file system and
* download any GAR files or directories that end with .gar from source
* directory defined in URI. For file system URI must have scheme equal to {@code file}.
* <p>
- * Following parameters are supported for FILE protocol:
+ * Following parameters are supported:
* <table class="doctable">
* <tr>
* <th>Parameter</th>
@@ -189,24 +214,29 @@ import org.jetbrains.annotations.Nullable;
* <th>Optional</th>
* <th>Default</th>
* </tr>
+ * <tr>
+ * <td>freq</td>
+ * <td>Scanning frequency in milliseconds.</td>
+ * <td>Yes</td>
+ * <td>{@code 5000} ms specified in {@link UriDeploymentFileScanner#DFLT_SCAN_FREQ}.</td>
+ * </tr>
* </table>
* <h2 class="header">File URI Example</h2>
* The following example will scan {@code 'c:/Program files/ignite/deployment'}
- * folder on local box every {@code '5000'} milliseconds. Note that since path
+ * folder on local box every {@code '1000'} milliseconds. Note that since path
* has spaces, {@link #setEncodeUri(boolean) setEncodeUri(boolean)} parameter must
* be set to {@code true} (which is default behavior).
* <blockquote class="snippet">
- * {@code file://freq=5000@localhost/c:/Program files/ignite/deployment}
+ * {@code file://freq=2000@localhost/c:/Program files/ignite/deployment}
* </blockquote>
* <a name="classes"></a>
- * <h1 class="header">Classes</h1>
- * For this protocol SPI will scan folder specified by URI on file system
- * looking for compiled classes that implement {@link org.apache.ignite.compute.ComputeTask} interface.
- * This protocol comes very handy during development, as it allows developer
- * to specify IDE compilation output folder as URI and all task classes
- * in that folder will be deployed automatically.
+ * <h2 class="header">HTTP/HTTPS</h2>
+ * URI deployment scanner tries to read DOM of the html it points to and parses out href attributes of all <a> tags
+ * - this becomes the collection of URLs to GAR files that should be deployed. It's important that HTTP scanner
+ * uses {@code URLConnection.getLastModified()} method to check if there were any changes since last iteration
+ * for each GAR-file before redeploying.
* <p>
- * Following parameters are supported for CLASSES protocol:
+ * Following parameters are supported:
* <table class="doctable">
* <tr>
* <th>Parameter</th>
@@ -214,20 +244,17 @@ import org.jetbrains.annotations.Nullable;
* <th>Optional</th>
* <th>Default</th>
* </tr>
+ * <tr>
+ * <td>freq</td>
+ * <td>Scanning frequency in milliseconds.</td>
+ * <td>Yes</td>
+ * <td>{@code 300000} ms specified in {@link UriDeploymentHttpScanner#DFLT_SCAN_FREQ}.</td>
+ * </tr>
* </table>
- * <h2 class="header">Classes URI Example</h2>
- * The following example will scan {@code 'c:/Program files/ignite/deployment'}
- * folder on local box every {@code '5000'} milliseconds. Note that since path
- * has spaces, {@link #setEncodeUri(boolean) setEncodeUri(boolean)} parameter must
- * be set to {@code true} (which is default behavior).
- * <blockquote class="snippet">
- * {@code classes://freq=5000@localhost/c:/Program files/ignite/deployment}
- * </blockquote>
- * <a name="http"></a>
* <h2 class="header">HTTP URI Example</h2>
- * The following example will scan {@code 'ignite/deployment'} folder with
- * on site {@code 'www.mysite.com'} using authentication
- * {@code 'username:password'} every {@code '10000'} milliseconds.
+ * The following example will download the page `www.mysite.com/ignite/deployment`, parse it and download and deploy
+ * all GAR files specified by href attributes of <a> elements on the page using authentication
+ * {@code 'username:password'} every '10000' milliseconds (only new/updated GAR-s).
* <blockquote class="snippet">
* {@code http://username:password;freq=10000@www.mysite.com:110/ignite/deployment}
* </blockquote>
@@ -238,14 +265,9 @@ import org.jetbrains.annotations.Nullable;
*
* IgniteConfiguration cfg = new IgniteConfiguration();
*
- * List<String> uris = new ArrayList<String>(5);
- *
- * uris.add("http://www.site.com/tasks");
- * uris.add("file://freq=20000@localhost/c:/Program files/gg-deployment");
- * uris.add("classes:///c:/Java_Projects/myproject/out");
- *
* // Set URIs.
- * deploySpi.setUriList(uris);
+ * deploySpi.setUriList(Arrays.asList("http://www.site.com/tasks",
+ * "file://freq=20000@localhost/c:/Program files/gg-deployment"));
*
* // Override temporary directory path.
* deploySpi.setTemporaryDirectoryPath("c:/tmp/grid");
@@ -254,7 +276,7 @@ import org.jetbrains.annotations.Nullable;
* cfg.setDeploymentSpi(deploySpi);
*
* // Start grid.
- * G.start(cfg);
+ * Ignition.start(cfg);
* </pre>
* <p>
* <h2 class="header">Spring Example</h2>
@@ -269,7 +291,6 @@ import org.jetbrains.annotations.Nullable;
* <list>
* <value>http://www.site.com/tasks</value>
* <value>file://freq=20000@localhost/c:/Program files/gg-deployment</value>
- * <value>classes:///c:/Java_Projects/myproject/out</value>
* </list>
* </property>
* </bean>
@@ -1325,4 +1346,4 @@ public class UriDeploymentSpi extends IgniteSpiAdapter implements DeploymentSpi,
@Override public String toString() {
return S.toString(UriDeploymentSpi.class, this);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/02b59e43/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/http/UriDeploymentHttpScanner.java
----------------------------------------------------------------------
diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/http/UriDeploymentHttpScanner.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/http/UriDeploymentHttpScanner.java
index ef29752..48bfd7f 100644
--- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/http/UriDeploymentHttpScanner.java
+++ b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/http/UriDeploymentHttpScanner.java
@@ -60,11 +60,15 @@ import org.w3c.dom.NodeList;
import org.w3c.tidy.Tidy;
/**
- * URI deployment HTTP scanner.
+ * HTTP-based URI deployment scanner.
+ * <p>
+ * This scanner reads DOM of the HTML available via {@link UriDeploymentScannerContext#getUri()}
+ * and parses out href attributes of all {@code <a>} tags -
+ * they become the collection of URLs to GAR files that should be deployed.
*/
public class UriDeploymentHttpScanner implements UriDeploymentScanner {
/** Default scan frequency. */
- private static final int DFLT_SCAN_FREQ = 300000;
+ public static final int DFLT_SCAN_FREQ = 300000;
/** Secure socket protocol to use. */
private static final String PROTOCOL = "TLS";
@@ -501,4 +505,4 @@ public class UriDeploymentHttpScanner implements UriDeploymentScanner {
return true;
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/02b59e43/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/http/GridHttpDeploymentSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/http/GridHttpDeploymentSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/http/GridHttpDeploymentSelfTest.java
index 216d0ab..c0044c3 100644
--- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/http/GridHttpDeploymentSelfTest.java
+++ b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/http/GridHttpDeploymentSelfTest.java
@@ -17,6 +17,8 @@
package org.apache.ignite.spi.deployment.uri.scanners.http;
+import java.io.File;
+import java.io.IOException;
import java.util.Collections;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
@@ -38,8 +40,35 @@ import static org.eclipse.jetty.http.HttpHeader.LAST_MODIFIED;
*/
@GridSpiTest(spi = UriDeploymentSpi.class, group = "Deployment SPI")
public class GridHttpDeploymentSelfTest extends GridUriDeploymentAbstractSelfTest {
+ /** Frequency */
+ private static final int FREQ = 5000;
+
+ /** */
+ public static final String LIBS_GAR = "libs-file.gar";
+
+ /** */
+ public static final String CLASSES_GAR = "classes-file.gar";
+
+ /** */
+ public static final String ALL_GAR = "file.gar";
+
+ /** Gar-file which contains libs. */
+ public static final String LIBS_GAR_FILE_PATH = U.resolveIgnitePath(
+ GridTestProperties.getProperty("ant.urideployment.gar.libs-file")).getPath();
+
+ /** Gar-file which contains classes (cannot be used without libs). */
+ public static final String CLASSES_GAR_FILE_PATH = U.resolveIgnitePath(
+ GridTestProperties.getProperty("ant.urideployment.gar.classes-file")).getPath();
+
+ /** Gar-file which caontains both libs and classes. */
+ public static final String ALL_GAR_FILE_PATH = U.resolveIgnitePath(
+ GridTestProperties.getProperty("ant.urideployment.gar.file")).getPath();
+
/** Jetty. */
- private Server srv;
+ private static Server srv;
+
+ /** Resource base. */
+ private static String rsrcBase;
/** {@inheritDoc} */
@Override protected void beforeSpiStarted() throws Exception {
@@ -60,8 +89,12 @@ public class GridHttpDeploymentSelfTest extends GridUriDeploymentAbstractSelfTes
};
hnd.setDirectoriesListed(true);
- hnd.setResourceBase(
- U.resolveIgnitePath(GridTestProperties.getProperty("ant.urideployment.gar.path")).getPath());
+
+ File resourseBaseDir = U.resolveIgnitePath(GridTestProperties.getProperty("ant.urideployment.gar.path.tmp"));
+
+ rsrcBase = resourseBaseDir.getPath();
+
+ hnd.setResourceBase(rsrcBase);
srv.setHandler(hnd);
@@ -82,11 +115,63 @@ public class GridHttpDeploymentSelfTest extends GridUriDeploymentAbstractSelfTes
}
/**
- * @throws Exception if failed.
+ * @throws Exception If failed.
*/
- public void testDeployment() throws Exception {
- checkTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask3");
- checkTask("GridUriDeploymentTestWithNameTask3");
+ public void testDeployUndeploy2Files() throws Exception {
+ checkNoTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask3");
+
+ try {
+ copyToResourceBase(LIBS_GAR_FILE_PATH, LIBS_GAR);
+
+ copyToResourceBase(CLASSES_GAR_FILE_PATH, CLASSES_GAR);
+
+ Thread.sleep(FREQ + 3000);
+
+ checkTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask3");
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ finally {
+ deleteFromResourceBase(LIBS_GAR);
+ deleteFromResourceBase(CLASSES_GAR);
+
+ Thread.sleep(FREQ + 3000);
+
+ checkNoTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask3");
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testSameContantFiles() throws Exception {
+ checkNoTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask3");
+
+ try {
+ copyToResourceBase(ALL_GAR_FILE_PATH, ALL_GAR);
+
+ Thread.sleep(FREQ + 3000);
+
+ checkTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask3");
+
+ copyToResourceBase(ALL_GAR_FILE_PATH, "file-copy.gar");
+
+ Thread.sleep(FREQ + 3000);
+
+ checkTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask3");
+ }
+ catch (Throwable e) {
+ e.printStackTrace();
+ }
+ finally {
+ deleteFromResourceBase(ALL_GAR);
+ deleteFromResourceBase("file-copy.gar");
+
+ Thread.sleep(FREQ + 3000);
+
+ checkNoTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask3");
+ }
}
/**
@@ -94,6 +179,35 @@ public class GridHttpDeploymentSelfTest extends GridUriDeploymentAbstractSelfTes
*/
@GridSpiTestConfig
public List<String> getUriList() {
- return Collections.singletonList("http://freq=5000@localhost:8080/");
+ return Collections.singletonList("http://freq="+FREQ+"@localhost:8080/");
+ }
+
+ /**
+ * @param fileName File name.
+ */
+ private void deleteFromResourceBase(String fileName) {
+ File file = new File(rsrcBase + '/' + fileName);
+
+ if (!file.delete())
+ U.warn(log, "Could not delete file: " + file);
+ }
+
+ /**
+ * @param path Path to the file which should be copied.
+ * @param newFileName New file name.
+ * @throws IOException If exception.
+ */
+ private void copyToResourceBase(String path, String newFileName) throws IOException {
+ File file = new File(path);
+
+ assert file.exists() : "Test file not found [path=" + path + ']';
+
+ File newFile = new File(rsrcBase + '/' + newFileName);
+
+ assert !newFile.exists();
+
+ U.copy(file, newFile, false);
+
+ assert newFile.exists();
}
-}
\ No newline at end of file
+}
[50/50] [abbrv] ignite git commit: IGNITE-1651: Finalization.
Posted by vo...@apache.org.
IGNITE-1651: Finalization.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/03cbca56
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/03cbca56
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/03cbca56
Branch: refs/heads/ignite-1651
Commit: 03cbca56fa85adfe4150929420ab9739ab243af3
Parents: ec58b87
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Oct 22 12:25:35 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Oct 22 12:25:35 2015 +0300
----------------------------------------------------------------------
.../Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs | 2 +-
.../dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs | 2 +-
.../Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/03cbca56/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs
index 2bf5ab8..9df180d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs
@@ -186,7 +186,7 @@ namespace Apache.Ignite.Core.Impl.Portable
{
IPortableStream stream = new PortableHeapStream(_data);
- stream.Seek(_offset + PortableUtils.OffsetRawOff, SeekOrigin.Begin);
+ stream.Seek(_offset + PortableUtils.OffsetRaw, SeekOrigin.Begin);
int rawDataOffset = stream.ReadInt();
http://git-wip-us.apache.org/repos/asf/ignite/blob/03cbca56/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
index 6d07757..15466d5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
@@ -66,7 +66,7 @@ namespace Apache.Ignite.Core.Impl.Portable
public const int OffsetLen = 11;
/** Offset: raw data offset. */
- public const int OffsetRawOff = 15;
+ public const int OffsetRaw = 15;
/** Type: object. */
public const byte TypeObject = HdrFull;
http://git-wip-us.apache.org/repos/asf/ignite/blob/03cbca56/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
index 6146362..5a66a0f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
@@ -1227,8 +1227,8 @@ namespace Apache.Ignite.Core.Impl.Portable
// Calculate and write length.
int len = _stream.Position - pos;
- _stream.Seek(pos + PU.OffsetLen, SeekOrigin.Begin);
-
+ _stream.WriteInt(pos + PU.OffsetLen, len);
+
if (_curRawPos != 0)
_stream.WriteInt(pos + PU.OffsetRaw, (int)(_curRawPos - pos));
else
[14/50] [abbrv] ignite git commit: fix compilation under java7
Posted by vo...@apache.org.
fix compilation under java7
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4d1c0266
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4d1c0266
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4d1c0266
Branch: refs/heads/ignite-1651
Commit: 4d1c02669602bef6e696494ccd7382c967d2f962
Parents: 077af17
Author: ashutak <as...@gridgain.com>
Authored: Thu Oct 15 17:09:27 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Thu Oct 15 17:09:27 2015 +0300
----------------------------------------------------------------------
.../CacheNearDisabledTransactionalWriteReadRestartSelfTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4d1c0266/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalWriteReadRestartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalWriteReadRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalWriteReadRestartSelfTest.java
index 875aef3..148a95db 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalWriteReadRestartSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalWriteReadRestartSelfTest.java
@@ -69,7 +69,7 @@ public class CacheNearDisabledTransactionalWriteReadRestartSelfTest extends Cach
}
/** {@inheritDoc} */
- @Override protected void updateCache(IgniteEx ignite, IgniteCache cache) throws Exception {
+ @Override protected void updateCache(IgniteEx ignite, final IgniteCache cache) throws Exception {
final int k = ThreadLocalRandom.current().nextInt(RANGE);
final String[] keys = new String[KEYS_CNT];
[47/50] [abbrv] ignite git commit: Merge branch 'ignite-1282' into
ignite-1651
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ec58b87c/modules/platforms/cpp/core/include/ignite/impl/portable/portable_reader_impl.h
----------------------------------------------------------------------
diff --cc modules/platforms/cpp/core/include/ignite/impl/portable/portable_reader_impl.h
index 0000000,5050a04..08b8fe1
mode 000000,100644..100644
--- a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_reader_impl.h
+++ b/modules/platforms/cpp/core/include/ignite/impl/portable/portable_reader_impl.h
@@@ -1,0 -1,1234 +1,1246 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ #ifndef _IGNITE_IMPL_PORTABLE_READER
+ #define _IGNITE_IMPL_PORTABLE_READER
+
+ #include <stdint.h>
+
+ #include <ignite/common/common.h>
+
+ #include "ignite/impl/interop/interop_input_stream.h"
+ #include "ignite/impl/portable/portable_common.h"
+ #include "ignite/impl/portable/portable_id_resolver.h"
+ #include "ignite/impl/portable/portable_utils.h"
+ #include "ignite/impl/utils.h"
+ #include "ignite/portable/portable_consts.h"
+ #include "ignite/portable/portable_type.h"
+ #include "ignite/guid.h"
+
+ namespace ignite
+ {
+ namespace impl
+ {
+ namespace portable
+ {
+ /**
+ * Internal implementation of portable reader.
+ */
+ class IGNITE_IMPORT_EXPORT PortableReaderImpl
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param stream Interop stream.
+ * @param idRslvr Portable ID resolver.
+ * @param pos Object position in the stream.
+ * @param usrType user type flag.
+ * @param typeId Type ID.
+ * @param hashcode Hash code.
+ * @param len Length in bytes.
+ * @param rawOff Raw data offset.
+ */
+ PortableReaderImpl(interop::InteropInputStream* stream, PortableIdResolver* idRslvr,
+ int32_t pos, bool usrType, int32_t typeId, int32_t hashCode, int32_t len, int32_t rawOff);
+
+ /**
+ * Constructor used to construct light-weight reader allowing only raw operations
+ * and read of primitives.
+ *
+ * @param stream Interop stream.
+ */
+ PortableReaderImpl(interop::InteropInputStream* stream);
+
+ /**
+ * Read 8-byte signed integer. Maps to "byte" type in Java.
+ *
+ * @return Result.
+ */
+ int8_t ReadInt8();
+
+ /**
+ * Read array of 8-byte signed integers. Maps to "byte[]" type in Java.
+ *
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadInt8Array(int8_t* res, const int32_t len);
+
+ /**
+ * Read 8-byte signed integer. Maps to "byte" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ int8_t ReadInt8(const char* fieldName);
+
+ /**
+ * Read array of 8-byte signed integers. Maps to "byte[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadInt8Array(const char* fieldName, int8_t* res, const int32_t len);
+
+ /**
+ * Read bool. Maps to "boolean" type in Java.
+ *
+ * @return Result.
+ */
+ bool ReadBool();
+
+ /**
+ * Read bool array. Maps to "boolean[]" type in Java.
+ *
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadBoolArray(bool* res, const int32_t len);
+
+ /**
+ * Read bool. Maps to "short" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ bool ReadBool(const char* fieldName);
+
+ /**
+ * Read bool array. Maps to "bool[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadBoolArray(const char* fieldName, bool* res, const int32_t len);
+
+ /**
+ * Read 16-byte signed integer. Maps to "short" type in Java.
+ *
+ * @return Result.
+ */
+ int16_t ReadInt16();
+
+ /**
+ * Read array of 16-byte signed integers. Maps to "short[]" type in Java.
+ *
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadInt16Array(int16_t* res, const int32_t len);
+
+ /**
+ * Read 16-byte signed integer. Maps to "short" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ int16_t ReadInt16(const char* fieldName);
+
+ /**
+ * Read array of 16-byte signed integers. Maps to "short[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadInt16Array(const char* fieldName, int16_t* res, const int32_t len);
+
+ /**
+ * Read 16-byte unsigned integer. Maps to "char" type in Java.
+ *
+ * @return Result.
+ */
+ uint16_t ReadUInt16();
+
+ /**
+ * Read array of 16-byte unsigned integers. Maps to "char[]" type in Java.
+ *
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadUInt16Array(uint16_t* res, const int32_t len);
+
+ /**
+ * Read 16-byte unsigned integer. Maps to "char" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ uint16_t ReadUInt16(const char* fieldName);
+
+ /**
+ * Read array of 16-byte unsigned integers. Maps to "char[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadUInt16Array(const char* fieldName, uint16_t* res, const int32_t len);
+
+ /**
+ * Read 32-byte signed integer. Maps to "int" type in Java.
+ *
+ * @return Result.
+ */
+ int32_t ReadInt32();
+
+ /**
+ * Read array of 32-byte signed integers. Maps to "int[]" type in Java.
+ *
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadInt32Array(int32_t* res, const int32_t len);
+
+ /**
+ * Read 32-byte signed integer. Maps to "int" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ int32_t ReadInt32(const char* fieldName);
+
+ /**
+ * Read array of 32-byte signed integers. Maps to "int[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadInt32Array(const char* fieldName, int32_t* res, const int32_t len);
+
+ /**
+ * Read 64-byte signed integer. Maps to "long" type in Java.
+ *
+ * @return Result.
+ */
+ int64_t ReadInt64();
+
+ /**
+ * Read array of 64-byte signed integers. Maps to "long[]" type in Java.
+ *
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadInt64Array(int64_t* res, const int32_t len);
+
+ /**
+ * Read 64-byte signed integer. Maps to "long" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ int64_t ReadInt64(const char* fieldName);
+
+ /**
+ * Read array of 64-byte signed integers. Maps to "long[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadInt64Array(const char* fieldName, int64_t* res, const int32_t len);
+
+ /**
+ * Read float. Maps to "float" type in Java.
+ *
+ * @return Result.
+ */
+ float ReadFloat();
+
+ /**
+ * Read float array. Maps to "float[]" type in Java.
+ *
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadFloatArray(float* res, const int32_t len);
+
+ /**
+ * Read float. Maps to "float" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ float ReadFloat(const char* fieldName);
+
+ /**
+ * Read float array. Maps to "float[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadFloatArray(const char* fieldName, float* res, const int32_t len);
+
+ /**
+ * Read double. Maps to "double" type in Java.
+ *
+ * @return Result.
+ */
+ double ReadDouble();
+
+ /**
+ * Read double array. Maps to "double[]" type in Java.
+ *
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadDoubleArray(double* res, const int32_t len);
+
+ /**
+ * Read double. Maps to "double" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ double ReadDouble(const char* fieldName);
+
+ /**
+ * Read double array. Maps to "double[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadDoubleArray(const char* fieldName, double* res, const int32_t len);
+
+ /**
+ * Read Guid. Maps to "UUID" type in Java.
+ *
+ * @return Result.
+ */
+ Guid ReadGuid();
+
+ /**
+ * Read array of Guids. Maps to "UUID[]" type in Java.
+ *
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadGuidArray(Guid* res, const int32_t len);
+
+ /**
+ * Read Guid. Maps to "UUID" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ Guid ReadGuid(const char* fieldName);
+
+ /**
+ * Read array of Guids. Maps to "UUID[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadGuidArray(const char* fieldName, Guid* res, const int32_t len);
+
+ /**
+ * Read string.
+ *
+ * @param len Expected length of string.
+ * @param res Array to store data to (should be able to acocmodate null-terminator).
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadString(char* res, const int32_t len);
+
+ /**
+ * Read string.
+ *
+ * @param fieldName Field name.
+ * @param res Array to store data to (should be able to acocmodate null-terminator).
+ * @param len Expected length of string.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadString(const char* fieldName, char* res, const int32_t len);
+
+ /**
+ * Start string array read.
+ *
+ * @param size Array size.
+ * @return Read session ID.
+ */
+ int32_t ReadStringArray(int32_t* size);
+
+ /**
+ * Start string array read.
+ *
+ * @param fieldName Field name.
+ * @param size Array size.
+ * @return Read session ID.
+ */
+ int32_t ReadStringArray(const char* fieldName, int32_t* size);
+
+ /**
+ * Read string element.
+ *
+ * @param id Session ID.
+ * @param len Expected length of string.
+ * @param res Array to store data to (should be able to acocmodate null-terminator).
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadStringElement(int32_t id, char* res, const int32_t len);
+
+ /**
+ * Start array read.
+ *
+ * @param size Array size.
+ * @return Read session ID.
+ */
+ int32_t ReadArray(int32_t* size);
+
+ /**
+ * Start array read.
+ *
+ * @param fieldName Field name.
+ * @param size Array size.
+ * @return Read session ID.
+ */
+ int32_t ReadArray(const char* fieldName, int32_t* size);
+
+ /**
+ * Start collection read.
+ *
+ * @param typ Collection type.
+ * @param size Collection size.
+ * @return Read session ID.
+ */
+ int32_t ReadCollection(ignite::portable::CollectionType* typ, int32_t* size);
+
+ /**
+ * Start collection read.
+ *
+ * @param fieldName Field name.
+ * @param typ Collection type.
+ * @param size Collection size.
+ * @return Read session ID.
+ */
+ int32_t ReadCollection(const char* fieldName, ignite::portable::CollectionType* typ, int32_t* size);
+
+ /**
+ * Read values and insert them to specified position.
+ *
+ * @param out Output iterator to the initial position in the destination sequence.
+ * @return Actual amount of elements read.
+ */
+ template<typename T, typename OutputIterator>
+ int32_t ReadCollection(OutputIterator out)
+ {
+ int32_t size;
+ int32_t id = StartContainerSession(true, IGNITE_TYPE_COLLECTION, &size);
+
+ // Reading collection type. We don't need it here but it should be read.
+ if (size != -1)
+ stream->ReadInt8();
+
+ while (HasNextElement(id))
+ {
+ *out = ReadElement<T>(id);
+ ++out;
+ }
+
+ return size;
+ }
+
+ /**
+ * Read values and insert them to specified position.
+ *
+ * @param fieldName Field name.
+ * @param out Output iterator to the initial position in the destination sequence.
+ * @return Actual amount of elements read.
+ */
+ template<typename T, typename OutputIterator>
+ int32_t ReadCollection(const char* fieldName, OutputIterator out)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+ int32_t fieldLen = SeekField(fieldId);
+
+ if (fieldLen <= 0)
+ return -1;
+
+ int32_t size;
+ int32_t id = StartContainerSession(false, IGNITE_TYPE_COLLECTION, &size);
+
+ // Reading collection type. We don't need it here but it should be read.
+ if (size != -1)
+ stream->ReadInt8();
+
+ while (HasNextElement(id))
+ {
+ *out = ReadElement<T>(id);
+ ++out;
+ }
+
+ return size;
+ }
+
+ /**
+ * Start map read.
+ *
+ * @param typ Map type.
+ * @param size Map size.
+ * @return Read session ID.
+ */
+ int32_t ReadMap(ignite::portable::MapType* typ, int32_t* size);
+
+ /**
+ * Start map read.
+ *
+ * @param fieldName Field name.
+ * @param typ Map type.
+ * @param size Map size.
+ * @return Read session ID.
+ */
+ int32_t ReadMap(const char* fieldName, ignite::portable::MapType* typ, int32_t* size);
+
+ /**
+ * Read type of the collection.
+ *
+ * @return Collection type.
+ */
+ ignite::portable::CollectionType ReadCollectionType();
+
+ /**
+ * Read type of the collection.
+ *
+ * @param fieldName Field name.
+ * @return Collection type.
+ */
+ ignite::portable::CollectionType ReadCollectionType(const char* fieldName);
+
+ /**
+ * Read size of the collection.
+ *
+ * @return Collection size.
+ */
+ int32_t ReadCollectionSize();
+
+ /**
+ * Read size of the collection.
+ *
+ * @param fieldName Field name.
+ * @return Collection size.
+ */
+ int32_t ReadCollectionSize(const char* fieldName);
+
+ /**
+ * Check whether next value exists.
+ *
+ * @param id Session ID.
+ * @return True if next element exists for the given session.
+ */
+ bool HasNextElement(int32_t id) const;
+
+ /**
+ * Read element.
+ *
+ * @param id Session ID.
+ * @return Value.
+ */
+ template<typename T>
+ T ReadElement(const int32_t id)
+ {
+ CheckSession(id);
+
+ if (++elemRead == elemCnt) {
+ elemId = 0;
+ elemCnt = -1;
+ elemRead = 0;
+ }
+
+ return ReadTopObject<T>();
+ }
+
+ /**
+ * Read element.
+ *
+ * @param id Session ID.
+ * @param key Key.
+ * @param val Value.
+ */
+ template<typename K, typename V>
+ void ReadElement(const int32_t id, K* key, V* val)
+ {
+ CheckSession(id);
+
+ if (++elemRead == elemCnt) {
+ elemId = 0;
+ elemCnt = -1;
+ elemRead = 0;
+ }
+
+ *key = ReadTopObject<K>();
+ *val = ReadTopObject<V>();
+ }
+
+ /**
+ * Read object.
+ *
+ * @return Object.
+ */
+ template<typename T>
+ T ReadObject()
+ {
+ CheckRawMode(true);
+
+ return ReadTopObject<T>();
+ }
+
+ /**
+ * Read object.
+ *
+ * @param fieldName Field name.
+ * @return Object.
+ */
+ template<typename T>
+ T ReadObject(const char* fieldName)
+ {
+ CheckRawMode(false);
+
+ int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+
+ int32_t fieldLen = SeekField(fieldId);
+
+ if (fieldLen > 0)
+ return ReadTopObject<T>();
+
+ return GetNull<T>();
+ }
+
+ /**
+ * Set raw mode.
+ */
+ void SetRawMode();
+
+ /**
+ * Read object.
+ *
+ * @param obj Object to write.
+ */
+ template<typename T>
+ T ReadTopObject()
+ {
+ int32_t pos = stream->Position();
+ int8_t hdr = stream->ReadInt8();
+
+ if (hdr == IGNITE_HDR_NULL)
+ return GetNull<T>();
+ else if (hdr == IGNITE_HDR_HND) {
+ IGNITE_ERROR_1(ignite::IgniteError::IGNITE_ERR_PORTABLE, "Circular references are not supported.");
+ }
+ else if (hdr == IGNITE_TYPE_PORTABLE)
+ {
+ int32_t portLen = stream->ReadInt32(); // Total length of portable object.
+ int32_t curPos = stream->Position();
+ int32_t portOff = stream->ReadInt32(curPos + portLen);
+
+ stream->Position(curPos + portOff); // Position stream right on the object.
+
+ T val = ReadTopObject<T>();
+
+ stream->Position(curPos + portLen + 4); // Position stream after portable.
+
+ return val;
+ }
+ else
+ {
- bool usrType = stream->ReadBool();
- int32_t typeId = stream->ReadInt32();
- int32_t hashCode = stream->ReadInt32();
- int32_t len = stream->ReadInt32();
- int32_t rawOff = stream->ReadInt32();
-
- ignite::portable::PortableType<T> type;
- TemplatedPortableIdResolver<T> idRslvr(type);
- PortableReaderImpl readerImpl(stream, &idRslvr, pos, usrType, typeId, hashCode, len, rawOff);
- ignite::portable::PortableReader reader(&readerImpl);
-
- T val = type.Read(reader);
-
- stream->Position(pos + len);
-
- return val;
++ if (hdr != IGNITE_HDR_FULL) {
++ IGNITE_ERROR_2(ignite::IgniteError::IGNITE_ERR_PORTABLE, "Unexpected header during deserialization: ", hdr);
++ }
++ else {
++ int8_t protoVer = stream->ReadInt8();
++
++ if (protoVer != IGNITE_PROTO_VER) {
++ IGNITE_ERROR_2(ignite::IgniteError::IGNITE_ERR_PORTABLE, "Unsupported portable protocol version: ", protoVer);
++ }
++ else {
++ bool usrType = stream->ReadBool();
++ int32_t typeId = stream->ReadInt32();
++ int32_t hashCode = stream->ReadInt32();
++ int32_t len = stream->ReadInt32();
++ int32_t rawOff = stream->ReadInt32();
++
++ ignite::portable::PortableType<T> type;
++ TemplatedPortableIdResolver<T> idRslvr(type);
++ PortableReaderImpl readerImpl(stream, &idRslvr, pos, usrType, typeId, hashCode, len, rawOff);
++ ignite::portable::PortableReader reader(&readerImpl);
++
++ T val = type.Read(reader);
++
++ stream->Position(pos + len);
++
++ return val;
++ }
++ }
+ }
+ }
+
+ /**
+ * Get NULL value for the given type.
+ */
+ template<typename T>
+ T GetNull() const
+ {
+ ignite::portable::PortableType<T> type;
+
+ return type.GetNull();
+ }
+
+ /**
+ * Get underlying stream.
+ *
+ * @return Stream.
+ */
+ impl::interop::InteropInputStream* GetStream();
+ private:
+ /** Underlying stream. */
+ interop::InteropInputStream* stream;
+
+ /** ID resolver. */
+ PortableIdResolver* idRslvr;
+
+ /** Position in the stream where this object starts. */
+ int32_t pos;
+
+ /** Whether this is user type or system type. */
+ bool usrType;
+
+ /** Type ID as defined in the stream. */
+ int32_t typeId;
+
+ /** Hash code. */
+ int32_t hashCode;
+
+ /** Total object length in the stream. */
+ int32_t len;
+
+ /** Raw data offset. */
+ int32_t rawOff;
+
+ /** Raw mode flag. */
+ bool rawMode;
+
+ /** Elements read session ID generator. */
+ int32_t elemIdGen;
+
+ /** Elements read session ID. */
+ int32_t elemId;
+
+ /** Total amount of elements in collection. */
+ int32_t elemCnt;
+
+ /** Amount of elements read. */
+ int32_t elemRead;
+
+ IGNITE_NO_COPY_ASSIGNMENT(PortableReaderImpl)
+
+ /**
+ * Internal routine to read Guid array.
+ *
+ * @param stream Stream.
+ * @param res Resulting array.
+ * @param len Length.
+ */
+ static void ReadGuidArrayInternal(
+ interop::InteropInputStream* stream,
+ Guid* res,
+ const int32_t len
+ );
+
+ /**
+ * Read single value in raw mode.
+ *
+ * @param stream Stream.
+ * @param func Function to be invoked on stream.
+ * @return Result.
+ */
+ template<typename T>
+ T ReadRaw(
+ T(*func) (interop::InteropInputStream*)
+ )
+ {
+ {
+ CheckRawMode(true);
+ CheckSingleMode(true);
+
+ return func(stream);
+ }
+ }
+
+ /**
+ * Read single value.
+ *
+ * @param fieldName Field name.
+ * @param func Function to be invoked on stream.
+ * @param epxHdr Expected header.
+ * @param dflt Default value returned if field is not found.
+ * @return Result.
+ */
+ template<typename T>
+ T Read(
+ const char* fieldName,
+ T(*func) (interop::InteropInputStream*),
+ const int8_t expHdr,
+ T dflt
+ )
+ {
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+ int32_t fieldLen = SeekField(fieldId);
+
+ if (fieldLen > 0)
+ {
+ int8_t typeId = stream->ReadInt8();
+
+ if (typeId == expHdr)
+ return func(stream);
+ else if (typeId != IGNITE_HDR_NULL)
+ {
+ int32_t pos = stream->Position();
+
+ IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_PORTABLE, "Invalid type ID",
+ "position", pos, "expected", expHdr, "actual", typeId)
+ }
+ }
+
+ return dflt;
+ }
+ }
+
+ /**
+ * Read array in raw mode.
+ *
+ * @param res Resulting array.
+ * @param len Length.
+ * @param func Function to be invoked on stream.
+ * @param expHdr Expected header.
+ * @return Length.
+ */
+ template<typename T>
+ int32_t ReadRawArray(
+ T* res,
+ const int32_t len,
+ void(*func)(interop::InteropInputStream*, T* const, const int32_t),
+ const int8_t expHdr
+ )
+ {
+ {
+ CheckRawMode(true);
+ CheckSingleMode(true);
+
+ return ReadArrayInternal(res, len, stream, func, expHdr);
+ }
+ }
+
+ /**
+ * Read array.
+ *
+ * @param fieldName Field name.
+ * @param res Resulting array.
+ * @param len Length.
+ * @param func Function to be invoked on stream.
+ * @param expHdr Expected header.
+ * @return Length.
+ */
+ template<typename T>
+ int32_t ReadArray(
+ const char* fieldName,
+ T* res,
+ const int32_t len,
+ void(*func)(interop::InteropInputStream*, T* const, const int32_t),
+ const int8_t expHdr
+ )
+ {
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ int32_t pos = stream->Position();
+
+ int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+ int32_t fieldLen = SeekField(fieldId);
+
+ if (fieldLen > 0) {
+ int32_t realLen = ReadArrayInternal(res, len, stream, func, expHdr);
+
+ // If actual read didn't occur return to initial position so that we do not perform
+ // N jumps to find the field again, where N is total amount of fields.
+ if (realLen != -1 && (!res || realLen > len))
+ stream->Position(pos);
+
+ return realLen;
+ }
+
+ return -1;
+ }
+ }
+
+ /**
+ * Internal read array routine.
+ *
+ * @param res Resulting array.
+ * @param len Length.
+ * @param stream Stream.
+ * @param func Function to be invoked on stream.
+ * @param expHdr Expected header.
+ * @return Length.
+ */
+ template<typename T>
+ static int32_t ReadArrayInternal(
+ T* res,
+ const int32_t len,
+ interop::InteropInputStream* stream,
+ void(*func)(interop::InteropInputStream*, T* const, const int32_t),
+ const int8_t expHdr
+ )
+ {
+ {
+ int8_t hdr = stream->ReadInt8();
+
+ if (hdr == expHdr)
+ {
+ int32_t realLen = stream->ReadInt32();
+
+ if (realLen == 0 || (res && len >= realLen))
+ func(stream, res, realLen);
+ else
+ stream->Position(stream->Position() - 5);
+
+ return realLen;
+ }
+ else if (hdr != IGNITE_HDR_NULL)
+ ThrowOnInvalidHeader(stream->Position() - 1, expHdr, hdr);
+
+ return -1;
+ }
+ }
+
+ /**
+ * Read nullable value.
+ *
+ * @param stream Stream.
+ * @param func Function to be invoked on stream.
+ * @param expHdr Expected header.
+ */
+ template<typename T>
+ static T ReadNullable(
+ interop::InteropInputStream* stream,
+ T(*func)(interop::InteropInputStream*),
+ const int8_t expHdr
+ )
+ {
+ {
+ int8_t hdr = stream->ReadInt8();
+
+ if (hdr == expHdr)
+ return func(stream);
+ else if (hdr == IGNITE_HDR_NULL)
+ return Guid();
+ else {
+ ThrowOnInvalidHeader(stream->Position() - 1, expHdr, hdr);
+
+ return Guid();
+ }
+ }
+ }
+
+ /**
+ * Seek field with the given ID.
+ *
+ * @param fieldId Field ID.
+ * @return Field length or -1 if field is not found.
+ */
+ int32_t SeekField(const int32_t fieldId);
+
+ /**
+ * Check raw mode.
+ *
+ * @param expected Expected raw mode of the reader.
+ */
+ void CheckRawMode(bool expected) const;
+
+ /**
+ * Check whether reader is currently operating in single mode.
+ *
+ * @param expected Expected value.
+ */
+ void CheckSingleMode(bool expected) const;
+
+ /**
+ * Start new container reader session.
+ *
+ * @param expRawMode Expected raw mode.
+ * @param expHdr Expected header.
+ * @param size Container size.
+ * @return Session ID.
+ */
+ int32_t StartContainerSession(const bool expRawMode, const int8_t expHdr, int32_t* size);
+
+ /**
+ * Check whether session ID matches.
+ *
+ * @param ses Expected session ID.
+ */
+ void CheckSession(int32_t expSes) const;
+
+ /**
+ * Throw an error due to invalid header.
+ *
+ * @param pos Position in the stream.
+ * @param expHdr Expected header.
+ * @param hdr Actual header.
+ */
+ static void ThrowOnInvalidHeader(int32_t pos, int8_t expHdr, int8_t hdr);
+
+ /**
+ * Throw an error due to invalid header.
+ *
+ * @param expHdr Expected header.
+ * @param hdr Actual header.
+ */
+ void ThrowOnInvalidHeader(int8_t expHdr, int8_t hdr) const;
+
+ /**
+ * Internal string read routine.
+ *
+ * @param res Resulting array.
+ * @param len Length of array.
+ * @return Real array length.
+ */
+ int32_t ReadStringInternal(char* res, const int32_t len);
+
+ /**
+ * Read type of the collection. Do not preserve stream position.
+ *
+ * @return Collection type.
+ */
+ ignite::portable::CollectionType ReadCollectionTypeUnprotected();
+
+ /**
+ * Read size of the collection. Do not preserve stream position.
+ *
+ * @return Collection size.
+ */
+ int32_t ReadCollectionSizeUnprotected();
+
+ /**
+ * Read value.
+ *
+ * @param expHdr Expected header.
+ * @param func Function to be applied to the stream.
+ */
+ template<typename T>
+ T ReadTopObject0(const int8_t expHdr, T(*func) (ignite::impl::interop::InteropInputStream*))
+ {
+ int8_t typeId = stream->ReadInt8();
+
+ if (typeId == expHdr)
+ return func(stream);
+ else if (typeId == IGNITE_HDR_NULL)
+ return GetNull<T>();
+ else {
+ int32_t pos = stream->Position() - 1;
+
+ IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_PORTABLE, "Invalid header", "position", pos, "expected", expHdr, "actual", typeId)
+ }
+ }
+
+ /**
+ * Read value.
+ *
+ * @param expHdr Expected header.
+ * @param func Function to be applied to the stream.
+ * @param dflt Default value.
+ */
+ template<typename T>
+ T ReadTopObject0(const int8_t expHdr, T(*func) (ignite::impl::interop::InteropInputStream*), T dflt)
+ {
+ int8_t typeId = stream->ReadInt8();
+
+ if (typeId == expHdr)
+ return func(stream);
+ else if (typeId == IGNITE_HDR_NULL)
+ return dflt;
+ else {
+ int32_t pos = stream->Position() - 1;
+
+ IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_PORTABLE, "Invalid header", "position", pos, "expected", expHdr, "actual", typeId)
+ }
+ }
+ };
+
+ template<>
+ int8_t IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<int8_t>();
+
+ template<>
+ bool IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<bool>();
+
+ template<>
+ int16_t IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<int16_t>();
+
+ template<>
+ uint16_t IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<uint16_t>();
+
+ template<>
+ int32_t IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<int32_t>();
+
+ template<>
+ int64_t IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<int64_t>();
+
+ template<>
+ float IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<float>();
+
+ template<>
+ double IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<double>();
+
+
+ template<>
+ Guid IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<Guid>();
+
+ template<>
+ inline std::string IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<std::string>()
+ {
+ int8_t typeId = stream->ReadInt8();
+
+ if (typeId == IGNITE_TYPE_STRING)
+ {
+ bool utf8Mode = stream->ReadBool();
+ int32_t realLen = stream->ReadInt32();
+
+ ignite::impl::utils::SafeArray<char> arr(realLen + 1);
+
+ if (utf8Mode)
+ {
+ for (int i = 0; i < realLen; i++)
+ *(arr.target + i) = static_cast<char>(stream->ReadInt8());
+ }
+ else
+ {
+ for (int i = 0; i < realLen; i++)
+ *(arr.target + i) = static_cast<char>(stream->ReadUInt16());
+ }
+
+ *(arr.target + realLen) = 0;
+
+ return std::string(arr.target);
+ }
+
+ else if (typeId == IGNITE_HDR_NULL)
+ return std::string();
+ else {
+ int32_t pos = stream->Position() - 1;
+
+ IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_PORTABLE, "Invalid header", "position", pos, "expected", IGNITE_TYPE_STRING, "actual", typeId)
+ }
+ }
+ }
+ }
+ }
+
+ #endif
http://git-wip-us.apache.org/repos/asf/ignite/blob/ec58b87c/modules/platforms/cpp/core/include/ignite/impl/portable/portable_writer_impl.h
----------------------------------------------------------------------
diff --cc modules/platforms/cpp/core/include/ignite/impl/portable/portable_writer_impl.h
index 0000000,0259a7e..2d94dbf
mode 000000,100644..100644
--- a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_writer_impl.h
+++ b/modules/platforms/cpp/core/include/ignite/impl/portable/portable_writer_impl.h
@@@ -1,0 -1,914 +1,915 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ #ifndef _IGNITE_IMPL_PORTABLE_WRITER
+ #define _IGNITE_IMPL_PORTABLE_WRITER
+
+ #include <cstring>
+ #include <string>
+ #include <stdint.h>
+
+ #include <ignite/common/common.h>
+ #include <ignite/common/concurrent.h>
+
+ #include "ignite/impl/interop/interop_output_stream.h"
+ #include "ignite/impl/portable/portable_common.h"
+ #include "ignite/impl/portable/portable_id_resolver.h"
+ #include "ignite/impl/portable/portable_metadata_manager.h"
+ #include "ignite/impl/portable/portable_utils.h"
+ #include "ignite/portable/portable_consts.h"
+ #include "ignite/portable/portable_type.h"
+ #include "ignite/guid.h"
+
+ namespace ignite
+ {
+ namespace impl
+ {
+ namespace portable
+ {
+ /**
+ * Internal implementation of portable reader.
+ */
+ class IGNITE_IMPORT_EXPORT PortableWriterImpl
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param stream Interop stream.
+ * @param idRslvr Portable ID resolver.
+ * @param metaMgr Metadata manager.
+ * @param metaHnd Metadata handler.
+ */
+ PortableWriterImpl(ignite::impl::interop::InteropOutputStream* stream, PortableIdResolver* idRslvr,
+ PortableMetadataManager* metaMgr, PortableMetadataHandler* metaHnd);
+
+ /**
+ * Constructor used to construct light-weight writer allowing only raw operations
+ * and primitive objects.
+ *
+ * @param stream Interop stream.
+ * @param metaMgr Metadata manager.
+ */
+ PortableWriterImpl(ignite::impl::interop::InteropOutputStream* stream, PortableMetadataManager* metaMgr);
+
+ /**
+ * Write 8-byte signed integer. Maps to "byte" type in Java.
+ *
+ * @param val Value.
+ */
+ void WriteInt8(const int8_t val);
+
+ /**
+ * Write array of 8-byte signed integers. Maps to "byte[]" type in Java.
+ *
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteInt8Array(const int8_t* val, const int32_t len);
+
+ /**
+ * Write 8-byte signed integer. Maps to "byte" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Value.
+ */
+ void WriteInt8(const char* fieldName, const int8_t val);
+
+ /**
+ * Write array of 8-byte signed integers. Maps to "byte[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteInt8Array(const char* fieldName, const int8_t* val, const int32_t len);
+
+ /**
+ * Write bool. Maps to "short" type in Java.
+ *
+ * @param val Value.
+ */
+ void WriteBool(const bool val);
+
+ /**
+ * Write array of bools. Maps to "bool[]" type in Java.
+ *
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteBoolArray(const bool* val, const int32_t len);
+
+ /**
+ * Write bool. Maps to "short" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Value.
+ */
+ void WriteBool(const char* fieldName, const bool val);
+
+ /**
+ * Write array of bools. Maps to "bool[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteBoolArray(const char* fieldName, const bool* val, const int32_t len);
+
+ /**
+ * Write 16-byte signed integer. Maps to "short" type in Java.
+ *
+ * @param val Value.
+ */
+ void WriteInt16(const int16_t val);
+
+ /**
+ * Write array of 16-byte signed integers. Maps to "short[]" type in Java.
+ *
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteInt16Array(const int16_t* val, const int32_t len);
+
+ /**
+ * Write 16-byte signed integer. Maps to "short" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Value.
+ */
+ void WriteInt16(const char* fieldName, const int16_t val);
+
+ /**
+ * Write array of 16-byte signed integers. Maps to "short[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteInt16Array(const char* fieldName, const int16_t* val, const int32_t len);
+
+ /**
+ * Write 16-byte unsigned integer. Maps to "char" type in Java.
+ *
+ * @param val Value.
+ */
+ void WriteUInt16(const uint16_t val);
+
+ /**
+ * Write array of 16-byte unsigned integers. Maps to "char[]" type in Java.
+ *
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteUInt16Array(const uint16_t* val, const int32_t len);
+
+ /**
+ * Write 16-byte unsigned integer. Maps to "char" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Value.
+ */
+ void WriteUInt16(const char* fieldName, const uint16_t val);
+
+ /**
+ * Write array of 16-byte unsigned integers. Maps to "char[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteUInt16Array(const char* fieldName, const uint16_t* val, const int32_t len);
+
+ /**
+ * Write 32-byte signed integer. Maps to "int" type in Java.
+ *
+ * @param val Value.
+ */
+ void WriteInt32(const int32_t val);
+
+ /**
+ * Write array of 32-byte signed integers. Maps to "int[]" type in Java.
+ *
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteInt32Array(const int32_t* val, const int32_t len);
+
+ /**
+ * Write 32-byte signed integer. Maps to "int" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Value.
+ */
+ void WriteInt32(const char* fieldName, const int32_t val);
+
+ /**
+ * Write array of 32-byte signed integers. Maps to "int[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteInt32Array(const char* fieldName, const int32_t* val, const int32_t len);
+
+ /**
+ * Write 64-byte signed integer. Maps to "long" type in Java.
+ *
+ * @param val Value.
+ */
+ void WriteInt64(const int64_t val);
+
+ /**
+ * Write array of 64-byte signed integers. Maps to "long[]" type in Java.
+ *
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteInt64Array(const int64_t* val, const int32_t len);
+
+ /**
+ * Write 64-byte signed integer. Maps to "long" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Value.
+ */
+ void WriteInt64(const char* fieldName, const int64_t val);
+
+ /**
+ * Write array of 64-byte signed integers. Maps to "long[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteInt64Array(const char* fieldName, const int64_t* val, const int32_t len);
+
+ /**
+ * Write float. Maps to "float" type in Java.
+ *
+ * @param val Value.
+ */
+ void WriteFloat(const float val);
+
+ /**
+ * Write array of floats. Maps to "float[]" type in Java.
+ *
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteFloatArray(const float* val, const int32_t len);
+
+ /**
+ * Write float. Maps to "float" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Value.
+ */
+ void WriteFloat(const char* fieldName, const float val);
+
+ /**
+ * Write array of floats. Maps to "float[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteFloatArray(const char* fieldName, const float* val, const int32_t len);
+
+ /**
+ * Write double. Maps to "double" type in Java.
+ *
+ * @param val Value.
+ */
+ void WriteDouble(const double val);
+
+ /**
+ * Write array of doubles. Maps to "double[]" type in Java.
+ *
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteDoubleArray(const double* val, const int32_t len);
+
+ /**
+ * Write double. Maps to "double" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Value.
+ */
+ void WriteDouble(const char* fieldName, const double val);
+
+ /**
+ * Write array of doubles. Maps to "double[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteDoubleArray(const char* fieldName, const double* val, const int32_t len);
+
+ /**
+ * Write Guid. Maps to "UUID" type in Java.
+ *
+ * @param val Value.
+ */
+ void WriteGuid(const Guid val);
+
+ /**
+ * Write array of Guids. Maps to "UUID[]" type in Java.
+ *
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteGuidArray(const Guid* val, const int32_t len);
+
+ /**
+ * Write Guid. Maps to "UUID" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Value.
+ */
+ void WriteGuid(const char* fieldName, const Guid val);
+
+ /**
+ * Write array of Guids. Maps to "UUID[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteGuidArray(const char* fieldName, const Guid* val, const int32_t len);
+
+ /**
+ * Write string.
+ *
+ * @param val String.
+ * @param len String length (characters).
+ */
+ void WriteString(const char* val, const int32_t len);
+
+ /**
+ * Write string.
+ *
+ * @param fieldName Field name.
+ * @param val String.
+ * @param len String length (characters).
+ */
+ void WriteString(const char* fieldName, const char* val, const int32_t len);
+
+ /**
+ * Start string array write.
+ *
+ * @param typ Collection type.
+ * @return Session ID.
+ */
+ int32_t WriteStringArray();
+
+ /**
+ * Start string array write.
+ *
+ * @param fieldName Field name.
+ * @return Session ID.
+ */
+ int32_t WriteStringArray(const char* fieldName);
+
+ /**
+ * Write string element.
+ *
+ * @param id Session ID.
+ * @param val Value.
+ * @param len Length.
+ */
+ void WriteStringElement(int32_t id, const char* val, int32_t len);
+
+ /**
+ * Write NULL value.
+ */
+ void WriteNull();
+
+ /**
+ * Write NULL value.
+ *
+ * @param fieldName Field name.
+ */
+ void WriteNull(const char* fieldName);
+
+ /**
+ * Start array write.
+ *
+ * @param typ Collection type.
+ * @return Session ID.
+ */
+ int32_t WriteArray();
+
+ /**
+ * Start array write.
+ *
+ * @param fieldName Field name.
+ * @return Session ID.
+ */
+ int32_t WriteArray(const char* fieldName);
+
+ /**
+ * Start collection write.
+ *
+ * @param typ Collection type.
+ * @return Session ID.
+ */
+ int32_t WriteCollection(ignite::portable::CollectionType typ);
+
+ /**
+ * Start collection write.
+ *
+ * @param fieldName Field name.
+ * @param typ Collection type.
+ * @return Session ID.
+ */
+ int32_t WriteCollection(const char* fieldName, ignite::portable::CollectionType typ);
+
+ /**
+ * Write values in interval [first, last).
+ *
+ * @param first Iterator pointing to the beginning of the interval.
+ * @param last Iterator pointing to the end of the interval.
+ * @param typ Collection type.
+ */
+ template<typename InputIterator>
+ void WriteCollection(InputIterator first, InputIterator last, ignite::portable::CollectionType typ)
+ {
+ StartContainerSession(true);
+
+ WriteCollectionWithinSession(first, last, typ);
+ }
+
+ /**
+ * Write values in interval [first, last).
+ *
+ * @param fieldName Field name.
+ * @param first Iterator pointing to the beginning of the interval.
+ * @param last Iterator pointing to the end of the interval.
+ * @param typ Collection type.
+ */
+ template<typename InputIterator>
+ void WriteCollection(const char* fieldName, InputIterator first, InputIterator last,
+ ignite::portable::CollectionType typ)
+ {
+ StartContainerSession(false);
+
+ WriteFieldIdSkipLength(fieldName, IGNITE_TYPE_COLLECTION);
+
+ WriteCollectionWithinSession(first, last, typ);
+ }
+
+ /**
+ * Start map write.
+ *
+ * @param typ Map type.
+ * @return Session ID.
+ */
+ int32_t WriteMap(ignite::portable::MapType typ);
+
+ /**
+ * Start map write.
+ *
+ * @param fieldName Field name.
+ * @param typ Map type.
+ * @return Session ID.
+ */
+ int32_t WriteMap(const char* fieldName, ignite::portable::MapType typ);
+
+ /**
+ * Write collection element.
+ *
+ * @param id Session ID.
+ * @param val Value.
+ */
+ template<typename T>
+ void WriteElement(int32_t id, T val)
+ {
+ CheckSession(id);
+
+ WriteTopObject<T>(val);
+
+ elemCnt++;
+ }
+
+ /**
+ * Write map element.
+ *
+ * @param id Session ID.
+ * @param key Key.
+ * @param val Value.
+ */
+ template<typename K, typename V>
+ void WriteElement(int32_t id, K key, V val)
+ {
+ CheckSession(id);
+
+ WriteTopObject<K>(key);
+ WriteTopObject<V>(val);
+
+ elemCnt++;
+ }
+
+ /**
+ * Commit container write session.
+ *
+ * @param id Session ID.
+ */
+ void CommitContainer(int32_t id);
+
+ /**
+ * Write object.
+ *
+ * @param val Object.
+ */
+ template<typename T>
+ void WriteObject(T val)
+ {
+ CheckRawMode(true);
+
+ WriteTopObject(val);
+ }
+
+ /**
+ * Write object.
+ *
+ * @param fieldName Field name.
+ * @param val Object.
+ */
+ template<typename T>
+ void WriteObject(const char* fieldName, T val)
+ {
+ CheckRawMode(false);
+
+ // 1. Write field ID.
+ WriteFieldId(fieldName, IGNITE_TYPE_OBJECT);
+
+ // 2. Preserve space for length.
+ int32_t lenPos = stream->Position();
+ stream->Position(lenPos + 4);
+
+ // 3. Actual write.
+ WriteTopObject(val);
+
+ // 4. Write field length.
+ int32_t len = stream->Position() - lenPos - 4;
+ stream->WriteInt32(lenPos, len);
+ }
+
+ /**
+ * Set raw mode.
+ */
+ void SetRawMode();
+
+ /**
+ * Get raw position.
+ */
+ int32_t GetRawPosition() const;
+
+ /**
+ * Write object.
+ *
+ * @param obj Object to write.
+ */
+ template<typename T>
+ void WriteTopObject(const T& obj)
+ {
+ ignite::portable::PortableType<T> type;
+
+ if (type.IsNull(obj))
+ stream->WriteInt8(IGNITE_HDR_NULL);
+ else
+ {
+ TemplatedPortableIdResolver<T> idRslvr(type);
+ ignite::common::concurrent::SharedPointer<PortableMetadataHandler> metaHnd;
+
+ if (metaMgr)
+ metaHnd = metaMgr->GetHandler(idRslvr.GetTypeId());
+
+ PortableWriterImpl writerImpl(stream, &idRslvr, metaMgr, metaHnd.Get());
+ ignite::portable::PortableWriter writer(&writerImpl);
+
+ int32_t pos = stream->Position();
+
+ stream->WriteInt8(IGNITE_HDR_FULL);
++ stream->WriteInt8(IGNITE_PROTO_VER);
+ stream->WriteBool(true);
+ stream->WriteInt32(idRslvr.GetTypeId());
+ stream->WriteInt32(type.GetHashCode(obj));
+
+ stream->Position(pos + IGNITE_FULL_HDR_LEN);
+
+ type.Write(writer, obj);
+
+ int32_t len = stream->Position() - pos;
+
- stream->WriteInt32(pos + 10, len);
- stream->WriteInt32(pos + 14, writerImpl.GetRawPosition() - pos);
++ stream->WriteInt32(pos + IGNITE_OFFSET_LEN, len);
++ stream->WriteInt32(pos + IGNITE_OFFSET_RAW, writerImpl.GetRawPosition() - pos);
+
+ if (metaMgr)
+ metaMgr->SubmitHandler(type.GetTypeName(), idRslvr.GetTypeId(), metaHnd.Get());
+ }
+ }
+
+ /**
+ * Get underlying stream.
+ *
+ * @return Stream.
+ */
+ impl::interop::InteropOutputStream* GetStream();
+ private:
+ /** Underlying stream. */
+ ignite::impl::interop::InteropOutputStream* stream;
+
+ /** ID resolver. */
+ PortableIdResolver* idRslvr;
+
+ /** Metadata manager. */
+ PortableMetadataManager* metaMgr;
+
+ /** Metadata handler. */
+ PortableMetadataHandler* metaHnd;
+
+ /** Type ID. */
+ int32_t typeId;
+
+ /** Elements write session ID generator. */
+ int32_t elemIdGen;
+
+ /** Elements write session ID. */
+ int32_t elemId;
+
+ /** Elements count. */
+ int32_t elemCnt;
+
+ /** Elements start position. */
+ int32_t elemPos;
+
+ /** Raw data offset. */
+ int32_t rawPos;
+
+ IGNITE_NO_COPY_ASSIGNMENT(PortableWriterImpl)
+
+ /**
+ * Write a primitive value to stream in raw mode.
+ *
+ * @param val Value.
+ * @param func Stream function.
+ */
+ template<typename T>
+ void WritePrimitiveRaw(
+ const T val,
+ void(*func)(interop::InteropOutputStream*, T)
+ )
+ {
+ CheckRawMode(true);
+ CheckSingleMode(true);
+
+ func(stream, val);
+ }
+
+ /**
+ * Write a primitive array to stream in raw mode.
+ *
+ * @param val Value.
+ * @param len Array length.
+ * @param func Stream function.
+ * @param hdr Header.
+ */
+ template<typename T>
+ void WritePrimitiveArrayRaw(
+ const T* val,
+ const int32_t len,
+ void(*func)(interop::InteropOutputStream*, const T*, const int32_t),
+ const int8_t hdr
+ )
+ {
+ CheckRawMode(true);
+ CheckSingleMode(true);
+
+ if (val)
+ {
+ stream->WriteInt8(hdr);
+ stream->WriteInt32(len);
+ func(stream, val, len);
+ }
+ else
+ stream->WriteInt8(IGNITE_HDR_NULL);
+ }
+
+ /**
+ * Write a primitive value to stream.
+ *
+ * @param fieldName Field name.
+ * @param val Value.
+ * @param func Stream function.
+ * @param typ Field type ID.
+ * @param len Field length.
+ */
+ template<typename T>
+ void WritePrimitive(
+ const char* fieldName,
+ const T val,
+ void(*func)(interop::InteropOutputStream*, T),
+ const int8_t typ,
+ const int32_t len
+ )
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ WriteFieldId(fieldName, typ);
+
+ stream->WriteInt32(1 + len);
+ stream->WriteInt8(typ);
+
+ func(stream, val);
+ }
+
+ /**
+ * Write a primitive array to stream.
+ *
+ * @param fieldName Field name.
+ * @param val Value.
+ * @param len Array length.
+ * @param func Stream function.
+ * @param hdr Header.
+ * @param lenShift Length shift.
+ */
+ template<typename T>
+ void WritePrimitiveArray(
+ const char* fieldName,
+ const T* val,
+ const int32_t len,
+ void(*func)(interop::InteropOutputStream*, const T*, const int32_t),
+ const int8_t hdr,
+ const int32_t lenShift
+ )
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ WriteFieldId(fieldName, hdr);
+
+ if (val)
+ {
+ stream->WriteInt32(5 + (len << lenShift));
+ stream->WriteInt8(hdr);
+ stream->WriteInt32(len);
+ func(stream, val, len);
+ }
+ else
+ {
+ stream->WriteInt32(1);
+ stream->WriteInt8(IGNITE_HDR_NULL);
+ }
+ }
+
+ /**
+ * Write values in interval [first, last).
+ * New session should be started prior to call to this method.
+ * @param first Iterator pointing to the beginning of the interval.
+ * @param last Iterator pointing to the end of the interval.
+ * @param typ Collection type.
+ */
+ template<typename InputIterator>
+ void WriteCollectionWithinSession(InputIterator first, InputIterator last,
+ ignite::portable::CollectionType typ)
+ {
+ stream->WriteInt8(IGNITE_TYPE_COLLECTION);
+ stream->Position(stream->Position() + 4);
+ stream->WriteInt8(typ);
+
+ for (InputIterator i = first; i != last; ++i)
+ WriteElement(elemId, *i);
+
+ CommitContainer(elemId);
+ }
+
+ /**
+ * Check raw mode.
+ *
+ * @param expected Expected raw mode of the reader.
+ */
+ void CheckRawMode(bool expected) const;
+
+ /**
+ * Check whether writer is currently operating in single mode.
+ *
+ * @param expected Expected value.
+ */
+ void CheckSingleMode(bool expected) const;
+
+ /**
+ * Start new container writer session.
+ *
+ * @param expRawMode Expected raw mode.
+ */
+ void StartContainerSession(bool expRawMode);
+
+ /**
+ * Check whether session ID matches.
+ *
+ * @param ses Expected session ID.
+ */
+ void CheckSession(int32_t expSes) const;
+
+ /**
+ * Write field ID.
+ *
+ * @param fieldName Field name.
+ * @param fieldTypeId Field type ID.
+ */
+ void WriteFieldId(const char* fieldName, int32_t fieldTypeId);
+
+ /**
+ * Write field ID and skip field length.
+ *
+ * @param fieldName Field name.
+ * @param fieldTypeId Field type ID.
+ */
+ void WriteFieldIdSkipLength(const char* fieldName, int32_t fieldTypeId);
+
+ /**
+ * Write field ID and length.
+ *
+ * @param fieldName Field name.
+ * @param fieldTypeId Field type ID.
+ * @param len Length.
+ */
+ void WriteFieldIdAndLength(const char* fieldName, int32_t fieldTypeId, int32_t len);
+
+ /**
+ * Write primitive value.
+ *
+ * @param obj Value.
+ * @param func Stream function.
+ * @param hdr Header.
+ */
+ template<typename T>
+ void WriteTopObject0(const T obj, void(*func)(impl::interop::InteropOutputStream*, T), const int8_t hdr)
+ {
+ stream->WriteInt8(hdr);
+ func(stream, obj);
+ }
+ };
+
+ template<>
+ void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const int8_t& obj);
+
+ template<>
+ void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const bool& obj);
+
+ template<>
+ void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const int16_t& obj);
+
+ template<>
+ void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const uint16_t& obj);
+
+ template<>
+ void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const int32_t& obj);
+
+ template<>
+ void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const int64_t& obj);
+
+ template<>
+ void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const float& obj);
+
+ template<>
+ void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const double& obj);
+
+ template<>
+ void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const Guid& obj);
+
+ template<>
+ inline void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const std::string& obj)
+ {
+ const char* obj0 = obj.c_str();
+
+ int32_t len = static_cast<int32_t>(strlen(obj0));
+
+ stream->WriteInt8(IGNITE_TYPE_STRING);
+
+ PortableUtils::WriteString(stream, obj0, len);
+ }
+ }
+ }
+ }
+
+ #endif
[36/50] [abbrv] ignite git commit: Muted
GridReplicatedTxPreloadTest#testLocalTxPreloadingOptimistic test
Posted by vo...@apache.org.
Muted GridReplicatedTxPreloadTest#testLocalTxPreloadingOptimistic test
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0acb5db8
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0acb5db8
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0acb5db8
Branch: refs/heads/ignite-1651
Commit: 0acb5db8e9b740d0e1109d0dba0e247e20267610
Parents: 43b40f4
Author: ashutak <as...@gridgain.com>
Authored: Wed Oct 21 13:48:12 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Wed Oct 21 13:48:12 2015 +0300
----------------------------------------------------------------------
.../distributed/replicated/GridReplicatedTxPreloadTest.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/0acb5db8/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridReplicatedTxPreloadTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridReplicatedTxPreloadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridReplicatedTxPreloadTest.java
index 4da7734..e7560c7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridReplicatedTxPreloadTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridReplicatedTxPreloadTest.java
@@ -30,4 +30,9 @@ public class GridReplicatedTxPreloadTest extends IgniteTxPreloadAbstractTest {
@Override protected CacheMode cacheMode() {
return REPLICATED;
}
-}
\ No newline at end of file
+
+ /** {@inheritDoc} */
+ @Override public void testLocalTxPreloadingOptimistic() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1755");
+ }
+}
[46/50] [abbrv] ignite git commit: Merge branch 'ignite-1282' into
ignite-1651
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ec58b87c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
----------------------------------------------------------------------
diff --cc modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
index 0000000,c65038c..17d7cc6
mode 000000,100644..100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
@@@ -1,0 -1,915 +1,918 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Portable
+ {
+ using System;
+ using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
+ using System.IO;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Impl.Portable.IO;
+ using Apache.Ignite.Core.Impl.Portable.Metadata;
+ using Apache.Ignite.Core.Portable;
+
+ /// <summary>
+ /// Portable builder implementation.
+ /// </summary>
+ internal class PortableBuilderImpl : IPortableBuilder
+ {
+ /** Type IDs for metadata. */
+ private static readonly IDictionary<Type, int> TypeIds;
+
+ /** Cached dictionary with no values. */
+ private static readonly IDictionary<int, object> EmptyVals = new Dictionary<int, object>();
+
+ /** Offset: length. */
+ private const int OffsetLen = 10;
+
+ /** Portables. */
+ private readonly PortablesImpl _portables;
+
+ /** */
+ private readonly PortableBuilderImpl _parent;
+
+ /** Initial portable object. */
+ private readonly PortableUserObject _obj;
+
+ /** Type descriptor. */
+ private readonly IPortableTypeDescriptor _desc;
+
+ /** Values. */
+ private IDictionary<string, PortableBuilderField> _vals;
+
+ /** Contextual fields. */
+ private IDictionary<int, object> _cache;
+
+ /** Hash code. */
+ private int _hashCode;
+
+ /** Current context. */
+ private Context _ctx;
+
+ /// <summary>
+ /// Static initializer.
+ /// </summary>
+ [SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")]
+ static PortableBuilderImpl()
+ {
+ TypeIds = new Dictionary<Type, int>();
+
+ // 1. Primitives.
+ TypeIds[typeof(byte)] = PortableUtils.TypeByte;
+ TypeIds[typeof(bool)] = PortableUtils.TypeBool;
+ TypeIds[typeof(short)] = PortableUtils.TypeShort;
+ TypeIds[typeof(char)] = PortableUtils.TypeChar;
+ TypeIds[typeof(int)] = PortableUtils.TypeInt;
+ TypeIds[typeof(long)] = PortableUtils.TypeLong;
+ TypeIds[typeof(float)] = PortableUtils.TypeFloat;
+ TypeIds[typeof(double)] = PortableUtils.TypeDouble;
+ TypeIds[typeof(decimal)] = PortableUtils.TypeDecimal;
+
+ TypeIds[typeof(byte[])] = PortableUtils.TypeArrayByte;
+ TypeIds[typeof(bool[])] = PortableUtils.TypeArrayBool;
+ TypeIds[typeof(short[])] = PortableUtils.TypeArrayShort;
+ TypeIds[typeof(char[])] = PortableUtils.TypeArrayChar;
+ TypeIds[typeof(int[])] = PortableUtils.TypeArrayInt;
+ TypeIds[typeof(long[])] = PortableUtils.TypeArrayLong;
+ TypeIds[typeof(float[])] = PortableUtils.TypeArrayFloat;
+ TypeIds[typeof(double[])] = PortableUtils.TypeArrayDouble;
+ TypeIds[typeof(decimal?[])] = PortableUtils.TypeArrayDecimal;
+
+ // 2. String.
+ TypeIds[typeof(string)] = PortableUtils.TypeString;
+ TypeIds[typeof(string[])] = PortableUtils.TypeArrayString;
+
+ // 3. Guid.
+ TypeIds[typeof(Guid)] = PortableUtils.TypeGuid;
+ TypeIds[typeof(Guid?)] = PortableUtils.TypeGuid;
+ TypeIds[typeof(Guid[])] = PortableUtils.TypeArrayGuid;
+ TypeIds[typeof(Guid?[])] = PortableUtils.TypeArrayGuid;
+
+ // 4. Date.
+ TypeIds[typeof(DateTime)] = PortableUtils.TypeDate;
+ TypeIds[typeof(DateTime?)] = PortableUtils.TypeDate;
+ TypeIds[typeof(DateTime[])] = PortableUtils.TypeArrayDate;
+ TypeIds[typeof(DateTime?[])] = PortableUtils.TypeArrayDate;
+ }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="portables">Portables.</param>
+ /// <param name="parent">Parent builder.</param>
+ /// <param name="obj">Initial portable object.</param>
+ /// <param name="desc">Type descriptor.</param>
+ public PortableBuilderImpl(PortablesImpl portables, PortableBuilderImpl parent,
+ PortableUserObject obj, IPortableTypeDescriptor desc)
+ {
+ _portables = portables;
+ _parent = parent ?? this;
+ _obj = obj;
+ _desc = desc;
+
+ _hashCode = obj.GetHashCode();
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetHashCode(int hashCode)
+ {
+ _hashCode = hashCode;
+
+ return this;
+ }
+
+ /** <inheritDoc /> */
+ public T GetField<T>(string name)
+ {
+ PortableBuilderField field;
+
+ if (_vals != null && _vals.TryGetValue(name, out field))
+ return field != PortableBuilderField.RmvMarker ? (T)field.Value : default(T);
+ T val = _obj.Field<T>(name, this);
+
+ if (_vals == null)
+ _vals = new Dictionary<string, PortableBuilderField>(2);
+
+ _vals[name] = new PortableBuilderField(typeof(T), val);
+
+ return val;
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetField<T>(string name, T val)
+ {
+ return SetField0(name, new PortableBuilderField(typeof(T), val));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder RemoveField(string name)
+ {
+ return SetField0(name, PortableBuilderField.RmvMarker);
+ }
+
+ /** <inheritDoc /> */
+ public IPortableObject Build()
+ {
+ PortableHeapStream inStream = new PortableHeapStream(_obj.Data);
+
+ inStream.Seek(_obj.Offset, SeekOrigin.Begin);
+
+ // Assume that resulting length will be no less than header + [fields_cnt] * 12;
+ int len = PortableUtils.FullHdrLen + (_vals == null ? 0 : _vals.Count * 12);
+
+ PortableHeapStream outStream = new PortableHeapStream(len);
+
+ PortableWriterImpl writer = _portables.Marshaller.StartMarshal(outStream);
+
+ writer.Builder(this);
+
+ // All related builders will work in this context with this writer.
+ _parent._ctx = new Context(writer);
+
+ try
+ {
+ // Write.
+ writer.Write(this);
+
+ // Process metadata.
+ _portables.Marshaller.FinishMarshal(writer);
+
+ // Create portable object once metadata is processed.
+ return new PortableUserObject(_portables.Marshaller, outStream.InternalArray, 0,
+ _desc.TypeId, _hashCode);
+ }
+ finally
+ {
+ // Cleanup.
+ _parent._ctx.Closed = true;
+ }
+ }
+
+ /// <summary>
+ /// Create child builder.
+ /// </summary>
+ /// <param name="obj">Portable object.</param>
+ /// <returns>Child builder.</returns>
+ public PortableBuilderImpl Child(PortableUserObject obj)
+ {
+ var desc = _portables.Marshaller.GetDescriptor(true, obj.TypeId);
+
+ return new PortableBuilderImpl(_portables, null, obj, desc);
+ }
+
+ /// <summary>
+ /// Get cache field.
+ /// </summary>
+ /// <param name="pos">Position.</param>
+ /// <param name="val">Value.</param>
+ /// <returns><c>true</c> if value is found in cache.</returns>
+ public bool CachedField<T>(int pos, out T val)
+ {
+ if (_parent._cache != null)
+ {
+ object res;
+
+ if (_parent._cache.TryGetValue(pos, out res))
+ {
+ val = res != null ? (T)res : default(T);
+
+ return true;
+ }
+ }
+
+ val = default(T);
+
+ return false;
+ }
+
+ /// <summary>
+ /// Add field to cache test.
+ /// </summary>
+ /// <param name="pos">Position.</param>
+ /// <param name="val">Value.</param>
+ public void CacheField(int pos, object val)
+ {
+ if (_parent._cache == null)
+ _parent._cache = new Dictionary<int, object>(2);
+
+ _parent._cache[pos] = val;
+ }
+
+ /// <summary>
+ /// Internal set field routine.
+ /// </summary>
+ /// <param name="fieldName">Name.</param>
+ /// <param name="val">Value.</param>
+ /// <returns>This builder.</returns>
+ private IPortableBuilder SetField0(string fieldName, PortableBuilderField val)
+ {
+ if (_vals == null)
+ _vals = new Dictionary<string, PortableBuilderField>();
+
+ _vals[fieldName] = val;
+
+ return this;
+ }
+
+ /// <summary>
+ /// Mutate portable object.
+ /// </summary>
+ /// <param name="inStream">Input stream with initial object.</param>
+ /// <param name="outStream">Output stream.</param>
+ /// <param name="desc">Portable type descriptor.</param>
+ /// <param name="hashCode">Hash code.</param>
+ /// <param name="vals">Values.</param>
+ internal void Mutate(
+ PortableHeapStream inStream,
+ PortableHeapStream outStream,
+ IPortableTypeDescriptor desc,
+ int hashCode,
+ IDictionary<string, PortableBuilderField> vals)
+ {
+ // Set correct builder to writer frame.
+ PortableBuilderImpl oldBuilder = _parent._ctx.Writer.Builder(_parent);
+
+ int streamPos = inStream.Position;
+
+ try
+ {
+ // Prepare fields.
+ IPortableMetadataHandler metaHnd = _portables.Marshaller.GetMetadataHandler(desc);
+
+ IDictionary<int, object> vals0;
+
+ if (vals == null || vals.Count == 0)
+ vals0 = EmptyVals;
+ else
+ {
+ vals0 = new Dictionary<int, object>(vals.Count);
+
+ foreach (KeyValuePair<string, PortableBuilderField> valEntry in vals)
+ {
+ int fieldId = PortableUtils.FieldId(desc.TypeId, valEntry.Key, desc.NameConverter, desc.Mapper);
+
+ if (vals0.ContainsKey(fieldId))
+ throw new IgniteException("Collision in field ID detected (change field name or " +
+ "define custom ID mapper) [fieldName=" + valEntry.Key + ", fieldId=" + fieldId + ']');
+
+ vals0[fieldId] = valEntry.Value.Value;
+
+ // Write metadata if: 1) it is enabled for type; 2) type is not null (i.e. it is neither
+ // remove marker, nor a field read through "GetField" method.
+ if (metaHnd != null && valEntry.Value.Type != null)
+ metaHnd.OnFieldWrite(fieldId, valEntry.Key, TypeId(valEntry.Value.Type));
+ }
+ }
+
+ // Actual processing.
+ Mutate0(_parent._ctx, inStream, outStream, true, hashCode, vals0);
+
+ // 3. Handle metadata.
+ if (metaHnd != null)
+ {
+ IDictionary<string, int> meta = metaHnd.OnObjectWriteFinished();
+
+ if (meta != null)
+ _parent._ctx.Writer.SaveMetadata(desc.TypeId, desc.TypeName, desc.AffinityKeyFieldName, meta);
+ }
+ }
+ finally
+ {
+ // Restore builder frame.
+ _parent._ctx.Writer.Builder(oldBuilder);
+
+ inStream.Seek(streamPos, SeekOrigin.Begin);
+ }
+ }
+
+ /// <summary>
+ /// Internal mutation routine.
+ /// </summary>
+ /// <param name="inStream">Input stream.</param>
+ /// <param name="outStream">Output stream.</param>
+ /// <param name="ctx">Context.</param>
+ /// <param name="changeHash">WHether hash should be changed.</param>
+ /// <param name="hash">New hash.</param>
+ /// <param name="vals">Values to be replaced.</param>
+ /// <returns>Mutated object.</returns>
+ private void Mutate0(Context ctx, PortableHeapStream inStream, IPortableStream outStream,
+ bool changeHash, int hash, IDictionary<int, object> vals)
+ {
+ int inStartPos = inStream.Position;
+ int outStartPos = outStream.Position;
+
+ byte inHdr = inStream.ReadByte();
+
+ if (inHdr == PortableUtils.HdrNull)
+ outStream.WriteByte(PortableUtils.HdrNull);
+ else if (inHdr == PortableUtils.HdrHnd)
+ {
+ int inHnd = inStream.ReadInt();
+
+ int oldPos = inStartPos - inHnd;
+ int newPos;
+
+ if (ctx.OldToNew(oldPos, out newPos))
+ {
+ // Handle is still valid.
+ outStream.WriteByte(PortableUtils.HdrHnd);
+ outStream.WriteInt(outStartPos - newPos);
+ }
+ else
+ {
+ // Handle is invalid, write full object.
+ int inRetPos = inStream.Position;
+
+ inStream.Seek(oldPos, SeekOrigin.Begin);
+
+ Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
+
+ inStream.Seek(inRetPos, SeekOrigin.Begin);
+ }
+ }
+ else if (inHdr == PortableUtils.HdrFull)
+ {
++ PortableUtils.ValidateProtocolVersion(inStream);
++
+ byte inUsrFlag = inStream.ReadByte();
+ int inTypeId = inStream.ReadInt();
+ int inHash = inStream.ReadInt();
+ int inLen = inStream.ReadInt();
+ int inRawOff = inStream.ReadInt();
+
+ int hndPos;
+
+ if (ctx.AddOldToNew(inStartPos, outStartPos, out hndPos))
+ {
+ // Object could be cached in parent builder.
+ object cachedVal;
+
+ if (_parent._cache != null && _parent._cache.TryGetValue(inStartPos, out cachedVal)) {
+ ctx.Writer.Write(cachedVal);
+ }
+ else
+ {
+ // New object, write in full form.
+ outStream.WriteByte(PortableUtils.HdrFull);
++ outStream.WriteByte(PortableUtils.ProtoVer);
+ outStream.WriteByte(inUsrFlag);
+ outStream.WriteInt(inTypeId);
+ outStream.WriteInt(changeHash ? hash : inHash);
+
+ // Skip length and raw offset as they are not known at this point.
+ outStream.Seek(8, SeekOrigin.Current);
+
+ // Write regular fields.
+ while (inStream.Position < inStartPos + inRawOff)
+ {
+ int inFieldId = inStream.ReadInt();
+ int inFieldLen = inStream.ReadInt();
+ int inFieldDataPos = inStream.Position;
+
+ object fieldVal;
+
+ bool fieldFound = vals.TryGetValue(inFieldId, out fieldVal);
+
+ if (!fieldFound || fieldVal != PortableBuilderField.RmvMarkerObj)
+ {
+ outStream.WriteInt(inFieldId);
+
+ int fieldLenPos = outStream.Position; // Here we will write length later.
+
+ outStream.Seek(4, SeekOrigin.Current);
+
+ if (fieldFound)
+ {
+ // Replace field with new value.
+ if (fieldVal != PortableBuilderField.RmvMarkerObj)
+ ctx.Writer.Write(fieldVal);
+
+ vals.Remove(inFieldId);
+ }
+ else
+ {
+ // If field was requested earlier, then we must write tracked value
+ if (_parent._cache != null && _parent._cache.TryGetValue(inFieldDataPos, out fieldVal))
+ ctx.Writer.Write(fieldVal);
+ else
+ // Filed is not tracked, re-write as is.
+ Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
+ }
+
+ int fieldEndPos = outStream.Position;
+
+ outStream.Seek(fieldLenPos, SeekOrigin.Begin);
+ outStream.WriteInt(fieldEndPos - fieldLenPos - 4);
+ outStream.Seek(fieldEndPos, SeekOrigin.Begin);
+ }
+
+ // Position intput stream pointer after the field.
+ inStream.Seek(inFieldDataPos + inFieldLen, SeekOrigin.Begin);
+ }
+
+ // Write remaining new fields.
+ foreach (KeyValuePair<int, object> valEntry in vals)
+ {
+ if (valEntry.Value != PortableBuilderField.RmvMarkerObj)
+ {
+ outStream.WriteInt(valEntry.Key);
+
+ int fieldLenPos = outStream.Position; // Here we will write length later.
+
+ outStream.Seek(4, SeekOrigin.Current);
+
+ ctx.Writer.Write(valEntry.Value);
+
+ int fieldEndPos = outStream.Position;
+
+ outStream.Seek(fieldLenPos, SeekOrigin.Begin);
+ outStream.WriteInt(fieldEndPos - fieldLenPos - 4);
+ outStream.Seek(fieldEndPos, SeekOrigin.Begin);
+ }
+ }
+
+ // Write raw data.
+ int rawPos = outStream.Position;
+
+ outStream.Write(inStream.InternalArray, inStartPos + inRawOff, inLen - inRawOff);
+
+ // Write length and raw data offset.
+ int outResPos = outStream.Position;
+
+ outStream.Seek(outStartPos + OffsetLen, SeekOrigin.Begin);
+
+ outStream.WriteInt(outResPos - outStartPos); // Length.
+ outStream.WriteInt(rawPos - outStartPos); // Raw offset.
+
+ outStream.Seek(outResPos, SeekOrigin.Begin);
+ }
+ }
+ else
+ {
+ // Object has already been written, write as handle.
+ outStream.WriteByte(PortableUtils.HdrHnd);
+ outStream.WriteInt(outStartPos - hndPos);
+ }
+
+ // Synchronize input stream position.
+ inStream.Seek(inStartPos + inLen, SeekOrigin.Begin);
+ }
+ else
+ {
+ // Try writing as well-known type with fixed size.
+ outStream.WriteByte(inHdr);
+
+ if (!WriteAsPredefined(inHdr, inStream, outStream, ctx))
+ throw new IgniteException("Unexpected header [position=" + (inStream.Position - 1) +
+ ", header=" + inHdr + ']');
+ }
+ }
+
+ /// <summary>
+ /// Process portable object inverting handles if needed.
+ /// </summary>
+ /// <param name="outStream">Output stream.</param>
+ /// <param name="port">Portable.</param>
+ internal void ProcessPortable(IPortableStream outStream, PortableUserObject port)
+ {
+ // Special case: writing portable object with correct inversions.
+ PortableHeapStream inStream = new PortableHeapStream(port.Data);
+
+ inStream.Seek(port.Offset, SeekOrigin.Begin);
+
+ // Use fresh context to ensure correct portable inversion.
+ Mutate0(new Context(), inStream, outStream, false, 0, EmptyVals);
+ }
+
+ /// <summary>
+ /// Process child builder.
+ /// </summary>
+ /// <param name="outStream">Output stream.</param>
+ /// <param name="builder">Builder.</param>
+ internal void ProcessBuilder(IPortableStream outStream, PortableBuilderImpl builder)
+ {
+ PortableHeapStream inStream = new PortableHeapStream(builder._obj.Data);
+
+ inStream.Seek(builder._obj.Offset, SeekOrigin.Begin);
+
+ // Builder parent context might be null only in one case: if we never met this group of
+ // builders before. In this case we set context to their parent and track it. Context
+ // cleanup will be performed at the very end of build process.
+ if (builder._parent._ctx == null || builder._parent._ctx.Closed)
+ builder._parent._ctx = new Context(_parent._ctx);
+
+ builder.Mutate(inStream, outStream as PortableHeapStream, builder._desc,
+ builder._hashCode, builder._vals);
+ }
+
+ /// <summary>
+ /// Write object as a predefined type if possible.
+ /// </summary>
+ /// <param name="hdr">Header.</param>
+ /// <param name="inStream">Input stream.</param>
+ /// <param name="outStream">Output stream.</param>
+ /// <param name="ctx">Context.</param>
+ /// <returns><c>True</c> if was written.</returns>
+ private bool WriteAsPredefined(byte hdr, PortableHeapStream inStream, IPortableStream outStream,
+ Context ctx)
+ {
+ switch (hdr)
+ {
+ case PortableUtils.TypeByte:
+ TransferBytes(inStream, outStream, 1);
+
+ break;
+
+ case PortableUtils.TypeShort:
+ TransferBytes(inStream, outStream, 2);
+
+ break;
+
+ case PortableUtils.TypeInt:
+ TransferBytes(inStream, outStream, 4);
+
+ break;
+
+ case PortableUtils.TypeLong:
+ TransferBytes(inStream, outStream, 8);
+
+ break;
+
+ case PortableUtils.TypeFloat:
+ TransferBytes(inStream, outStream, 4);
+
+ break;
+
+ case PortableUtils.TypeDouble:
+ TransferBytes(inStream, outStream, 8);
+
+ break;
+
+ case PortableUtils.TypeChar:
+ TransferBytes(inStream, outStream, 2);
+
+ break;
+
+ case PortableUtils.TypeBool:
+ TransferBytes(inStream, outStream, 1);
+
+ break;
+
+ case PortableUtils.TypeDecimal:
+ TransferBytes(inStream, outStream, 4); // Transfer scale
+
+ int magLen = inStream.ReadInt(); // Transfer magnitude length.
+
+ outStream.WriteInt(magLen);
+
+ TransferBytes(inStream, outStream, magLen); // Transfer magnitude.
+
+ break;
+
+ case PortableUtils.TypeString:
+ PortableUtils.WriteString(PortableUtils.ReadString(inStream), outStream);
+
+ break;
+
+ case PortableUtils.TypeGuid:
+ TransferBytes(inStream, outStream, 16);
+
+ break;
+
+ case PortableUtils.TypeDate:
+ TransferBytes(inStream, outStream, 12);
+
+ break;
+
+ case PortableUtils.TypeArrayByte:
+ TransferArray(inStream, outStream, 1);
+
+ break;
+
+ case PortableUtils.TypeArrayShort:
+ TransferArray(inStream, outStream, 2);
+
+ break;
+
+ case PortableUtils.TypeArrayInt:
+ TransferArray(inStream, outStream, 4);
+
+ break;
+
+ case PortableUtils.TypeArrayLong:
+ TransferArray(inStream, outStream, 8);
+
+ break;
+
+ case PortableUtils.TypeArrayFloat:
+ TransferArray(inStream, outStream, 4);
+
+ break;
+
+ case PortableUtils.TypeArrayDouble:
+ TransferArray(inStream, outStream, 8);
+
+ break;
+
+ case PortableUtils.TypeArrayChar:
+ TransferArray(inStream, outStream, 2);
+
+ break;
+
+ case PortableUtils.TypeArrayBool:
+ TransferArray(inStream, outStream, 1);
+
+ break;
+
+ case PortableUtils.TypeArrayDecimal:
+ case PortableUtils.TypeArrayString:
+ case PortableUtils.TypeArrayGuid:
+ case PortableUtils.TypeArrayDate:
+ case PortableUtils.TypeArrayEnum:
+ case PortableUtils.TypeArray:
+ int arrLen = inStream.ReadInt();
+
+ outStream.WriteInt(arrLen);
+
+ for (int i = 0; i < arrLen; i++)
+ Mutate0(ctx, inStream, outStream, false, 0, null);
+
+ break;
+
+ case PortableUtils.TypeCollection:
+ int colLen = inStream.ReadInt();
+
+ outStream.WriteInt(colLen);
+
+ outStream.WriteByte(inStream.ReadByte());
+
+ for (int i = 0; i < colLen; i++)
+ Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
+
+ break;
+
+ case PortableUtils.TypeDictionary:
+ int dictLen = inStream.ReadInt();
+
+ outStream.WriteInt(dictLen);
+
+ outStream.WriteByte(inStream.ReadByte());
+
+ for (int i = 0; i < dictLen; i++)
+ {
+ Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
+ Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
+ }
+
+ break;
+
+ case PortableUtils.TypeMapEntry:
+ Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
+ Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
+
+ break;
+
+ case PortableUtils.TypePortable:
+ TransferArray(inStream, outStream, 1); // Data array.
+ TransferBytes(inStream, outStream, 4); // Offset in array.
+
+ break;
+
+ case PortableUtils.TypeEnum:
+ TransferBytes(inStream, outStream, 4); // Integer ordinal.
+
+ break;
+
+ default:
+ return false;
+ }
+
+ return true;
+ }
+
+ /// <summary>
+ /// Get's metadata field type ID for the given type.
+ /// </summary>
+ /// <param name="type">Type.</param>
+ /// <returns>Type ID.</returns>
+ private static int TypeId(Type type)
+ {
+ int typeId;
+
+ if (TypeIds.TryGetValue(type, out typeId))
+ return typeId;
+ if (type.IsEnum)
+ return PortableUtils.TypeEnum;
+ if (type.IsArray)
+ return type.GetElementType().IsEnum ? PortableUtils.TypeArrayEnum : PortableUtils.TypeArray;
+ PortableCollectionInfo colInfo = PortableCollectionInfo.Info(type);
+
+ return colInfo.IsAny ? colInfo.IsCollection || colInfo.IsGenericCollection ?
+ PortableUtils.TypeCollection : PortableUtils.TypeDictionary : PortableUtils.TypeObject;
+ }
+
+ /// <summary>
+ /// Transfer bytes from one stream to another.
+ /// </summary>
+ /// <param name="inStream">Input stream.</param>
+ /// <param name="outStream">Output stream.</param>
+ /// <param name="cnt">Bytes count.</param>
+ private static void TransferBytes(PortableHeapStream inStream, IPortableStream outStream, int cnt)
+ {
+ outStream.Write(inStream.InternalArray, inStream.Position, cnt);
+
+ inStream.Seek(cnt, SeekOrigin.Current);
+ }
+
+ /// <summary>
+ /// Transfer array of fixed-size elements from one stream to another.
+ /// </summary>
+ /// <param name="inStream">Input stream.</param>
+ /// <param name="outStream">Output stream.</param>
+ /// <param name="elemSize">Element size.</param>
+ private static void TransferArray(PortableHeapStream inStream, IPortableStream outStream,
+ int elemSize)
+ {
+ int len = inStream.ReadInt();
+
+ outStream.WriteInt(len);
+
+ TransferBytes(inStream, outStream, elemSize * len);
+ }
+
+ /// <summary>
+ /// Mutation ocntext.
+ /// </summary>
+ private class Context
+ {
+ /** Map from object position in old portable to position in new portable. */
+ private IDictionary<int, int> _oldToNew;
+
+ /** Parent context. */
+ private readonly Context _parent;
+
+ /** Portable writer. */
+ private readonly PortableWriterImpl _writer;
+
+ /** Children contexts. */
+ private ICollection<Context> _children;
+
+ /** Closed flag; if context is closed, it can no longer be used. */
+ private bool _closed;
+
+ /// <summary>
+ /// Constructor for parent context where writer invocation is not expected.
+ /// </summary>
+ public Context()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Constructor for parent context.
+ /// </summary>
+ /// <param name="writer">Writer</param>
+ public Context(PortableWriterImpl writer)
+ {
+ _writer = writer;
+ }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="parent">Parent context.</param>
+ public Context(Context parent)
+ {
+ _parent = parent;
+
+ _writer = parent._writer;
+
+ if (parent._children == null)
+ parent._children = new List<Context>();
+
+ parent._children.Add(this);
+ }
+
+ /// <summary>
+ /// Add another old-to-new position mapping.
+ /// </summary>
+ /// <param name="oldPos">Old position.</param>
+ /// <param name="newPos">New position.</param>
+ /// <param name="hndPos">Handle position.</param>
+ /// <returns><c>True</c> if ampping was added, <c>false</c> if mapping already existed and handle
+ /// position in the new object is returned.</returns>
+ public bool AddOldToNew(int oldPos, int newPos, out int hndPos)
+ {
+ if (_oldToNew == null)
+ _oldToNew = new Dictionary<int, int>();
+
+ if (_oldToNew.TryGetValue(oldPos, out hndPos))
+ return false;
+ _oldToNew[oldPos] = newPos;
+
+ return true;
+ }
+
+ /// <summary>
+ /// Get mapping of old position to the new one.
+ /// </summary>
+ /// <param name="oldPos">Old position.</param>
+ /// <param name="newPos">New position.</param>
+ /// <returns><c>True</c> if mapping exists.</returns>
+ public bool OldToNew(int oldPos, out int newPos)
+ {
+ return _oldToNew.TryGetValue(oldPos, out newPos);
+ }
+
+ /// <summary>
+ /// Writer.
+ /// </summary>
+ public PortableWriterImpl Writer
+ {
+ get { return _writer; }
+ }
+
+ /// <summary>
+ /// Closed flag.
+ /// </summary>
+ public bool Closed
+ {
+ get
+ {
+ return _closed;
+ }
+ set
+ {
+ Context ctx = this;
+
+ while (ctx != null)
+ {
+ ctx._closed = value;
+
+ if (_children != null) {
+ foreach (Context child in _children)
+ child.Closed = value;
+ }
+
+ ctx = ctx._parent;
+ }
+ }
+ }
+ }
+ }
+ }
http://git-wip-us.apache.org/repos/asf/ignite/blob/ec58b87c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
----------------------------------------------------------------------
diff --cc modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
index 0000000,fe5f5c9..ff9aa34
mode 000000,100644..100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
@@@ -1,0 -1,1017 +1,1020 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Portable
+ {
+ using System;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
+ using System.IO;
+ using System.Runtime.Serialization;
+ using Apache.Ignite.Core.Impl.Common;
+ using Apache.Ignite.Core.Impl.Portable.IO;
+ using Apache.Ignite.Core.Portable;
+
+ /// <summary>
+ /// Portable reader implementation.
+ /// </summary>
+ internal class PortableReaderImpl : IPortableReader, IPortableRawReader
+ {
+ /** Marshaller. */
+ private readonly PortableMarshaller _marsh;
+
+ /** Type descriptors. */
+ private readonly IDictionary<long, IPortableTypeDescriptor> _descs;
+
+ /** Parent builder. */
+ private readonly PortableBuilderImpl _builder;
+
+ /** Handles. */
+ private PortableReaderHandleDictionary _hnds;
+
+ /** Current type ID. */
+ private int _curTypeId;
+
+ /** Current position. */
+ private int _curPos;
+
+ /** Current raw data offset. */
+ private int _curRawOffset;
+
+ /** Current converter. */
+ private IPortableNameMapper _curConverter;
+
+ /** Current mapper. */
+ private IPortableIdMapper _curMapper;
+
+ /** Current raw flag. */
+ private bool _curRaw;
+
+ /** Detach flag. */
+ private bool _detach;
+
+ /** Portable read mode. */
+ private PortableMode _mode;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="marsh">Marshaller.</param>
+ /// <param name="descs">Descriptors.</param>
+ /// <param name="stream">Input stream.</param>
+ /// <param name="mode">The mode.</param>
+ /// <param name="builder">Builder.</param>
+ public PortableReaderImpl
+ (PortableMarshaller marsh,
+ IDictionary<long, IPortableTypeDescriptor> descs,
+ IPortableStream stream,
+ PortableMode mode,
+ PortableBuilderImpl builder)
+ {
+ _marsh = marsh;
+ _descs = descs;
+ _mode = mode;
+ _builder = builder;
+
+ Stream = stream;
+ }
+
+ /// <summary>
+ /// Gets the marshaller.
+ /// </summary>
+ public PortableMarshaller Marshaller
+ {
+ get { return _marsh; }
+ }
+
+ /** <inheritdoc /> */
+ public IPortableRawReader GetRawReader()
+ {
+ MarkRaw();
+
+ return this;
+ }
+
+ /** <inheritdoc /> */
+ public bool ReadBoolean(string fieldName)
+ {
+ return ReadField(fieldName, r => r.ReadBoolean());
+ }
+
+ /** <inheritdoc /> */
+ public bool ReadBoolean()
+ {
+ return Stream.ReadBool();
+ }
+
+ /** <inheritdoc /> */
+ public bool[] ReadBooleanArray(string fieldName)
+ {
+ return ReadField(fieldName, PortableUtils.ReadBooleanArray);
+ }
+
+ /** <inheritdoc /> */
+ public bool[] ReadBooleanArray()
+ {
+ return Read(PortableUtils.ReadBooleanArray);
+ }
+
+ /** <inheritdoc /> */
+ public byte ReadByte(string fieldName)
+ {
+ return ReadField(fieldName, ReadByte);
+ }
+
+ /** <inheritdoc /> */
+ public byte ReadByte()
+ {
+ return Stream.ReadByte();
+ }
+
+ /** <inheritdoc /> */
+ public byte[] ReadByteArray(string fieldName)
+ {
+ return ReadField(fieldName, PortableUtils.ReadByteArray);
+ }
+
+ /** <inheritdoc /> */
+ public byte[] ReadByteArray()
+ {
+ return Read(PortableUtils.ReadByteArray);
+ }
+
+ /** <inheritdoc /> */
+ public short ReadShort(string fieldName)
+ {
+ return ReadField(fieldName, ReadShort);
+ }
+
+ /** <inheritdoc /> */
+ public short ReadShort()
+ {
+ return Stream.ReadShort();
+ }
+
+ /** <inheritdoc /> */
+ public short[] ReadShortArray(string fieldName)
+ {
+ return ReadField(fieldName, PortableUtils.ReadShortArray);
+ }
+
+ /** <inheritdoc /> */
+ public short[] ReadShortArray()
+ {
+ return Read(PortableUtils.ReadShortArray);
+ }
+
+ /** <inheritdoc /> */
+ public char ReadChar(string fieldName)
+ {
+ return ReadField(fieldName, ReadChar);
+ }
+
+ /** <inheritdoc /> */
+ public char ReadChar()
+ {
+ return Stream.ReadChar();
+ }
+
+ /** <inheritdoc /> */
+ public char[] ReadCharArray(string fieldName)
+ {
+ return ReadField(fieldName, PortableUtils.ReadCharArray);
+ }
+
+ /** <inheritdoc /> */
+ public char[] ReadCharArray()
+ {
+ return Read(PortableUtils.ReadCharArray);
+ }
+
+ /** <inheritdoc /> */
+ public int ReadInt(string fieldName)
+ {
+ return ReadField(fieldName, ReadInt);
+ }
+
+ /** <inheritdoc /> */
+ public int ReadInt()
+ {
+ return Stream.ReadInt();
+ }
+
+ /** <inheritdoc /> */
+ public int[] ReadIntArray(string fieldName)
+ {
+ return ReadField(fieldName, PortableUtils.ReadIntArray);
+ }
+
+ /** <inheritdoc /> */
+ public int[] ReadIntArray()
+ {
+ return Read(PortableUtils.ReadIntArray);
+ }
+
+ /** <inheritdoc /> */
+ public long ReadLong(string fieldName)
+ {
+ return ReadField(fieldName, ReadLong);
+ }
+
+ /** <inheritdoc /> */
+ public long ReadLong()
+ {
+ return Stream.ReadLong();
+ }
+
+ /** <inheritdoc /> */
+ public long[] ReadLongArray(string fieldName)
+ {
+ return ReadField(fieldName, PortableUtils.ReadLongArray);
+ }
+
+ /** <inheritdoc /> */
+ public long[] ReadLongArray()
+ {
+ return Read(PortableUtils.ReadLongArray);
+ }
+
+ /** <inheritdoc /> */
+ public float ReadFloat(string fieldName)
+ {
+ return ReadField(fieldName, ReadFloat);
+ }
+
+ /** <inheritdoc /> */
+ public float ReadFloat()
+ {
+ return Stream.ReadFloat();
+ }
+
+ /** <inheritdoc /> */
+ public float[] ReadFloatArray(string fieldName)
+ {
+ return ReadField(fieldName, PortableUtils.ReadFloatArray);
+ }
+
+ /** <inheritdoc /> */
+ public float[] ReadFloatArray()
+ {
+ return Read(PortableUtils.ReadFloatArray);
+ }
+
+ /** <inheritdoc /> */
+ public double ReadDouble(string fieldName)
+ {
+ return ReadField(fieldName, ReadDouble);
+ }
+
+ /** <inheritdoc /> */
+ public double ReadDouble()
+ {
+ return Stream.ReadDouble();
+ }
+
+ /** <inheritdoc /> */
+ public double[] ReadDoubleArray(string fieldName)
+ {
+ return ReadField(fieldName, PortableUtils.ReadDoubleArray);
+ }
+
+ /** <inheritdoc /> */
+ public double[] ReadDoubleArray()
+ {
+ return Read(PortableUtils.ReadDoubleArray);
+ }
+
+ /** <inheritdoc /> */
+ public decimal? ReadDecimal(string fieldName)
+ {
+ return ReadField(fieldName, PortableUtils.ReadDecimal);
+ }
+
+ /** <inheritdoc /> */
+ public decimal? ReadDecimal()
+ {
+ return Read(PortableUtils.ReadDecimal);
+ }
+
+ /** <inheritdoc /> */
+ public decimal?[] ReadDecimalArray(string fieldName)
+ {
+ return ReadField(fieldName, PortableUtils.ReadDecimalArray);
+ }
+
+ /** <inheritdoc /> */
+ public decimal?[] ReadDecimalArray()
+ {
+ return Read(PortableUtils.ReadDecimalArray);
+ }
+
+ /** <inheritdoc /> */
+ public DateTime? ReadDate(string fieldName)
+ {
+ return ReadDate(fieldName, false);
+ }
+
+ /** <inheritdoc /> */
+ public DateTime? ReadDate(string fieldName, bool local)
+ {
+ return ReadField(fieldName, r => PortableUtils.ReadDate(r, local));
+ }
+
+ /** <inheritdoc /> */
+ public DateTime? ReadDate()
+ {
+ return ReadDate(false);
+ }
+
+ /** <inheritdoc /> */
+ public DateTime? ReadDate(bool local)
+ {
+ return Read(r => PortableUtils.ReadDate(r, local));
+ }
+
+ /** <inheritdoc /> */
+ public DateTime?[] ReadDateArray(string fieldName)
+ {
+ return ReadDateArray(fieldName, false);
+ }
+
+ /** <inheritdoc /> */
+ public DateTime?[] ReadDateArray(string fieldName, bool local)
+ {
+ return ReadField(fieldName, r => PortableUtils.ReadDateArray(r, local));
+ }
+
+ /** <inheritdoc /> */
+ public DateTime?[] ReadDateArray()
+ {
+ return ReadDateArray(false);
+ }
+
+ /** <inheritdoc /> */
+ public DateTime?[] ReadDateArray(bool local)
+ {
+ return Read(r => PortableUtils.ReadDateArray(r, local));
+ }
+
+ /** <inheritdoc /> */
+ public string ReadString(string fieldName)
+ {
+ return ReadField(fieldName, PortableUtils.ReadString);
+ }
+
+ /** <inheritdoc /> */
+ public string ReadString()
+ {
+ return Read(PortableUtils.ReadString);
+ }
+
+ /** <inheritdoc /> */
+ public string[] ReadStringArray(string fieldName)
+ {
+ return ReadField(fieldName, r => PortableUtils.ReadGenericArray<string>(r, false));
+ }
+
+ /** <inheritdoc /> */
+ public string[] ReadStringArray()
+ {
+ return Read(r => PortableUtils.ReadGenericArray<string>(r, false));
+ }
+
+ /** <inheritdoc /> */
+ public Guid? ReadGuid(string fieldName)
+ {
+ return ReadField(fieldName, PortableUtils.ReadGuid);
+ }
+
+ /** <inheritdoc /> */
+ public Guid? ReadGuid()
+ {
+ return Read(PortableUtils.ReadGuid);
+ }
+
+ /** <inheritdoc /> */
+ public Guid?[] ReadGuidArray(string fieldName)
+ {
+ return ReadField(fieldName, r => PortableUtils.ReadGenericArray<Guid?>(r, false));
+ }
+
+ /** <inheritdoc /> */
+ public Guid?[] ReadGuidArray()
+ {
+ return Read(r => PortableUtils.ReadGenericArray<Guid?>(r, false));
+ }
+
+ /** <inheritdoc /> */
+ public T ReadEnum<T>(string fieldName)
+ {
+ return ReadField(fieldName, PortableUtils.ReadEnum<T>);
+ }
+
+ /** <inheritdoc /> */
+ public T ReadEnum<T>()
+ {
+ return Read(PortableUtils.ReadEnum<T>);
+ }
+
+ /** <inheritdoc /> */
+ public T[] ReadEnumArray<T>(string fieldName)
+ {
+ return ReadField(fieldName, r => PortableUtils.ReadGenericArray<T>(r, true));
+ }
+
+ /** <inheritdoc /> */
+ public T[] ReadEnumArray<T>()
+ {
+ return Read(r => PortableUtils.ReadGenericArray<T>(r, true));
+ }
+
+ /** <inheritdoc /> */
+ public T ReadObject<T>(string fieldName)
+ {
+ if (_curRaw)
+ throw new PortableException("Cannot read named fields after raw data is read.");
+
+ int fieldId = PortableUtils.FieldId(_curTypeId, fieldName, _curConverter, _curMapper);
+
+ if (SeekField(fieldId))
+ return Deserialize<T>();
+
+ return default(T);
+ }
+
+ /** <inheritdoc /> */
+ public T ReadObject<T>()
+ {
+ return Deserialize<T>();
+ }
+
+ /** <inheritdoc /> */
+ public T[] ReadObjectArray<T>(string fieldName)
+ {
+ return ReadField(fieldName, r => PortableUtils.ReadGenericArray<T>(r, true));
+ }
+
+ /** <inheritdoc /> */
+ public T[] ReadObjectArray<T>()
+ {
+ return Read(r => PortableUtils.ReadGenericArray<T>(r, true));
+ }
+
+ /** <inheritdoc /> */
+ public ICollection ReadCollection(string fieldName)
+ {
+ return ReadCollection(fieldName, null, null);
+ }
+
+ /** <inheritdoc /> */
+ public ICollection ReadCollection()
+ {
+ return ReadCollection(null, null);
+ }
+
+ /** <inheritdoc /> */
+ public ICollection ReadCollection(string fieldName, PortableCollectionFactory factory,
+ PortableCollectionAdder adder)
+ {
+ return ReadField(fieldName, r => PortableUtils.ReadCollection(r, factory, adder));
+ }
+
+ /** <inheritdoc /> */
+ public ICollection ReadCollection(PortableCollectionFactory factory,
+ PortableCollectionAdder adder)
+ {
+ return Read(r => PortableUtils.ReadCollection(r, factory, adder));
+ }
+
+ /** <inheritdoc /> */
+ public ICollection<T> ReadGenericCollection<T>(string fieldName)
+ {
+ return ReadGenericCollection<T>(fieldName, null);
+ }
+
+ /** <inheritdoc /> */
+ public ICollection<T> ReadGenericCollection<T>()
+ {
+ return ReadGenericCollection((PortableGenericCollectionFactory<T>) null);
+ }
+
+ /** <inheritdoc /> */
+ public ICollection<T> ReadGenericCollection<T>(string fieldName,
+ PortableGenericCollectionFactory<T> factory)
+ {
+ return ReadField(fieldName, r => PortableUtils.ReadGenericCollection(r, factory));
+ }
+
+ /** <inheritdoc /> */
+ public ICollection<T> ReadGenericCollection<T>(PortableGenericCollectionFactory<T> factory)
+ {
+ return Read(r => PortableUtils.ReadGenericCollection(r, factory));
+ }
+
+ /** <inheritdoc /> */
+ public IDictionary ReadDictionary(string fieldName)
+ {
+ return ReadDictionary(fieldName, null);
+ }
+
+ /** <inheritdoc /> */
+ public IDictionary ReadDictionary()
+ {
+ return ReadDictionary((PortableDictionaryFactory)null);
+ }
+
+ /** <inheritdoc /> */
+ public IDictionary ReadDictionary(string fieldName, PortableDictionaryFactory factory)
+ {
+ return ReadField(fieldName, r => PortableUtils.ReadDictionary(r, factory));
+ }
+
+ /** <inheritdoc /> */
+ public IDictionary ReadDictionary(PortableDictionaryFactory factory)
+ {
+ return Read(r => PortableUtils.ReadDictionary(r, factory));
+ }
+
+ /** <inheritdoc /> */
+ public IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(string fieldName)
+ {
+ return ReadGenericDictionary<TK, TV>(fieldName, null);
+ }
+
+ /** <inheritdoc /> */
+ public IDictionary<TK, TV> ReadGenericDictionary<TK, TV>()
+ {
+ return ReadGenericDictionary((PortableGenericDictionaryFactory<TK, TV>) null);
+ }
+
+ /** <inheritdoc /> */
+ public IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(string fieldName,
+ PortableGenericDictionaryFactory<TK, TV> factory)
+ {
+ return ReadField(fieldName, r => PortableUtils.ReadGenericDictionary(r, factory));
+ }
+
+ /** <inheritdoc /> */
+ public IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(PortableGenericDictionaryFactory<TK, TV> factory)
+ {
+ return Read(r => PortableUtils.ReadGenericDictionary(r, factory));
+ }
+
+ /// <summary>
+ /// Enable detach mode for the next object read.
+ /// </summary>
+ public void DetachNext()
+ {
+ _detach = true;
+ }
+
+ /// <summary>
+ /// Deserialize object.
+ /// </summary>
+ /// <returns>Deserialized object.</returns>
+ public T Deserialize<T>()
+ {
+ int pos = Stream.Position;
+
+ byte hdr = Stream.ReadByte();
+
+ var doDetach = _detach; // save detach flag into a var and reset so it does not go deeper
+
+ _detach = false;
+
+ switch (hdr)
+ {
+ case PortableUtils.HdrNull:
+ if (default(T) != null)
+ throw new PortableException(string.Format("Invalid data on deserialization. " +
+ "Expected: '{0}' But was: null", typeof (T)));
+
+ return default(T);
+
+ case PortableUtils.HdrHnd:
+ return ReadHandleObject<T>(pos);
+
+ case PortableUtils.HdrFull:
+ return ReadFullObject<T>(pos);
+
+ case PortableUtils.TypePortable:
+ return ReadPortableObject<T>(doDetach);
+ }
+
+ if (PortableUtils.IsPredefinedType(hdr))
+ return PortableSystemHandlers.ReadSystemType<T>(hdr, this);
+
+ throw new PortableException("Invalid header on deserialization [pos=" + pos + ", hdr=" + hdr + ']');
+ }
+
+ /// <summary>
+ /// Reads the portable object.
+ /// </summary>
+ private T ReadPortableObject<T>(bool doDetach)
+ {
+ var len = Stream.ReadInt();
+
+ var portablePos = Stream.Position;
+
+ if (_mode != PortableMode.Deserialize)
+ return TypeCaster<T>.Cast(ReadAsPortable(portablePos, len, doDetach));
+
+ Stream.Seek(len, SeekOrigin.Current);
+
+ var offset = Stream.ReadInt();
+
+ var retPos = Stream.Position;
+
+ Stream.Seek(portablePos + offset, SeekOrigin.Begin);
+
+ _mode = PortableMode.KeepPortable;
+
+ try
+ {
+ return Deserialize<T>();
+ }
+ finally
+ {
+ _mode = PortableMode.Deserialize;
+
+ Stream.Seek(retPos, SeekOrigin.Begin);
+ }
+ }
+
+ /// <summary>
+ /// Reads the portable object in portable form.
+ /// </summary>
+ private PortableUserObject ReadAsPortable(int dataPos, int dataLen, bool doDetach)
+ {
+ try
+ {
+ Stream.Seek(dataLen + dataPos, SeekOrigin.Begin);
+
+ var offs = Stream.ReadInt(); // offset inside data
+
+ var pos = dataPos + offs;
+
+ if (!doDetach)
+ return GetPortableUserObject(pos, pos, Stream.Array());
+
- Stream.Seek(pos + 10, SeekOrigin.Begin);
++ Stream.Seek(pos + PortableUtils.OffsetLen, SeekOrigin.Begin);
+
+ var len = Stream.ReadInt();
+
+ Stream.Seek(pos, SeekOrigin.Begin);
+
+ return GetPortableUserObject(pos, 0, Stream.ReadByteArray(len));
+ }
+ finally
+ {
+ Stream.Seek(dataPos + dataLen + 4, SeekOrigin.Begin);
+ }
+ }
+
+ /// <summary>
+ /// Reads the full object.
+ /// </summary>
+ [SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "hashCode")]
+ private T ReadFullObject<T>(int pos)
+ {
++ // Validate protocol version.
++ PortableUtils.ValidateProtocolVersion(Stream);
++
+ // Read header.
+ bool userType = Stream.ReadBool();
+ int typeId = Stream.ReadInt();
+ // ReSharper disable once UnusedVariable
+ int hashCode = Stream.ReadInt();
+ int len = Stream.ReadInt();
+ int rawOffset = Stream.ReadInt();
+
+ try
+ {
+ // Already read this object?
+ object hndObj;
+
+ if (_hnds != null && _hnds.TryGetValue(pos, out hndObj))
+ return (T) hndObj;
+
+ if (userType && _mode == PortableMode.ForcePortable)
+ {
+ PortableUserObject portObj;
+
+ if (_detach)
+ {
+ Stream.Seek(pos, SeekOrigin.Begin);
+
+ portObj = GetPortableUserObject(pos, 0, Stream.ReadByteArray(len));
+ }
+ else
+ portObj = GetPortableUserObject(pos, pos, Stream.Array());
+
+ T obj = _builder == null ? TypeCaster<T>.Cast(portObj) : TypeCaster<T>.Cast(_builder.Child(portObj));
+
+ AddHandle(pos, obj);
+
+ return obj;
+ }
+ else
+ {
+ // Find descriptor.
+ IPortableTypeDescriptor desc;
+
+ if (!_descs.TryGetValue(PortableUtils.TypeKey(userType, typeId), out desc))
+ throw new PortableException("Unknown type ID: " + typeId);
+
+ // Instantiate object.
+ if (desc.Type == null)
+ throw new PortableException("No matching type found for object [typeId=" +
+ desc.TypeId + ", typeName=" + desc.TypeName + ']');
+
+ // Preserve old frame.
+ int oldTypeId = _curTypeId;
+ int oldPos = _curPos;
+ int oldRawOffset = _curRawOffset;
+ IPortableNameMapper oldConverter = _curConverter;
+ IPortableIdMapper oldMapper = _curMapper;
+ bool oldRaw = _curRaw;
+
+ // Set new frame.
+ _curTypeId = typeId;
+ _curPos = pos;
+ _curRawOffset = rawOffset;
+ _curConverter = desc.NameConverter;
+ _curMapper = desc.Mapper;
+ _curRaw = false;
+
+ // Read object.
+ object obj;
+
+ var sysSerializer = desc.Serializer as IPortableSystemTypeSerializer;
+
+ if (sysSerializer != null)
+ obj = sysSerializer.ReadInstance(this);
+ else
+ {
+ try
+ {
+ obj = FormatterServices.GetUninitializedObject(desc.Type);
+
+ // Save handle.
+ AddHandle(pos, obj);
+ }
+ catch (Exception e)
+ {
+ throw new PortableException("Failed to create type instance: " +
+ desc.Type.AssemblyQualifiedName, e);
+ }
+
+ desc.Serializer.ReadPortable(obj, this);
+ }
+
+ // Restore old frame.
+ _curTypeId = oldTypeId;
+ _curPos = oldPos;
+ _curRawOffset = oldRawOffset;
+ _curConverter = oldConverter;
+ _curMapper = oldMapper;
+ _curRaw = oldRaw;
+
+ var wrappedSerializable = obj as SerializableObjectHolder;
+
+ return wrappedSerializable != null ? (T) wrappedSerializable.Item : (T) obj;
+ }
+ }
+ finally
+ {
+ // Advance stream pointer.
+ Stream.Seek(pos + len, SeekOrigin.Begin);
+ }
+ }
+
+ /// <summary>
+ /// Reads the handle object.
+ /// </summary>
+ private T ReadHandleObject<T>(int pos)
+ {
+ // Get handle position.
+ int hndPos = pos - Stream.ReadInt();
+
+ int retPos = Stream.Position;
+
+ try
+ {
+ object hndObj;
+
+ if (_builder == null || !_builder.CachedField(hndPos, out hndObj))
+ {
+ if (_hnds == null || !_hnds.TryGetValue(hndPos, out hndObj))
+ {
+ // No such handler, i.e. we trying to deserialize inner object before deserializing outer.
+ Stream.Seek(hndPos, SeekOrigin.Begin);
+
+ hndObj = Deserialize<T>();
+ }
+
+ // Notify builder that we deserialized object on other location.
+ if (_builder != null)
+ _builder.CacheField(hndPos, hndObj);
+ }
+
+ return (T) hndObj;
+ }
+ finally
+ {
+ // Position stream to correct place.
+ Stream.Seek(retPos, SeekOrigin.Begin);
+ }
+ }
+
+ /// <summary>
+ /// Adds a handle to the dictionary.
+ /// </summary>
+ /// <param name="pos">Position.</param>
+ /// <param name="obj">Object.</param>
+ private void AddHandle(int pos, object obj)
+ {
+ if (_hnds == null)
+ _hnds = new PortableReaderHandleDictionary(pos, obj);
+ else
+ _hnds.Add(pos, obj);
+ }
+
+ /// <summary>
+ /// Underlying stream.
+ /// </summary>
+ public IPortableStream Stream
+ {
+ get;
+ private set;
+ }
+
+ /// <summary>
+ /// Mark current output as raw.
+ /// </summary>
+ private void MarkRaw()
+ {
+ if (!_curRaw)
+ {
+ _curRaw = true;
+
+ Stream.Seek(_curPos + _curRawOffset, SeekOrigin.Begin);
+ }
+ }
+
+ /// <summary>
+ /// Seek field with the given ID in the current object.
+ /// </summary>
+ /// <param name="fieldId">Field ID.</param>
+ /// <returns>True in case the field was found and position adjusted, false otherwise.</returns>
+ private bool SeekField(int fieldId)
+ {
+ // This method is expected to be called when stream pointer is set either before
+ // the field or on raw data offset.
- int start = _curPos + 18;
++ int start = _curPos + PortableUtils.FullHdrLen;
+ int end = _curPos + _curRawOffset;
+
+ int initial = Stream.Position;
+
+ int cur = initial;
+
+ while (cur < end)
+ {
+ int id = Stream.ReadInt();
+
+ if (fieldId == id)
+ {
+ // Field is found, return.
+ Stream.Seek(4, SeekOrigin.Current);
+
+ return true;
+ }
+
+ Stream.Seek(Stream.ReadInt(), SeekOrigin.Current);
+
+ cur = Stream.Position;
+ }
+
+ Stream.Seek(start, SeekOrigin.Begin);
+
+ cur = start;
+
+ while (cur < initial)
+ {
+ int id = Stream.ReadInt();
+
+ if (fieldId == id)
+ {
+ // Field is found, return.
+ Stream.Seek(4, SeekOrigin.Current);
+
+ return true;
+ }
+
+ Stream.Seek(Stream.ReadInt(), SeekOrigin.Current);
+
+ cur = Stream.Position;
+ }
+
+ return false;
+ }
+
+ /// <summary>
+ /// Determines whether header at current position is HDR_NULL.
+ /// </summary>
+ private bool IsNullHeader()
+ {
+ var hdr = ReadByte();
+
+ return hdr != PortableUtils.HdrNull;
+ }
+
+ /// <summary>
+ /// Seeks the field by name, reads header and returns true if field is present and header is not null.
+ /// </summary>
+ private bool SeekField(string fieldName)
+ {
+ if (_curRaw)
+ throw new PortableException("Cannot read named fields after raw data is read.");
+
+ var fieldId = PortableUtils.FieldId(_curTypeId, fieldName, _curConverter, _curMapper);
+
+ if (!SeekField(fieldId))
+ return false;
+
+ return IsNullHeader();
+ }
+
+ /// <summary>
+ /// Seeks specified field and invokes provided func.
+ /// </summary>
+ private T ReadField<T>(string fieldName, Func<IPortableStream, T> readFunc)
+ {
+ return SeekField(fieldName) ? readFunc(Stream) : default(T);
+ }
+
+ /// <summary>
+ /// Seeks specified field and invokes provided func.
+ /// </summary>
+ private T ReadField<T>(string fieldName, Func<PortableReaderImpl, T> readFunc)
+ {
+ return SeekField(fieldName) ? readFunc(this) : default(T);
+ }
+
+ /// <summary>
+ /// Seeks specified field and invokes provided func.
+ /// </summary>
+ private T ReadField<T>(string fieldName, Func<T> readFunc)
+ {
+ return SeekField(fieldName) ? readFunc() : default(T);
+ }
+
+ /// <summary>
+ /// Reads header and invokes specified func if the header is not null.
+ /// </summary>
+ private T Read<T>(Func<PortableReaderImpl, T> readFunc)
+ {
+ return IsNullHeader() ? readFunc(this) : default(T);
+ }
+
+ /// <summary>
+ /// Reads header and invokes specified func if the header is not null.
+ /// </summary>
+ private T Read<T>(Func<IPortableStream, T> readFunc)
+ {
+ return IsNullHeader() ? readFunc(Stream) : default(T);
+ }
+
+ /// <summary>
+ /// Gets the portable user object from a byte array.
+ /// </summary>
+ /// <param name="pos">Position in the current stream.</param>
+ /// <param name="offs">Offset in the byte array.</param>
+ /// <param name="bytes">Bytes.</param>
+ private PortableUserObject GetPortableUserObject(int pos, int offs, byte[] bytes)
+ {
- Stream.Seek(pos + 2, SeekOrigin.Begin);
++ Stream.Seek(pos + PortableUtils.OffsetTypeId, SeekOrigin.Begin);
+
+ var id = Stream.ReadInt();
+
+ var hash = Stream.ReadInt();
+
+ return new PortableUserObject(_marsh, bytes, offs, id, hash);
+ }
+ }
+ }
http://git-wip-us.apache.org/repos/asf/ignite/blob/ec58b87c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs
----------------------------------------------------------------------
diff --cc modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs
index 0000000,891f261..2bf5ab8
mode 000000,100644..100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs
@@@ -1,0 -1,385 +1,385 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Portable
+ {
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.IO;
+ using System.Runtime.CompilerServices;
+ using System.Text;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Impl.Portable.IO;
+ using Apache.Ignite.Core.Portable;
+
+ /// <summary>
+ /// User portable object.
+ /// </summary>
+ internal class PortableUserObject : IPortableObject
+ {
+ /** Marshaller. */
+ private readonly PortableMarshaller _marsh;
+
+ /** Raw data of this portable object. */
+ private readonly byte[] _data;
+
+ /** Offset in data array. */
+ private readonly int _offset;
+
+ /** Type ID. */
+ private readonly int _typeId;
+
+ /** Hash code. */
+ private readonly int _hashCode;
+
+ /** Fields. */
+ private volatile IDictionary<int, int> _fields;
+
+ /** Deserialized value. */
+ private object _deserialized;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="PortableUserObject"/> class.
+ /// </summary>
+ /// <param name="marsh">Marshaller.</param>
+ /// <param name="data">Raw data of this portable object.</param>
+ /// <param name="offset">Offset in data array.</param>
+ /// <param name="typeId">Type ID.</param>
+ /// <param name="hashCode">Hash code.</param>
+ public PortableUserObject(PortableMarshaller marsh, byte[] data, int offset, int typeId, int hashCode)
+ {
+ _marsh = marsh;
+
+ _data = data;
+ _offset = offset;
+
+ _typeId = typeId;
+ _hashCode = hashCode;
+ }
+
+ /** <inheritdoc /> */
+ public int TypeId
+ {
+ get { return _typeId; }
+ }
+
+ /** <inheritdoc /> */
+ public T GetField<T>(string fieldName)
+ {
+ return Field<T>(fieldName, null);
+ }
+
+ /** <inheritdoc /> */
+ public T Deserialize<T>()
+ {
+ return Deserialize<T>(PortableMode.Deserialize);
+ }
+
+ /// <summary>
+ /// Internal deserialization routine.
+ /// </summary>
+ /// <param name="mode">The mode.</param>
+ /// <returns>
+ /// Deserialized object.
+ /// </returns>
+ private T Deserialize<T>(PortableMode mode)
+ {
+ if (_deserialized == null)
+ {
+ IPortableStream stream = new PortableHeapStream(_data);
+
+ stream.Seek(_offset, SeekOrigin.Begin);
+
+ T res = _marsh.Unmarshal<T>(stream, mode);
+
+ IPortableTypeDescriptor desc = _marsh.GetDescriptor(true, _typeId);
+
+ if (!desc.KeepDeserialized)
+ return res;
+
+ _deserialized = res;
+ }
+
+ return (T)_deserialized;
+ }
+
+ /** <inheritdoc /> */
+ public IPortableMetadata GetMetadata()
+ {
+ return _marsh.GetMetadata(_typeId);
+ }
+
+ /// <summary>
+ /// Raw data of this portable object.
+ /// </summary>
+ public byte[] Data
+ {
+ get { return _data; }
+ }
+
+ /// <summary>
+ /// Offset in data array.
+ /// </summary>
+ public int Offset
+ {
+ get { return _offset; }
+ }
+
+ /// <summary>
+ /// Get field with builder.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="fieldName"></param>
+ /// <param name="builder"></param>
+ /// <returns></returns>
+ public T Field<T>(string fieldName, PortableBuilderImpl builder)
+ {
+ IPortableTypeDescriptor desc = _marsh.GetDescriptor(true, _typeId);
+
+ InitializeFields();
+
+ int fieldId = PortableUtils.FieldId(_typeId, fieldName, desc.NameConverter, desc.Mapper);
+
+ int pos;
+
+ if (_fields.TryGetValue(fieldId, out pos))
+ {
+ if (builder != null)
+ {
+ // Read in scope of build process.
+ T res;
+
+ if (!builder.CachedField(pos, out res))
+ {
+ res = Field0<T>(pos, builder);
+
+ builder.CacheField(pos, res);
+ }
+
+ return res;
+ }
+ return Field0<T>(pos, null);
+ }
+ return default(T);
+ }
+
+ /// <summary>
+ /// Lazy fields initialization routine.
+ /// </summary>
+ private void InitializeFields()
+ {
+ if (_fields == null)
+ {
+ IPortableStream stream = new PortableHeapStream(_data);
+
- stream.Seek(_offset + 14, SeekOrigin.Begin);
++ stream.Seek(_offset + PortableUtils.OffsetRawOff, SeekOrigin.Begin);
+
+ int rawDataOffset = stream.ReadInt();
+
+ _fields = PortableUtils.ObjectFields(stream, _typeId, rawDataOffset);
+ }
+ }
+
+ /// <summary>
+ /// Gets field value on the given object.
+ /// </summary>
+ /// <param name="pos">Position.</param>
+ /// <param name="builder">Builder.</param>
+ /// <returns>Field value.</returns>
+ private T Field0<T>(int pos, PortableBuilderImpl builder)
+ {
+ IPortableStream stream = new PortableHeapStream(_data);
+
+ stream.Seek(pos, SeekOrigin.Begin);
+
+ return _marsh.Unmarshal<T>(stream, PortableMode.ForcePortable, builder);
+ }
+
+ /** <inheritdoc /> */
+ public override int GetHashCode()
+ {
+ return _hashCode;
+ }
+
+ /** <inheritdoc /> */
+ public override bool Equals(object obj)
+ {
+ if (this == obj)
+ return true;
+
+ PortableUserObject that = obj as PortableUserObject;
+
+ if (that != null)
+ {
+ if (_data == that._data && _offset == that._offset)
+ return true;
+
+ // 1. Check hash code and type IDs.
+ if (_hashCode == that._hashCode && _typeId == that._typeId)
+ {
+ // 2. Check if objects have the same field sets.
+ InitializeFields();
+ that.InitializeFields();
+
+ if (_fields.Keys.Count != that._fields.Keys.Count)
+ return false;
+
+ foreach (int id in _fields.Keys)
+ {
+ if (!that._fields.Keys.Contains(id))
+ return false;
+ }
+
+ // 3. Check if objects have the same field values.
+ foreach (KeyValuePair<int, int> field in _fields)
+ {
+ object fieldVal = Field0<object>(field.Value, null);
+ object thatFieldVal = that.Field0<object>(that._fields[field.Key], null);
+
+ if (!Equals(fieldVal, thatFieldVal))
+ return false;
+ }
+
+ // 4. Check if objects have the same raw data.
+ IPortableStream stream = new PortableHeapStream(_data);
- stream.Seek(_offset + 10, SeekOrigin.Begin);
++ stream.Seek(_offset + PortableUtils.OffsetLen, SeekOrigin.Begin);
+ int len = stream.ReadInt();
+ int rawOffset = stream.ReadInt();
+
+ IPortableStream thatStream = new PortableHeapStream(that._data);
- thatStream.Seek(_offset + 10, SeekOrigin.Begin);
++ thatStream.Seek(_offset + PortableUtils.OffsetLen, SeekOrigin.Begin);
+ int thatLen = thatStream.ReadInt();
+ int thatRawOffset = thatStream.ReadInt();
+
+ return PortableUtils.CompareArrays(_data, _offset + rawOffset, len - rawOffset, that._data,
+ that._offset + thatRawOffset, thatLen - thatRawOffset);
+ }
+ }
+
+ return false;
+ }
+
+ /** <inheritdoc /> */
+ public override string ToString()
+ {
+ return ToString(new Dictionary<int, int>());
+ }
+
+ /// <summary>
+ /// ToString implementation.
+ /// </summary>
+ /// <param name="handled">Already handled objects.</param>
+ /// <returns>Object string.</returns>
+ private string ToString(IDictionary<int, int> handled)
+ {
+ int idHash;
+
+ bool alreadyHandled = handled.TryGetValue(_offset, out idHash);
+
+ if (!alreadyHandled)
+ idHash = RuntimeHelpers.GetHashCode(this);
+
+ StringBuilder sb;
+
+ IPortableTypeDescriptor desc = _marsh.GetDescriptor(true, _typeId);
+
+ IPortableMetadata meta;
+
+ try
+ {
+ meta = _marsh.GetMetadata(_typeId);
+ }
+ catch (IgniteException)
+ {
+ meta = null;
+ }
+
+ if (meta == null)
+ sb = new StringBuilder("PortableObject [typeId=").Append(_typeId).Append(", idHash=" + idHash);
+ else
+ {
+ sb = new StringBuilder(meta.TypeName).Append(" [idHash=" + idHash);
+
+ if (!alreadyHandled)
+ {
+ handled[_offset] = idHash;
+
+ InitializeFields();
+
+ foreach (string fieldName in meta.Fields)
+ {
+ sb.Append(", ");
+
+ int fieldId = PortableUtils.FieldId(_typeId, fieldName, desc.NameConverter, desc.Mapper);
+
+ int fieldPos;
+
+ if (_fields.TryGetValue(fieldId, out fieldPos))
+ {
+ sb.Append(fieldName).Append('=');
+
+ ToString0(sb, Field0<object>(fieldPos, null), handled);
+ }
+ }
+ }
+ else
+ sb.Append(", ...");
+ }
+
+ sb.Append(']');
+
+ return sb.ToString();
+ }
+
+ /// <summary>
+ /// Internal ToString routine with correct collections printout.
+ /// </summary>
+ /// <param name="sb">String builder.</param>
+ /// <param name="obj">Object to print.</param>
+ /// <param name="handled">Already handled objects.</param>
+ /// <returns>The same string builder.</returns>
+ private static void ToString0(StringBuilder sb, object obj, IDictionary<int, int> handled)
+ {
+ IEnumerable col = (obj is string) ? null : obj as IEnumerable;
+
+ if (col == null)
+ {
+ PortableUserObject obj0 = obj as PortableUserObject;
+
+ sb.Append(obj0 == null ? obj : obj0.ToString(handled));
+ }
+ else
+ {
+ sb.Append('[');
+
+ bool first = true;
+
+ foreach (object elem in col)
+ {
+ if (first)
+ first = false;
+ else
+ sb.Append(", ");
+
+ ToString0(sb, elem, handled);
+ }
+
+ sb.Append(']');
+ }
+ }
+ }
+ }
[24/50] [abbrv] ignite git commit: IGNITE-1733
Posted by vo...@apache.org.
IGNITE-1733
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/10cf673c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/10cf673c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/10cf673c
Branch: refs/heads/ignite-1651
Commit: 10cf673ce288229d5ff346f95542e0b8d4a9fea0
Parents: 9527933
Author: Anton Vinogradov <av...@apache.org>
Authored: Mon Oct 19 18:23:47 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Mon Oct 19 18:23:47 2015 +0300
----------------------------------------------------------------------
.../misc/schedule/ComputeScheduleExample.java | 82 ++++++++++++++++++++
.../examples/misc/schedule/package-info.java | 22 ++++++
.../misc/schedule/ComputeScheduleExample.java | 68 ++++++++++++++++
.../java8/misc/schedule/package-info.java | 22 ++++++
.../misc/schedule/ComputeScheduleExample.java | 82 --------------------
.../examples/misc/schedule/package-info.java | 22 ------
.../misc/schedule/ComputeScheduleExample.java | 68 ----------------
.../java8/misc/schedule/package-info.java | 22 ------
8 files changed, 194 insertions(+), 194 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/10cf673c/examples-lgpl/src/main/java/org/apache/ignite/examples/misc/schedule/ComputeScheduleExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/misc/schedule/ComputeScheduleExample.java b/examples-lgpl/src/main/java/org/apache/ignite/examples/misc/schedule/ComputeScheduleExample.java
new file mode 100644
index 0000000..f8d0660
--- /dev/null
+++ b/examples-lgpl/src/main/java/org/apache/ignite/examples/misc/schedule/ComputeScheduleExample.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.examples.misc.schedule;
+
+import java.util.concurrent.Callable;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.scheduler.SchedulerFuture;
+
+/**
+ * Demonstrates a cron-based {@link Runnable} execution scheduling.
+ * Test runnable object broadcasts a phrase to all cluster nodes every minute
+ * three times with initial scheduling delay equal to five seconds.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class ComputeScheduleExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ * @throws IgniteException If example execution failed.
+ */
+ public static void main(String[] args) throws IgniteException {
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ System.out.println();
+ System.out.println("Compute schedule example started.");
+
+ // Schedule output message every minute.
+ SchedulerFuture<?> fut = ignite.scheduler().scheduleLocal(
+ new Callable<Integer>() {
+ private int invocations;
+
+ @Override public Integer call() {
+ invocations++;
+
+ ignite.compute().broadcast(
+ new IgniteRunnable() {
+ @Override public void run() {
+ System.out.println();
+ System.out.println("Howdy! :)");
+ }
+ }
+ );
+
+ return invocations;
+ }
+ },
+ "{5, 3} * * * * *" // Cron expression.
+ );
+
+ while (!fut.isDone())
+ System.out.println(">>> Invocation #: " + fut.get());
+
+ System.out.println();
+ System.out.println(">>> Schedule future is done and has been unscheduled.");
+ System.out.println(">>> Check all nodes for hello message output.");
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/10cf673c/examples-lgpl/src/main/java/org/apache/ignite/examples/misc/schedule/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/misc/schedule/package-info.java b/examples-lgpl/src/main/java/org/apache/ignite/examples/misc/schedule/package-info.java
new file mode 100644
index 0000000..6602a6e
--- /dev/null
+++ b/examples-lgpl/src/main/java/org/apache/ignite/examples/misc/schedule/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 description. -->
+ * Demonstrates usage of cron-based scheduler.
+ */
+package org.apache.ignite.examples.misc.schedule;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/10cf673c/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java
new file mode 100644
index 0000000..c250638
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.examples.java8.misc.schedule;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.scheduler.SchedulerFuture;
+
+/**
+ * Demonstrates a cron-based {@link Runnable} execution scheduling.
+ * Test runnable object broadcasts a phrase to all cluster nodes every minute
+ * three times with initial scheduling delay equal to five seconds.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class ComputeScheduleExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ * @throws IgniteException If example execution failed.
+ */
+ public static void main(String[] args) throws IgniteException {
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ System.out.println();
+ System.out.println("Compute schedule example started.");
+
+ // Schedule output message every minute.
+ SchedulerFuture<?> fut = ignite.scheduler().scheduleLocal(() ->
+ ignite.compute().broadcast(() -> {
+ System.out.println();
+ System.out.println("Howdy! :)");
+
+ return "Howdy! :)";
+ }),
+ "{5, 3} * * * * *" // Cron expression.
+ );
+
+ while (!fut.isDone())
+ System.out.println(">>> Invocation result: " + fut.get());
+
+ System.out.println();
+ System.out.println(">>> Schedule future is done and has been unscheduled.");
+ System.out.println(">>> Check all nodes for hello message output.");
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/10cf673c/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java
new file mode 100644
index 0000000..5855994
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 description. -->
+ * Demonstrates usage of cron-based scheduler.
+ */
+package org.apache.ignite.examples.java8.misc.schedule;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/10cf673c/examples/src/main/java/org/apache/ignite/examples/misc/schedule/ComputeScheduleExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/misc/schedule/ComputeScheduleExample.java b/examples/src/main/java/org/apache/ignite/examples/misc/schedule/ComputeScheduleExample.java
deleted file mode 100644
index f8d0660..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/misc/schedule/ComputeScheduleExample.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.misc.schedule;
-
-import java.util.concurrent.Callable;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.lang.IgniteRunnable;
-import org.apache.ignite.scheduler.SchedulerFuture;
-
-/**
- * Demonstrates a cron-based {@link Runnable} execution scheduling.
- * Test runnable object broadcasts a phrase to all cluster nodes every minute
- * three times with initial scheduling delay equal to five seconds.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class ComputeScheduleExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws IgniteException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println("Compute schedule example started.");
-
- // Schedule output message every minute.
- SchedulerFuture<?> fut = ignite.scheduler().scheduleLocal(
- new Callable<Integer>() {
- private int invocations;
-
- @Override public Integer call() {
- invocations++;
-
- ignite.compute().broadcast(
- new IgniteRunnable() {
- @Override public void run() {
- System.out.println();
- System.out.println("Howdy! :)");
- }
- }
- );
-
- return invocations;
- }
- },
- "{5, 3} * * * * *" // Cron expression.
- );
-
- while (!fut.isDone())
- System.out.println(">>> Invocation #: " + fut.get());
-
- System.out.println();
- System.out.println(">>> Schedule future is done and has been unscheduled.");
- System.out.println(">>> Check all nodes for hello message output.");
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/10cf673c/examples/src/main/java/org/apache/ignite/examples/misc/schedule/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/misc/schedule/package-info.java b/examples/src/main/java/org/apache/ignite/examples/misc/schedule/package-info.java
deleted file mode 100644
index 6602a6e..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/misc/schedule/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Demonstrates usage of cron-based scheduler.
- */
-package org.apache.ignite.examples.misc.schedule;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/10cf673c/examples/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java
deleted file mode 100644
index c250638..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.misc.schedule;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.scheduler.SchedulerFuture;
-
-/**
- * Demonstrates a cron-based {@link Runnable} execution scheduling.
- * Test runnable object broadcasts a phrase to all cluster nodes every minute
- * three times with initial scheduling delay equal to five seconds.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class ComputeScheduleExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws IgniteException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println("Compute schedule example started.");
-
- // Schedule output message every minute.
- SchedulerFuture<?> fut = ignite.scheduler().scheduleLocal(() ->
- ignite.compute().broadcast(() -> {
- System.out.println();
- System.out.println("Howdy! :)");
-
- return "Howdy! :)";
- }),
- "{5, 3} * * * * *" // Cron expression.
- );
-
- while (!fut.isDone())
- System.out.println(">>> Invocation result: " + fut.get());
-
- System.out.println();
- System.out.println(">>> Schedule future is done and has been unscheduled.");
- System.out.println(">>> Check all nodes for hello message output.");
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/10cf673c/examples/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java b/examples/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java
deleted file mode 100644
index 5855994..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Demonstrates usage of cron-based scheduler.
- */
-package org.apache.ignite.examples.java8.misc.schedule;
\ No newline at end of file
[23/50] [abbrv] ignite git commit: Mute tests
Posted by vo...@apache.org.
Mute tests
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9527933e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9527933e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9527933e
Branch: refs/heads/ignite-1651
Commit: 9527933e5fd088bdb1e541daf6cf3fb412aadc1e
Parents: 50cf42a
Author: ashutak <as...@gridgain.com>
Authored: Mon Oct 19 14:58:57 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Mon Oct 19 14:58:57 2015 +0300
----------------------------------------------------------------------
.../cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java | 2 ++
.../dht/IgniteAtomicLongChangingTopologySelfTest.java | 4 +++-
.../ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java | 2 ++
3 files changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9527933e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
index 4302486..cadd03f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
@@ -137,6 +137,8 @@ public class GridCacheTxNodeFailureSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPrimaryNodeFailureBackupRollbackOptimistic() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1731");
+
checkPrimaryNodeFailureBackupCommit(OPTIMISTIC, false, false);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9527933e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteAtomicLongChangingTopologySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteAtomicLongChangingTopologySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteAtomicLongChangingTopologySelfTest.java
index 32a86e4..19daa26 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteAtomicLongChangingTopologySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteAtomicLongChangingTopologySelfTest.java
@@ -133,6 +133,8 @@ public class IgniteAtomicLongChangingTopologySelfTest extends GridCommonAbstract
* @throws Exception If failed.
*/
public void testClientAtomicLongCreateCloseFailover() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1732");
+
testFailoverWithClient(new IgniteInClosure<Ignite>() {
@Override public void apply(Ignite ignite) {
for (int i = 0; i < 100; i++) {
@@ -391,4 +393,4 @@ public class IgniteAtomicLongChangingTopologySelfTest extends GridCommonAbstract
}
}, 1, "grunner-" + i);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9527933e/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
index a8c8388..26d87a9 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
@@ -74,6 +74,8 @@ public class SqlFieldsQuerySelfTest extends GridCommonAbstractTest {
* @throws Exception If error.
*/
public void testSqlFieldsQueryWithTopologyChanges() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1698");
+
startGrid(0);
createAndFillCache();
[37/50] [abbrv] ignite git commit: Muted
GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.testIgniteCacheIterator
muted
Posted by vo...@apache.org.
Muted GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.testIgniteCacheIterator muted
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9ffe402c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9ffe402c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9ffe402c
Branch: refs/heads/ignite-1651
Commit: 9ffe402cf50c3b4260f132945b8d51e56f3926fd
Parents: 0acb5db
Author: ashutak <as...@gridgain.com>
Authored: Wed Oct 21 14:56:54 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Wed Oct 21 14:56:54 2015 +0300
----------------------------------------------------------------------
.../GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9ffe402c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.java
index 2ee9335..608729a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.java
@@ -30,4 +30,9 @@ public class GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest extends
@Override protected CacheMemoryMode memoryMode() {
return OFFHEAP_TIERED;
}
-}
\ No newline at end of file
+
+ /** {@inheritDoc} */
+ @Override public void testIgniteCacheIterator() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1756");
+ }
+}
[10/50] [abbrv] ignite git commit: IGNITE-1653
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java
new file mode 100644
index 0000000..cef9f2f
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.examples.java8.streaming;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Random;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.examples.ExamplesUtils;
+import org.apache.ignite.stream.StreamVisitor;
+
+/**
+ * Stream random numbers into the streaming cache.
+ * To start the example, you should:
+ * <ul>
+ * <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li>
+ * <li>Start streaming using {@link StreamVisitorExample}.</li>
+ * </ul>
+ * <p>
+ * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM.
+ */
+public class StreamVisitorExample {
+ /** Random number generator. */
+ private static final Random RAND = new Random();
+
+ /** The list of instruments. */
+ private static final String[] INSTRUMENTS = {"IBM", "GOOG", "MSFT", "GE", "EBAY", "YHOO", "ORCL", "CSCO", "AMZN", "RHT"};
+
+ /** The list of initial instrument prices. */
+ private static final double[] INITIAL_PRICES = {194.9, 893.49, 34.21, 23.24, 57.93, 45.03, 44.41, 28.44, 378.49, 69.50};
+
+ public static void main(String[] args) throws Exception {
+ // Mark this cluster member as client.
+ Ignition.setClientMode(true);
+
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ if (!ExamplesUtils.hasServerNodes(ignite))
+ return;
+
+ // Market data cache with default configuration.
+ CacheConfiguration<String, Double> mktDataCfg = new CacheConfiguration<>("marketTicks");
+
+ // Financial instrument cache configuration.
+ CacheConfiguration<String, Instrument> instCfg = new CacheConfiguration<>("instCache");
+
+ // Index key and value for querying financial instruments.
+ // Note that Instrument class has @QuerySqlField annotation for secondary field indexing.
+ instCfg.setIndexedTypes(String.class, Instrument.class);
+
+ // Auto-close caches at the end of the example.
+ try (
+ IgniteCache<String, Double> mktCache = ignite.getOrCreateCache(mktDataCfg);
+ IgniteCache<String, Instrument> instCache = ignite.getOrCreateCache(instCfg)
+ ) {
+ try (IgniteDataStreamer<String, Double> mktStmr = ignite.dataStreamer(mktCache.getName())) {
+ // Note that we receive market data, but do not populate 'mktCache' (it remains empty).
+ // Instead we update the instruments in the 'instCache'.
+ // Since both, 'instCache' and 'mktCache' use the same key, updates are collocated.
+ mktStmr.receiver(StreamVisitor.from((cache, e) -> {
+ String symbol = e.getKey();
+ Double tick = e.getValue();
+
+ Instrument inst = instCache.get(symbol);
+
+ if (inst == null)
+ inst = new Instrument(symbol);
+
+ // Don't populate market cache, as we don't use it for querying.
+ // Update cached instrument based on the latest market tick.
+ inst.update(tick);
+
+ instCache.put(symbol, inst);
+ }));
+
+ // Stream 10 million market data ticks into the system.
+ for (int i = 1; i <= 10_000_000; i++) {
+ int idx = RAND.nextInt(INSTRUMENTS.length);
+
+ // Use gaussian distribution to ensure that
+ // numbers closer to 0 have higher probability.
+ double price = round2(INITIAL_PRICES[idx] + RAND.nextGaussian());
+
+ mktStmr.addData(INSTRUMENTS[idx], price);
+
+ if (i % 500_000 == 0)
+ System.out.println("Number of tuples streamed into Ignite: " + i);
+ }
+ }
+
+ // Select top 3 best performing instruments.
+ SqlFieldsQuery top3qry = new SqlFieldsQuery(
+ "select symbol, (latest - open) from Instrument order by (latest - open) desc limit 3");
+
+ // Execute queries.
+ List<List<?>> top3 = instCache.query(top3qry).getAll();
+
+ System.out.println("Top performing financial instruments: ");
+
+ // Print top 10 words.
+ ExamplesUtils.printQueryResults(top3);
+ }
+ }
+ }
+
+ /**
+ * Rounds double value to two significant signs.
+ *
+ * @param val value to be rounded.
+ * @return rounded double value.
+ */
+ private static double round2(double val) {
+ return Math.floor(100 * val + 0.5) / 100;
+ }
+
+ /**
+ * Financial instrument.
+ */
+ public static class Instrument implements Serializable {
+ /** Instrument symbol. */
+ @QuerySqlField(index = true)
+ private final String symbol;
+
+ /** Open price. */
+ @QuerySqlField(index = true)
+ private double open;
+
+ /** Close price. */
+ @QuerySqlField(index = true)
+ private double latest;
+
+ /**
+ * @param symbol Symbol.
+ */
+ public Instrument(String symbol) {
+ this.symbol = symbol;
+ }
+
+ /**
+ * Updates this instrument based on the latest market tick price.
+ *
+ * @param price Latest price.
+ */
+ public void update(double price) {
+ if (open == 0)
+ open = price;
+
+ this.latest = price;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/package-info.java
new file mode 100644
index 0000000..d215d2f
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 description. -->
+ * Demonstrates usage of data streamer.
+ */
+package org.apache.ignite.examples.java8.streaming;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleMultiNodeSelfTest.java b/examples-lgpl/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleMultiNodeSelfTest.java
new file mode 100644
index 0000000..8a40d4a
--- /dev/null
+++ b/examples-lgpl/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleMultiNodeSelfTest.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.examples;
+
+import org.apache.ignite.examples.datagrid.hibernate.HibernateL2CacheExample;
+
+/**
+ * Multi-node test for {@link HibernateL2CacheExample}.
+ */
+public class HibernateL2CacheExampleMultiNodeSelfTest extends HibernateL2CacheExampleSelfTest {
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ for (int i = 0; i < RMT_NODES_CNT; i++)
+ startGrid("node-" + i, "examples/config/example-ignite.xml");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleSelfTest.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleSelfTest.java b/examples-lgpl/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleSelfTest.java
new file mode 100644
index 0000000..68767d7
--- /dev/null
+++ b/examples-lgpl/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleSelfTest.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples;
+
+import org.apache.ignite.examples.datagrid.hibernate.HibernateL2CacheExample;
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
+
+/**
+ * Tests the {@link HibernateL2CacheExample}.
+ */
+public class HibernateL2CacheExampleSelfTest extends GridAbstractExamplesTest {
+ /**
+ * @throws Exception If failed.
+ */
+ public void testHibernateL2CacheExample() throws Exception {
+ HibernateL2CacheExample.main(EMPTY_ARGS);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/test/java/org/apache/ignite/testsuites/IgniteLgplExamplesSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/test/java/org/apache/ignite/testsuites/IgniteLgplExamplesSelfTestSuite.java b/examples-lgpl/src/test/java/org/apache/ignite/testsuites/IgniteLgplExamplesSelfTestSuite.java
new file mode 100644
index 0000000..7c99712
--- /dev/null
+++ b/examples-lgpl/src/test/java/org/apache/ignite/testsuites/IgniteLgplExamplesSelfTestSuite.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.examples.HibernateL2CacheExampleMultiNodeSelfTest;
+import org.apache.ignite.examples.HibernateL2CacheExampleSelfTest;
+import org.apache.ignite.testframework.GridTestUtils;
+
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_OVERRIDE_MCAST_GRP;
+
+/**
+ * Examples test suite. <p> Contains only Spring ignite examples tests.
+ */
+public class IgniteLgplExamplesSelfTestSuite extends TestSuite {
+ /**
+ * @return Suite.
+ * @throws Exception If failed.
+ */
+ public static TestSuite suite() throws Exception {
+ System.setProperty(IGNITE_OVERRIDE_MCAST_GRP,
+ GridTestUtils.getNextMulticastGroup(IgniteLgplExamplesSelfTestSuite.class));
+
+ TestSuite suite = new TestSuite("Ignite Examples Test Suite");
+
+ suite.addTest(new TestSuite(HibernateL2CacheExampleSelfTest.class));
+
+ // Multi-node.
+ suite.addTest(new TestSuite(HibernateL2CacheExampleMultiNodeSelfTest.class));
+
+ return suite;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleMultiNodeSelfTest.java b/examples-lgpl/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleMultiNodeSelfTest.java
new file mode 100644
index 0000000..edfba3d
--- /dev/null
+++ b/examples-lgpl/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleMultiNodeSelfTest.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.java8.examples;
+
+/**
+ * Multi-node test for {@link org.apache.ignite.examples.java8.datagrid.hibernate.HibernateL2CacheExample}.
+ */
+public class HibernateL2CacheExampleMultiNodeSelfTest extends HibernateL2CacheExampleSelfTest {
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ for (int i = 0; i < RMT_NODES_CNT; i++)
+ startGrid("node-" + i, "examples/config/example-ignite.xml");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleSelfTest.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleSelfTest.java b/examples-lgpl/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleSelfTest.java
new file mode 100644
index 0000000..8c7a2de
--- /dev/null
+++ b/examples-lgpl/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleSelfTest.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.java8.examples;
+
+//import org.apache.ignite.examples.java8.datagrid.hibernate.*;
+
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
+
+/**
+ * Tests the {@link org.apache.ignite.examples.java8.datagrid.hibernate.HibernateL2CacheExample}.
+ */
+public class HibernateL2CacheExampleSelfTest extends GridAbstractExamplesTest {
+ /**
+ * TODO: IGNITE-711 next example(s) should be implemented for java 8
+ * or testing method(s) should be removed if example(s) does not applicable for java 8.
+ *
+ * @throws Exception If failed.
+ */
+// public void testHibernateL2CacheExample() throws Exception {
+// HibernateL2CacheExample.main(EMPTY_ARGS);
+// }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/test/java8/org/apache/ignite/java8/testsuites/IgniteLgplExamplesJ8SelfTestSuite.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/test/java8/org/apache/ignite/java8/testsuites/IgniteLgplExamplesJ8SelfTestSuite.java b/examples-lgpl/src/test/java8/org/apache/ignite/java8/testsuites/IgniteLgplExamplesJ8SelfTestSuite.java
new file mode 100644
index 0000000..bdda5f6
--- /dev/null
+++ b/examples-lgpl/src/test/java8/org/apache/ignite/java8/testsuites/IgniteLgplExamplesJ8SelfTestSuite.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.java8.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.testframework.GridTestUtils;
+
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_OVERRIDE_MCAST_GRP;
+
+/**
+ * Examples test suite. <p> Contains only Spring ignite examples tests.
+ */
+public class IgniteLgplExamplesJ8SelfTestSuite extends TestSuite {
+ /**
+ * @return Suite.
+ * @throws Exception If failed.
+ */
+ public static TestSuite suite() throws Exception {
+ System.setProperty(IGNITE_OVERRIDE_MCAST_GRP,
+ GridTestUtils.getNextMulticastGroup(IgniteLgplExamplesJ8SelfTestSuite.class));
+
+ TestSuite suite = new TestSuite("Ignite Examples Test Suite");
+
+// suite.addTest(new TestSuite(HibernateL2CacheExampleSelfTest.class));
+
+ // Multi-node.
+// suite.addTest(new TestSuite(HibernateL2CacheExampleMultiNodeSelfTest.class));
+
+ return suite;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/pom-standalone.xml
----------------------------------------------------------------------
diff --git a/examples/pom-standalone.xml b/examples/pom-standalone.xml
index 996753e..e314acb 100644
--- a/examples/pom-standalone.xml
+++ b/examples/pom-standalone.xml
@@ -49,12 +49,6 @@
<dependency>
<groupId>org.apache.ignite</groupId>
- <artifactId>ignite-hibernate</artifactId>
- <version>to_be_replaced_by_ignite_version</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ignite</groupId>
<artifactId>ignite-spring</artifactId>
<version>to_be_replaced_by_ignite_version</version>
</dependency>
@@ -72,12 +66,6 @@
</dependency>
<dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-schedule</artifactId>
- <version>to_be_replaced_by_ignite_version</version>
- </dependency>
-
- <dependency>
<groupId>com.google.code.simple-spring-memcached</groupId>
<artifactId>spymemcached</artifactId>
<version>2.7.3</version>
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index e4ec73a..34ba05a 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -45,12 +45,6 @@
<dependency>
<groupId>org.apache.ignite</groupId>
- <artifactId>ignite-hibernate</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ignite</groupId>
<artifactId>ignite-spring</artifactId>
<version>${project.version}</version>
</dependency>
@@ -68,12 +62,6 @@
</dependency>
<dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-schedule</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
<groupId>com.google.code.simple-spring-memcached</groupId>
<artifactId>spymemcached</artifactId>
<version>2.7.3</version>
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
deleted file mode 100644
index 2f271c8..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.datagrid.hibernate;
-
-import java.net.URL;
-import java.util.Arrays;
-import java.util.List;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.CacheAtomicityMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.examples.ExamplesUtils;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.stat.SecondLevelCacheStatistics;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
-import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
-import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
-
-/**
- * This example demonstrates the use of Ignite In-Memory Data Ignite cluster as a Hibernate
- * Second-Level cache provider.
- * <p>
- * The Hibernate Second-Level cache (or "L2 cache" shortly) lets you significantly
- * reduce the number of requests to the underlying SQL database. Because database
- * access is known to be an expansive operation, using L2 cache may improve
- * performance dramatically.
- * <p>
- * This example defines 2 entity classes: {@link User} and {@link Post}, with
- * 1 <-> N relation, and marks them with appropriate annotations for Hibernate
- * object-relational mapping to SQL tables of an underlying H2 in-memory database.
- * The example launches node in the same JVM and registers it in
- * Hibernate configuration as an L2 cache implementation. It then stores and
- * queries instances of the entity classes to and from the database, having
- * Hibernate SQL output, L2 cache statistics output, and Ignite cache metrics
- * output enabled.
- * <p>
- * When running example, it's easy to notice that when an object is first
- * put into a database, the L2 cache is not used and it's contents is empty.
- * However, when an object is first read from the database, it is immediately
- * stored in L2 cache (which is Ignite In-Memory Data Ignite cluster in fact), which can
- * be seen in stats output. Further requests of the same object only read the data
- * from L2 cache and do not hit the database.
- * <p>
- * In this example, the Hibernate query cache is also enabled. Query cache lets you
- * avoid hitting the database in case of repetitive queries with the same parameter
- * values. You may notice that when the example runs the same query repeatedly in
- * loop, only the first query hits the database and the successive requests take the
- * data from L2 cache.
- * <p>
- * Note: this example uses {@link AccessType#READ_ONLY} L2 cache access type, but you
- * can experiment with other access types by modifying the Hibernate configuration file
- * {@code IGNITE_HOME/examples/config/hibernate/example-hibernate-L2-cache.xml}, used by the example.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-ignite.xml} configuration.
- */
-public class HibernateL2CacheExample {
- /** JDBC URL for backing database (an H2 in-memory database is used). */
- private static final String JDBC_URL = "jdbc:h2:mem:example;DB_CLOSE_DELAY=-1";
-
- /** Path to hibernate configuration file (will be resolved from application {@code CLASSPATH}). */
- private static final String HIBERNATE_CFG = "hibernate/example-hibernate-L2-cache.xml";
-
- /** Entity names for stats output. */
- private static final List<String> ENTITY_NAMES =
- Arrays.asList(User.class.getName(), Post.class.getName(), User.class.getName() + ".posts");
-
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws IgniteException {
- // Start the node, run the example, and stop the node when finished.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- // We use a single session factory, but create a dedicated session
- // for each transaction or query. This way we ensure that L1 cache
- // is not used (L1 cache has per-session scope only).
- System.out.println();
- System.out.println(">>> Hibernate L2 cache example started.");
-
- try (
- // Create all required caches.
- IgniteCache c1 = createCache("org.hibernate.cache.spi.UpdateTimestampsCache", ATOMIC);
- IgniteCache c2 = createCache("org.hibernate.cache.internal.StandardQueryCache", ATOMIC);
- IgniteCache c3 = createCache("org.apache.ignite.examples.datagrid.hibernate.User", TRANSACTIONAL);
- IgniteCache c4 = createCache("org.apache.ignite.examples.datagrid.hibernate.User.posts", TRANSACTIONAL);
- IgniteCache c5 = createCache("org.apache.ignite.examples.datagrid.hibernate.Post", TRANSACTIONAL)
- ) {
- URL hibernateCfg = ExamplesUtils.url(HIBERNATE_CFG);
-
- SessionFactory sesFactory = createHibernateSessionFactory(hibernateCfg);
-
- System.out.println();
- System.out.println(">>> Creating objects.");
-
- final long userId;
-
- Session ses = sesFactory.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- User user = new User("jedi", "Luke", "Skywalker");
-
- user.getPosts().add(new Post(user, "Let the Force be with you."));
-
- ses.save(user);
-
- tx.commit();
-
- // Create a user object, store it in DB, and save the database-generated
- // object ID. You may try adding more objects in a similar way.
- userId = user.getId();
- }
- finally {
- ses.close();
- }
-
- // Output L2 cache and Ignite cache stats. You may notice that
- // at this point the object is not yet stored in L2 cache, because
- // the read was not yet performed.
- printStats(sesFactory);
-
- System.out.println();
- System.out.println(">>> Querying object by ID.");
-
- // Query user by ID several times. First time we get an L2 cache
- // miss, and the data is queried from DB, but it is then stored
- // in cache and successive queries hit the cache and return
- // immediately, no SQL query is made.
- for (int i = 0; i < 3; i++) {
- ses = sesFactory.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- User user = (User)ses.get(User.class, userId);
-
- System.out.println("User: " + user);
-
- for (Post post : user.getPosts())
- System.out.println("\tPost: " + post);
-
- tx.commit();
- }
- finally {
- ses.close();
- }
- }
-
- // Output the stats. We should see 1 miss and 2 hits for
- // User and Collection object (stored separately in L2 cache).
- // The Post is loaded with the collection, so it won't imply
- // a miss.
- printStats(sesFactory);
- }
- }
- }
-
- /**
- * Creates cache.
- *
- * @param name Cache name.
- * @param atomicityMode Atomicity mode.
- * @return Cache configuration.
- */
- private static IgniteCache createCache(String name, CacheAtomicityMode atomicityMode) {
- CacheConfiguration ccfg = new CacheConfiguration(name);
-
- ccfg.setAtomicityMode(atomicityMode);
- ccfg.setWriteSynchronizationMode(FULL_SYNC);
-
- return Ignition.ignite().getOrCreateCache(ccfg);
- }
-
- /**
- * Creates a new Hibernate {@link SessionFactory} using a programmatic
- * configuration.
- *
- * @param hibernateCfg Hibernate configuration file.
- * @return New Hibernate {@link SessionFactory}.
- */
- private static SessionFactory createHibernateSessionFactory(URL hibernateCfg) {
- ServiceRegistryBuilder builder = new ServiceRegistryBuilder();
-
- builder.applySetting("hibernate.connection.url", JDBC_URL);
- builder.applySetting("hibernate.show_sql", true);
-
- return new Configuration()
- .configure(hibernateCfg)
- .buildSessionFactory(builder.buildServiceRegistry());
- }
-
- /**
- * Prints Hibernate L2 cache statistics to standard output.
- *
- * @param sesFactory Hibernate {@link SessionFactory}, for which to print
- * statistics.
- */
- private static void printStats(SessionFactory sesFactory) {
- System.out.println("=== Hibernate L2 cache statistics ===");
-
- for (String entityName : ENTITY_NAMES) {
- System.out.println("\tEntity: " + entityName);
-
- SecondLevelCacheStatistics stats =
- sesFactory.getStatistics().getSecondLevelCacheStatistics(entityName);
-
- System.out.println("\t\tL2 cache entries: " + stats.getEntries());
- System.out.println("\t\tHits: " + stats.getHitCount());
- System.out.println("\t\tMisses: " + stats.getMissCount());
- }
-
- System.out.println("=====================================");
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/Post.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/Post.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/Post.java
deleted file mode 100644
index 798411a..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/Post.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.datagrid.hibernate;
-
-import java.util.Date;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.ManyToOne;
-
-/**
- * An entity class representing a post, that a
- * {@link User} has made on some public service.
- */
-@Entity
-class Post {
- /** ID. */
- @Id
- @GeneratedValue(strategy=GenerationType.AUTO)
- private long id;
-
- /** Author. */
- @ManyToOne
- private User author;
-
- /** Text. */
- private String text;
-
- /** Created timestamp. */
- private Date created;
-
- /**
- * Default constructor (required by Hibernate).
- */
- Post() {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param author Author.
- * @param text Text.
- */
- Post(User author, String text) {
- this.author = author;
- this.text = text;
- created = new Date();
- }
-
- /**
- * @return ID.
- */
- public long getId() {
- return id;
- }
-
- /**
- * @param id New ID.
- */
- public void setId(long id) {
- this.id = id;
- }
-
- /**
- * @return Author.
- */
- public User getAuthor() {
- return author;
- }
-
- /**
- * @param author New author.
- */
- public void setAuthor(User author) {
- this.author = author;
- }
-
- /**
- * @return Text.
- */
- public String getText() {
- return text;
- }
-
- /**
- * @param text New text.
- */
- public void setText(String text) {
- this.text = text;
- }
-
- /**
- * @return Created timestamp.
- */
- public Date getCreated() {
- return (Date)created.clone();
- }
-
- /**
- * @param created New created timestamp.
- */
- public void setCreated(Date created) {
- this.created = (Date)created.clone();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return "Post [id=" + id +
- ", text=" + text +
- ", created=" + created +
- ']';
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/User.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/User.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/User.java
deleted file mode 100644
index b7d5299..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/User.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.datagrid.hibernate;
-
-import java.util.HashSet;
-import java.util.Set;
-import javax.persistence.CascadeType;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.OneToMany;
-import org.hibernate.annotations.NaturalId;
-
-/**
- * A user entity class. Represents a user of some public service,
- * having a number of personal information fields as well as a
- * number of posts written.
- */
-@Entity
-class User {
- /** ID. */
- @Id
- @GeneratedValue(strategy=GenerationType.AUTO)
- private long id;
-
- /** Login. */
- @NaturalId
- private String login;
-
- /** First name. */
- private String firstName;
-
- /** Last name. */
- private String lastName;
-
- /** Posts. */
- @OneToMany(mappedBy = "author", cascade = CascadeType.ALL)
- private Set<Post> posts = new HashSet<>();
-
- /**
- * Default constructor (required by Hibernate).
- */
- User() {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param login Login.
- * @param firstName First name.
- * @param lastName Last name.
- */
- User(String login, String firstName, String lastName) {
- this.login = login;
- this.firstName = firstName;
- this.lastName = lastName;
- }
-
- /**
- * @return ID.
- */
- public long getId() {
- return id;
- }
-
- /**
- * @param id New ID.
- */
- public void setId(long id) {
- this.id = id;
- }
-
- /**
- * @return Login.
- */
- public String getLogin() {
- return login;
- }
-
- /**
- * @param login New login.
- */
- public void setLogin(String login) {
- this.login = login;
- }
-
- /**
- * @return First name.
- */
- public String getFirstName() {
- return firstName;
- }
-
- /**
- * @param firstName New first name.
- */
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- /**
- * @return Last name.
- */
- public String getLastName() {
- return lastName;
- }
-
- /**
- * @param lastName New last name.
- */
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
-
- /**
- * @return Posts.
- */
- public Set<Post> getPosts() {
- return posts;
- }
-
- /**
- * @param posts New posts.
- */
- public void setPosts(Set<Post> posts) {
- this.posts = posts;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return "User [id=" + id +
- ", login=" + login +
- ", firstName=" + firstName +
- ", lastName=" + lastName +
- ']';
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/package-info.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/package-info.java
deleted file mode 100644
index 4bb876b..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Hibernate example.
- */
-package org.apache.ignite.examples.datagrid.hibernate;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java
deleted file mode 100644
index f8831ab..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.datagrid.store.hibernate;
-
-import java.util.List;
-import java.util.UUID;
-import javax.cache.integration.CacheLoaderException;
-import javax.cache.integration.CacheWriterException;
-import org.apache.ignite.cache.store.CacheStore;
-import org.apache.ignite.cache.store.CacheStoreAdapter;
-import org.apache.ignite.cache.store.CacheStoreSession;
-import org.apache.ignite.examples.datagrid.store.Person;
-import org.apache.ignite.lang.IgniteBiInClosure;
-import org.apache.ignite.resources.CacheStoreSessionResource;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-
-/**
- * Example of {@link CacheStore} implementation that uses Hibernate
- * and deals with maps {@link UUID} to {@link Person}.
- */
-public class CacheHibernatePersonStore extends CacheStoreAdapter<Long, Person> {
- /** Auto-injected store session. */
- @CacheStoreSessionResource
- private CacheStoreSession ses;
-
- /** {@inheritDoc} */
- @Override public Person load(Long key) {
- System.out.println(">>> Store load [key=" + key + ']');
-
- Session hibSes = ses.attachment();
-
- try {
- return (Person)hibSes.get(Person.class, key);
- }
- catch (HibernateException e) {
- throw new CacheLoaderException("Failed to load value from cache store [key=" + key + ']', e);
- }
- }
-
- /** {@inheritDoc} */
- @Override public void write(javax.cache.Cache.Entry<? extends Long, ? extends Person> entry) {
- Long key = entry.getKey();
- Person val = entry.getValue();
-
- System.out.println(">>> Store write [key=" + key + ", val=" + val + ']');
-
- Session hibSes = ses.attachment();
-
- try {
- hibSes.saveOrUpdate(val);
- }
- catch (HibernateException e) {
- throw new CacheWriterException("Failed to put value to cache store [key=" + key + ", val" + val + "]", e);
- }
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings({"JpaQueryApiInspection"})
- @Override public void delete(Object key) {
- System.out.println(">>> Store delete [key=" + key + ']');
-
- Session hibSes = ses.attachment();
-
- try {
- hibSes.createQuery("delete " + Person.class.getSimpleName() + " where key = :key").
- setParameter("key", key).
- executeUpdate();
- }
- catch (HibernateException e) {
- throw new CacheWriterException("Failed to remove value from cache store [key=" + key + ']', e);
- }
- }
-
- /** {@inheritDoc} */
- @Override public void loadCache(IgniteBiInClosure<Long, Person> clo, Object... args) {
- if (args == null || args.length == 0 || args[0] == null)
- throw new CacheLoaderException("Expected entry count parameter is not provided.");
-
- final int entryCnt = (Integer)args[0];
-
- Session hibSes = ses.attachment();
-
- try {
- int cnt = 0;
-
- List list = hibSes.createCriteria(Person.class).
- setMaxResults(entryCnt).
- list();
-
- if (list != null) {
- for (Object obj : list) {
- Person person = (Person)obj;
-
- clo.apply(person.getId(), person);
-
- cnt++;
- }
- }
-
- System.out.println(">>> Loaded " + cnt + " values into cache.");
- }
- catch (HibernateException e) {
- throw new CacheLoaderException("Failed to load values from cache store.", e);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java
deleted file mode 100644
index fbb761a..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.datagrid.store.hibernate;
-
-import java.util.UUID;
-import javax.cache.configuration.Factory;
-import javax.cache.configuration.FactoryBuilder;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.store.CacheStoreSessionListener;
-import org.apache.ignite.cache.store.hibernate.CacheHibernateStoreSessionListener;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.examples.ExamplesUtils;
-import org.apache.ignite.examples.datagrid.store.Person;
-import org.apache.ignite.transactions.Transaction;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
-
-/**
- * Demonstrates usage of cache with underlying persistent store configured.
- * <p>
- * This example uses {@link CacheHibernatePersonStore} as a persistent store.
- * <p>
- * Remote nodes can be started with {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-ignite.xml} configuration.
- */
-public class CacheHibernateStoreExample {
- /** Hibernate configuration resource path. */
- private static final String HIBERNATE_CFG =
- "/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml";
-
- /** Cache name. */
- private static final String CACHE_NAME = CacheHibernateStoreExample.class.getSimpleName();
-
- /** Heap size required to run this example. */
- public static final int MIN_MEMORY = 1024 * 1024 * 1024;
-
- /** Number of entries to load. */
- private static final int ENTRY_COUNT = 100_000;
-
- /** Global person ID to use across entire example. */
- private static final Long id = Math.abs(UUID.randomUUID().getLeastSignificantBits());
-
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws IgniteException {
- ExamplesUtils.checkMinMemory(MIN_MEMORY);
-
- // To start ignite with desired configuration uncomment the appropriate line.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println(">>> Cache store example started.");
-
- CacheConfiguration<Long, Person> cacheCfg = new CacheConfiguration<>(CACHE_NAME);
-
- // Set atomicity as transaction, since we are showing transactions in example.
- cacheCfg.setAtomicityMode(TRANSACTIONAL);
-
- // Configure Hibernate store.
- cacheCfg.setCacheStoreFactory(FactoryBuilder.factoryOf(CacheHibernatePersonStore.class));
-
- // Configure Hibernate session listener.
- cacheCfg.setCacheStoreSessionListenerFactories(new Factory<CacheStoreSessionListener>() {
- @Override public CacheStoreSessionListener create() {
- CacheHibernateStoreSessionListener lsnr = new CacheHibernateStoreSessionListener();
-
- lsnr.setHibernateConfigurationPath(HIBERNATE_CFG);
-
- return lsnr;
- }
- });
-
- cacheCfg.setReadThrough(true);
- cacheCfg.setWriteThrough(true);
-
- try (IgniteCache<Long, Person> cache = ignite.getOrCreateCache(cacheCfg)) {
- // Make initial cache loading from persistent store. This is a
- // distributed operation and will call CacheStore.loadCache(...)
- // method on all nodes in topology.
- loadCache(cache);
-
- // Start transaction and execute several cache operations with
- // read/write-through to persistent store.
- executeTransaction(cache);
- }
- }
- }
-
- /**
- * Makes initial cache loading.
- *
- * @param cache Cache to load.
- */
- private static void loadCache(IgniteCache<Long, Person> cache) {
- long start = System.currentTimeMillis();
-
- // Start loading cache from persistent store on all caching nodes.
- cache.loadCache(null, ENTRY_COUNT);
-
- long end = System.currentTimeMillis();
-
- System.out.println(">>> Loaded " + cache.size() + " keys with backups in " + (end - start) + "ms.");
- }
-
- /**
- * Executes transaction with read/write-through to persistent store.
- *
- * @param cache Cache to execute transaction on.
- */
- private static void executeTransaction(IgniteCache<Long, Person> cache) {
- try (Transaction tx = Ignition.ignite().transactions().txStart()) {
- Person val = cache.get(id);
-
- System.out.println("Read value: " + val);
-
- val = cache.getAndPut(id, new Person(id, "Isaac", "Newton"));
-
- System.out.println("Overwrote old value: " + val);
-
- val = cache.get(id);
-
- System.out.println("Read value: " + val);
-
- tx.commit();
- }
-
- System.out.println("Read value after commit: " + cache.get(id));
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml
deleted file mode 100644
index 035ab98..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
-
-<hibernate-mapping default-access="field">
- <class name="org.apache.ignite.examples.datagrid.store.Person" table="PERSONS">
- <!-- ID. -->
- <id name="id"/>
-
- <!-- We only map data we are interested in. -->
- <property name="firstName"/>
- <property name="lastName"/>
- </class>
-</hibernate-mapping>
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml
deleted file mode 100644
index 80a43e7..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<!DOCTYPE hibernate-configuration PUBLIC
- "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
- "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
-
-<!--
- Hibernate configuration.
--->
-<hibernate-configuration>
- <session-factory>
- <!-- Database connection settings (private in-memory database). -->
- <property name="connection.url">jdbc:h2:mem:example;DB_CLOSE_DELAY=-1</property>
-
- <!-- Only validate the database schema on startup in production mode. -->
- <property name="hbm2ddl.auto">update</property>
-
- <!-- Do not output SQL. -->
- <property name="show_sql">false</property>
-
- <!-- Mappings. -->
- <mapping resource="org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml"/>
- </session-factory>
-</hibernate-configuration>
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/package-info.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/package-info.java
deleted file mode 100644
index 7a6d6de..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Contains Hibernate-based cache store implementation.
- */
-package org.apache.ignite.examples.datagrid.store.hibernate;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleMultiNodeSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleMultiNodeSelfTest.java
deleted file mode 100644
index 1ca9b59..0000000
--- a/examples/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleMultiNodeSelfTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples;
-
-import org.apache.ignite.examples.datagrid.hibernate.HibernateL2CacheExample;
-
-/**
- * Multi-node test for {@link HibernateL2CacheExample}.
- */
-public class HibernateL2CacheExampleMultiNodeSelfTest extends HibernateL2CacheExampleSelfTest {
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- for (int i = 0; i < RMT_NODES_CNT; i++)
- startGrid("node-" + i, "examples/config/example-ignite.xml");
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleSelfTest.java
deleted file mode 100644
index 5f55e82..0000000
--- a/examples/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleSelfTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples;
-
-import org.apache.ignite.examples.datagrid.hibernate.HibernateL2CacheExample;
-import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
-
-/**
- * Tests the {@link HibernateL2CacheExample}.
- */
-public class HibernateL2CacheExampleSelfTest extends GridAbstractExamplesTest {
- /**
- * @throws Exception If failed.
- */
- public void testHibernateL2CacheExample() throws Exception {
- HibernateL2CacheExample.main(EMPTY_ARGS);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java b/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java
index 4669ae4..57ff3ff 100644
--- a/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java
+++ b/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java
@@ -32,8 +32,6 @@ import org.apache.ignite.examples.DeploymentExamplesMultiNodeSelfTest;
import org.apache.ignite.examples.DeploymentExamplesSelfTest;
import org.apache.ignite.examples.EventsExamplesMultiNodeSelfTest;
import org.apache.ignite.examples.EventsExamplesSelfTest;
-import org.apache.ignite.examples.HibernateL2CacheExampleMultiNodeSelfTest;
-import org.apache.ignite.examples.HibernateL2CacheExampleSelfTest;
import org.apache.ignite.examples.IgfsExamplesSelfTest;
import org.apache.ignite.examples.LifecycleExamplesSelfTest;
import org.apache.ignite.examples.MemcacheRestExamplesMultiNodeSelfTest;
@@ -78,7 +76,6 @@ public class IgniteExamplesSelfTestSuite extends TestSuite {
suite.addTest(new TestSuite(SpringBeanExamplesSelfTest.class));
suite.addTest(new TestSuite(IgfsExamplesSelfTest.class));
suite.addTest(new TestSuite(CheckpointExamplesSelfTest.class));
- suite.addTest(new TestSuite(HibernateL2CacheExampleSelfTest.class));
suite.addTest(new TestSuite(ClusterGroupExampleSelfTest.class));
// Multi-node.
@@ -91,7 +88,6 @@ public class IgniteExamplesSelfTestSuite extends TestSuite {
suite.addTest(new TestSuite(TaskExamplesMultiNodeSelfTest.class));
suite.addTest(new TestSuite(MemcacheRestExamplesMultiNodeSelfTest.class));
suite.addTest(new TestSuite(MonteCarloExamplesMultiNodeSelfTest.class));
- suite.addTest(new TestSuite(HibernateL2CacheExampleMultiNodeSelfTest.class));
return suite;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleMultiNodeSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleMultiNodeSelfTest.java
deleted file mode 100644
index 737d498..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleMultiNodeSelfTest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.java8.examples;
-
-/**
- * Multi-node test for {@link org.apache.ignite.examples.java8.datagrid.hibernate.HibernateL2CacheExample}.
- */
-public class HibernateL2CacheExampleMultiNodeSelfTest extends HibernateL2CacheExampleSelfTest {
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- for (int i = 0; i < RMT_NODES_CNT; i++)
- startGrid("node-" + i, "examples/config/example-ignite.xml");
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleSelfTest.java
deleted file mode 100644
index 8c7a2de..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleSelfTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.java8.examples;
-
-//import org.apache.ignite.examples.java8.datagrid.hibernate.*;
-
-import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
-
-/**
- * Tests the {@link org.apache.ignite.examples.java8.datagrid.hibernate.HibernateL2CacheExample}.
- */
-public class HibernateL2CacheExampleSelfTest extends GridAbstractExamplesTest {
- /**
- * TODO: IGNITE-711 next example(s) should be implemented for java 8
- * or testing method(s) should be removed if example(s) does not applicable for java 8.
- *
- * @throws Exception If failed.
- */
-// public void testHibernateL2CacheExample() throws Exception {
-// HibernateL2CacheExample.main(EMPTY_ARGS);
-// }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 208dbbc..7b8763f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -458,7 +458,6 @@
</modules>
</profile>
-
<profile>
<id>lgpl</id>
<modules>
@@ -466,6 +465,63 @@
<module>modules/geospatial</module>
<module>modules/schedule</module>
</modules>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.apache.resources</groupId>
+ <artifactId>apache-source-release-assembly-descriptor</artifactId>
+ <version>1.0.4</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>release-lgpl</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <descriptors>
+ <descriptor>assembly/release-${ignite.edition}-lgpl.xml</descriptor>
+ </descriptors>
+ <finalName>release-package</finalName>
+ <appendAssemblyId>false</appendAssemblyId>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.7</version>
+ <inherited>false</inherited>
+ <executions>
+ <execution>
+ <id>release-postprocessing-lgpl</id>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <target>
+ <replaceregexp file="${basedir}/target/release-package/examples-lgpl/pom.xml"
+ byline="true">
+ <regexp pattern="to_be_replaced_by_ignite_version"/>
+ <substitution expression="${project.version}"/>
+ </replaceregexp>
+ </target>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
</profile>
<profile>
@@ -477,6 +533,13 @@
</profile>
<profile>
+ <id>examples-lgpl</id>
+ <modules>
+ <module>examples-lgpl</module>
+ </modules>
+ </profile>
+
+ <profile>
<id>apache-release</id>
<build>
<plugins>
[40/50] [abbrv] ignite git commit: ignite-1718: proper type name
extraction in portable context for classes that ends on '$' sign
Posted by vo...@apache.org.
ignite-1718: proper type name extraction in portable context for classes that ends on '$' sign
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e9524cea
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e9524cea
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e9524cea
Branch: refs/heads/ignite-1651
Commit: e9524cea121ce70338bb9bf1a5f622acc445d5f0
Parents: 91e31e9
Author: Andrey Gura <ag...@gridgain.com>
Authored: Thu Oct 22 11:05:02 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Thu Oct 22 11:05:02 2015 +0300
----------------------------------------------------------------------
.../ignite/internal/portable/PortableContext.java | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9524cea/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
index 1ad42ab..e9cccf0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
@@ -547,7 +547,6 @@ public class PortableContext implements Externalizable {
try {
registered = marshCtx.registerClass(typeId, cls);
-
}
catch (IgniteCheckedException e) {
throw new PortableException("Failed to register class.", e);
@@ -891,10 +890,11 @@ public class PortableContext implements Externalizable {
int idx = clsName.lastIndexOf('$');
- String typeName;
-
- if (idx >= 0) {
- typeName = clsName.substring(idx + 1);
+ if (idx == clsName.length() - 1)
+ // This is a regular (not inner) class name that ends with '$'. Common use case for Scala classes.
+ idx = -1;
+ else if (idx >= 0) {
+ String typeName = clsName.substring(idx + 1);
try {
Integer.parseInt(typeName);
@@ -1147,4 +1147,4 @@ public class PortableContext implements Externalizable {
return registered;
}
}
-}
\ No newline at end of file
+}
[16/50] [abbrv] ignite git commit: IGNITE-1555. Combine ignite-hadoop
and ignite-spark into signle assembly for downstream consumption.
Posted by vo...@apache.org.
IGNITE-1555. Combine ignite-hadoop and ignite-spark into signle assembly for downstream consumption.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c9eb539b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c9eb539b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c9eb539b
Branch: refs/heads/ignite-1651
Commit: c9eb539b565bf0a49dbe8dc936c1b2f165946805
Parents: 8217be6
Author: Konstantin Boudnik <co...@wandisco.com>
Authored: Fri Oct 9 20:54:30 2015 -0700
Committer: Konstantin Boudnik <co...@wandisco.com>
Committed: Thu Oct 15 14:01:50 2015 -0700
----------------------------------------------------------------------
DEVNOTES.txt | 3 ++-
assembly/dependencies-hadoop.xml | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c9eb539b/DEVNOTES.txt
----------------------------------------------------------------------
diff --git a/DEVNOTES.txt b/DEVNOTES.txt
index a46b73d..a6c45f0 100644
--- a/DEVNOTES.txt
+++ b/DEVNOTES.txt
@@ -23,7 +23,8 @@ mvn clean package -DskipTests -Dignite.edition=hadoop [-Dhadoop.version=X.X.X]
Use 'hadoop.version' parameter to build Ignite against a specific Hadoop version.
-Look for apache-ignite-hadoop-<version>-bin.zip in ./target/bin directory.
+Look for apache-ignite-hadoop-<version>-bin.zip in ./target/bin directory. Resulting binary
+assembly will also include integration module for Apache Spark.
NOTE: JDK version should be 1.7.0-* or >= 1.8.0-u40.
http://git-wip-us.apache.org/repos/asf/ignite/blob/c9eb539b/assembly/dependencies-hadoop.xml
----------------------------------------------------------------------
diff --git a/assembly/dependencies-hadoop.xml b/assembly/dependencies-hadoop.xml
index 0e282a4..38646ba 100644
--- a/assembly/dependencies-hadoop.xml
+++ b/assembly/dependencies-hadoop.xml
@@ -32,6 +32,7 @@
<moduleSets>
<moduleSet>
<includes>
+ <include>org.apache.ignite:ignite-spark</include>
<include>org.apache.ignite:ignite-spring</include>
<include>org.apache.ignite:ignite-log4j</include>
<include>org.apache.ignite:ignite-indexing</include>
[11/50] [abbrv] ignite git commit: IGNITE-1653
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/ClusterGroupExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/ClusterGroupExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/ClusterGroupExample.java
new file mode 100644
index 0000000..caea8a7
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/ClusterGroupExample.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples.java8.cluster;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCluster;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cluster.ClusterGroup;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.examples.ExamplesUtils;
+
+/**
+ * Demonstrates new functional APIs.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class ClusterGroupExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ * @throws IgniteException If example execution failed.
+ */
+ public static void main(String[] args) throws IgniteException {
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ if (!ExamplesUtils.checkMinTopologySize(ignite.cluster(), 2))
+ return;
+
+ System.out.println();
+ System.out.println("Compute example started.");
+
+ IgniteCluster cluster = ignite.cluster();
+
+ // Say hello to all nodes in the cluster, including local node.
+ sayHello(ignite, cluster);
+
+ // Say hello to all remote nodes.
+ sayHello(ignite, cluster.forRemotes());
+
+ // Pick random node out of remote nodes.
+ ClusterGroup randomNode = cluster.forRemotes().forRandom();
+
+ // Say hello to a random node.
+ sayHello(ignite, randomNode);
+
+ // Say hello to all nodes residing on the same host with random node.
+ sayHello(ignite, cluster.forHost(randomNode.node()));
+
+ // Say hello to all nodes that have current CPU load less than 50%.
+ sayHello(ignite, cluster.forPredicate(n -> n.metrics().getCurrentCpuLoad() < 0.5));
+ }
+ }
+
+ /**
+ * Print 'Hello' message on remote nodes.
+ *
+ * @param ignite Ignite.
+ * @param grp Cluster group.
+ * @throws IgniteException If failed.
+ */
+ private static void sayHello(Ignite ignite, final ClusterGroup grp) throws IgniteException {
+ // Print out hello message on all cluster nodes.
+ ignite.compute(grp).broadcast(
+ () -> System.out.println(">>> Hello Node: " + grp.ignite().cluster().localNode().id()));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/package-info.java
new file mode 100644
index 0000000..b96e98a
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 description. -->
+ * Cluster group example.
+ */
+package org.apache.ignite.examples.java8.cluster;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeAsyncExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeAsyncExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeAsyncExample.java
new file mode 100644
index 0000000..8d9cc64
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeAsyncExample.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.examples.java8.computegrid;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.lang.IgniteRunnable;
+
+/**
+ * Demonstrates a simple use of {@link IgniteRunnable}.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class ComputeAsyncExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ * @throws IgniteException If example execution failed.
+ */
+ public static void main(String[] args) throws IgniteException {
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ System.out.println();
+ System.out.println("Compute asynchronous example started.");
+
+ // Enable asynchronous mode.
+ IgniteCompute compute = ignite.compute().withAsync();
+
+ Collection<IgniteFuture<?>> futs = new ArrayList<>();
+
+ // Iterate through all words in the sentence and create runnable jobs.
+ for (final String word : "Print words using runnable".split(" ")) {
+ // Execute runnable on some node.
+ compute.run(() -> {
+ System.out.println();
+ System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
+ });
+
+ futs.add(compute.future());
+ }
+
+ // Wait for completion of all futures.
+ futs.forEach(IgniteFuture::get);
+
+ System.out.println();
+ System.out.println(">>> Finished printing words using runnable execution.");
+ System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeBroadcastExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeBroadcastExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeBroadcastExample.java
new file mode 100644
index 0000000..1aed33b
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeBroadcastExample.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.examples.java8.computegrid;
+
+import java.util.Collection;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.ExampleNodeStartup;
+
+/**
+ * Demonstrates broadcasting computations within cluster.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class ComputeBroadcastExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ * @throws IgniteException If example execution failed.
+ */
+ public static void main(String[] args) throws IgniteException {
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ System.out.println();
+ System.out.println(">>> Compute broadcast example started.");
+
+ // Print hello message on all nodes.
+ hello(ignite);
+
+ // Gather system info from all nodes.
+ gatherSystemInfo(ignite);
+ }
+ }
+
+ /**
+ * Print 'Hello' message on all nodes.
+ *
+ * @param ignite Ignite instance.
+ * @throws IgniteException If failed.
+ */
+ private static void hello(Ignite ignite) throws IgniteException {
+ // Print out hello message on all nodes.
+ ignite.compute().broadcast(() -> {
+ System.out.println();
+ System.out.println(">>> Hello Node! :)");
+ });
+
+ System.out.println();
+ System.out.println(">>> Check all nodes for hello message output.");
+ }
+
+ /**
+ * Gather system info from all nodes and print it out.
+ *
+ * @param ignite Ignite instance.
+ * @throws IgniteException if failed.
+ */
+ private static void gatherSystemInfo(Ignite ignite) throws IgniteException {
+ // Gather system info from all nodes.
+ Collection<String> res = ignite.compute().broadcast(() -> {
+ System.out.println();
+ System.out.println("Executing task on node: " + ignite.cluster().localNode().id());
+
+ return "Node ID: " + ignite.cluster().localNode().id() + "\n" +
+ "OS: " + System.getProperty("os.name") + " " + System.getProperty("os.version") + " " +
+ System.getProperty("os.arch") + "\n" +
+ "User: " + System.getProperty("user.name") + "\n" +
+ "JRE: " + System.getProperty("java.runtime.name") + " " +
+ System.getProperty("java.runtime.version");
+ });
+
+ // Print result.
+ System.out.println();
+ System.out.println("Nodes system information:");
+ System.out.println();
+
+ res.forEach(r -> {
+ System.out.println(r);
+ System.out.println();
+ });
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeCallableExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeCallableExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeCallableExample.java
new file mode 100644
index 0000000..cadb447
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeCallableExample.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.examples.java8.computegrid;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.lang.IgniteCallable;
+
+/**
+ * Demonstrates using of {@link IgniteCallable} job execution on the cluster.
+ * <p>
+ * This example takes a sentence composed of multiple words and counts number of non-space
+ * characters in the sentence by having each compute job count characters in each individual
+ * word.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class ComputeCallableExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ * @throws IgniteException If example execution failed.
+ */
+ public static void main(String[] args) throws IgniteException {
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ System.out.println();
+ System.out.println(">>> Compute callable example started.");
+
+ Collection<IgniteCallable<Integer>> calls = new ArrayList<>();
+
+ // Iterate through all words in the sentence and create callable jobs.
+ for (String word : "Count characters using callable".split(" ")) {
+ calls.add(() -> {
+ System.out.println();
+ System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
+
+ return word.length();
+ });
+ }
+
+ // Execute collection of callables on the ignite.
+ Collection<Integer> res = ignite.compute().call(calls);
+
+ int sum = res.stream().mapToInt(i -> i).sum();
+
+ System.out.println();
+ System.out.println(">>> Total number of characters in the phrase is '" + sum + "'.");
+ System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeClosureExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeClosureExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeClosureExample.java
new file mode 100644
index 0000000..c4d3c94
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeClosureExample.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples.java8.computegrid;
+
+import java.util.Arrays;
+import java.util.Collection;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.ExampleNodeStartup;
+
+/**
+ * Demonstrates a simple use of Ignite with reduce closure.
+ * <p>
+ * This example splits a phrase into collection of words, computes their length on different
+ * nodes and then computes total amount of non-whitespaces characters in the phrase.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class ComputeClosureExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ * @throws IgniteException If example execution failed.
+ */
+ public static void main(String[] args) throws IgniteException {
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ System.out.println();
+ System.out.println(">>> Compute closure example started.");
+
+ // Execute closure on all cluster nodes.
+ Collection<Integer> res = ignite.compute().apply(
+ (String word) -> {
+ System.out.println();
+ System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
+
+ // Return number of letters in the word.
+ return word.length();
+ },
+ // Job parameters. Ignite will create as many jobs as there are parameters.
+ Arrays.asList("Count characters using closure".split(" "))
+ );
+
+ int sum = res.stream().mapToInt(i -> i).sum();
+
+ System.out.println();
+ System.out.println(">>> Total number of characters in the phrase is '" + sum + "'.");
+ System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeRunnableExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeRunnableExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeRunnableExample.java
new file mode 100644
index 0000000..acb9893
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeRunnableExample.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.examples.java8.computegrid;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.lang.IgniteRunnable;
+
+/**
+ * Demonstrates a simple use of {@link IgniteRunnable}.
+ * <p>
+ * Remote nodes should always be 0started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class ComputeRunnableExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ * @throws IgniteException If example execution failed.
+ */
+ public static void main(String[] args) throws IgniteException {
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ System.out.println();
+ System.out.println("Compute runnable example started.");
+
+ IgniteCompute compute = ignite.compute();
+
+ // Iterate through all words in the sentence and create runnable jobs.
+ for (final String word : "Print words using runnable".split(" ")) {
+ // Execute runnable on some node.
+ compute.run(() -> {
+ System.out.println();
+ System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
+ });
+ }
+
+ System.out.println();
+ System.out.println(">>> Finished printing words using runnable execution.");
+ System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/package-info.java
new file mode 100644
index 0000000..cda49ef
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 description. -->
+ * Basic examples for computational ignite functionality.
+ */
+package org.apache.ignite.examples.java8.computegrid;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java
new file mode 100644
index 0000000..f4a3b03
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java
@@ -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.
+ */
+
+package org.apache.ignite.examples.java8.datagrid;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCluster;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.lang.IgniteRunnable;
+
+/**
+ * This example demonstrates the simplest code that populates the distributed cache
+ * and co-locates simple closure execution with each key. The goal of this particular
+ * example is to provide the simplest code example of this logic.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
+ * start node with {@code examples/config/example-ignite.xml} configuration.
+ */
+public final class CacheAffinityExample {
+ /** Cache name. */
+ private static final String CACHE_NAME = CacheAffinityExample.class.getSimpleName();
+
+ /** Number of keys. */
+ private static final int KEY_CNT = 20;
+
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ * @throws IgniteException If example execution failed.
+ */
+ public static void main(String[] args) throws IgniteException {
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ System.out.println();
+ System.out.println(">>> Cache affinity example started.");
+
+ CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
+
+ cfg.setCacheMode(CacheMode.PARTITIONED);
+ cfg.setName(CACHE_NAME);
+
+ try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg)) {
+ for (int i = 0; i < KEY_CNT; i++)
+ cache.put(i, Integer.toString(i));
+
+ // Co-locates jobs with data using IgniteCompute.affinityRun(...) method.
+ visitUsingAffinityRun();
+
+ // Co-locates jobs with data using IgniteCluster.mapKeysToNodes(...) method.
+ visitUsingMapKeysToNodes();
+ }
+ }
+ }
+
+ /**
+ * Collocates jobs with keys they need to work on using
+ * {@link IgniteCompute#affinityRun(String, Object, IgniteRunnable)} method.
+ */
+ private static void visitUsingAffinityRun() {
+ Ignite ignite = Ignition.ignite();
+
+ final IgniteCache<Integer, String> cache = ignite.cache(CACHE_NAME);
+
+ for (int i = 0; i < KEY_CNT; i++) {
+ int key = i;
+
+ // This runnable will execute on the remote node where
+ // data with the given key is located. Since it will be co-located
+ // we can use local 'peek' operation safely.
+ ignite.compute().affinityRun(CACHE_NAME, key,
+ () -> System.out.println("Co-located using affinityRun [key= " + key + ", value=" + cache.localPeek(key) + ']'));
+ }
+ }
+
+ /**
+ * Collocates jobs with keys they need to work on using {@link IgniteCluster#mapKeysToNodes(String, Collection)}
+ * method. The difference from {@code affinityRun(...)} method is that here we process multiple keys
+ * in a single job.
+ */
+ private static void visitUsingMapKeysToNodes() {
+ final Ignite ignite = Ignition.ignite();
+
+ Collection<Integer> keys = new ArrayList<>(KEY_CNT);
+
+ for (int i = 0; i < KEY_CNT; i++)
+ keys.add(i);
+
+ // Map all keys to nodes.
+ Map<ClusterNode, Collection<Integer>> mappings = ignite.cluster().mapKeysToNodes(CACHE_NAME, keys);
+
+ for (Map.Entry<ClusterNode, Collection<Integer>> mapping : mappings.entrySet()) {
+ ClusterNode node = mapping.getKey();
+
+ final Collection<Integer> mappedKeys = mapping.getValue();
+
+ if (node != null) {
+ // Bring computations to the nodes where the data resides (i.e. collocation).
+ ignite.compute(ignite.cluster().forNode(node)).run(() -> {
+ IgniteCache<Integer, String> cache = ignite.cache(CACHE_NAME);
+
+ // Peek is a local memory lookup, however, value should never be 'null'
+ // as we are co-located with node that has a given key.
+ for (Integer key : mappedKeys)
+ System.out.println("Co-located using mapKeysToNodes [key= " + key +
+ ", value=" + cache.localPeek(key) + ']');
+ });
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheApiExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheApiExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheApiExample.java
new file mode 100644
index 0000000..1891a35
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheApiExample.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples.java8.datagrid;
+
+import java.util.concurrent.ConcurrentMap;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.examples.ExampleNodeStartup;
+
+/**
+ * This example demonstrates some of the cache rich API capabilities.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
+ * start node with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class CacheApiExample {
+ /** Cache name. */
+ private static final String CACHE_NAME = CacheApiExample.class.getSimpleName();
+
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ * @throws IgniteException If example execution failed.
+ */
+ public static void main(String[] args) throws IgniteException {
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ System.out.println();
+ System.out.println(">>> Cache API example started.");
+
+ CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
+
+ cfg.setCacheMode(CacheMode.PARTITIONED);
+ cfg.setName(CACHE_NAME);
+
+ try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg)) {
+ // Demonstrate atomic map operations.
+ atomicMapOperations(cache);
+ }
+ }
+ }
+
+ /**
+ * Demonstrates cache operations similar to {@link ConcurrentMap} API. Note that
+ * cache API is a lot richer than the JDK {@link ConcurrentMap}.
+ *
+ * @throws IgniteException If failed.
+ */
+ private static void atomicMapOperations(final IgniteCache<Integer, String> cache) throws IgniteException {
+ System.out.println();
+ System.out.println(">>> Cache atomic map operation examples.");
+
+ // Put and return previous value.
+ String v = cache.getAndPut(1, "1");
+ assert v == null;
+
+ // Put and do not return previous value (all methods ending with 'x' return boolean).
+ // Performs better when previous value is not needed.
+ cache.put(2, "2");
+
+ // Put-if-absent.
+ boolean b1 = cache.putIfAbsent(4, "4");
+ boolean b2 = cache.putIfAbsent(4, "44");
+ assert b1 && !b2;
+
+ // Invoke - assign new value based on previous value.
+ cache.put(6, "6");
+
+ cache.invoke(6, (entry, args) -> {
+ String val = entry.getValue();
+
+ entry.setValue(val + "6"); // Set new value based on previous value.
+
+ return null;
+ });
+
+ // Replace.
+ cache.put(7, "7");
+ b1 = cache.replace(7, "7", "77");
+ b2 = cache.replace(7, "7", "777");
+ assert b1 & !b2;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAsyncApiExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAsyncApiExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAsyncApiExample.java
new file mode 100644
index 0000000..b457b27
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAsyncApiExample.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.examples.java8.datagrid;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.lang.IgniteFuture;
+
+/**
+ * This example demonstrates some of the cache rich API capabilities.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
+ * start node with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class CacheAsyncApiExample {
+ /** Cache name. */
+ private static final String CACHE_NAME = CacheAsyncApiExample.class.getSimpleName();
+
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ * @throws IgniteException If example execution failed.
+ */
+ public static void main(String[] args) throws IgniteException {
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ System.out.println();
+ System.out.println(">>> Cache asynchronous API example started.");
+
+ CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
+
+ cfg.setCacheMode(CacheMode.PARTITIONED);
+ cfg.setName(CACHE_NAME);
+
+ try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg)) {
+ // Enable asynchronous mode.
+ IgniteCache<Integer, String> asyncCache = cache.withAsync();
+
+ Collection<IgniteFuture<?>> futs = new ArrayList<>();
+
+ // Execute several puts asynchronously.
+ for (int i = 0; i < 10; i++) {
+ asyncCache.put(i, String.valueOf(i));
+
+ futs.add(asyncCache.future());
+ }
+
+ // Wait for completion of all futures.
+ futs.forEach(IgniteFuture::get);
+
+ // Execute get operation asynchronously.
+ asyncCache.get(1);
+
+ // Asynchronously wait for result.
+ asyncCache.<String>future().listen(fut ->
+ System.out.println("Get operation completed [value=" + fut.get() + ']'));
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/package-info.java
new file mode 100644
index 0000000..0bd86a0
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 description. -->
+ * Demonstrates data ignite cache usage.
+ */
+package org.apache.ignite.examples.java8.datagrid;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/IgniteExecutorServiceExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/IgniteExecutorServiceExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/IgniteExecutorServiceExample.java
new file mode 100644
index 0000000..0155144
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/IgniteExecutorServiceExample.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples.java8.datastructures;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.lang.IgniteRunnable;
+
+/**
+ * Simple example to demonstrate usage of distributed executor service provided by Ignite.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.
+ */
+public final class IgniteExecutorServiceExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ * @throws Exception If example execution failed.
+ */
+ @SuppressWarnings({"TooBroadScope"})
+ public static void main(String[] args) throws Exception {
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ System.out.println();
+ System.out.println(">>> Compute executor service example started.");
+
+ // Get ignite-enabled executor service.
+ ExecutorService exec = ignite.executorService();
+
+ // Iterate through all words in the sentence and create callable jobs.
+ for (final String word : "Print words using runnable".split(" ")) {
+ // Execute runnable on some node.
+ exec.submit((IgniteRunnable)() -> {
+ System.out.println();
+ System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
+ });
+ }
+
+ exec.shutdown();
+
+ // Wait for all jobs to complete (0 means no limit).
+ exec.awaitTermination(0, TimeUnit.MILLISECONDS);
+
+ System.out.println();
+ System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/package-info.java
new file mode 100644
index 0000000..86f3423
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 description. -->
+ * Demonstrates using of blocking and non-blocking queues and atomic data structures.
+ */
+package org.apache.ignite.examples.java8.datastructures;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/EventsExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/EventsExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/EventsExample.java
new file mode 100644
index 0000000..df2d52b
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/EventsExample.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples.java8.events;
+
+import java.util.UUID;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.compute.ComputeTaskSession;
+import org.apache.ignite.events.TaskEvent;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.resources.TaskSessionResource;
+
+import static org.apache.ignite.events.EventType.EVTS_TASK_EXECUTION;
+
+/**
+ * Demonstrates event consume API that allows to register event listeners on remote nodes.
+ * Note that ignite events are disabled by default and must be specifically enabled,
+ * just like in {@code examples/config/example-ignite.xml} file.
+ * <p>
+ * Remote nodes should always be started with configuration: {@code 'ignite.sh examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start
+ * node with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class EventsExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ * @throws Exception If example execution failed.
+ */
+ public static void main(String[] args) throws Exception {
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ System.out.println();
+ System.out.println(">>> Events API example started.");
+
+ // Listen to events happening on local node.
+ localListen();
+
+ // Listen to events happening on all cluster nodes.
+ remoteListen();
+
+ // Wait for a while while callback is notified about remaining puts.
+ Thread.sleep(1000);
+ }
+ }
+
+ /**
+ * Listen to events that happen only on local node.
+ *
+ * @throws IgniteException If failed.
+ */
+ private static void localListen() throws IgniteException {
+ System.out.println();
+ System.out.println(">>> Local event listener example.");
+
+ Ignite ignite = Ignition.ignite();
+
+ IgnitePredicate<TaskEvent> lsnr = evt -> {
+ System.out.println("Received task event [evt=" + evt.name() + ", taskName=" + evt.taskName() + ']');
+
+ return true; // Return true to continue listening.
+ };
+
+ // Register event listener for all local task execution events.
+ ignite.events().localListen(lsnr, EVTS_TASK_EXECUTION);
+
+ // Generate task events.
+ ignite.compute().withName("example-event-task").run(() -> System.out.println("Executing sample job."));
+
+ // Unsubscribe local task event listener.
+ ignite.events().stopLocalListen(lsnr);
+ }
+
+ /**
+ * Listen to events coming from all cluster nodes.
+ *
+ * @throws IgniteException If failed.
+ */
+ private static void remoteListen() throws IgniteException {
+ System.out.println();
+ System.out.println(">>> Remote event listener example.");
+
+ // This optional local callback is called for each event notification
+ // that passed remote predicate listener.
+ IgniteBiPredicate<UUID, TaskEvent> locLsnr = (nodeId, evt) -> {
+ // Remote filter only accepts tasks whose name being with "good-task" prefix.
+ assert evt.taskName().startsWith("good-task");
+
+ System.out.println("Received task event [evt=" + evt.name() + ", taskName=" + evt.taskName());
+
+ return true; // Return true to continue listening.
+ };
+
+ // Remote filter which only accepts tasks whose name begins with "good-task" prefix.
+ IgnitePredicate<TaskEvent> rmtLsnr = evt -> evt.taskName().startsWith("good-task");
+
+ Ignite ignite = Ignition.ignite();
+
+ // Register event listeners on all nodes to listen for task events.
+ ignite.events().remoteListen(locLsnr, rmtLsnr, EVTS_TASK_EXECUTION);
+
+ // Generate task events.
+ for (int i = 0; i < 10; i++) {
+ ignite.compute().withName(i < 5 ? "good-task-" + i : "bad-task-" + i).run(new IgniteRunnable() {
+ // Auto-inject task session.
+ @TaskSessionResource
+ private ComputeTaskSession ses;
+
+ @Override public void run() {
+ System.out.println("Executing sample job for task: " + ses.getTaskName());
+ }
+ });
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/package-info.java
new file mode 100644
index 0000000..b402e78
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 description. -->
+ * Demonstrates events management API.
+ */
+package org.apache.ignite.examples.java8.events;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
new file mode 100644
index 0000000..8b88708
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.examples.java8.messaging;
+
+import java.util.concurrent.CountDownLatch;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteMessaging;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cluster.ClusterGroup;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.examples.ExamplesUtils;
+
+/**
+ * Example that demonstrates how to exchange messages between nodes. Use such
+ * functionality for cases when you need to communicate to other nodes outside
+ * of ignite task.
+ * <p>
+ * To run this example you must have at least one remote node started.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.
+ */
+public final class MessagingExample {
+ /** Number of messages. */
+ private static final int MESSAGES_NUM = 10;
+
+ /** Message topics. */
+ private enum TOPIC { ORDERED, UNORDERED }
+
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ * @throws IgniteException If example execution failed.
+ */
+ public static void main(String[] args) throws Exception {
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ if (!ExamplesUtils.checkMinTopologySize(ignite.cluster(), 2)) {
+ System.out.println();
+ System.out.println(">>> Please start at least 2 cluster nodes to run example.");
+ System.out.println();
+
+ return;
+ }
+
+ System.out.println();
+ System.out.println(">>> Messaging example started.");
+
+ // Group for remote nodes.
+ ClusterGroup rmtGrp = ignite.cluster().forRemotes();
+
+ // Listen for messages from remote nodes to make sure that they received all the messages.
+ int msgCnt = rmtGrp.nodes().size() * MESSAGES_NUM;
+
+ CountDownLatch orderedLatch = new CountDownLatch(msgCnt);
+ CountDownLatch unorderedLatch = new CountDownLatch(msgCnt);
+
+ localListen(ignite.message(ignite.cluster().forLocal()), orderedLatch, unorderedLatch);
+
+ // Register listeners on all cluster nodes.
+ startListening(ignite, ignite.message(rmtGrp));
+
+ // Send unordered messages to all remote nodes.
+ for (int i = 0; i < MESSAGES_NUM; i++)
+ ignite.message(rmtGrp).send(TOPIC.UNORDERED, Integer.toString(i));
+
+ System.out.println(">>> Finished sending unordered messages.");
+
+ // Send ordered messages to all remote nodes.
+ for (int i = 0; i < MESSAGES_NUM; i++)
+ ignite.message(rmtGrp).sendOrdered(TOPIC.ORDERED, Integer.toString(i), 0);
+
+ System.out.println(">>> Finished sending ordered messages.");
+ System.out.println(">>> Check output on all nodes for message printouts.");
+ System.out.println(">>> Will wait for messages acknowledgements from all remote nodes.");
+
+ orderedLatch.await();
+ unorderedLatch.await();
+
+ System.out.println(">>> Messaging example finished.");
+ }
+ }
+
+ /**
+ * Start listening to messages on remote cluster nodes.
+ *
+ * @param ignite Ignite.
+ * @param imsg Ignite messaging.
+ * @throws IgniteException If failed.
+ */
+ private static void startListening(final Ignite ignite, IgniteMessaging imsg) throws IgniteException {
+ // Add ordered message listener.
+ imsg.remoteListen(TOPIC.ORDERED, (nodeId, msg) -> {
+ System.out.println("Received ordered message [msg=" + msg + ", fromNodeId=" + nodeId + ']');
+
+ try {
+ ignite.message(ignite.cluster().forNodeId(nodeId)).send(TOPIC.ORDERED, msg);
+ }
+ catch (IgniteException e) {
+ e.printStackTrace();
+ }
+
+ return true; // Return true to continue listening.
+ });
+
+ // Add unordered message listener.
+ imsg.remoteListen(TOPIC.UNORDERED, (nodeId, msg) -> {
+ System.out.println("Received unordered message [msg=" + msg + ", fromNodeId=" + nodeId + ']');
+
+ try {
+ ignite.message(ignite.cluster().forNodeId(nodeId)).send(TOPIC.UNORDERED, msg);
+ }
+ catch (IgniteException e) {
+ e.printStackTrace();
+ }
+
+ return true; // Return true to continue listening.
+ });
+ }
+
+ /**
+ * Listen for messages from remote nodes.
+ *
+ * @param imsg Ignite messaging.
+ * @param orderedLatch Latch for ordered messages acks.
+ * @param unorderedLatch Latch for unordered messages acks.
+ */
+ private static void localListen(
+ IgniteMessaging imsg,
+ final CountDownLatch orderedLatch,
+ final CountDownLatch unorderedLatch
+ ) {
+ imsg.localListen(TOPIC.ORDERED, (nodeId, msg) -> {
+ orderedLatch.countDown();
+
+ // Return true to continue listening, false to stop.
+ return orderedLatch.getCount() > 0;
+ });
+
+ imsg.localListen(TOPIC.UNORDERED, (nodeId, msg) -> {
+ unorderedLatch.countDown();
+
+ // Return true to continue listening, false to stop.
+ return unorderedLatch.getCount() > 0;
+ });
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingPingPongExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingPingPongExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingPingPongExample.java
new file mode 100644
index 0000000..b19b476
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingPingPongExample.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.examples.java8.messaging;
+
+import java.util.concurrent.CountDownLatch;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cluster.ClusterGroup;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.examples.ExamplesUtils;
+
+/**
+ * Demonstrates simple message exchange between local and remote nodes.
+ * <p>
+ * To run this example you must have at least one remote node started.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class MessagingPingPongExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ * @throws Exception If example execution failed.
+ */
+ public static void main(String[] args) throws Exception {
+ // Game is played over the default ignite.
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ if (!ExamplesUtils.checkMinTopologySize(ignite.cluster(), 2))
+ return;
+
+ System.out.println();
+ System.out.println(">>> Messaging ping-pong example started.");
+
+ // Pick random remote node as a partner.
+ ClusterGroup nodeB = ignite.cluster().forRemotes().forRandom();
+
+ // Note that both nodeA and nodeB will always point to
+ // same nodes regardless of whether they were implicitly
+ // serialized and deserialized on another node as part of
+ // anonymous closure's state during its remote execution.
+
+ // Set up remote player.
+ ignite.message(nodeB).remoteListen(null, (nodeId, rcvMsg) -> {
+ System.out.println("Received message [msg=" + rcvMsg + ", sender=" + nodeId + ']');
+
+ if ("PING".equals(rcvMsg)) {
+ ignite.message(ignite.cluster().forNodeId(nodeId)).send(null, "PONG");
+
+ return true; // Continue listening.
+ }
+
+ return false; // Unsubscribe.
+ });
+
+ int MAX_PLAYS = 10;
+
+ final CountDownLatch cnt = new CountDownLatch(MAX_PLAYS);
+
+ // Set up local player.
+ ignite.message().localListen(null, (nodeId, rcvMsg) -> {
+ System.out.println("Received message [msg=" + rcvMsg + ", sender=" + nodeId + ']');
+
+ if (cnt.getCount() == 1) {
+ ignite.message(ignite.cluster().forNodeId(nodeId)).send(null, "STOP");
+
+ cnt.countDown();
+
+ return false; // Stop listening.
+ }
+ else if ("PONG".equals(rcvMsg))
+ ignite.message(ignite.cluster().forNodeId(nodeId)).send(null, "PING");
+ else
+ throw new IgniteException("Received unexpected message: " + rcvMsg);
+
+ cnt.countDown();
+
+ return true; // Continue listening.
+ });
+
+ // Serve!
+ ignite.message(nodeB).send(null, "PING");
+
+ // Wait til the game is over.
+ try {
+ cnt.await();
+ }
+ catch (InterruptedException e) {
+ System.err.println("Hm... let us finish the game!\n" + e);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/package-info.java
new file mode 100644
index 0000000..75180cf
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 description. -->
+ * Demonstrates how to exchange messages between nodes.
+ */
+package org.apache.ignite.examples.java8.messaging;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java
new file mode 100644
index 0000000..8c85a3e
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.examples.java8.misc.schedule;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.scheduler.SchedulerFuture;
+
+/**
+ * Demonstrates a cron-based {@link Runnable} execution scheduling.
+ * Test runnable object broadcasts a phrase to all cluster nodes every minute
+ * three times with initial scheduling delay equal to five seconds.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class ComputeScheduleExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ * @throws IgniteException If example execution failed.
+ */
+ public static void main(String[] args) throws IgniteException {
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ System.out.println();
+ System.out.println("Compute schedule example started.");
+
+ // Schedule output message every minute.
+ SchedulerFuture<?> fut = ignite.scheduler().scheduleLocal(() ->
+ ignite.compute().broadcast(() -> {
+ System.out.println();
+ System.out.println("Howdy! :)");
+
+ return "Howdy! :)";
+ }),
+ "{5, 3} * * * * *" // Cron expression.
+ );
+
+ while (!fut.isDone())
+ System.out.println(">>> Invocation result: " + fut.get());
+
+ System.out.println();
+ System.out.println(">>> Schedule future is done and has been unscheduled.");
+ System.out.println(">>> Check all nodes for hello message output.");
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java
new file mode 100644
index 0000000..42132f1
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 description. -->
+ * Demonstrates usage of cron-based scheduler.
+ */
+package org.apache.ignite.examples.java8.misc.schedule;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/package-info.java
new file mode 100644
index 0000000..66847dc
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 description. -->
+ * Basic examples for ignite functionality utilizing Java8 lambdas.
+ * Use "java8" examples with JDK8 in addition to the "java" examples.
+ */
+package org.apache.ignite.examples.java8;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java
new file mode 100644
index 0000000..538c4eb
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples.java8.streaming;
+
+import java.util.List;
+import java.util.Random;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.examples.ExamplesUtils;
+import org.apache.ignite.stream.StreamTransformer;
+
+/**
+ * Stream random numbers into the streaming cache.
+ * To start the example, you should:
+ * <ul>
+ * <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li>
+ * <li>Start streaming using {@link StreamTransformerExample}.</li>
+ * </ul>
+ * <p>
+ * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM.
+ */
+public class StreamTransformerExample {
+ /** Random number generator. */
+ private static final Random RAND = new Random();
+
+ /** Range within which to generate numbers. */
+ private static final int RANGE = 1000;
+
+ public static void main(String[] args) throws Exception {
+ // Mark this cluster member as client.
+ Ignition.setClientMode(true);
+
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ if (!ExamplesUtils.hasServerNodes(ignite))
+ return;
+
+ CacheConfiguration<Integer, Long> cfg = new CacheConfiguration<>("randomNumbers");
+
+ // Index key and value.
+ cfg.setIndexedTypes(Integer.class, Long.class);
+
+ // Auto-close cache at the end of the example.
+ try (IgniteCache<Integer, Long> stmCache = ignite.getOrCreateCache(cfg)) {
+ try (IgniteDataStreamer<Integer, Long> stmr = ignite.dataStreamer(stmCache.getName())) {
+ // Allow data updates.
+ stmr.allowOverwrite(true);
+
+ // Configure data transformation to count random numbers added to the stream.
+ stmr.receiver(StreamTransformer.from((e, arg) -> {
+ // Get current count.
+ Long val = e.getValue();
+
+ // Increment count by 1.
+ e.setValue(val == null ? 1L : val + 1);
+
+ return null;
+ }));
+
+ // Stream 10 million of random numbers into the streamer cache.
+ for (int i = 1; i <= 10_000_000; i++) {
+ stmr.addData(RAND.nextInt(RANGE), 1L);
+
+ if (i % 500_000 == 0)
+ System.out.println("Number of tuples streamed into Ignite: " + i);
+ }
+ }
+
+ // Query top 10 most popular numbers every.
+ SqlFieldsQuery top10Qry = new SqlFieldsQuery("select _key, _val from Long order by _val desc limit 10");
+
+ // Execute queries.
+ List<List<?>> top10 = stmCache.query(top10Qry).getAll();
+
+ System.out.println("Top 10 most popular numbers:");
+
+ // Print top 10 words.
+ ExamplesUtils.printQueryResults(top10);
+ }
+ }
+ }
+}
\ No newline at end of file
[06/50] [abbrv] ignite git commit: IGNITE-1662: Renamed
IMessageFilter to IMessageListener.
Posted by vo...@apache.org.
IGNITE-1662: Renamed IMessageFilter to IMessageListener.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2a77dd3a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2a77dd3a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2a77dd3a
Branch: refs/heads/ignite-1651
Commit: 2a77dd3a7f01208d7172b66f6520cfc0e6615570
Parents: 81feb95
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Thu Oct 15 12:20:58 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Oct 15 12:20:58 2015 +0300
----------------------------------------------------------------------
.../Apache.Ignite.Core.Tests/EventsTest.cs | 2 +-
.../IgniteStartStopTest.cs | 4 +-
.../Apache.Ignite.Core.Tests/MessagingTest.cs | 16 +-
.../Apache.Ignite.Core.csproj | 4 +-
.../dotnet/Apache.Ignite.Core/Events/IEvents.cs | 2 +-
.../Impl/Common/DelegateTypeDescriptor.cs | 16 +-
.../Apache.Ignite.Core/Impl/Events/Events.cs | 2 +-
.../Impl/Messaging/MessageFilterHolder.cs | 177 -------------------
.../Impl/Messaging/MessageListenerHolder.cs | 177 +++++++++++++++++++
.../Impl/Messaging/Messaging.cs | 22 +--
.../Impl/Portable/PortableMarshaller.cs | 2 +-
.../Impl/Portable/PortableUtils.cs | 2 +-
.../Impl/Unmanaged/UnmanagedCallbacks.cs | 4 +-
.../Messaging/IMessageFilter.cs | 35 ----
.../Messaging/IMessageListener.cs | 38 ++++
.../Apache.Ignite.Core/Messaging/IMessaging.cs | 15 +-
.../Events/LocalListener.cs | 2 +-
.../Messaging/LocalListener.cs | 2 +-
.../Messaging/RemoteOrderedListener.cs | 2 +-
.../Messaging/RemoteUnorderedListener.cs | 2 +-
20 files changed, 266 insertions(+), 260 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a77dd3a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
index c271aa6..b325d36 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
@@ -383,7 +383,7 @@ namespace Apache.Ignite.Core.Tests
var expectedType = EventType.JobStarted;
var remoteFilter = portable
- ? (IEventFilter<IEvent>) new RemoteEventPortableFilter(expectedType)
+ ? (IEventFilter<IEvent>) new RemoteEventPortableFilter(expectedType)
: new RemoteEventFilter(expectedType);
var localListener = EventsTestHelper.GetListener();
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a77dd3a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
index bd776ce..d16063f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
@@ -384,7 +384,7 @@ namespace Apache.Ignite.Core.Tests
// to test race conditions during processor init on remote node
var listenTask = Task.Factory.StartNew(() =>
{
- var filter = new MessageFilter();
+ var filter = new MessageListener();
while (!token.IsCancellationRequested)
{
@@ -410,7 +410,7 @@ namespace Apache.Ignite.Core.Tests
/// Noop message filter.
/// </summary>
[Serializable]
- private class MessageFilter : IMessageFilter<int>
+ private class MessageListener : IMessageListener<int>
{
/** <inheritdoc /> */
public bool Invoke(Guid nodeId, int message)
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a77dd3a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MessagingTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MessagingTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MessagingTest.cs
index 95e48d3..55f2e6c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MessagingTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MessagingTest.cs
@@ -155,7 +155,7 @@ namespace Apache.Ignite.Core.Tests
{
var grid3GotMessage = false;
- var grid3Listener = new MessageFilter<string>((id, x) =>
+ var grid3Listener = new MessageListener<string>((id, x) =>
{
grid3GotMessage = true;
return true;
@@ -199,7 +199,7 @@ namespace Apache.Ignite.Core.Tests
var sharedReceived = 0;
- var sharedListener = new MessageFilter<string>((id, x) =>
+ var sharedListener = new MessageListener<string>((id, x) =>
{
Interlocked.Increment(ref sharedReceived);
Thread.MemoryBarrier();
@@ -220,7 +220,7 @@ namespace Apache.Ignite.Core.Tests
var localReceived = 0;
var stopLocal = 0;
- var localListener = new MessageFilter<string>((id, x) =>
+ var localListener = new MessageListener<string>((id, x) =>
{
Interlocked.Increment(ref localReceived);
Thread.MemoryBarrier();
@@ -569,9 +569,9 @@ namespace Apache.Ignite.Core.Tests
/// Gets the message listener.
/// </summary>
/// <returns>New instance of message listener.</returns>
- public static IMessageFilter<string> GetListener()
+ public static IMessageListener<string> GetListener()
{
- return new MessageFilter<string>(Listen);
+ return new MessageListener<string>(Listen);
}
/// <summary>
@@ -616,7 +616,7 @@ namespace Apache.Ignite.Core.Tests
/// Test message filter.
/// </summary>
[Serializable]
- public class MessageFilter<T> : IMessageFilter<T>
+ public class MessageListener<T> : IMessageListener<T>
{
/** */
private readonly Func<Guid, T, bool> _invoke;
@@ -628,10 +628,10 @@ namespace Apache.Ignite.Core.Tests
#pragma warning restore 649
/// <summary>
- /// Initializes a new instance of the <see cref="MessageFilter{T}"/> class.
+ /// Initializes a new instance of the <see cref="MessageListener{T}"/> class.
/// </summary>
/// <param name="invoke">The invoke delegate.</param>
- public MessageFilter(Func<Guid, T, bool> invoke)
+ public MessageListener(Func<Guid, T, bool> invoke)
{
_invoke = invoke;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a77dd3a/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 848ce49..a10a0a5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -238,7 +238,7 @@
<Compile Include="Impl\Memory\PlatformPooledMemory.cs" />
<Compile Include="Impl\Memory\PlatformRawMemory.cs" />
<Compile Include="Impl\Memory\PlatformUnpooledMemory.cs" />
- <Compile Include="Impl\Messaging\MessageFilterHolder.cs" />
+ <Compile Include="Impl\Messaging\MessageListenerHolder.cs" />
<Compile Include="Impl\Messaging\Messaging.cs" />
<Compile Include="Impl\Messaging\MessagingAsync.cs" />
<Compile Include="Impl\NativeMethods.cs" />
@@ -307,7 +307,7 @@
<Compile Include="Impl\Unmanaged\UnmanagedUtils.cs" />
<Compile Include="Lifecycle\ILifecycleBean.cs" />
<Compile Include="Lifecycle\LifecycleEventType.cs" />
- <Compile Include="Messaging\IMessageFilter.cs" />
+ <Compile Include="Messaging\IMessageListener.cs" />
<Compile Include="Messaging\IMessaging.cs" />
<Compile Include="Portable\IPortableBuilder.cs" />
<Compile Include="Portable\IPortableIdMapper.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a77dd3a/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEvents.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEvents.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEvents.cs
index be38104..b2f07d4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEvents.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEvents.cs
@@ -92,7 +92,7 @@ namespace Apache.Ignite.Core.Events
/// </returns>
[AsyncSupported]
Guid? RemoteListen<T>(int bufSize = 1, TimeSpan? interval = null, bool autoUnsubscribe = true,
- IEventFilter<T> localListener = null, IEventFilter<T> remoteFilter = null, params int[] types)
+ IEventFilter<T> localListener = null, IEventFilter<T> remoteFilter = null, params int[] types)
where T : IEvent;
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a77dd3a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
index 8b97884..0f2b3c1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
@@ -58,7 +58,7 @@ namespace Apache.Ignite.Core.Impl.Common
_cacheEntryProcessor;
/** */
- private readonly Func<object, Guid, object, bool> _messageFilter;
+ private readonly Func<object, Guid, object, bool> _messageLsnr;
/** */
private readonly Func<object, object> _computeJobExecute;
@@ -136,13 +136,13 @@ namespace Apache.Ignite.Core.Impl.Common
}
/// <summary>
- /// Gets the <see cref="IMessageFilter{T}" /> invocator.
+ /// Gets the <see cref="IMessageListener{T}" /> invocator.
/// </summary>
/// <param name="type">Type.</param>
/// <returns>Precompiled invocator delegate.</returns>
- public static Func<object, Guid, object, bool> GetMessageFilter(Type type)
+ public static Func<object, Guid, object, bool> GetMessageListener(Type type)
{
- return Get(type)._messageFilter;
+ return Get(type)._messageLsnr;
}
/// <summary>
@@ -286,18 +286,18 @@ namespace Apache.Ignite.Core.Impl.Common
_streamTransformerCtor = DelegateConverter.CompileCtor<Func<object, object>>(transformerType,
new[] {iface});
}
- else if (genericTypeDefinition == typeof (IMessageFilter<>))
+ else if (genericTypeDefinition == typeof (IMessageListener<>))
{
- ThrowIfMultipleInterfaces(_messageFilter, type, typeof(IMessageFilter<>));
+ ThrowIfMultipleInterfaces(_messageLsnr, type, typeof(IMessageListener<>));
var arg = iface.GetGenericArguments()[0];
- _messageFilter = DelegateConverter.CompileFunc<Func<object, Guid, object, bool>>(iface,
+ _messageLsnr = DelegateConverter.CompileFunc<Func<object, Guid, object, bool>>(iface,
new[] { typeof(Guid), arg }, new[] { false, true, false });
}
else if (genericTypeDefinition == typeof (IComputeJob<>))
{
- ThrowIfMultipleInterfaces(_messageFilter, type, typeof(IComputeJob<>));
+ ThrowIfMultipleInterfaces(_messageLsnr, type, typeof(IComputeJob<>));
_computeJobExecute = DelegateConverter.CompileFunc<Func<object, object>>(iface, new Type[0],
methodName: "Execute");
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a77dd3a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
index f4cc341..08936e4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
@@ -164,7 +164,7 @@ namespace Apache.Ignite.Core.Impl.Events
/** <inheritDoc /> */
public Guid? RemoteListen<T>(int bufSize = 1, TimeSpan? interval = null, bool autoUnsubscribe = true,
- IEventFilter<T> localListener = null, IEventFilter<T> remoteFilter = null, IEnumerable<int> types = null)
+ IEventFilter<T> localListener = null, IEventFilter<T> remoteFilter = null, IEnumerable<int> types = null)
where T : IEvent
{
return RemoteListen(bufSize, interval, autoUnsubscribe, localListener, remoteFilter, TypesToArray(types));
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a77dd3a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageFilterHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageFilterHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageFilterHolder.cs
deleted file mode 100644
index 8666e9b..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageFilterHolder.cs
+++ /dev/null
@@ -1,177 +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.Messaging
-{
- using System;
- using System.Diagnostics;
- using Apache.Ignite.Core.Impl.Common;
- using Apache.Ignite.Core.Impl.Handle;
- using Apache.Ignite.Core.Impl.Portable;
- using Apache.Ignite.Core.Impl.Portable.IO;
- using Apache.Ignite.Core.Impl.Resource;
- using Apache.Ignite.Core.Messaging;
- using Apache.Ignite.Core.Portable;
-
- /// <summary>
- /// Non-generic portable filter wrapper.
- /// </summary>
- internal class MessageFilterHolder : IPortableWriteAware, IHandle
- {
- /** Invoker function that takes key and value and invokes wrapped IMessageFilter */
- private readonly Func<Guid, object, bool> _invoker;
-
- /** Current Ignite instance. */
- private readonly Ignite _ignite;
-
- /** Underlying filter. */
- private readonly object _filter;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="MessageFilterHolder" /> class.
- /// </summary>
- /// <param name="grid">Grid.</param>
- /// <param name="filter">The <see cref="IMessageFilter{T}" /> to wrap.</param>
- /// <param name="invoker">The invoker func that takes key and value and invokes wrapped IMessageFilter.</param>
- private MessageFilterHolder(Ignite grid, object filter, Func<Guid, object, bool> invoker)
- {
- Debug.Assert(filter != null);
- Debug.Assert(invoker != null);
-
- _invoker = invoker;
-
- _filter = filter;
-
- // 1. Set fields.
- Debug.Assert(grid != null);
-
- _ignite = grid;
- _invoker = invoker;
-
- // 2. Perform injections.
- ResourceProcessor.Inject(filter, grid);
- }
-
- /// <summary>
- /// Invoke the filter.
- /// </summary>
- /// <param name="input">Input.</param>
- /// <returns></returns>
- public int Invoke(IPortableStream input)
- {
- var rawReader = _ignite.Marshaller.StartUnmarshal(input).GetRawReader();
-
- var nodeId = rawReader.ReadGuid();
-
- Debug.Assert(nodeId != null);
-
- return _invoker(nodeId.Value, rawReader.ReadObject<object>()) ? 1 : 0;
- }
-
- /// <summary>
- /// Wrapped <see cref="IMessageFilter{T}" />.
- /// </summary>
- public object Filter
- {
- get { return _filter; }
- }
-
- /// <summary>
- /// Destroy callback.
- /// </summary>
- public Action DestroyAction { private get; set; }
-
- /** <inheritDoc /> */
- public void Release()
- {
- if (DestroyAction != null)
- DestroyAction();
- }
-
- /** <inheritDoc /> */
- public bool Released
- {
- get { return false; } // Multiple releases are allowed.
- }
-
- /// <summary>
- /// Creates local holder instance.
- /// </summary>
- /// <param name="grid">Ignite instance.</param>
- /// <param name="filter">Filter.</param>
- /// <returns>
- /// New instance of <see cref="MessageFilterHolder" />
- /// </returns>
- public static MessageFilterHolder CreateLocal<T>(Ignite grid, IMessageFilter<T> filter)
- {
- Debug.Assert(filter != null);
-
- return new MessageFilterHolder(grid, filter, (id, msg) => filter.Invoke(id, (T)msg));
- }
-
- /// <summary>
- /// Creates remote holder instance.
- /// </summary>
- /// <param name="grid">Grid.</param>
- /// <param name="memPtr">Memory pointer.</param>
- /// <returns>Deserialized instance of <see cref="MessageFilterHolder"/></returns>
- public static MessageFilterHolder CreateRemote(Ignite grid, long memPtr)
- {
- Debug.Assert(grid != null);
-
- using (var stream = IgniteManager.Memory.Get(memPtr).GetStream())
- {
- return grid.Marshaller.Unmarshal<MessageFilterHolder>(stream);
- }
- }
-
- /// <summary>
- /// Gets the invoker func.
- /// </summary>
- private static Func<Guid, object, bool> GetInvoker(object pred)
- {
- var func = DelegateTypeDescriptor.GetMessageFilter(pred.GetType());
-
- return (id, msg) => func(pred, id, msg);
- }
-
- /** <inheritdoc /> */
- public void WritePortable(IPortableWriter writer)
- {
- var writer0 = (PortableWriterImpl)writer.GetRawWriter();
-
- writer0.WithDetach(w => PortableUtils.WritePortableOrSerializable(w, Filter));
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="MessageFilterHolder"/> class.
- /// </summary>
- /// <param name="reader">The reader.</param>
- public MessageFilterHolder(IPortableReader reader)
- {
- var reader0 = (PortableReaderImpl)reader.GetRawReader();
-
- _filter = PortableUtils.ReadPortableOrSerializable<object>(reader0);
-
- _invoker = GetInvoker(_filter);
-
- _ignite = reader0.Marshaller.Ignite;
-
- ResourceProcessor.Inject(_filter, _ignite);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a77dd3a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageListenerHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageListenerHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageListenerHolder.cs
new file mode 100644
index 0000000..412a84e
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageListenerHolder.cs
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Messaging
+{
+ using System;
+ using System.Diagnostics;
+ using Apache.Ignite.Core.Impl.Common;
+ using Apache.Ignite.Core.Impl.Handle;
+ using Apache.Ignite.Core.Impl.Portable;
+ using Apache.Ignite.Core.Impl.Portable.IO;
+ using Apache.Ignite.Core.Impl.Resource;
+ using Apache.Ignite.Core.Messaging;
+ using Apache.Ignite.Core.Portable;
+
+ /// <summary>
+ /// Non-generic portable message listener wrapper.
+ /// </summary>
+ internal class MessageListenerHolder : IPortableWriteAware, IHandle
+ {
+ /** Invoker function that takes key and value and invokes wrapped IMessageListener */
+ private readonly Func<Guid, object, bool> _invoker;
+
+ /** Current Ignite instance. */
+ private readonly Ignite _ignite;
+
+ /** Underlying filter. */
+ private readonly object _filter;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MessageListenerHolder" /> class.
+ /// </summary>
+ /// <param name="grid">Grid.</param>
+ /// <param name="filter">The <see cref="IMessageListener{T}" /> to wrap.</param>
+ /// <param name="invoker">The invoker func that takes key and value and invokes wrapped IMessageListener.</param>
+ private MessageListenerHolder(Ignite grid, object filter, Func<Guid, object, bool> invoker)
+ {
+ Debug.Assert(filter != null);
+ Debug.Assert(invoker != null);
+
+ _invoker = invoker;
+
+ _filter = filter;
+
+ // 1. Set fields.
+ Debug.Assert(grid != null);
+
+ _ignite = grid;
+ _invoker = invoker;
+
+ // 2. Perform injections.
+ ResourceProcessor.Inject(filter, grid);
+ }
+
+ /// <summary>
+ /// Invoke the filter.
+ /// </summary>
+ /// <param name="input">Input.</param>
+ /// <returns></returns>
+ public int Invoke(IPortableStream input)
+ {
+ var rawReader = _ignite.Marshaller.StartUnmarshal(input).GetRawReader();
+
+ var nodeId = rawReader.ReadGuid();
+
+ Debug.Assert(nodeId != null);
+
+ return _invoker(nodeId.Value, rawReader.ReadObject<object>()) ? 1 : 0;
+ }
+
+ /// <summary>
+ /// Wrapped <see cref="IMessageListener{T}" />.
+ /// </summary>
+ public object Filter
+ {
+ get { return _filter; }
+ }
+
+ /// <summary>
+ /// Destroy callback.
+ /// </summary>
+ public Action DestroyAction { private get; set; }
+
+ /** <inheritDoc /> */
+ public void Release()
+ {
+ if (DestroyAction != null)
+ DestroyAction();
+ }
+
+ /** <inheritDoc /> */
+ public bool Released
+ {
+ get { return false; } // Multiple releases are allowed.
+ }
+
+ /// <summary>
+ /// Creates local holder instance.
+ /// </summary>
+ /// <param name="grid">Ignite instance.</param>
+ /// <param name="listener">Filter.</param>
+ /// <returns>
+ /// New instance of <see cref="MessageListenerHolder" />
+ /// </returns>
+ public static MessageListenerHolder CreateLocal<T>(Ignite grid, IMessageListener<T> listener)
+ {
+ Debug.Assert(listener != null);
+
+ return new MessageListenerHolder(grid, listener, (id, msg) => listener.Invoke(id, (T)msg));
+ }
+
+ /// <summary>
+ /// Creates remote holder instance.
+ /// </summary>
+ /// <param name="grid">Grid.</param>
+ /// <param name="memPtr">Memory pointer.</param>
+ /// <returns>Deserialized instance of <see cref="MessageListenerHolder"/></returns>
+ public static MessageListenerHolder CreateRemote(Ignite grid, long memPtr)
+ {
+ Debug.Assert(grid != null);
+
+ using (var stream = IgniteManager.Memory.Get(memPtr).GetStream())
+ {
+ return grid.Marshaller.Unmarshal<MessageListenerHolder>(stream);
+ }
+ }
+
+ /// <summary>
+ /// Gets the invoker func.
+ /// </summary>
+ private static Func<Guid, object, bool> GetInvoker(object pred)
+ {
+ var func = DelegateTypeDescriptor.GetMessageListener(pred.GetType());
+
+ return (id, msg) => func(pred, id, msg);
+ }
+
+ /** <inheritdoc /> */
+ public void WritePortable(IPortableWriter writer)
+ {
+ var writer0 = (PortableWriterImpl)writer.GetRawWriter();
+
+ writer0.WithDetach(w => PortableUtils.WritePortableOrSerializable(w, Filter));
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MessageListenerHolder"/> class.
+ /// </summary>
+ /// <param name="reader">The reader.</param>
+ public MessageListenerHolder(IPortableReader reader)
+ {
+ var reader0 = (PortableReaderImpl)reader.GetRawReader();
+
+ _filter = PortableUtils.ReadPortableOrSerializable<object>(reader0);
+
+ _invoker = GetInvoker(_filter);
+
+ _ignite = reader0.Marshaller.Ignite;
+
+ ResourceProcessor.Inject(_filter, _ignite);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a77dd3a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
index 8170a91..4ccbc3e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
@@ -113,17 +113,17 @@ namespace Apache.Ignite.Core.Impl.Messaging
}
/** <inheritdoc /> */
- public void LocalListen<T>(IMessageFilter<T> filter, object topic = null)
+ public void LocalListen<T>(IMessageListener<T> listener, object topic = null)
{
- IgniteArgumentCheck.NotNull(filter, "filter");
+ IgniteArgumentCheck.NotNull(listener, "filter");
- ResourceProcessor.Inject(filter, _ignite);
+ ResourceProcessor.Inject(listener, _ignite);
lock (_funcMap)
{
- var key = GetKey(filter, topic);
+ var key = GetKey(listener, topic);
- MessageFilterHolder filter0 = MessageFilterHolder.CreateLocal(_ignite, filter);
+ MessageListenerHolder filter0 = MessageListenerHolder.CreateLocal(_ignite, listener);
var filterHnd = _ignite.HandleRegistry.Allocate(filter0);
@@ -155,16 +155,16 @@ namespace Apache.Ignite.Core.Impl.Messaging
}
/** <inheritdoc /> */
- public void StopLocalListen<T>(IMessageFilter<T> filter, object topic = null)
+ public void StopLocalListen<T>(IMessageListener<T> listener, object topic = null)
{
- IgniteArgumentCheck.NotNull(filter, "filter");
+ IgniteArgumentCheck.NotNull(listener, "filter");
long filterHnd;
bool removed;
lock (_funcMap)
{
- removed = _funcMap.TryRemove(GetKey(filter, topic), out filterHnd);
+ removed = _funcMap.TryRemove(GetKey(listener, topic), out filterHnd);
}
if (removed)
@@ -178,11 +178,11 @@ namespace Apache.Ignite.Core.Impl.Messaging
}
/** <inheritdoc /> */
- public Guid RemoteListen<T>(IMessageFilter<T> filter, object topic = null)
+ public Guid RemoteListen<T>(IMessageListener<T> listener, object topic = null)
{
- IgniteArgumentCheck.NotNull(filter, "filter");
+ IgniteArgumentCheck.NotNull(listener, "filter");
- var filter0 = MessageFilterHolder.CreateLocal(_ignite, filter);
+ var filter0 = MessageListenerHolder.CreateLocal(_ignite, listener);
var filterHnd = _ignite.HandleRegistry.AllocateSafe(filter0);
try
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a77dd3a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
index 67d8f2b..6499946 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
@@ -516,7 +516,7 @@ namespace Apache.Ignite.Core.Impl.Portable
AddSystemType(PortableUtils.TypeSerializableHolder, w => new SerializableObjectHolder(w));
AddSystemType(PortableUtils.TypeCacheEntryProcessorHolder, w => new CacheEntryProcessorHolder(w));
AddSystemType(PortableUtils.TypeCacheEntryPredicateHolder, w => new CacheEntryFilterHolder(w));
- AddSystemType(PortableUtils.TypeMessageFilterHolder, w => new MessageFilterHolder(w));
+ AddSystemType(PortableUtils.TypeMessageListenerHolder, w => new MessageListenerHolder(w));
AddSystemType(PortableUtils.TypePortableOrSerializableHolder, w => new PortableOrSerializableObjectHolder(w));
AddSystemType(PortableUtils.TypeStreamReceiverHolder, w => new StreamReceiverHolder(w));
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a77dd3a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
index f80a199..c7be496 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
@@ -200,7 +200,7 @@ namespace Apache.Ignite.Core.Impl.Portable
public const byte TypeProductLicense = 78;
/** Type: message filter holder. */
- public const byte TypeMessageFilterHolder = 92;
+ public const byte TypeMessageListenerHolder = 92;
/** Type: message filter holder. */
public const byte TypePortableOrSerializableHolder = 93;
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a77dd3a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
index f9949f3..3295904 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
@@ -788,7 +788,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
{
return SafeCall(() =>
{
- MessageFilterHolder holder = MessageFilterHolder.CreateRemote(_ignite, memPtr);
+ MessageListenerHolder holder = MessageListenerHolder.CreateRemote(_ignite, memPtr);
return _ignite.HandleRegistry.AllocateSafe(holder);
});
@@ -798,7 +798,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
{
return SafeCall(() =>
{
- var holder = _ignite.HandleRegistry.Get<MessageFilterHolder>(ptr, false);
+ var holder = _ignite.HandleRegistry.Get<MessageListenerHolder>(ptr, false);
if (holder == null)
return 0;
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a77dd3a/modules/platforms/dotnet/Apache.Ignite.Core/Messaging/IMessageFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Messaging/IMessageFilter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Messaging/IMessageFilter.cs
deleted file mode 100644
index 456c5e6..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Messaging/IMessageFilter.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Messaging
-{
- using System;
-
- /// <summary>
- /// Represents messaging filter predicate.
- /// </summary>
- public interface IMessageFilter<in T>
- {
- /// <summary>
- /// Returns a value indicating whether provided message and node id satisfy this predicate.
- /// </summary>
- /// <param name="nodeId">Node identifier.</param>
- /// <param name="message">Message.</param>
- /// <returns>Value indicating whether provided message and node id satisfy this predicate.</returns>
- bool Invoke(Guid nodeId, T message);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a77dd3a/modules/platforms/dotnet/Apache.Ignite.Core/Messaging/IMessageListener.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Messaging/IMessageListener.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Messaging/IMessageListener.cs
new file mode 100644
index 0000000..393a670
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Messaging/IMessageListener.cs
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Messaging
+{
+ using System;
+
+ /// <summary>
+ /// Represents messaging filter predicate.
+ /// </summary>
+ public interface IMessageListener<in T>
+ {
+ /// <summary>
+ /// Invokes the message listener when a message arrives.
+ /// </summary>
+ /// <param name="nodeId">Message source node identifier.</param>
+ /// <param name="message">Message.</param>
+ /// <returns>
+ /// Value indicating whether this instance should remain subscribed.
+ /// Returning <c>false</c> will unsubscribe this message listener from further notifications.
+ /// </returns>
+ bool Invoke(Guid nodeId, T message);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a77dd3a/modules/platforms/dotnet/Apache.Ignite.Core/Messaging/IMessaging.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Messaging/IMessaging.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Messaging/IMessaging.cs
index 96f46b9..f846745 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Messaging/IMessaging.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Messaging/IMessaging.cs
@@ -67,19 +67,19 @@ namespace Apache.Ignite.Core.Messaging
/// node within the cluster group will send a message for a given topic to this node. Local listen
/// subscription will happen regardless of whether local node belongs to this cluster group or not.
/// </summary>
- /// <param name="filter">
+ /// <param name="listener">
/// Predicate that is called on each received message. If predicate returns false,
/// then it will be unsubscribed from any further notifications.
/// </param>
/// <param name="topic">Topic to subscribe to.</param>
- void LocalListen<T>(IMessageFilter<T> filter, object topic = null);
+ void LocalListen<T>(IMessageListener<T> listener, object topic = null);
/// <summary>
/// Unregisters local listener for given topic on local node only.
/// </summary>
- /// <param name="filter">Listener predicate.</param>
+ /// <param name="listener">Listener predicate.</param>
/// <param name="topic">Topic to unsubscribe from.</param>
- void StopLocalListen<T>(IMessageFilter<T> filter, object topic = null);
+ void StopLocalListen<T>(IMessageListener<T> listener, object topic = null);
/// <summary>
/// Adds a message listener for a given topic to all nodes in the cluster group (possibly including
@@ -87,13 +87,16 @@ namespace Apache.Ignite.Core.Messaging
/// group can send a message for a given topic and all nodes within the cluster group will receive
/// listener notifications.
/// </summary>
- /// <param name="filter">Listener predicate.</param>
+ /// <param name="listener">
+ /// Predicate that is called on each received message. If predicate returns false,
+ /// then it will be unsubscribed from any further notifications.
+ /// </param>
/// <param name="topic">Topic to unsubscribe from.</param>
/// <returns>
/// Operation ID that can be passed to <see cref="StopRemoteListen"/> method to stop listening.
/// </returns>
[AsyncSupported]
- Guid RemoteListen<T>(IMessageFilter<T> filter, object topic = null);
+ Guid RemoteListen<T>(IMessageListener<T> listener, object topic = null);
/// <summary>
/// Unregisters all listeners identified with provided operation ID on all nodes in the cluster group.
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a77dd3a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
index 5cdb20c..067bd2a 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a77dd3a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs
index 7659bb4..591d426 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs
@@ -24,7 +24,7 @@ namespace Apache.Ignite.ExamplesDll.Messaging
/// <summary>
/// Local message listener which signals countdown event on each received message.
/// </summary>
- public class LocalListener : IMessageFilter<int>
+ public class LocalListener : IMessageListener<int>
{
/** Countdown event. */
private readonly CountdownEvent _countdown;
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a77dd3a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs
index 8ae5ac1..85538c2 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs
@@ -26,7 +26,7 @@ namespace Apache.Ignite.ExamplesDll.Messaging
/// Listener for Ordered topic.
/// </summary>
[Serializable]
- public class RemoteOrderedListener : IMessageFilter<int>
+ public class RemoteOrderedListener : IMessageListener<int>
{
/** Injected Ignite instance. */
[InstanceResource]
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a77dd3a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs
index 166dbd6..ab23e8b 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs
@@ -26,7 +26,7 @@ namespace Apache.Ignite.ExamplesDll.Messaging
/// Listener for Unordered topic.
/// </summary>
[Serializable]
- public class RemoteUnorderedListener : IMessageFilter<int>
+ public class RemoteUnorderedListener : IMessageListener<int>
{
/** Injected Ignite instance. */
[InstanceResource]
[27/50] [abbrv] ignite git commit: IGNITE-1740: Node id in IGFS file
lock id.
Posted by vo...@apache.org.
IGNITE-1740: Node id in IGFS file lock id.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f619e094
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f619e094
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f619e094
Branch: refs/heads/ignite-1651
Commit: f619e094356959cf749243989e3c3c17daf93d50
Parents: 75fb19d
Author: iveselovskiy <iv...@gridgain.com>
Authored: Tue Oct 20 15:49:21 2015 +0300
Committer: thatcoach <pp...@list.ru>
Committed: Tue Oct 20 15:49:21 2015 +0300
----------------------------------------------------------------------
.../ignite/internal/processors/igfs/IgfsMetaManager.java | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f619e094/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index c016e46..e75fe51 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -526,7 +526,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return New file info with lock set, or null if the info passed in is already locked.
* @throws IgniteCheckedException In case lock is already set on that file.
*/
- private static @Nullable IgfsFileInfo lockInfo(IgfsFileInfo info, boolean isDeleteLock) {
+ private @Nullable IgfsFileInfo lockInfo(IgfsFileInfo info, boolean isDeleteLock) {
assert info != null;
if (info.lockId() != null)
@@ -537,12 +537,16 @@ public class IgfsMetaManager extends IgfsManager {
/**
* Gets a new lock id.
+ * The returned Id #globalId() method will return the Id of the node which locked the file.
*
* @param isDeleteLock if this is special delete lock.
* @return The new lock id.
*/
- private static IgniteUuid composeLockId(boolean isDeleteLock) {
- return isDeleteLock ? DELETE_LOCK_ID : IgniteUuid.randomUuid();
+ private IgniteUuid composeLockId(boolean isDeleteLock) {
+ if (isDeleteLock)
+ return DELETE_LOCK_ID;
+
+ return IgniteUuid.fromUuid(locNode.id());
}
/**
[03/50] [abbrv] ignite git commit: IGNITE-1571 .Fixed
date/guid/decimal handling.
Posted by vo...@apache.org.
IGNITE-1571 .Fixed date/guid/decimal handling.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7c1ef1ae
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7c1ef1ae
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7c1ef1ae
Branch: refs/heads/ignite-1651
Commit: 7c1ef1ae6889ec093357c8426d07b1b5147b62e4
Parents: 0d7fd86
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Fri Oct 9 14:47:31 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Oct 9 14:47:31 2015 +0300
----------------------------------------------------------------------
.../Apache.Ignite.Benchmarks/Model/TestModel.cs | 6 +-
.../Portable/PortableWriteBenchmark.cs | 2 +-
.../Compute/ComputeApiTest.cs | 1 -
.../Apache.Ignite.Core.Tests/EventsTest.cs | 18 ++-
.../Portable/PortableApiSelfTest.cs | 8 +-
.../Portable/PortableSelfTest.cs | 58 +++----
.../Apache.Ignite.Core/Common/IgniteGuid.cs | 9 +-
.../Apache.Ignite.Core/Events/CacheEvent.cs | 14 +-
.../Events/CacheQueryExecutedEvent.cs | 6 +-
.../Events/CacheQueryReadEvent.cs | 6 +-
.../Apache.Ignite.Core/Events/EventBase.cs | 10 +-
.../Apache.Ignite.Core/Events/IEventFilter.cs | 2 +-
.../dotnet/Apache.Ignite.Core/Events/IEvents.cs | 4 +-
.../Apache.Ignite.Core/Events/JobEvent.cs | 14 +-
.../Apache.Ignite.Core/Events/TaskEvent.cs | 12 +-
.../Impl/Cluster/ClusterMetricsImpl.cs | 18 ++-
.../Impl/Cluster/ClusterNodeImpl.cs | 7 +-
.../Impl/Common/DelegateTypeDescriptor.cs | 8 +-
.../Impl/Compute/ComputeTaskHolder.cs | 6 +-
.../Apache.Ignite.Core/Impl/Events/Events.cs | 6 +-
.../Impl/Events/EventsAsync.cs | 2 +-
.../Impl/Events/RemoteListenEventFilter.cs | 6 +-
.../Impl/Portable/PortableBuilderImpl.cs | 2 +-
.../Impl/Portable/PortableMarshaller.cs | 2 +-
.../Impl/Portable/PortableReaderImpl.cs | 8 +-
.../Impl/Portable/PortableReflectiveRoutines.cs | 8 +-
.../Impl/Portable/PortableSystemHandlers.cs | 8 +-
.../Impl/Portable/PortableUtils.cs | 23 ++-
.../Impl/Portable/PortableWriterImpl.cs | 151 +++----------------
.../Impl/Transactions/TransactionMetricsImpl.cs | 10 +-
.../Portable/IPortableRawReader.cs | 4 +-
.../Portable/IPortableRawWriter.cs | 28 +---
.../Portable/IPortableReader.cs | 4 +-
.../Portable/IPortableWriter.cs | 32 +---
.../Events/EventsExample.cs | 5 +-
.../Events/LocalListener.cs | 2 +-
.../Events/RemoteFilter.cs | 2 +-
37 files changed, 195 insertions(+), 317 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/TestModel.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/TestModel.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/TestModel.cs
index 1c87018..2685dec 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/TestModel.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/TestModel.cs
@@ -41,8 +41,8 @@ namespace Apache.Ignite.Benchmarks.Model
public float[] FloatArray { get; set; }
public double Double { get; set; }
public double[] DoubleArray { get; set; }
- public decimal Decimal { get; set; }
- public decimal[] DecimalArray { get; set; }
+ public decimal? Decimal { get; set; }
+ public decimal?[] DecimalArray { get; set; }
public DateTime? Date { get; set; }
public DateTime?[] DateArray { get; set; }
public string String { get; set; }
@@ -104,7 +104,7 @@ namespace Apache.Ignite.Benchmarks.Model
DateArray = reader.ReadDateArray("DateArray");
String = reader.ReadString("String");
StringArray = reader.ReadStringArray("StringArray");
- Guid = reader.ReadGuid("Guid");
+ Guid = reader.ReadObject<Guid>("Guid");
GuidArray = reader.ReadGuidArray("GuidArray");
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableWriteBenchmark.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableWriteBenchmark.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableWriteBenchmark.cs
index 7ac27ea..7815106 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableWriteBenchmark.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableWriteBenchmark.cs
@@ -51,7 +51,7 @@ namespace Apache.Ignite.Benchmarks.Portable
Date = DateTime.Now,
DateArray = Enumerable.Range(1, 15).Select(x => (DateTime?) DateTime.Now.AddDays(x)).ToArray(),
Decimal = decimal.MinValue,
- DecimalArray = new[] {1.1M, decimal.MinValue, decimal.MaxValue, decimal.MinusOne, decimal.One},
+ DecimalArray = new decimal?[] {1.1M, decimal.MinValue, decimal.MaxValue, decimal.MinusOne, decimal.One},
Double = double.MaxValue/2,
DoubleArray = new[] {double.MaxValue, double.MinValue, double.Epsilon, double.NegativeInfinity},
Float = 98,
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
index ffc6e34..f7ab05b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
@@ -25,7 +25,6 @@ namespace Apache.Ignite.Core.Tests.Compute
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Compute;
- using Apache.Ignite.Core.Impl;
using Apache.Ignite.Core.Impl.Common;
using Apache.Ignite.Core.Portable;
using Apache.Ignite.Core.Resource;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
index de90cd3..2c014e2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
@@ -397,13 +397,15 @@ namespace Apache.Ignite.Core.Tests
if (async)
listenId = events.GetFuture<Guid>().Get();
+ Assert.IsNotNull(listenId);
+
CheckSend(3, typeof(JobEvent), expectedType);
_grid3.GetEvents().DisableLocal(EventType.EventsJobExecution);
CheckSend(2, typeof(JobEvent), expectedType);
- events.StopRemoteListen(listenId);
+ events.StopRemoteListen(listenId.Value);
if (async)
events.GetFuture().Get();
@@ -745,7 +747,7 @@ namespace Apache.Ignite.Core.Tests
public static readonly CountdownEvent ReceivedEvent = new CountdownEvent(0);
/** */
- public static readonly ConcurrentStack<Guid> LastNodeIds = new ConcurrentStack<Guid>();
+ public static readonly ConcurrentStack<Guid?> LastNodeIds = new ConcurrentStack<Guid?>();
/** */
public static volatile bool ListenResult = true;
@@ -813,7 +815,7 @@ namespace Apache.Ignite.Core.Tests
/// </summary>
/// <param name="id">Originating node ID.</param>
/// <param name="evt">Event.</param>
- private static bool Listen(Guid id, IEvent evt)
+ private static bool Listen(Guid? id, IEvent evt)
{
try
{
@@ -841,19 +843,19 @@ namespace Apache.Ignite.Core.Tests
public class EventFilter<T> : IEventFilter<T> where T : IEvent
{
/** */
- private readonly Func<Guid, T, bool> _invoke;
+ private readonly Func<Guid?, T, bool> _invoke;
/// <summary>
/// Initializes a new instance of the <see cref="RemoteListenEventFilter"/> class.
/// </summary>
/// <param name="invoke">The invoke delegate.</param>
- public EventFilter(Func<Guid, T, bool> invoke)
+ public EventFilter(Func<Guid?, T, bool> invoke)
{
_invoke = invoke;
}
/** <inheritdoc /> */
- bool IEventFilter<T>.Invoke(Guid nodeId, T evt)
+ bool IEventFilter<T>.Invoke(Guid? nodeId, T evt)
{
return _invoke(nodeId, evt);
}
@@ -880,7 +882,7 @@ namespace Apache.Ignite.Core.Tests
}
/** <inheritdoc /> */
- public bool Invoke(Guid nodeId, IEvent evt)
+ public bool Invoke(Guid? nodeId, IEvent evt)
{
return evt.Type == _type;
}
@@ -904,7 +906,7 @@ namespace Apache.Ignite.Core.Tests
}
/** <inheritdoc /> */
- public bool Invoke(Guid nodeId, IEvent evt)
+ public bool Invoke(Guid? nodeId, IEvent evt)
{
return evt.Type == _type;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
index 90f49a0..009a2da 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
@@ -415,7 +415,7 @@ namespace Apache.Ignite.Core.Tests.Portable
{
IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(DecimalHolder))
.SetField("val", decimal.One)
- .SetField("valArr", new[] { decimal.MinusOne })
+ .SetField("valArr", new decimal?[] { decimal.MinusOne })
.Build();
IPortableMetadata meta = portObj.GetMetadata();
@@ -428,12 +428,12 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(PortableTypeNames.TypeNameArrayDecimal, meta.GetFieldTypeName("valArr"));
Assert.AreEqual(decimal.One, portObj.GetField<decimal>("val"));
- Assert.AreEqual(new[] { decimal.MinusOne }, portObj.GetField<decimal[]>("valArr"));
+ Assert.AreEqual(new decimal?[] { decimal.MinusOne }, portObj.GetField<decimal?[]>("valArr"));
DecimalHolder obj = portObj.Deserialize<DecimalHolder>();
Assert.AreEqual(decimal.One, obj.Val);
- Assert.AreEqual(new[] { decimal.MinusOne }, obj.ValArr);
+ Assert.AreEqual(new decimal?[] { decimal.MinusOne }, obj.ValArr);
}
/// <summary>
@@ -1758,7 +1758,7 @@ namespace Apache.Ignite.Core.Tests.Portable
public decimal Val;
/** */
- public decimal[] ValArr;
+ public decimal?[] ValArr;
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
index db9a2f7..275460f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
@@ -59,7 +59,7 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(_marsh.Unmarshal<bool>(_marsh.Marshal(true)), true);
Assert.AreEqual(_marsh.Unmarshal<bool?>(_marsh.Marshal((bool?)false)), false);
- Assert.AreEqual(_marsh.Unmarshal<bool?>(_marsh.Marshal(null)), null);
+ Assert.AreEqual(_marsh.Unmarshal<bool?>(_marsh.Marshal((bool?)null)), null);
}
/**
@@ -71,6 +71,10 @@ namespace Apache.Ignite.Core.Tests.Portable
bool[] vals = { true, false };
Assert.AreEqual(_marsh.Unmarshal<bool[]>(_marsh.Marshal(vals)), vals);
+
+ bool?[] vals2 = { true, false };
+
+ Assert.AreEqual(_marsh.Unmarshal<bool?[]>(_marsh.Marshal(vals2)), vals2);
}
/**
@@ -84,7 +88,7 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(_marsh.Unmarshal<sbyte>(_marsh.Marshal(sbyte.MaxValue)), sbyte.MaxValue);
Assert.AreEqual(_marsh.Unmarshal<sbyte?>(_marsh.Marshal((sbyte?)1)), (sbyte?)1);
- Assert.AreEqual(_marsh.Unmarshal<sbyte?>(_marsh.Marshal(null)), null);
+ Assert.AreEqual(_marsh.Unmarshal<sbyte?>(_marsh.Marshal((sbyte?)null)), null);
}
/**
@@ -110,7 +114,7 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(_marsh.Unmarshal<byte>(_marsh.Marshal(byte.MaxValue)), byte.MaxValue);
Assert.AreEqual(_marsh.Unmarshal<byte?>(_marsh.Marshal((byte?)1)), (byte?)1);
- Assert.AreEqual(_marsh.Unmarshal<byte?>(_marsh.Marshal(null)), null);
+ Assert.AreEqual(_marsh.Unmarshal<byte?>(_marsh.Marshal((byte?)null)), null);
}
/**
@@ -136,7 +140,7 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(_marsh.Unmarshal<short>(_marsh.Marshal(short.MaxValue)), short.MaxValue);
Assert.AreEqual(_marsh.Unmarshal<short?>(_marsh.Marshal((short?)1)), (short?)1);
- Assert.AreEqual(_marsh.Unmarshal<short?>(_marsh.Marshal(null)), null);
+ Assert.AreEqual(_marsh.Unmarshal<short?>(_marsh.Marshal((short?)null)), null);
}
/**
@@ -162,7 +166,7 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(_marsh.Unmarshal<ushort>(_marsh.Marshal(ushort.MaxValue)), ushort.MaxValue);
Assert.AreEqual(_marsh.Unmarshal<ushort?>(_marsh.Marshal((ushort?)1)), (ushort?)1);
- Assert.AreEqual(_marsh.Unmarshal<ushort?>(_marsh.Marshal(null)), null);
+ Assert.AreEqual(_marsh.Unmarshal<ushort?>(_marsh.Marshal((ushort?)null)), null);
}
/**
@@ -188,7 +192,7 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(_marsh.Unmarshal<char>(_marsh.Marshal(char.MaxValue)), char.MaxValue);
Assert.AreEqual(_marsh.Unmarshal<char?>(_marsh.Marshal((char?)1)), (char?)1);
- Assert.AreEqual(_marsh.Unmarshal<char?>(_marsh.Marshal(null)), null);
+ Assert.AreEqual(_marsh.Unmarshal<char?>(_marsh.Marshal((char?)null)), null);
}
/**
@@ -214,7 +218,7 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(_marsh.Unmarshal<int>(_marsh.Marshal(int.MaxValue)), int.MaxValue);
Assert.AreEqual(_marsh.Unmarshal<int?>(_marsh.Marshal((int?)1)), (int?)1);
- Assert.AreEqual(_marsh.Unmarshal<int?>(_marsh.Marshal(null)), null);
+ Assert.AreEqual(_marsh.Unmarshal<int?>(_marsh.Marshal((int?)null)), null);
}
/**
@@ -240,7 +244,7 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(_marsh.Unmarshal<uint>(_marsh.Marshal(uint.MaxValue)), uint.MaxValue);
Assert.AreEqual(_marsh.Unmarshal<uint?>(_marsh.Marshal((uint?)1)), (int?)1);
- Assert.AreEqual(_marsh.Unmarshal<uint?>(_marsh.Marshal(null)), null);
+ Assert.AreEqual(_marsh.Unmarshal<uint?>(_marsh.Marshal((uint?)null)), null);
}
/**
@@ -266,7 +270,7 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(_marsh.Unmarshal<long>(_marsh.Marshal(long.MaxValue)), long.MaxValue);
Assert.AreEqual(_marsh.Unmarshal<long?>(_marsh.Marshal((long?)1)), (long?)1);
- Assert.AreEqual(_marsh.Unmarshal<long?>(_marsh.Marshal(null)), null);
+ Assert.AreEqual(_marsh.Unmarshal<long?>(_marsh.Marshal((long?)null)), null);
}
/**
@@ -292,7 +296,7 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(_marsh.Unmarshal<ulong>(_marsh.Marshal(ulong.MaxValue)), ulong.MaxValue);
Assert.AreEqual(_marsh.Unmarshal<ulong?>(_marsh.Marshal((ulong?)1)), (ulong?)1);
- Assert.AreEqual(_marsh.Unmarshal<ulong?>(_marsh.Marshal(null)), null);
+ Assert.AreEqual(_marsh.Unmarshal<ulong?>(_marsh.Marshal((ulong?)null)), null);
}
/**
@@ -318,7 +322,7 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(_marsh.Unmarshal<float>(_marsh.Marshal(float.MaxValue)), float.MaxValue);
Assert.AreEqual(_marsh.Unmarshal<float?>(_marsh.Marshal((float?)1)), (float?)1);
- Assert.AreEqual(_marsh.Unmarshal<float?>(_marsh.Marshal(null)), null);
+ Assert.AreEqual(_marsh.Unmarshal<float?>(_marsh.Marshal((float?)null)), null);
}
/**
@@ -344,7 +348,7 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(_marsh.Unmarshal<double>(_marsh.Marshal(double.MaxValue)), double.MaxValue);
Assert.AreEqual(_marsh.Unmarshal<double?>(_marsh.Marshal((double?)1)), (double?)1);
- Assert.AreEqual(_marsh.Unmarshal<double?>(_marsh.Marshal(null)), null);
+ Assert.AreEqual(_marsh.Unmarshal<double?>(_marsh.Marshal((double?)null)), null);
}
/**
@@ -404,7 +408,7 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-11,12"))), val);
// Test null.
- Assert.AreEqual(_marsh.Unmarshal<decimal?>(_marsh.Marshal(null)), null);
+ Assert.AreEqual(_marsh.Unmarshal<decimal?>(_marsh.Marshal((decimal?)null)), null);
}
/**
@@ -413,8 +417,8 @@ namespace Apache.Ignite.Core.Tests.Portable
[Test]
public void TestWritePrimitiveDecimalArray()
{
- decimal[] vals = { decimal.One, decimal.Parse("11,12") };
- decimal[] newVals = _marsh.Unmarshal<decimal[]>(_marsh.Marshal(vals));
+ decimal?[] vals = { decimal.One, decimal.Parse("11,12") };
+ var newVals = _marsh.Unmarshal<decimal?[]>(_marsh.Marshal(vals));
Assert.AreEqual(vals, newVals);
}
@@ -426,7 +430,7 @@ namespace Apache.Ignite.Core.Tests.Portable
public void TestWriteString()
{
Assert.AreEqual(_marsh.Unmarshal<string>(_marsh.Marshal("str")), "str");
- Assert.AreEqual(_marsh.Unmarshal<string>(_marsh.Marshal(null)), null);
+ Assert.AreEqual(_marsh.Unmarshal<string>(_marsh.Marshal((string) null)), null);
}
/**
@@ -706,13 +710,13 @@ namespace Apache.Ignite.Core.Tests.Portable
DecimalReflective obj1 = new DecimalReflective
{
Val = decimal.Zero,
- ValArr = new[] {decimal.One, decimal.MinusOne}
+ ValArr = new decimal?[] {decimal.One, decimal.MinusOne}
};
IPortableObject portObj = marsh.Unmarshal<IPortableObject>(marsh.Marshal(obj1), PortableMode.ForcePortable);
Assert.AreEqual(obj1.Val, portObj.GetField<decimal>("val"));
- Assert.AreEqual(obj1.ValArr, portObj.GetField<decimal[]>("valArr"));
+ Assert.AreEqual(obj1.ValArr, portObj.GetField<decimal?[]>("valArr"));
Assert.AreEqual(obj1.Val, portObj.Deserialize<DecimalReflective>().Val);
Assert.AreEqual(obj1.ValArr, portObj.Deserialize<DecimalReflective>().ValArr);
@@ -721,14 +725,14 @@ namespace Apache.Ignite.Core.Tests.Portable
DecimalMarshalAware obj2 = new DecimalMarshalAware();
obj2.Val = decimal.Zero;
- obj2.ValArr = new[] { decimal.One, decimal.MinusOne };
+ obj2.ValArr = new decimal?[] { decimal.One, decimal.MinusOne };
obj2.RawVal = decimal.MaxValue;
- obj2.RawValArr = new[] { decimal.MinusOne, decimal.One} ;
+ obj2.RawValArr = new decimal?[] { decimal.MinusOne, decimal.One} ;
portObj = marsh.Unmarshal<IPortableObject>(marsh.Marshal(obj2), PortableMode.ForcePortable);
Assert.AreEqual(obj2.Val, portObj.GetField<decimal>("val"));
- Assert.AreEqual(obj2.ValArr, portObj.GetField<decimal[]>("valArr"));
+ Assert.AreEqual(obj2.ValArr, portObj.GetField<decimal?[]>("valArr"));
Assert.AreEqual(obj2.Val, portObj.Deserialize<DecimalMarshalAware>().Val);
Assert.AreEqual(obj2.ValArr, portObj.Deserialize<DecimalMarshalAware>().ValArr);
@@ -1604,7 +1608,7 @@ namespace Apache.Ignite.Core.Tests.Portable
PUlong = *(ulong*)&uLong;
PString = reader.ReadString("string");
- PGuid = reader.ReadGuid("guid").Value;
+ PGuid = reader.ReadObject<Guid>("guid");
PnGuid = reader.ReadGuid("nguid");
}
}
@@ -1724,7 +1728,7 @@ namespace Apache.Ignite.Core.Tests.Portable
obj0.PUlong = *(ulong*)&uLong;
obj0.PString = reader.ReadString("string");
- obj0.PGuid = reader.ReadGuid("guid").Value;
+ obj0.PGuid = reader.ReadObject<Guid>("guid");
obj0.PnGuid = reader.ReadGuid("nguid");
}
}
@@ -1945,19 +1949,19 @@ namespace Apache.Ignite.Core.Tests.Portable
public class DecimalReflective
{
/** */
- public decimal Val;
+ public decimal? Val;
/** */
- public decimal[] ValArr;
+ public decimal?[] ValArr;
}
public class DecimalMarshalAware : DecimalReflective, IPortableMarshalAware
{
/** */
- public decimal RawVal;
+ public decimal? RawVal;
/** */
- public decimal[] RawValArr;
+ public decimal?[] RawValArr;
/** <inheritDoc /> */
public void WritePortable(IPortableWriter writer)
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
index 6c77531..7386a03 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
@@ -102,13 +102,14 @@ namespace Apache.Ignite.Core.Common
/// Reads this object from the given reader.
/// </summary>
/// <param name="r">Reader.</param>
- public static IgniteGuid ReadPortable(IPortableRawReader r)
+ public static IgniteGuid? ReadPortable(IPortableRawReader r)
{
var guid = r.ReadGuid();
- return guid == null
- ? new IgniteGuid(Guid.Empty, 0)
- : new IgniteGuid(guid.Value, r.ReadLong());
+ if (guid == null)
+ return null;
+
+ return new IgniteGuid(guid.Value, r.ReadLong());
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheEvent.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheEvent.cs
index bd8a41a..095a49f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheEvent.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheEvent.cs
@@ -44,7 +44,7 @@ namespace Apache.Ignite.Core.Events
private readonly object _key;
/** */
- private readonly IgniteGuid _xid;
+ private readonly IgniteGuid? _xid;
/** */
private readonly object _lockId;
@@ -62,7 +62,7 @@ namespace Apache.Ignite.Core.Events
private readonly bool _hasNewValue;
/** */
- private readonly Guid _subjectId;
+ private readonly Guid? _subjectId;
/** */
private readonly string _closureClassName;
@@ -87,7 +87,7 @@ namespace Apache.Ignite.Core.Events
_oldValue = r.ReadObject<object>();
_hasOldValue = r.ReadBoolean();
_hasNewValue = r.ReadBoolean();
- _subjectId = r.ReadGuid() ?? Guid.Empty;
+ _subjectId = r.ReadGuid();
_closureClassName = r.ReadString();
_taskName = r.ReadString();
}
@@ -120,7 +120,7 @@ namespace Apache.Ignite.Core.Events
/// <summary>
/// ID of surrounding cache cache transaction or null if there is no surrounding transaction.
/// </summary>
- public IgniteGuid Xid { get { return _xid; } }
+ public IgniteGuid? Xid { get { return _xid; } }
/// <summary>
/// ID of the lock if held or null if no lock held.
@@ -151,11 +151,11 @@ namespace Apache.Ignite.Core.Events
/// <summary>
/// Gets security subject ID initiated this cache event, if available. This property is available only for <see
- /// cref="EventType.EvtCacheObjectPut" />, <see cref="EventType.EvtCacheObjectRemoved" /> and <see
- /// cref="EventType.EvtCacheObjectRead" /> cache events. Subject ID will be set either to nodeId initiated
+ /// cref="EventType.EventCacheObjectPut" />, <see cref="EventType.EventCacheObjectRemoved" /> and <see
+ /// cref="EventType.EventCacheObjectRead" /> cache events. Subject ID will be set either to nodeId initiated
/// cache update or read or client ID initiated cache update or read.
/// </summary>
- public Guid SubjectId { get { return _subjectId; } }
+ public Guid? SubjectId { get { return _subjectId; } }
/// <summary>
/// Gets closure class name (applicable only for TRANSFORM operations).
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheQueryExecutedEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheQueryExecutedEvent.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheQueryExecutedEvent.cs
index 5107b84..fd43c5a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheQueryExecutedEvent.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheQueryExecutedEvent.cs
@@ -39,7 +39,7 @@ namespace Apache.Ignite.Core.Events
private readonly string _clause;
/** */
- private readonly Guid _subjectId;
+ private readonly Guid? _subjectId;
/** */
private readonly string _taskName;
@@ -54,7 +54,7 @@ namespace Apache.Ignite.Core.Events
_cacheName = r.ReadString();
_className = r.ReadString();
_clause = r.ReadString();
- _subjectId = r.ReadGuid() ?? Guid.Empty;
+ _subjectId = r.ReadGuid();
_taskName = r.ReadString();
}
@@ -81,7 +81,7 @@ namespace Apache.Ignite.Core.Events
/// <summary>
/// Gets security subject ID.
/// </summary>
- public Guid SubjectId { get { return _subjectId; } }
+ public Guid? SubjectId { get { return _subjectId; } }
/// <summary>
/// Gets the name of the task that executed the query (if any).
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheQueryReadEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheQueryReadEvent.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheQueryReadEvent.cs
index ea99927..5c9e632 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheQueryReadEvent.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheQueryReadEvent.cs
@@ -39,7 +39,7 @@ namespace Apache.Ignite.Core.Events
private readonly string _clause;
/** */
- private readonly Guid _subjectId;
+ private readonly Guid? _subjectId;
/** */
private readonly string _taskName;
@@ -66,7 +66,7 @@ namespace Apache.Ignite.Core.Events
_cacheName = r.ReadString();
_className = r.ReadString();
_clause = r.ReadString();
- _subjectId = r.ReadGuid() ?? Guid.Empty;
+ _subjectId = r.ReadGuid();
_taskName = r.ReadString();
_key = r.ReadObject<object>();
_value = r.ReadObject<object>();
@@ -97,7 +97,7 @@ namespace Apache.Ignite.Core.Events
/// <summary>
/// Gets security subject ID.
/// </summary>
- public Guid SubjectId { get { return _subjectId; } }
+ public Guid? SubjectId { get { return _subjectId; } }
/// <summary>
/// Gets the name of the task that executed the query (if any).
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventBase.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventBase.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventBase.cs
index a03c373..96f94ad 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventBase.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventBase.cs
@@ -18,6 +18,7 @@
namespace Apache.Ignite.Core.Events
{
using System;
+ using System.Diagnostics;
using System.Globalization;
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Common;
@@ -56,7 +57,9 @@ namespace Apache.Ignite.Core.Events
/// <param name="r">The reader to read data from.</param>
protected EventBase(IPortableRawReader r)
{
- _id = IgniteGuid.ReadPortable(r);
+ var id = IgniteGuid.ReadPortable(r);
+ Debug.Assert(id.HasValue);
+ _id = id.Value;
_localOrder = r.ReadLong();
@@ -65,7 +68,10 @@ namespace Apache.Ignite.Core.Events
_message = r.ReadString();
_type = r.ReadInt();
_name = r.ReadString();
- _timestamp = r.ReadDate() ?? DateTime.Now;
+
+ var timestamp = r.ReadDate();
+ Debug.Assert(timestamp.HasValue);
+ _timestamp = timestamp.Value;
}
/** <inheritDoc /> */
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEventFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEventFilter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEventFilter.cs
index 7523c52..83aca53 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEventFilter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEventFilter.cs
@@ -31,6 +31,6 @@ namespace Apache.Ignite.Core.Events
/// <param name="nodeId">Node identifier.</param>
/// <param name="evt">Event.</param>
/// <returns>Value indicating whether specified event passes this filtger.</returns>
- bool Invoke(Guid nodeId, T evt);
+ bool Invoke(Guid? nodeId, T evt);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEvents.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEvents.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEvents.cs
index 9676873..be38104 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEvents.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEvents.cs
@@ -91,7 +91,7 @@ namespace Apache.Ignite.Core.Events
/// Operation ID that can be passed to <see cref="StopRemoteListen"/> method to stop listening.
/// </returns>
[AsyncSupported]
- Guid RemoteListen<T>(int bufSize = 1, TimeSpan? interval = null, bool autoUnsubscribe = true,
+ Guid? RemoteListen<T>(int bufSize = 1, TimeSpan? interval = null, bool autoUnsubscribe = true,
IEventFilter<T> localListener = null, IEventFilter<T> remoteFilter = null, params int[] types)
where T : IEvent;
@@ -128,7 +128,7 @@ namespace Apache.Ignite.Core.Events
/// Operation ID that can be passed to <see cref="StopRemoteListen"/> method to stop listening.
/// </returns>
[AsyncSupported]
- Guid RemoteListen<T>(int bufSize = 1, TimeSpan? interval = null, bool autoUnsubscribe = true,
+ Guid? RemoteListen<T>(int bufSize = 1, TimeSpan? interval = null, bool autoUnsubscribe = true,
IEventFilter<T> localListener = null, IEventFilter<T> remoteFilter = null, IEnumerable<int> types = null)
where T : IEvent;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Events/JobEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/JobEvent.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/JobEvent.cs
index 87090e4..ee5bdae 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/JobEvent.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/JobEvent.cs
@@ -35,16 +35,16 @@ namespace Apache.Ignite.Core.Events
private readonly string _taskClassName;
/** */
- private readonly IgniteGuid _taskSessionId;
+ private readonly IgniteGuid? _taskSessionId;
/** */
- private readonly IgniteGuid _jobId;
+ private readonly IgniteGuid? _jobId;
/** */
private readonly IClusterNode _taskNode;
/** */
- private readonly Guid _taskSubjectId;
+ private readonly Guid? _taskSubjectId;
/// <summary>
/// Constructor.
@@ -57,7 +57,7 @@ namespace Apache.Ignite.Core.Events
_taskSessionId = IgniteGuid.ReadPortable(r);
_jobId = IgniteGuid.ReadPortable(r);
_taskNode = ReadNode(r);
- _taskSubjectId = r.ReadGuid() ?? Guid.Empty;
+ _taskSubjectId = r.ReadGuid();
}
/// <summary>
@@ -73,12 +73,12 @@ namespace Apache.Ignite.Core.Events
/// <summary>
/// Gets task session ID of the task that triggered this event.
/// </summary>
- public IgniteGuid TaskSessionId { get { return _taskSessionId; } }
+ public IgniteGuid? TaskSessionId { get { return _taskSessionId; } }
/// <summary>
/// Gets job ID.
/// </summary>
- public IgniteGuid JobId { get { return _jobId; } }
+ public IgniteGuid? JobId { get { return _jobId; } }
/// <summary>
/// Get node where parent task of the job has originated.
@@ -88,7 +88,7 @@ namespace Apache.Ignite.Core.Events
/// <summary>
/// Gets task subject ID.
/// </summary>
- public Guid TaskSubjectId { get { return _taskSubjectId; } }
+ public Guid? TaskSubjectId { get { return _taskSubjectId; } }
/** <inheritDoc /> */
public override string ToShortString()
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs
index c17e72b..8de22d2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs
@@ -34,13 +34,13 @@ namespace Apache.Ignite.Core.Events
private readonly string _taskClassName;
/** */
- private readonly IgniteGuid _taskSessionId;
+ private readonly IgniteGuid? _taskSessionId;
/** */
private readonly bool _internal;
/** */
- private readonly Guid _subjectId;
+ private readonly Guid? _subjectId;
/// <summary>
/// Constructor.
@@ -52,7 +52,7 @@ namespace Apache.Ignite.Core.Events
_taskClassName = r.ReadString();
_taskSessionId = IgniteGuid.ReadPortable(r);
_internal = r.ReadBoolean();
- _subjectId = r.ReadGuid() ?? Guid.Empty;
+ _subjectId = r.ReadGuid();
}
/// <summary>
@@ -68,7 +68,7 @@ namespace Apache.Ignite.Core.Events
/// <summary>
/// Gets session ID of the task that triggered the event.
/// </summary>
- public IgniteGuid TaskSessionId { get { return _taskSessionId; } }
+ public IgniteGuid? TaskSessionId { get { return _taskSessionId; } }
/// <summary>
/// Returns true if task is created by Ignite and is used for system needs.
@@ -77,10 +77,10 @@ namespace Apache.Ignite.Core.Events
/// <summary>
/// Gets security subject ID initiated this task event, if available. This property is not available for
- /// <see cref="EventType.EvtTaskSessionAttrSet" /> task event.
+ /// <see cref="EventType.EventTaskSessionAttrSet" /> task event.
/// Subject ID will be set either to node ID or client ID initiated task execution.
/// </summary>
- public Guid SubjectId { get { return _subjectId; } }
+ public Guid? SubjectId { get { return _subjectId; } }
/** <inheritDoc /> */
public override string ToShortString()
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs
index 52d5236..81a9a5a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs
@@ -18,6 +18,7 @@
namespace Apache.Ignite.Core.Impl.Cluster
{
using System;
+ using System.Diagnostics;
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Portable;
@@ -34,9 +35,10 @@ namespace Apache.Ignite.Core.Impl.Cluster
{
LastUpdateTimeRaw = reader.ReadLong();
- DateTime? lastUpdateTime0 = reader.ReadDate();
+ var lastUpdateTime = reader.ReadDate();
+ Debug.Assert(lastUpdateTime.HasValue);
+ LastUpdateTime = lastUpdateTime.Value;
- LastUpdateTime = lastUpdateTime0 ?? default(DateTime);
MaximumActiveJobs = reader.ReadInt();
CurrentActiveJobs = reader.ReadInt();
AverageActiveJobs = reader.ReadFloat();
@@ -84,13 +86,13 @@ namespace Apache.Ignite.Core.Impl.Cluster
NonHeapMemoryTotal = reader.ReadLong();
Uptime = reader.ReadLong();
- DateTime? startTime0 = reader.ReadDate();
+ var startTime = reader.ReadDate();
+ Debug.Assert(startTime.HasValue);
+ StartTime = startTime.Value;
- StartTime = startTime0 ?? default(DateTime);
-
- DateTime? nodeStartTime0 = reader.ReadDate();
-
- NodeStartTime = nodeStartTime0 ?? default(DateTime);
+ var nodeStartTime = reader.ReadDate();
+ Debug.Assert(nodeStartTime.HasValue);
+ NodeStartTime = nodeStartTime.Value;
CurrentThreadCount = reader.ReadInt();
MaximumThreadCount = reader.ReadInt();
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs
index da49feb..1b6358a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs
@@ -19,6 +19,7 @@ namespace Apache.Ignite.Core.Impl.Cluster
{
using System;
using System.Collections.Generic;
+ using System.Diagnostics;
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Impl.Collections;
using Apache.Ignite.Core.Impl.Common;
@@ -62,7 +63,11 @@ namespace Apache.Ignite.Core.Impl.Cluster
/// <param name="reader">The reader.</param>
public ClusterNodeImpl(IPortableRawReader reader)
{
- _id = reader.ReadGuid() ?? default(Guid);
+ var id = reader.ReadGuid();
+
+ Debug.Assert(id.HasValue);
+
+ _id = id.Value;
_attrs = reader.ReadGenericDictionary<string, object>().AsReadOnly();
_addrs = reader.ReadGenericCollection<string>().AsReadOnly();
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
index d974654..8b97884 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
@@ -48,7 +48,7 @@ namespace Apache.Ignite.Core.Impl.Common
private readonly Func<object, object, object> _computeFunc;
/** */
- private readonly Func<object, Guid, object, bool> _eventFilter;
+ private readonly Func<object, Guid?, object, bool> _eventFilter;
/** */
private readonly Func<object, object, object, bool> _cacheEntryFilter;
@@ -100,7 +100,7 @@ namespace Apache.Ignite.Core.Impl.Common
/// </summary>
/// <param name="type">Type.</param>
/// <returns>Precompiled invocator delegate.</returns>
- public static Func<object, Guid, object, bool> GetEventFilter(Type type)
+ public static Func<object, Guid?, object, bool> GetEventFilter(Type type)
{
return Get(type)._eventFilter;
}
@@ -245,8 +245,8 @@ namespace Apache.Ignite.Core.Impl.Common
var args = iface.GetGenericArguments();
- _eventFilter = DelegateConverter.CompileFunc<Func<object, Guid, object, bool>>(iface,
- new[] {typeof (Guid), args[0]}, new[] {false, true, false});
+ _eventFilter = DelegateConverter.CompileFunc<Func<object, Guid?, object, bool>>(iface,
+ new[] {typeof (Guid?), args[0]}, new[] {false, true, false});
}
else if (genericTypeDefinition == typeof (ICacheEntryFilter<,>))
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs
index dfe0d18..552e0eb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs
@@ -290,7 +290,9 @@ namespace Apache.Ignite.Core.Impl.Compute
// 1. Unmarshal result.
PortableReaderImpl reader = _compute.Marshaller.StartUnmarshal(stream);
- Guid nodeId = reader.ReadGuid().Value;
+ var nodeId = reader.ReadGuid();
+ Debug.Assert(nodeId.HasValue);
+
bool cancelled = reader.ReadBoolean();
try
@@ -300,7 +302,7 @@ namespace Apache.Ignite.Core.Impl.Compute
var data = PortableUtils.ReadWrappedInvocationResult(reader, out err);
// 2. Process the result.
- return (int) JobResult0(new ComputeJobResultImpl(data, (Exception) err, job.Job, nodeId, cancelled));
+ return (int) JobResult0(new ComputeJobResultImpl(data, (Exception) err, job.Job, nodeId.Value, cancelled));
}
catch (Exception e)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
index 726dd87..f4cc341 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
@@ -130,7 +130,7 @@ namespace Apache.Ignite.Core.Impl.Events
}
/** <inheritDoc /> */
- public virtual Guid RemoteListen<T>(int bufSize = 1, TimeSpan? interval = null, bool autoUnsubscribe = true,
+ public virtual Guid? RemoteListen<T>(int bufSize = 1, TimeSpan? interval = null, bool autoUnsubscribe = true,
IEventFilter<T> localListener = null, IEventFilter<T> remoteFilter = null, params int[] types)
where T : IEvent
{
@@ -159,11 +159,11 @@ namespace Apache.Ignite.Core.Impl.Events
WriteEventTypes(types, writer);
},
- reader => Marshaller.StartUnmarshal(reader).ReadGuid() ?? Guid.Empty);
+ reader => Marshaller.StartUnmarshal(reader).ReadGuid());
}
/** <inheritDoc /> */
- public Guid RemoteListen<T>(int bufSize = 1, TimeSpan? interval = null, bool autoUnsubscribe = true,
+ public Guid? RemoteListen<T>(int bufSize = 1, TimeSpan? interval = null, bool autoUnsubscribe = true,
IEventFilter<T> localListener = null, IEventFilter<T> remoteFilter = null, IEnumerable<int> types = null)
where T : IEvent
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/EventsAsync.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/EventsAsync.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/EventsAsync.cs
index 84bcb19..461f2ae 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/EventsAsync.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/EventsAsync.cs
@@ -69,7 +69,7 @@ namespace Apache.Ignite.Core.Impl.Events
}
/** <inheritdoc /> */
- public override Guid RemoteListen<T>(int bufSize = 1, TimeSpan? interval = null, bool autoUnsubscribe = true,
+ public override Guid? RemoteListen<T>(int bufSize = 1, TimeSpan? interval = null, bool autoUnsubscribe = true,
IEventFilter<T> localListener = null, IEventFilter<T> remoteFilter = null, params int[] types)
{
_lastAsyncOp.Value = (int) Op.RemoteListen;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
index ca6d8f6..ac50b35 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
@@ -33,14 +33,14 @@ namespace Apache.Ignite.Core.Impl.Events
private readonly Ignite _ignite;
/** */
- private readonly Func<Guid, IEvent, bool> _filter;
+ private readonly Func<Guid?, IEvent, bool> _filter;
/// <summary>
/// Initializes a new instance of the <see cref="RemoteListenEventFilter"/> class.
/// </summary>
/// <param name="ignite">The grid.</param>
/// <param name="filter">The filter.</param>
- public RemoteListenEventFilter(Ignite ignite, Func<Guid, IEvent, bool> filter)
+ public RemoteListenEventFilter(Ignite ignite, Func<Guid?, IEvent, bool> filter)
{
_ignite = ignite;
_filter = filter;
@@ -53,7 +53,7 @@ namespace Apache.Ignite.Core.Impl.Events
var evt = EventReader.Read<IEvent>(reader);
- var nodeId = reader.ReadGuid() ?? Guid.Empty;
+ var nodeId = reader.ReadGuid();
return _filter(nodeId, evt) ? 1 : 0;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
index 9723f79..c65038c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
@@ -91,7 +91,7 @@ namespace Apache.Ignite.Core.Impl.Portable
TypeIds[typeof(long[])] = PortableUtils.TypeArrayLong;
TypeIds[typeof(float[])] = PortableUtils.TypeArrayFloat;
TypeIds[typeof(double[])] = PortableUtils.TypeArrayDouble;
- TypeIds[typeof(decimal[])] = PortableUtils.TypeArrayDecimal;
+ TypeIds[typeof(decimal?[])] = PortableUtils.TypeArrayDecimal;
// 2. String.
TypeIds[typeof(string)] = PortableUtils.TypeString;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
index e1cd4c5..67d8f2b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
@@ -114,7 +114,7 @@ namespace Apache.Ignite.Core.Impl.Portable
/// </summary>
/// <param name="val">Value.</param>
/// <returns>Serialized data as byte array.</returns>
- public byte[] Marshal(object val)
+ public byte[] Marshal<T>(T val)
{
PortableHeapStream stream = new PortableHeapStream(128);
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
index cfc84fd..dfc7c74 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
@@ -300,25 +300,25 @@ namespace Apache.Ignite.Core.Impl.Portable
}
/** <inheritdoc /> */
- public decimal ReadDecimal(string fieldName)
+ public decimal? ReadDecimal(string fieldName)
{
return ReadField(fieldName, PortableUtils.ReadDecimal);
}
/** <inheritdoc /> */
- public decimal ReadDecimal()
+ public decimal? ReadDecimal()
{
return Read(PortableUtils.ReadDecimal);
}
/** <inheritdoc /> */
- public decimal[] ReadDecimalArray(string fieldName)
+ public decimal?[] ReadDecimalArray(string fieldName)
{
return ReadField(fieldName, PortableUtils.ReadDecimalArray);
}
/** <inheritdoc /> */
- public decimal[] ReadDecimalArray()
+ public decimal?[] ReadDecimalArray()
{
return Read(PortableUtils.ReadDecimalArray);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs
index d939d29..907c480 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs
@@ -255,9 +255,9 @@ namespace Apache.Ignite.Core.Impl.Portable
writeAction = GetWriter<double[]>(field, (f, w, o) => w.WriteDoubleArray(f, o));
readAction = GetReader(field, (f, r) => r.ReadDoubleArray(f));
}
- else if (elemType == typeof(decimal))
+ else if (elemType == typeof(decimal?))
{
- writeAction = GetWriter<decimal[]>(field, (f, w, o) => w.WriteDecimalArray(f, o));
+ writeAction = GetWriter<decimal?[]>(field, (f, w, o) => w.WriteDecimalArray(f, o));
readAction = GetReader(field, (f, r) => r.ReadDecimalArray(f));
}
else if (elemType == typeof(string))
@@ -317,7 +317,7 @@ namespace Apache.Ignite.Core.Impl.Portable
else if (type == typeof(Guid))
{
writeAction = GetWriter<Guid>(field, (f, w, o) => w.WriteGuid(f, o));
- readAction = GetReader(field, (f, r) => r.ReadGuid(f) ?? default(Guid));
+ readAction = GetReader(field, (f, r) => r.ReadObject<Guid>(f));
}
else if (nullable && nullableType == typeof(Guid))
{
@@ -327,7 +327,7 @@ namespace Apache.Ignite.Core.Impl.Portable
else if (type == typeof(DateTime))
{
writeAction = GetWriter<DateTime>(field, (f, w, o) => w.WriteDate(f, o));
- readAction = GetReader(field, (f, r) => r.ReadDate(f) ?? default(DateTime));
+ readAction = GetReader(field, (f, r) => r.ReadDate(f));
}
else if (nullable && nullableType == typeof(DateTime))
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
index c02c457..6b5e20d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
@@ -87,7 +87,7 @@ namespace Apache.Ignite.Core.Impl.Portable
ReadHandlers[PortableUtils.TypeLong] = new PortableSystemReader<long>(s => s.ReadLong());
ReadHandlers[PortableUtils.TypeFloat] = new PortableSystemReader<float>(s => s.ReadFloat());
ReadHandlers[PortableUtils.TypeDouble] = new PortableSystemReader<double>(s => s.ReadDouble());
- ReadHandlers[PortableUtils.TypeDecimal] = new PortableSystemReader<decimal>(PortableUtils.ReadDecimal);
+ ReadHandlers[PortableUtils.TypeDecimal] = new PortableSystemReader<decimal?>(PortableUtils.ReadDecimal);
// 2. Date.
ReadHandlers[PortableUtils.TypeDate] = new PortableSystemReader<DateTime?>(s => PortableUtils.ReadDate(s, false));
@@ -125,7 +125,7 @@ namespace Apache.Ignite.Core.Impl.Portable
new PortableSystemReader<double[]>(PortableUtils.ReadDoubleArray);
ReadHandlers[PortableUtils.TypeArrayDecimal] =
- new PortableSystemReader<decimal[]>(PortableUtils.ReadDecimalArray);
+ new PortableSystemReader<decimal?[]>(PortableUtils.ReadDecimalArray);
// 6. Date array.
ReadHandlers[PortableUtils.TypeArrayDate] =
@@ -237,7 +237,7 @@ namespace Apache.Ignite.Core.Impl.Portable
else if (elemType == typeof(ulong))
return WriteUlongArray;
// Special types.
- else if (elemType == typeof (decimal))
+ else if (elemType == typeof (decimal?))
return WriteDecimalArray;
else if (elemType == typeof(string))
return WriteStringArray;
@@ -514,7 +514,7 @@ namespace Apache.Ignite.Core.Impl.Portable
{
ctx.Stream.WriteByte(PortableUtils.TypeArrayDecimal);
- PortableUtils.WriteDecimalArray((decimal[])obj, ctx.Stream);
+ PortableUtils.WriteDecimalArray((decimal?[])obj, ctx.Stream);
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
index d02fcf1..f80a199 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
@@ -901,7 +901,7 @@ namespace Apache.Ignite.Core.Impl.Portable
* <param name="stream">Stream.</param>
* <returns>Decimal value.</returns>
*/
- public static decimal ReadDecimal(IPortableStream stream)
+ public static decimal? ReadDecimal(IPortableStream stream)
{
int scale = stream.ReadInt();
@@ -961,12 +961,21 @@ namespace Apache.Ignite.Core.Impl.Portable
* <param name="vals">Decimal array.</param>
* <param name="stream">Stream.</param>
*/
- public static void WriteDecimalArray(decimal[] vals, IPortableStream stream)
+ public static void WriteDecimalArray(decimal?[] vals, IPortableStream stream)
{
stream.WriteInt(vals.Length);
- foreach (decimal val in vals)
- WriteDecimal(val, stream);
+ foreach (var val in vals)
+ {
+ if (val.HasValue)
+ {
+ stream.WriteByte(TypeDecimal);
+
+ WriteDecimal(val.Value, stream);
+ }
+ else
+ stream.WriteByte(HdrNull);
+ }
}
/**
@@ -974,14 +983,14 @@ namespace Apache.Ignite.Core.Impl.Portable
* <param name="stream">Stream.</param>
* <returns>Decimal array.</returns>
*/
- public static decimal[] ReadDecimalArray(IPortableStream stream)
+ public static decimal?[] ReadDecimalArray(IPortableStream stream)
{
int len = stream.ReadInt();
- decimal[] vals = new decimal[len];
+ var vals = new decimal?[len];
for (int i = 0; i < len; i++)
- vals[i] = ReadDecimal(stream);
+ vals[i] = stream.ReadByte() == HdrNull ? (decimal?) null : ReadDecimal(stream);
return vals;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
index 0ff4c64..b490460 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
@@ -545,26 +545,36 @@ namespace Apache.Ignite.Core.Impl.Portable
/// </summary>
/// <param name="fieldName">Field name.</param>
/// <param name="val">Decimal value.</param>
- public void WriteDecimal(string fieldName, decimal val)
+ public void WriteDecimal(string fieldName, decimal? val)
{
WriteFieldId(fieldName, PU.TypeDecimal);
- int pos = SkipFieldLength();
+ if (val == null)
+ WriteNullField();
+ else
+ {
+ int pos = SkipFieldLength();
- _stream.WriteByte(PU.TypeDecimal);
- PortableUtils.WriteDecimal(val, _stream);
+ _stream.WriteByte(PU.TypeDecimal);
+ PortableUtils.WriteDecimal(val.Value, _stream);
- WriteFieldLength(_stream, pos);
+ WriteFieldLength(_stream, pos);
+ }
}
/// <summary>
/// Write decimal value.
/// </summary>
/// <param name="val">Decimal value.</param>
- public void WriteDecimal(decimal val)
+ public void WriteDecimal(decimal? val)
{
- _stream.WriteByte(PU.TypeDecimal);
- PortableUtils.WriteDecimal(val, _stream);
+ if (val == null)
+ WriteNullRawField();
+ else
+ {
+ _stream.WriteByte(PU.TypeDecimal);
+ PortableUtils.WriteDecimal(val.Value, _stream);
+ }
}
/// <summary>
@@ -572,7 +582,7 @@ namespace Apache.Ignite.Core.Impl.Portable
/// </summary>
/// <param name="fieldName">Field name.</param>
/// <param name="val">Decimal array.</param>
- public void WriteDecimalArray(string fieldName, decimal[] val)
+ public void WriteDecimalArray(string fieldName, decimal?[] val)
{
WriteFieldId(fieldName, PU.TypeArrayDecimal);
@@ -593,7 +603,7 @@ namespace Apache.Ignite.Core.Impl.Portable
/// Write decimal array.
/// </summary>
/// <param name="val">Decimal array.</param>
- public void WriteDecimalArray(decimal[] val)
+ public void WriteDecimalArray(decimal?[] val)
{
if (val == null)
WriteNullRawField();
@@ -604,63 +614,6 @@ namespace Apache.Ignite.Core.Impl.Portable
}
}
-// /// <summary>
-// /// Write named date value.
-// /// </summary>
-// /// <param name="fieldName">Field name.</param>
-// /// <param name="val">Date value.</param>
-// public void WriteDate(string fieldName, DateTime val)
-// {
-// WriteFieldId(fieldName, PU.TypeDate);
-//
-// _stream.WriteInt(PU.LengthTypeId + 12);
-//
-// _stream.WriteByte(PortableUtils.TypeDate);
-// PortableUtils.WriteDate(val, _stream);
-// }
-//
-// /// <summary>
-// /// Write date value.
-// /// </summary>
-// /// <param name="val">Date value.</param>
-// public void WriteDate(DateTime val)
-// {
-// _stream.WriteByte(PortableUtils.TypeDate);
-// PortableUtils.WriteDate(val, _stream);
-// }
-//
-// /// <summary>
-// /// Write named date array.
-// /// </summary>
-// /// <param name="fieldName">Field name.</param>
-// /// <param name="val">Date array.</param>
-// public void WriteDateArray(string fieldName, DateTime[] val)
-// {
-// WriteFieldId(fieldName, PU.TypeDate);
-//
-// if (val == null)
-// WriteNullField();
-// else
-// {
-// int pos = SkipFieldLength();
-//
-// _stream.WriteByte(PortableUtils.TypeArrayDate);
-// PortableUtils.WriteDateArray(val, _stream);
-//
-// WriteFieldLength(_stream, pos);
-// }
-// }
-//
-// /// <summary>
-// /// Write date array.
-// /// </summary>
-// /// <param name="val">Date array.</param>
-// public void WriteDateArray(DateTime[] val)
-// {
-// _stream.WriteByte(PortableUtils.TypeArrayDate);
-// PortableUtils.WriteDateArray(val, _stream);
-// }
-
/// <summary>
/// Write named date value.
/// </summary>
@@ -807,68 +760,6 @@ namespace Apache.Ignite.Core.Impl.Portable
}
}
-// /// <summary>
-// /// Write named GUID value.
-// /// </summary>
-// /// <param name="fieldName">Field name.</param>
-// /// <param name="val">GUID value.</param>
-// public void WriteGuid(string fieldName, Guid val)
-// {
-// WriteFieldId(fieldName, PU.TypeGuid);
-//
-// _stream.WriteInt(PU.LengthTypeId + 16);
-//
-// _stream.WriteByte(PU.TypeGuid);
-// PU.WriteGuid(val, _stream);
-// }
-//
-// /// <summary>
-// /// Write GUID value.
-// /// </summary>
-// /// <param name="val">GUID value.</param>
-// public void WriteGuid(Guid val)
-// {
-// _stream.WriteByte(PU.TypeGuid);
-// PU.WriteGuid(val, _stream);
-// }
-//
-// /// <summary>
-// /// Write named GUID array.
-// /// </summary>
-// /// <param name="fieldName">Field name.</param>
-// /// <param name="val">GUID array.</param>
-// public void WriteGuidArray(string fieldName, Guid[] val)
-// {
-// WriteFieldId(fieldName, PU.TypeArrayGuid);
-//
-// if (val == null)
-// WriteNullField();
-// else
-// {
-// int pos = SkipFieldLength();
-//
-// _stream.WriteByte(PU.TypeArrayGuid);
-// PU.WriteGuidArray(val, _stream);
-//
-// WriteFieldLength(_stream, pos);
-// }
-// }
-//
-// /// <summary>
-// /// Write GUID array.
-// /// </summary>
-// /// <param name="val">GUID array.</param>
-// public void WriteGuidArray(Guid[] val)
-// {
-// if (val == null)
-// WriteNullRawField();
-// else
-// {
-// _stream.WriteByte(PU.TypeArrayGuid);
-// PU.WriteGuidArray(val, _stream);
-// }
-// }
-
/// <summary>
/// Write named GUID value.
/// </summary>
@@ -1255,7 +1146,7 @@ namespace Apache.Ignite.Core.Impl.Portable
_marsh = marsh;
_stream = stream;
}
-
+
/// <summary>
/// Write object.
/// </summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionMetricsImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionMetricsImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionMetricsImpl.cs
index e2528f4..4b15150 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionMetricsImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionMetricsImpl.cs
@@ -18,6 +18,7 @@
namespace Apache.Ignite.Core.Impl.Transactions
{
using System;
+ using System.Diagnostics;
using Apache.Ignite.Core.Portable;
using Apache.Ignite.Core.Transactions;
@@ -32,8 +33,13 @@ namespace Apache.Ignite.Core.Impl.Transactions
/// <param name="reader">The reader.</param>
public TransactionMetricsImpl(IPortableRawReader reader)
{
- CommitTime = reader.ReadDate() ?? default(DateTime);
- RollbackTime = reader.ReadDate() ?? default(DateTime);
+ var commitTime = reader.ReadDate();
+ Debug.Assert(commitTime.HasValue);
+ CommitTime = commitTime.Value;
+
+ var rollbackTime = reader.ReadDate();
+ Debug.Assert(rollbackTime.HasValue);
+ RollbackTime = rollbackTime.Value;
TxCommits = reader.ReadInt();
TxRollbacks = reader.ReadInt();
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs
index ee2520d..a3e8dd5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs
@@ -126,13 +126,13 @@ namespace Apache.Ignite.Core.Portable
/// Read decimal value.
/// </summary>
/// <returns>Decimal value.</returns>
- decimal ReadDecimal();
+ decimal? ReadDecimal();
/// <summary>
/// Read decimal array.
/// </summary>
/// <returns>Decimal array.</returns>
- decimal[] ReadDecimalArray();
+ decimal?[] ReadDecimalArray();
/// <summary>
/// Read date value in UTC form. Shortcut for <c>ReadDate(false)</c>.
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs
index 42d8c66..cc14f45 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs
@@ -126,25 +126,13 @@ namespace Apache.Ignite.Core.Portable
/// Write decimal value.
/// </summary>
/// <param name="val">Decimal value.</param>
- void WriteDecimal(decimal val);
+ void WriteDecimal(decimal? val);
/// <summary>
/// Write decimal array.
/// </summary>
/// <param name="val">Decimal array.</param>
- void WriteDecimalArray(decimal[] val);
-
-// /// <summary>
-// /// Write date value.
-// /// </summary>
-// /// <param name="val">Date value.</param>
-// void WriteDate(DateTime val);
-//
-// /// <summary>
-// /// Write date array.
-// /// </summary>
-// /// <param name="val">Date array.</param>
-// void WriteDateArray(DateTime[] val);
+ void WriteDecimalArray(decimal?[] val);
/// <summary>
/// Write date value.
@@ -170,18 +158,6 @@ namespace Apache.Ignite.Core.Portable
/// <param name="val">String array.</param>
void WriteStringArray(string[] val);
-// /// <summary>
-// /// Write GUID value.
-// /// </summary>
-// /// <param name="val">GUID value.</param>
-// void WriteGuid(Guid val);
-//
-// /// <summary>
-// /// Write GUID array.
-// /// </summary>
-// /// <param name="val">GUID array.</param>
-// void WriteGuidArray(Guid[] val);
-
/// <summary>
/// Write GUID value.
/// </summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs
index 96f5757..ed86b7e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs
@@ -175,14 +175,14 @@ namespace Apache.Ignite.Core.Portable
/// </summary>
/// <param name="fieldName">Field name.</param>
/// <returns>Decimal value.</returns>
- decimal ReadDecimal(string fieldName);
+ decimal? ReadDecimal(string fieldName);
/// <summary>
/// Read named decimal array.
/// </summary>
/// <param name="fieldName">Field name.</param>
/// <returns>Decimal array.</returns>
- decimal[] ReadDecimalArray(string fieldName);
+ decimal?[] ReadDecimalArray(string fieldName);
/// <summary>
/// Read named date value in UTC form. Shortcut for <c>ReadDate(fieldName, false)</c>.
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs
index edca218..670a137 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs
@@ -143,28 +143,14 @@ namespace Apache.Ignite.Core.Portable
/// </summary>
/// <param name="fieldName">Field name.</param>
/// <param name="val">Decimal value.</param>
- void WriteDecimal(string fieldName, decimal val);
+ void WriteDecimal(string fieldName, decimal? val);
/// <summary>
/// Write named decimal array.
/// </summary>
/// <param name="fieldName">Field name.</param>
/// <param name="val">Decimal array.</param>
- void WriteDecimalArray(string fieldName, decimal[] val);
-
-// /// <summary>
-// /// Write named date value.
-// /// </summary>
-// /// <param name="fieldName">Field name.</param>
-// /// <param name="val">Date value.</param>
-// void WriteDate(string fieldName, DateTime val);
-//
-// /// <summary>
-// /// Write named date array.
-// /// </summary>
-// /// <param name="fieldName">Field name.</param>
-// /// <param name="val">Date array.</param>
-// void WriteDateArray(string fieldName, DateTime[] val);
+ void WriteDecimalArray(string fieldName, decimal?[] val);
/// <summary>
/// Write named date value.
@@ -194,20 +180,6 @@ namespace Apache.Ignite.Core.Portable
/// <param name="val">String array.</param>
void WriteStringArray(string fieldName, string[] val);
-// /// <summary>
-// /// Write named GUID value.
-// /// </summary>
-// /// <param name="fieldName">Field name.</param>
-// /// <param name="val">GUID value.</param>
-// void WriteGuid(string fieldName, Guid val);
-//
-// /// <summary>
-// /// Write named GUID array.
-// /// </summary>
-// /// <param name="fieldName">Field name.</param>
-// /// <param name="val">GUID array.</param>
-// void WriteGuidArray(string fieldName, Guid[] val);
-
/// <summary>
/// Write named GUID value.
/// </summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
index 16074a0..ed87309 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
@@ -81,9 +81,12 @@ namespace Apache.Ignite.Examples.Events
var listenId = ignite.GetEvents().RemoteListen(localListener: localListener,
remoteFilter: remoteFilter, types: EventType.EventsJobExecution);
+ if (listenId == null)
+ throw new InvalidOperationException("Subscription failed.");
+
ExecuteTask(ignite);
- ignite.GetEvents().StopRemoteListen(listenId);
+ ignite.GetEvents().StopRemoteListen(listenId.Value);
Console.WriteLine(">>> Received events count: " + localListener.EventsReceived);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
index 8a28355..5cdb20c 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
@@ -43,7 +43,7 @@ namespace Apache.Ignite.ExamplesDll.Events
/// <param name="nodeId">Node identifier.</param>
/// <param name="evt">Event.</param>
/// <returns>Value indicating whether specified event passes this filter.</returns>
- public bool Invoke(Guid nodeId, IEvent evt)
+ public bool Invoke(Guid? nodeId, IEvent evt)
{
Interlocked.Increment(ref _eventsReceived);
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c1ef1ae/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs
index db3204a..45a957c 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs
@@ -32,7 +32,7 @@ namespace Apache.Ignite.ExamplesDll.Events
/// <param name="nodeId">Node identifier.</param>
/// <param name="evt">Event.</param>
/// <returns>Value indicating whether specified event passes this filter.</returns>
- public bool Invoke(Guid nodeId, IEvent evt)
+ public bool Invoke(Guid? nodeId, IEvent evt)
{
Console.WriteLine("Remote filter received event [evt={0}]", evt.Name);
[35/50] [abbrv] ignite git commit: IGNITE-1282 CPP: Disabled
incremental building for "common" project.
Posted by vo...@apache.org.
IGNITE-1282 CPP: Disabled incremental building for "common" project.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d8c51453
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d8c51453
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d8c51453
Branch: refs/heads/ignite-1651
Commit: d8c51453bd6a941ffd9a69accce39fe108d4c1e8
Parents: b1b8094
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Oct 21 11:54:40 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Oct 21 11:54:40 2015 +0300
----------------------------------------------------------------------
modules/platforms/cpp/common/project/vs/common.vcxproj | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d8c51453/modules/platforms/cpp/common/project/vs/common.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/project/vs/common.vcxproj b/modules/platforms/cpp/common/project/vs/common.vcxproj
index b7cfb8a..c5c790e 100644
--- a/modules/platforms/cpp/common/project/vs/common.vcxproj
+++ b/modules/platforms/cpp/common/project/vs/common.vcxproj
@@ -67,7 +67,7 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <LinkIncremental>true</LinkIncremental>
+ <LinkIncremental>false</LinkIncremental>
<TargetName>ignite.common</TargetName>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
@@ -76,7 +76,7 @@
<TargetName>ignite.common</TargetName>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
- <LinkIncremental>true</LinkIncremental>
+ <LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
[04/50] [abbrv] ignite git commit: IGNITE-1642: Renamed events.
Posted by vo...@apache.org.
IGNITE-1642: Renamed events.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/52534c33
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/52534c33
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/52534c33
Branch: refs/heads/ignite-1651
Commit: 52534c33ab517981abb6356f550155bc8ae23761
Parents: 7c1ef1a
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Wed Oct 14 13:30:08 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Oct 14 13:30:08 2015 +0300
----------------------------------------------------------------------
.../Apache.Ignite.Core.Tests/EventsTest.cs | 74 ++--
.../Apache.Ignite.Core/Events/EventType.cs | 344 +++++++++----------
.../Events/EventsExample.cs | 4 +-
3 files changed, 206 insertions(+), 216 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/52534c33/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
index 2c014e2..c271aa6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
@@ -104,19 +104,19 @@ namespace Apache.Ignite.Core.Tests
Assert.AreEqual(0, events.GetEnabledEvents().Count);
- Assert.IsFalse(EventType.EventsCache.Any(events.IsEnabled));
+ Assert.IsFalse(EventType.CacheAll.Any(events.IsEnabled));
- events.EnableLocal(EventType.EventsCache);
+ events.EnableLocal(EventType.CacheAll);
- Assert.AreEqual(EventType.EventsCache, events.GetEnabledEvents());
+ Assert.AreEqual(EventType.CacheAll, events.GetEnabledEvents());
- Assert.IsTrue(EventType.EventsCache.All(events.IsEnabled));
+ Assert.IsTrue(EventType.CacheAll.All(events.IsEnabled));
- events.EnableLocal(EventType.EventsTaskExecution);
+ events.EnableLocal(EventType.TaskExecutionAll);
- events.DisableLocal(EventType.EventsCache);
+ events.DisableLocal(EventType.CacheAll);
- Assert.AreEqual(EventType.EventsTaskExecution, events.GetEnabledEvents());
+ Assert.AreEqual(EventType.TaskExecutionAll, events.GetEnabledEvents());
}
/// <summary>
@@ -127,7 +127,7 @@ namespace Apache.Ignite.Core.Tests
{
var events = _grid1.GetEvents();
var listener = EventsTestHelper.GetListener();
- var eventType = EventType.EventsTaskExecution;
+ var eventType = EventType.TaskExecutionAll;
events.EnableLocal(eventType);
@@ -136,7 +136,7 @@ namespace Apache.Ignite.Core.Tests
CheckSend(3); // 3 events per task * 3 grids
// Check unsubscription for specific event
- events.StopLocalListen(listener, EventType.EventTaskReduced);
+ events.StopLocalListen(listener, EventType.TaskReduced);
CheckSend(2);
@@ -146,7 +146,7 @@ namespace Apache.Ignite.Core.Tests
CheckNoEvent();
// Check unsubscription by filter
- events.LocalListen(listener, EventType.EventTaskReduced);
+ events.LocalListen(listener, EventType.TaskReduced);
CheckSend();
@@ -166,7 +166,7 @@ namespace Apache.Ignite.Core.Tests
{
var events = _grid1.GetEvents();
var listener = EventsTestHelper.GetListener();
- var eventType = EventType.EventsTaskExecution;
+ var eventType = EventType.TaskExecutionAll;
events.EnableLocal(eventType);
@@ -234,7 +234,7 @@ namespace Apache.Ignite.Core.Tests
{
yield return new EventTestCase
{
- EventType = EventType.EventsCache,
+ EventType = EventType.CacheAll,
EventObjectType = typeof (CacheEvent),
GenerateEvent = g => g.GetCache<int, int>(null).Put(1, 1),
VerifyEvents = (e, g) => VerifyCacheEvents(e, g),
@@ -243,7 +243,7 @@ namespace Apache.Ignite.Core.Tests
yield return new EventTestCase
{
- EventType = EventType.EventsTaskExecution,
+ EventType = EventType.TaskExecutionAll,
EventObjectType = typeof (TaskEvent),
GenerateEvent = g => GenerateTaskEvent(g),
VerifyEvents = (e, g) => VerifyTaskEvents(e),
@@ -252,7 +252,7 @@ namespace Apache.Ignite.Core.Tests
yield return new EventTestCase
{
- EventType = EventType.EventsJobExecution,
+ EventType = EventType.JobExecutionAll,
EventObjectType = typeof (JobEvent),
GenerateEvent = g => GenerateTaskEvent(g),
EventCount = 9
@@ -260,7 +260,7 @@ namespace Apache.Ignite.Core.Tests
yield return new EventTestCase
{
- EventType = new[] {EventType.EventCacheQueryExecuted},
+ EventType = new[] {EventType.CacheQueryExecuted},
EventObjectType = typeof (CacheQueryExecutedEvent),
GenerateEvent = g => GenerateCacheQueryEvent(g),
EventCount = 1
@@ -268,7 +268,7 @@ namespace Apache.Ignite.Core.Tests
yield return new EventTestCase
{
- EventType = new[] { EventType.EventCacheQueryObjectRead },
+ EventType = new[] { EventType.CacheQueryObjectRead },
EventObjectType = typeof (CacheQueryReadEvent),
GenerateEvent = g => GenerateCacheQueryEvent(g),
EventCount = 1
@@ -284,7 +284,7 @@ namespace Apache.Ignite.Core.Tests
{
var events = _grid1.GetEvents();
- var eventType = EventType.EventsTaskExecution;
+ var eventType = EventType.TaskExecutionAll;
events.EnableLocal(eventType);
@@ -311,7 +311,7 @@ namespace Apache.Ignite.Core.Tests
if (async)
events = events.WithAsync();
- var eventType = EventType.EventsTaskExecution;
+ var eventType = EventType.TaskExecutionAll;
events.EnableLocal(eventType);
@@ -340,27 +340,27 @@ namespace Apache.Ignite.Core.Tests
waitTask.Wait(timeout);
// Event types
- waitTask = getWaitTask(() => events.WaitForLocal(EventType.EventTaskReduced));
+ waitTask = getWaitTask(() => events.WaitForLocal(EventType.TaskReduced));
Assert.IsTrue(waitTask.Wait(timeout));
Assert.IsInstanceOf(typeof(TaskEvent), waitTask.Result);
- Assert.AreEqual(EventType.EventTaskReduced, waitTask.Result.Type);
+ Assert.AreEqual(EventType.TaskReduced, waitTask.Result.Type);
// Filter
waitTask = getWaitTask(() => events.WaitForLocal(
- new EventFilter<IEvent>((g, e) => e.Type == EventType.EventTaskReduced)));
+ new EventFilter<IEvent>((g, e) => e.Type == EventType.TaskReduced)));
Assert.IsTrue(waitTask.Wait(timeout));
Assert.IsInstanceOf(typeof(TaskEvent), waitTask.Result);
- Assert.AreEqual(EventType.EventTaskReduced, waitTask.Result.Type);
+ Assert.AreEqual(EventType.TaskReduced, waitTask.Result.Type);
// Filter & types
waitTask = getWaitTask(() => events.WaitForLocal(
- new EventFilter<IEvent>((g, e) => e.Type == EventType.EventTaskReduced), EventType.EventTaskReduced));
+ new EventFilter<IEvent>((g, e) => e.Type == EventType.TaskReduced), EventType.TaskReduced));
Assert.IsTrue(waitTask.Wait(timeout));
Assert.IsInstanceOf(typeof(TaskEvent), waitTask.Result);
- Assert.AreEqual(EventType.EventTaskReduced, waitTask.Result.Type);
+ Assert.AreEqual(EventType.TaskReduced, waitTask.Result.Type);
}
/// <summary>
@@ -374,13 +374,13 @@ namespace Apache.Ignite.Core.Tests
{
foreach (var g in _grids)
{
- g.GetEvents().EnableLocal(EventType.EventsJobExecution);
- g.GetEvents().EnableLocal(EventType.EventsTaskExecution);
+ g.GetEvents().EnableLocal(EventType.JobExecutionAll);
+ g.GetEvents().EnableLocal(EventType.TaskExecutionAll);
}
var events = _grid1.GetEvents();
- var expectedType = EventType.EventJobStarted;
+ var expectedType = EventType.JobStarted;
var remoteFilter = portable
? (IEventFilter<IEvent>) new RemoteEventPortableFilter(expectedType)
@@ -401,7 +401,7 @@ namespace Apache.Ignite.Core.Tests
CheckSend(3, typeof(JobEvent), expectedType);
- _grid3.GetEvents().DisableLocal(EventType.EventsJobExecution);
+ _grid3.GetEvents().DisableLocal(EventType.JobExecutionAll);
CheckSend(2, typeof(JobEvent), expectedType);
@@ -435,11 +435,11 @@ namespace Apache.Ignite.Core.Tests
public void TestRemoteQuery([Values(true, false)] bool async)
{
foreach (var g in _grids)
- g.GetEvents().EnableLocal(EventType.EventsJobExecution);
+ g.GetEvents().EnableLocal(EventType.JobExecutionAll);
var events = _grid1.GetEvents();
- var eventFilter = new RemoteEventFilter(EventType.EventJobStarted);
+ var eventFilter = new RemoteEventFilter(EventType.JobStarted);
var oldEvents = events.RemoteQuery(eventFilter);
@@ -448,7 +448,7 @@ namespace Apache.Ignite.Core.Tests
GenerateTaskEvent();
- var remoteQuery = events.RemoteQuery(eventFilter, EventsTestHelper.Timeout, EventType.EventsJobExecution);
+ var remoteQuery = events.RemoteQuery(eventFilter, EventsTestHelper.Timeout, EventType.JobExecutionAll);
if (async)
{
@@ -461,7 +461,7 @@ namespace Apache.Ignite.Core.Tests
Assert.AreEqual(_grids.Length, qryResult.Count);
- Assert.IsTrue(qryResult.All(x => x.Type == EventType.EventJobStarted));
+ Assert.IsTrue(qryResult.All(x => x.Type == EventType.JobStarted));
}
/// <summary>
@@ -577,7 +577,7 @@ namespace Apache.Ignite.Core.Tests
Assert.AreEqual(locNode, evt.Node);
Assert.AreEqual("msg", evt.Message);
- Assert.AreEqual(EventType.EventSwapSpaceCleared, evt.Type);
+ Assert.AreEqual(EventType.SwapSpaceCleared, evt.Type);
Assert.IsNotNullOrEmpty(evt.Name);
Assert.AreNotEqual(Guid.Empty, evt.Id.GlobalId);
Assert.IsTrue((evt.Timestamp - DateTime.Now).TotalSeconds < 10);
@@ -596,7 +596,7 @@ namespace Apache.Ignite.Core.Tests
GenerateTaskEvent();
EventsTestHelper.VerifyReceive(repeat, eventObjectType ?? typeof (TaskEvent),
- eventType.Any() ? eventType : EventType.EventsTaskExecution);
+ eventType.Any() ? eventType : EventType.TaskExecutionAll);
}
/// <summary>
@@ -651,7 +651,7 @@ namespace Apache.Ignite.Core.Tests
// started, reduced, finished
Assert.AreEqual(
- new[] {EventType.EventTaskStarted, EventType.EventTaskReduced, EventType.EventTaskFinished},
+ new[] {EventType.TaskStarted, EventType.TaskReduced, EventType.TaskFinished},
e.Select(x => x.Type).ToArray());
}
@@ -687,12 +687,12 @@ namespace Apache.Ignite.Core.Tests
Assert.AreEqual(false, cacheEvent.HasOldValue);
Assert.AreEqual(null, cacheEvent.OldValue);
- if (cacheEvent.Type == EventType.EventCacheObjectPut)
+ if (cacheEvent.Type == EventType.CacheObjectPut)
{
Assert.AreEqual(true, cacheEvent.HasNewValue);
Assert.AreEqual(1, cacheEvent.NewValue);
}
- else if (cacheEvent.Type == EventType.EventCacheEntryCreated)
+ else if (cacheEvent.Type == EventType.CacheEntryCreated)
{
Assert.AreEqual(false, cacheEvent.HasNewValue);
Assert.AreEqual(null, cacheEvent.NewValue);
http://git-wip-us.apache.org/repos/asf/ignite/blob/52534c33/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventType.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventType.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventType.cs
index 1c56de2..56a1b83 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventType.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventType.cs
@@ -15,10 +15,12 @@
* limitations under the License.
*/
+// ReSharper disable ConvertToConstant.Global
+// ReSharper disable MemberCanBePrivate.Global
+// ReSharper disable UnusedMember.Global
namespace Apache.Ignite.Core.Events
{
using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
@@ -39,556 +41,544 @@ namespace Apache.Ignite.Core.Events
/// <summary>
/// Built-in event type: checkpoint was saved.
/// </summary>
- public static readonly int EventCheckpointSaved = 1;
+ public static readonly int CheckpointSaved = 1;
/// <summary>
/// Built-in event type: checkpoint was loaded.
/// </summary>
- public static readonly int EventCheckpointLoaded = 2;
+ public static readonly int CheckpointLoaded = 2;
/// <summary>
/// Built-in event type: checkpoint was removed. Reasons are: timeout expired, or or it was manually removed,
/// or it was automatically removed by the task session.
/// </summary>
- public static readonly int EventCheckpointRemoved = 3;
+ public static readonly int CheckpointRemoved = 3;
/// <summary>
/// Built-in event type: node joined topology. New node has been discovered and joined grid topology. Note that
/// even though a node has been discovered there could be a number of warnings in the log. In certain
/// situations Ignite doesn't prevent a node from joining but prints warning messages into the log.
/// </summary>
- public static readonly int EventNodeJoined = 10;
+ public static readonly int NodeJoined = 10;
/// <summary>
/// Built-in event type: node has normally left topology.
/// </summary>
- public static readonly int EventNodeLeft = 11;
+ public static readonly int NodeLeft = 11;
/// <summary>
/// Built-in event type: node failed. Ignite detected that node has presumably crashed and is considered
/// failed.
/// </summary>
- public static readonly int EventNodeFailed = 12;
+ public static readonly int NodeFailed = 12;
/// <summary>
/// Built-in event type: node metrics updated. Generated when node's metrics are updated. In most cases this
/// callback is invoked with every heartbeat received from a node (including local node).
/// </summary>
- public static readonly int EventNodeMetricsUpdated = 13;
+ public static readonly int NodeMetricsUpdated = 13;
/// <summary>
/// Built-in event type: local node segmented. Generated when node determines that it runs in invalid network
/// segment.
/// </summary>
- public static readonly int EventNodeSegmented = 14;
+ public static readonly int NodeSegmented = 14;
/// <summary>
/// Built-in event type: client node disconnected.
/// </summary>
- public static readonly int EventClientNodeDisconnected = 16;
+ public static readonly int ClientNodeDisconnected = 16;
/// <summary>
/// Built-in event type: client node reconnected.
/// </summary>
- public static readonly int EventClientNodeReconnected = 17;
+ public static readonly int ClientNodeReconnected = 17;
/// <summary>
/// Built-in event type: task started.
/// </summary>
- public static readonly int EventTaskStarted = 20;
+ public static readonly int TaskStarted = 20;
/// <summary>
/// Built-in event type: task finished. Task got finished. This event is triggered every time a task finished
/// without exception.
/// </summary>
- public static readonly int EventTaskFinished = 21;
+ public static readonly int TaskFinished = 21;
/// <summary>
/// Built-in event type: task failed. Task failed. This event is triggered every time a task finished with an
/// exception. Note that prior to this event, there could be other events recorded specific to the failure.
/// </summary>
- public static readonly int EventTaskFailed = 22;
+ public static readonly int TaskFailed = 22;
/// <summary>
/// Built-in event type: task timed out.
/// </summary>
- public static readonly int EventTaskTimedout = 23;
+ public static readonly int TaskTimedout = 23;
/// <summary>
/// Built-in event type: task session attribute set.
/// </summary>
- public static readonly int EventTaskSessionAttrSet = 24;
+ public static readonly int TaskSessionAttrSet = 24;
/// <summary>
/// Built-in event type: task reduced.
/// </summary>
- public static readonly int EventTaskReduced = 25;
+ public static readonly int TaskReduced = 25;
/// <summary>
/// Built-in event type: Ignite job was mapped in {@link org.apache.ignite.compute.ComputeTask#map(List, Object)}
/// method.
/// </summary>
- public static readonly int EventJobMapped = 40;
+ public static readonly int JobMapped = 40;
/// <summary>
/// Built-in event type: Ignite job result was received by {@link
/// org.apache.ignite.compute.ComputeTask#result(org.apache.ignite.compute.ComputeJobResult, List)} method.
/// </summary>
- public static readonly int EventJobResulted = 41;
+ public static readonly int JobResulted = 41;
/// <summary>
/// Built-in event type: Ignite job failed over.
/// </summary>
- public static readonly int EventJobFailedOver = 43;
+ public static readonly int JobFailedOver = 43;
/// <summary>
/// Built-in event type: Ignite job started.
/// </summary>
- public static readonly int EventJobStarted = 44;
+ public static readonly int JobStarted = 44;
/// <summary>
/// Built-in event type: Ignite job finished. Job has successfully completed and produced a result which from the
/// user perspective can still be either negative or positive.
/// </summary>
- public static readonly int EventJobFinished = 45;
+ public static readonly int JobFinished = 45;
/// <summary>
/// Built-in event type: Ignite job timed out.
/// </summary>
- public static readonly int EventJobTimedout = 46;
+ public static readonly int JobTimedout = 46;
/// <summary>
/// Built-in event type: Ignite job rejected during collision resolution.
/// </summary>
- public static readonly int EventJobRejected = 47;
+ public static readonly int JobRejected = 47;
/// <summary>
/// Built-in event type: Ignite job failed. Job has failed. This means that there was some error event during job
/// execution and job did not produce a result.
/// </summary>
- public static readonly int EventJobFailed = 48;
+ public static readonly int JobFailed = 48;
/// <summary>
/// Built-in event type: Ignite job queued. Job arrived for execution and has been queued (added to passive queue
/// during collision resolution).
/// </summary>
- public static readonly int EventJobQueued = 49;
+ public static readonly int JobQueued = 49;
/// <summary>
/// Built-in event type: Ignite job cancelled.
/// </summary>
- public static readonly int EventJobCancelled = 50;
+ public static readonly int JobCancelled = 50;
/// <summary>
/// Built-in event type: entry created.
/// </summary>
- public static readonly int EventCacheEntryCreated = 60;
+ public static readonly int CacheEntryCreated = 60;
/// <summary>
/// Built-in event type: entry destroyed.
/// </summary>
- public static readonly int EventCacheEntryDestroyed = 61;
+ public static readonly int CacheEntryDestroyed = 61;
/// <summary>
/// Built-in event type: entry evicted.
/// </summary>
- public static readonly int EventCacheEntryEvicted = 62;
+ public static readonly int CacheEntryEvicted = 62;
/// <summary>
/// Built-in event type: object put.
/// </summary>
- public static readonly int EventCacheObjectPut = 63;
+ public static readonly int CacheObjectPut = 63;
/// <summary>
/// Built-in event type: object read.
/// </summary>
- public static readonly int EventCacheObjectRead = 64;
+ public static readonly int CacheObjectRead = 64;
/// <summary>
/// Built-in event type: object removed.
/// </summary>
- public static readonly int EventCacheObjectRemoved = 65;
+ public static readonly int CacheObjectRemoved = 65;
/// <summary>
/// Built-in event type: object locked.
/// </summary>
- public static readonly int EventCacheObjectLocked = 66;
+ public static readonly int CacheObjectLocked = 66;
/// <summary>
/// Built-in event type: object unlocked.
/// </summary>
- public static readonly int EventCacheObjectUnlocked = 67;
+ public static readonly int CacheObjectUnlocked = 67;
/// <summary>
/// Built-in event type: cache object swapped from swap storage.
/// </summary>
- public static readonly int EventCacheObjectSwapped = 68;
+ public static readonly int CacheObjectSwapped = 68;
/// <summary>
/// Built-in event type: cache object unswapped from swap storage.
/// </summary>
- public static readonly int EventCacheObjectUnswapped = 69;
+ public static readonly int CacheObjectUnswapped = 69;
/// <summary>
/// Built-in event type: cache object was expired when reading it.
/// </summary>
- public static readonly int EventCacheObjectExpired = 70;
+ public static readonly int CacheObjectExpired = 70;
/// <summary>
/// Built-in event type: swap space data read.
/// </summary>
- public static readonly int EventSwapSpaceDataRead = 71;
+ public static readonly int SwapSpaceDataRead = 71;
/// <summary>
/// Built-in event type: swap space data stored.
/// </summary>
- public static readonly int EventSwapSpaceDataStored = 72;
+ public static readonly int SwapSpaceDataStored = 72;
/// <summary>
/// Built-in event type: swap space data removed.
/// </summary>
- public static readonly int EventSwapSpaceDataRemoved = 73;
+ public static readonly int SwapSpaceDataRemoved = 73;
/// <summary>
/// Built-in event type: swap space cleared.
/// </summary>
- public static readonly int EventSwapSpaceCleared = 74;
+ public static readonly int SwapSpaceCleared = 74;
/// <summary>
/// Built-in event type: swap space data evicted.
/// </summary>
- public static readonly int EventSwapSpaceDataEvicted = 75;
+ public static readonly int SwapSpaceDataEvicted = 75;
/// <summary>
/// Built-in event type: cache object stored in off-heap storage.
/// </summary>
- public static readonly int EventCacheObjectToOffheap = 76;
+ public static readonly int CacheObjectToOffheap = 76;
/// <summary>
/// Built-in event type: cache object moved from off-heap storage back into memory.
/// </summary>
- public static readonly int EventCacheObjectFromOffheap = 77;
+ public static readonly int CacheObjectFromOffheap = 77;
/// <summary>
/// Built-in event type: cache rebalance started.
/// </summary>
- public static readonly int EventCacheRebalanceStarted = 80;
+ public static readonly int CacheRebalanceStarted = 80;
/// <summary>
/// Built-in event type: cache rebalance stopped.
/// </summary>
- public static readonly int EventCacheRebalanceStopped = 81;
+ public static readonly int CacheRebalanceStopped = 81;
/// <summary>
/// Built-in event type: cache partition loaded.
/// </summary>
- public static readonly int EventCacheRebalancePartLoaded = 82;
+ public static readonly int CacheRebalancePartLoaded = 82;
/// <summary>
/// Built-in event type: cache partition unloaded.
/// </summary>
- public static readonly int EventCacheRebalancePartUnloaded = 83;
+ public static readonly int CacheRebalancePartUnloaded = 83;
/// <summary>
/// Built-in event type: cache entry rebalanced.
/// </summary>
- public static readonly int EventCacheRebalanceObjectLoaded = 84;
+ public static readonly int CacheRebalanceObjectLoaded = 84;
/// <summary>
/// Built-in event type: cache entry unloaded.
/// </summary>
- public static readonly int EventCacheRebalanceObjectUnloaded = 85;
+ public static readonly int CacheRebalanceObjectUnloaded = 85;
/// <summary>
/// Built-in event type: all nodes that hold partition left topology.
/// </summary>
- public static readonly int EventCacheRebalancePartDataLost = 86;
+ public static readonly int CacheRebalancePartDataLost = 86;
/// <summary>
/// Built-in event type: query executed.
/// </summary>
- public static readonly int EventCacheQueryExecuted = 96;
+ public static readonly int CacheQueryExecuted = 96;
/// <summary>
/// Built-in event type: query entry read.
/// </summary>
- public static readonly int EventCacheQueryObjectRead = 97;
+ public static readonly int CacheQueryObjectRead = 97;
/// <summary>
/// Built-in event type: cache started.
/// </summary>
- public static readonly int EventCacheStarted = 98;
+ public static readonly int CacheStarted = 98;
/// <summary>
/// Built-in event type: cache started.
/// </summary>
- public static readonly int EventCacheStopped = 99;
+ public static readonly int CacheStopped = 99;
/// <summary>
/// Built-in event type: cache nodes left.
/// </summary>
- public static readonly int EventCacheNodesLeft = 100;
+ public static readonly int CacheNodesLeft = 100;
/// <summary>
/// All events indicating an error or failure condition. It is convenient to use when fetching all events
/// indicating error or failure.
/// </summary>
- private static readonly ICollection<int> EventsError0 = new[]
+ private static readonly ICollection<int> ErrorAll0 = new[]
{
- EventJobTimedout,
- EventJobFailed,
- EventJobFailedOver,
- EventJobRejected,
- EventJobCancelled,
- EventTaskTimedout,
- EventTaskFailed,
- EventCacheRebalanceStarted,
- EventCacheRebalanceStopped
+ JobTimedout,
+ JobFailed,
+ JobFailedOver,
+ JobRejected,
+ JobCancelled,
+ TaskTimedout,
+ TaskFailed,
+ CacheRebalanceStarted,
+ CacheRebalanceStopped
}.AsReadOnly();
/// <summary>
- /// All discovery events except for <see cref="EventNodeMetricsUpdated" />. Subscription to <see
- /// cref="EventNodeMetricsUpdated" /> can generate massive amount of event processing in most cases is not
+ /// All discovery events except for <see cref="NodeMetricsUpdated" />. Subscription to <see
+ /// cref="NodeMetricsUpdated" /> can generate massive amount of event processing in most cases is not
/// necessary. If this event is indeed required you can subscribe to it individually or use <see
- /// cref="EventsDiscoveryAll0" /> array.
+ /// cref="DiscoveryAll0" /> array.
/// </summary>
- private static readonly ICollection<int> EventsDiscovery0 = new[]
+ private static readonly ICollection<int> DiscoveryAllMinusMetrics0 = new[]
{
- EventNodeJoined,
- EventNodeLeft,
- EventNodeFailed,
- EventNodeSegmented,
- EventClientNodeDisconnected,
- EventClientNodeReconnected
+ NodeJoined,
+ NodeLeft,
+ NodeFailed,
+ NodeSegmented,
+ ClientNodeDisconnected,
+ ClientNodeReconnected
}.AsReadOnly();
/// <summary>
/// All discovery events.
/// </summary>
- private static readonly ICollection<int> EventsDiscoveryAll0 = new[]
+ private static readonly ICollection<int> DiscoveryAll0 = new[]
{
- EventNodeJoined,
- EventNodeLeft,
- EventNodeFailed,
- EventNodeSegmented,
- EventNodeMetricsUpdated,
- EventClientNodeDisconnected,
- EventClientNodeReconnected
+ NodeJoined,
+ NodeLeft,
+ NodeFailed,
+ NodeSegmented,
+ NodeMetricsUpdated,
+ ClientNodeDisconnected,
+ ClientNodeReconnected
}.AsReadOnly();
/// <summary>
/// All Ignite job execution events.
/// </summary>
- private static readonly ICollection<int> EventsJobExecution0 = new[]
+ private static readonly ICollection<int> JobExecutionAll0 = new[]
{
- EventJobMapped,
- EventJobResulted,
- EventJobFailedOver,
- EventJobStarted,
- EventJobFinished,
- EventJobTimedout,
- EventJobRejected,
- EventJobFailed,
- EventJobQueued,
- EventJobCancelled
+ JobMapped,
+ JobResulted,
+ JobFailedOver,
+ JobStarted,
+ JobFinished,
+ JobTimedout,
+ JobRejected,
+ JobFailed,
+ JobQueued,
+ JobCancelled
}.AsReadOnly();
/// <summary>
/// All Ignite task execution events.
/// </summary>
- private static readonly ICollection<int> EventsTaskExecution0 = new[]
+ private static readonly ICollection<int> TaskExecutionAll0 = new[]
{
- EventTaskStarted,
- EventTaskFinished,
- EventTaskFailed,
- EventTaskTimedout,
- EventTaskSessionAttrSet,
- EventTaskReduced
+ TaskStarted,
+ TaskFinished,
+ TaskFailed,
+ TaskTimedout,
+ TaskSessionAttrSet,
+ TaskReduced
}.AsReadOnly();
/// <summary>
/// All cache events.
/// </summary>
- private static readonly ICollection<int> EventsCache0 = new[]
+ private static readonly ICollection<int> CacheAll0 = new[]
{
- EventCacheEntryCreated,
- EventCacheEntryDestroyed,
- EventCacheObjectPut,
- EventCacheObjectRead,
- EventCacheObjectRemoved,
- EventCacheObjectLocked,
- EventCacheObjectUnlocked,
- EventCacheObjectSwapped,
- EventCacheObjectUnswapped,
- EventCacheObjectExpired
+ CacheEntryCreated,
+ CacheEntryDestroyed,
+ CacheObjectPut,
+ CacheObjectRead,
+ CacheObjectRemoved,
+ CacheObjectLocked,
+ CacheObjectUnlocked,
+ CacheObjectSwapped,
+ CacheObjectUnswapped,
+ CacheObjectExpired
}.AsReadOnly();
/// <summary>
/// All cache rebalance events.
/// </summary>
- private static readonly ICollection<int> EventsCacheRebalance0 = new[]
+ private static readonly ICollection<int> CacheRebalanceAll0 = new[]
{
- EventCacheRebalanceStarted,
- EventCacheRebalanceStopped,
- EventCacheRebalancePartLoaded,
- EventCacheRebalancePartUnloaded,
- EventCacheRebalanceObjectLoaded,
- EventCacheRebalanceObjectUnloaded,
- EventCacheRebalancePartDataLost
+ CacheRebalanceStarted,
+ CacheRebalanceStopped,
+ CacheRebalancePartLoaded,
+ CacheRebalancePartUnloaded,
+ CacheRebalanceObjectLoaded,
+ CacheRebalanceObjectUnloaded,
+ CacheRebalancePartDataLost
}.AsReadOnly();
/// <summary>
/// All cache lifecycle events.
/// </summary>
- private static readonly ICollection<int> EventsCacheLifecycle0 = new[]
+ private static readonly ICollection<int> CacheLifecycleAll0 = new[]
{
- EventCacheStarted,
- EventCacheStopped,
- EventCacheNodesLeft
+ CacheStarted,
+ CacheStopped,
+ CacheNodesLeft
}.AsReadOnly();
/// <summary>
/// All cache query events.
/// </summary>
- private static readonly ICollection<int> EventsCacheQuery0 = new[]
+ private static readonly ICollection<int> CacheQueryAll0 = new[]
{
- EventCacheQueryExecuted,
- EventCacheQueryObjectRead
+ CacheQueryExecuted,
+ CacheQueryObjectRead
}.AsReadOnly();
/// <summary>
/// All swap space events.
/// </summary>
- private static readonly ICollection<int> EventsSwapspace0 = new[]
+ private static readonly ICollection<int> SwapspaceAll0 = new[]
{
- EventSwapSpaceCleared,
- EventSwapSpaceDataRemoved,
- EventSwapSpaceDataRead,
- EventSwapSpaceDataStored,
- EventSwapSpaceDataEvicted
+ SwapSpaceCleared,
+ SwapSpaceDataRemoved,
+ SwapSpaceDataRead,
+ SwapSpaceDataStored,
+ SwapSpaceDataEvicted
}.AsReadOnly();
/// <summary>
/// All Ignite events.
/// </summary>
- private static readonly ICollection<int> EventsAll0 = GetAllEvents().AsReadOnly();
+ private static readonly ICollection<int> All0 = GetAllEvents().AsReadOnly();
/// <summary>
/// All Ignite events (<b>excluding</b> metric update event).
/// </summary>
- private static readonly ICollection<int> EventsAllMinusMetricUpdate0 =
- EventsAll0.Where(x => x != EventNodeMetricsUpdated).ToArray().AsReadOnly();
+ private static readonly ICollection<int> AllMinusMetricUpdate0 =
+ All0.Where(x => x != NodeMetricsUpdated).ToArray().AsReadOnly();
/// <summary>
/// All events indicating an error or failure condition. It is convenient to use when fetching all events
/// indicating error or failure.
/// </summary>
- [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
- public static ICollection<int> EventsError
+ public static ICollection<int> ErrorAll
{
- get { return EventsError0; }
+ get { return ErrorAll0; }
}
/// <summary>
/// All Ignite events (<b>excluding</b> metric update event).
/// </summary>
- [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
- public static ICollection<int> EventsAllMinusMetricUpdate
+ public static ICollection<int> AllMinusMetricUpdate
{
- get { return EventsAllMinusMetricUpdate0; }
+ get { return AllMinusMetricUpdate0; }
}
/// <summary>
/// All swap space events.
/// </summary>
- [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
- public static ICollection<int> EventsSwapspace
+ public static ICollection<int> SwapspaceAll
{
- get { return EventsSwapspace0; }
+ get { return SwapspaceAll0; }
}
/// <summary>
/// All cache query events.
/// </summary>
- [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
- public static ICollection<int> EventsCacheQuery
+ public static ICollection<int> CacheQueryAll
{
- get { return EventsCacheQuery0; }
+ get { return CacheQueryAll0; }
}
/// <summary>
/// All cache lifecycle events.
/// </summary>
- [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
- public static ICollection<int> EventsCacheLifecycle
+ public static ICollection<int> CacheLifecycleAll
{
- get { return EventsCacheLifecycle0; }
+ get { return CacheLifecycleAll0; }
}
/// <summary>
/// All cache rebalance events.
/// </summary>
- [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
- public static ICollection<int> EventsCacheRebalance
+ public static ICollection<int> CacheRebalanceAll
{
- get { return EventsCacheRebalance0; }
+ get { return CacheRebalanceAll0; }
}
/// <summary>
/// All cache events.
/// </summary>
- [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
- public static ICollection<int> EventsCache
+ public static ICollection<int> CacheAll
{
- get { return EventsCache0; }
+ get { return CacheAll0; }
}
/// <summary>
/// All Ignite task execution events.
/// </summary>
- [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
- public static ICollection<int> EventsTaskExecution
+ public static ICollection<int> TaskExecutionAll
{
- get { return EventsTaskExecution0; }
+ get { return TaskExecutionAll0; }
}
/// <summary>
/// All Ignite job execution events.
/// </summary>
- [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
- public static ICollection<int> EventsJobExecution
+ public static ICollection<int> JobExecutionAll
{
- get { return EventsJobExecution0; }
+ get { return JobExecutionAll0; }
}
/// <summary>
/// All discovery events.
/// </summary>
- [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
- public static ICollection<int> EventsDiscoveryAll
+ public static ICollection<int> DiscoveryAll
{
- get { return EventsDiscoveryAll0; }
+ get { return DiscoveryAll0; }
}
/// <summary>
- /// All discovery events except for <see cref="EventNodeMetricsUpdated" />. Subscription to <see
- /// cref="EventNodeMetricsUpdated" /> can generate massive amount of event processing in most cases is not
+ /// All discovery events except for <see cref="NodeMetricsUpdated" />. Subscription to <see
+ /// cref="NodeMetricsUpdated" /> can generate massive amount of event processing in most cases is not
/// necessary. If this event is indeed required you can subscribe to it individually or use <see
- /// cref="EventsDiscoveryAll0" /> array.
+ /// cref="DiscoveryAll0" /> array.
/// </summary>
- [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
- public static ICollection<int> EventsDiscovery
+ public static ICollection<int> DiscoveryAllMinusMetrics
{
- get { return EventsDiscovery0; }
+ get { return DiscoveryAllMinusMetrics0; }
}
/// <summary>
/// All Ignite events.
/// </summary>
- [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
- public static ICollection<int> EventsAll
+ public static ICollection<int> All
{
- get { return EventsAll0; }
+ get { return All0; }
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/52534c33/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
index ed87309..c1f3035 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
@@ -63,7 +63,7 @@ namespace Apache.Ignite.Examples.Events
Console.WriteLine(">>> Listening for a local event...");
var listener = new LocalListener();
- ignite.GetEvents().LocalListen(listener, EventType.EventsTaskExecution);
+ ignite.GetEvents().LocalListen(listener, EventType.TaskExecutionAll);
ExecuteTask(ignite);
@@ -79,7 +79,7 @@ namespace Apache.Ignite.Examples.Events
var remoteFilter = new RemoteFilter();
var listenId = ignite.GetEvents().RemoteListen(localListener: localListener,
- remoteFilter: remoteFilter, types: EventType.EventsJobExecution);
+ remoteFilter: remoteFilter, types: EventType.JobExecutionAll);
if (listenId == null)
throw new InvalidOperationException("Subscription failed.");
[49/50] [abbrv] ignite git commit: Merge branch 'ignite-1282' into
ignite-1651
Posted by vo...@apache.org.
Merge branch 'ignite-1282' into ignite-1651
Conflicts:
modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ec58b87c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ec58b87c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ec58b87c
Branch: refs/heads/ignite-1651
Commit: ec58b87cf4e2e93dca1a943d5479518ee0eb75a4
Parents: 4f82364 dedf283
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Oct 22 12:22:32 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Oct 22 12:22:32 2015 +0300
----------------------------------------------------------------------
DEVNOTES.txt | 3 +-
assembly/dependencies-hadoop.xml | 1 +
assembly/release-fabric-lgpl.xml | 63 +
assembly/release-fabric.xml | 92 +
assembly/release-hadoop-lgpl.xml | 39 +
examples-lgpl/README.txt | 27 +
examples-lgpl/config/example-cache.xml | 73 +
examples-lgpl/config/example-ignite.xml | 83 +
examples-lgpl/config/hibernate/README.txt | 8 +
.../hibernate/example-hibernate-L2-cache.xml | 64 +
examples-lgpl/pom-standalone.xml | 186 +
examples-lgpl/pom.xml | 128 +
.../hibernate/HibernateL2CacheExample.java | 245 ++
.../examples/datagrid/hibernate/Post.java | 130 +
.../examples/datagrid/hibernate/User.java | 154 +
.../datagrid/hibernate/package-info.java | 22 +
.../hibernate/CacheHibernatePersonStore.java | 122 +
.../hibernate/CacheHibernateStoreExample.java | 151 +
.../datagrid/store/hibernate/Person.hbm.xml | 34 +
.../datagrid/store/hibernate/hibernate.cfg.xml | 41 +
.../datagrid/store/hibernate/package-info.java | 22 +
.../misc/schedule/ComputeScheduleExample.java | 82 +
.../examples/misc/schedule/package-info.java | 22 +
.../misc/schedule/ComputeScheduleExample.java | 68 +
.../java8/misc/schedule/package-info.java | 22 +
.../ignite/examples/java8/package-info.java | 23 +
.../scalar/examples/ScalarScheduleExample.scala | 66 +
...ibernateL2CacheExampleMultiNodeSelfTest.java | 31 +
.../HibernateL2CacheExampleSelfTest.java | 33 +
.../IgniteLgplExamplesSelfTestSuite.java | 48 +
...ibernateL2CacheExampleMultiNodeSelfTest.java | 29 +
.../HibernateL2CacheExampleSelfTest.java | 37 +
.../IgniteLgplExamplesJ8SelfTestSuite.java | 46 +
.../ScalarLgplExamplesMultiNodeSelfTest.scala | 33 +
.../examples/ScalarLgplExamplesSelfTest.scala | 36 +
.../ScalarLgplExamplesSelfTestSuite.scala | 37 +
examples/config/hibernate/README.txt | 8 -
.../hibernate/example-hibernate-L2-cache.xml | 64 -
examples/pom-standalone.xml | 12 -
examples/pom.xml | 12 -
.../hibernate/HibernateL2CacheExample.java | 245 --
.../examples/datagrid/hibernate/Post.java | 130 -
.../examples/datagrid/hibernate/User.java | 154 -
.../datagrid/hibernate/package-info.java | 22 -
.../hibernate/CacheHibernatePersonStore.java | 122 -
.../hibernate/CacheHibernateStoreExample.java | 151 -
.../datagrid/store/hibernate/Person.hbm.xml | 34 -
.../datagrid/store/hibernate/hibernate.cfg.xml | 41 -
.../datagrid/store/hibernate/package-info.java | 22 -
.../misc/schedule/ComputeScheduleExample.java | 82 -
.../examples/misc/schedule/package-info.java | 22 -
.../misc/schedule/ComputeScheduleExample.java | 68 -
.../java8/misc/schedule/package-info.java | 22 -
.../scalar/examples/ScalarScheduleExample.scala | 66 -
...ibernateL2CacheExampleMultiNodeSelfTest.java | 31 -
.../HibernateL2CacheExampleSelfTest.java | 33 -
.../testsuites/IgniteExamplesSelfTestSuite.java | 4 -
...ibernateL2CacheExampleMultiNodeSelfTest.java | 29 -
.../HibernateL2CacheExampleSelfTest.java | 37 -
.../tests/examples/ScalarExamplesSelfTest.scala | 5 -
...processors.platform.PlatformBootstrapFactory | 2 +
.../configuration/CacheConfiguration.java | 12 +-
.../configuration/IgniteConfiguration.java | 22 +
.../configuration/PlatformConfiguration.java | 25 +
.../apache/ignite/internal/IgniteKernal.java | 14 +-
.../discovery/GridDiscoveryManager.java | 10 -
.../internal/portable/PortableContext.java | 19 +-
.../processors/cache/GridCacheAdapter.java | 357 +-
.../cache/GridCacheClearAllRunnable.java | 18 +-
.../cache/GridCacheConcurrentMap.java | 4 +-
.../processors/cache/GridCacheProxyImpl.java | 14 +-
.../processors/cache/IgniteCacheProxy.java | 2 +-
.../processors/cache/IgniteInternalCache.java | 19 +-
.../distributed/dht/GridDhtCacheAdapter.java | 6 +-
.../distributed/near/GridNearCacheAdapter.java | 21 +-
.../near/GridNearCacheClearAllRunnable.java | 9 +-
.../datastructures/GridCacheAtomicLongImpl.java | 26 +-
.../processors/hadoop/HadoopJobProperty.java | 2 +-
.../processors/igfs/IgfsMetaManager.java | 10 +-
.../platform/PlatformAbstractBootstrap.java | 48 +
.../PlatformAbstractConfigurationClosure.java | 61 +
.../platform/PlatformAbstractPredicate.java | 67 +
.../platform/PlatformAbstractTarget.java | 320 ++
.../processors/platform/PlatformBootstrap.java | 35 +
.../platform/PlatformBootstrapFactory.java | 37 +
.../platform/PlatformConfiguration.java | 25 -
.../platform/PlatformConfigurationEx.java | 48 +
.../platform/PlatformContextImpl.java | 622 ++++
.../processors/platform/PlatformIgnition.java | 189 +
.../platform/PlatformNoopProcessor.java | 6 +
.../processors/platform/PlatformProcessor.java | 11 +
.../platform/PlatformProcessorImpl.java | 372 ++
.../platform/cache/PlatformCache.java | 1090 ++++++
.../cache/PlatformCacheEntryFilterImpl.java | 106 +
.../cache/PlatformCacheEntryProcessorImpl.java | 220 ++
.../platform/cache/PlatformCacheIterator.java | 72 +
.../PlatformCachePartialUpdateException.java | 59 +
.../cache/affinity/PlatformAffinity.java | 296 ++
.../query/PlatformAbstractQueryCursor.java | 192 +
.../query/PlatformContinuousQueryImpl.java | 235 ++
.../PlatformContinuousQueryRemoteFilter.java | 188 +
.../cache/query/PlatformFieldsQueryCursor.java | 49 +
.../cache/query/PlatformQueryCursor.java | 45 +
.../cache/store/PlatformCacheStoreCallback.java | 61 +
.../platform/cluster/PlatformClusterGroup.java | 335 ++
.../cluster/PlatformClusterNodeFilterImpl.java | 78 +
.../platform/compute/PlatformAbstractJob.java | 156 +
.../platform/compute/PlatformAbstractTask.java | 206 ++
.../PlatformBalancingMultiClosureTask.java | 83 +
...tformBalancingSingleClosureAffinityTask.java | 88 +
.../PlatformBalancingSingleClosureTask.java | 81 +
.../PlatformBroadcastingMultiClosureTask.java | 87 +
.../PlatformBroadcastingSingleClosureTask.java | 84 +
.../platform/compute/PlatformClosureJob.java | 104 +
.../platform/compute/PlatformCompute.java | 332 ++
.../platform/compute/PlatformFullJob.java | 220 ++
.../platform/compute/PlatformFullTask.java | 192 +
.../platform/cpp/PlatformCppBootstrap.java | 31 +
.../cpp/PlatformCppBootstrapFactory.java | 39 +
.../cpp/PlatformCppConfigurationClosure.java | 99 +
.../cpp/PlatformCppConfigurationEx.java | 82 +
.../datastreamer/PlatformDataStreamer.java | 226 ++
.../PlatformStreamReceiverImpl.java | 119 +
.../datastructures/PlatformAtomicLong.java | 149 +
.../dotnet/PlatformDotNetBootstrap.java | 31 +
.../dotnet/PlatformDotNetBootstrapFactory.java | 39 +
.../dotnet/PlatformDotNetCacheStore.java | 497 +++
.../dotnet/PlatformDotNetConfiguration.java | 119 -
.../PlatformDotNetConfigurationClosure.java | 255 ++
.../dotnet/PlatformDotNetConfigurationEx.java | 91 +
.../PlatformDotNetPortableConfiguration.java | 228 --
...PlatformDotNetPortableTypeConfiguration.java | 248 --
.../platform/dotnet/PlatformDotNetService.java | 27 +
.../dotnet/PlatformDotNetServiceImpl.java | 47 +
.../events/PlatformEventFilterListenerImpl.java | 163 +
.../platform/events/PlatformEvents.java | 396 +++
.../lifecycle/PlatformLifecycleBean.java | 75 +
.../platform/memory/PlatformAbstractMemory.java | 121 +
.../PlatformBigEndianInputStreamImpl.java | 126 +
.../PlatformBigEndianOutputStreamImpl.java | 161 +
.../platform/memory/PlatformExternalMemory.java | 55 +
.../memory/PlatformInputStreamImpl.java | 331 ++
.../memory/PlatformMemoryManagerImpl.java | 85 +
.../platform/memory/PlatformMemoryPool.java | 140 +
.../platform/memory/PlatformMemoryUtils.java | 467 +++
.../memory/PlatformOutputStreamImpl.java | 267 ++
.../platform/memory/PlatformPooledMemory.java | 64 +
.../platform/memory/PlatformUnpooledMemory.java | 51 +
.../messaging/PlatformMessageFilterImpl.java | 110 +
.../messaging/PlatformMessageLocalFilter.java | 102 +
.../platform/messaging/PlatformMessaging.java | 166 +
.../services/PlatformAbstractService.java | 230 ++
.../platform/services/PlatformServices.java | 275 ++
.../transactions/PlatformTransactions.java | 259 ++
.../platform/utils/PlatformFutureUtils.java | 397 +++
.../platform/utils/PlatformReaderBiClosure.java | 34 +
.../platform/utils/PlatformReaderClosure.java | 34 +
.../platform/utils/PlatformUtils.java | 812 +++++
.../platform/utils/PlatformWriterBiClosure.java | 34 +
.../platform/utils/PlatformWriterClosure.java | 33 +
.../marshaller/portable/PortableMarshaller.java | 32 -
.../platform/cpp/PlatformCppConfiguration.java | 47 +
.../ignite/platform/cpp/package-info.java | 22 +
.../dotnet/PlatformDotNetCacheStoreFactory.java | 139 +
.../dotnet/PlatformDotNetConfiguration.java | 97 +
.../dotnet/PlatformDotNetLifecycleBean.java | 109 +
.../PlatformDotNetPortableConfiguration.java | 196 ++
...PlatformDotNetPortableTypeConfiguration.java | 214 ++
.../ignite/platform/dotnet/package-info.java | 22 +
.../apache/ignite/platform/package-info.java | 22 +
.../portable/PortableProtocolVersion.java | 41 -
.../ignite/spi/deployment/DeploymentSpi.java | 8 +-
.../resources/META-INF/classnames.properties | 1 -
modules/core/src/test/config/tests.properties | 3 +
.../GridDiscoveryManagerAttributesSelfTest.java | 50 -
.../cache/CacheAffinityCallSelfTest.java | 4 +-
.../cache/GridCacheClearSelfTest.java | 308 ++
.../CacheAbstractRestartSelfTest.java | 247 ++
...NearDisabledAtomicInvokeRestartSelfTest.java | 179 +
...abledTransactionalInvokeRestartSelfTest.java | 173 +
...edTransactionalWriteReadRestartSelfTest.java | 124 +
...niteCacheClientNodeChangingTopologyTest.java | 4 +-
.../dht/GridCacheDhtEntrySelfTest.java | 2 +-
.../dht/GridCacheTxNodeFailureSelfTest.java | 2 +
...gniteAtomicLongChangingTopologySelfTest.java | 4 +-
...ledFairAffinityMultiNodeFullApiSelfTest.java | 8 +-
...icOffHeapTieredMultiNodeFullApiSelfTest.java | 7 +-
.../replicated/GridReplicatedTxPreloadTest.java | 7 +-
.../platform/PlatformComputeBroadcastTask.java | 73 +
.../platform/PlatformComputeDecimalTask.java | 106 +
.../platform/PlatformComputeEchoTask.java | 188 +
.../ignite/platform/PlatformComputeEnum.java | 28 +
.../platform/PlatformComputeJavaPortable.java | 39 +
.../platform/PlatformComputePortable.java | 42 +
.../PlatformComputePortableArgTask.java | 119 +
.../platform/PlatformEventsWriteEventTask.java | 146 +
.../ignite/platform/PlatformMaxMemoryTask.java | 57 +
.../ignite/platform/PlatformMinMemoryTask.java | 57 +
.../lifecycle/PlatformJavaLifecycleBean.java | 47 +
.../lifecycle/PlatformJavaLifecycleTask.java | 65 +
.../IgniteCacheFullApiSelfTestSuite.java | 8 +-
.../IgniteCacheLoadConsistencyTestSuite.java | 42 +
modules/extdata/uri/pom.xml | 11 +-
.../CacheHibernateBlobStoreSelfTest.java | 6 +-
.../cache/SqlFieldsQuerySelfTest.java | 172 +
.../IgniteCacheQuerySelfTestSuite.java | 2 +
modules/platform/licenses/apache-2.0.txt | 202 --
modules/platform/pom.xml | 80 -
modules/platform/src/main/cpp/README.txt | 103 -
.../platform/src/main/cpp/common/Makefile.am | 45 -
.../platform/src/main/cpp/common/configure.ac | 62 -
.../src/main/cpp/common/ignite-common.pc.in | 9 -
.../src/main/cpp/common/include/Makefile.am | 22 -
.../common/include/ignite/common/concurrent.h | 210 --
.../cpp/common/include/ignite/common/exports.h | 145 -
.../cpp/common/include/ignite/common/java.h | 652 ----
.../cpp/common/os/linux/include/Makefile.am | 21 -
.../os/linux/include/ignite/common/common.h | 81 -
.../linux/include/ignite/common/concurrent_os.h | 394 ---
.../src/main/cpp/common/os/linux/src/common.cpp | 59 -
.../cpp/common/os/linux/src/concurrent_os.cpp | 175 -
.../os/win/include/ignite/common/common.h | 56 -
.../win/include/ignite/common/concurrent_os.h | 406 ---
.../src/main/cpp/common/os/win/src/common.cpp | 65 -
.../cpp/common/os/win/src/concurrent_os.cpp | 151 -
.../src/main/cpp/common/project/README.TXT | 1 -
.../src/main/cpp/common/project/vs/README.TXT | 1 -
.../main/cpp/common/project/vs/common.vcxproj | 202 --
.../common/project/vs/common.vcxproj.filters | 54 -
.../src/main/cpp/common/project/vs/module.def | 99 -
.../src/main/cpp/common/project/vs/targetver.h | 25 -
.../src/main/cpp/common/src/concurrent.cpp | 94 -
.../src/main/cpp/common/src/exports.cpp | 413 ---
.../platform/src/main/cpp/common/src/java.cpp | 2205 ------------
.../platform/src/main/cpp/core-test/Makefile.am | 49 -
.../main/cpp/core-test/config/cache-query.xml | 91 -
.../main/cpp/core-test/config/cache-test.xml | 129 -
.../src/main/cpp/core-test/configure.ac | 62 -
.../src/main/cpp/core-test/include/Makefile.am | 22 -
.../include/ignite/portable_test_defs.h | 320 --
.../include/ignite/portable_test_utils.h | 516 ---
.../cpp/core-test/include/teamcity_messages.h | 55 -
.../src/main/cpp/core-test/project/README.TXT | 1 -
.../main/cpp/core-test/project/vs/README.TXT | 1 -
.../cpp/core-test/project/vs/core-test.vcxproj | 174 -
.../project/vs/core-test.vcxproj.filters | 68 -
.../main/cpp/core-test/src/cache_query_test.cpp | 656 ----
.../src/main/cpp/core-test/src/cache_test.cpp | 486 ---
.../main/cpp/core-test/src/concurrent_test.cpp | 186 -
.../cpp/core-test/src/handle_registry_test.cpp | 176 -
.../main/cpp/core-test/src/ignition_test.cpp | 102 -
.../src/portable_reader_writer_raw_test.cpp | 1532 --------
.../src/portable_reader_writer_test.cpp | 1952 -----------
.../cpp/core-test/src/portable_session_test.cpp | 257 --
.../cpp/core-test/src/portable_test_defs.cpp | 65 -
.../main/cpp/core-test/src/teamcity_boost.cpp | 159 -
.../cpp/core-test/src/teamcity_messages.cpp | 150 -
modules/platform/src/main/cpp/core/Makefile.am | 66 -
modules/platform/src/main/cpp/core/configure.ac | 62 -
modules/platform/src/main/cpp/core/ignite.pc.in | 9 -
.../src/main/cpp/core/include/Makefile.am | 61 -
.../main/cpp/core/include/ignite/cache/cache.h | 1153 ------
.../cpp/core/include/ignite/cache/cache_entry.h | 118 -
.../core/include/ignite/cache/cache_peek_mode.h | 71 -
.../cpp/core/include/ignite/cache/query/query.h | 27 -
.../include/ignite/cache/query/query_argument.h | 125 -
.../include/ignite/cache/query/query_cursor.h | 191 -
.../include/ignite/cache/query/query_scan.h | 151 -
.../core/include/ignite/cache/query/query_sql.h | 253 --
.../include/ignite/cache/query/query_text.h | 159 -
.../src/main/cpp/core/include/ignite/guid.h | 112 -
.../src/main/cpp/core/include/ignite/ignite.h | 154 -
.../core/include/ignite/ignite_configuration.h | 92 -
.../main/cpp/core/include/ignite/ignite_error.h | 260 --
.../src/main/cpp/core/include/ignite/ignition.h | 195 --
.../core/include/ignite/impl/cache/cache_impl.h | 418 ---
.../ignite/impl/cache/query/query_impl.h | 115 -
.../core/include/ignite/impl/handle_registry.h | 202 --
.../include/ignite/impl/ignite_environment.h | 130 -
.../cpp/core/include/ignite/impl/ignite_impl.h | 146 -
.../core/include/ignite/impl/interop/interop.h | 25 -
.../ignite/impl/interop/interop_input_stream.h | 234 --
.../ignite/impl/interop/interop_memory.h | 280 --
.../ignite/impl/interop/interop_output_stream.h | 234 --
.../cpp/core/include/ignite/impl/operations.h | 452 ---
.../ignite/impl/portable/portable_common.h | 155 -
.../ignite/impl/portable/portable_id_resolver.h | 106 -
.../impl/portable/portable_metadata_handler.h | 102 -
.../impl/portable/portable_metadata_manager.h | 120 -
.../impl/portable/portable_metadata_snapshot.h | 122 -
.../impl/portable/portable_metadata_updater.h | 53 -
.../portable/portable_metadata_updater_impl.h | 65 -
.../ignite/impl/portable/portable_reader_impl.h | 1142 ------
.../ignite/impl/portable/portable_utils.h | 344 --
.../ignite/impl/portable/portable_writer_impl.h | 860 -----
.../cpp/core/include/ignite/portable/portable.h | 29 -
.../include/ignite/portable/portable_consts.h | 106 -
.../ignite/portable/portable_containers.h | 525 ---
.../ignite/portable/portable_raw_reader.h | 324 --
.../ignite/portable/portable_raw_writer.h | 300 --
.../include/ignite/portable/portable_reader.h | 355 --
.../include/ignite/portable/portable_type.h | 293 --
.../include/ignite/portable/portable_writer.h | 335 --
.../main/cpp/core/os/linux/include/Makefile.am | 20 -
.../core/os/linux/include/ignite/impl/utils.h | 155 -
.../main/cpp/core/os/linux/src/impl/utils.cpp | 439 ---
.../cpp/core/os/win/include/ignite/impl/utils.h | 155 -
.../src/main/cpp/core/os/win/src/impl/utils.cpp | 453 ---
.../src/main/cpp/core/project/README.TXT | 1 -
.../src/main/cpp/core/project/vs/README.TXT | 1 -
.../src/main/cpp/core/project/vs/core.vcxproj | 272 --
.../cpp/core/project/vs/core.vcxproj.filters | 246 --
modules/platform/src/main/cpp/core/src/guid.cpp | 65 -
.../platform/src/main/cpp/core/src/ignite.cpp | 43 -
.../src/main/cpp/core/src/ignite_error.cpp | 222 --
.../platform/src/main/cpp/core/src/ignition.cpp | 468 ---
.../main/cpp/core/src/impl/cache/cache_impl.cpp | 388 ---
.../core/src/impl/cache/query/query_impl.cpp | 193 -
.../main/cpp/core/src/impl/handle_registry.cpp | 234 --
.../cpp/core/src/impl/ignite_environment.cpp | 167 -
.../src/main/cpp/core/src/impl/ignite_impl.cpp | 42 -
.../src/impl/interop/interop_input_stream.cpp | 215 --
.../core/src/impl/interop/interop_memory.cpp | 182 -
.../src/impl/interop/interop_output_stream.cpp | 215 --
.../impl/portable/portable_metadata_handler.cpp | 78 -
.../impl/portable/portable_metadata_manager.cpp | 201 --
.../portable/portable_metadata_snapshot.cpp | 70 -
.../impl/portable/portable_metadata_updater.cpp | 32 -
.../portable/portable_metadata_updater_impl.cpp | 94 -
.../src/impl/portable/portable_reader_impl.cpp | 683 ----
.../core/src/impl/portable/portable_utils.cpp | 214 --
.../src/impl/portable/portable_writer_impl.cpp | 600 ----
.../core/src/portable/portable_containers.cpp | 76 -
.../core/src/portable/portable_raw_reader.cpp | 135 -
.../core/src/portable/portable_raw_writer.cpp | 147 -
.../cpp/core/src/portable/portable_reader.cpp | 142 -
.../cpp/core/src/portable/portable_type.cpp | 51 -
.../cpp/core/src/portable/portable_writer.cpp | 154 -
.../platform/src/main/cpp/project/vs/ignite.sln | 48 -
.../Apache.Ignite.Core.csproj | 376 --
.../Cache/CacheAtomicUpdateTimeoutException.cs | 67 -
.../Cache/CacheEntryProcessorException.cs | 79 -
.../Apache.Ignite.Core/Cache/CacheException.cs | 68 -
.../Cache/CachePartialUpdateException.cs | 119 -
.../Apache.Ignite.Core/Cache/CachePeekMode.cs | 68 -
.../Cache/Event/CacheEntryEventType.cs | 41 -
.../Cache/Event/ICacheEntryEvent.cs | 40 -
.../Cache/Event/ICacheEntryEventFilter.cs | 31 -
.../Cache/Event/ICacheEntryEventListener.cs | 33 -
.../Cache/Expiry/ExpiryPolicy.cs | 89 -
.../Cache/Expiry/IExpiryPolicy.cs | 59 -
.../dotnet/Apache.Ignite.Core/Cache/ICache.cs | 542 ---
.../Apache.Ignite.Core/Cache/ICacheAffinity.cs | 161 -
.../Apache.Ignite.Core/Cache/ICacheEntry.cs | 37 -
.../Cache/ICacheEntryFilter.cs | 34 -
.../Cache/ICacheEntryProcessor.cs | 45 -
.../Cache/ICacheEntryProcessorResult.cs | 40 -
.../Apache.Ignite.Core/Cache/ICacheLock.cs | 58 -
.../Apache.Ignite.Core/Cache/ICacheMetrics.cs | 486 ---
.../Cache/IMutableCacheEntry.cs | 47 -
.../Cache/Query/Continuous/ContinuousQuery.cs | 170 -
.../Query/Continuous/IContinuousQueryHandle.cs | 51 -
.../Cache/Query/IQueryCursor.cs | 40 -
.../Apache.Ignite.Core/Cache/Query/QueryBase.cs | 82 -
.../Apache.Ignite.Core/Cache/Query/ScanQuery.cs | 77 -
.../Cache/Query/SqlFieldsQuery.cs | 81 -
.../Apache.Ignite.Core/Cache/Query/SqlQuery.cs | 119 -
.../Apache.Ignite.Core/Cache/Query/TextQuery.cs | 104 -
.../Store/CacheParallelLoadStoreAdapter.cs | 205 --
.../Cache/Store/CacheStoreAdapter.cs | 146 -
.../Cache/Store/CacheStoreException.cs | 66 -
.../Cache/Store/ICacheStore.cs | 184 -
.../Cache/Store/ICacheStoreSession.cs | 42 -
.../Cluster/ClusterGroupEmptyException.cs | 70 -
.../Cluster/ClusterTopologyException.cs | 69 -
.../Apache.Ignite.Core/Cluster/ICluster.cs | 80 -
.../Apache.Ignite.Core/Cluster/IClusterGroup.cs | 229 --
.../Cluster/IClusterMetrics.cs | 515 ---
.../Apache.Ignite.Core/Cluster/IClusterNode.cs | 138 -
.../Cluster/IClusterNodeFilter.cs | 32 -
.../Common/AsyncSupportedAttribute.cs | 33 -
.../Apache.Ignite.Core/Common/IAsyncSupport.cs | 52 -
.../dotnet/Apache.Ignite.Core/Common/IFuture.cs | 115 -
.../Common/IgniteException.cs | 66 -
.../Apache.Ignite.Core/Common/IgniteGuid.cs | 138 -
.../ComputeExecutionRejectedException.cs | 69 -
.../Compute/ComputeJobAdapter.cs | 122 -
.../Compute/ComputeJobFailoverException.cs | 72 -
.../Compute/ComputeJobResultPolicy.cs | 45 -
.../Compute/ComputeTaskAdapter.cs | 93 -
.../Compute/ComputeTaskCancelledException.cs | 69 -
.../ComputeTaskNoResultCacheAttribute.cs | 35 -
.../Compute/ComputeTaskSplitAdapter.cs | 95 -
.../Compute/ComputeTaskTimeoutException.cs | 67 -
.../Compute/ComputeUserUndeclaredException.cs | 70 -
.../Apache.Ignite.Core/Compute/ICompute.cs | 274 --
.../Apache.Ignite.Core/Compute/IComputeFunc.cs | 55 -
.../Apache.Ignite.Core/Compute/IComputeJob.cs | 58 -
.../Compute/IComputeJobResult.cs | 73 -
.../Compute/IComputeReducer.cs | 39 -
.../Apache.Ignite.Core/Compute/IComputeTask.cs | 132 -
.../Datastream/IDataStreamer.cs | 206 --
.../Datastream/IStreamReceiver.cs | 38 -
.../Datastream/StreamTransformer.cs | 73 -
.../Datastream/StreamVisitor.cs | 55 -
.../Apache.Ignite.Core/Events/CacheEvent.cs | 176 -
.../Events/CacheQueryExecutedEvent.cs | 97 -
.../Events/CacheQueryReadEvent.cs | 134 -
.../Events/CacheRebalancingEvent.cs | 98 -
.../Events/CheckpointEvent.cs | 50 -
.../Apache.Ignite.Core/Events/DiscoveryEvent.cs | 80 -
.../Apache.Ignite.Core/Events/EventBase.cs | 160 -
.../Apache.Ignite.Core/Events/EventReader.cs | 72 -
.../Apache.Ignite.Core/Events/EventType.cs | 514 ---
.../dotnet/Apache.Ignite.Core/Events/IEvent.cs | 74 -
.../Apache.Ignite.Core/Events/IEventFilter.cs | 36 -
.../dotnet/Apache.Ignite.Core/Events/IEvents.cs | 182 -
.../Apache.Ignite.Core/Events/JobEvent.cs | 100 -
.../Apache.Ignite.Core/Events/SwapSpaceEvent.cs | 50 -
.../Apache.Ignite.Core/Events/TaskEvent.cs | 91 -
.../main/dotnet/Apache.Ignite.Core/IIgnite.cs | 168 -
.../Apache.Ignite.Core/IgniteConfiguration.cs | 140 -
.../main/dotnet/Apache.Ignite.Core/Ignition.cs | 657 ----
.../Impl/Cache/CacheAffinityImpl.cs | 275 --
.../Apache.Ignite.Core/Impl/Cache/CacheEntry.cs | 126 -
.../Impl/Cache/CacheEntryFilterHolder.cs | 147 -
.../Impl/Cache/CacheEntryProcessorHolder.cs | 145 -
.../Impl/Cache/CacheEntryProcessorResult.cs | 65 -
.../Cache/CacheEntryProcessorResultHolder.cs | 127 -
.../Impl/Cache/CacheEnumerable.cs | 82 -
.../Impl/Cache/CacheEnumerator.cs | 117 -
.../Impl/Cache/CacheEnumeratorProxy.cs | 156 -
.../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 940 -----
.../Apache.Ignite.Core/Impl/Cache/CacheLock.cs | 171 -
.../Impl/Cache/CacheMetricsImpl.cs | 248 --
.../Apache.Ignite.Core/Impl/Cache/CacheOp.cs | 63 -
.../Impl/Cache/CacheProxyImpl.cs | 499 ---
.../Impl/Cache/Event/CacheEntryCreateEvent.cs | 74 -
.../Impl/Cache/Event/CacheEntryRemoveEvent.cs | 74 -
.../Impl/Cache/Event/CacheEntryUpdateEvent.cs | 79 -
.../Impl/Cache/MutableCacheEntry.cs | 163 -
.../Impl/Cache/Query/AbstractQueryCursor.cs | 264 --
.../Query/Continuous/ContinuousQueryFilter.cs | 125 -
.../Continuous/ContinuousQueryFilterHolder.cs | 118 -
.../Continuous/ContinuousQueryHandleImpl.cs | 216 --
.../Query/Continuous/ContinuousQueryUtils.cs | 115 -
.../Impl/Cache/Query/FieldsQueryCursor.cs | 54 -
.../Impl/Cache/Query/QueryCursor.cs | 50 -
.../Impl/Cache/Store/CacheStore.cs | 263 --
.../Impl/Cache/Store/CacheStoreSession.cs | 53 -
.../Impl/Cache/Store/CacheStoreSessionProxy.cs | 63 -
.../Impl/Cluster/ClusterGroupImpl.cs | 577 ---
.../Impl/Cluster/ClusterMetricsImpl.cs | 292 --
.../Impl/Cluster/ClusterNodeImpl.cs | 221 --
.../Impl/Cluster/IClusterGroupEx.cs | 35 -
.../Impl/Collections/CollectionExtensions.cs | 45 -
.../Impl/Collections/MultiValueDictionary.cs | 143 -
.../Impl/Collections/ReadOnlyCollection.cs | 102 -
.../Impl/Collections/ReadOnlyDictionary.cs | 149 -
.../Impl/Common/AsyncResult.cs | 71 -
.../Impl/Common/CompletedAsyncResult.cs | 70 -
.../Common/CopyOnWriteConcurrentDictionary.cs | 70 -
.../Impl/Common/DelegateConverter.cs | 253 --
.../Impl/Common/DelegateTypeDescriptor.cs | 314 --
.../Apache.Ignite.Core/Impl/Common/Future.cs | 286 --
.../Impl/Common/FutureConverter.cs | 62 -
.../Impl/Common/FutureType.cs | 52 -
.../Impl/Common/IFutureConverter.cs | 34 -
.../Impl/Common/IFutureInternal.cs | 46 -
.../Impl/Common/IgniteArgumentCheck.cs | 76 -
.../Impl/Common/LoadedAssembliesResolver.cs | 96 -
.../Impl/Common/PortableResultWrapper.cs | 68 -
.../Impl/Common/TypeCaster.cs | 72 -
.../Closure/ComputeAbstractClosureTask.cs | 101 -
.../Impl/Compute/Closure/ComputeActionJob.cs | 83 -
.../Impl/Compute/Closure/ComputeFuncJob.cs | 89 -
.../Compute/Closure/ComputeMultiClosureTask.cs | 56 -
.../Impl/Compute/Closure/ComputeOutFuncJob.cs | 76 -
.../Closure/ComputeReducingClosureTask.cs | 61 -
.../Compute/Closure/ComputeSingleClosureTask.cs | 48 -
.../Compute/Closure/IComputeResourceInjector.cs | 31 -
.../Apache.Ignite.Core/Impl/Compute/Compute.cs | 213 --
.../Impl/Compute/ComputeAsync.cs | 261 --
.../Impl/Compute/ComputeFunc.cs | 119 -
.../Impl/Compute/ComputeImpl.cs | 645 ----
.../Impl/Compute/ComputeJob.cs | 163 -
.../Impl/Compute/ComputeJobHolder.cs | 246 --
.../Compute/ComputeJobResultGenericWrapper.cs | 70 -
.../Impl/Compute/ComputeJobResultImpl.cs | 96 -
.../Impl/Compute/ComputeOutFunc.cs | 123 -
.../Impl/Compute/ComputeTaskHolder.cs | 484 ---
.../Impl/Datastream/DataStreamerBatch.cs | 269 --
.../Impl/Datastream/DataStreamerEntry.cs | 64 -
.../Impl/Datastream/DataStreamerImpl.cs | 832 -----
.../Impl/Datastream/DataStreamerRemoveEntry.cs | 48 -
.../Impl/Datastream/StreamReceiverHolder.cs | 144 -
.../Apache.Ignite.Core/Impl/Events/Events.cs | 498 ---
.../Impl/Events/EventsAsync.cs | 158 -
.../Impl/Events/RemoteListenEventFilter.cs | 85 -
.../Apache.Ignite.Core/Impl/ExceptionUtils.cs | 204 --
.../Apache.Ignite.Core/Impl/Handle/Handle.cs | 69 -
.../Impl/Handle/HandleRegistry.cs | 340 --
.../Apache.Ignite.Core/Impl/Handle/IHandle.cs | 35 -
.../Apache.Ignite.Core/Impl/IInteropCallback.cs | 34 -
.../dotnet/Apache.Ignite.Core/Impl/Ignite.cs | 549 ---
.../Impl/IgniteConfigurationEx.cs | 57 -
.../Apache.Ignite.Core/Impl/IgniteManager.cs | 490 ---
.../Apache.Ignite.Core/Impl/IgniteProxy.cs | 351 --
.../Apache.Ignite.Core/Impl/IgniteUtils.cs | 438 ---
.../Impl/Interop/InteropDotNetConfiguration.cs | 62 -
.../InteropDotNetPortableConfiguration.cs | 127 -
.../InteropDotNetPortableTypeConfiguration.cs | 151 -
.../Impl/InteropExceptionHolder.cs | 85 -
.../Impl/LifecycleBeanHolder.cs | 66 -
.../Impl/Memory/IPlatformMemory.cs | 65 -
.../Impl/Memory/InteropExternalMemory.cs | 46 -
.../Impl/Memory/InteropMemoryUtils.cs | 38 -
.../Memory/PlatformBigEndianMemoryStream.cs | 483 ---
.../Impl/Memory/PlatformMemory.cs | 78 -
.../Impl/Memory/PlatformMemoryManager.cs | 107 -
.../Impl/Memory/PlatformMemoryPool.cs | 106 -
.../Impl/Memory/PlatformMemoryStream.cs | 677 ----
.../Impl/Memory/PlatformMemoryUtils.cs | 463 ---
.../Impl/Memory/PlatformPooledMemory.cs | 70 -
.../Impl/Memory/PlatformRawMemory.cs | 89 -
.../Impl/Memory/PlatformUnpooledMemory.cs | 52 -
.../Impl/Messaging/MessageFilterHolder.cs | 179 -
.../Impl/Messaging/Messaging.cs | 262 --
.../Impl/Messaging/MessagingAsync.cs | 68 -
.../Apache.Ignite.Core/Impl/NativeMethods.cs | 47 -
.../Apache.Ignite.Core/Impl/PlatformTarget.cs | 715 ----
.../Portable/IPortableSystemTypeSerializer.cs | 34 -
.../Impl/Portable/IPortableTypeDescriptor.cs | 124 -
.../Impl/Portable/IPortableWriteAware.cs | 34 -
.../Impl/Portable/Io/IPortableStream.cs | 320 --
.../Impl/Portable/Io/PortableAbstractStream.cs | 1298 -------
.../Impl/Portable/Io/PortableHeapStream.cs | 447 ---
.../Impl/Portable/Io/PortableStreamAdapter.cs | 114 -
.../Metadata/IPortableMetadataHandler.cs | 41 -
.../Metadata/PortableHashsetMetadataHandler.cs | 69 -
.../Portable/Metadata/PortableMetadataHolder.cs | 149 -
.../Portable/Metadata/PortableMetadataImpl.cs | 200 --
.../Impl/Portable/PortableBuilderField.cs | 73 -
.../Impl/Portable/PortableBuilderImpl.cs | 926 -----
.../Impl/Portable/PortableCollectionInfo.cs | 251 --
.../Impl/Portable/PortableFullTypeDescriptor.cs | 203 --
.../Impl/Portable/PortableHandleDictionary.cs | 187 -
.../Portable/PortableMarshalAwareSerializer.cs | 45 -
.../Impl/Portable/PortableMarshaller.cs | 603 ----
.../Impl/Portable/PortableMode.cs | 40 -
.../Impl/Portable/PortableObjectHandle.cs | 59 -
.../PortableOrSerializableObjectHolder.cs | 66 -
.../Portable/PortableReaderHandleDictionary.cs | 42 -
.../Impl/Portable/PortableReaderImpl.cs | 1016 ------
.../Impl/Portable/PortableReflectiveRoutines.cs | 483 ---
.../Portable/PortableReflectiveSerializer.cs | 218 --
.../Portable/PortableSurrogateTypeDescriptor.cs | 133 -
.../Impl/Portable/PortableSystemHandlers.cs | 1336 -------
.../Portable/PortableSystemTypeSerializer.cs | 62 -
.../Impl/Portable/PortableUserObject.cs | 385 --
.../Impl/Portable/PortableUtils.cs | 2067 -----------
.../Impl/Portable/PortableWriterImpl.cs | 1305 -------
.../Impl/Portable/PortablesImpl.cs | 206 --
.../Impl/Portable/SerializableObjectHolder.cs | 66 -
.../Impl/Portable/TypeResolver.cs | 227 --
.../Impl/Resource/IResourceInjector.cs | 27 -
.../Impl/Resource/ResourceFieldInjector.cs | 47 -
.../Impl/Resource/ResourceMethodInjector.cs | 48 -
.../Impl/Resource/ResourceProcessor.cs | 105 -
.../Impl/Resource/ResourcePropertyInjector.cs | 47 -
.../Impl/Resource/ResourceTypeDescriptor.cs | 291 --
.../Impl/Services/ServiceContext.cs | 60 -
.../Impl/Services/ServiceDescriptor.cs | 106 -
.../Impl/Services/ServiceProxy.cs | 71 -
.../Impl/Services/ServiceProxyInvoker.cs | 136 -
.../Impl/Services/ServiceProxySerializer.cs | 140 -
.../Impl/Services/Services.cs | 316 --
.../Impl/Services/ServicesAsync.cs | 89 -
.../Impl/Transactions/AsyncTransaction.cs | 78 -
.../Impl/Transactions/Transaction.cs | 155 -
.../Impl/Transactions/TransactionImpl.cs | 489 ---
.../Impl/Transactions/TransactionMetricsImpl.cs | 62 -
.../Impl/Transactions/TransactionsImpl.cs | 201 --
.../Impl/Unmanaged/IUnmanagedTarget.cs | 42 -
.../Impl/Unmanaged/UnmanagedCallbackHandlers.cs | 99 -
.../Impl/Unmanaged/UnmanagedCallbacks.cs | 1154 ------
.../Impl/Unmanaged/UnmanagedContext.cs | 53 -
.../Unmanaged/UnmanagedNonReleaseableTarget.cs | 68 -
.../Impl/Unmanaged/UnmanagedTarget.cs | 77 -
.../Impl/Unmanaged/UnmanagedUtils.cs | 1263 -------
.../Lifecycle/ILifecycleBean.cs | 64 -
.../Lifecycle/LifecycleEventType.cs | 49 -
.../Messaging/IMessageFilter.cs | 35 -
.../Apache.Ignite.Core/Messaging/IMessaging.cs | 105 -
.../Portable/IPortableBuilder.cs | 78 -
.../Portable/IPortableIdMapper.cs | 40 -
.../Portable/IPortableMarshalAware.cs | 39 -
.../Portable/IPortableMetadata.cs | 61 -
.../Portable/IPortableNameMapper.cs | 39 -
.../Portable/IPortableObject.cs | 44 -
.../Portable/IPortableRawReader.cs | 264 --
.../Portable/IPortableRawWriter.cs | 221 --
.../Portable/IPortableReader.cs | 340 --
.../Portable/IPortableSerializer.cs | 39 -
.../Portable/IPortableWriter.cs | 259 --
.../Apache.Ignite.Core/Portable/IPortables.cs | 120 -
.../Portable/PortableConfiguration.cs | 122 -
.../Portable/PortableException.cs | 64 -
.../Portable/PortableTypeConfiguration.cs | 162 -
.../Portable/PortableTypeNames.cs | 115 -
.../Properties/AssemblyInfo.cs | 46 -
.../Resource/InstanceResourceAttribute.cs | 35 -
.../Resource/StoreSessionResourceAttribute.cs | 32 -
.../Apache.Ignite.Core/Services/IService.cs | 51 -
.../Services/IServiceContext.cs | 69 -
.../Services/IServiceDescriptor.cs | 96 -
.../Apache.Ignite.Core/Services/IServices.cs | 181 -
.../Services/ServiceConfiguration.cs | 62 -
.../Services/ServiceInvocationException.cs | 101 -
.../Transactions/ITransaction.cs | 230 --
.../Transactions/ITransactionMetrics.cs | 47 -
.../Transactions/ITransactions.cs | 73 -
.../Transactions/TransactionConcurrency.cs | 36 -
.../TransactionHeuristicException.cs | 72 -
.../Transactions/TransactionIsolation.cs | 41 -
.../TransactionOptimisticException.cs | 69 -
.../TransactionRollbackException.cs | 68 -
.../Transactions/TransactionState.cs | 70 -
.../Transactions/TransactionTimeoutException.cs | 69 -
.../platform/src/main/dotnet/Apache.Ignite.sln | 68 -
.../main/dotnet/Apache.Ignite.sln.DotSettings | 4 -
.../dotnet/Apache.Ignite/Apache.Ignite.csproj | 76 -
.../src/main/dotnet/Apache.Ignite/App.config | 56 -
.../Config/AppSettingsConfigurator.cs | 113 -
.../Apache.Ignite/Config/ArgsConfigurator.cs | 164 -
.../Apache.Ignite/Config/ConfigValueParser.cs | 42 -
.../Apache.Ignite/Config/IConfigurator.cs | 34 -
.../main/dotnet/Apache.Ignite/IgniteRunner.cs | 171 -
.../Apache.Ignite/Properties/AssemblyInfo.cs | 35 -
.../Apache.Ignite/Service/IgniteService.cs | 219 --
.../Apache.Ignite/Service/NativeMethods.cs | 57 -
.../Apache.Ignite/Service/ServiceDescription.cs | 32 -
...processors.platform.PlatformBootstrapFactory | 2 -
.../platform/PlatformAbstractBootstrap.java | 48 -
.../PlatformAbstractConfigurationClosure.java | 61 -
.../platform/PlatformAbstractPredicate.java | 67 -
.../platform/PlatformAbstractTarget.java | 320 --
.../processors/platform/PlatformBootstrap.java | 35 -
.../platform/PlatformBootstrapFactory.java | 37 -
.../platform/PlatformConfigurationEx.java | 48 -
.../platform/PlatformContextImpl.java | 621 ----
.../processors/platform/PlatformIgnition.java | 189 -
.../platform/PlatformProcessorImpl.java | 359 --
.../platform/cache/PlatformCache.java | 1090 ------
.../cache/PlatformCacheEntryFilterImpl.java | 106 -
.../cache/PlatformCacheEntryProcessorImpl.java | 220 --
.../platform/cache/PlatformCacheIterator.java | 72 -
.../PlatformCachePartialUpdateException.java | 59 -
.../cache/affinity/PlatformAffinity.java | 296 --
.../query/PlatformAbstractQueryCursor.java | 192 -
.../query/PlatformContinuousQueryImpl.java | 235 --
.../PlatformContinuousQueryRemoteFilter.java | 188 -
.../cache/query/PlatformFieldsQueryCursor.java | 49 -
.../cache/query/PlatformQueryCursor.java | 45 -
.../cache/store/PlatformCacheStoreCallback.java | 61 -
.../platform/cluster/PlatformClusterGroup.java | 335 --
.../cluster/PlatformClusterNodeFilterImpl.java | 78 -
.../platform/compute/PlatformAbstractJob.java | 156 -
.../platform/compute/PlatformAbstractTask.java | 206 --
.../PlatformBalancingMultiClosureTask.java | 83 -
...tformBalancingSingleClosureAffinityTask.java | 88 -
.../PlatformBalancingSingleClosureTask.java | 81 -
.../PlatformBroadcastingMultiClosureTask.java | 87 -
.../PlatformBroadcastingSingleClosureTask.java | 84 -
.../platform/compute/PlatformClosureJob.java | 104 -
.../platform/compute/PlatformCompute.java | 332 --
.../platform/compute/PlatformFullJob.java | 220 --
.../platform/compute/PlatformFullTask.java | 192 -
.../platform/cpp/PlatformCppBootstrap.java | 31 -
.../cpp/PlatformCppBootstrapFactory.java | 39 -
.../cpp/PlatformCppConfigurationClosure.java | 99 -
.../cpp/PlatformCppConfigurationEx.java | 82 -
.../datastreamer/PlatformDataStreamer.java | 226 --
.../PlatformStreamReceiverImpl.java | 119 -
.../dotnet/PlatformDotNetBootstrap.java | 31 -
.../dotnet/PlatformDotNetBootstrapFactory.java | 39 -
.../dotnet/PlatformDotNetCacheStore.java | 497 ---
.../PlatformDotNetConfigurationClosure.java | 254 --
.../dotnet/PlatformDotNetConfigurationEx.java | 90 -
.../platform/dotnet/PlatformDotNetService.java | 27 -
.../dotnet/PlatformDotNetServiceImpl.java | 47 -
.../events/PlatformEventFilterListenerImpl.java | 163 -
.../platform/events/PlatformEvents.java | 396 ---
.../lifecycle/PlatformLifecycleBean.java | 75 -
.../platform/memory/PlatformAbstractMemory.java | 121 -
.../PlatformBigEndianInputStreamImpl.java | 126 -
.../PlatformBigEndianOutputStreamImpl.java | 161 -
.../platform/memory/PlatformExternalMemory.java | 55 -
.../memory/PlatformInputStreamImpl.java | 331 --
.../memory/PlatformMemoryManagerImpl.java | 85 -
.../platform/memory/PlatformMemoryPool.java | 140 -
.../platform/memory/PlatformMemoryUtils.java | 467 ---
.../memory/PlatformOutputStreamImpl.java | 267 --
.../platform/memory/PlatformPooledMemory.java | 64 -
.../platform/memory/PlatformUnpooledMemory.java | 51 -
.../messaging/PlatformMessageFilterImpl.java | 110 -
.../messaging/PlatformMessageLocalFilter.java | 102 -
.../platform/messaging/PlatformMessaging.java | 166 -
.../services/PlatformAbstractService.java | 230 --
.../platform/services/PlatformServices.java | 275 --
.../transactions/PlatformTransactions.java | 259 --
.../platform/utils/PlatformFutureUtils.java | 397 ---
.../platform/utils/PlatformReaderBiClosure.java | 34 -
.../platform/utils/PlatformReaderClosure.java | 34 -
.../platform/utils/PlatformUtils.java | 768 ----
.../platform/utils/PlatformWriterBiClosure.java | 34 -
.../platform/utils/PlatformWriterClosure.java | 33 -
.../platform/cpp/PlatformCppConfiguration.java | 47 -
.../ignite/platform/cpp/package-info.java | 22 -
.../dotnet/PlatformDotNetCacheStoreFactory.java | 139 -
.../dotnet/PlatformDotNetLifecycleBean.java | 109 -
.../ignite/platform/dotnet/package-info.java | 22 -
.../apache/ignite/platform/package-info.java | 22 -
.../Apache.Ignite.Core.Tests.TestDll.csproj | 52 -
.../Properties/AssemblyInfo.cs | 49 -
.../TestClass.cs | 35 -
.../Apache.Ignite.Core.Tests.csproj | 225 --
.../Cache/CacheAbstractTest.cs | 3252 -----------------
.../Cache/CacheAffinityTest.cs | 139 -
.../Cache/CacheDynamicStartTest.cs | 281 --
.../Cache/CacheEntryTest.cs | 69 -
.../Cache/CacheForkedTest.cs | 81 -
.../Cache/CacheLocalAtomicTest.cs | 57 -
.../Cache/CacheLocalTest.cs | 56 -
.../CachePartitionedAtomicNearEnabledTest.cs | 50 -
.../Cache/CachePartitionedAtomicTest.cs | 50 -
.../Cache/CachePartitionedNearEnabledTest.cs | 50 -
.../Cache/CachePartitionedTest.cs | 50 -
.../Cache/CacheReplicatedAtomicTest.cs | 60 -
.../Cache/CacheReplicatedTest.cs | 60 -
.../Cache/CacheTestAsyncWrapper.cs | 436 ---
.../Cache/Query/CacheQueriesTest.cs | 928 -----
.../Continuous/ContinuousQueryAbstractTest.cs | 1181 -------
.../ContinuousQueryAtomicBackupTest.cs | 33 -
.../ContinuousQueryAtomicNoBackupTest.cs | 34 -
.../ContinuousQueryNoBackupAbstractTest.cs | 72 -
.../ContinuousQueryTransactionalBackupTest.cs | 34 -
.../ContinuousQueryTransactionalNoBackupTest.cs | 33 -
.../Cache/Store/CacheParallelLoadStoreTest.cs | 110 -
.../Cache/Store/CacheStoreSessionTest.cs | 285 --
.../Cache/Store/CacheStoreTest.cs | 510 ---
.../Cache/Store/CacheTestParallelLoadStore.cs | 91 -
.../Cache/Store/CacheTestStore.cs | 155 -
.../Compute/AbstractTaskTest.cs | 217 --
.../Compute/ClosureTaskTest.cs | 390 ---
.../Compute/ComputeApiTest.cs | 1281 -------
.../Compute/ComputeMultithreadedTest.cs | 269 --
.../Compute/FailoverTaskSelfTest.cs | 246 --
.../Forked/ForkedPortableClosureTaskTest.cs | 30 -
.../Compute/Forked/ForkedResourceTaskTest.cs | 33 -
.../Forked/ForkedSerializableClosureTaskTest.cs | 33 -
.../Compute/Forked/ForkedTaskAdapterTest.cs | 30 -
.../Compute/IgniteExceptionTaskSelfTest.cs | 753 ----
.../Compute/PortableClosureTaskTest.cs | 217 --
.../Compute/PortableTaskTest.cs | 253 --
.../Compute/ResourceTaskTest.cs | 568 ---
.../Compute/SerializableClosureTaskTest.cs | 217 --
.../Compute/TaskAdapterTest.cs | 274 --
.../Compute/TaskResultTest.cs | 437 ---
.../Config/Apache.Ignite.exe.config.test | 41 -
.../Config/Cache/Store/cache-store-session.xml | 80 -
.../Config/Compute/compute-grid1.xml | 90 -
.../Config/Compute/compute-grid2.xml | 63 -
.../Config/Compute/compute-grid3.xml | 52 -
.../Config/Compute/compute-standalone.xml | 87 -
.../Config/Dynamic/dynamic-client.xml | 51 -
.../Config/Dynamic/dynamic-data-no-cfg.xml | 47 -
.../Config/Dynamic/dynamic-data.xml | 65 -
.../Config/Lifecycle/lifecycle-beans.xml | 66 -
.../Config/Lifecycle/lifecycle-no-beans.xml | 44 -
.../Config/cache-portables.xml | 78 -
.../Config/cache-query-continuous.xml | 171 -
.../Config/cache-query.xml | 100 -
.../Config/marshaller-default.xml | 43 -
.../Config/marshaller-invalid.xml | 46 -
.../Config/marshaller-portable.xml | 43 -
.../native-client-test-cache-affinity.xml | 70 -
.../native-client-test-cache-parallel-store.xml | 69 -
.../Config/native-client-test-cache-store.xml | 125 -
.../Config/native-client-test-cache.xml | 194 --
.../Config/portable.xml | 56 -
.../Config/start-test-grid1.xml | 54 -
.../Config/start-test-grid2.xml | 45 -
.../Config/start-test-grid3.xml | 43 -
.../Dataload/DataStreamerTest.cs | 592 ----
.../Apache.Ignite.Core.Tests/EventsTest.cs | 961 -----
.../Apache.Ignite.Core.Tests/ExceptionsTest.cs | 352 --
.../Apache.Ignite.Core.Tests/ExecutableTest.cs | 443 ---
.../Apache.Ignite.Core.Tests/FutureTest.cs | 278 --
.../IgniteManagerTest.cs | 51 -
.../IgniteStartStopTest.cs | 422 ---
.../Apache.Ignite.Core.Tests/LifecycleTest.cs | 288 --
.../Apache.Ignite.Core.Tests/LoadDllTest.cs | 243 --
.../Apache.Ignite.Core.Tests/MarshallerTest.cs | 71 -
.../Memory/InteropMemoryTest.cs | 213 --
.../Apache.Ignite.Core.Tests/MessagingTest.cs | 646 ----
.../Portable/PortableApiSelfTest.cs | 1787 ----------
.../Portable/PortableSelfTest.cs | 2078 -----------
.../PortableConfigurationTest.cs | 173 -
.../Process/IIgniteProcessOutputReader.cs | 35 -
.../Process/IgniteProcess.cs | 283 --
.../Process/IgniteProcessConsoleOutputReader.cs | 40 -
.../Properties/AssemblyInfo.cs | 35 -
.../Query/ImplicitPortablePerson.cs | 46 -
.../Query/NoDefPortablePerson.cs | 35 -
.../Query/PortablePerson.cs | 69 -
.../SerializationTest.cs | 240 --
.../Services/ServiceProxyTest.cs | 741 ----
.../Services/ServicesAsyncWrapper.cs | 174 -
.../Services/ServicesTest.cs | 823 -----
.../Services/ServicesTestAsync.cs | 33 -
.../Apache.Ignite.Core.Tests/TestRunner.cs | 71 -
.../Apache.Ignite.Core.Tests/TestUtils.cs | 292 --
.../TypeResolverTest.cs | 107 -
.../platform/PlatformComputeBroadcastTask.java | 73 -
.../platform/PlatformComputeDecimalTask.java | 106 -
.../platform/PlatformComputeEchoTask.java | 188 -
.../ignite/platform/PlatformComputeEnum.java | 28 -
.../platform/PlatformComputeJavaPortable.java | 39 -
.../platform/PlatformComputePortable.java | 42 -
.../PlatformComputePortableArgTask.java | 119 -
.../platform/PlatformEventsWriteEventTask.java | 146 -
.../ignite/platform/PlatformMaxMemoryTask.java | 57 -
.../ignite/platform/PlatformMinMemoryTask.java | 57 -
.../lifecycle/PlatformJavaLifecycleBean.java | 47 -
.../lifecycle/PlatformJavaLifecycleTask.java | 65 -
modules/platforms/cpp/README.txt | 101 +
modules/platforms/cpp/common/Makefile.am | 45 +
modules/platforms/cpp/common/configure.ac | 62 +
.../platforms/cpp/common/ignite-common.pc.in | 9 +
.../platforms/cpp/common/include/Makefile.am | 22 +
.../common/include/ignite/common/concurrent.h | 237 ++
.../cpp/common/include/ignite/common/exports.h | 158 +
.../cpp/common/include/ignite/common/java.h | 679 ++++
.../cpp/common/os/linux/include/Makefile.am | 21 +
.../os/linux/include/ignite/common/common.h | 81 +
.../linux/include/ignite/common/concurrent_os.h | 394 +++
.../cpp/common/os/linux/src/common.cpp | 59 +
.../cpp/common/os/linux/src/concurrent_os.cpp | 175 +
.../os/win/include/ignite/common/common.h | 56 +
.../win/include/ignite/common/concurrent_os.h | 406 +++
.../platforms/cpp/common/os/win/src/common.cpp | 65 +
.../cpp/common/os/win/src/concurrent_os.cpp | 151 +
modules/platforms/cpp/common/project/README.TXT | 1 +
.../platforms/cpp/common/project/vs/README.TXT | 1 +
.../cpp/common/project/vs/common.vcxproj | 202 ++
.../common/project/vs/common.vcxproj.filters | 54 +
.../platforms/cpp/common/project/vs/module.def | 111 +
.../platforms/cpp/common/project/vs/targetver.h | 25 +
modules/platforms/cpp/common/src/concurrent.cpp | 94 +
modules/platforms/cpp/common/src/exports.cpp | 461 +++
modules/platforms/cpp/common/src/java.cpp | 2368 +++++++++++++
modules/platforms/cpp/core-test/Makefile.am | 49 +
.../cpp/core-test/config/cache-query.xml | 91 +
.../cpp/core-test/config/cache-test.xml | 129 +
modules/platforms/cpp/core-test/configure.ac | 62 +
.../platforms/cpp/core-test/include/Makefile.am | 22 +
.../include/ignite/portable_test_defs.h | 320 ++
.../include/ignite/portable_test_utils.h | 516 +++
.../cpp/core-test/include/teamcity_messages.h | 55 +
.../platforms/cpp/core-test/project/README.TXT | 1 +
.../cpp/core-test/project/vs/README.TXT | 1 +
.../cpp/core-test/project/vs/core-test.vcxproj | 174 +
.../project/vs/core-test.vcxproj.filters | 68 +
.../cpp/core-test/src/cache_query_test.cpp | 656 ++++
.../platforms/cpp/core-test/src/cache_test.cpp | 486 +++
.../cpp/core-test/src/concurrent_test.cpp | 186 +
.../cpp/core-test/src/handle_registry_test.cpp | 176 +
.../cpp/core-test/src/ignition_test.cpp | 102 +
.../src/portable_reader_writer_raw_test.cpp | 1593 +++++++++
.../src/portable_reader_writer_test.cpp | 2017 +++++++++++
.../cpp/core-test/src/portable_session_test.cpp | 257 ++
.../cpp/core-test/src/portable_test_defs.cpp | 65 +
.../cpp/core-test/src/teamcity_boost.cpp | 159 +
.../cpp/core-test/src/teamcity_messages.cpp | 150 +
modules/platforms/cpp/core/Makefile.am | 66 +
modules/platforms/cpp/core/configure.ac | 62 +
modules/platforms/cpp/core/ignite.pc.in | 9 +
modules/platforms/cpp/core/include/Makefile.am | 61 +
.../cpp/core/include/ignite/cache/cache.h | 1163 +++++++
.../cpp/core/include/ignite/cache/cache_entry.h | 118 +
.../core/include/ignite/cache/cache_peek_mode.h | 71 +
.../cpp/core/include/ignite/cache/query/query.h | 27 +
.../include/ignite/cache/query/query_argument.h | 125 +
.../include/ignite/cache/query/query_cursor.h | 201 ++
.../include/ignite/cache/query/query_scan.h | 151 +
.../core/include/ignite/cache/query/query_sql.h | 253 ++
.../include/ignite/cache/query/query_text.h | 160 +
.../platforms/cpp/core/include/ignite/guid.h | 112 +
.../platforms/cpp/core/include/ignite/ignite.h | 165 +
.../core/include/ignite/ignite_configuration.h | 127 +
.../cpp/core/include/ignite/ignite_error.h | 260 ++
.../cpp/core/include/ignite/ignition.h | 195 ++
.../core/include/ignite/impl/cache/cache_impl.h | 418 +++
.../ignite/impl/cache/query/query_impl.h | 115 +
.../core/include/ignite/impl/handle_registry.h | 202 ++
.../include/ignite/impl/ignite_environment.h | 130 +
.../cpp/core/include/ignite/impl/ignite_impl.h | 146 +
.../core/include/ignite/impl/interop/interop.h | 25 +
.../ignite/impl/interop/interop_input_stream.h | 234 ++
.../ignite/impl/interop/interop_memory.h | 280 ++
.../ignite/impl/interop/interop_output_stream.h | 234 ++
.../interop/interop_stream_position_guard.h | 79 +
.../cpp/core/include/ignite/impl/operations.h | 452 +++
.../ignite/impl/portable/portable_common.h | 155 +
.../ignite/impl/portable/portable_id_resolver.h | 106 +
.../impl/portable/portable_metadata_handler.h | 102 +
.../impl/portable/portable_metadata_manager.h | 120 +
.../impl/portable/portable_metadata_snapshot.h | 122 +
.../impl/portable/portable_metadata_updater.h | 53 +
.../portable/portable_metadata_updater_impl.h | 65 +
.../ignite/impl/portable/portable_reader_impl.h | 1246 +++++++
.../ignite/impl/portable/portable_utils.h | 344 ++
.../ignite/impl/portable/portable_writer_impl.h | 915 +++++
.../cpp/core/include/ignite/portable/portable.h | 29 +
.../include/ignite/portable/portable_consts.h | 106 +
.../ignite/portable/portable_containers.h | 525 +++
.../ignite/portable/portable_raw_reader.h | 350 ++
.../ignite/portable/portable_raw_writer.h | 326 ++
.../include/ignite/portable/portable_reader.h | 384 ++
.../include/ignite/portable/portable_type.h | 293 ++
.../include/ignite/portable/portable_writer.h | 362 ++
.../cpp/core/os/linux/include/Makefile.am | 20 +
.../core/os/linux/include/ignite/impl/utils.h | 155 +
.../cpp/core/os/linux/src/impl/utils.cpp | 439 +++
.../cpp/core/os/win/include/ignite/impl/utils.h | 155 +
.../cpp/core/os/win/src/impl/utils.cpp | 453 +++
modules/platforms/cpp/core/project/README.TXT | 1 +
.../platforms/cpp/core/project/vs/README.TXT | 1 +
.../platforms/cpp/core/project/vs/core.vcxproj | 273 ++
.../cpp/core/project/vs/core.vcxproj.filters | 249 ++
modules/platforms/cpp/core/src/guid.cpp | 65 +
modules/platforms/cpp/core/src/ignite.cpp | 43 +
modules/platforms/cpp/core/src/ignite_error.cpp | 222 ++
modules/platforms/cpp/core/src/ignition.cpp | 468 +++
.../cpp/core/src/impl/cache/cache_impl.cpp | 388 +++
.../core/src/impl/cache/query/query_impl.cpp | 193 +
.../cpp/core/src/impl/handle_registry.cpp | 234 ++
.../cpp/core/src/impl/ignite_environment.cpp | 167 +
.../platforms/cpp/core/src/impl/ignite_impl.cpp | 42 +
.../src/impl/interop/interop_input_stream.cpp | 215 ++
.../core/src/impl/interop/interop_memory.cpp | 182 +
.../src/impl/interop/interop_output_stream.cpp | 215 ++
.../impl/portable/portable_metadata_handler.cpp | 78 +
.../impl/portable/portable_metadata_manager.cpp | 201 ++
.../portable/portable_metadata_snapshot.cpp | 70 +
.../impl/portable/portable_metadata_updater.cpp | 32 +
.../portable/portable_metadata_updater_impl.cpp | 94 +
.../src/impl/portable/portable_reader_impl.cpp | 758 ++++
.../core/src/impl/portable/portable_utils.cpp | 214 ++
.../src/impl/portable/portable_writer_impl.cpp | 600 ++++
.../core/src/portable/portable_containers.cpp | 76 +
.../core/src/portable/portable_raw_reader.cpp | 145 +
.../core/src/portable/portable_raw_writer.cpp | 147 +
.../cpp/core/src/portable/portable_reader.cpp | 152 +
.../cpp/core/src/portable/portable_type.cpp | 51 +
.../cpp/core/src/portable/portable_writer.cpp | 154 +
modules/platforms/cpp/examples/Makefile.am | 39 +
modules/platforms/cpp/examples/README.txt | 42 +
.../cpp/examples/config/example-cache.xml | 77 +
modules/platforms/cpp/examples/configure.ac | 38 +
.../platforms/cpp/examples/include/Makefile.am | 21 +
.../examples/include/ignite/examples/address.h | 109 +
.../include/ignite/examples/organization.h | 111 +
.../cpp/examples/project/vs/ignite-examples.sln | 19 +
.../examples/project/vs/ignite-examples.vcxproj | 107 +
.../project/vs/ignite-examples.vcxproj.filters | 30 +
.../cpp/examples/src/putgetexample.cpp | 126 +
modules/platforms/cpp/project/vs/ignite.sln | 48 +
modules/platforms/cpp/project/vs/ignite.slnrel | 33 +
.../platforms/cpp/project/vs/ignite_x86.slnrel | 33 +
.../Apache.Ignite.Benchmarks.csproj | 84 +
.../dotnet/Apache.Ignite.Benchmarks/App.config | 24 +
.../Apache.Ignite.Benchmarks/BenchmarkBase.cs | 931 +++++
.../BenchmarkOperationDescriptor.cs | 68 +
.../Apache.Ignite.Benchmarks/BenchmarkRunner.cs | 94 +
.../Apache.Ignite.Benchmarks/BenchmarkState.cs | 106 +
.../Apache.Ignite.Benchmarks/BenchmarkUtils.cs | 236 ++
.../Config/benchmark.xml | 57 +
.../Interop/ClosureBenchmark.cs | 66 +
.../Interop/GetAsyncBenchmark.cs | 66 +
.../Interop/GetBenchmark.cs | 62 +
.../Interop/PlatformBenchmarkBase.cs | 122 +
.../Interop/PutAsyncBenchmark.cs | 60 +
.../Interop/PutBenchmark.cs | 58 +
.../Interop/TaskBenchmark.cs | 100 +
.../Interop/TxBenchmark.cs | 65 +
.../Apache.Ignite.Benchmarks/Model/Address.cs | 80 +
.../Apache.Ignite.Benchmarks/Model/Company.cs | 89 +
.../Model/Department.cs | 40 +
.../Apache.Ignite.Benchmarks/Model/Employee.cs | 136 +
.../Apache.Ignite.Benchmarks/Model/Sex.cs | 31 +
.../Apache.Ignite.Benchmarks/Model/TestModel.cs | 111 +
.../Portable/PortableWriteBenchmark.cs | 135 +
.../Properties/AssemblyInfo.cs | 35 +
.../Result/BenchmarkConsoleResultWriter.cs | 68 +
.../Result/BenchmarkFileResultWriter.cs | 323 ++
.../Result/IBenchmarkResultWriter.cs | 55 +
.../Apache.Ignite.Core.Tests.TestDll.csproj | 52 +
.../Properties/AssemblyInfo.cs | 49 +
.../TestClass.cs | 35 +
.../Apache.Ignite.Core.Tests.csproj | 249 ++
.../Cache/CacheAbstractTest.cs | 3285 ++++++++++++++++++
.../Cache/CacheAffinityTest.cs | 139 +
.../Cache/CacheDynamicStartTest.cs | 281 ++
.../Cache/CacheEntryTest.cs | 69 +
.../Cache/CacheForkedTest.cs | 81 +
.../Cache/CacheLocalAtomicTest.cs | 57 +
.../Cache/CacheLocalTest.cs | 56 +
.../CachePartitionedAtomicNearEnabledTest.cs | 50 +
.../Cache/CachePartitionedAtomicTest.cs | 50 +
.../Cache/CachePartitionedNearEnabledTest.cs | 50 +
.../Cache/CachePartitionedTest.cs | 50 +
.../Cache/CacheReplicatedAtomicTest.cs | 60 +
.../Cache/CacheReplicatedTest.cs | 60 +
.../Cache/CacheTestAsyncWrapper.cs | 456 +++
.../Cache/Query/CacheQueriesTest.cs | 928 +++++
.../Continuous/ContinuousQueryAbstractTest.cs | 1181 +++++++
.../ContinuousQueryAtomicBackupTest.cs | 33 +
.../ContinuousQueryAtomicNoBackupTest.cs | 34 +
.../ContinuousQueryNoBackupAbstractTest.cs | 72 +
.../ContinuousQueryTransactionalBackupTest.cs | 34 +
.../ContinuousQueryTransactionalNoBackupTest.cs | 33 +
.../Cache/Store/CacheParallelLoadStoreTest.cs | 110 +
.../Cache/Store/CacheStoreSessionTest.cs | 285 ++
.../Cache/Store/CacheStoreTest.cs | 510 +++
.../Cache/Store/CacheTestParallelLoadStore.cs | 91 +
.../Cache/Store/CacheTestStore.cs | 155 +
.../Compute/AbstractTaskTest.cs | 217 ++
.../Compute/ClosureTaskTest.cs | 390 +++
.../Compute/ComputeApiTest.cs | 1281 +++++++
.../Compute/ComputeMultithreadedTest.cs | 269 ++
.../Compute/FailoverTaskSelfTest.cs | 246 ++
.../Forked/ForkedPortableClosureTaskTest.cs | 30 +
.../Compute/Forked/ForkedResourceTaskTest.cs | 33 +
.../Forked/ForkedSerializableClosureTaskTest.cs | 33 +
.../Compute/Forked/ForkedTaskAdapterTest.cs | 30 +
.../Compute/IgniteExceptionTaskSelfTest.cs | 753 ++++
.../Compute/PortableClosureTaskTest.cs | 217 ++
.../Compute/PortableTaskTest.cs | 253 ++
.../Compute/ResourceTaskTest.cs | 568 +++
.../Compute/SerializableClosureTaskTest.cs | 217 ++
.../Compute/TaskAdapterTest.cs | 274 ++
.../Compute/TaskResultTest.cs | 437 +++
.../Config/Apache.Ignite.exe.config.test | 41 +
.../Config/Cache/Store/cache-store-session.xml | 80 +
.../Config/Compute/compute-grid1.xml | 90 +
.../Config/Compute/compute-grid2.xml | 63 +
.../Config/Compute/compute-grid3.xml | 52 +
.../Config/Compute/compute-standalone.xml | 87 +
.../Config/Dynamic/dynamic-client.xml | 51 +
.../Config/Dynamic/dynamic-data-no-cfg.xml | 47 +
.../Config/Dynamic/dynamic-data.xml | 65 +
.../Config/Lifecycle/lifecycle-beans.xml | 66 +
.../Config/Lifecycle/lifecycle-no-beans.xml | 44 +
.../Config/cache-portables.xml | 78 +
.../Config/cache-query-continuous.xml | 171 +
.../Config/cache-query.xml | 100 +
.../Config/marshaller-default.xml | 43 +
.../Config/marshaller-invalid.xml | 46 +
.../Config/marshaller-portable.xml | 43 +
.../native-client-test-cache-affinity.xml | 70 +
.../native-client-test-cache-parallel-store.xml | 69 +
.../Config/native-client-test-cache-store.xml | 125 +
.../Config/native-client-test-cache.xml | 194 ++
.../Config/portable.xml | 56 +
.../Config/start-test-grid1.xml | 54 +
.../Config/start-test-grid2.xml | 45 +
.../Config/start-test-grid3.xml | 43 +
.../DataStructures/AtomicLongTest.cs | 138 +
.../Dataload/DataStreamerTest.cs | 592 ++++
.../Apache.Ignite.Core.Tests/EventsTest.cs | 969 ++++++
.../Examples/Example.cs | 126 +
.../Examples/ExamplesTest.cs | 156 +
.../Examples/PathUtil.cs | 51 +
.../Examples/ProjectFilesTest.cs | 49 +
.../Apache.Ignite.Core.Tests/ExceptionsTest.cs | 352 ++
.../Apache.Ignite.Core.Tests/ExecutableTest.cs | 443 +++
.../Apache.Ignite.Core.Tests/FutureTest.cs | 278 ++
.../IgniteManagerTest.cs | 52 +
.../IgniteStartStopTest.cs | 426 +++
.../Apache.Ignite.Core.Tests/IgniteTestBase.cs | 200 ++
.../Apache.Ignite.Core.Tests/LifecycleTest.cs | 288 ++
.../Apache.Ignite.Core.Tests/LoadDllTest.cs | 243 ++
.../Apache.Ignite.Core.Tests/MarshallerTest.cs | 71 +
.../Memory/InteropMemoryTest.cs | 200 ++
.../Apache.Ignite.Core.Tests/MessagingTest.cs | 646 ++++
.../Portable/PortableApiSelfTest.cs | 1787 ++++++++++
.../Portable/PortableSelfTest.cs | 2072 +++++++++++
.../Portable/PortableStructureTest.cs | 261 ++
.../PortableConfigurationTest.cs | 173 +
.../Process/IIgniteProcessOutputReader.cs | 35 +
.../Process/IgniteProcess.cs | 284 ++
.../Process/IgniteProcessConsoleOutputReader.cs | 40 +
.../Properties/AssemblyInfo.cs | 35 +
.../Query/ImplicitPortablePerson.cs | 46 +
.../Query/NoDefPortablePerson.cs | 35 +
.../Query/PortablePerson.cs | 69 +
.../SerializationTest.cs | 240 ++
.../Services/ServiceProxyTest.cs | 741 ++++
.../Services/ServicesAsyncWrapper.cs | 174 +
.../Services/ServicesTest.cs | 823 +++++
.../Services/ServicesTestAsync.cs | 33 +
.../Apache.Ignite.Core.Tests/TestRunner.cs | 71 +
.../Apache.Ignite.Core.Tests/TestUtils.cs | 306 ++
.../TypeResolverTest.cs | 107 +
.../Apache.Ignite.Core.csproj | 384 ++
.../Cache/CacheAtomicUpdateTimeoutException.cs | 67 +
.../Cache/CacheEntryProcessorException.cs | 79 +
.../Apache.Ignite.Core/Cache/CacheException.cs | 68 +
.../Cache/CachePartialUpdateException.cs | 119 +
.../Apache.Ignite.Core/Cache/CachePeekMode.cs | 68 +
.../Apache.Ignite.Core/Cache/CacheResult.cs | 98 +
.../Cache/Event/CacheEntryEventType.cs | 41 +
.../Cache/Event/ICacheEntryEvent.cs | 40 +
.../Cache/Event/ICacheEntryEventFilter.cs | 31 +
.../Cache/Event/ICacheEntryEventListener.cs | 33 +
.../Cache/Expiry/ExpiryPolicy.cs | 89 +
.../Cache/Expiry/IExpiryPolicy.cs | 63 +
.../dotnet/Apache.Ignite.Core/Cache/ICache.cs | 590 ++++
.../Apache.Ignite.Core/Cache/ICacheAffinity.cs | 158 +
.../Apache.Ignite.Core/Cache/ICacheEntry.cs | 37 +
.../Cache/ICacheEntryFilter.cs | 34 +
.../Cache/ICacheEntryProcessor.cs | 45 +
.../Cache/ICacheEntryProcessorResult.cs | 40 +
.../Apache.Ignite.Core/Cache/ICacheLock.cs | 58 +
.../Apache.Ignite.Core/Cache/ICacheMetrics.cs | 486 +++
.../Cache/IMutableCacheEntry.cs | 47 +
.../Cache/Query/Continuous/ContinuousQuery.cs | 170 +
.../Query/Continuous/IContinuousQueryHandle.cs | 47 +
.../Cache/Query/IQueryCursor.cs | 44 +
.../Apache.Ignite.Core/Cache/Query/QueryBase.cs | 82 +
.../Apache.Ignite.Core/Cache/Query/ScanQuery.cs | 77 +
.../Cache/Query/SqlFieldsQuery.cs | 81 +
.../Apache.Ignite.Core/Cache/Query/SqlQuery.cs | 120 +
.../Apache.Ignite.Core/Cache/Query/TextQuery.cs | 104 +
.../Store/CacheParallelLoadStoreAdapter.cs | 207 ++
.../Cache/Store/CacheStoreAdapter.cs | 146 +
.../Cache/Store/CacheStoreException.cs | 66 +
.../Cache/Store/ICacheStore.cs | 184 +
.../Cache/Store/ICacheStoreSession.cs | 42 +
.../Cluster/ClusterGroupEmptyException.cs | 70 +
.../Cluster/ClusterTopologyException.cs | 69 +
.../Apache.Ignite.Core/Cluster/ICluster.cs | 79 +
.../Apache.Ignite.Core/Cluster/IClusterGroup.cs | 235 ++
.../Cluster/IClusterMetrics.cs | 347 ++
.../Apache.Ignite.Core/Cluster/IClusterNode.cs | 135 +
.../Cluster/IClusterNodeFilter.cs | 32 +
.../Common/AsyncSupportedAttribute.cs | 33 +
.../Apache.Ignite.Core/Common/IAsyncSupport.cs | 52 +
.../dotnet/Apache.Ignite.Core/Common/IFuture.cs | 115 +
.../Common/IgniteException.cs | 66 +
.../Apache.Ignite.Core/Common/IgniteGuid.cs | 132 +
.../ComputeExecutionRejectedException.cs | 69 +
.../Compute/ComputeJobAdapter.cs | 122 +
.../Compute/ComputeJobFailoverException.cs | 72 +
.../Compute/ComputeJobResultPolicy.cs | 45 +
.../Compute/ComputeTaskAdapter.cs | 95 +
.../Compute/ComputeTaskCancelledException.cs | 69 +
.../ComputeTaskNoResultCacheAttribute.cs | 35 +
.../Compute/ComputeTaskSplitAdapter.cs | 95 +
.../Compute/ComputeTaskTimeoutException.cs | 67 +
.../Compute/ComputeUserUndeclaredException.cs | 70 +
.../Apache.Ignite.Core/Compute/ICompute.cs | 273 ++
.../Apache.Ignite.Core/Compute/IComputeFunc.cs | 55 +
.../Apache.Ignite.Core/Compute/IComputeJob.cs | 59 +
.../Compute/IComputeJobResult.cs | 73 +
.../Compute/IComputeReducer.cs | 41 +
.../Apache.Ignite.Core/Compute/IComputeTask.cs | 132 +
.../DataStructures/IAtomicLong.cs | 84 +
.../Datastream/IDataStreamer.cs | 206 ++
.../Datastream/IStreamReceiver.cs | 38 +
.../Datastream/StreamTransformer.cs | 73 +
.../Datastream/StreamVisitor.cs | 55 +
.../Apache.Ignite.Core/Events/CacheEvent.cs | 178 +
.../Events/CacheQueryExecutedEvent.cs | 99 +
.../Events/CacheQueryReadEvent.cs | 136 +
.../Events/CacheRebalancingEvent.cs | 100 +
.../Events/CheckpointEvent.cs | 51 +
.../Apache.Ignite.Core/Events/DiscoveryEvent.cs | 82 +
.../Apache.Ignite.Core/Events/EventBase.cs | 167 +
.../Apache.Ignite.Core/Events/EventReader.cs | 72 +
.../Apache.Ignite.Core/Events/EventType.cs | 595 ++++
.../dotnet/Apache.Ignite.Core/Events/IEvent.cs | 74 +
.../Apache.Ignite.Core/Events/IEventFilter.cs | 33 +
.../Apache.Ignite.Core/Events/IEventListener.cs | 34 +
.../dotnet/Apache.Ignite.Core/Events/IEvents.cs | 207 ++
.../Apache.Ignite.Core/Events/JobEvent.cs | 102 +
.../Apache.Ignite.Core/Events/SwapSpaceEvent.cs | 51 +
.../Apache.Ignite.Core/Events/TaskEvent.cs | 93 +
.../Apache.Ignite.Core/GlobalSuppressions.cs | Bin 0 -> 1908 bytes
.../dotnet/Apache.Ignite.Core/IIgnite.cs | 168 +
.../Apache.Ignite.Core/IgniteConfiguration.cs | 143 +
.../dotnet/Apache.Ignite.Core/Ignition.cs | 655 ++++
.../Impl/Cache/CacheAffinityImpl.cs | 275 ++
.../Apache.Ignite.Core/Impl/Cache/CacheEntry.cs | 127 +
.../Impl/Cache/CacheEntryFilterHolder.cs | 147 +
.../Impl/Cache/CacheEntryProcessorHolder.cs | 144 +
.../Impl/Cache/CacheEntryProcessorResult.cs | 65 +
.../Cache/CacheEntryProcessorResultHolder.cs | 128 +
.../Impl/Cache/CacheEnumerable.cs | 82 +
.../Impl/Cache/CacheEnumerator.cs | 117 +
.../Impl/Cache/CacheEnumeratorProxy.cs | 159 +
.../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 1087 ++++++
.../Apache.Ignite.Core/Impl/Cache/CacheLock.cs | 171 +
.../Impl/Cache/CacheMetricsImpl.cs | 248 ++
.../Apache.Ignite.Core/Impl/Cache/CacheOp.cs | 64 +
.../Impl/Cache/CacheProxyImpl.cs | 519 +++
.../Impl/Cache/Event/CacheEntryCreateEvent.cs | 74 +
.../Impl/Cache/Event/CacheEntryRemoveEvent.cs | 74 +
.../Impl/Cache/Event/CacheEntryUpdateEvent.cs | 79 +
.../Impl/Cache/MutableCacheEntry.cs | 163 +
.../Impl/Cache/Query/AbstractQueryCursor.cs | 264 ++
.../Query/Continuous/ContinuousQueryFilter.cs | 125 +
.../Continuous/ContinuousQueryFilterHolder.cs | 87 +
.../Continuous/ContinuousQueryHandleImpl.cs | 213 ++
.../Query/Continuous/ContinuousQueryUtils.cs | 115 +
.../Impl/Cache/Query/FieldsQueryCursor.cs | 54 +
.../Impl/Cache/Query/QueryCursor.cs | 50 +
.../Impl/Cache/Store/CacheStore.cs | 265 ++
.../Impl/Cache/Store/CacheStoreSession.cs | 53 +
.../Impl/Cache/Store/CacheStoreSessionProxy.cs | 63 +
.../Impl/Cluster/ClusterGroupImpl.cs | 577 +++
.../Impl/Cluster/ClusterMetricsImpl.cs | 294 ++
.../Impl/Cluster/ClusterNodeImpl.cs | 221 ++
.../Impl/Cluster/IClusterGroupEx.cs | 35 +
.../Impl/Collections/CollectionExtensions.cs | 45 +
.../Impl/Collections/MultiValueDictionary.cs | 145 +
.../Impl/Collections/ReadOnlyCollection.cs | 102 +
.../Impl/Collections/ReadOnlyDictionary.cs | 149 +
.../Impl/Common/AsyncResult.cs | 71 +
.../Apache.Ignite.Core/Impl/Common/Classpath.cs | 159 +
.../Impl/Common/CompletedAsyncResult.cs | 59 +
.../Common/CopyOnWriteConcurrentDictionary.cs | 72 +
.../Impl/Common/DelegateConverter.cs | 253 ++
.../Impl/Common/DelegateTypeDescriptor.cs | 340 ++
.../Apache.Ignite.Core/Impl/Common/Future.cs | 301 ++
.../Impl/Common/FutureConverter.cs | 62 +
.../Impl/Common/FutureType.cs | 55 +
.../Impl/Common/IFutureConverter.cs | 35 +
.../Impl/Common/IFutureInternal.cs | 46 +
.../Impl/Common/IgniteArgumentCheck.cs | 77 +
.../Impl/Common/IgniteHome.cs | 97 +
.../Impl/Common/LoadedAssembliesResolver.cs | 96 +
.../Impl/Common/PortableResultWrapper.cs | 67 +
.../Impl/Common/TypeCaster.cs | 79 +
.../Closure/ComputeAbstractClosureTask.cs | 101 +
.../Impl/Compute/Closure/ComputeActionJob.cs | 82 +
.../Impl/Compute/Closure/ComputeFuncJob.cs | 86 +
.../Compute/Closure/ComputeMultiClosureTask.cs | 56 +
.../Impl/Compute/Closure/ComputeOutFuncJob.cs | 75 +
.../Closure/ComputeReducingClosureTask.cs | 61 +
.../Compute/Closure/ComputeSingleClosureTask.cs | 48 +
.../Compute/Closure/IComputeResourceInjector.cs | 31 +
.../Apache.Ignite.Core/Impl/Compute/Compute.cs | 215 ++
.../Impl/Compute/ComputeAsync.cs | 264 ++
.../Impl/Compute/ComputeFunc.cs | 118 +
.../Impl/Compute/ComputeImpl.cs | 650 ++++
.../Impl/Compute/ComputeJob.cs | 162 +
.../Impl/Compute/ComputeJobHolder.cs | 245 ++
.../Compute/ComputeJobResultGenericWrapper.cs | 70 +
.../Impl/Compute/ComputeJobResultImpl.cs | 96 +
.../Impl/Compute/ComputeOutFunc.cs | 122 +
.../Impl/Compute/ComputeTaskHolder.cs | 486 +++
.../Impl/DataStructures/AtomicLong.cs | 102 +
.../Impl/Datastream/DataStreamerBatch.cs | 270 ++
.../Impl/Datastream/DataStreamerEntry.cs | 64 +
.../Impl/Datastream/DataStreamerImpl.cs | 840 +++++
.../Impl/Datastream/DataStreamerRemoveEntry.cs | 48 +
.../Impl/Datastream/StreamReceiverHolder.cs | 144 +
.../Apache.Ignite.Core/Impl/Events/Events.cs | 579 +++
.../Impl/Events/EventsAsync.cs | 159 +
.../Impl/Events/RemoteListenEventFilter.cs | 85 +
.../Apache.Ignite.Core/Impl/ExceptionUtils.cs | 208 ++
.../Apache.Ignite.Core/Impl/Handle/Handle.cs | 69 +
.../Impl/Handle/HandleRegistry.cs | 343 ++
.../Apache.Ignite.Core/Impl/Handle/IHandle.cs | 35 +
.../Apache.Ignite.Core/Impl/IInteropCallback.cs | 34 +
.../dotnet/Apache.Ignite.Core/Impl/Ignite.cs | 531 +++
.../Impl/IgniteConfigurationEx.cs | 57 +
.../Apache.Ignite.Core/Impl/IgniteManager.cs | 286 ++
.../Apache.Ignite.Core/Impl/IgniteProxy.cs | 343 ++
.../Apache.Ignite.Core/Impl/IgniteUtils.cs | 428 +++
.../Impl/InteropExceptionHolder.cs | 85 +
.../Impl/LifecycleBeanHolder.cs | 66 +
.../Impl/Memory/IPlatformMemory.cs | 65 +
.../Impl/Memory/InteropExternalMemory.cs | 46 +
.../Impl/Memory/InteropMemoryUtils.cs | 38 +
.../Memory/PlatformBigEndianMemoryStream.cs | 483 +++
.../Impl/Memory/PlatformMemory.cs | 78 +
.../Impl/Memory/PlatformMemoryManager.cs | 107 +
.../Impl/Memory/PlatformMemoryPool.cs | 106 +
.../Impl/Memory/PlatformMemoryStream.cs | 704 ++++
.../Impl/Memory/PlatformMemoryUtils.cs | 465 +++
.../Impl/Memory/PlatformPooledMemory.cs | 66 +
.../Impl/Memory/PlatformRawMemory.cs | 89 +
.../Impl/Memory/PlatformUnpooledMemory.cs | 52 +
.../Impl/Messaging/MessageListenerHolder.cs | 177 +
.../Impl/Messaging/Messaging.cs | 262 ++
.../Impl/Messaging/MessagingAsync.cs | 68 +
.../Apache.Ignite.Core/Impl/NativeMethods.cs | 47 +
.../Apache.Ignite.Core/Impl/PlatformTarget.cs | 720 ++++
.../Portable/IPortableSystemTypeSerializer.cs | 34 +
.../Impl/Portable/IPortableTypeDescriptor.cs | 124 +
.../Impl/Portable/IPortableWriteAware.cs | 34 +
.../Impl/Portable/Io/IPortableStream.cs | 322 ++
.../Impl/Portable/Io/PortableAbstractStream.cs | 1300 +++++++
.../Impl/Portable/Io/PortableHeapStream.cs | 447 +++
.../Impl/Portable/Io/PortableStreamAdapter.cs | 114 +
.../Metadata/IPortableMetadataHandler.cs | 41 +
.../Metadata/PortableHashsetMetadataHandler.cs | 69 +
.../Portable/Metadata/PortableMetadataHolder.cs | 149 +
.../Portable/Metadata/PortableMetadataImpl.cs | 200 ++
.../Impl/Portable/PortableBuilderField.cs | 73 +
.../Impl/Portable/PortableBuilderImpl.cs | 918 +++++
.../Impl/Portable/PortableCollectionInfo.cs | 251 ++
.../Impl/Portable/PortableFullTypeDescriptor.cs | 197 ++
.../Impl/Portable/PortableHandleDictionary.cs | 188 +
.../Portable/PortableMarshalAwareSerializer.cs | 45 +
.../Impl/Portable/PortableMarshaller.cs | 541 +++
.../Impl/Portable/PortableMode.cs | 40 +
.../Impl/Portable/PortableObjectHandle.cs | 59 +
.../PortableOrSerializableObjectHolder.cs | 64 +
.../Portable/PortableReaderHandleDictionary.cs | 42 +
.../Impl/Portable/PortableReaderImpl.cs | 1020 ++++++
.../Impl/Portable/PortableReflectiveRoutines.cs | 483 +++
.../Portable/PortableReflectiveSerializer.cs | 218 ++
.../Portable/PortableSurrogateTypeDescriptor.cs | 143 +
.../Impl/Portable/PortableSystemHandlers.cs | 985 ++++++
.../Portable/PortableSystemTypeSerializer.cs | 62 +
.../Impl/Portable/PortableUserObject.cs | 385 ++
.../Impl/Portable/PortableUtils.cs | 2228 ++++++++++++
.../Impl/Portable/PortableWriterImpl.cs | 1620 +++++++++
.../Impl/Portable/PortablesImpl.cs | 193 +
.../Impl/Portable/SerializableObjectHolder.cs | 64 +
.../Portable/Structure/PortableStructure.cs | 333 ++
.../Structure/PortableStructureEntry.cs | 129 +
.../Structure/PortableStructureJumpTable.cs | 118 +
.../Structure/PortableStructureUpdate.cs | 84 +
.../Impl/Portable/TypeResolver.cs | 231 ++
.../Impl/Resource/IResourceInjector.cs | 27 +
.../Impl/Resource/ResourceFieldInjector.cs | 47 +
.../Impl/Resource/ResourceMethodInjector.cs | 48 +
.../Impl/Resource/ResourceProcessor.cs | 105 +
.../Impl/Resource/ResourcePropertyInjector.cs | 47 +
.../Impl/Resource/ResourceTypeDescriptor.cs | 291 ++
.../Impl/Services/ServiceContext.cs | 60 +
.../Impl/Services/ServiceDescriptor.cs | 106 +
.../Impl/Services/ServiceProxy.cs | 71 +
.../Impl/Services/ServiceProxyInvoker.cs | 141 +
.../Impl/Services/ServiceProxySerializer.cs | 140 +
.../Impl/Services/Services.cs | 316 ++
.../Impl/Services/ServicesAsync.cs | 89 +
.../Impl/Transactions/AsyncTransaction.cs | 78 +
.../Impl/Transactions/Transaction.cs | 158 +
.../Impl/Transactions/TransactionImpl.cs | 491 +++
.../Impl/Transactions/TransactionMetricsImpl.cs | 68 +
.../Impl/Transactions/TransactionsImpl.cs | 201 ++
.../Impl/Unmanaged/IUnmanagedTarget.cs | 42 +
.../Impl/Unmanaged/UnmanagedCallbackHandlers.cs | 99 +
.../Impl/Unmanaged/UnmanagedCallbacks.cs | 1164 +++++++
.../Impl/Unmanaged/UnmanagedContext.cs | 53 +
.../Unmanaged/UnmanagedNonReleaseableTarget.cs | 71 +
.../Impl/Unmanaged/UnmanagedTarget.cs | 77 +
.../Impl/Unmanaged/UnmanagedUtils.cs | 1371 ++++++++
.../Lifecycle/ILifecycleBean.cs | 64 +
.../Lifecycle/LifecycleEventType.cs | 49 +
.../Messaging/IMessageListener.cs | 38 +
.../Apache.Ignite.Core/Messaging/IMessaging.cs | 108 +
.../Portable/IPortableBuilder.cs | 77 +
.../Portable/IPortableIdMapper.cs | 40 +
.../Portable/IPortableMarshalAware.cs | 39 +
.../Portable/IPortableMetadata.cs | 52 +
.../Portable/IPortableNameMapper.cs | 39 +
.../Portable/IPortableObject.cs | 60 +
.../Portable/IPortableRawReader.cs | 264 ++
.../Portable/IPortableRawWriter.cs | 221 ++
.../Portable/IPortableReader.cs | 340 ++
.../Portable/IPortableSerializer.cs | 39 +
.../Portable/IPortableWriter.cs | 259 ++
.../Apache.Ignite.Core/Portable/IPortables.cs | 120 +
.../Portable/PortableConfiguration.cs | 125 +
.../Portable/PortableException.cs | 64 +
.../Portable/PortableTypeConfiguration.cs | 162 +
.../Portable/PortableTypeNames.cs | 115 +
.../Properties/AssemblyInfo.cs | 47 +
.../Resource/InstanceResourceAttribute.cs | 35 +
.../Resource/StoreSessionResourceAttribute.cs | 32 +
.../Apache.Ignite.Core/Services/IService.cs | 51 +
.../Services/IServiceContext.cs | 69 +
.../Services/IServiceDescriptor.cs | 96 +
.../Apache.Ignite.Core/Services/IServices.cs | 184 +
.../Services/ServiceConfiguration.cs | 62 +
.../Services/ServiceInvocationException.cs | 101 +
.../Transactions/ITransaction.cs | 230 ++
.../Transactions/ITransactionMetrics.cs | 47 +
.../Transactions/ITransactions.cs | 76 +
.../Transactions/TransactionConcurrency.cs | 36 +
.../TransactionHeuristicException.cs | 72 +
.../Transactions/TransactionIsolation.cs | 41 +
.../TransactionOptimisticException.cs | 69 +
.../TransactionRollbackException.cs | 68 +
.../Transactions/TransactionState.cs | 70 +
.../Transactions/TransactionTimeoutException.cs | 69 +
modules/platforms/dotnet/Apache.Ignite.FxCop | 117 +
modules/platforms/dotnet/Apache.Ignite.sln | 107 +
.../dotnet/Apache.Ignite.sln.DotSettings | 4 +
modules/platforms/dotnet/Apache.Ignite.slnrel | 43 +
.../dotnet/Apache.Ignite/Apache.Ignite.csproj | 76 +
.../platforms/dotnet/Apache.Ignite/App.config | 56 +
.../Config/AppSettingsConfigurator.cs | 113 +
.../Apache.Ignite/Config/ArgsConfigurator.cs | 164 +
.../Apache.Ignite/Config/ConfigValueParser.cs | 42 +
.../Apache.Ignite/Config/IConfigurator.cs | 34 +
.../dotnet/Apache.Ignite/IgniteRunner.cs | 171 +
.../Apache.Ignite/Properties/AssemblyInfo.cs | 35 +
.../Apache.Ignite/Service/IgniteService.cs | 219 ++
.../Apache.Ignite/Service/NativeMethods.cs | 57 +
.../Apache.Ignite/Service/ServiceDescription.cs | 32 +
.../platforms/dotnet/Apache.Ignite_x86.slnrel | 43 +
modules/platforms/dotnet/README.txt | 24 +
.../dotnet/examples/Apache.Ignite.Examples.sln | 38 +
.../Apache.Ignite.Examples.csproj | 81 +
.../examples/Apache.Ignite.Examples/App.config | 24 +
.../Compute/ClosureExample.cs | 84 +
.../Compute/TaskExample.cs | 140 +
.../Datagrid/ContinuousQueryExample.cs | 103 +
.../Datagrid/CrossPlatformExample.cs | 208 ++
.../Datagrid/DataStreamerExample.cs | 101 +
.../Datagrid/PutGetExample.cs | 219 ++
.../Datagrid/QueryExample.cs | 226 ++
.../Datagrid/StoreExample.cs | 114 +
.../Datagrid/TransactionExample.cs | 104 +
.../Events/EventsExample.cs | 103 +
.../Messaging/MessagingExample.cs | 112 +
.../Misc/LifecycleExample.cs | 109 +
.../Properties/AssemblyInfo.cs | 35 +
.../Services/IMapService.cs | 56 +
.../Services/ServicesExample.cs | 77 +
.../Apache.Ignite.ExamplesDll.csproj | 73 +
.../Compute/AverageSalaryJob.cs | 65 +
.../Compute/AverageSalaryTask.cs | 84 +
.../Compute/CharacterCountClosure.cs | 43 +
.../Compute/CharacterCountReducer.cs | 51 +
.../Datagrid/ContinuousQueryFilter.cs | 50 +
.../Datagrid/EmployeeStore.cs | 121 +
.../Datagrid/EmployeeStorePredicate.cs | 40 +
.../Events/LocalListener.cs | 54 +
.../Messaging/LocalListener.cs | 59 +
.../Messaging/RemoteOrderedListener.cs | 54 +
.../Messaging/RemoteUnorderedListener.cs | 54 +
.../Messaging/Topic.cs | 28 +
.../Portable/Account.cs | 60 +
.../Portable/Address.cs | 81 +
.../Portable/Employee.cs | 93 +
.../Portable/EmployeeKey.cs | 86 +
.../Portable/Organization.cs | 84 +
.../Portable/OrganizationType.cs | 43 +
.../Properties/AssemblyInfo.cs | 35 +
.../Services/MapService.cs | 119 +
.../examples/Config/example-cache-query.xml | 111 +
.../examples/Config/example-cache-store.xml | 60 +
.../dotnet/examples/Config/example-cache.xml | 80 +
.../dotnet/examples/Config/example-compute.xml | 70 +
modules/platforms/dotnet/examples/README.txt | 14 +
modules/platforms/licenses/apache-2.0.txt | 202 ++
.../spi/deployment/uri/UriDeploymentSpi.java | 93 +-
.../scanners/http/UriDeploymentHttpScanner.java | 10 +-
.../http/GridHttpDeploymentSelfTest.java | 132 +-
parent/pom.xml | 16 +-
pom.xml | 90 +-
1481 files changed, 141121 insertions(+), 127504 deletions(-)
----------------------------------------------------------------------
[45/50] [abbrv] ignite git commit: Merge branch 'ignite-1282' into
ignite-1651
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ec58b87c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
----------------------------------------------------------------------
diff --cc modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
index 0000000,c7be496..6d07757
mode 000000,100644..100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
@@@ -1,0 -1,2200 +1,2228 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Portable
+ {
+ using System;
+ using System.Collections;
+ using System.Collections.Concurrent;
+ using System.Collections.Generic;
+ using System.Diagnostics;
+ using System.Diagnostics.CodeAnalysis;
+ using System.IO;
+ using System.Reflection;
+ using System.Runtime.InteropServices;
+ using System.Runtime.Serialization.Formatters.Binary;
++ using System.Security.Policy;
+ using System.Text;
+ using Apache.Ignite.Core.Impl.Common;
+ using Apache.Ignite.Core.Impl.Portable.IO;
+ using Apache.Ignite.Core.Portable;
+
+ /**
+ * <summary>Utilities for portable serialization.</summary>
+ */
+ static class PortableUtils
+ {
+ /** Cache empty dictionary. */
+ public static readonly IDictionary<int, int> EmptyFields = new Dictionary<int, int>();
+
+ /** Header of NULL object. */
+ public const byte HdrNull = 101;
+
+ /** Header of object handle. */
+ public const byte HdrHnd = 102;
+
+ /** Header of object in fully serialized form. */
+ public const byte HdrFull = 103;
-
++
++ /** Protocol versnion. */
++ public const byte ProtoVer = 1;
++
+ /** Full header length. */
- public const int FullHdrLen = 18;
++ public const int FullHdrLen = 19;
++
++ /** Offset: hash code. */
++ public const int OffsetTypeId = 3;
++
++ /** Offset: hash code. */
++ public const int OffsetHashCode = 7;
++
++ /** Offset: length. */
++ public const int OffsetLen = 11;
++
++ /** Offset: raw data offset. */
++ public const int OffsetRawOff = 15;
+
+ /** Type: object. */
+ public const byte TypeObject = HdrFull;
+
+ /** Type: unsigned byte. */
+ public const byte TypeByte = 1;
+
+ /** Type: short. */
+ public const byte TypeShort = 2;
+
+ /** Type: int. */
+ public const byte TypeInt = 3;
+
+ /** Type: long. */
+ public const byte TypeLong = 4;
+
+ /** Type: float. */
+ public const byte TypeFloat = 5;
+
+ /** Type: double. */
+ public const byte TypeDouble = 6;
+
+ /** Type: char. */
+ public const byte TypeChar = 7;
+
+ /** Type: boolean. */
+ public const byte TypeBool = 8;
+
+ /** Type: decimal. */
+ public const byte TypeDecimal = 30;
+
+ /** Type: string. */
+ public const byte TypeString = 9;
+
+ /** Type: GUID. */
+ public const byte TypeGuid = 10;
+
+ /** Type: date. */
+ public const byte TypeDate = 11;
+
+ /** Type: unsigned byte array. */
+ public const byte TypeArrayByte = 12;
+
+ /** Type: short array. */
+ public const byte TypeArrayShort = 13;
+
+ /** Type: int array. */
+ public const byte TypeArrayInt = 14;
+
+ /** Type: long array. */
+ public const byte TypeArrayLong = 15;
+
+ /** Type: float array. */
+ public const byte TypeArrayFloat = 16;
+
+ /** Type: double array. */
+ public const byte TypeArrayDouble = 17;
+
+ /** Type: char array. */
+ public const byte TypeArrayChar = 18;
+
+ /** Type: boolean array. */
+ public const byte TypeArrayBool = 19;
+
+ /** Type: decimal array. */
+ public const byte TypeArrayDecimal = 31;
+
+ /** Type: string array. */
+ public const byte TypeArrayString = 20;
+
+ /** Type: GUID array. */
+ public const byte TypeArrayGuid = 21;
+
+ /** Type: date array. */
+ public const byte TypeArrayDate = 22;
+
+ /** Type: object array. */
+ public const byte TypeArray = 23;
+
+ /** Type: collection. */
+ public const byte TypeCollection = 24;
+
+ /** Type: map. */
+ public const byte TypeDictionary = 25;
+
+ /** Type: map entry. */
+ public const byte TypeMapEntry = 26;
+
+ /** Type: portable object. */
+ public const byte TypePortable = 27;
+
+ /** Type: enum. */
+ public const byte TypeEnum = 28;
+
+ /** Type: enum array. */
+ public const byte TypeArrayEnum = 29;
+
+ /** Type: native job holder. */
+ public const byte TypeNativeJobHolder = 77;
+
+ /** Type: native job result holder. */
+ public const byte TypePortableJobResHolder = 76;
+
+ /** Type: .Net configuration. */
+ public const byte TypeDotNetCfg = 202;
+
+ /** Type: .Net portable configuration. */
+ public const byte TypeDotNetPortableCfg = 203;
+
+ /** Type: .Net portable type configuration. */
+ public const byte TypeDotNetPortableTypCfg = 204;
+
+ /** Type: Ignite proxy. */
+ public const byte TypeIgniteProxy = 74;
+
+ /** Type: function wrapper. */
+ public const byte TypeComputeOutFuncJob = 80;
+
+ /** Type: function wrapper. */
+ public const byte TypeComputeFuncJob = 81;
+
+ /** Type: continuous query remote filter. */
+ public const byte TypeContinuousQueryRemoteFilterHolder = 82;
+
+ /** Type: Compute out func wrapper. */
+ public const byte TypeComputeOutFuncWrapper = 83;
+
+ /** Type: Compute func wrapper. */
+ public const byte TypeComputeFuncWrapper = 85;
+
+ /** Type: Compute job wrapper. */
+ public const byte TypeComputeJobWrapper = 86;
+
+ /** Type: Compute job wrapper. */
+ public const byte TypeSerializableHolder = 87;
+
+ /** Type: action wrapper. */
+ public const byte TypeComputeActionJob = 88;
+
+ /** Type: entry processor holder. */
+ public const byte TypeCacheEntryProcessorHolder = 89;
+
+ /** Type: entry predicate holder. */
+ public const byte TypeCacheEntryPredicateHolder = 90;
+
+ /** Type: product license. */
+ public const byte TypeProductLicense = 78;
+
+ /** Type: message filter holder. */
+ public const byte TypeMessageListenerHolder = 92;
+
+ /** Type: message filter holder. */
+ public const byte TypePortableOrSerializableHolder = 93;
+
+ /** Type: stream receiver holder. */
+ public const byte TypeStreamReceiverHolder = 94;
+
+ /** Collection: custom. */
+ public const byte CollectionCustom = 0;
+
+ /** Collection: array list. */
+ public const byte CollectionArrayList = 1;
+
+ /** Collection: linked list. */
+ public const byte CollectionLinkedList = 2;
+
+ /** Collection: hash set. */
+ public const byte CollectionHashSet = 3;
+
+ /** Collection: hash set. */
+ public const byte CollectionLinkedHashSet = 4;
+
+ /** Collection: sorted set. */
+ public const byte CollectionSortedSet = 5;
+
+ /** Collection: concurrent bag. */
+ public const byte CollectionConcurrentBag = 6;
+
+ /** Map: custom. */
+ public const byte MapCustom = 0;
+
+ /** Map: hash map. */
+ public const byte MapHashMap = 1;
+
+ /** Map: linked hash map. */
+ public const byte MapLinkedHashMap = 2;
+
+ /** Map: sorted map. */
+ public const byte MapSortedMap = 3;
+
+ /** Map: concurrent hash map. */
+ public const byte MapConcurrentHashMap = 4;
+
+ /** Byte "0". */
+ public const byte ByteZero = 0;
+
+ /** Byte "1". */
+ public const byte ByteOne = 1;
+
+ /** Indicates object array. */
+ public const int ObjTypeId = -1;
+
+ /** Length of tpye ID. */
+ public const int LengthTypeId = 1;
+
+ /** Length of array size. */
+ public const int LengthArraySize = 4;
+
+ /** Int type. */
+ public static readonly Type TypInt = typeof(int);
+
+ /** Collection type. */
+ public static readonly Type TypCollection = typeof(ICollection);
+
+ /** Dictionary type. */
+ public static readonly Type TypDictionary = typeof(IDictionary);
+
+ /** Generic collection type. */
+ public static readonly Type TypGenericCollection = typeof(ICollection<>);
+
+ /** Generic dictionary type. */
+ public static readonly Type TypGenericDictionary = typeof(IDictionary<,>);
+
+ /** Ticks for Java epoch. */
+ private static readonly long JavaDateTicks = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).Ticks;
+
+ /** Bindig flags for static search. */
+ private static BindingFlags _bindFlagsStatic =
+ BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
+
+ /** Default poratble marshaller. */
+ private static readonly PortableMarshaller Marsh = new PortableMarshaller(null);
+
+ /** Method: WriteGenericCollection. */
+ public static readonly MethodInfo MtdhWriteGenericCollection =
+ typeof(PortableUtils).GetMethod("WriteGenericCollection", _bindFlagsStatic);
+
+ /** Method: ReadGenericCollection. */
+ public static readonly MethodInfo MtdhReadGenericCollection =
+ typeof(PortableUtils).GetMethod("ReadGenericCollection", _bindFlagsStatic);
+
+ /** Method: WriteGenericDictionary. */
+ public static readonly MethodInfo MtdhWriteGenericDictionary =
+ typeof(PortableUtils).GetMethod("WriteGenericDictionary", _bindFlagsStatic);
+
+ /** Method: ReadGenericDictionary. */
+ public static readonly MethodInfo MtdhReadGenericDictionary =
+ typeof(PortableUtils).GetMethod("ReadGenericDictionary", _bindFlagsStatic);
+
+ /** Method: ReadGenericArray. */
+ public static readonly MethodInfo MtdhReadGenericArray =
+ typeof(PortableUtils).GetMethod("ReadGenericArray", _bindFlagsStatic);
+
+ /** Cached UTF8 encoding. */
+ private static readonly Encoding Utf8 = Encoding.UTF8;
+
+ /** Cached generic array read funcs. */
+ private static readonly CopyOnWriteConcurrentDictionary<Type, Func<PortableReaderImpl, bool, object>>
+ ArrayReaders = new CopyOnWriteConcurrentDictionary<Type, Func<PortableReaderImpl, bool, object>>();
+
+ /// <summary>
+ /// Default marshaller.
+ /// </summary>
+ public static PortableMarshaller Marshaller
+ {
+ get { return Marsh; }
+ }
+
+ /**
+ * <summary>Write boolean array.</summary>
+ * <param name="vals">Value.</param>
+ * <param name="stream">Output stream.</param>
+ */
+ public static void WriteBooleanArray(bool[] vals, IPortableStream stream)
+ {
+ stream.WriteInt(vals.Length);
+
+ stream.WriteBoolArray(vals);
+ }
+
+ /**
+ * <summary>Read boolean array.</summary>
+ * <param name="stream">Output stream.</param>
+ * <returns>Value.</returns>
+ */
+ public static bool[] ReadBooleanArray(IPortableStream stream)
+ {
+ int len = stream.ReadInt();
+
+ return stream.ReadBoolArray(len);
+ }
+
+ /**
+ * <summary>Write byte array.</summary>
+ * <param name="vals">Value.</param>
+ * <param name="stream">Output stream.</param>
+ * <returns>Length of written data.</returns>
+ */
+ public static void WriteByteArray(byte[] vals, IPortableStream stream)
+ {
+ stream.WriteInt(vals.Length);
+
+ stream.WriteByteArray(vals);
+ }
+
+ /**
+ * <summary>Read byte array.</summary>
+ * <param name="stream">Output stream.</param>
+ * <returns>Value.</returns>
+ */
+ public static byte[] ReadByteArray(IPortableStream stream)
+ {
+ return stream.ReadByteArray(stream.ReadInt());
+ }
+
+ /**
+ * <summary>Read byte array.</summary>
+ * <param name="stream">Output stream.</param>
+ * <returns>Value.</returns>
+ */
+ public static unsafe sbyte[] ReadSbyteArray(IPortableStream stream)
+ {
+ int len = stream.ReadInt();
+
+ sbyte[] res = new sbyte[len];
+
+ fixed (sbyte* res0 = res)
+ {
+ stream.Read((byte*) res0, len);
+ }
+
+ return res;
+ }
+
+ /**
+ * <summary>Read byte array.</summary>
+ * <param name="data">Data.</param>
+ * <param name="pos">Position.</param>
+ * <returns>Value.</returns>
+ */
+ public static byte[] ReadByteArray(byte[] data, int pos) {
+ int len = ReadInt(data, pos);
+
+ pos += 4;
+
+ byte[] res = new byte[len];
+
+ Buffer.BlockCopy(data, pos, res, 0, len);
+
+ return res;
+ }
+
+ /**
+ * <summary>Write short array.</summary>
+ * <param name="vals">Value.</param>
+ * <param name="stream">Output stream.</param>
+ */
+ public static void WriteShortArray(short[] vals, IPortableStream stream)
+ {
+ stream.WriteInt(vals.Length);
+
+ stream.WriteShortArray(vals);
+ }
+
+ /**
+ * <summary>Read short array.</summary>
+ * <param name="stream">Stream.</param>
+ * <returns>Value.</returns>
+ */
+ public static unsafe ushort[] ReadUshortArray(IPortableStream stream)
+ {
+ int len = stream.ReadInt();
+
+ ushort[] res = new ushort[len];
+
+ fixed (ushort* res0 = res)
+ {
+ stream.Read((byte*) res0, len * 2);
+ }
+
+ return res;
+ }
+
+ /**
+ * <summary>Read short array.</summary>
+ * <param name="stream">Stream.</param>
+ * <returns>Value.</returns>
+ */
+ public static short[] ReadShortArray(IPortableStream stream)
+ {
+ return stream.ReadShortArray(stream.ReadInt());
+ }
+
+ /**
+ * <summary>Read int value.</summary>
+ * <param name="data">Data array.</param>
+ * <param name="pos">Position.</param>
+ * <returns>Value.</returns>
+ */
+ public static int ReadInt(byte[] data, int pos) {
+ int val = data[pos];
+
+ val |= data[pos + 1] << 8;
+ val |= data[pos + 2] << 16;
+ val |= data[pos + 3] << 24;
+
+ return val;
+ }
+
+ /**
+ * <summary>Read long value.</summary>
+ * <param name="data">Data array.</param>
+ * <param name="pos">Position.</param>
+ * <returns>Value.</returns>
+ */
+ public static long ReadLong(byte[] data, int pos) {
+ long val = (long)(data[pos]) << 0;
+
+ val |= (long)(data[pos + 1]) << 8;
+ val |= (long)(data[pos + 2]) << 16;
+ val |= (long)(data[pos + 3]) << 24;
+ val |= (long)(data[pos + 4]) << 32;
+ val |= (long)(data[pos + 5]) << 40;
+ val |= (long)(data[pos + 6]) << 48;
+ val |= (long)(data[pos + 7]) << 56;
+
+ return val;
+ }
+
+ /**
+ * <summary>Write int array.</summary>
+ * <param name="vals">Value.</param>
+ * <param name="stream">Output stream.</param>
+ */
+ public static void WriteIntArray(int[] vals, IPortableStream stream)
+ {
+ stream.WriteInt(vals.Length);
+
+ stream.WriteIntArray(vals);
+ }
+
+ /**
+ * <summary>Read int array.</summary>
+ * <param name="stream">Stream.</param>
+ * <returns>Value.</returns>
+ */
+ public static int[] ReadIntArray(IPortableStream stream)
+ {
+ return stream.ReadIntArray(stream.ReadInt());
+ }
+
+ /**
+ * <summary>Read int array.</summary>
+ * <param name="stream">Stream.</param>
+ * <returns>Value.</returns>
+ */
+ public static unsafe uint[] ReadUintArray(IPortableStream stream)
+ {
+ int len = stream.ReadInt();
+
+ uint[] res = new uint[len];
+
+ fixed (uint* res0 = res)
+ {
+ stream.Read((byte*) res0, len * 4);
+ }
+
+ return res;
+ }
+
+ /**
+ * <summary>Write long array.</summary>
+ * <param name="vals">Value.</param>
+ * <param name="stream">Output stream.</param>
+ */
+ public static void WriteLongArray(long[] vals, IPortableStream stream)
+ {
+ stream.WriteInt(vals.Length);
+
+ stream.WriteLongArray(vals);
+ }
+
+ /**
+ * <summary>Read long array.</summary>
+ * <param name="stream">Stream.</param>
+ * <returns>Value.</returns>
+ */
+ public static long[] ReadLongArray(IPortableStream stream)
+ {
+ return stream.ReadLongArray(stream.ReadInt());
+ }
+
+ /**
+ * <summary>Read ulong array.</summary>
+ * <param name="stream">Stream.</param>
+ * <returns>Value.</returns>
+ */
+ public static unsafe ulong[] ReadUlongArray(IPortableStream stream)
+ {
+ int len = stream.ReadInt();
+
+ ulong[] res = new ulong[len];
+
+ fixed (ulong* res0 = res)
+ {
+ stream.Read((byte*) res0, len * 8);
+ }
+
+ return res;
+ }
+
+ /**
+ * <summary>Write char array.</summary>
+ * <param name="vals">Value.</param>
+ * <param name="stream">Output stream.</param>
+ */
+ public static void WriteCharArray(char[] vals, IPortableStream stream)
+ {
+ stream.WriteInt(vals.Length);
+
+ stream.WriteCharArray(vals);
+ }
+
+ /**
+ * <summary>Read char array.</summary>
+ * <param name="stream">Stream.</param>
+ * <returns>Value.</returns>
+ */
+ public static char[] ReadCharArray(IPortableStream stream)
+ {
+ int len = stream.ReadInt();
+
+ return stream.ReadCharArray(len);
+ }
+
+ /**
+ * <summary>Write float array.</summary>
+ * <param name="vals">Value.</param>
+ * <param name="stream">Output stream.</param>
+ */
+ public static void WriteFloatArray(float[] vals, IPortableStream stream)
+ {
+ stream.WriteInt(vals.Length);
+
+ stream.WriteFloatArray(vals);
+ }
+
+ /**
+ * <summary>Read float array.</summary>
+ * <param name="stream">Stream.</param>
+ * <returns>Value.</returns>
+ */
+ public static float[] ReadFloatArray(IPortableStream stream)
+ {
+ int len = stream.ReadInt();
+
+ return stream.ReadFloatArray(len);
+ }
+
+ /**
+ * <summary>Write double array.</summary>
+ * <param name="vals">Value.</param>
+ * <param name="stream">Output stream.</param>
+ */
+ public static void WriteDoubleArray(double[] vals, IPortableStream stream)
+ {
+ stream.WriteInt(vals.Length);
+
+ stream.WriteDoubleArray(vals);
+ }
+
+ /**
+ * <summary>Read double array.</summary>
+ * <param name="stream">Stream.</param>
+ * <returns>Value.</returns>
+ */
+ public static double[] ReadDoubleArray(IPortableStream stream)
+ {
+ int len = stream.ReadInt();
+
+ return stream.ReadDoubleArray(len);
+ }
+
+ /**
+ * <summary>Write date.</summary>
+ * <param name="val">Date.</param>
+ * <param name="stream">Stream.</param>
+ */
+ public static void WriteDate(DateTime val, IPortableStream stream)
+ {
+ long high;
+ int low;
+
+ ToJavaDate(val, out high, out low);
+
+ stream.WriteLong(high);
+ stream.WriteInt(low);
+ }
+
+ /**
+ * <summary>Read date.</summary>
+ * <param name="stream">Stream.</param>
+ * <param name="local">Local flag.</param>
+ * <returns>Date</returns>
+ */
+ public static DateTime? ReadDate(IPortableStream stream, bool local)
+ {
+ long high = stream.ReadLong();
+ int low = stream.ReadInt();
+
+ return ToDotNetDate(high, low, local);
+ }
+
+ /// <summary>
+ /// Write date array.
+ /// </summary>
+ /// <param name="vals">Values.</param>
+ /// <param name="stream">Stream.</param>
+ public static void WriteDateArray(DateTime[] vals, IPortableStream stream)
+ {
+ stream.WriteInt(vals.Length);
+
+ foreach (DateTime val in vals)
+ {
+ stream.WriteByte(TypeDate);
+
+ WriteDate(val, stream);
+ }
+ }
+
+ /// <summary>
+ /// Write nullable date array.
+ /// </summary>
+ /// <param name="vals">Values.</param>
+ /// <param name="stream">Stream.</param>
+ public static void WriteDateArray(DateTime?[] vals, IPortableStream stream)
+ {
+ stream.WriteInt(vals.Length);
+
+ foreach (DateTime? val in vals)
+ {
+ if (val.HasValue)
+ {
+ stream.WriteByte(TypeDate);
+
+ WriteDate(val.Value, stream);
+ }
+ else
+ stream.WriteByte(HdrNull);
+ }
+ }
+
+ /**
+ * <summary>Write string in UTF8 encoding.</summary>
+ * <param name="val">String.</param>
+ * <param name="stream">Stream.</param>
+ */
+ public static unsafe void WriteString(string val, IPortableStream stream)
+ {
+ stream.WriteBool(true);
+
+ int charCnt = val.Length;
+
+ fixed (char* chars = val)
+ {
+ int byteCnt = Utf8.GetByteCount(chars, charCnt);
+
+ stream.WriteInt(byteCnt);
+
+ stream.WriteString(chars, charCnt, byteCnt, Utf8);
+ }
+ }
+
+ /**
+ * <summary>Read string in UTF8 encoding.</summary>
+ * <param name="stream">Stream.</param>
+ * <returns>String.</returns>
+ */
+ public static string ReadString(IPortableStream stream)
+ {
+ if (stream.ReadBool())
+ {
+ byte[] bytes = ReadByteArray(stream);
+
+ return bytes != null ? Utf8.GetString(bytes) : null;
+ }
+
+ char[] chars = ReadCharArray(stream);
+
+ return new string(chars);
+ }
+
+ /**
+ * <summary>Write string array in UTF8 encoding.</summary>
+ * <param name="vals">String array.</param>
+ * <param name="stream">Stream.</param>
+ */
+ public static void WriteStringArray(string[] vals, IPortableStream stream)
+ {
+ stream.WriteInt(vals.Length);
+
+ foreach (string val in vals)
+ {
+ if (val != null)
+ {
+ stream.WriteByte(TypeString);
+ WriteString(val, stream);
+ }
+ else
+ stream.WriteByte(HdrNull);
+ }
+ }
+
+ /**
+ * <summary>Read string array in UTF8 encoding.</summary>
+ * <param name="stream">Stream.</param>
+ * <returns>String array.</returns>
+ */
+ public static string[] ReadStringArray(IPortableStream stream)
+ {
+ int len = stream.ReadInt();
+
+ string[] vals = new string[len];
+
+ for (int i = 0; i < len; i++)
+ vals[i] = ReadString(stream);
+
+ return vals;
+ }
+
+ /**
+ * <summary>Write decimal value.</summary>
+ * <param name="val">Decimal value.</param>
+ * <param name="stream">Stream.</param>
+ */
+ public static void WriteDecimal(decimal val, IPortableStream stream)
+ {
+ // Vals are:
+ // [0] = lo
+ // [1] = mid
+ // [2] = high
+ // [3] = flags
+ int[] vals = decimal.GetBits(val);
+
+ // Get start index skipping leading zeros.
+ int idx = vals[2] != 0 ? 2 : vals[1] != 0 ? 1 : vals[0] != 0 ? 0 : -1;
+
+ // Write scale and negative flag.
+ int scale = (vals[3] & 0x00FF0000) >> 16;
+
+ stream.WriteInt(((vals[3] & 0x80000000) == 0x80000000) ? (int)((uint)scale | 0x80000000) : scale);
+
+ if (idx == -1)
+ {
+ // Writing zero.
+ stream.WriteInt(1);
+ stream.WriteByte(0);
+ }
+ else
+ {
+ int len = (idx + 1) << 2;
+
+ // Write data.
+ for (int i = idx; i >= 0; i--)
+ {
+ int curPart = vals[i];
+
+ int part24 = (curPart >> 24) & 0xFF;
+ int part16 = (curPart >> 16) & 0xFF;
+ int part8 = (curPart >> 8) & 0xFF;
+ int part0 = curPart & 0xFF;
+
+ if (i == idx)
+ {
+ // Possibly skipping some values here.
+ if (part24 != 0)
+ {
+ if ((part24 & 0x80) == 0x80)
+ {
+ stream.WriteInt(len + 1);
+
+ stream.WriteByte(ByteZero);
+ }
+ else
+ stream.WriteInt(len);
+
+ stream.WriteByte((byte)part24);
+ stream.WriteByte((byte)part16);
+ stream.WriteByte((byte)part8);
+ stream.WriteByte((byte)part0);
+ }
+ else if (part16 != 0)
+ {
+ if ((part16 & 0x80) == 0x80)
+ {
+ stream.WriteInt(len);
+
+ stream.WriteByte(ByteZero);
+ }
+ else
+ stream.WriteInt(len - 1);
+
+ stream.WriteByte((byte)part16);
+ stream.WriteByte((byte)part8);
+ stream.WriteByte((byte)part0);
+ }
+ else if (part8 != 0)
+ {
+ if ((part8 & 0x80) == 0x80)
+ {
+ stream.WriteInt(len - 1);
+
+ stream.WriteByte(ByteZero);
+ }
+ else
+ stream.WriteInt(len - 2);
+
+ stream.WriteByte((byte)part8);
+ stream.WriteByte((byte)part0);
+ }
+ else
+ {
+ if ((part0 & 0x80) == 0x80)
+ {
+ stream.WriteInt(len - 2);
+
+ stream.WriteByte(ByteZero);
+ }
+ else
+ stream.WriteInt(len - 3);
+
+ stream.WriteByte((byte)part0);
+ }
+ }
+ else
+ {
+ stream.WriteByte((byte)part24);
+ stream.WriteByte((byte)part16);
+ stream.WriteByte((byte)part8);
+ stream.WriteByte((byte)part0);
+ }
+ }
+ }
+ }
+
+ /**
+ * <summary>Read decimal value.</summary>
+ * <param name="stream">Stream.</param>
+ * <returns>Decimal value.</returns>
+ */
+ public static decimal? ReadDecimal(IPortableStream stream)
+ {
+ int scale = stream.ReadInt();
+
+ bool neg;
+
+ if (scale < 0)
+ {
+ scale = scale & 0x7FFFFFFF;
+
+ neg = true;
+ }
+ else
+ neg = false;
+
+ byte[] mag = ReadByteArray(stream);
+
+ if (scale < 0 || scale > 28)
+ throw new PortableException("Decimal value scale overflow (must be between 0 and 28): " + scale);
+
+ if (mag.Length > 13)
+ throw new PortableException("Decimal magnitude overflow (must be less than 96 bits): " +
+ mag.Length * 8);
+
+ if (mag.Length == 13 && mag[0] != 0)
+ throw new PortableException("Decimal magnitude overflow (must be less than 96 bits): " +
+ mag.Length * 8);
+
+ int hi = 0;
+ int mid = 0;
+ int lo = 0;
+
+ int ctr = -1;
+
+ for (int i = mag.Length - 12; i < mag.Length; i++)
+ {
+ if (++ctr == 4)
+ {
+ mid = lo;
+ lo = 0;
+ }
+ else if (ctr == 8)
+ {
+ hi = mid;
+ mid = lo;
+ lo = 0;
+ }
+
+ if (i >= 0)
+ lo = (lo << 8) + mag[i];
+ }
+
+ return new decimal(lo, mid, hi, neg, (byte)scale);
+ }
+
+ /**
+ * <summary>Write decimal array.</summary>
+ * <param name="vals">Decimal array.</param>
+ * <param name="stream">Stream.</param>
+ */
+ public static void WriteDecimalArray(decimal?[] vals, IPortableStream stream)
+ {
+ stream.WriteInt(vals.Length);
+
+ foreach (var val in vals)
+ {
+ if (val.HasValue)
+ {
+ stream.WriteByte(TypeDecimal);
+
+ WriteDecimal(val.Value, stream);
+ }
+ else
+ stream.WriteByte(HdrNull);
+ }
+ }
+
+ /**
+ * <summary>Read decimal array.</summary>
+ * <param name="stream">Stream.</param>
+ * <returns>Decimal array.</returns>
+ */
+ public static decimal?[] ReadDecimalArray(IPortableStream stream)
+ {
+ int len = stream.ReadInt();
+
+ var vals = new decimal?[len];
+
+ for (int i = 0; i < len; i++)
+ vals[i] = stream.ReadByte() == HdrNull ? (decimal?) null : ReadDecimal(stream);
+
+ return vals;
+ }
+
+ /**
+ * <summary>Write GUID.</summary>
+ * <param name="val">GUID.</param>
+ * <param name="stream">Stream.</param>
+ */
+ public static unsafe void WriteGuid(Guid val, IPortableStream stream)
+ {
+ var jguid = new JavaGuid(val);
+
+ var ptr = &jguid;
+
+ stream.Write((byte*) ptr, 16);
+ }
+
+ /**
+ * <summary>Read GUID.</summary>
+ * <param name="stream">Stream.</param>
+ * <returns>GUID</returns>
+ */
+ public static unsafe Guid? ReadGuid(IPortableStream stream)
+ {
+ JavaGuid jguid;
+
+ var ptr = (byte*) &jguid;
+
+ stream.Read(ptr, 16);
+
+ var dotnetGuid = new GuidAccessor(jguid);
+
+ return *(Guid*) (&dotnetGuid);
+ }
+
+ /// <summary>
+ /// Write GUID array.
+ /// </summary>
+ /// <param name="vals">Values.</param>
+ /// <param name="stream">Stream.</param>
+ public static void WriteGuidArray(Guid[] vals, IPortableStream stream)
+ {
+ stream.WriteInt(vals.Length);
+
+ foreach (Guid val in vals)
+ {
+ stream.WriteByte(TypeGuid);
+
+ WriteGuid(val, stream);
+ }
+ }
+
+ /// <summary>
+ /// Write GUID array.
+ /// </summary>
+ /// <param name="vals">Values.</param>
+ /// <param name="stream">Stream.</param>
+ public static void WriteGuidArray(Guid?[] vals, IPortableStream stream)
+ {
+ stream.WriteInt(vals.Length);
+
+ foreach (Guid? val in vals)
+ {
+ if (val.HasValue)
+ {
+ stream.WriteByte(TypeGuid);
+
+ WriteGuid(val.Value, stream);
+ }
+ else
+ stream.WriteByte(HdrNull);
+ }
+ }
+
+ /**
+ * <summary>Read GUID array.</summary>
+ * <param name="stream">Stream.</param>
+ * <returns>GUID array.</returns>
+ */
+ public static Guid?[] ReadGuidArray(IPortableStream stream)
+ {
+ int len = stream.ReadInt();
+
+ Guid?[] vals = new Guid?[len];
+
+ for (int i = 0; i < len; i++)
+ vals[i] = ReadGuid(stream);
+
+ return vals;
+ }
+
+ /// <summary>
+ /// Write array.
+ /// </summary>
+ /// <param name="val">Array.</param>
+ /// <param name="ctx">Write context.</param>
+ /// <param name="typed">Typed flag.</param>
+ public static void WriteArray(Array val, PortableWriterImpl ctx, bool typed)
+ {
+ IPortableStream stream = ctx.Stream;
+
+ if (typed)
+ stream.WriteInt(ObjTypeId);
+
+ stream.WriteInt(val.Length);
+
+ for (int i = 0; i < val.Length; i++)
+ ctx.Write(val.GetValue(i));
+ }
+
+ /// <summary>
+ /// Read array.
+ /// </summary>
+ /// <param name="ctx">Read context.</param>
+ /// <param name="typed">Typed flag.</param>
+ /// <param name="elementType">Type of the element.</param>
+ /// <returns>Array.</returns>
+ public static object ReadArray(PortableReaderImpl ctx, bool typed, Type elementType)
+ {
+ Func<PortableReaderImpl, bool, object> result;
+
+ if (!ArrayReaders.TryGetValue(elementType, out result))
+ result = ArrayReaders.GetOrAdd(elementType, t =>
+ DelegateConverter.CompileFunc<Func<PortableReaderImpl, bool, object>>(null,
+ MtdhReadGenericArray.MakeGenericMethod(t),
+ new[] {typeof (PortableReaderImpl), typeof (bool)}, new[] {false, false, true}));
+
+ return result(ctx, typed);
+ }
+
+ /// <summary>
+ /// Read array.
+ /// </summary>
+ /// <param name="ctx">Read context.</param>
+ /// <param name="typed">Typed flag.</param>
+ /// <returns>Array.</returns>
+ public static T[] ReadGenericArray<T>(PortableReaderImpl ctx, bool typed)
+ {
+ IPortableStream stream = ctx.Stream;
+
+ if (typed)
+ stream.ReadInt();
+
+ int len = stream.ReadInt();
+
+ var vals = new T[len];
+
+ for (int i = 0; i < len; i++)
+ vals[i] = ctx.Deserialize<T>();
+
+ return vals;
+ }
+
+ /**
+ * <summary>Read DateTime array.</summary>
+ * <param name="stream">Stream.</param>
+ * <param name="local">Local flag.</param>
+ * <returns>Array.</returns>
+ */
+ public static DateTime?[] ReadDateArray(IPortableStream stream, bool local)
+ {
+ int len = stream.ReadInt();
+
+ DateTime?[] vals = new DateTime?[len];
+
+ for (int i = 0; i < len; i++)
+ vals[i] = stream.ReadByte() == HdrNull ? null : ReadDate(stream, local);
+
+ return vals;
+ }
+
+ /**
+ * <summary>Write collection.</summary>
+ * <param name="val">Value.</param>
+ * <param name="ctx">Write context.</param>
+ */
+ public static void WriteCollection(ICollection val, PortableWriterImpl ctx)
+ {
+ byte colType = val.GetType() == typeof(ArrayList) ? CollectionArrayList : CollectionCustom;
+
+ WriteTypedCollection(val, ctx, colType);
+ }
+
+ /**
+ * <summary>Write non-null collection with known type.</summary>
+ * <param name="val">Value.</param>
+ * <param name="ctx">Write context.</param>
+ * <param name="colType">Collection type.</param>
+ */
+ public static void WriteTypedCollection(ICollection val, PortableWriterImpl ctx, byte colType)
+ {
+ ctx.Stream.WriteInt(val.Count);
+
+ ctx.Stream.WriteByte(colType);
+
+ foreach (object elem in val)
+ ctx.Write(elem);
+ }
+
+ /**
+ * <summary>Read collection.</summary>
+ * <param name="ctx">Context.</param>
+ * <param name="factory">Factory delegate.</param>
+ * <param name="adder">Adder delegate.</param>
+ * <returns>Collection.</returns>
+ */
+ public static ICollection ReadCollection(PortableReaderImpl ctx,
+ PortableCollectionFactory factory, PortableCollectionAdder adder)
+ {
+ if (factory == null)
+ factory = PortableSystemHandlers.CreateArrayList;
+
+ if (adder == null)
+ adder = PortableSystemHandlers.AddToArrayList;
+
+ IPortableStream stream = ctx.Stream;
+
+ int len = stream.ReadInt();
+
+ ctx.Stream.Seek(1, SeekOrigin.Current);
+
+ ICollection res = factory.Invoke(len);
+
+ for (int i = 0; i < len; i++)
+ adder.Invoke(res, ctx.Deserialize<object>());
+
+ return res;
+ }
+
+ /**
+ * <summary>Write generic collection.</summary>
+ * <param name="val">Value.</param>
+ * <param name="ctx">Write context.</param>
+ */
+ public static void WriteGenericCollection<T>(ICollection<T> val, PortableWriterImpl ctx)
+ {
+ Type type = val.GetType().GetGenericTypeDefinition();
+
+ byte colType;
+
+ if (type == typeof(List<>))
+ colType = CollectionArrayList;
+ else if (type == typeof(LinkedList<>))
+ colType = CollectionLinkedList;
+ else if (type == typeof(HashSet<>))
+ colType = CollectionHashSet;
+ else if (type == typeof(SortedSet<>))
+ colType = CollectionSortedSet;
+ else
+ colType = CollectionCustom;
+
+ WriteTypedGenericCollection(val, ctx, colType);
+ }
+
+ /**
+ * <summary>Write generic non-null collection with known type.</summary>
+ * <param name="val">Value.</param>
+ * <param name="ctx">Write context.</param>
+ * <param name="colType">Collection type.</param>
+ */
+ public static void WriteTypedGenericCollection<T>(ICollection<T> val, PortableWriterImpl ctx,
+ byte colType)
+ {
+ ctx.Stream.WriteInt(val.Count);
+
+ ctx.Stream.WriteByte(colType);
+
+ foreach (T elem in val)
+ ctx.Write(elem);
+ }
+
+ /**
+ * <summary>Read generic collection.</summary>
+ * <param name="ctx">Context.</param>
+ * <param name="factory">Factory delegate.</param>
+ * <returns>Collection.</returns>
+ */
+ public static ICollection<T> ReadGenericCollection<T>(PortableReaderImpl ctx,
+ PortableGenericCollectionFactory<T> factory)
+ {
+ int len = ctx.Stream.ReadInt();
+
+ if (len >= 0)
+ {
+ byte colType = ctx.Stream.ReadByte();
+
+ if (factory == null)
+ {
+ // Need to detect factory automatically.
+ if (colType == CollectionLinkedList)
+ factory = PortableSystemHandlers.CreateLinkedList<T>;
+ else if (colType == CollectionHashSet)
+ factory = PortableSystemHandlers.CreateHashSet<T>;
+ else if (colType == CollectionSortedSet)
+ factory = PortableSystemHandlers.CreateSortedSet<T>;
+ else
+ factory = PortableSystemHandlers.CreateList<T>;
+ }
+
+ ICollection<T> res = factory.Invoke(len);
+
+ for (int i = 0; i < len; i++)
+ res.Add(ctx.Deserialize<T>());
+
+ return res;
+ }
+ return null;
+ }
+
+ /**
+ * <summary>Write dictionary.</summary>
+ * <param name="val">Value.</param>
+ * <param name="ctx">Write context.</param>
+ */
+ public static void WriteDictionary(IDictionary val, PortableWriterImpl ctx)
+ {
+ byte dictType = val.GetType() == typeof(Hashtable) ? MapHashMap : MapCustom;
+
+ WriteTypedDictionary(val, ctx, dictType);
+ }
+
+ /**
+ * <summary>Write non-null dictionary with known type.</summary>
+ * <param name="val">Value.</param>
+ * <param name="ctx">Write context.</param>
+ * <param name="dictType">Dictionary type.</param>
+ */
+ public static void WriteTypedDictionary(IDictionary val, PortableWriterImpl ctx, byte dictType)
+ {
+ ctx.Stream.WriteInt(val.Count);
+
+ ctx.Stream.WriteByte(dictType);
+
+ foreach (DictionaryEntry entry in val)
+ {
+ ctx.Write(entry.Key);
+ ctx.Write(entry.Value);
+ }
+ }
+
+ /**
+ * <summary>Read dictionary.</summary>
+ * <param name="ctx">Context.</param>
+ * <param name="factory">Factory delegate.</param>
+ * <returns>Dictionary.</returns>
+ */
+ public static IDictionary ReadDictionary(PortableReaderImpl ctx,
+ PortableDictionaryFactory factory)
+ {
+ if (factory == null)
+ factory = PortableSystemHandlers.CreateHashtable;
+
+ IPortableStream stream = ctx.Stream;
+
+ int len = stream.ReadInt();
+
+ ctx.Stream.Seek(1, SeekOrigin.Current);
+
+ IDictionary res = factory.Invoke(len);
+
+ for (int i = 0; i < len; i++)
+ {
+ object key = ctx.Deserialize<object>();
+ object val = ctx.Deserialize<object>();
+
+ res[key] = val;
+ }
+
+ return res;
+ }
+
+ /**
+ * <summary>Write generic dictionary.</summary>
+ * <param name="val">Value.</param>
+ * <param name="ctx">Write context.</param>
+ */
+ public static void WriteGenericDictionary<TK, TV>(IDictionary<TK, TV> val, PortableWriterImpl ctx)
+ {
+ Type type = val.GetType().GetGenericTypeDefinition();
+
+ byte dictType;
+
+ if (type == typeof(Dictionary<,>))
+ dictType = MapHashMap;
+ else if (type == typeof(SortedDictionary<,>))
+ dictType = MapSortedMap;
+ else if (type == typeof(ConcurrentDictionary<,>))
+ dictType = MapConcurrentHashMap;
+ else
+ dictType = MapCustom;
+
+ WriteTypedGenericDictionary(val, ctx, dictType);
+ }
+
+ /**
+ * <summary>Write generic non-null dictionary with known type.</summary>
+ * <param name="val">Value.</param>
+ * <param name="ctx">Write context.</param>
+ * <param name="dictType">Dictionary type.</param>
+ */
+ public static void WriteTypedGenericDictionary<TK, TV>(IDictionary<TK, TV> val,
+ PortableWriterImpl ctx, byte dictType)
+ {
+ ctx.Stream.WriteInt(val.Count);
+
+ ctx.Stream.WriteByte(dictType);
+
+ foreach (KeyValuePair<TK, TV> entry in val)
+ {
+ ctx.Write(entry.Key);
+ ctx.Write(entry.Value);
+ }
+ }
+
+ /**
+ * <summary>Read generic dictionary.</summary>
+ * <param name="ctx">Context.</param>
+ * <param name="factory">Factory delegate.</param>
+ * <returns>Collection.</returns>
+ */
+ public static IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(PortableReaderImpl ctx,
+ PortableGenericDictionaryFactory<TK, TV> factory)
+ {
+ int len = ctx.Stream.ReadInt();
+
+ if (len >= 0)
+ {
+ byte colType = ctx.Stream.ReadByte();
+
+ if (factory == null)
+ {
+ if (colType == MapSortedMap)
+ factory = PortableSystemHandlers.CreateSortedDictionary<TK, TV>;
+ else if (colType == MapConcurrentHashMap)
+ factory = PortableSystemHandlers.CreateConcurrentDictionary<TK, TV>;
+ else
+ factory = PortableSystemHandlers.CreateDictionary<TK, TV>;
+ }
+
+ IDictionary<TK, TV> res = factory.Invoke(len);
+
+ for (int i = 0; i < len; i++)
+ {
+ TK key = ctx.Deserialize<TK>();
+ TV val = ctx.Deserialize<TV>();
+
+ res[key] = val;
+ }
+
+ return res;
+ }
+ return null;
+ }
+
+ /**
+ * <summary>Write map entry.</summary>
+ * <param name="ctx">Write context.</param>
+ * <param name="val">Value.</param>
+ */
+ public static void WriteMapEntry(PortableWriterImpl ctx, DictionaryEntry val)
+ {
+ ctx.Write(val.Key);
+ ctx.Write(val.Value);
+ }
+
+ /**
+ * <summary>Read map entry.</summary>
+ * <param name="ctx">Context.</param>
+ * <returns>Map entry.</returns>
+ */
+ public static DictionaryEntry ReadMapEntry(PortableReaderImpl ctx)
+ {
+ object key = ctx.Deserialize<object>();
+ object val = ctx.Deserialize<object>();
+
+ return new DictionaryEntry(key, val);
+ }
+
+ /**
+ * <summary>Write portable object.</summary>
+ * <param name="stream">Stream.</param>
+ * <param name="val">Value.</param>
+ */
+ public static void WritePortable(IPortableStream stream, PortableUserObject val)
+ {
+ WriteByteArray(val.Data, stream);
+
+ stream.WriteInt(val.Offset);
+ }
+
+ /// <summary>
+ /// Write enum.
+ /// </summary>
+ /// <param name="stream">Stream.</param>
+ /// <param name="val">Value.</param>
+ public static void WriteEnum(IPortableStream stream, Enum val)
+ {
+ if (Enum.GetUnderlyingType(val.GetType()) == TypInt)
+ {
+ stream.WriteInt(ObjTypeId);
+ stream.WriteInt((int) (object) val);
+ }
+ else
+ throw new PortableException("Only Int32 underlying type is supported for enums: " +
+ val.GetType().Name);
+ }
+
+ /// <summary>
+ /// Read enum.
+ /// </summary>
+ /// <param name="stream">Stream.</param>
+ /// <returns>Enumeration.</returns>
+ public static T ReadEnum<T>(IPortableStream stream)
+ {
+ if (!typeof(T).IsEnum || Enum.GetUnderlyingType(typeof(T)) == TypInt)
+ {
+ stream.ReadInt();
+
+ return TypeCaster<T>.Cast(stream.ReadInt());
+ }
+
+ throw new PortableException("Only Int32 underlying type is supported for enums: " +
+ typeof (T).Name);
+ }
+
+ /**
+ * <summary>Gets type key.</summary>
+ * <param name="userType">User type flag.</param>
+ * <param name="typeId">Type ID.</param>
+ * <returns>Type key.</returns>
+ */
+ public static long TypeKey(bool userType, int typeId)
+ {
+ long res = typeId;
+
+ if (userType)
+ res |= (long)1 << 32;
+
+ return res;
+ }
+
+ /**
+ * <summary>Get string hash code.</summary>
+ * <param name="val">Value.</param>
+ * <returns>Hash code.</returns>
+ */
+ public static int GetStringHashCode(string val)
+ {
+ if (val == null)
+ return 0;
+ int hash = 0;
+
+ for (int i = 0; i < val.Length; i++)
+ {
+ char c = val[i];
+
+ if ('A' <= c && c <= 'Z')
+ c = (char)(c | 0x20);
+
+ hash = 31 * hash + c;
+ }
+
+ return hash;
+ }
+
+ public static string CleanFieldName(string fieldName)
+ {
+ if (fieldName.StartsWith("<", StringComparison.Ordinal)
+ && fieldName.EndsWith(">k__BackingField", StringComparison.Ordinal))
+ return fieldName.Substring(1, fieldName.IndexOf(">", StringComparison.Ordinal) - 1);
+
+ return fieldName;
+ }
+
+ /**
+ * <summary>Check whether this is predefined type.</summary>
+ * <param name="hdr">Header.</param>
+ * <returns>True is this is one of predefined types with special semantics.</returns>
+ */
+ public static bool IsPredefinedType(byte hdr)
+ {
+ switch (hdr)
+ {
+ case TypeByte:
+ case TypeShort:
+ case TypeInt:
+ case TypeLong:
+ case TypeFloat:
+ case TypeDouble:
+ case TypeChar:
+ case TypeBool:
+ case TypeDecimal:
+ case TypeString:
+ case TypeGuid:
+ case TypeDate:
+ case TypeEnum:
+ case TypeArrayByte:
+ case TypeArrayShort:
+ case TypeArrayInt:
+ case TypeArrayLong:
+ case TypeArrayFloat:
+ case TypeArrayDouble:
+ case TypeArrayChar:
+ case TypeArrayBool:
+ case TypeArrayDecimal:
+ case TypeArrayString:
+ case TypeArrayGuid:
+ case TypeArrayDate:
+ case TypeArrayEnum:
+ case TypeArray:
+ case TypeCollection:
+ case TypeDictionary:
+ case TypeMapEntry:
+ case TypePortable:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ /**
+ * <summary>Convert type name.</summary>
+ * <param name="typeName">Type name.</param>
+ * <param name="converter">Converter.</param>
+ * <returns>Converted name.</returns>
+ */
+ public static string ConvertTypeName(string typeName, IPortableNameMapper converter)
+ {
+ var typeName0 = typeName;
+
+ try
+ {
+ if (converter != null)
+ typeName = converter.GetTypeName(typeName);
+ }
+ catch (Exception e)
+ {
+ throw new PortableException("Failed to convert type name due to converter exception " +
+ "[typeName=" + typeName + ", converter=" + converter + ']', e);
+ }
+
+ if (typeName == null)
+ throw new PortableException("Name converter returned null name for type [typeName=" +
+ typeName0 + ", converter=" + converter + "]");
+
+ return typeName;
+ }
+
+ /**
+ * <summary>Convert field name.</summary>
+ * <param name="fieldName">Field name.</param>
+ * <param name="converter">Converter.</param>
+ * <returns>Converted name.</returns>
+ */
+ public static string ConvertFieldName(string fieldName, IPortableNameMapper converter)
+ {
+ var fieldName0 = fieldName;
+
+ try
+ {
+ if (converter != null)
+ fieldName = converter.GetFieldName(fieldName);
+ }
+ catch (Exception e)
+ {
+ throw new PortableException("Failed to convert field name due to converter exception " +
+ "[fieldName=" + fieldName + ", converter=" + converter + ']', e);
+ }
+
+ if (fieldName == null)
+ throw new PortableException("Name converter returned null name for field [fieldName=" +
+ fieldName0 + ", converter=" + converter + "]");
+
+ return fieldName;
+ }
+
+ /**
+ * <summary>Extract simple type name.</summary>
+ * <param name="typeName">Type name.</param>
+ * <returns>Simple type name.</returns>
+ */
+ public static string SimpleTypeName(string typeName)
+ {
+ int idx = typeName.LastIndexOf('.');
+
+ return idx < 0 ? typeName : typeName.Substring(idx + 1);
+ }
+
+ /**
+ * <summary>Resolve type ID.</summary>
+ * <param name="typeName">Type name.</param>
+ * <param name="nameMapper">Name mapper.</param>
+ * <param name="idMapper">ID mapper.</param>
+ */
+ public static int TypeId(string typeName, IPortableNameMapper nameMapper,
+ IPortableIdMapper idMapper)
+ {
+ Debug.Assert(typeName != null);
+
+ typeName = ConvertTypeName(typeName, nameMapper);
+
+ int id = 0;
+
+ if (idMapper != null)
+ {
+ try
+ {
+ id = idMapper.GetTypeId(typeName);
+ }
+ catch (Exception e)
+ {
+ throw new PortableException("Failed to resolve type ID due to ID mapper exception " +
+ "[typeName=" + typeName + ", idMapper=" + idMapper + ']', e);
+ }
+ }
+
+ if (id == 0)
+ id = GetStringHashCode(typeName);
+
+ return id;
+ }
+
+ /**
+ * <summary>Resolve field ID.</summary>
+ * <param name="typeId">Type ID.</param>
+ * <param name="fieldName">Field name.</param>
+ * <param name="nameMapper">Name mapper.</param>
+ * <param name="idMapper">ID mapper.</param>
+ */
+ public static int FieldId(int typeId, string fieldName, IPortableNameMapper nameMapper,
+ IPortableIdMapper idMapper)
+ {
+ Debug.Assert(typeId != 0);
+ Debug.Assert(fieldName != null);
+
+ fieldName = ConvertFieldName(fieldName, nameMapper);
+
+ int id = 0;
+
+ if (idMapper != null)
+ {
+ try
+ {
+ id = idMapper.GetFieldId(typeId, fieldName);
+ }
+ catch (Exception e)
+ {
+ throw new PortableException("Failed to resolve field ID due to ID mapper exception " +
+ "[typeId=" + typeId + ", fieldName=" + fieldName + ", idMapper=" + idMapper + ']', e);
+ }
+ }
+
+ if (id == 0)
+ id = GetStringHashCode(fieldName);
+
+ if (id == 0)
+ throw new PortableException("Field ID is zero (please provide ID mapper or change field name) " +
+ "[typeId=" + typeId + ", fieldName=" + fieldName + ", idMapper=" + idMapper + ']');
+
+ return id;
+ }
+
+ /**
+ * <summary>Get fields map for the given object.</summary>
+ * <param name="stream">Stream.</param>
+ * <param name="typeId">Type ID.</param>
+ * <param name="rawDataOffset">Raw data offset.</param>
+ * <returns>Dictionary with field ID as key and field position as value.</returns>
+ */
+ public static IDictionary<int, int> ObjectFields(IPortableStream stream, int typeId, int rawDataOffset)
+ {
- int endPos = stream.Position + rawDataOffset - 18;
++ int endPos = stream.Position + rawDataOffset - FullHdrLen;
+
+ // First loop detects amount of fields in the object.
+ int retPos = stream.Position;
+ int cnt = 0;
+
+ while (stream.Position < endPos)
+ {
+ cnt++;
+
+ stream.Seek(4, SeekOrigin.Current);
+ int len = stream.ReadInt();
+
+ stream.Seek(stream.Position + len, SeekOrigin.Begin);
+ }
+
+ if (cnt == 0)
+ return EmptyFields;
+
+ stream.Seek(retPos, SeekOrigin.Begin);
+
+ IDictionary<int, int> fields = new Dictionary<int, int>(cnt);
+
+ // Second loop populates fields.
+ while (stream.Position < endPos)
+ {
+ int id = stream.ReadInt();
+ int len = stream.ReadInt();
+
+ if (fields.ContainsKey(id))
+ throw new PortableException("Object contains duplicate field IDs [typeId=" +
+ typeId + ", fieldId=" + id + ']');
+
+ fields[id] = stream.Position; // Add field ID and length.
+
+ stream.Seek(stream.Position + len, SeekOrigin.Begin);
+ }
+
+ return fields;
+ }
+
+ /// <summary>
+ /// Compare contents of two byte array chunks.
+ /// </summary>
+ /// <param name="arr1">Array 1.</param>
+ /// <param name="offset1">Offset 1.</param>
+ /// <param name="len1">Length 1.</param>
+ /// <param name="arr2">Array 2.</param>
+ /// <param name="offset2">Offset 2.</param>
+ /// <param name="len2">Length 2.</param>
+ /// <returns>True if array chunks are equal.</returns>
+ public static bool CompareArrays(byte[] arr1, int offset1, int len1, byte[] arr2, int offset2, int len2)
+ {
+ if (len1 == len2)
+ {
+ for (int i = 0; i < len1; i++)
+ {
+ if (arr1[offset1 + i] != arr2[offset2 + i])
+ return false;
+ }
+
+ return true;
+ }
+ return false;
+ }
+
+ /// <summary>
+ /// Write object which is not necessary portable.
+ /// </summary>
+ /// <param name="writer">Writer.</param>
+ /// <param name="obj">Object.</param>
+ public static void WritePortableOrSerializable<T>(PortableWriterImpl writer, T obj)
+ {
+ if (writer.IsPortable(obj))
+ {
+ writer.WriteBoolean(true);
+
+ writer.WriteObject(obj);
+ }
+ else
+ {
+ writer.WriteBoolean(false);
+
+ WriteSerializable(writer, obj);
+ }
+ }
+
+ /// <summary>
+ /// Writes a serializable object.
+ /// </summary>
+ /// <param name="writer">Writer.</param>
+ /// <param name="obj">Object.</param>
+ public static void WriteSerializable<T>(PortableWriterImpl writer, T obj)
+ {
+ new BinaryFormatter().Serialize(new PortableStreamAdapter(writer.Stream), obj);
+ }
+
+ /// <summary>
+ /// Read object which is not necessary portable.
+ /// </summary>
+ /// <param name="reader">Reader.</param>
+ /// <returns>Object.</returns>
+ public static T ReadPortableOrSerializable<T>(PortableReaderImpl reader)
+ {
+ return reader.ReadBoolean()
+ ? reader.ReadObject<T>()
+ : ReadSerializable<T>(reader);
+ }
+
+ /// <summary>
+ /// Reads a serializable object.
+ /// </summary>
+ /// <param name="reader">Reader.</param>
+ /// <returns>Object.</returns>
+ public static T ReadSerializable<T>(PortableReaderImpl reader)
+ {
+ return (T) new BinaryFormatter().Deserialize(new PortableStreamAdapter(reader.Stream), null);
+ }
+
+ /// <summary>
+ /// Writes wrapped invocation result.
+ /// </summary>
+ /// <param name="writer">Writer.</param>
+ /// <param name="success">Success flag.</param>
+ /// <param name="res">Result.</param>
+ [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
+ public static void WriteWrappedInvocationResult(PortableWriterImpl writer, bool success, object res)
+ {
+ var pos = writer.Stream.Position;
+
+ try
+ {
+ if (success)
+ writer.WriteBoolean(true);
+ else
+ {
+ writer.WriteBoolean(false); // Call failed.
+ writer.WriteBoolean(true); // Exception serialized sucessfully.
+ }
+
+ writer.Write(new PortableResultWrapper(res));
+ }
+ catch (Exception marshErr)
+ {
+ // Failed to serialize result, fallback to plain string.
+ writer.Stream.Seek(pos, SeekOrigin.Begin);
+
+ writer.WriteBoolean(false); // Call failed.
+ writer.WriteBoolean(false); // Cannot serialize result or exception.
+
+ if (success)
+ {
+ writer.WriteString("Call completed successfully, but result serialization failed [resultType=" +
+ res.GetType().Name + ", serializationErrMsg=" + marshErr.Message + ']');
+ }
+ else
+ {
+ writer.WriteString("Call completed with error, but error serialization failed [errType=" +
+ res.GetType().Name + ", serializationErrMsg=" + marshErr.Message + ']');
+ }
+ }
+ }
+ /// <summary>
+ /// Writes invocation result.
+ /// </summary>
+ /// <param name="writer">Writer.</param>
+ /// <param name="success">Success flag.</param>
+ /// <param name="res">Result.</param>
+ [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
+ public static void WriteInvocationResult(PortableWriterImpl writer, bool success, object res)
+ {
+ var pos = writer.Stream.Position;
+
+ try
+ {
+ if (success)
+ writer.WriteBoolean(true);
+ else
+ {
+ writer.WriteBoolean(false); // Call failed.
+ writer.WriteBoolean(true); // Exception serialized sucessfully.
+ }
+
+ writer.Write(res);
+ }
+ catch (Exception marshErr)
+ {
+ // Failed to serialize result, fallback to plain string.
+ writer.Stream.Seek(pos, SeekOrigin.Begin);
+
+ writer.WriteBoolean(false); // Call failed.
+ writer.WriteBoolean(false); // Cannot serialize result or exception.
+
+ if (success)
+ {
+ writer.WriteString("Call completed successfully, but result serialization failed [resultType=" +
+ res.GetType().Name + ", serializationErrMsg=" + marshErr.Message + ']');
+ }
+ else
+ {
+ writer.WriteString("Call completed with error, but error serialization failed [errType=" +
+ res.GetType().Name + ", serializationErrMsg=" + marshErr.Message + ']');
+ }
+ }
+ }
+
+ /// <summary>
+ /// Reads wrapped invocation result.
+ /// </summary>
+ /// <param name="reader">Reader.</param>
+ /// <param name="err">Error.</param>
+ /// <returns>Result.</returns>
+ public static object ReadWrappedInvocationResult(PortableReaderImpl reader, out object err)
+ {
+ err = null;
+
+ if (reader.ReadBoolean())
+ return reader.ReadObject<PortableResultWrapper>().Result;
+
+ if (reader.ReadBoolean())
+ err = (Exception) reader.ReadObject<PortableResultWrapper>().Result;
+ else
+ err = ExceptionUtils.GetException(reader.ReadString(), reader.ReadString());
+
+ return null;
+ }
+
+ /// <summary>
+ /// Reads invocation result.
+ /// </summary>
+ /// <param name="reader">Reader.</param>
+ /// <param name="err">Error.</param>
+ /// <returns>Result.</returns>
+ public static object ReadInvocationResult(PortableReaderImpl reader, out object err)
+ {
+ err = null;
+
+ if (reader.ReadBoolean())
+ return reader.ReadObject<object>();
+
+ if (reader.ReadBoolean())
+ err = reader.ReadObject<object>();
+ else
+ err = ExceptionUtils.GetException(reader.ReadString(), reader.ReadString());
+
+ return null;
+ }
+
++ /// <summary>
++ /// Validate protocol version.
++ /// </summary>
++ /// <param name="stream">Stream.</param>
++ public static void ValidateProtocolVersion(IPortableStream stream)
++ {
++ byte ver = stream.ReadByte();
++
++ if (ver != ProtoVer)
++ throw new PortableException("Unsupported protocol version: " + ver);
++ }
++
+ /**
+ * <summary>Convert date to Java ticks.</summary>
+ * <param name="date">Date</param>
+ * <param name="high">High part (milliseconds).</param>
+ * <param name="low">Low part (nanoseconds)</param>
+ */
+ private static void ToJavaDate(DateTime date, out long high, out int low)
+ {
+ long diff = date.ToUniversalTime().Ticks - JavaDateTicks;
+
+ high = diff / TimeSpan.TicksPerMillisecond;
+
+ low = (int)(diff % TimeSpan.TicksPerMillisecond) * 100;
+ }
+
+ /**
+ * <summary>Convert Java ticks to date.</summary>
+ * <param name="high">High part (milliseconds).</param>
+ * <param name="low">Low part (nanoseconds).</param>
+ * <param name="local">Whether the time should be treaten as local.</param>
+ * <returns>Date.</returns>
+ */
+ private static DateTime ToDotNetDate(long high, int low, bool local)
+ {
+ DateTime res =
+ new DateTime(JavaDateTicks + high * TimeSpan.TicksPerMillisecond + low / 100, DateTimeKind.Utc);
+
+ return local ? res.ToLocalTime() : res;
+ }
+
+ /// <summary>
+ /// Read additional configuration from the stream.
+ /// </summary>
+ /// <param name="reader">Reader.</param>
+ /// <param name="assemblies">Assemblies.</param>
+ /// <param name="cfg">Portable configuration.</param>
+ public static void ReadConfiguration(PortableReaderImpl reader, out ICollection<string> assemblies, out PortableConfiguration cfg)
+ {
+ if (reader.ReadBoolean())
+ {
+ int assemblyCnt = reader.ReadInt();
+
+ assemblies = new List<string>(assemblyCnt);
+
+ for (int i = 0; i < assemblyCnt; i++)
+ assemblies.Add(reader.ReadObject<string>());
+ }
+ else
+ assemblies = null;
+
+ if (reader.ReadBoolean())
+ {
+ cfg = new PortableConfiguration();
+
+ // Read portable types in full form.
+ if (reader.ReadBoolean())
+ {
+ int typesCnt = reader.ReadInt();
+
+ cfg.TypeConfigurations = new List<PortableTypeConfiguration>();
+
+ for (int i = 0; i < typesCnt; i++)
+ {
+ PortableTypeConfiguration typCfg = new PortableTypeConfiguration();
+
+ typCfg.AssemblyName = reader.ReadString();
+ typCfg.TypeName = reader.ReadString();
+ typCfg.NameMapper = (IPortableNameMapper)CreateInstance(reader.ReadString());
+ typCfg.IdMapper = (IPortableIdMapper)CreateInstance(reader.ReadString());
+ typCfg.Serializer = (IPortableSerializer)CreateInstance(reader.ReadString());
+ typCfg.AffinityKeyFieldName = reader.ReadString();
+ typCfg.MetadataEnabled = reader.ReadObject<bool?>();
+ typCfg.KeepDeserialized = reader.ReadObject<bool?>();
+
+ cfg.TypeConfigurations.Add(typCfg);
+ }
+ }
+
+ // Read portable types in compact form.
+ if (reader.ReadBoolean())
+ {
+ int typesCnt = reader.ReadInt();
+
+ cfg.Types = new List<string>(typesCnt);
+
+ for (int i = 0; i < typesCnt; i++)
+ cfg.Types.Add(reader.ReadString());
+ }
+
+ // Read the rest.
+ cfg.DefaultNameMapper = (IPortableNameMapper)CreateInstance(reader.ReadString());
+ cfg.DefaultIdMapper = (IPortableIdMapper)CreateInstance(reader.ReadString());
+ cfg.DefaultSerializer = (IPortableSerializer)CreateInstance(reader.ReadString());
+ cfg.DefaultMetadataEnabled = reader.ReadBoolean();
+ cfg.DefaultKeepDeserialized = reader.ReadBoolean();
+ }
+ else
+ cfg = null;
+ }
+
+ /// <summary>
+ /// Create new instance of specified class.
+ /// </summary>
+ /// <param name="typeName">Name of the type.</param>
+ /// <returns>New Instance.</returns>
+ public static object CreateInstance(string typeName)
+ {
+ if (typeName == null)
+ return null;
+
+ foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
+ {
+ object instance = assembly.CreateInstance(typeName);
+
+ if (instance != null)
+ return instance;
+ }
+
+ throw new PortableException("Failed to find class: " + typeName);
+ }
+
+ /// <summary>
+ /// Reverses the byte order of an unsigned long.
+ /// </summary>
+ private static ulong ReverseByteOrder(ulong l)
+ {
+ // Fastest way would be to use bswap processor instruction.
+ return ((l >> 56) & 0x00000000000000FF) | ((l >> 40) & 0x000000000000FF00) |
+ ((l >> 24) & 0x0000000000FF0000) | ((l >> 8) & 0x00000000FF000000) |
+ ((l << 8) & 0x000000FF00000000) | ((l << 24) & 0x0000FF0000000000) |
+ ((l << 40) & 0x00FF000000000000) | ((l << 56) & 0xFF00000000000000);
+ }
+
+ /// <summary>
+ /// Struct with .Net-style Guid memory layout.
+ /// </summary>
+ [StructLayout(LayoutKind.Sequential)]
+ private struct GuidAccessor
+ {
+ public readonly ulong ABC;
+ public readonly ulong DEGHIJK;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="GuidAccessor"/> struct.
+ /// </summary>
+ /// <param name="val">The value.</param>
+ public GuidAccessor(JavaGuid val)
+ {
+ var l = val.CBA;
+
+ ABC = ((l >> 32) & 0x00000000FFFFFFFF) | ((l << 48) & 0xFFFF000000000000) |
+ ((l << 16) & 0x0000FFFF00000000);
+
+ DEGHIJK = ReverseByteOrder(val.KJIHGED);
+ }
+ }
+
+ /// <summary>
+ /// Struct with Java-style Guid memory layout.
+ /// </summary>
+ [StructLayout(LayoutKind.Sequential)]
+ private struct JavaGuid
+ {
+ public readonly ulong CBA;
+ public readonly ulong KJIHGED;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="JavaGuid"/> struct.
+ /// </summary>
+ /// <param name="val">The value.</param>
+ public unsafe JavaGuid(Guid val)
+ {
+ // .Net returns bytes in the following order: _a(4), _b(2), _c(2), _d, _e, _g, _h, _i, _j, _k.
+ // And _a, _b and _c are always in little endian format irrespective of system configuration.
+ // To be compliant with Java we rearrange them as follows: _c, _b_, a_, _k, _j, _i, _h, _g, _e, _d.
+ var accessor = *((GuidAccessor*)&val);
+
+ var l = accessor.ABC;
+
+ CBA = ((l << 32) & 0xFFFFFFFF00000000) | ((l >> 48) & 0x000000000000FFFF) |
+ ((l >> 16) & 0x00000000FFFF0000);
+
+ KJIHGED = ReverseByteOrder(accessor.DEGHIJK);
+ }
+ }
+ }
+ }
[42/50] [abbrv] ignite git commit: IGNITE-1486: Removed protocol
version as we decided it is not needed.
Posted by vo...@apache.org.
IGNITE-1486: Removed protocol version as we decided it is not needed.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4f1120f1
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4f1120f1
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4f1120f1
Branch: refs/heads/ignite-1651
Commit: 4f1120f1b13396139fd3bb72ecc22772b9e58fb4
Parents: e4dba7b
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Oct 22 12:09:41 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Oct 22 12:09:41 2015 +0300
----------------------------------------------------------------------
.../apache/ignite/internal/IgniteKernal.java | 4 --
.../discovery/GridDiscoveryManager.java | 10 ----
.../marshaller/portable/PortableMarshaller.java | 32 -------------
.../portable/PortableProtocolVersion.java | 41 ----------------
.../resources/META-INF/classnames.properties | 1 -
.../GridDiscoveryManagerAttributesSelfTest.java | 50 --------------------
6 files changed, 138 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f1120f1/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index a4ad469..d7cacab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -204,7 +204,6 @@ import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MARSHALLER;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_NODE_CONSISTENT_ID;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PEER_CLASSLOADING;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PHY_RAM;
-import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PORTABLE_PROTO_VER;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PREFIX;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_RESTART_ENABLED;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_REST_PORT_RANGE;
@@ -1271,9 +1270,6 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
add(ATTR_MARSHALLER, cfg.getMarshaller().getClass().getName());
add(ATTR_USER_NAME, System.getProperty("user.name"));
add(ATTR_GRID_NAME, gridName);
- add(ATTR_PORTABLE_PROTO_VER, cfg.getMarshaller() instanceof PortableMarshaller ?
- ((PortableMarshaller)cfg.getMarshaller()).getProtocolVersion().toString() :
- PortableMarshaller.DFLT_PORTABLE_PROTO_VER.toString());
add(ATTR_PEER_CLASSLOADING, cfg.isPeerClassLoadingEnabled());
add(ATTR_DEPLOYMENT_MODE, cfg.getDeploymentMode());
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f1120f1/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index da934ea..6aba211 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -126,7 +126,6 @@ import static org.apache.ignite.events.EventType.EVT_NODE_SEGMENTED;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_DEPLOYMENT_MODE;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MACS;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PEER_CLASSLOADING;
-import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PORTABLE_PROTO_VER;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_USER_NAME;
import static org.apache.ignite.internal.IgniteVersionUtils.VER;
import static org.apache.ignite.plugin.segmentation.SegmentationPolicy.NOOP;
@@ -983,8 +982,6 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
// Fetch local node attributes once.
String locPreferIpV4 = locNode.attribute("java.net.preferIPv4Stack");
- String locPortableProtoVer = locNode.attribute(ATTR_PORTABLE_PROTO_VER);
-
Object locMode = locNode.attribute(ATTR_DEPLOYMENT_MODE);
int locJvmMajVer = nodeJavaMajorVersion(locNode);
@@ -1039,13 +1036,6 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
", rmtId8=" + U.id8(n.id()) + ", rmtPeerClassLoading=" + rmtP2pEnabled +
", rmtAddrs=" + U.addressesAsString(n) + ']');
}
-
- String rmtPortableProtoVer = n.attribute(ATTR_PORTABLE_PROTO_VER);
-
- // In order to support backward compatibility skip the check for nodes that don't have this attribute.
- if (rmtPortableProtoVer != null && !F.eq(locPortableProtoVer, rmtPortableProtoVer))
- throw new IgniteCheckedException("Remote node has portable protocol version different from local " +
- "[locVersion=" + locPortableProtoVer + ", rmtVersion=" + rmtPortableProtoVer + ']');
}
if (log.isDebugEnabled())
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f1120f1/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java b/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
index e3905cd..3f02c65 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
@@ -32,7 +32,6 @@ import org.apache.ignite.marshaller.MarshallerContext;
import org.apache.ignite.portable.PortableException;
import org.apache.ignite.portable.PortableIdMapper;
import org.apache.ignite.portable.PortableObject;
-import org.apache.ignite.portable.PortableProtocolVersion;
import org.apache.ignite.portable.PortableSerializer;
import org.apache.ignite.portable.PortableTypeConfiguration;
import org.jetbrains.annotations.Nullable;
@@ -77,9 +76,6 @@ import org.jetbrains.annotations.Nullable;
* For information about Spring framework visit <a href="http://www.springframework.org/">www.springframework.org</a>
*/
public class PortableMarshaller extends AbstractMarshaller {
- /** Default portable protocol version. */
- public static final PortableProtocolVersion DFLT_PORTABLE_PROTO_VER = PortableProtocolVersion.VER_1_4_0;
-
/** Class names. */
private Collection<String> clsNames;
@@ -104,9 +100,6 @@ public class PortableMarshaller extends AbstractMarshaller {
/** Keep deserialized flag. */
private boolean keepDeserialized = true;
- /** Protocol version. */
- private PortableProtocolVersion protoVer = DFLT_PORTABLE_PROTO_VER;
-
/** */
private GridPortableMarshaller impl;
@@ -268,31 +261,6 @@ public class PortableMarshaller extends AbstractMarshaller {
}
/**
- * Gets portable protocol version.
- * <p>
- * Defaults to {@link #DFLT_PORTABLE_PROTO_VER}.
- *
- * @return Portable protocol version.
- */
- public PortableProtocolVersion getProtocolVersion() {
- return protoVer;
- }
-
- /**
- * Sets portable protocol version.
- * <p>
- * Defaults to {@link #DFLT_PORTABLE_PROTO_VER}.
- *
- * @param protoVer Portable protocol version.
- */
- public void setProtocolVersion(PortableProtocolVersion protoVer) {
- if (protoVer == null)
- throw new IllegalArgumentException("Wrong portable protocol version: " + protoVer);
-
- this.protoVer = protoVer;
- }
-
- /**
* Returns currently set {@link MarshallerContext}.
*
* @return Marshaller context.
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f1120f1/modules/core/src/main/java/org/apache/ignite/portable/PortableProtocolVersion.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableProtocolVersion.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableProtocolVersion.java
deleted file mode 100644
index 9189b28..0000000
--- a/modules/core/src/main/java/org/apache/ignite/portable/PortableProtocolVersion.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.portable;
-
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Portable protocol version.
- */
-public enum PortableProtocolVersion {
- /** Ignite 1.4.0 release. */
- VER_1_4_0;
-
- /** Enumerated values. */
- private static final PortableProtocolVersion[] VALS = values();
-
- /**
- * Efficiently gets enumerated value from its ordinal.
- *
- * @param ord Ordinal value.
- * @return Enumerated value or {@code null} if ordinal out of range.
- */
- @Nullable public static PortableProtocolVersion fromOrdinal(int ord) {
- return ord >= 0 && ord < VALS.length ? VALS[ord] : null;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f1120f1/modules/core/src/main/resources/META-INF/classnames.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties
index 70c32e5..9376613 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -1575,7 +1575,6 @@ org.apache.ignite.plugin.segmentation.SegmentationResolver
org.apache.ignite.portable.PortableException
org.apache.ignite.portable.PortableInvalidClassException
org.apache.ignite.portable.PortableObject
-org.apache.ignite.portable.PortableProtocolVersion
org.apache.ignite.services.Service
org.apache.ignite.services.ServiceConfiguration
org.apache.ignite.services.ServiceContext
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f1120f1/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
index 82da10f..3c6d53b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
@@ -17,15 +17,10 @@
package org.apache.ignite.internal.managers.discovery;
-import java.lang.reflect.Field;
-import java.util.HashMap;
-import java.util.Map;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.DeploymentMode;
import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgniteNodeAttributes;
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.vm.TcpDiscoveryVmIpFinder;
@@ -159,51 +154,6 @@ public abstract class GridDiscoveryManagerAttributesSelfTest extends GridCommonA
}
/**
- * @throws Exception If failed.
- */
- public void testDifferentPortableProtocolVersions() throws Exception {
- startGridWithPortableProtocolVer("VER_99_99_99");
-
- try {
- startGrid(1);
-
- fail();
- }
- catch (IgniteCheckedException e) {
- if (!e.getCause().getMessage().startsWith("Remote node has portable protocol version different from local"))
- throw e;
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testNullPortableProtocolVersion() throws Exception {
- startGridWithPortableProtocolVer(null);
-
- // Must not fail in order to preserve backward compatibility with the nodes that don't have this property yet.
- startGrid(1);
- }
-
- /**
- * @throws Exception If failed.
- */
- private void startGridWithPortableProtocolVer(String ver) throws Exception {
- Ignite ignite = startGrid(0);
-
- ClusterNode clusterNode = ignite.cluster().localNode();
-
- Field f = clusterNode.getClass().getDeclaredField("attrs");
- f.setAccessible(true);
-
- Map<String, Object> attrs = new HashMap<>((Map<String, Object>)f.get(clusterNode));
-
- attrs.put(IgniteNodeAttributes.ATTR_PORTABLE_PROTO_VER, ver);
-
- f.set(clusterNode, attrs);
- }
-
- /**
* @param preferIpV4 {@code java.net.preferIPv4Stack} system property value.
* @throws Exception If failed.
*/
[33/50] [abbrv] ignite git commit: IGNITE-1693 .Net: Renamed
IMessage.Send(IEnumerable, object) method to "SendAll".
Posted by vo...@apache.org.
IGNITE-1693 .Net: Renamed IMessage.Send(IEnumerable, object) method to "SendAll".
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e0853eae
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e0853eae
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e0853eae
Branch: refs/heads/ignite-1651
Commit: e0853eae7490dd918d600f27a3898f778fea06fc
Parents: 2ed4794
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Tue Oct 20 17:00:26 2015 +0300
Committer: thatcoach <pp...@list.ru>
Committed: Tue Oct 20 17:00:26 2015 +0300
----------------------------------------------------------------------
.../platforms/dotnet/Apache.Ignite.Core.Tests/MessagingTest.cs | 4 ++--
.../dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs | 2 +-
.../platforms/dotnet/Apache.Ignite.Core/Messaging/IMessaging.cs | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e0853eae/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MessagingTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MessagingTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MessagingTest.cs
index 55f2e6c..274c25e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MessagingTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MessagingTest.cs
@@ -447,7 +447,7 @@ namespace Apache.Ignite.Core.Tests
// Multiple messages (receive order is undefined)
MessagingTestHelper.ClearReceived(messages.Count * expectedRepeat);
- msg.Send(messages, topic);
+ msg.SendAll(messages, topic);
MessagingTestHelper.VerifyReceive(cluster, messages, m => m.OrderBy(x => x), expectedRepeat);
// Multiple messages, ordered
@@ -468,7 +468,7 @@ namespace Apache.Ignite.Core.Tests
// this will result in an exception in case of a message
MessagingTestHelper.ClearReceived(0);
- (grid ?? _grid1).GetMessaging().Send(NextMessage(), topic);
+ (grid ?? _grid1).GetMessaging().SendAll(NextMessage(), topic);
Thread.Sleep(MessagingTestHelper.MessageTimeout);
http://git-wip-us.apache.org/repos/asf/ignite/blob/e0853eae/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
index 4ccbc3e..de94c74 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
@@ -86,7 +86,7 @@ namespace Apache.Ignite.Core.Impl.Messaging
}
/** <inheritdoc /> */
- public void Send(IEnumerable messages, object topic = null)
+ public void SendAll(IEnumerable messages, object topic = null)
{
IgniteArgumentCheck.NotNull(messages, "messages");
http://git-wip-us.apache.org/repos/asf/ignite/blob/e0853eae/modules/platforms/dotnet/Apache.Ignite.Core/Messaging/IMessaging.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Messaging/IMessaging.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Messaging/IMessaging.cs
index f846745..de2b0d9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Messaging/IMessaging.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Messaging/IMessaging.cs
@@ -48,7 +48,7 @@ namespace Apache.Ignite.Core.Messaging
/// </summary>
/// <param name="messages">Messages to send.</param>
/// <param name="topic">Topic to send to, null for default topic.</param>
- void Send(IEnumerable messages, object topic = null);
+ void SendAll(IEnumerable messages, object topic = null);
/// <summary>
/// Sends a message with specified topic to the nodes in the underlying cluster group.
[25/50] [abbrv] ignite git commit: IGNITE-1733
Posted by vo...@apache.org.
IGNITE-1733
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/10ef06a1
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/10ef06a1
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/10ef06a1
Branch: refs/heads/ignite-1651
Commit: 10ef06a14245c73cbfe66b744406a0391c4a9c08
Parents: 10cf673
Author: Anton Vinogradov <av...@apache.org>
Authored: Mon Oct 19 18:59:55 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Mon Oct 19 18:59:55 2015 +0300
----------------------------------------------------------------------
examples-lgpl/pom-standalone.xml | 45 +++++++++++++
.../scalar/examples/ScalarScheduleExample.scala | 66 ++++++++++++++++++++
.../ScalarLgplExamplesMultiNodeSelfTest.scala | 33 ++++++++++
.../examples/ScalarLgplExamplesSelfTest.scala | 36 +++++++++++
.../ScalarLgplExamplesSelfTestSuite.scala | 37 +++++++++++
.../scalar/examples/ScalarScheduleExample.scala | 66 --------------------
.../tests/examples/ScalarExamplesSelfTest.scala | 5 --
7 files changed, 217 insertions(+), 71 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/10ef06a1/examples-lgpl/pom-standalone.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/pom-standalone.xml b/examples-lgpl/pom-standalone.xml
index d2a00d1..2e3bf8f 100644
--- a/examples-lgpl/pom-standalone.xml
+++ b/examples-lgpl/pom-standalone.xml
@@ -137,5 +137,50 @@
</plugins>
</build>
</profile>
+
+ <profile>
+ <id>scala</id>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-scalar</artifactId>
+ <version>to_be_replaced_by_ignite_version</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>net.alchim31.maven</groupId>
+ <artifactId>scala-maven-plugin</artifactId>
+ <version>3.2.0</version>
+ <configuration>
+ <jvmArgs>
+ <jvmArg>-Xms512m</jvmArg>
+ <jvmArg>-Xmx1024m</jvmArg>
+ </jvmArgs>
+ </configuration>
+ <executions>
+ <execution>
+ <id>scala-compile-first</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>add-source</goal>
+ <goal>compile</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>scala-test-compile</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>testCompile</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
</project>
http://git-wip-us.apache.org/repos/asf/ignite/blob/10ef06a1/examples-lgpl/src/main/scala/org/apache/ignite/scalar/examples/ScalarScheduleExample.scala
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/scala/org/apache/ignite/scalar/examples/ScalarScheduleExample.scala b/examples-lgpl/src/main/scala/org/apache/ignite/scalar/examples/ScalarScheduleExample.scala
new file mode 100644
index 0000000..8734a23
--- /dev/null
+++ b/examples-lgpl/src/main/scala/org/apache/ignite/scalar/examples/ScalarScheduleExample.scala
@@ -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.
+ */
+
+package org.apache.ignite.scalar.examples
+
+import org.apache.ignite.scalar.scalar
+import org.apache.ignite.scalar.scalar._
+
+/**
+ * Demonstrates a cron-based `Runnable` execution scheduling.
+ * Test runnable object broadcasts a phrase to all cluster nodes every minute
+ * three times with initial scheduling delay equal to five seconds.
+ * <p/>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: `'ignite.{sh|bat} examples/config/example-ignite.xml'`.
+ * <p/>
+ * Alternatively you can run `ExampleNodeStartup` in another JVM which will
+ * start node with `examples/config/example-ignite.xml` configuration.
+ */
+object ScalarScheduleExample extends App {
+ scalar("examples/config/example-ignite.xml") {
+ println()
+ println("Compute schedule example started.")
+
+ val g = ignite$
+
+ var invocations = 0
+
+ // Schedule callable that returns incremented value each time.
+ val fut = ignite$.scheduleLocalCall(
+ () => {
+ invocations += 1
+
+ g.bcastRun(() => {
+ println()
+ println("Howdy! :)")
+ }, null)
+
+ invocations
+ },
+ "{5, 3} * * * * *" // Cron expression.
+ )
+
+ while (!fut.isDone)
+ println(">>> Invocation #: " + fut.get)
+
+ // Prints.
+ println()
+ println(">>> Schedule future is done and has been unscheduled.")
+ println(">>> Check all nodes for hello message output.")
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/10ef06a1/examples-lgpl/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarLgplExamplesMultiNodeSelfTest.scala
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarLgplExamplesMultiNodeSelfTest.scala b/examples-lgpl/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarLgplExamplesMultiNodeSelfTest.scala
new file mode 100644
index 0000000..fca44e3
--- /dev/null
+++ b/examples-lgpl/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarLgplExamplesMultiNodeSelfTest.scala
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.scalar.tests.examples
+
+/**
+ * Scalar examples multi-node self test.
+ */
+class ScalarLgplExamplesMultiNodeSelfTest extends ScalarExamplesSelfTest {
+ /** */
+ protected override def beforeTest() {
+ startRemoteNodes()
+ }
+
+ /** */
+ protected override def getTestTimeout: Long = {
+ 10 * 60 * 1000
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/10ef06a1/examples-lgpl/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarLgplExamplesSelfTest.scala
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarLgplExamplesSelfTest.scala b/examples-lgpl/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarLgplExamplesSelfTest.scala
new file mode 100644
index 0000000..25a5fe4
--- /dev/null
+++ b/examples-lgpl/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarLgplExamplesSelfTest.scala
@@ -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.
+ */
+
+package org.apache.ignite.scalar.tests.examples
+
+import org.apache.ignite.scalar.examples._
+import org.apache.ignite.scalar.scalar
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest
+import org.scalatest.junit.JUnitSuiteLike
+
+/**
+ * Scalar examples self test.
+ */
+class ScalarLgplExamplesSelfTest extends GridAbstractExamplesTest with JUnitSuiteLike {
+ /** */
+ private def EMPTY_ARGS = Array.empty[String]
+
+ /** */
+ def testScalarScheduleCallableExample() {
+ ScalarScheduleExample.main(EMPTY_ARGS)
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/10ef06a1/examples-lgpl/src/test/scala/org/apache/ignite/scalar/testsuites/ScalarLgplExamplesSelfTestSuite.scala
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/test/scala/org/apache/ignite/scalar/testsuites/ScalarLgplExamplesSelfTestSuite.scala b/examples-lgpl/src/test/scala/org/apache/ignite/scalar/testsuites/ScalarLgplExamplesSelfTestSuite.scala
new file mode 100644
index 0000000..4f3195e
--- /dev/null
+++ b/examples-lgpl/src/test/scala/org/apache/ignite/scalar/testsuites/ScalarLgplExamplesSelfTestSuite.scala
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.scalar.testsuites
+
+import org.apache.ignite.IgniteSystemProperties._
+import org.apache.ignite.scalar.tests.examples.{ScalarExamplesMultiNodeSelfTest, ScalarExamplesSelfTest}
+import org.apache.ignite.testframework.GridTestUtils
+import org.junit.runner.RunWith
+import org.scalatest._
+import org.scalatest.junit.JUnitRunner
+
+/**
+ *
+ */
+@RunWith(classOf[JUnitRunner])
+class ScalarLgplExamplesSelfTestSuite extends Suites(
+ new ScalarLgplExamplesSelfTest,
+ new ScalarLgplExamplesMultiNodeSelfTest
+) {
+ System.setProperty(IGNITE_OVERRIDE_MCAST_GRP,
+ GridTestUtils.getNextMulticastGroup(classOf[ScalarLgplExamplesSelfTest]))
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/10ef06a1/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarScheduleExample.scala
----------------------------------------------------------------------
diff --git a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarScheduleExample.scala b/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarScheduleExample.scala
deleted file mode 100644
index 8734a23..0000000
--- a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarScheduleExample.scala
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.scalar.examples
-
-import org.apache.ignite.scalar.scalar
-import org.apache.ignite.scalar.scalar._
-
-/**
- * Demonstrates a cron-based `Runnable` execution scheduling.
- * Test runnable object broadcasts a phrase to all cluster nodes every minute
- * three times with initial scheduling delay equal to five seconds.
- * <p/>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: `'ignite.{sh|bat} examples/config/example-ignite.xml'`.
- * <p/>
- * Alternatively you can run `ExampleNodeStartup` in another JVM which will
- * start node with `examples/config/example-ignite.xml` configuration.
- */
-object ScalarScheduleExample extends App {
- scalar("examples/config/example-ignite.xml") {
- println()
- println("Compute schedule example started.")
-
- val g = ignite$
-
- var invocations = 0
-
- // Schedule callable that returns incremented value each time.
- val fut = ignite$.scheduleLocalCall(
- () => {
- invocations += 1
-
- g.bcastRun(() => {
- println()
- println("Howdy! :)")
- }, null)
-
- invocations
- },
- "{5, 3} * * * * *" // Cron expression.
- )
-
- while (!fut.isDone)
- println(">>> Invocation #: " + fut.get)
-
- // Prints.
- println()
- println(">>> Schedule future is done and has been unscheduled.")
- println(">>> Check all nodes for hello message output.")
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/10ef06a1/examples/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarExamplesSelfTest.scala
----------------------------------------------------------------------
diff --git a/examples/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarExamplesSelfTest.scala b/examples/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarExamplesSelfTest.scala
index 52d5ce1..ef56434 100644
--- a/examples/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarExamplesSelfTest.scala
+++ b/examples/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarExamplesSelfTest.scala
@@ -77,11 +77,6 @@ class ScalarExamplesSelfTest extends GridAbstractExamplesTest with JUnitSuiteLik
}
/** */
- def testScalarScheduleCallableExample() {
- ScalarScheduleExample.main(EMPTY_ARGS)
- }
-
- /** */
def testScalarTaskExample() {
ScalarTaskExample.main(EMPTY_ARGS)
}
[02/50] [abbrv] ignite git commit: IGNITE-1625 .Net: Remove Types
serialization from Continuous Queries.
Posted by vo...@apache.org.
IGNITE-1625 .Net: Remove Types serialization from Continuous Queries.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0d7fd86b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0d7fd86b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0d7fd86b
Branch: refs/heads/ignite-1651
Commit: 0d7fd86bd420abbce879a01aba81f60e6ef2198f
Parents: b1c64af
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Oct 9 10:10:12 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Oct 9 10:10:12 2015 +0300
----------------------------------------------------------------------
.../Continuous/ContinuousQueryFilterHolder.cs | 35 ++------------------
.../Continuous/ContinuousQueryHandleImpl.cs | 4 +--
.../Impl/Common/DelegateTypeDescriptor.cs | 26 +++++++++++++++
.../Impl/Unmanaged/UnmanagedCallbacks.cs | 13 ++------
4 files changed, 33 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/0d7fd86b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs
index 9b1f8f4..5737ed3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs
@@ -17,7 +17,6 @@
namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
{
- using System;
using Apache.Ignite.Core.Impl.Portable;
using Apache.Ignite.Core.Portable;
@@ -27,12 +26,6 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
/// </summary>
public class ContinuousQueryFilterHolder : IPortableWriteAware
{
- /** Key type. */
- private readonly Type _keyTyp;
-
- /** Value type. */
- private readonly Type _valTyp;
-
/** Filter object. */
private readonly object _filter;
@@ -42,35 +35,15 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
/// <summary>
/// Constructor.
/// </summary>
- /// <param name="keyTyp">Key type.</param>
- /// <param name="valTyp">Value type.</param>
/// <param name="filter">Filter.</param>
/// <param name="keepPortable">Keep portable flag.</param>
- public ContinuousQueryFilterHolder(Type keyTyp, Type valTyp, object filter, bool keepPortable)
+ public ContinuousQueryFilterHolder(object filter, bool keepPortable)
{
- _keyTyp = keyTyp;
- _valTyp = valTyp;
_filter = filter;
_keepPortable = keepPortable;
}
/// <summary>
- /// Key type.
- /// </summary>
- internal Type KeyType
- {
- get { return _keyTyp; }
- }
-
- /// <summary>
- /// Value type.
- /// </summary>
- internal Type ValueType
- {
- get { return _valTyp; }
- }
-
- /// <summary>
/// Filter.
/// </summary>
internal object Filter
@@ -94,8 +67,6 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
{
PortableWriterImpl rawWriter = (PortableWriterImpl) writer.GetRawWriter();
- PortableUtils.WritePortableOrSerializable(rawWriter, _keyTyp);
- PortableUtils.WritePortableOrSerializable(rawWriter, _valTyp);
PortableUtils.WritePortableOrSerializable(rawWriter, _filter);
rawWriter.WriteBoolean(_keepPortable);
@@ -107,10 +78,8 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
/// <param name="reader">The reader.</param>
public ContinuousQueryFilterHolder(IPortableReader reader)
{
- PortableReaderImpl rawReader = (PortableReaderImpl) reader.GetRawReader();
+ var rawReader = (PortableReaderImpl) reader.GetRawReader();
- _keyTyp = PortableUtils.ReadPortableOrSerializable<Type>(rawReader);
- _valTyp = PortableUtils.ReadPortableOrSerializable<Type>(rawReader);
_filter = PortableUtils.ReadPortableOrSerializable<object>(rawReader);
_keepPortable = rawReader.ReadBoolean();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0d7fd86b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
index b292a13..f7dd6e1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
@@ -111,8 +111,8 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
writer.WriteBoolean(qry.Local);
writer.WriteBoolean(_filter != null);
- ContinuousQueryFilterHolder filterHolder = _filter == null || qry.Local ? null :
- new ContinuousQueryFilterHolder(typeof (TK), typeof (TV), _filter, _keepPortable);
+ var filterHolder = _filter == null || qry.Local ? null :
+ new ContinuousQueryFilterHolder(_filter, _keepPortable);
writer.WriteObject(filterHolder);
http://git-wip-us.apache.org/repos/asf/ignite/blob/0d7fd86b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
index 5460037..d974654 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
@@ -19,11 +19,14 @@ namespace Apache.Ignite.Core.Impl.Common
{
using System;
using System.Globalization;
+
using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cache.Event;
using Apache.Ignite.Core.Compute;
using Apache.Ignite.Core.Datastream;
using Apache.Ignite.Core.Events;
using Apache.Ignite.Core.Impl.Cache;
+ using Apache.Ignite.Core.Impl.Cache.Query.Continuous;
using Apache.Ignite.Core.Impl.Datastream;
using Apache.Ignite.Core.Impl.Portable.IO;
using Apache.Ignite.Core.Impl.Unmanaged;
@@ -69,6 +72,9 @@ namespace Apache.Ignite.Core.Impl.Common
/** */
private readonly Func<object, object> _streamTransformerCtor;
+ /** */
+ private readonly Func<object, object, object> _continuousQueryFilterCtor;
+
/// <summary>
/// Gets the <see cref="IComputeFunc{T}" /> invocator.
/// </summary>
@@ -174,6 +180,16 @@ namespace Apache.Ignite.Core.Impl.Common
}
/// <summary>
+ /// Gets the <see cref="ContinuousQueryFilter{TK,TV}"/>> ctor invocator.
+ /// </summary>
+ /// <param name="type">Type.</param>
+ /// <returns>Precompiled invocator delegate.</returns>
+ public static Func<object, object, object> GetContinuousQueryFilterCtor(Type type)
+ {
+ return Get(type)._continuousQueryFilterCtor;
+ }
+
+ /// <summary>
/// Gets the <see cref="DelegateTypeDescriptor" /> by type.
/// </summary>
private static DelegateTypeDescriptor Get(Type type)
@@ -308,6 +324,16 @@ namespace Apache.Ignite.Core.Impl.Common
},
new[] {true, false, false, false, false, false});
}
+ else if (genericTypeDefinition == typeof (ICacheEntryEventFilter<,>))
+ {
+ ThrowIfMultipleInterfaces(_streamReceiver, type, typeof(ICacheEntryEventFilter<,>));
+
+ var args = iface.GetGenericArguments();
+
+ _continuousQueryFilterCtor =
+ DelegateConverter.CompileCtor<Func<object, object, object>>(
+ typeof(ContinuousQueryFilter<,>).MakeGenericType(args), new[] { iface, typeof(bool) });
+ }
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0d7fd86b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
index 6373353..f9949f3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
@@ -23,7 +23,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Threading;
- using Apache.Ignite.Core.Cache.Event;
+
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Impl.Cache;
@@ -546,15 +546,8 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
var filterHolder = reader.ReadObject<ContinuousQueryFilterHolder>();
// 2. Create real filter from it's holder.
- Type filterWrapperTyp = typeof (ContinuousQueryFilter<,>)
- .MakeGenericType(filterHolder.KeyType, filterHolder.ValueType);
-
- Type filterTyp = typeof (ICacheEntryEventFilter<,>)
- .MakeGenericType(filterHolder.KeyType, filterHolder.ValueType);
-
- var filter = (IContinuousQueryFilter) filterWrapperTyp
- .GetConstructor(new[] {filterTyp, typeof (bool)})
- .Invoke(new[] {filterHolder.Filter, filterHolder.KeepPortable});
+ var filter = (IContinuousQueryFilter) DelegateTypeDescriptor.GetContinuousQueryFilterCtor(
+ filterHolder.Filter.GetType())(filterHolder.Filter, filterHolder.KeepPortable);
// 3. Inject grid.
filter.Inject(_ignite);
[21/50] [abbrv] ignite git commit: IGNITE-1653 fixes
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java
deleted file mode 100644
index 8c85a3e..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.misc.schedule;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.scheduler.SchedulerFuture;
-
-/**
- * Demonstrates a cron-based {@link Runnable} execution scheduling.
- * Test runnable object broadcasts a phrase to all cluster nodes every minute
- * three times with initial scheduling delay equal to five seconds.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class ComputeScheduleExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws IgniteException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println("Compute schedule example started.");
-
- // Schedule output message every minute.
- SchedulerFuture<?> fut = ignite.scheduler().scheduleLocal(() ->
- ignite.compute().broadcast(() -> {
- System.out.println();
- System.out.println("Howdy! :)");
-
- return "Howdy! :)";
- }),
- "{5, 3} * * * * *" // Cron expression.
- );
-
- while (!fut.isDone())
- System.out.println(">>> Invocation result: " + fut.get());
-
- System.out.println();
- System.out.println(">>> Schedule future is done and has been unscheduled.");
- System.out.println(">>> Check all nodes for hello message output.");
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java
deleted file mode 100644
index 42132f1..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Demonstrates usage of cron-based scheduler.
- */
-package org.apache.ignite.examples.java8.misc.schedule;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java
deleted file mode 100644
index 538c4eb..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.streaming;
-
-import java.util.List;
-import java.util.Random;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteDataStreamer;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.query.SqlFieldsQuery;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.examples.ExamplesUtils;
-import org.apache.ignite.stream.StreamTransformer;
-
-/**
- * Stream random numbers into the streaming cache.
- * To start the example, you should:
- * <ul>
- * <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li>
- * <li>Start streaming using {@link StreamTransformerExample}.</li>
- * </ul>
- * <p>
- * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM.
- */
-public class StreamTransformerExample {
- /** Random number generator. */
- private static final Random RAND = new Random();
-
- /** Range within which to generate numbers. */
- private static final int RANGE = 1000;
-
- public static void main(String[] args) throws Exception {
- // Mark this cluster member as client.
- Ignition.setClientMode(true);
-
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- if (!ExamplesUtils.hasServerNodes(ignite))
- return;
-
- CacheConfiguration<Integer, Long> cfg = new CacheConfiguration<>("randomNumbers");
-
- // Index key and value.
- cfg.setIndexedTypes(Integer.class, Long.class);
-
- // Auto-close cache at the end of the example.
- try (IgniteCache<Integer, Long> stmCache = ignite.getOrCreateCache(cfg)) {
- try (IgniteDataStreamer<Integer, Long> stmr = ignite.dataStreamer(stmCache.getName())) {
- // Allow data updates.
- stmr.allowOverwrite(true);
-
- // Configure data transformation to count random numbers added to the stream.
- stmr.receiver(StreamTransformer.from((e, arg) -> {
- // Get current count.
- Long val = e.getValue();
-
- // Increment count by 1.
- e.setValue(val == null ? 1L : val + 1);
-
- return null;
- }));
-
- // Stream 10 million of random numbers into the streamer cache.
- for (int i = 1; i <= 10_000_000; i++) {
- stmr.addData(RAND.nextInt(RANGE), 1L);
-
- if (i % 500_000 == 0)
- System.out.println("Number of tuples streamed into Ignite: " + i);
- }
- }
-
- // Query top 10 most popular numbers every.
- SqlFieldsQuery top10Qry = new SqlFieldsQuery("select _key, _val from Long order by _val desc limit 10");
-
- // Execute queries.
- List<List<?>> top10 = stmCache.query(top10Qry).getAll();
-
- System.out.println("Top 10 most popular numbers:");
-
- // Print top 10 words.
- ExamplesUtils.printQueryResults(top10);
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java
deleted file mode 100644
index cef9f2f..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.streaming;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Random;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteDataStreamer;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.query.SqlFieldsQuery;
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.examples.ExamplesUtils;
-import org.apache.ignite.stream.StreamVisitor;
-
-/**
- * Stream random numbers into the streaming cache.
- * To start the example, you should:
- * <ul>
- * <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li>
- * <li>Start streaming using {@link StreamVisitorExample}.</li>
- * </ul>
- * <p>
- * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM.
- */
-public class StreamVisitorExample {
- /** Random number generator. */
- private static final Random RAND = new Random();
-
- /** The list of instruments. */
- private static final String[] INSTRUMENTS = {"IBM", "GOOG", "MSFT", "GE", "EBAY", "YHOO", "ORCL", "CSCO", "AMZN", "RHT"};
-
- /** The list of initial instrument prices. */
- private static final double[] INITIAL_PRICES = {194.9, 893.49, 34.21, 23.24, 57.93, 45.03, 44.41, 28.44, 378.49, 69.50};
-
- public static void main(String[] args) throws Exception {
- // Mark this cluster member as client.
- Ignition.setClientMode(true);
-
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- if (!ExamplesUtils.hasServerNodes(ignite))
- return;
-
- // Market data cache with default configuration.
- CacheConfiguration<String, Double> mktDataCfg = new CacheConfiguration<>("marketTicks");
-
- // Financial instrument cache configuration.
- CacheConfiguration<String, Instrument> instCfg = new CacheConfiguration<>("instCache");
-
- // Index key and value for querying financial instruments.
- // Note that Instrument class has @QuerySqlField annotation for secondary field indexing.
- instCfg.setIndexedTypes(String.class, Instrument.class);
-
- // Auto-close caches at the end of the example.
- try (
- IgniteCache<String, Double> mktCache = ignite.getOrCreateCache(mktDataCfg);
- IgniteCache<String, Instrument> instCache = ignite.getOrCreateCache(instCfg)
- ) {
- try (IgniteDataStreamer<String, Double> mktStmr = ignite.dataStreamer(mktCache.getName())) {
- // Note that we receive market data, but do not populate 'mktCache' (it remains empty).
- // Instead we update the instruments in the 'instCache'.
- // Since both, 'instCache' and 'mktCache' use the same key, updates are collocated.
- mktStmr.receiver(StreamVisitor.from((cache, e) -> {
- String symbol = e.getKey();
- Double tick = e.getValue();
-
- Instrument inst = instCache.get(symbol);
-
- if (inst == null)
- inst = new Instrument(symbol);
-
- // Don't populate market cache, as we don't use it for querying.
- // Update cached instrument based on the latest market tick.
- inst.update(tick);
-
- instCache.put(symbol, inst);
- }));
-
- // Stream 10 million market data ticks into the system.
- for (int i = 1; i <= 10_000_000; i++) {
- int idx = RAND.nextInt(INSTRUMENTS.length);
-
- // Use gaussian distribution to ensure that
- // numbers closer to 0 have higher probability.
- double price = round2(INITIAL_PRICES[idx] + RAND.nextGaussian());
-
- mktStmr.addData(INSTRUMENTS[idx], price);
-
- if (i % 500_000 == 0)
- System.out.println("Number of tuples streamed into Ignite: " + i);
- }
- }
-
- // Select top 3 best performing instruments.
- SqlFieldsQuery top3qry = new SqlFieldsQuery(
- "select symbol, (latest - open) from Instrument order by (latest - open) desc limit 3");
-
- // Execute queries.
- List<List<?>> top3 = instCache.query(top3qry).getAll();
-
- System.out.println("Top performing financial instruments: ");
-
- // Print top 10 words.
- ExamplesUtils.printQueryResults(top3);
- }
- }
- }
-
- /**
- * Rounds double value to two significant signs.
- *
- * @param val value to be rounded.
- * @return rounded double value.
- */
- private static double round2(double val) {
- return Math.floor(100 * val + 0.5) / 100;
- }
-
- /**
- * Financial instrument.
- */
- public static class Instrument implements Serializable {
- /** Instrument symbol. */
- @QuerySqlField(index = true)
- private final String symbol;
-
- /** Open price. */
- @QuerySqlField(index = true)
- private double open;
-
- /** Close price. */
- @QuerySqlField(index = true)
- private double latest;
-
- /**
- * @param symbol Symbol.
- */
- public Instrument(String symbol) {
- this.symbol = symbol;
- }
-
- /**
- * Updates this instrument based on the latest market tick price.
- *
- * @param price Latest price.
- */
- public void update(double price) {
- if (open == 0)
- open = price;
-
- this.latest = price;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/package-info.java
deleted file mode 100644
index d215d2f..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Demonstrates usage of data streamer.
- */
-package org.apache.ignite.examples.java8.streaming;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples/config/hibernate/README.txt
----------------------------------------------------------------------
diff --git a/examples/config/hibernate/README.txt b/examples/config/hibernate/README.txt
deleted file mode 100644
index 5b7ab29..0000000
--- a/examples/config/hibernate/README.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-Hibernate L2 Cache Configuration Example
-----------------------------------------
-
-This folder contains example-hibernate-L2-cache.xml file that demonstrates
-how to configure Hibernate to use Apache Ignite cache as an L2 cache provider.
-
-This file is also used in Hibernate example located in org.apache.ignite.examples.datagrid.hibernate
-package.
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples/config/hibernate/example-hibernate-L2-cache.xml
----------------------------------------------------------------------
diff --git a/examples/config/hibernate/example-hibernate-L2-cache.xml b/examples/config/hibernate/example-hibernate-L2-cache.xml
deleted file mode 100644
index 3248946..0000000
--- a/examples/config/hibernate/example-hibernate-L2-cache.xml
+++ /dev/null
@@ -1,64 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-
-<!DOCTYPE hibernate-configuration PUBLIC
- "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
- "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
-
-<!--
- Configuration file for HibernateL2CacheExample.
--->
-
-<hibernate-configuration>
- <session-factory>
- <!-- Database connection settings -->
- <property name="connection.url">jdbc:h2:mem:example;DB_CLOSE_DELAY=-1</property>
-
- <!-- Drop and re-create the database schema on startup. -->
- <property name="hbm2ddl.auto">create</property>
-
- <!-- Enable L2 cache. -->
- <property name="cache.use_second_level_cache">true</property>
-
- <!-- Enable query cache. -->
- <property name="cache.use_query_cache">true</property>
-
- <!-- Generate L2 cache statistics. -->
- <property name="generate_statistics">true</property>
-
- <!-- Specify Ignite as L2 cache provider. -->
- <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
-
- <!-- Specify connection release mode. -->
- <property name="connection.release_mode">on_close</property>
-
- <!-- Set default L2 cache access type. -->
- <property name="org.apache.ignite.hibernate.default_access_type">READ_ONLY</property>
-
- <!-- Specify the entity classes for mapping. -->
- <mapping class="org.apache.ignite.examples.datagrid.hibernate.User"/>
- <mapping class="org.apache.ignite.examples.datagrid.hibernate.Post"/>
-
- <!-- Per-class L2 cache settings. -->
- <class-cache class="org.apache.ignite.examples.datagrid.hibernate.User" usage="read-only"/>
- <class-cache class="org.apache.ignite.examples.datagrid.hibernate.Post" usage="read-only"/>
- <collection-cache collection="org.apache.ignite.examples.datagrid.hibernate.User.posts" usage="read-only"/>
- </session-factory>
-</hibernate-configuration>
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 7b8763f..6eeb006 100644
--- a/pom.xml
+++ b/pom.xml
@@ -147,6 +147,72 @@
</profile>
<profile>
+ <id>lgpl</id>
+ <modules>
+ <module>modules/hibernate</module>
+ <module>modules/geospatial</module>
+ <module>modules/schedule</module>
+ </modules>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.apache.resources</groupId>
+ <artifactId>apache-source-release-assembly-descriptor</artifactId>
+ <version>1.0.4</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>release-lgpl</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <descriptors>
+ <descriptor>assembly/release-${ignite.edition}-lgpl.xml</descriptor>
+ </descriptors>
+ <finalName>release-package</finalName>
+ <appendAssemblyId>false</appendAssemblyId>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.7</version>
+ <inherited>false</inherited>
+ <executions>
+ <execution>
+ <id>release-postprocessing-lgpl</id>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <target>
+ <replaceregexp file="${basedir}/target/release-package/examples-lgpl/pom.xml"
+ byline="true">
+ <regexp pattern="to_be_replaced_by_ignite_version"/>
+ <substitution expression="${project.version}"/>
+ </replaceregexp>
+ </target>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
<id>release</id>
<activation>
<activeByDefault>true</activeByDefault>
@@ -459,72 +525,6 @@
</profile>
<profile>
- <id>lgpl</id>
- <modules>
- <module>modules/hibernate</module>
- <module>modules/geospatial</module>
- <module>modules/schedule</module>
- </modules>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <dependencies>
- <dependency>
- <groupId>org.apache.apache.resources</groupId>
- <artifactId>apache-source-release-assembly-descriptor</artifactId>
- <version>1.0.4</version>
- </dependency>
- </dependencies>
- <executions>
- <execution>
- <id>release-lgpl</id>
- <phase>prepare-package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <descriptors>
- <descriptor>assembly/release-${ignite.edition}-lgpl.xml</descriptor>
- </descriptors>
- <finalName>release-package</finalName>
- <appendAssemblyId>false</appendAssemblyId>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>1.7</version>
- <inherited>false</inherited>
- <executions>
- <execution>
- <id>release-postprocessing-lgpl</id>
- <goals>
- <goal>run</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <target>
- <replaceregexp file="${basedir}/target/release-package/examples-lgpl/pom.xml"
- byline="true">
- <regexp pattern="to_be_replaced_by_ignite_version"/>
- <substitution expression="${project.version}"/>
- </replaceregexp>
- </target>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
- </build>
- </profile>
-
- <profile>
<id>examples</id>
<modules>
<module>examples</module>
[34/50] [abbrv] ignite git commit: IGNITE-1646 .Net: IgniteGuid is
now serializable.
Posted by vo...@apache.org.
IGNITE-1646 .Net: IgniteGuid is now serializable.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b1b80944
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b1b80944
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b1b80944
Branch: refs/heads/ignite-1651
Commit: b1b80944d6c5c6db74cb1e2f07c9a74975aa249b
Parents: e0853ea
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Tue Oct 20 17:03:36 2015 +0300
Committer: thatcoach <pp...@list.ru>
Committed: Tue Oct 20 17:03:36 2015 +0300
----------------------------------------------------------------------
.../Portable/PortableSelfTest.cs | 56 +++++++++-----------
.../Apache.Ignite.Core/Common/IgniteGuid.cs | 13 +----
2 files changed, 26 insertions(+), 43 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b1b80944/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
index 275460f..36faf36 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
@@ -27,6 +27,7 @@ namespace Apache.Ignite.Core.Tests.Portable
using System.Collections.Generic;
using System.Linq;
using System.Text;
+ using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Impl.Portable;
using Apache.Ignite.Core.Impl.Portable.IO;
using Apache.Ignite.Core.Portable;
@@ -784,20 +785,8 @@ namespace Apache.Ignite.Core.Tests.Portable
obj.PString = "abc";
obj.PGuid = Guid.NewGuid();
obj.PnGuid = Guid.NewGuid();
+ obj.IgniteGuid = new IgniteGuid(Guid.NewGuid(), 123);
- //CheckPrimitiveFieldsSerialization(marsh, obj);
-
- //obj.PString = "";
-
- //CheckPrimitiveFieldsSerialization(marsh, obj);
-
- //obj.PString = null;
-
- //CheckPrimitiveFieldsSerialization(marsh, obj);
-
- //obj.PString = null;
- //obj.PNGuid = null;
-
CheckPrimitiveFieldsSerialization(marsh, obj);
}
@@ -1485,8 +1474,6 @@ namespace Apache.Ignite.Core.Tests.Portable
public class PrimitiveFieldType
{
- private Guid _pGuid;
-
public bool PBool { get; set; }
public sbyte PSbyte { get; set; }
@@ -1513,14 +1500,12 @@ namespace Apache.Ignite.Core.Tests.Portable
public string PString { get; set; }
- public Guid PGuid
- {
- get { return _pGuid; }
- set { _pGuid = value; }
- }
+ public Guid PGuid { get; set; }
public Guid? PnGuid { get; set; }
+ public IgniteGuid IgniteGuid { get; set; }
+
/** <inheritdoc /> */
public override bool Equals(object obj)
{
@@ -1543,8 +1528,9 @@ namespace Apache.Ignite.Core.Tests.Portable
PChar == that.PChar &&
PFloat == that.PFloat &&
PDouble == that.PDouble &&
- (PString == null && that.PString == null || PString != null && PString.Equals(that.PString)) &&
- _pGuid.Equals(that._pGuid) &&
+ (string.Equals(PString, that.PString)) &&
+ PGuid.Equals(that.PGuid) &&
+ IgniteGuid.Equals(that.IgniteGuid) &&
(PnGuid == null && that.PnGuid == null || PnGuid != null && PnGuid.Equals(that.PnGuid));
}
return false;
@@ -1583,6 +1569,8 @@ namespace Apache.Ignite.Core.Tests.Portable
writer.WriteString("string", PString);
writer.WriteGuid("guid", PGuid);
writer.WriteGuid("nguid", PnGuid);
+
+ writer.WriteObject("iguid", IgniteGuid);
}
public unsafe void ReadPortable(IPortableReader reader)
@@ -1610,6 +1598,8 @@ namespace Apache.Ignite.Core.Tests.Portable
PString = reader.ReadString("string");
PGuid = reader.ReadObject<Guid>("guid");
PnGuid = reader.ReadGuid("nguid");
+
+ IgniteGuid = reader.ReadObject<IgniteGuid>("iguid");
}
}
@@ -1641,6 +1631,8 @@ namespace Apache.Ignite.Core.Tests.Portable
rawWriter.WriteString(PString);
rawWriter.WriteGuid(PGuid);
rawWriter.WriteGuid(PnGuid);
+
+ rawWriter.WriteObject(IgniteGuid);
}
public unsafe void ReadPortable(IPortableReader reader)
@@ -1670,6 +1662,8 @@ namespace Apache.Ignite.Core.Tests.Portable
PString = rawReader.ReadString();
PGuid = rawReader.ReadGuid().Value;
PnGuid = rawReader.ReadGuid();
+
+ IgniteGuid = rawReader.ReadObject<IgniteGuid>();
}
}
@@ -1701,6 +1695,8 @@ namespace Apache.Ignite.Core.Tests.Portable
writer.WriteString("string", obj0.PString);
writer.WriteGuid("guid", obj0.PGuid);
writer.WriteGuid("nguid", obj0.PnGuid);
+
+ writer.WriteObject("iguid", obj0.IgniteGuid);
}
public unsafe void ReadPortable(object obj, IPortableReader reader)
@@ -1730,6 +1726,8 @@ namespace Apache.Ignite.Core.Tests.Portable
obj0.PString = reader.ReadString("string");
obj0.PGuid = reader.ReadObject<Guid>("guid");
obj0.PnGuid = reader.ReadGuid("nguid");
+
+ obj0.IgniteGuid = reader.ReadObject<IgniteGuid>("iguid");
}
}
@@ -1763,6 +1761,8 @@ namespace Apache.Ignite.Core.Tests.Portable
rawWriter.WriteString(obj0.PString);
rawWriter.WriteGuid(obj0.PGuid);
rawWriter.WriteGuid(obj0.PnGuid);
+
+ rawWriter.WriteObject(obj0.IgniteGuid);
}
public unsafe void ReadPortable(object obj, IPortableReader reader)
@@ -1793,17 +1793,9 @@ namespace Apache.Ignite.Core.Tests.Portable
obj0.PString = rawReader.ReadString();
obj0.PGuid = rawReader.ReadGuid().Value;
obj0.PnGuid = rawReader.ReadGuid();
- }
- }
-
- public static string PrintBytes(byte[] bytes)
- {
- StringBuilder sb = new StringBuilder();
- foreach (byte b in bytes)
- sb.Append(b + " ");
-
- return sb.ToString();
+ obj0.IgniteGuid = rawReader.ReadObject<IgniteGuid>();
+ }
}
public class HandleOuter : IPortableMarshalAware
http://git-wip-us.apache.org/repos/asf/ignite/blob/b1b80944/modules/platforms/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
index 7386a03..60a5839 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
@@ -24,6 +24,7 @@ namespace Apache.Ignite.Core.Common
/// <summary>
/// Ignite guid with additional local ID.
/// </summary>
+ [Serializable]
public struct IgniteGuid : IEquatable<IgniteGuid>
{
/** Global id. */
@@ -89,20 +90,10 @@ namespace Apache.Ignite.Core.Common
}
/// <summary>
- /// Writes this object to the given writer.
- /// </summary>
- /// <param name="w">Writer.</param>
- public void WritePortable(IPortableRawWriter w)
- {
- w.WriteGuid(GlobalId);
- w.WriteLong(LocalId);
- }
-
- /// <summary>
/// Reads this object from the given reader.
/// </summary>
/// <param name="r">Reader.</param>
- public static IgniteGuid? ReadPortable(IPortableRawReader r)
+ internal static IgniteGuid? ReadPortable(IPortableRawReader r)
{
var guid = r.ReadGuid();
[31/50] [abbrv] ignite git commit: IGNITE-1696: Added IBM JDK
specific path to jvm.dll library search sequence.
Posted by vo...@apache.org.
IGNITE-1696: Added IBM JDK specific path to jvm.dll library search sequence.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/27300974
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/27300974
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/27300974
Branch: refs/heads/ignite-1651
Commit: 27300974bacfc5d8aa927cc082933608dc325bcf
Parents: 9879bed
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Tue Oct 20 15:58:11 2015 +0300
Committer: thatcoach <pp...@list.ru>
Committed: Tue Oct 20 15:58:11 2015 +0300
----------------------------------------------------------------------
.../Apache.Ignite.Core/Impl/IgniteUtils.cs | 30 +++++---------------
1 file changed, 7 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/27300974/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 88ab75f..7588945 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
@@ -41,14 +41,8 @@ namespace Apache.Ignite.Core.Impl
/** Environment variable: JAVA_HOME. */
private const string EnvJavaHome = "JAVA_HOME";
- /** Directory: jre. */
- private const string DirJre = "jre";
-
- /** Directory: bin. */
- private const string DirBin = "bin";
-
- /** Directory: server. */
- private const string DirServer = "server";
+ /** Lookup paths. */
+ private static readonly string[] JvmDllLookupPaths = {@"jre\bin\server", @"jre\bin\default"};
/** File: jvm.dll. */
private const string FileJvmDll = "jvm.dll";
@@ -78,12 +72,9 @@ namespace Apache.Ignite.Core.Impl
/// Gets thread local random.
/// </summary>
/// <returns>Thread local random.</returns>
- public static Random ThreadLocalRandom()
+ private static Random ThreadLocalRandom()
{
- if (_rnd == null)
- _rnd = new Random();
-
- return _rnd;
+ return _rnd ?? (_rnd = new Random());
}
/// <summary>
@@ -260,16 +251,9 @@ namespace Apache.Ignite.Core.Impl
var javaHomeDir = Environment.GetEnvironmentVariable(EnvJavaHome);
if (!string.IsNullOrEmpty(javaHomeDir))
- yield return
- new KeyValuePair<string, string>(EnvJavaHome, GetJvmDllPath(Path.Combine(javaHomeDir, DirJre)));
- }
-
- /// <summary>
- /// Gets the JVM DLL path from JRE dir.
- /// </summary>
- private static string GetJvmDllPath(string jreDir)
- {
- return Path.Combine(jreDir, DirBin, DirServer, FileJvmDll);
+ foreach (var path in JvmDllLookupPaths)
+ yield return
+ new KeyValuePair<string, string>(EnvJavaHome, Path.Combine(javaHomeDir, path, FileJvmDll));
}
/// <summary>
[26/50] [abbrv] ignite git commit: Muted test
IgniteCacheClientNodeChangingTopologyTest.testAtomicClockPutAllMultinode
Posted by vo...@apache.org.
Muted test IgniteCacheClientNodeChangingTopologyTest.testAtomicClockPutAllMultinode
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/75fb19de
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/75fb19de
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/75fb19de
Branch: refs/heads/ignite-1651
Commit: 75fb19deec4a4dfec8d93a27008faa1c90ebb780
Parents: 10ef06a
Author: ashutak <as...@gridgain.com>
Authored: Tue Oct 20 13:32:43 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Tue Oct 20 13:32:43 2015 +0300
----------------------------------------------------------------------
.../distributed/IgniteCacheClientNodeChangingTopologyTest.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/75fb19de/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
index 1b3dc7a..b6e86f2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
@@ -1413,6 +1413,8 @@ public class IgniteCacheClientNodeChangingTopologyTest extends GridCommonAbstrac
* @throws Exception If failed.
*/
public void testAtomicClockPutAllMultinode() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1685");
+
multinode(CLOCK, TestType.PUT_ALL);
}
@@ -1840,4 +1842,4 @@ public class IgniteCacheClientNodeChangingTopologyTest extends GridCommonAbstrac
/** */
LOCK
}
-}
\ No newline at end of file
+}
[39/50] [abbrv] ignite git commit: Muted test
GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest#testIgniteCacheIterator
Posted by vo...@apache.org.
Muted test GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest#testIgniteCacheIterator
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/91e31e99
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/91e31e99
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/91e31e99
Branch: refs/heads/ignite-1651
Commit: 91e31e99c2574f7cede8d80ec9b8d981ccc34bcb
Parents: c28af3c
Author: ashutak <as...@gridgain.com>
Authored: Wed Oct 21 20:03:29 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Wed Oct 21 20:03:29 2015 +0300
----------------------------------------------------------------------
...tomicNearEnabledFairAffinityMultiNodeFullApiSelfTest.java | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/91e31e99/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest.java
index 8e47134..de4a53d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest.java
@@ -34,7 +34,13 @@ public class GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest
return cfg;
}
+ /** {@inheritDoc} */
@Override public void testWithSkipStore(){
fail("https://issues.apache.org/jira/browse/IGNITE-1582");
}
-}
\ No newline at end of file
+
+ /** {@inheritDoc} */
+ @Override public void testIgniteCacheIterator() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1756");
+ }
+}