You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/09/21 16:27:42 UTC
[46/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Events/EventType.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Events/EventType.cs b/modules/platform/dotnet/Apache.Ignite.Core/Events/EventType.cs
new file mode 100644
index 0000000..1e649bb
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Events/EventType.cs
@@ -0,0 +1,514 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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
+{
+ using System.Diagnostics.CodeAnalysis;
+ using System.Linq;
+ using System.Reflection;
+
+ /// <summary>
+ /// Contains event type constants. The decision to use class and not enumeration is dictated
+ /// by allowing users to create their own events and/or event types which would be impossible with enumerations.
+ /// <para />
+ /// Note that this interface defines not only individual type constants,
+ /// but arrays of types as well to be conveniently used with <see cref="IEvents"/> methods.
+ /// <para />
+ /// NOTE: all types in range <b>from 1 to 1000 are reserved</b> for internal Ignite events
+ /// and should not be used by user-defined events.
+ /// </summary>
+ public static class EventType
+ {
+ /// <summary>
+ /// Built-in event type: checkpoint was saved.
+ /// </summary>
+ public static readonly int EvtCheckpointSaved = 1;
+
+ /// <summary>
+ /// Built-in event type: checkpoint was loaded.
+ /// </summary>
+ public static readonly int EvtCheckpointLoaded = 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 EvtCheckpointRemoved = 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 EvtNodeJoined = 10;
+
+ /// <summary>
+ /// Built-in event type: node has normally left topology.
+ /// </summary>
+ public static readonly int EvtNodeLeft = 11;
+
+ /// <summary>
+ /// Built-in event type: node failed. Ignite detected that node has presumably crashed and is considered
+ /// failed.
+ /// </summary>
+ public static readonly int EvtNodeFailed = 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 EvtNodeMetricsUpdated = 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 EvtNodeSegmented = 14;
+
+ /// <summary>
+ /// Built-in event type: client node disconnected.
+ /// </summary>
+ public static readonly int EvtClientNodeDisconnected = 16;
+
+ /// <summary>
+ /// Built-in event type: client node reconnected.
+ /// </summary>
+ public static readonly int EvtClientNodeReconnected = 17;
+
+ /// <summary>
+ /// Built-in event type: task started.
+ /// </summary>
+ public static readonly int EvtTaskStarted = 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 EvtTaskFinished = 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 EvtTaskFailed = 22;
+
+ /// <summary>
+ /// Built-in event type: task timed out.
+ /// </summary>
+ public static readonly int EvtTaskTimedout = 23;
+
+ /// <summary>
+ /// Built-in event type: task session attribute set.
+ /// </summary>
+ public static readonly int EvtTaskSessionAttrSet = 24;
+
+ /// <summary>
+ /// Built-in event type: task reduced.
+ /// </summary>
+ public static readonly int EvtTaskReduced = 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 EvtJobMapped = 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 EvtJobResulted = 41;
+
+ /// <summary>
+ /// Built-in event type: Ignite job failed over.
+ /// </summary>
+ public static readonly int EvtJobFailedOver = 43;
+
+ /// <summary>
+ /// Built-in event type: Ignite job started.
+ /// </summary>
+ public static readonly int EvtJobStarted = 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 EvtJobFinished = 45;
+
+ /// <summary>
+ /// Built-in event type: Ignite job timed out.
+ /// </summary>
+ public static readonly int EvtJobTimedout = 46;
+
+ /// <summary>
+ /// Built-in event type: Ignite job rejected during collision resolution.
+ /// </summary>
+ public static readonly int EvtJobRejected = 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 EvtJobFailed = 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 EvtJobQueued = 49;
+
+ /// <summary>
+ /// Built-in event type: Ignite job cancelled.
+ /// </summary>
+ public static readonly int EvtJobCancelled = 50;
+
+ /// <summary>
+ /// Built-in event type: entry created.
+ /// </summary>
+ public static readonly int EvtCacheEntryCreated = 60;
+
+ /// <summary>
+ /// Built-in event type: entry destroyed.
+ /// </summary>
+ public static readonly int EvtCacheEntryDestroyed = 61;
+
+ /// <summary>
+ /// Built-in event type: entry evicted.
+ /// </summary>
+ public static readonly int EvtCacheEntryEvicted = 62;
+
+ /// <summary>
+ /// Built-in event type: object put.
+ /// </summary>
+ public static readonly int EvtCacheObjectPut = 63;
+
+ /// <summary>
+ /// Built-in event type: object read.
+ /// </summary>
+ public static readonly int EvtCacheObjectRead = 64;
+
+ /// <summary>
+ /// Built-in event type: object removed.
+ /// </summary>
+ public static readonly int EvtCacheObjectRemoved = 65;
+
+ /// <summary>
+ /// Built-in event type: object locked.
+ /// </summary>
+ public static readonly int EvtCacheObjectLocked = 66;
+
+ /// <summary>
+ /// Built-in event type: object unlocked.
+ /// </summary>
+ public static readonly int EvtCacheObjectUnlocked = 67;
+
+ /// <summary>
+ /// Built-in event type: cache object swapped from swap storage.
+ /// </summary>
+ public static readonly int EvtCacheObjectSwapped = 68;
+
+ /// <summary>
+ /// Built-in event type: cache object unswapped from swap storage.
+ /// </summary>
+ public static readonly int EvtCacheObjectUnswapped = 69;
+
+ /// <summary>
+ /// Built-in event type: cache object was expired when reading it.
+ /// </summary>
+ public static readonly int EvtCacheObjectExpired = 70;
+
+ /// <summary>
+ /// Built-in event type: swap space data read.
+ /// </summary>
+ public static readonly int EvtSwapSpaceDataRead = 71;
+
+ /// <summary>
+ /// Built-in event type: swap space data stored.
+ /// </summary>
+ public static readonly int EvtSwapSpaceDataStored = 72;
+
+ /// <summary>
+ /// Built-in event type: swap space data removed.
+ /// </summary>
+ public static readonly int EvtSwapSpaceDataRemoved = 73;
+
+ /// <summary>
+ /// Built-in event type: swap space cleared.
+ /// </summary>
+ public static readonly int EvtSwapSpaceCleared = 74;
+
+ /// <summary>
+ /// Built-in event type: swap space data evicted.
+ /// </summary>
+ public static readonly int EvtSwapSpaceDataEvicted = 75;
+
+ /// <summary>
+ /// Built-in event type: cache object stored in off-heap storage.
+ /// </summary>
+ public static readonly int EvtCacheObjectToOffheap = 76;
+
+ /// <summary>
+ /// Built-in event type: cache object moved from off-heap storage back into memory.
+ /// </summary>
+ public static readonly int EvtCacheObjectFromOffheap = 77;
+
+ /// <summary>
+ /// Built-in event type: cache rebalance started.
+ /// </summary>
+ public static readonly int EvtCacheRebalanceStarted = 80;
+
+ /// <summary>
+ /// Built-in event type: cache rebalance stopped.
+ /// </summary>
+ public static readonly int EvtCacheRebalanceStopped = 81;
+
+ /// <summary>
+ /// Built-in event type: cache partition loaded.
+ /// </summary>
+ public static readonly int EvtCacheRebalancePartLoaded = 82;
+
+ /// <summary>
+ /// Built-in event type: cache partition unloaded.
+ /// </summary>
+ public static readonly int EvtCacheRebalancePartUnloaded = 83;
+
+ /// <summary>
+ /// Built-in event type: cache entry rebalanced.
+ /// </summary>
+ public static readonly int EvtCacheRebalanceObjectLoaded = 84;
+
+ /// <summary>
+ /// Built-in event type: cache entry unloaded.
+ /// </summary>
+ public static readonly int EvtCacheRebalanceObjectUnloaded = 85;
+
+ /// <summary>
+ /// Built-in event type: all nodes that hold partition left topology.
+ /// </summary>
+ public static readonly int EvtCacheRebalancePartDataLost = 86;
+
+ /// <summary>
+ /// Built-in event type: query executed.
+ /// </summary>
+ public static readonly int EvtCacheQueryExecuted = 96;
+
+ /// <summary>
+ /// Built-in event type: query entry read.
+ /// </summary>
+ public static readonly int EvtCacheQueryObjectRead = 97;
+
+ /// <summary>
+ /// Built-in event type: cache started.
+ /// </summary>
+ public static readonly int EvtCacheStarted = 98;
+
+ /// <summary>
+ /// Built-in event type: cache started.
+ /// </summary>
+ public static readonly int EvtCacheStopped = 99;
+
+ /// <summary>
+ /// Built-in event type: cache nodes left.
+ /// </summary>
+ public static readonly int EvtCacheNodesLeft = 100;
+
+ /// <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.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
+ Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
+ public static readonly int[] EvtsError =
+ {
+ EvtJobTimedout,
+ EvtJobFailed,
+ EvtJobFailedOver,
+ EvtJobRejected,
+ EvtJobCancelled,
+ EvtTaskTimedout,
+ EvtTaskFailed,
+ EvtCacheRebalanceStarted,
+ EvtCacheRebalanceStopped
+ };
+
+ /// <summary>
+ /// All discovery events except for <see cref="EvtNodeMetricsUpdated" />. Subscription to <see
+ /// cref="EvtNodeMetricsUpdated" /> 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="EvtsDiscoveryAll" /> array.
+ /// </summary>
+ [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
+ Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
+ public static readonly int[] EvtsDiscovery =
+ {
+ EvtNodeJoined,
+ EvtNodeLeft,
+ EvtNodeFailed,
+ EvtNodeSegmented,
+ EvtClientNodeDisconnected,
+ EvtClientNodeReconnected
+ };
+
+ /// <summary>
+ /// All discovery events.
+ /// </summary>
+ [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
+ Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
+ public static readonly int[] EvtsDiscoveryAll =
+ {
+ EvtNodeJoined,
+ EvtNodeLeft,
+ EvtNodeFailed,
+ EvtNodeSegmented,
+ EvtNodeMetricsUpdated,
+ EvtClientNodeDisconnected,
+ EvtClientNodeReconnected
+ };
+
+ /// <summary>
+ /// All Ignite job execution events.
+ /// </summary>
+ [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
+ Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
+ public static readonly int[] EvtsJobExecution =
+ {
+ EvtJobMapped,
+ EvtJobResulted,
+ EvtJobFailedOver,
+ EvtJobStarted,
+ EvtJobFinished,
+ EvtJobTimedout,
+ EvtJobRejected,
+ EvtJobFailed,
+ EvtJobQueued,
+ EvtJobCancelled
+ };
+
+ /// <summary>
+ /// All Ignite task execution events.
+ /// </summary>
+ [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
+ Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
+ public static readonly int[] EvtsTaskExecution =
+ {
+ EvtTaskStarted,
+ EvtTaskFinished,
+ EvtTaskFailed,
+ EvtTaskTimedout,
+ EvtTaskSessionAttrSet,
+ EvtTaskReduced
+ };
+
+ /// <summary>
+ /// All cache events.
+ /// </summary>
+ [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
+ Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
+ public static readonly int[] EvtsCache =
+ {
+ EvtCacheEntryCreated,
+ EvtCacheEntryDestroyed,
+ EvtCacheObjectPut,
+ EvtCacheObjectRead,
+ EvtCacheObjectRemoved,
+ EvtCacheObjectLocked,
+ EvtCacheObjectUnlocked,
+ EvtCacheObjectSwapped,
+ EvtCacheObjectUnswapped,
+ EvtCacheObjectExpired
+ };
+
+ /// <summary>
+ /// All cache rebalance events.
+ /// </summary>
+ [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
+ Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
+ public static readonly int[] EvtsCacheRebalance =
+ {
+ EvtCacheRebalanceStarted,
+ EvtCacheRebalanceStopped,
+ EvtCacheRebalancePartLoaded,
+ EvtCacheRebalancePartUnloaded,
+ EvtCacheRebalanceObjectLoaded,
+ EvtCacheRebalanceObjectUnloaded,
+ EvtCacheRebalancePartDataLost
+ };
+
+ /// <summary>
+ /// All cache lifecycle events.
+ /// </summary>
+ [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
+ Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
+ public static readonly int[] EvtsCacheLifecycle =
+ {
+ EvtCacheStarted,
+ EvtCacheStopped,
+ EvtCacheNodesLeft
+ };
+
+ /// <summary>
+ /// All cache query events.
+ /// </summary>
+ [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
+ Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
+ public static readonly int[] EvtsCacheQuery =
+ {
+ EvtCacheQueryExecuted,
+ EvtCacheQueryObjectRead
+ };
+
+ /// <summary>
+ /// All swap space events.
+ /// </summary>
+ [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
+ Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
+ public static readonly int[] EvtsSwapspace =
+ {
+ EvtSwapSpaceCleared,
+ EvtSwapSpaceDataRemoved,
+ EvtSwapSpaceDataRead,
+ EvtSwapSpaceDataStored,
+ EvtSwapSpaceDataEvicted
+ };
+
+ /// <summary>
+ /// All Ignite events.
+ /// </summary>
+ [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
+ Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
+ public static readonly int[] EvtsAll = GetAllEvents();
+
+ /// <summary>
+ /// All Ignite events (<b>excluding</b> metric update event).
+ /// </summary>
+ [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
+ Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
+ public static readonly int[] EvtsAllMinusMetricUpdate =
+ EvtsAll.Where(x => x != EvtNodeMetricsUpdated).ToArray();
+
+ /// <summary>
+ /// Gets all the events.
+ /// </summary>
+ /// <returns>All event ids.</returns>
+ private static int[] GetAllEvents()
+ {
+ return typeof (EventType).GetFields(BindingFlags.Public | BindingFlags.Static)
+ .Where(x => x.FieldType == typeof (int))
+ .Select(x => (int) x.GetValue(null)).ToArray();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Events/IEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Events/IEvent.cs b/modules/platform/dotnet/Apache.Ignite.Core/Events/IEvent.cs
new file mode 100644
index 0000000..181aeef
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Events/IEvent.cs
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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
+{
+ using System;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Common;
+
+ /// <summary>
+ /// Represents a Ignite event.
+ /// </summary>
+ public interface IEvent
+ {
+ /// <summary>
+ /// Gets globally unique ID of this event.
+ /// </summary>
+ IgniteGuid Id { get; }
+
+ /// <summary>
+ /// Gets locally unique ID that is atomically incremented for each event. Unlike global <see cref="Id" />
+ /// this local ID can be used for ordering events on this node.
+ /// <para/>
+ /// Note that for performance considerations Ignite doesn't order events globally.
+ /// </summary>
+ long LocalOrder { get; }
+
+ /// <summary>
+ /// Node where event occurred and was recorded.
+ /// </summary>
+ IClusterNode Node { get; }
+
+ /// <summary>
+ /// Gets optional message for this event.
+ /// </summary>
+ string Message { get; }
+
+ /// <summary>
+ /// Gets type of this event. All system event types are defined in <see cref="EventType"/>
+ /// </summary>
+ int Type { get; }
+
+ /// <summary>
+ /// Gets name of this event.
+ /// </summary>
+ string Name { get; }
+
+ /// <summary>
+ /// Gets event timestamp. Timestamp is local to the node on which this event was produced.
+ /// Note that more than one event can be generated with the same timestamp.
+ /// For ordering purposes use <see cref="LocalOrder"/> instead.
+ /// </summary>
+ DateTime TimeStamp { get; }
+
+ /// <summary>
+ /// Gets shortened version of ToString result.
+ /// </summary>
+ string ToShortString();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Events/IEventFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Events/IEventFilter.cs b/modules/platform/dotnet/Apache.Ignite.Core/Events/IEventFilter.cs
new file mode 100644
index 0000000..7523c52
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Events/IEventFilter.cs
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Events
+{
+ using System;
+
+ /// <summary>
+ /// Represents an event filter.
+ /// </summary>
+ /// <typeparam name="T">Event type.</typeparam>
+ public interface IEventFilter<in T> where T : IEvent
+ {
+ /// <summary>
+ /// Determines whether specified event passes this filtger.
+ /// </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);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Events/IEvents.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Events/IEvents.cs b/modules/platform/dotnet/Apache.Ignite.Core/Events/IEvents.cs
new file mode 100644
index 0000000..e13513c
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Events/IEvents.cs
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Common;
+
+ /// <summary>
+ /// Provides functionality for local and remote event notifications on nodes defined by <see cref="ClusterGroup"/>.
+ /// <para/>
+ /// All members are thread-safe and may be used concurrently from multiple threads.
+ /// </summary>
+ public interface IEvents : IAsyncSupport<IEvents>
+ {
+ /// <summary>
+ /// Gets the cluster group to which this instance belongs.
+ /// </summary>
+ IClusterGroup ClusterGroup { get; }
+
+ /// <summary>
+ /// Queries nodes in this cluster group for events using passed in predicate filter for event selection.
+ /// </summary>
+ /// <typeparam name="T">Type of events.</typeparam>
+ /// <param name="filter">Predicate filter used to query events on remote nodes.</param>
+ /// <param name="timeout">Maximum time to wait for result, null or 0 to wait forever.</param>
+ /// <param name="types">Event types to be queried.</param>
+ /// <returns>Collection of Ignite events returned from specified nodes.</returns>
+ [AsyncSupported]
+ [SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists")]
+ List<T> RemoteQuery<T>(IEventFilter<T> filter, TimeSpan? timeout = 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, params int[] types)
+ 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}"/>.</param>
+ [AsyncSupported]
+ void StopRemoteListen(Guid opId);
+
+ /// <summary>
+ /// Waits for the specified events.
+ /// </summary>
+ /// <param name="types">Types of the events to wait for.
+ /// If not provided, all events will be passed to the filter.</param>
+ /// <returns>Ignite event.</returns>
+ [AsyncSupported]
+ IEvent WaitForLocal(params int[] types);
+
+ /// <summary>
+ /// Waits for the specified events.
+ /// </summary>
+ /// <typeparam name="T">Type of events.</typeparam>
+ /// <param name="filter">Optional filtering predicate. Event wait will end as soon as it returns false.</param>
+ /// <param name="types">Types of the events to wait for.
+ /// If not provided, all events will be passed to the filter.</param>
+ /// <returns>Ignite event.</returns>
+ [AsyncSupported]
+ T WaitForLocal<T>(IEventFilter<T> filter, params int[] types) where T : IEvent;
+
+ /// <summary>
+ /// Queries local node for events using of specified types.
+ /// </summary>
+ /// <param name="types">Event types to be queried. Optional.</param>
+ /// <returns>Collection of Ignite events found on local node.</returns>
+ [SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists")]
+ List<IEvent> LocalQuery(params int[] types);
+
+ /// <summary>
+ /// Records customer user generated event. All registered local listeners will be notified.
+ /// <para/>
+ /// NOTE: all types in range <b>from 1 to 1000 are reserved</b> for
+ /// internal Ignite events and should not be used by user-defined 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>
+ void RecordLocal(IEvent evt);
+
+ /// <summary>
+ /// Adds an event listener for local events. Note that listener will be added regardless of whether
+ /// local node is in this cluster group or not.
+ /// </summary>
+ /// <typeparam name="T">Type of events.</typeparam>
+ /// <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;
+
+ /// <summary>
+ /// Removes local event listener.
+ /// </summary>
+ /// <typeparam name="T">Type of events.</typeparam>
+ /// <param name="listener">Local event listener to remove.</param>
+ /// <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;
+
+ /// <summary>
+ /// Enables provided events. Allows to start recording events that were disabled before.
+ /// Note that provided events will be enabled regardless of whether local node is in this cluster group or not.
+ /// </summary>
+ /// <param name="types">Events to enable.</param>
+ void EnableLocal(params int[] types);
+
+ /// <summary>
+ /// Disables provided events. Allows to stop recording events that were enabled before. Note that specified
+ /// events will be disabled regardless of whether local node is in this cluster group or not.
+ /// </summary>
+ /// <param name="types">Events to disable.</param>
+ void DisableLocal(params int[] types);
+
+ /// <summary>
+ /// Gets types of enabled events.
+ /// </summary>
+ /// <returns>Types of enabled events.</returns>
+ int[] GetEnabledEvents();
+
+ /// <summary>
+ /// Determines whether the specified event is enabled.
+ /// </summary>
+ /// <param name="type">Event type.</param>
+ /// <returns>Value indicating whether the specified event is enabled.</returns>
+ bool IsEnabled(int type);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Events/JobEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Events/JobEvent.cs b/modules/platform/dotnet/Apache.Ignite.Core/Events/JobEvent.cs
new file mode 100644
index 0000000..81d537f
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Events/JobEvent.cs
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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
+{
+ using System;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Portable;
+
+ /// <summary>
+ /// Ignite job event.
+ /// </summary>
+ public sealed class JobEvent : EventBase
+ {
+ /** */
+ private readonly string _taskName;
+
+ /** */
+ private readonly string _taskClassName;
+
+ /** */
+ private readonly IgniteGuid _taskSessionId;
+
+ /** */
+ private readonly IgniteGuid _jobId;
+
+ /** */
+ private readonly IClusterNode _taskNode;
+
+ /** */
+ private readonly Guid _taskSubjectId;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="r">The reader to read data from.</param>
+ internal JobEvent(IPortableRawReader r) : base(r)
+ {
+ _taskName = r.ReadString();
+ _taskClassName = r.ReadString();
+ _taskSessionId = IgniteGuid.ReadPortable(r);
+ _jobId = IgniteGuid.ReadPortable(r);
+ _taskNode = ReadNode(r);
+ _taskSubjectId = r.ReadGuid() ?? Guid.Empty;
+ }
+
+ /// <summary>
+ /// Gets name of the task that triggered the event.
+ /// </summary>
+ public string TaskName { get { return _taskName; } }
+
+ /// <summary>
+ /// Gets name of task class that triggered this event.
+ /// </summary>
+ public string TaskClassName { get { return _taskClassName; } }
+
+ /// <summary>
+ /// Gets task session ID of the task that triggered this event.
+ /// </summary>
+ public IgniteGuid TaskSessionId { get { return _taskSessionId; } }
+
+ /// <summary>
+ /// Gets job ID.
+ /// </summary>
+ public IgniteGuid JobId { get { return _jobId; } }
+
+ /// <summary>
+ /// Get node where parent task of the job has originated.
+ /// </summary>
+ public IClusterNode TaskNode { get { return _taskNode; } }
+
+ /// <summary>
+ /// Gets task subject ID.
+ /// </summary>
+ public Guid TaskSubjectId { get { return _taskSubjectId; } }
+
+ /** <inheritDoc /> */
+ public override string ToShortString()
+ {
+ return string.Format("{0}: TaskName={1}, TaskClassName={2}, TaskSessionId={3}, JobId={4}, TaskNode={5}, " +
+ "TaskSubjectId={6}", Name, TaskName, TaskClassName, TaskSessionId, JobId, TaskNode,
+ TaskSubjectId);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Events/SwapSpaceEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Events/SwapSpaceEvent.cs b/modules/platform/dotnet/Apache.Ignite.Core/Events/SwapSpaceEvent.cs
new file mode 100644
index 0000000..676c2e0
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Events/SwapSpaceEvent.cs
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Events
+{
+ using Apache.Ignite.Core.Portable;
+
+ /// <summary>
+ /// Grid swap space event.
+ /// </summary>
+ public sealed class SwapSpaceEvent : EventBase
+ {
+ /** */
+ private readonly string _space;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="r">The reader to read data from.</param>
+ internal SwapSpaceEvent(IPortableRawReader r) : base(r)
+ {
+ _space = r.ReadString();
+ }
+
+ /// <summary>
+ /// Gets swap space name.
+ /// </summary>
+ public string Space { get { return _space; } }
+
+ /** <inheritDoc /> */
+ public override string ToShortString()
+ {
+ return string.Format("{0}: Space={1}", Name, Space);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs b/modules/platform/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs
new file mode 100644
index 0000000..7149fb3
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Events
+{
+ using System;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Portable;
+
+ /// <summary>
+ /// Ignite task event.
+ /// </summary>
+ public sealed class TaskEvent : EventBase
+ {
+ /** */
+ private readonly string _taskName;
+
+ /** */
+ private readonly string _taskClassName;
+
+ /** */
+ private readonly IgniteGuid _taskSessionId;
+
+ /** */
+ private readonly bool _internal;
+
+ /** */
+ private readonly Guid _subjectId;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="r">The reader to read data from.</param>
+ internal TaskEvent(IPortableRawReader r) : base(r)
+ {
+ _taskName = r.ReadString();
+ _taskClassName = r.ReadString();
+ _taskSessionId = IgniteGuid.ReadPortable(r);
+ _internal = r.ReadBoolean();
+ _subjectId = r.ReadGuid() ?? Guid.Empty;
+ }
+
+ /// <summary>
+ /// Gets name of the task that triggered the event.
+ /// </summary>
+ public string TaskName { get { return _taskName; } }
+
+ /// <summary>
+ /// Gets name of task class that triggered this event.
+ /// </summary>
+ public string TaskClassName { get { return _taskClassName; } }
+
+ /// <summary>
+ /// Gets session ID of the task that triggered the event.
+ /// </summary>
+ public IgniteGuid TaskSessionId { get { return _taskSessionId; } }
+
+ /// <summary>
+ /// Returns true if task is created by Ignite and is used for system needs.
+ /// </summary>
+ public bool Internal { get { return _internal; } }
+
+ /// <summary>
+ /// Gets security subject ID initiated this task event, if available. This property is not available for
+ /// <see cref="EventType.EvtTaskSessionAttrSet" /> task event.
+ /// Subject ID will be set either to node ID or client ID initiated task execution.
+ /// </summary>
+ public Guid SubjectId { get { return _subjectId; } }
+
+ /** <inheritDoc /> */
+ public override string ToShortString()
+ {
+ return string.Format("{0}: TaskName={1}, TaskClassName={2}, TaskSessionId={3}, Internal={4}, " +
+ "SubjectId={5}", Name, TaskName, TaskClassName, TaskSessionId, Internal, SubjectId);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/IIgnite.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/IIgnite.cs b/modules/platform/dotnet/Apache.Ignite.Core/IIgnite.cs
new file mode 100644
index 0000000..a9fae89
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/IIgnite.cs
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core
+{
+ using System;
+ using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Compute;
+ using Apache.Ignite.Core.Datastream;
+ using Apache.Ignite.Core.Events;
+ using Apache.Ignite.Core.Messaging;
+ using Apache.Ignite.Core.Portable;
+ using Apache.Ignite.Core.Services;
+ using Apache.Ignite.Core.Transactions;
+
+ /// <summary>
+ /// Main entry point for all Ignite APIs.
+ /// You can obtain an instance of <c>IGrid</c> through <see cref="Ignition.GetIgnite()"/>,
+ /// or for named grids you can use <see cref="Ignition.GetIgnite(string)"/>. Note that you
+ /// can have multiple instances of <c>IGrid</c> running in the same process by giving
+ /// each instance a different name.
+ /// <para/>
+ /// All members are thread-safe and may be used concurrently from multiple threads.
+ /// </summary>
+ public interface IIgnite : IDisposable
+ {
+ /// <summary>
+ /// Gets the name of the grid this Ignite instance (and correspondingly its local node) belongs to.
+ /// Note that single process can have multiple Ignite instances all belonging to different grids. Grid
+ /// name allows to indicate to what grid this particular Ignite instance (i.e. Ignite runtime and its
+ /// local node) belongs to.
+ /// <p/>
+ /// If default Ignite instance is used, then <c>null</c> is returned. Refer to <see cref="Ignition"/> documentation
+ /// for information on how to start named grids.
+ /// </summary>
+ /// <returns>Name of the grid, or <c>null</c> for default grid.</returns>
+ string Name { get; }
+
+ /// <summary>
+ /// Gets an instance of <see cref="ICluster" /> interface.
+ /// </summary>
+ ICluster GetCluster();
+
+ /// <summary>
+ /// Gets compute functionality over this grid projection. All operations
+ /// on the returned ICompute instance will only include nodes from
+ /// this projection.
+ /// </summary>
+ /// <returns>Compute instance over this grid projection.</returns>
+ ICompute GetCompute();
+
+ /// <summary>
+ /// Gets the cache instance for the given name to work with keys and values of specified types.
+ /// <para/>
+ /// You can get instances of ICache of the same name, but with different key/value types.
+ /// These will use the same named cache, but only allow working with entries of specified types.
+ /// Attempt to retrieve an entry of incompatible type will result in <see cref="InvalidCastException"/>.
+ /// Use <see cref="GetCache{TK,TV}"/> in order to work with entries of arbitrary types.
+ /// </summary>
+ /// <param name="name">Cache name.</param>
+ /// <returns>Cache instance for given name.</returns>
+ /// <typeparam name="TK">Cache key type.</typeparam>
+ /// <typeparam name="TV">Cache value type.</typeparam>
+ ICache<TK, TV> GetCache<TK, TV>(string name);
+
+ /// <summary>
+ /// Gets existing cache with the given name or creates new one using template configuration.
+ /// </summary>
+ /// <typeparam name="TK">Cache key type.</typeparam>
+ /// <typeparam name="TV">Cache value type.</typeparam>
+ /// <param name="name">Cache name.</param>
+ /// <returns>Existing or newly created cache.</returns>
+ ICache<TK, TV> GetOrCreateCache<TK, TV>(string name);
+
+ /// <summary>
+ /// Dynamically starts new cache using template configuration.
+ /// </summary>
+ /// <typeparam name="TK">Cache key type.</typeparam>
+ /// <typeparam name="TV">Cache value type.</typeparam>
+ /// <param name="name">Cache name.</param>
+ /// <returns>Existing or newly created cache.</returns>
+ ICache<TK, TV> CreateCache<TK, TV>(string name);
+
+ /// <summary>
+ /// Gets a new instance of data streamer associated with given cache name. Data streamer
+ /// is responsible for loading external data into Ignite. For more information
+ /// refer to <see cref="IDataStreamer{K,V}"/> documentation.
+ /// </summary>
+ /// <param name="cacheName">Cache name (<c>null</c> for default cache).</param>
+ /// <returns>Data streamer.</returns>
+ IDataStreamer<TK, TV> GetDataStreamer<TK, TV>(string cacheName);
+
+ /// <summary>
+ /// Gets an instance of <see cref="IPortables"/> interface.
+ /// </summary>
+ /// <returns>Instance of <see cref="IPortables"/> interface</returns>
+ IPortables GetPortables();
+
+ /// <summary>
+ /// Gets affinity service to provide information about data partitioning and distribution.
+ /// </summary>
+ /// <param name="name">Cache name.</param>
+ /// <returns>Cache data affinity service.</returns>
+ ICacheAffinity GetAffinity(string name);
+
+ /// <summary>
+ /// Gets Ignite transactions facade.
+ /// </summary>
+ ITransactions GetTransactions();
+
+ /// <summary>
+ /// Gets messaging facade over all cluster nodes.
+ /// </summary>
+ /// <returns>Messaging instance over all cluster nodes.</returns>
+ IMessaging GetMessaging();
+
+ /// <summary>
+ /// Gets events facade over all cluster nodes.
+ /// </summary>
+ /// <returns>Events facade over all cluster nodes.</returns>
+ IEvents GetEvents();
+
+ /// <summary>
+ /// Gets services facade over all cluster nodes.
+ /// </summary>
+ /// <returns>Services facade over all cluster nodes.</returns>
+ IServices GetServices();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs b/modules/platform/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
new file mode 100644
index 0000000..5a03e93
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core
+{
+ using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
+ using Apache.Ignite.Core.Lifecycle;
+ using Apache.Ignite.Core.Portable;
+
+ /// <summary>
+ /// Grid configuration.
+ /// </summary>
+ public class IgniteConfiguration
+ {
+ /// <summary>
+ /// Default initial JVM memory in megabytes.
+ /// </summary>
+ public const int DefaultJvmInitMem = 512;
+
+ /// <summary>
+ /// Default maximum JVM memory in megabytes.
+ /// </summary>
+ public const int DefaultJvmMaxMem = 1024;
+
+ /// <summary>
+ /// Default constructor.
+ /// </summary>
+ public IgniteConfiguration()
+ {
+ JvmInitialMemoryMb = DefaultJvmInitMem;
+ JvmMaxMemoryMb = DefaultJvmMaxMem;
+ }
+
+ /// <summary>
+ /// Copying constructor.
+ /// </summary>
+ /// <param name="cfg">Configuration.</param>
+ internal IgniteConfiguration(IgniteConfiguration cfg)
+ {
+ SpringConfigUrl = cfg.SpringConfigUrl;
+ JvmDllPath = cfg.JvmDllPath;
+ IgniteHome = cfg.IgniteHome;
+ JvmClasspath = cfg.JvmClasspath;
+ SuppressWarnings = cfg.SuppressWarnings;
+
+ JvmOptions = cfg.JvmOptions != null ? new List<string>(cfg.JvmOptions) : null;
+ Assemblies = cfg.Assemblies != null ? new List<string>(cfg.Assemblies) : null;
+
+ PortableConfiguration = cfg.PortableConfiguration != null
+ ? new PortableConfiguration(cfg.PortableConfiguration)
+ : null;
+
+ LifecycleBeans = cfg.LifecycleBeans != null ? new List<ILifecycleBean>(cfg.LifecycleBeans) : null;
+
+ JvmInitialMemoryMb = cfg.JvmInitialMemoryMb;
+ JvmMaxMemoryMb = cfg.JvmMaxMemoryMb;
+ }
+
+ /// <summary>
+ /// Gets or sets the portable configuration.
+ /// </summary>
+ /// <value>
+ /// The portable configuration.
+ /// </value>
+ public PortableConfiguration PortableConfiguration { get; set; }
+
+ /// <summary>
+ /// URL to Spring configuration file.
+ /// </summary>
+ [SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")]
+ public string SpringConfigUrl { get; set; }
+
+ /// <summary>
+ /// Path jvm.dll file. If not set, it's location will be determined
+ /// using JAVA_HOME environment variable.
+ /// If path is neither set nor determined automatically, an exception
+ /// will be thrown.
+ /// </summary>
+ public string JvmDllPath { get; set; }
+
+ /// <summary>
+ /// Path to Ignite home. If not set environment variable IGNITE_HOME will be used.
+ /// </summary>
+ public string IgniteHome { get; set; }
+
+ /// <summary>
+ /// Classpath used by JVM on Ignite start.
+ /// </summary>
+ public string JvmClasspath { get; set; }
+
+ /// <summary>
+ /// Collection of options passed to JVM on Ignite start.
+ /// </summary>
+ public ICollection<string> JvmOptions { get; set; }
+
+ /// <summary>
+ /// List of additional .Net assemblies to load on Ignite start. Each item can be either
+ /// fully qualified assembly name, path to assembly to DLL or path to a directory when
+ /// assemblies reside.
+ /// </summary>
+ public IList<string> Assemblies { get; set; }
+
+ /// <summary>
+ /// Whether to suppress warnings.
+ /// </summary>
+ public bool SuppressWarnings { get; set; }
+
+ /// <summary>
+ /// Lifecycle beans.
+ /// </summary>
+ public ICollection<ILifecycleBean> LifecycleBeans { get; set; }
+
+ /// <summary>
+ /// Initial amount of memory in megabytes given to JVM. Maps to -Xms Java option.
+ /// Defaults to <see cref="DefaultJvmInitMem"/>.
+ /// </summary>
+ public int JvmInitialMemoryMb { get; set; }
+
+ /// <summary>
+ /// Maximum amount of memory in megabytes given to JVM. Maps to -Xmx Java option.
+ /// Defaults to <see cref="DefaultJvmMaxMem"/>.
+ /// </summary>
+ public int JvmMaxMemoryMb { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Ignition.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Ignition.cs b/modules/platform/dotnet/Apache.Ignite.Core/Ignition.cs
new file mode 100644
index 0000000..96d002f
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Ignition.cs
@@ -0,0 +1,662 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using Apache.Ignite.Core.Portable;
+
+namespace Apache.Ignite.Core
+{
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
+ using System.Linq;
+ using System.Reflection;
+ using System.Runtime;
+ using System.Runtime.InteropServices;
+ using System.Threading;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Impl;
+ using Apache.Ignite.Core.Impl.Common;
+ using Apache.Ignite.Core.Impl.Handle;
+ using Apache.Ignite.Core.Impl.Memory;
+ using Apache.Ignite.Core.Impl.Portable;
+ using Apache.Ignite.Core.Impl.Portable.IO;
+ using Apache.Ignite.Core.Impl.Unmanaged;
+ using Apache.Ignite.Core.Lifecycle;
+ using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
+ using PU = Apache.Ignite.Core.Impl.Portable.PortableUtils;
+
+ /// <summary>
+ /// This class defines a factory for the main Ignite API.
+ /// <p/>
+ /// Use <see cref="Ignition.Start()"/> method to start Ignite with default configuration.
+ /// <para/>
+ /// All members are thread-safe and may be used concurrently from multiple threads.
+ /// <example>
+ /// You can also use <see cref="IgniteConfiguration"/> to override some default configuration.
+ /// Below is an example on how to start Ignite with custom configuration for portable types and
+ /// provide path to Spring XML configuration file:
+ /// <code>
+ /// IgniteConfiguration cfg = new IgniteConfiguration();
+ ///
+ /// // Create portable type configuration.
+ /// PortableConfiguration portableCfg = new PortableConfiguration();
+ ///
+ /// cfg.SpringConfigUrl = "examples\\config\\example-cache.xml";
+ ///
+ /// portableCfg.TypeConfigurations = new List<PortableTypeConfiguration>
+ /// {
+ /// new PortableTypeConfiguration(typeof(Address)),
+ /// new PortableTypeConfiguration(typeof(Organization))
+ /// };
+ ///
+ /// cfg.PortableConfiguration = portableCfg;
+ ///
+ /// // Start Ignite node with Ignite configuration.
+ /// var ignite = Ignition.Start(cfg);
+ /// </code>
+ /// </example>
+ /// </summary>
+ public static class Ignition
+ {
+ /** */
+ private const string DefaultCfg = "config/default-config.xml";
+
+ /** */
+ private static readonly object SyncRoot = new object();
+
+ /** GC warning flag. */
+ private static int _gcWarn;
+
+ /** */
+ private static readonly IDictionary<NodeKey, Ignite> Nodes = new Dictionary<NodeKey, Ignite>();
+
+ /** Current DLL name. */
+ private static readonly string IgniteDllName = Path.GetFileName(Assembly.GetExecutingAssembly().Location);
+
+ /** Startup info. */
+ [ThreadStatic]
+ private static Startup _startup;
+
+ /** Client mode flag. */
+ [ThreadStatic]
+ private static bool _clientMode;
+
+ /// <summary>
+ /// Static initializer.
+ /// </summary>
+ static Ignition()
+ {
+ AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether Ignite should be started in client mode.
+ /// Client nodes cannot hold data in caches.
+ /// </summary>
+ public static bool ClientMode
+ {
+ get { return _clientMode; }
+ set { _clientMode = value; }
+ }
+
+ /// <summary>
+ /// Starts Ignite with default configuration. By default this method will
+ /// use Ignite configuration defined in <code>IGNITE/config/default-config.xml</code>
+ /// configuration file. If such file is not found, then all system defaults will be used.
+ /// </summary>
+ /// <returns>Started Ignite.</returns>
+ public static IIgnite Start()
+ {
+ return Start(new IgniteConfiguration());
+ }
+
+ /// <summary>
+ /// Starts all grids specified within given Spring XML configuration file. If Ignite with given name
+ /// is already started, then exception is thrown. In this case all instances that may
+ /// have been started so far will be stopped too.
+ /// </summary>
+ /// <param name="springCfgPath">Spring XML configuration file path or URL. Note, that the path can be
+ /// absolute or relative to IGNITE_HOME.</param>
+ /// <returns>Started Ignite. If Spring configuration contains multiple Ignite instances, then the 1st
+ /// found instance is returned.</returns>
+ public static IIgnite Start(string springCfgPath)
+ {
+ return Start(new IgniteConfiguration {SpringConfigUrl = springCfgPath});
+ }
+
+ /// <summary>
+ /// Starts Ignite with given configuration.
+ /// </summary>
+ /// <returns>Started Ignite.</returns>
+ public unsafe static IIgnite Start(IgniteConfiguration cfg)
+ {
+ IgniteArgumentCheck.NotNull(cfg, "cfg");
+
+ // Copy configuration to avoid changes to user-provided instance.
+ IgniteConfigurationEx cfgEx = cfg as IgniteConfigurationEx;
+
+ cfg = cfgEx == null ? new IgniteConfiguration(cfg) : new IgniteConfigurationEx(cfgEx);
+
+ // Set default Spring config if needed.
+ if (cfg.SpringConfigUrl == null)
+ cfg.SpringConfigUrl = DefaultCfg;
+
+ lock (SyncRoot)
+ {
+ // 1. Check GC settings.
+ CheckServerGc(cfg);
+
+ // 2. Create context.
+ IgniteUtils.LoadDlls(cfg.JvmDllPath);
+
+ var cbs = new UnmanagedCallbacks();
+
+ void* ctx = IgniteManager.GetContext(cfg, cbs);
+
+ sbyte* cfgPath0 = IgniteUtils.StringToUtf8Unmanaged(cfg.SpringConfigUrl ?? DefaultCfg);
+
+ string gridName = cfgEx != null ? cfgEx.GridName : null;
+ sbyte* gridName0 = IgniteUtils.StringToUtf8Unmanaged(gridName);
+
+ // 3. Create startup object which will guide us through the rest of the process.
+ _startup = new Startup(cfg, cbs) { Context = ctx };
+
+ IUnmanagedTarget interopProc = null;
+
+ try
+ {
+ // 4. Initiate Ignite start.
+ UU.IgnitionStart(cbs.Context, cfg.SpringConfigUrl ?? DefaultCfg,
+ cfgEx != null ? cfgEx.GridName : null, ClientMode);
+
+ // 5. At this point start routine is finished. We expect STARTUP object to have all necessary data.
+ var node = _startup.Ignite;
+ interopProc = node.InteropProcessor;
+
+ // 6. On-start callback (notify lifecycle components).
+ node.OnStart();
+
+ Nodes[new NodeKey(_startup.Name)] = node;
+
+ return node;
+ }
+ catch (Exception)
+ {
+ // 1. Perform keys cleanup.
+ string name = _startup.Name;
+
+ if (name != null)
+ {
+ NodeKey key = new NodeKey(name);
+
+ if (Nodes.ContainsKey(key))
+ Nodes.Remove(key);
+ }
+
+ // 2. Stop Ignite node if it was started.
+ if (interopProc != null)
+ UU.IgnitionStop(interopProc.Context, gridName, true);
+
+ // 3. Throw error further (use startup error if exists because it is more precise).
+ if (_startup.Error != null)
+ throw _startup.Error;
+
+ throw;
+ }
+ finally
+ {
+ _startup = null;
+
+ Marshal.FreeHGlobal((IntPtr)cfgPath0);
+
+ if ((IntPtr)gridName0 != IntPtr.Zero)
+ Marshal.FreeHGlobal((IntPtr)gridName0);
+
+ if (interopProc != null)
+ UU.ProcessorReleaseStart(interopProc);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Check whether GC is set to server mode.
+ /// </summary>
+ /// <param name="cfg">Configuration.</param>
+ private static void CheckServerGc(IgniteConfiguration cfg)
+ {
+ if (!cfg.SuppressWarnings && !GCSettings.IsServerGC && Interlocked.CompareExchange(ref _gcWarn, 1, 0) == 0)
+ Console.WriteLine("GC server mode is not enabled, this could lead to less " +
+ "than optimal performance on multi-core machines (to enable see " +
+ "http://msdn.microsoft.com/en-us/library/ms229357(v=vs.110).aspx).");
+ }
+
+ /// <summary>
+ /// Prepare callback invoked from Java.
+ /// </summary>
+ /// <param name="inStream">Intput stream with data.</param>
+ /// <param name="outStream">Output stream.</param>
+ /// <param name="handleRegistry">Handle registry.</param>
+ internal static void OnPrepare(PlatformMemoryStream inStream, PlatformMemoryStream outStream,
+ HandleRegistry handleRegistry)
+ {
+ try
+ {
+ PortableReaderImpl reader = PU.Marshaller.StartUnmarshal(inStream);
+
+ PrepareConfiguration(reader);
+
+ PrepareLifecycleBeans(reader, outStream, handleRegistry);
+ }
+ catch (Exception e)
+ {
+ _startup.Error = e;
+
+ throw;
+ }
+ }
+
+ /// <summary>
+ /// Preapare configuration.
+ /// </summary>
+ /// <param name="reader">Reader.</param>
+ private static void PrepareConfiguration(PortableReaderImpl reader)
+ {
+ // 1. Load assemblies.
+ IgniteConfiguration cfg = _startup.Configuration;
+
+ LoadAssemblies(cfg.Assemblies);
+
+ ICollection<string> cfgAssembllies;
+ PortableConfiguration portableCfg;
+
+ PortableUtils.ReadConfiguration(reader, out cfgAssembllies, out portableCfg);
+
+ LoadAssemblies(cfgAssembllies);
+
+ // 2. Create marshaller only after assemblies are loaded.
+ if (cfg.PortableConfiguration == null)
+ cfg.PortableConfiguration = portableCfg;
+
+ _startup.Marshaller = new PortableMarshaller(cfg.PortableConfiguration);
+ }
+
+ /// <summary>
+ /// Prepare lifecycle beans.
+ /// </summary>
+ /// <param name="reader">Reader.</param>
+ /// <param name="outStream">Output stream.</param>
+ /// <param name="handleRegistry">Handle registry.</param>
+ private static void PrepareLifecycleBeans(PortableReaderImpl reader, PlatformMemoryStream outStream,
+ HandleRegistry handleRegistry)
+ {
+ IList<LifecycleBeanHolder> beans = new List<LifecycleBeanHolder>();
+
+ // 1. Read beans defined in Java.
+ int cnt = reader.ReadInt();
+
+ for (int i = 0; i < cnt; i++)
+ beans.Add(new LifecycleBeanHolder(CreateLifecycleBean(reader)));
+
+ // 2. Append beans definied in local configuration.
+ ICollection<ILifecycleBean> nativeBeans = _startup.Configuration.LifecycleBeans;
+
+ if (nativeBeans != null)
+ {
+ foreach (ILifecycleBean nativeBean in nativeBeans)
+ beans.Add(new LifecycleBeanHolder(nativeBean));
+ }
+
+ // 3. Write bean pointers to Java stream.
+ outStream.WriteInt(beans.Count);
+
+ foreach (LifecycleBeanHolder bean in beans)
+ outStream.WriteLong(handleRegistry.AllocateCritical(bean));
+
+ outStream.SynchronizeOutput();
+
+ // 4. Set beans to STARTUP object.
+ _startup.LifecycleBeans = beans;
+ }
+
+ /// <summary>
+ /// Create lifecycle bean.
+ /// </summary>
+ /// <param name="reader">Reader.</param>
+ /// <returns>Lifecycle bean.</returns>
+ internal static ILifecycleBean CreateLifecycleBean(PortableReaderImpl reader)
+ {
+ // 1. Instantiate.
+ string assemblyName = reader.ReadString();
+ string clsName = reader.ReadString();
+
+ object bean = IgniteUtils.CreateInstance(assemblyName, clsName);
+
+ // 2. Set properties.
+ IDictionary<string, object> props = reader.ReadGenericDictionary<string, object>();
+
+ IgniteUtils.SetProperties(bean, props);
+
+ return bean as ILifecycleBean;
+ }
+
+ /// <summary>
+ /// Kernal start callback.
+ /// </summary>
+ /// <param name="interopProc">Interop processor.</param>
+ /// <param name="stream">Stream.</param>
+ internal static void OnStart(IUnmanagedTarget interopProc, IPortableStream stream)
+ {
+ try
+ {
+ // 1. Read data and leave critical state ASAP.
+ PortableReaderImpl reader = PU.Marshaller.StartUnmarshal(stream);
+
+ // ReSharper disable once PossibleInvalidOperationException
+ var name = reader.ReadString();
+
+ // 2. Set ID and name so that Start() method can use them later.
+ _startup.Name = name;
+
+ if (Nodes.ContainsKey(new NodeKey(name)))
+ throw new IgniteException("Ignite with the same name already started: " + name);
+
+ _startup.Ignite = new Ignite(_startup.Configuration, _startup.Name, interopProc, _startup.Marshaller,
+ _startup.LifecycleBeans, _startup.Callbacks);
+ }
+ catch (Exception e)
+ {
+ // 5. Preserve exception to throw it later in the "Start" method and throw it further
+ // to abort startup in Java.
+ _startup.Error = e;
+
+ throw;
+ }
+ }
+
+ /// <summary>
+ /// Load assemblies.
+ /// </summary>
+ /// <param name="assemblies">Assemblies.</param>
+ private static void LoadAssemblies(IEnumerable<string> assemblies)
+ {
+ if (assemblies != null)
+ {
+ foreach (string s in assemblies)
+ {
+ // 1. Try loading as directory.
+ if (Directory.Exists(s))
+ {
+ string[] files = Directory.GetFiles(s, "*.dll");
+
+#pragma warning disable 0168
+
+ foreach (string dllPath in files)
+ {
+ if (!SelfAssembly(dllPath))
+ {
+ try
+ {
+ Assembly.LoadFile(dllPath);
+ }
+
+ catch (BadImageFormatException)
+ {
+ // No-op.
+ }
+ }
+ }
+
+#pragma warning restore 0168
+
+ continue;
+ }
+
+ // 2. Try loading using full-name.
+ try
+ {
+ Assembly assembly = Assembly.Load(s);
+
+ if (assembly != null)
+ continue;
+ }
+ catch (Exception e)
+ {
+ if (!(e is FileNotFoundException || e is FileLoadException))
+ throw new IgniteException("Failed to load assembly: " + s, e);
+ }
+
+ // 3. Try loading using file path.
+ try
+ {
+ Assembly assembly = Assembly.LoadFrom(s);
+
+ if (assembly != null)
+ continue;
+ }
+ catch (Exception e)
+ {
+ if (!(e is FileNotFoundException || e is FileLoadException))
+ throw new IgniteException("Failed to load assembly: " + s, e);
+ }
+
+ // 4. Not found, exception.
+ throw new IgniteException("Failed to load assembly: " + s);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Whether assembly points to Ignite binary.
+ /// </summary>
+ /// <param name="assembly">Assembly to check..</param>
+ /// <returns><c>True</c> if this is one of GG assemblies.</returns>
+ private static bool SelfAssembly(string assembly)
+ {
+ return assembly.EndsWith(IgniteDllName, StringComparison.OrdinalIgnoreCase);
+ }
+
+ /// <summary>
+ /// Gets a named Ignite instance. If Ignite name is {@code null} or empty string,
+ /// then default no-name Ignite will be returned. Note that caller of this method
+ /// should not assume that it will return the same instance every time.
+ /// <p/>
+ /// Note that single process can run multiple Ignite instances and every Ignite instance (and its
+ /// node) can belong to a different grid. Ignite name defines what grid a particular Ignite
+ /// instance (and correspondingly its node) belongs to.
+ /// </summary>
+ /// <param name="name">Ignite name to which requested Ignite instance belongs. If <code>null</code>,
+ /// then Ignite instance belonging to a default no-name Ignite will be returned.
+ /// </param>
+ /// <returns>An instance of named grid.</returns>
+ public static IIgnite GetIgnite(string name)
+ {
+ lock (SyncRoot)
+ {
+ Ignite result;
+
+ if (!Nodes.TryGetValue(new NodeKey(name), out result))
+ throw new IgniteException("Ignite instance was not properly started or was already stopped: " + name);
+
+ return result;
+ }
+ }
+
+ /// <summary>
+ /// Gets an instance of default no-name grid. Note that
+ /// caller of this method should not assume that it will return the same
+ /// instance every time.
+ /// </summary>
+ /// <returns>An instance of default no-name grid.</returns>
+ public static IIgnite GetIgnite()
+ {
+ return GetIgnite(null);
+ }
+
+ /// <summary>
+ /// Stops named grid. If <code>cancel</code> flag is set to <code>true</code> then
+ /// all jobs currently executing on local node will be interrupted. If
+ /// grid name is <code>null</code>, then default no-name Ignite will be stopped.
+ /// </summary>
+ /// <param name="name">Grid name. If <code>null</code>, then default no-name Ignite will be stopped.</param>
+ /// <param name="cancel">If <code>true</code> then all jobs currently executing will be cancelled
+ /// by calling <code>ComputeJob.cancel</code>method.</param>
+ /// <returns><code>true</code> if named Ignite instance was indeed found and stopped, <code>false</code>
+ /// othwerwise (the instance with given <code>name</code> was not found).</returns>
+ public static bool Stop(string name, bool cancel)
+ {
+ lock (SyncRoot)
+ {
+ NodeKey key = new NodeKey(name);
+
+ Ignite node;
+
+ if (!Nodes.TryGetValue(key, out node))
+ return false;
+
+ node.Stop(cancel);
+
+ Nodes.Remove(key);
+
+ GC.Collect();
+
+ return true;
+ }
+ }
+
+ /// <summary>
+ /// Stops <b>all</b> started grids. If <code>cancel</code> flag is set to <code>true</code> then
+ /// all jobs currently executing on local node will be interrupted.
+ /// </summary>
+ /// <param name="cancel">If <code>true</code> then all jobs currently executing will be cancelled
+ /// by calling <code>ComputeJob.cancel</code>method.</param>
+ public static void StopAll(bool cancel)
+ {
+ lock (SyncRoot)
+ {
+ while (Nodes.Count > 0)
+ {
+ var entry = Nodes.First();
+
+ entry.Value.Stop(cancel);
+
+ Nodes.Remove(entry.Key);
+ }
+ }
+
+ GC.Collect();
+ }
+
+ /// <summary>
+ /// Handles the AssemblyResolve event of the CurrentDomain control.
+ /// </summary>
+ /// <param name="sender">The source of the event.</param>
+ /// <param name="args">The <see cref="ResolveEventArgs"/> instance containing the event data.</param>
+ /// <returns>Manually resolved assembly, or null.</returns>
+ private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
+ {
+ return LoadedAssembliesResolver.Instance.GetAssembly(args.Name);
+ }
+
+ /// <summary>
+ /// Grid key.
+ /// </summary>
+ private class NodeKey
+ {
+ /** */
+ private readonly string _name;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="NodeKey"/> class.
+ /// </summary>
+ /// <param name="name">The name.</param>
+ internal NodeKey(string name)
+ {
+ _name = name;
+ }
+
+ /** <inheritdoc /> */
+ public override bool Equals(object obj)
+ {
+ var other = obj as NodeKey;
+
+ return other != null && Equals(_name, other._name);
+ }
+
+ /** <inheritdoc /> */
+ public override int GetHashCode()
+ {
+ return _name == null ? 0 : _name.GetHashCode();
+ }
+ }
+
+ /// <summary>
+ /// Value object to pass data between .Net methods during startup bypassing Java.
+ /// </summary>
+ private unsafe class Startup
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="cfg">Configuration.</param>
+ /// <param name="cbs"></param>
+ internal Startup(IgniteConfiguration cfg, UnmanagedCallbacks cbs)
+ {
+ Configuration = cfg;
+ Callbacks = cbs;
+ }
+ /// <summary>
+ /// Configuration.
+ /// </summary>
+ internal IgniteConfiguration Configuration { get; private set; }
+
+ /// <summary>
+ /// Gets unmanaged callbacks.
+ /// </summary>
+ internal UnmanagedCallbacks Callbacks { get; private set; }
+
+ /// <summary>
+ /// Lifecycle beans.
+ /// </summary>
+ internal IList<LifecycleBeanHolder> LifecycleBeans { get; set; }
+
+ /// <summary>
+ /// Node name.
+ /// </summary>
+ internal string Name { get; set; }
+
+ /// <summary>
+ /// Marshaller.
+ /// </summary>
+ internal PortableMarshaller Marshaller { get; set; }
+
+ /// <summary>
+ /// Start error.
+ /// </summary>
+ internal Exception Error { get; set; }
+
+ /// <summary>
+ /// Gets or sets the context.
+ /// </summary>
+ internal void* Context { get; set; }
+
+ /// <summary>
+ /// Gets or sets the ignite.
+ /// </summary>
+ internal Ignite Ignite { get; set; }
+ }
+ }
+}