You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/09/22 17:01:59 UTC
[25/51] [partial] ignite git commit: IGNITE-1513: Finalized build
procedure.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
deleted file mode 100644
index 8b44966..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
+++ /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.
- */
-
-namespace Apache.Ignite.Core.Impl.Events
-{
- using System;
- using System.Diagnostics;
- using Apache.Ignite.Core.Events;
- using Apache.Ignite.Core.Impl.Common;
- using Apache.Ignite.Core.Impl.Portable;
- using Apache.Ignite.Core.Impl.Portable.IO;
-
- /// <summary>
- /// Event filter/listener holder for RemoteListen.
- /// </summary>
- internal class RemoteListenEventFilter : IInteropCallback
- {
- /** */
- private readonly Ignite _ignite;
-
- /** */
- 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)
- {
- _ignite = ignite;
- _filter = filter;
- }
-
- /** <inheritdoc /> */
- public int Invoke(IPortableStream stream)
- {
- var reader = _ignite.Marshaller.StartUnmarshal(stream);
-
- var evt = EventReader.Read<IEvent>(reader);
-
- var nodeId = reader.ReadGuid() ?? Guid.Empty;
-
- return _filter(nodeId, evt) ? 1 : 0;
- }
-
- /// <summary>
- /// Creates an instance of this class from a stream.
- /// </summary>
- /// <param name="memPtr">Memory pointer.</param>
- /// <param name="grid">Grid</param>
- /// <returns>Deserialized instance of <see cref="RemoteListenEventFilter"/></returns>
- public static RemoteListenEventFilter CreateInstance(long memPtr, Ignite grid)
- {
- Debug.Assert(grid != null);
-
- using (var stream = IgniteManager.Memory.Get(memPtr).Stream())
- {
- var marsh = grid.Marshaller;
-
- var reader = marsh.StartUnmarshal(stream);
-
- var pred = reader.ReadObject<PortableOrSerializableObjectHolder>().Item;
-
- var func = DelegateTypeDescriptor.GetEventFilter(pred.GetType());
-
- return new RemoteListenEventFilter(grid, (id, evt) => func(pred, id, evt));
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
deleted file mode 100644
index 066f345..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
+++ /dev/null
@@ -1,204 +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
-{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Runtime.InteropServices;
- using System.Security;
- using System.Threading;
- using Apache.Ignite.Core.Cache;
- using Apache.Ignite.Core.Cache.Store;
- using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Compute;
- using Apache.Ignite.Core.Impl.Portable;
- using Apache.Ignite.Core.Transactions;
-
- /// <summary>
- /// Managed environment. Acts as a gateway for native code.
- /// </summary>
- [StructLayout(LayoutKind.Sequential)]
- internal static class ExceptionUtils
- {
- /** NoClassDefFoundError fully-qualified class name which is important during startup phase. */
- private const string ClsNoClsDefFoundErr = "java.lang.NoClassDefFoundError";
-
- /** NoSuchMethodError fully-qualified class name which is important during startup phase. */
- private const string ClsNoSuchMthdErr = "java.lang.NoSuchMethodError";
-
- /** InteropCachePartialUpdateException. */
- private const string ClsCachePartialUpdateErr = "org.apache.ignite.internal.processors.platform.cache.PlatformCachePartialUpdateException";
-
- /** Map with predefined exceptions. */
- private static readonly IDictionary<string, ExceptionFactoryDelegate> EXS = new Dictionary<string, ExceptionFactoryDelegate>();
-
- /** Exception factory delegate. */
- private delegate Exception ExceptionFactoryDelegate(string msg);
-
- /// <summary>
- /// Static initializer.
- /// </summary>
- static ExceptionUtils()
- {
- // Common Java exceptions mapped to common .Net exceptions.
- EXS["java.lang.IllegalArgumentException"] = m => new ArgumentException(m);
- EXS["java.lang.IllegalStateException"] = m => new InvalidOperationException(m);
- EXS["java.lang.UnsupportedOperationException"] = m => new NotImplementedException(m);
- EXS["java.lang.InterruptedException"] = m => new ThreadInterruptedException(m);
-
- // Generic Ignite exceptions.
- EXS["org.apache.ignite.IgniteException"] = m => new IgniteException(m);
- EXS["org.apache.ignite.IgniteCheckedException"] = m => new IgniteException(m);
-
- // Cluster exceptions.
- EXS["org.apache.ignite.cluster.ClusterGroupEmptyException"] = m => new ClusterGroupEmptyException(m);
- EXS["org.apache.ignite.cluster.ClusterTopologyException"] = m => new ClusterTopologyException(m);
-
- // Compute exceptions.
- EXS["org.apache.ignite.compute.ComputeExecutionRejectedException"] = m => new ComputeExecutionRejectedException(m);
- EXS["org.apache.ignite.compute.ComputeJobFailoverException"] = m => new ComputeJobFailoverException(m);
- EXS["org.apache.ignite.compute.ComputeTaskCancelledException"] = m => new ComputeTaskCancelledException(m);
- EXS["org.apache.ignite.compute.ComputeTaskTimeoutException"] = m => new ComputeTaskTimeoutException(m);
- EXS["org.apache.ignite.compute.ComputeUserUndeclaredException"] = m => new ComputeUserUndeclaredException(m);
-
- // Cache exceptions.
- EXS["javax.cache.CacheException"] = m => new CacheException(m);
- EXS["javax.cache.integration.CacheLoaderException"] = m => new CacheStoreException(m);
- EXS["javax.cache.integration.CacheWriterException"] = m => new CacheStoreException(m);
- EXS["javax.cache.processor.EntryProcessorException"] = m => new CacheEntryProcessorException(m);
- EXS["org.apache.ignite.cache.CacheAtomicUpdateTimeoutException"] = m => new CacheAtomicUpdateTimeoutException(m);
-
- // Transaction exceptions.
- EXS["org.apache.ignite.transactions.TransactionOptimisticException"] = m => new TransactionOptimisticException(m);
- EXS["org.apache.ignite.transactions.TransactionTimeoutException"] = m => new TransactionTimeoutException(m);
- EXS["org.apache.ignite.transactions.TransactionRollbackException"] = m => new TransactionRollbackException(m);
- EXS["org.apache.ignite.transactions.TransactionHeuristicException"] = m => new TransactionHeuristicException(m);
-
- // Security exceptions.
- EXS["org.apache.ignite.IgniteAuthenticationException"] = m => new SecurityException(m);
- EXS["org.apache.ignite.plugin.security.GridSecurityException"] = m => new SecurityException(m);
- }
-
- /// <summary>
- /// Creates exception according to native code class and message.
- /// </summary>
- /// <param name="clsName">Exception class name.</param>
- /// <param name="msg">Exception message.</param>
- /// <param name="reader">Error data reader.</param>
- public static Exception GetException(string clsName, string msg, PortableReaderImpl reader = null)
- {
- ExceptionFactoryDelegate ctor;
-
- if (EXS.TryGetValue(clsName, out ctor))
- return ctor(msg);
-
- if (ClsNoClsDefFoundErr.Equals(clsName))
- return new IgniteException("Java class is not found (did you set IGNITE_HOME environment " +
- "variable?): " + msg);
-
- if (ClsNoSuchMthdErr.Equals(clsName))
- return new IgniteException("Java class method is not found (did you set IGNITE_HOME environment " +
- "variable?): " + msg);
-
- if (ClsCachePartialUpdateErr.Equals(clsName))
- return ProcessCachePartialUpdateException(msg, reader);
-
- return new IgniteException("Java exception occurred [class=" + clsName + ", message=" + msg + ']');
- }
-
- /// <summary>
- /// Process cache partial update exception.
- /// </summary>
- /// <param name="msg">Message.</param>
- /// <param name="reader">Reader.</param>
- /// <returns></returns>
- private static Exception ProcessCachePartialUpdateException(string msg, PortableReaderImpl reader)
- {
- if (reader == null)
- return new CachePartialUpdateException(msg, new IgniteException("Failed keys are not available."));
-
- bool dataExists = reader.ReadBoolean();
-
- Debug.Assert(dataExists);
-
- if (reader.ReadBoolean())
- {
- bool keepPortable = reader.ReadBoolean();
-
- PortableReaderImpl keysReader = reader.Marshaller.StartUnmarshal(reader.Stream, keepPortable);
-
- try
- {
- return new CachePartialUpdateException(msg, ReadNullableList(keysReader));
- }
- catch (Exception e)
- {
- // Failed to deserialize data.
- return new CachePartialUpdateException(msg, e);
- }
- }
-
- // Was not able to write keys.
- string innerErrCls = reader.ReadString();
- string innerErrMsg = reader.ReadString();
-
- Exception innerErr = GetException(innerErrCls, innerErrMsg);
-
- return new CachePartialUpdateException(msg, innerErr);
- }
-
- /// <summary>
- /// Create JVM initialization exception.
- /// </summary>
- /// <param name="clsName">Class name.</param>
- /// <param name="msg">Message.</param>
- /// <returns>Exception.</returns>
- public static Exception GetJvmInitializeException(string clsName, string msg)
- {
- if (clsName != null)
- return new IgniteException("Failed to initialize JVM.", GetException(clsName, msg));
-
- if (msg != null)
- return new IgniteException("Failed to initialize JVM: " + msg);
-
- return new IgniteException("Failed to initialize JVM.");
- }
-
- /// <summary>
- /// Reads nullable list.
- /// </summary>
- /// <param name="reader">Reader.</param>
- /// <returns>List.</returns>
- private static List<object> ReadNullableList(PortableReaderImpl reader)
- {
- if (!reader.ReadBoolean())
- return null;
-
- var size = reader.ReadInt();
-
- var list = new List<object>(size);
-
- for (int i = 0; i < size; i++)
- list.Add(reader.ReadObject<object>());
-
- return list;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.cs
deleted file mode 100644
index 0168963..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl.Handle
-{
- using System;
- using System.Threading;
-
- /// <summary>
- /// Wrapper over some resource ensuring it's release.
- /// </summary>
- public class Handle<T> : IHandle
- {
- /** Target.*/
- private readonly T _target;
-
- /** Release action. */
- private readonly Action<T> _releaseAction;
-
- /** Release flag. */
- private int _released;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="target">Target.</param>
- /// <param name="releaseAction">Release action.</param>
- public Handle(T target, Action<T> releaseAction)
- {
- _target = target;
- _releaseAction = releaseAction;
- }
-
- /// <summary>
- /// Target.
- /// </summary>
- public T Target
- {
- get { return _target; }
- }
-
- /** <inheritdoc /> */
- public void Release()
- {
- if (Interlocked.CompareExchange(ref _released, 1, 0) == 0)
- _releaseAction(_target);
- }
-
- /** <inheritdoc /> */
- public bool Released
- {
- get { return Thread.VolatileRead(ref _released) == 1; }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs
deleted file mode 100644
index 9c8178f..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs
+++ /dev/null
@@ -1,340 +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.Handle
-{
- using System;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading;
-
- /// <summary>
- /// Resource registry.
- /// </summary>
- public class HandleRegistry
- {
- /** Default critical resources capacity. */
- internal const int DfltFastCap = 1024;
-
- /** Array for fast-path. */
- private readonly object[] _fast;
-
- /** Dictionery for slow-path. */
- private readonly ConcurrentDictionary<long, object> _slow;
-
- /** Capacity of fast array. */
- private readonly int _fastCap;
-
- /** Counter for fast-path. */
- private int _fastCtr;
-
- /** Counter for slow-path. */
- private long _slowCtr;
-
- /** Close flag. */
- private int _closed;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- public HandleRegistry() : this(DfltFastCap)
- {
- // No-op.
- }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="fastCap">Amount of critical resources this registry can allocate in "fast" mode.</param>
- public HandleRegistry(int fastCap)
- {
- _fastCap = fastCap;
- _fast = new object[fastCap];
-
- _slow = new ConcurrentDictionary<long, object>();
- _slowCtr = fastCap;
- }
-
- /// <summary>
- /// Allocate a handle for resource.
- /// </summary>
- /// <param name="target">Target.</param>
- /// <returns>Pointer.</returns>
- public long Allocate(object target)
- {
- return Allocate0(target, false, false);
- }
-
- /// <summary>
- /// Allocate a handle in safe mode.
- /// </summary>
- /// <param name="target">Target.</param>
- /// <returns>Pointer.</returns>
- public long AllocateSafe(object target)
- {
- return Allocate0(target, false, true);
- }
-
- /// <summary>
- /// Allocate a handle for critical resource.
- /// </summary>
- /// <param name="target">Target.</param>
- /// <returns>Pointer.</returns>
- public long AllocateCritical(object target)
- {
- return Allocate0(target, true, false);
- }
-
- /// <summary>
- /// Allocate a handle for critical resource in safe mode.
- /// </summary>
- /// <param name="target">Target.</param>
- /// <returns>Pointer.</returns>
- public long AllocateCriticalSafe(object target)
- {
- return Allocate0(target, true, true);
- }
-
- /// <summary>
- /// Internal allocation routine.
- /// </summary>
- /// <param name="target">Target.</param>
- /// <param name="critical">Critical flag.</param>
- /// <param name="safe">Safe flag.</param>
- /// <returns>Pointer.</returns>
- private long Allocate0(object target, bool critical, bool safe)
- {
- if (Closed)
- throw ClosedException();
-
- // Try allocating on critical path.
- if (critical)
- {
- if (_fastCtr < _fastCap) // Non-volatile read could yield in old value, but increment resolves this.
- {
- int fastIdx = Interlocked.Increment(ref _fastCtr);
-
- if (fastIdx < _fastCap)
- {
- Thread.VolatileWrite(ref _fast[fastIdx], target);
-
- if (safe && Closed)
- {
- Thread.VolatileWrite(ref _fast[fastIdx], null);
-
- Release0(target, true);
-
- throw ClosedException();
- }
-
- return fastIdx;
- }
- }
- }
-
- // Critical allocation failed, fallback to slow mode.
- long slowIdx = Interlocked.Increment(ref _slowCtr);
-
- _slow[slowIdx] = target;
-
- if (safe && Closed)
- {
- _slow[slowIdx] = null;
-
- Release0(target, true);
-
- throw ClosedException();
- }
-
- return slowIdx;
- }
-
-
- /// <summary>
- /// Release handle.
- /// </summary>
- /// <param name="id">Identifier.</param>
- /// <param name="quiet">Whether release must be quiet or not.</param>
- public void Release(long id, bool quiet = false)
- {
- if (id < _fastCap)
- {
- object target = Thread.VolatileRead(ref _fast[id]);
-
- if (target != null)
- {
- Thread.VolatileWrite(ref _fast[id], null);
-
- Release0(target, quiet);
- }
- }
- else
- {
- object target;
-
- if (_slow.TryRemove(id, out target))
- Release0(target, quiet);
- }
- }
-
- /// <summary>
- /// Internal release routine.
- /// </summary>
- /// <param name="target">Target.</param>
- /// <param name="quiet">Whether release must be quiet or not.</param>
- private static void Release0(object target, bool quiet)
- {
- IHandle target0 = target as IHandle;
-
- if (target0 != null)
- {
- if (quiet)
- {
- try
- {
- target0.Release();
- }
- catch (Exception)
- {
- // No-op.
- }
- }
- else
- target0.Release();
- }
- }
-
- /// <summary>
- /// Gets handle target.
- /// </summary>
- /// <param name="id">Identifier.</param>
- /// <returns>Target.</returns>
- public T Get<T>(long id)
- {
- return Get<T>(id, false);
- }
-
- /// <summary>
- /// Gets handle target.
- /// </summary>
- /// <param name="id">Identifier.</param>
- /// <param name="throwOnAbsent">Whether to throw an exception if resource is not found.</param>
- /// <returns>Target.</returns>
- public T Get<T>(long id, bool throwOnAbsent)
- {
- object target;
-
- if (id < _fastCap)
- {
- target = Thread.VolatileRead(ref _fast[id]);
-
- if (target != null)
- return (T)target;
- }
- else
- {
- if (_slow.TryGetValue(id, out target))
- return (T) target;
- }
-
- if (throwOnAbsent)
- throw new InvalidOperationException("Resource handle has been released (is Ignite stopping?).");
-
- return default(T);
- }
-
- /// <summary>
- /// Close the registry. All resources allocated at the moment of close are
- /// guaranteed to be released.
- /// </summary>
- public void Close()
- {
- if (Interlocked.CompareExchange(ref _closed, 1, 0) == 0)
- {
- // Cleanup on fast-path.
- for (int i = 0; i < _fastCap; i++)
- {
- object target = Thread.VolatileRead(ref _fast[i]);
-
- if (target != null)
- {
- Thread.VolatileWrite(ref _fast[i], null);
-
- Release0(target, true);
- }
- }
-
- // Cleanup on slow-path.
- foreach (var item in _slow)
- {
- object target = item.Value;
-
- if (target != null)
- Release0(target, true);
- }
-
- _slow.Clear();
- }
- }
-
- /// <summary>
- /// Closed flag.
- /// </summary>
- public bool Closed
- {
- get { return Thread.VolatileRead(ref _closed) == 1; }
- }
-
- /// <summary>
- /// Gets the current handle count.
- /// </summary>
- public int Count
- {
- get
- {
- Thread.MemoryBarrier();
-
- return _fast.Count(x => x != null) + _slow.Count;
- }
- }
-
- /// <summary>
- /// Gets a snapshot of currently referenced objects list.
- /// </summary>
- public List<KeyValuePair<long, object>> GetItems()
- {
- Thread.MemoryBarrier();
-
- return
- _fast.Select((x, i) => new KeyValuePair<long, object>(i, x))
- .Where(x => x.Value != null)
- .Concat(_slow)
- .ToList();
- }
-
- /// <summary>
- /// Create new exception for closed state.
- /// </summary>
- /// <returns>Exception.</returns>
- private static Exception ClosedException()
- {
- return new InvalidOperationException("Cannot allocate a resource handle because Ignite is stopping.");
- }
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/IHandle.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/IHandle.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/IHandle.cs
deleted file mode 100644
index d147f8b..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/IHandle.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.Impl.Handle
-{
- /// <summary>
- /// Wrapper over some resource ensuring it's release.
- /// </summary>
- public interface IHandle
- {
- /// <summary>
- /// Release the resource.
- /// </summary>
- void Release();
-
- /// <summary>
- /// Resource released flag.
- /// </summary>
- bool Released { get; }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IInteropCallback.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IInteropCallback.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IInteropCallback.cs
deleted file mode 100644
index 91838d0..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IInteropCallback.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl
-{
- using Apache.Ignite.Core.Impl.Portable.IO;
-
- /// <summary>
- /// Interop callback.
- /// </summary>
- internal interface IInteropCallback
- {
- /// <summary>
- /// Invokes callback.
- /// </summary>
- /// <param name="stream">Stream.</param>
- /// <returns>Invocation result.</returns>
- int Invoke(IPortableStream stream);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Ignite.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
deleted file mode 100644
index 5f764c1..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
+++ /dev/null
@@ -1,511 +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
-{
- using System;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- 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.Impl.Cache;
- using Apache.Ignite.Core.Impl.Cluster;
- using Apache.Ignite.Core.Impl.Common;
- using Apache.Ignite.Core.Impl.Datastream;
- using Apache.Ignite.Core.Impl.Handle;
- using Apache.Ignite.Core.Impl.Portable;
- using Apache.Ignite.Core.Impl.Transactions;
- using Apache.Ignite.Core.Impl.Unmanaged;
- using Apache.Ignite.Core.Lifecycle;
- using Apache.Ignite.Core.Messaging;
- using Apache.Ignite.Core.Portable;
- using Apache.Ignite.Core.Services;
- using Apache.Ignite.Core.Transactions;
- using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
-
- /// <summary>
- /// Native Ignite wrapper.
- /// </summary>
- internal class Ignite : IIgnite, IClusterGroupEx, ICluster
- {
- /** */
- private readonly IgniteConfiguration _cfg;
-
- /** Grid name. */
- private readonly string _name;
-
- /** Unmanaged node. */
- private readonly IUnmanagedTarget _proc;
-
- /** Marshaller. */
- private readonly PortableMarshaller _marsh;
-
- /** Initial projection. */
- private readonly ClusterGroupImpl _prj;
-
- /** Portables. */
- private readonly PortablesImpl _portables;
-
- /** Cached proxy. */
- private readonly IgniteProxy _proxy;
-
- /** Lifecycle beans. */
- private readonly IList<LifecycleBeanHolder> _lifecycleBeans;
-
- /** Local node. */
- private IClusterNode _locNode;
-
- /** Transactions facade. */
- private readonly Lazy<TransactionsImpl> _transactions;
-
- /** Callbacks */
- private readonly UnmanagedCallbacks _cbs;
-
- /** Node info cache. */
-
- private readonly ConcurrentDictionary<Guid, ClusterNodeImpl> _nodes =
- new ConcurrentDictionary<Guid, ClusterNodeImpl>();
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="cfg">Configuration.</param>
- /// <param name="name">Grid name.</param>
- /// <param name="proc">Interop processor.</param>
- /// <param name="marsh">Marshaller.</param>
- /// <param name="lifecycleBeans">Lifecycle beans.</param>
- /// <param name="cbs">Callbacks.</param>
- public Ignite(IgniteConfiguration cfg, string name, IUnmanagedTarget proc, PortableMarshaller marsh,
- IList<LifecycleBeanHolder> lifecycleBeans, UnmanagedCallbacks cbs)
- {
- Debug.Assert(cfg != null);
- Debug.Assert(proc != null);
- Debug.Assert(marsh != null);
- Debug.Assert(lifecycleBeans != null);
- Debug.Assert(cbs != null);
-
- _cfg = cfg;
- _name = name;
- _proc = proc;
- _marsh = marsh;
- _lifecycleBeans = lifecycleBeans;
- _cbs = cbs;
-
- marsh.Ignite = this;
-
- _prj = new ClusterGroupImpl(proc, UU.ProcessorProjection(proc), marsh, this, null);
-
- _portables = new PortablesImpl(marsh);
-
- _proxy = new IgniteProxy(this);
-
- cbs.Initialize(this);
-
- // Grid is not completely started here, can't initialize interop transactions right away.
- _transactions = new Lazy<TransactionsImpl>(
- () => new TransactionsImpl(UU.ProcessorTransactions(proc), marsh, GetLocalNode().Id));
- }
-
- /// <summary>
- /// On-start routine.
- /// </summary>
- internal void OnStart()
- {
- foreach (var lifecycleBean in _lifecycleBeans)
- lifecycleBean.OnStart(this);
- }
-
- /// <summary>
- /// Gets Ignite proxy.
- /// </summary>
- /// <returns>Proxy.</returns>
- public IgniteProxy Proxy
- {
- get { return _proxy; }
- }
-
- /** <inheritdoc /> */
- public string Name
- {
- get { return _name; }
- }
-
- /** <inheritdoc /> */
-
- public ICluster GetCluster()
- {
- return this;
- }
-
- /** <inheritdoc /> */
- IIgnite IClusterGroup.Ignite
- {
- get { return this; }
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForLocal()
- {
- return _prj.ForNodes(GetLocalNode());
- }
-
- /** <inheritdoc /> */
- public ICompute GetCompute()
- {
- return _prj.GetCompute();
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForNodes(IEnumerable<IClusterNode> nodes)
- {
- return ((IClusterGroup) _prj).ForNodes(nodes);
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForNodes(params IClusterNode[] nodes)
- {
- return _prj.ForNodes(nodes);
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForNodeIds(IEnumerable<Guid> ids)
- {
- return ((IClusterGroup) _prj).ForNodeIds(ids);
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForNodeIds(ICollection<Guid> ids)
- {
- return _prj.ForNodeIds(ids);
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForNodeIds(params Guid[] ids)
- {
- return _prj.ForNodeIds(ids);
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForPredicate(Func<IClusterNode, bool> p)
- {
- IgniteArgumentCheck.NotNull(p, "p");
-
- return _prj.ForPredicate(p);
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForAttribute(string name, string val)
- {
- return _prj.ForAttribute(name, val);
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForCacheNodes(string name)
- {
- return _prj.ForCacheNodes(name);
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForDataNodes(string name)
- {
- return _prj.ForDataNodes(name);
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForClientNodes(string name)
- {
- return _prj.ForClientNodes(name);
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForRemotes()
- {
- return _prj.ForRemotes();
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForHost(IClusterNode node)
- {
- IgniteArgumentCheck.NotNull(node, "node");
-
- return _prj.ForHost(node);
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForRandom()
- {
- return _prj.ForRandom();
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForOldest()
- {
- return _prj.ForOldest();
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForYoungest()
- {
- return _prj.ForYoungest();
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForDotNet()
- {
- return _prj.ForDotNet();
- }
-
- /** <inheritdoc /> */
- public ICollection<IClusterNode> GetNodes()
- {
- return _prj.GetNodes();
- }
-
- /** <inheritdoc /> */
- public IClusterNode GetNode(Guid id)
- {
- return _prj.GetNode(id);
- }
-
- /** <inheritdoc /> */
- public IClusterNode GetNode()
- {
- return _prj.GetNode();
- }
-
- /** <inheritdoc /> */
- public IClusterMetrics GetMetrics()
- {
- return _prj.GetMetrics();
- }
-
- /** <inheritdoc /> */
- public void Dispose()
- {
- Ignition.Stop(Name, true);
- }
-
- /// <summary>
- /// Internal stop routine.
- /// </summary>
- /// <param name="cancel">Cancel flag.</param>
- internal unsafe void Stop(bool cancel)
- {
- UU.IgnitionStop(_proc.Context, Name, cancel);
-
- _cbs.Cleanup();
-
- foreach (var bean in _lifecycleBeans)
- bean.OnLifecycleEvent(LifecycleEventType.AfterNodeStop);
- }
-
- /** <inheritdoc /> */
- public ICache<TK, TV> GetCache<TK, TV>(string name)
- {
- return Cache<TK, TV>(UU.ProcessorCache(_proc, name));
- }
-
- /** <inheritdoc /> */
- public ICache<TK, TV> GetOrCreateCache<TK, TV>(string name)
- {
- return Cache<TK, TV>(UU.ProcessorGetOrCreateCache(_proc, name));
- }
-
- /** <inheritdoc /> */
- public ICache<TK, TV> CreateCache<TK, TV>(string name)
- {
- return Cache<TK, TV>(UU.ProcessorCreateCache(_proc, name));
- }
-
- /// <summary>
- /// Gets cache from specified native cache object.
- /// </summary>
- /// <param name="nativeCache">Native cache.</param>
- /// <param name="keepPortable">Portable flag.</param>
- /// <returns>
- /// New instance of cache wrapping specified native cache.
- /// </returns>
- public ICache<TK, TV> Cache<TK, TV>(IUnmanagedTarget nativeCache, bool keepPortable = false)
- {
- var cacheImpl = new CacheImpl<TK, TV>(this, nativeCache, _marsh, false, keepPortable, false, false);
-
- return new CacheProxyImpl<TK, TV>(cacheImpl);
- }
-
- /** <inheritdoc /> */
- public IClusterNode GetLocalNode()
- {
- return _locNode ?? (_locNode = GetNodes().FirstOrDefault(x => x.IsLocal));
- }
-
- /** <inheritdoc /> */
- public bool PingNode(Guid nodeId)
- {
- return _prj.PingNode(nodeId);
- }
-
- /** <inheritdoc /> */
- public long TopologyVersion
- {
- get { return _prj.TopologyVersion; }
- }
-
- /** <inheritdoc /> */
- public ICollection<IClusterNode> GetTopology(long ver)
- {
- return _prj.Topology(ver);
- }
-
- /** <inheritdoc /> */
- public void ResetMetrics()
- {
- UU.ProjectionResetMetrics(_prj.Target);
- }
-
- /** <inheritdoc /> */
- public IDataStreamer<TK, TV> GetDataStreamer<TK, TV>(string cacheName)
- {
- return new DataStreamerImpl<TK, TV>(UU.ProcessorDataStreamer(_proc, cacheName, false),
- _marsh, cacheName, false);
- }
-
- /** <inheritdoc /> */
- public IPortables GetPortables()
- {
- return _portables;
- }
-
- /** <inheritdoc /> */
- public ICacheAffinity GetAffinity(string cacheName)
- {
- return new CacheAffinityImpl(UU.ProcessorAffinity(_proc, cacheName), _marsh, false, this);
- }
-
- /** <inheritdoc /> */
-
- public ITransactions GetTransactions()
- {
- return _transactions.Value;
- }
-
- /** <inheritdoc /> */
- public IMessaging GetMessaging()
- {
- return _prj.GetMessaging();
- }
-
- /** <inheritdoc /> */
- public IEvents GetEvents()
- {
- return _prj.GetEvents();
- }
-
- /** <inheritdoc /> */
- public IServices GetServices()
- {
- return _prj.GetServices();
- }
-
- /// <summary>
- /// Gets internal projection.
- /// </summary>
- /// <returns>Projection.</returns>
- internal ClusterGroupImpl ClusterGroup
- {
- get { return _prj; }
- }
-
- /// <summary>
- /// Marshaller.
- /// </summary>
- internal PortableMarshaller Marshaller
- {
- get { return _marsh; }
- }
-
- /// <summary>
- /// Configuration.
- /// </summary>
- internal IgniteConfiguration Configuration
- {
- get { return _cfg; }
- }
-
- /// <summary>
- /// Put metadata to Grid.
- /// </summary>
- /// <param name="metas">Metadata.</param>
- internal void PutMetadata(IDictionary<int, IPortableMetadata> metas)
- {
- _prj.PutMetadata(metas);
- }
-
- /** <inheritDoc /> */
- public IPortableMetadata Metadata(int typeId)
- {
- return _prj.Metadata(typeId);
- }
-
- /// <summary>
- /// Handle registry.
- /// </summary>
- public HandleRegistry HandleRegistry
- {
- get { return _cbs.HandleRegistry; }
- }
-
- /// <summary>
- /// Updates the node information from stream.
- /// </summary>
- /// <param name="memPtr">Stream ptr.</param>
- public void UpdateNodeInfo(long memPtr)
- {
- var stream = IgniteManager.Memory.Get(memPtr).Stream();
-
- IPortableRawReader reader = Marshaller.StartUnmarshal(stream, false);
-
- var node = new ClusterNodeImpl(reader);
-
- node.Init(this);
-
- _nodes[node.Id] = node;
- }
-
- /// <summary>
- /// Gets the node from cache.
- /// </summary>
- /// <param name="id">Node id.</param>
- /// <returns>Cached node.</returns>
- public ClusterNodeImpl GetNode(Guid? id)
- {
- return id == null ? null : _nodes[id.Value];
- }
-
- /// <summary>
- /// Gets the interop processor.
- /// </summary>
- internal IUnmanagedTarget InteropProcessor
- {
- get { return _proc; }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteConfigurationEx.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteConfigurationEx.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteConfigurationEx.cs
deleted file mode 100644
index 358e805..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteConfigurationEx.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl
-{
- /// <summary>
- /// Internal extensions for IgniteConfiguration.
- /// </summary>
- internal class IgniteConfigurationEx : IgniteConfiguration
- {
- /// <summary>
- /// Default constructor.
- /// </summary>
- public IgniteConfigurationEx()
- {
- // No-op.
- }
-
- /// <summary>
- /// Copying constructor.
- /// </summary>
- /// <param name="cfg">Configuration.</param>
- public IgniteConfigurationEx(IgniteConfiguration cfg) : base(cfg)
- {
- // No-op.
- }
-
- /// <summary>
- /// Copying constructor.
- /// </summary>
- /// <param name="cfg">Configuration.</param>
- public IgniteConfigurationEx(IgniteConfigurationEx cfg)
- : this((IgniteConfiguration) cfg)
- {
- GridName = cfg.GridName;
- }
-
- /// <summary>
- /// Grid name which is used if not provided in configuration file.
- /// </summary>
- public string GridName { get; set; }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
deleted file mode 100644
index 8fd8825..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
+++ /dev/null
@@ -1,490 +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
-{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
- using System.IO;
- using System.Linq;
- using System.Reflection;
- using System.Runtime.InteropServices;
- using System.Text;
- using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Impl.Memory;
- using Apache.Ignite.Core.Impl.Unmanaged;
- using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
-
- /// <summary>
- /// Native interface manager.
- /// </summary>
- internal static unsafe class IgniteManager
- {
- /** Environment variable: IGNITE_HOME. */
- internal const string EnvIgniteHome = "IGNITE_HOME";
-
- /** Environment variable: whether to set test classpath or not. */
- internal const string EnvIgniteNativeTestClasspath = "IGNITE_NATIVE_TEST_CLASSPATH";
-
- /** Classpath prefix. */
- private const string ClasspathPrefix = "-Djava.class.path=";
-
- /** Java Command line argument: Xms. Case sensitive. */
- private const string CmdJvmMinMemJava = "-Xms";
-
- /** Java Command line argument: Xmx. Case sensitive. */
- private const string CmdJvmMaxMemJava = "-Xmx";
-
- /** Monitor for DLL load synchronization. */
- private static readonly object SyncRoot = new object();
-
- /** First created context. */
- private static void* _ctx;
-
- /** Configuration used on JVM start. */
- private static JvmConfiguration _jvmCfg;
-
- /** Memory manager. */
- private static PlatformMemoryManager _mem;
-
- /// <summary>
- /// Static initializer.
- /// </summary>
- static IgniteManager()
- {
- // No-op.
- }
-
- /// <summary>
- /// Create JVM.
- /// </summary>
- /// <param name="cfg">Configuration.</param>
- /// <param name="cbs">Callbacks.</param>
- /// <returns>Context.</returns>
- internal static void* GetContext(IgniteConfiguration cfg, UnmanagedCallbacks cbs)
- {
- lock (SyncRoot)
- {
- // 1. Warn about possible configuration inconsistency.
- JvmConfiguration jvmCfg = JvmConfig(cfg);
-
- if (!cfg.SuppressWarnings && _jvmCfg != null)
- {
- if (!_jvmCfg.Equals(jvmCfg))
- {
- Console.WriteLine("Attempting to start Ignite node with different Java " +
- "configuration; current Java configuration will be ignored (consider " +
- "starting node in separate process) [oldConfig=" + _jvmCfg +
- ", newConfig=" + jvmCfg + ']');
- }
- }
-
- // 2. Create unmanaged pointer.
- void* ctx = CreateJvm(cfg, cbs);
-
- cbs.SetContext(ctx);
-
- // 3. If this is the first JVM created, preserve it.
- if (_ctx == null)
- {
- _ctx = ctx;
- _jvmCfg = jvmCfg;
- _mem = new PlatformMemoryManager(1024);
- }
-
- return ctx;
- }
- }
-
- /// <summary>
- /// Memory manager attached to currently running JVM.
- /// </summary>
- internal static PlatformMemoryManager Memory
- {
- get { return _mem; }
- }
-
- /// <summary>
- /// Destroy JVM.
- /// </summary>
- public static void DestroyJvm()
- {
- lock (SyncRoot)
- {
- if (_ctx != null)
- {
- UU.DestroyJvm(_ctx);
-
- _ctx = null;
- }
- }
- }
-
- /// <summary>
- /// Create JVM.
- /// </summary>
- /// <returns>JVM.</returns>
- private static void* CreateJvm(IgniteConfiguration cfg, UnmanagedCallbacks cbs)
- {
- var ggHome = GetIgniteHome(cfg);
-
- var cp = CreateClasspath(ggHome, cfg, false);
-
- var jvmOpts = GetMergedJvmOptions(cfg);
-
- var hasGgHome = !string.IsNullOrWhiteSpace(ggHome);
-
- var opts = new sbyte*[1 + jvmOpts.Count + (hasGgHome ? 1 : 0)];
-
- int idx = 0;
-
- opts[idx++] = IgniteUtils.StringToUtf8Unmanaged(cp);
-
- if (hasGgHome)
- opts[idx++] = IgniteUtils.StringToUtf8Unmanaged("-DIGNITE_HOME=" + ggHome);
-
- foreach (string cfgOpt in jvmOpts)
- opts[idx++] = IgniteUtils.StringToUtf8Unmanaged(cfgOpt);
-
- try
- {
- IntPtr mem = Marshal.AllocHGlobal(opts.Length * 8);
-
- fixed (sbyte** opts0 = opts)
- {
- PlatformMemoryUtils.CopyMemory(opts0, mem.ToPointer(), opts.Length * 8);
- }
-
- try
- {
- return UU.CreateContext(mem.ToPointer(), opts.Length, cbs.CallbacksPointer);
- }
- finally
- {
- Marshal.FreeHGlobal(mem);
- }
- }
- finally
- {
- foreach (sbyte* opt in opts)
- Marshal.FreeHGlobal((IntPtr)opt);
- }
- }
-
- /// <summary>
- /// Gets JvmOptions collection merged with individual properties (Min/Max mem, etc) according to priority.
- /// </summary>
- private static IList<string> GetMergedJvmOptions(IgniteConfiguration cfg)
- {
- var jvmOpts = cfg.JvmOptions == null ? new List<string>() : cfg.JvmOptions.ToList();
-
- // JvmInitialMemoryMB / JvmMaxMemoryMB have lower priority than CMD_JVM_OPT
- if (!jvmOpts.Any(opt => opt.StartsWith(CmdJvmMinMemJava, StringComparison.OrdinalIgnoreCase)))
- jvmOpts.Add(string.Format("{0}{1}m", CmdJvmMinMemJava, cfg.JvmInitialMemoryMb));
-
- if (!jvmOpts.Any(opt => opt.StartsWith(CmdJvmMaxMemJava, StringComparison.OrdinalIgnoreCase)))
- jvmOpts.Add(string.Format("{0}{1}m", CmdJvmMaxMemJava, cfg.JvmMaxMemoryMb));
-
- return jvmOpts;
- }
-
- /// <summary>
- /// Create JVM configuration value object.
- /// </summary>
- /// <param name="cfg">Configuration.</param>
- /// <returns>JVM configuration.</returns>
- private static JvmConfiguration JvmConfig(IgniteConfiguration cfg)
- {
- return new JvmConfiguration
- {
- Home = cfg.IgniteHome,
- Dll = cfg.JvmDllPath,
- Classpath = cfg.JvmClasspath,
- Options = cfg.JvmOptions
- };
- }
-
- /// <summary>
- /// Append jars from the given path.
- /// </summary>
- /// <param name="path">Path.</param>
- /// <param name="cpStr">Classpath string builder.</param>
- private static void AppendJars(string path, StringBuilder cpStr)
- {
- if (Directory.Exists(path))
- {
- foreach (string jar in Directory.EnumerateFiles(path, "*.jar"))
- {
- cpStr.Append(jar);
- cpStr.Append(';');
- }
- }
- }
-
- /// <summary>
- /// Calculate Ignite home.
- /// </summary>
- /// <param name="cfg">Configuration.</param>
- /// <returns></returns>
- internal static string GetIgniteHome(IgniteConfiguration cfg)
- {
- var home = cfg == null ? null : cfg.IgniteHome;
-
- if (string.IsNullOrWhiteSpace(home))
- home = Environment.GetEnvironmentVariable(EnvIgniteHome);
- else if (!IsIgniteHome(new DirectoryInfo(home)))
- throw new IgniteException(string.Format("IgniteConfiguration.IgniteHome is not valid: '{0}'", home));
-
- if (string.IsNullOrWhiteSpace(home))
- home = ResolveIgniteHome();
- else if (!IsIgniteHome(new DirectoryInfo(home)))
- throw new IgniteException(string.Format("{0} is not valid: '{1}'", EnvIgniteHome, home));
-
- return home;
- }
-
- /// <summary>
- /// Automatically resolve Ignite home directory.
- /// </summary>
- /// <returns>Ignite home directory.</returns>
- private static string ResolveIgniteHome()
- {
- var probeDirs = new[]
- {
- Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
- Directory.GetCurrentDirectory()
- };
-
- foreach (var probeDir in probeDirs.Where(x => !string.IsNullOrEmpty(x)))
- {
- var dir = new DirectoryInfo(probeDir);
-
- while (dir != null)
- {
- if (IsIgniteHome(dir))
- return dir.FullName;
-
- dir = dir.Parent;
- }
- }
-
- return null;
- }
-
- /// <summary>
- /// Determines whether specified dir looks like a Ignite home.
- /// </summary>
- /// <param name="dir">Directory.</param>
- /// <returns>Value indicating whether specified dir looks like a Ignite home.</returns>
- private static bool IsIgniteHome(DirectoryInfo dir)
- {
- return dir.Exists && dir.EnumerateDirectories().Count(x => x.Name == "examples" || x.Name == "bin") == 2;
- }
-
- /// <summary>
- /// Creates classpath from the given configuration, or default classpath if given config is null.
- /// </summary>
- /// <param name="cfg">The configuration.</param>
- /// <param name="forceTestClasspath">Append test directories even if <see cref="EnvIgniteNativeTestClasspath" /> is not set.</param>
- /// <returns>
- /// Classpath string.
- /// </returns>
- internal static string CreateClasspath(IgniteConfiguration cfg = null, bool forceTestClasspath = false)
- {
- return CreateClasspath(GetIgniteHome(cfg), cfg, forceTestClasspath);
- }
-
- /// <summary>
- /// Creates classpath from the given configuration, or default classpath if given config is null.
- /// </summary>
- /// <param name="ggHome">The home dir.</param>
- /// <param name="cfg">The configuration.</param>
- /// <param name="forceTestClasspath">Append test directories even if
- /// <see cref="EnvIgniteNativeTestClasspath" /> is not set.</param>
- /// <returns>
- /// Classpath string.
- /// </returns>
- private static string CreateClasspath(string ggHome, IgniteConfiguration cfg, bool forceTestClasspath)
- {
- var cpStr = new StringBuilder();
-
- if (cfg != null && cfg.JvmClasspath != null)
- {
- cpStr.Append(cfg.JvmClasspath);
-
- if (!cfg.JvmClasspath.EndsWith(";"))
- cpStr.Append(';');
- }
-
- if (!string.IsNullOrWhiteSpace(ggHome))
- AppendHomeClasspath(ggHome, forceTestClasspath, cpStr);
-
- return ClasspathPrefix + cpStr;
- }
-
- /// <summary>
- /// Appends classpath from home directory, if it is defined.
- /// </summary>
- /// <param name="ggHome">The home dir.</param>
- /// <param name="forceTestClasspath">Append test directories even if
- /// <see cref="EnvIgniteNativeTestClasspath"/> is not set.</param>
- /// <param name="cpStr">The classpath string.</param>
- private static void AppendHomeClasspath(string ggHome, bool forceTestClasspath, StringBuilder cpStr)
- {
- // Append test directories (if needed) first, because otherwise build *.jar will be picked first.
- if (forceTestClasspath || "true".Equals(Environment.GetEnvironmentVariable(EnvIgniteNativeTestClasspath)))
- {
- AppendTestClasses(ggHome + "\\examples", cpStr);
- AppendTestClasses(ggHome + "\\modules", cpStr);
- }
-
- string ggLibs = ggHome + "\\libs";
-
- AppendJars(ggLibs, cpStr);
-
- if (Directory.Exists(ggLibs))
- {
- foreach (string dir in Directory.EnumerateDirectories(ggLibs))
- {
- if (!dir.EndsWith("optional"))
- AppendJars(dir, cpStr);
- }
- }
- }
-
- /// <summary>
- /// Append target (compile) directories to classpath (for testing purposes only).
- /// </summary>
- /// <param name="path">Path</param>
- /// <param name="cp">Classpath builder.</param>
- private static void AppendTestClasses(string path, StringBuilder cp)
- {
- if (Directory.Exists(path))
- {
- AppendTestClasses0(path, cp);
-
- foreach (string moduleDir in Directory.EnumerateDirectories(path))
- AppendTestClasses0(moduleDir, cp);
- }
- }
-
- /// <summary>
- /// Internal routine to append classes and jars from eploded directory.
- /// </summary>
- /// <param name="path">Path.</param>
- /// <param name="cp">Classpath builder.</param>
- private static void AppendTestClasses0(string path, StringBuilder cp)
- {
- if (path.EndsWith("rest-http", StringComparison.OrdinalIgnoreCase))
- return;
-
- if (Directory.Exists(path + "\\target\\classes"))
- cp.Append(path + "\\target\\classes;");
-
- if (Directory.Exists(path + "\\target\\test-classes"))
- cp.Append(path + "\\target\\test-classes;");
-
- if (Directory.Exists(path + "\\target\\libs"))
- AppendJars(path + "\\target\\libs", cp);
- }
-
- /// <summary>
- /// JVM configuration.
- /// </summary>
- private class JvmConfiguration
- {
- /// <summary>
- /// Gets or sets the home.
- /// </summary>
- public string Home { get; set; }
-
- /// <summary>
- /// Gets or sets the DLL.
- /// </summary>
- public string Dll { get; set; }
-
- /// <summary>
- /// Gets or sets the cp.
- /// </summary>
- public string Classpath { get; set; }
-
- /// <summary>
- /// Gets or sets the options.
- /// </summary>
- public ICollection<string> Options { get; set; }
-
- /** <inheritDoc /> */
- public override int GetHashCode()
- {
- return 0;
- }
-
- /** <inheritDoc /> */
- [SuppressMessage("ReSharper", "FunctionComplexityOverflow")]
- public override bool Equals(object obj)
- {
- JvmConfiguration other = obj as JvmConfiguration;
-
- if (other == null)
- return false;
-
- if (!string.Equals(Home, other.Home, StringComparison.OrdinalIgnoreCase))
- return false;
-
- if (!string.Equals(Classpath, other.Classpath, StringComparison.OrdinalIgnoreCase))
- return false;
-
- if (!string.Equals(Dll, other.Dll, StringComparison.OrdinalIgnoreCase))
- return false;
-
- return (Options == null && other.Options == null) ||
- (Options != null && other.Options != null && Options.Count == other.Options.Count
- && !Options.Except(other.Options).Any());
- }
-
- /** <inheritDoc /> */
- public override string ToString()
- {
- var sb = new StringBuilder("[IgniteHome=" + Home + ", JvmDllPath=" + Dll);
-
- if (Options != null && Options.Count > 0)
- {
- sb.Append(", JvmOptions=[");
-
- bool first = true;
-
- foreach (string opt in Options)
- {
- if (first)
- first = false;
- else
- sb.Append(", ");
-
- sb.Append(opt);
- }
-
- sb.Append(']');
- }
-
- sb.Append(", Classpath=" + Classpath + ']');
-
- return sb.ToString();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
deleted file mode 100644
index 2e01a5b..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
+++ /dev/null
@@ -1,333 +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
-{
- using System;
- using System.Collections.Generic;
- 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.Impl.Cluster;
- using Apache.Ignite.Core.Impl.Portable;
- using Apache.Ignite.Core.Messaging;
- using Apache.Ignite.Core.Portable;
- using Apache.Ignite.Core.Services;
- using Apache.Ignite.Core.Transactions;
-
- /// <summary>
- /// Grid proxy with fake serialization.
- /// </summary>
- [Serializable]
- internal class IgniteProxy : IIgnite, IClusterGroupEx, IPortableWriteAware, ICluster
- {
- /** */
- [NonSerialized]
- private readonly IIgnite _ignite;
-
- /// <summary>
- /// Default ctor for marshalling.
- /// </summary>
- public IgniteProxy()
- {
- // No-op.
- }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="ignite">Grid.</param>
- public IgniteProxy(IIgnite ignite)
- {
- _ignite = ignite;
- }
-
- /** <inheritdoc /> */
- public string Name
- {
- get { return _ignite.Name; }
- }
-
- /** <inheritdoc /> */
-
- public ICluster GetCluster()
- {
- return this;
- }
-
- /** <inheritdoc /> */
- public IIgnite Ignite
- {
- get { return this; }
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForLocal()
- {
- return _ignite.GetCluster().ForLocal();
- }
-
- /** <inheritdoc /> */
- public ICompute GetCompute()
- {
- return _ignite.GetCompute();
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForNodes(IEnumerable<IClusterNode> nodes)
- {
- return _ignite.GetCluster().ForNodes(nodes);
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForNodes(params IClusterNode[] nodes)
- {
- return _ignite.GetCluster().ForNodes(nodes);
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForNodeIds(IEnumerable<Guid> ids)
- {
- return _ignite.GetCluster().ForNodeIds(ids);
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForNodeIds(ICollection<Guid> ids)
- {
- return _ignite.GetCluster().ForNodeIds(ids);
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForNodeIds(params Guid[] ids)
- {
- return _ignite.GetCluster().ForNodeIds(ids);
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForPredicate(Func<IClusterNode, bool> p)
- {
- return _ignite.GetCluster().ForPredicate(p);
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForAttribute(string name, string val)
- {
- return _ignite.GetCluster().ForAttribute(name, val);
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForCacheNodes(string name)
- {
- return _ignite.GetCluster().ForCacheNodes(name);
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForDataNodes(string name)
- {
- return _ignite.GetCluster().ForDataNodes(name);
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForClientNodes(string name)
- {
- return _ignite.GetCluster().ForClientNodes(name);
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForRemotes()
- {
- return _ignite.GetCluster().ForRemotes();
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForHost(IClusterNode node)
- {
- return _ignite.GetCluster().ForHost(node);
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForRandom()
- {
- return _ignite.GetCluster().ForRandom();
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForOldest()
- {
- return _ignite.GetCluster().ForOldest();
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForYoungest()
- {
- return _ignite.GetCluster().ForYoungest();
- }
-
- /** <inheritdoc /> */
- public IClusterGroup ForDotNet()
- {
- return _ignite.GetCluster().ForDotNet();
- }
-
- /** <inheritdoc /> */
- public ICollection<IClusterNode> GetNodes()
- {
- return _ignite.GetCluster().GetNodes();
- }
-
- /** <inheritdoc /> */
- public IClusterNode GetNode(Guid id)
- {
- return _ignite.GetCluster().GetNode(id);
- }
-
- /** <inheritdoc /> */
- public IClusterNode GetNode()
- {
- return _ignite.GetCluster().GetNode();
- }
-
- /** <inheritdoc /> */
- public IClusterMetrics GetMetrics()
- {
- return _ignite.GetCluster().GetMetrics();
- }
-
- /** <inheritdoc /> */
- public void Dispose()
- {
- _ignite.Dispose();
- }
-
- /** <inheritdoc /> */
- public ICache<TK, TV> GetCache<TK, TV>(string name)
- {
- return _ignite.GetCache<TK, TV>(name);
- }
-
- /** <inheritdoc /> */
- public ICache<TK, TV> GetOrCreateCache<TK, TV>(string name)
- {
- return _ignite.GetOrCreateCache<TK, TV>(name);
- }
-
- /** <inheritdoc /> */
- public ICache<TK, TV> CreateCache<TK, TV>(string name)
- {
- return _ignite.CreateCache<TK, TV>(name);
- }
-
- /** <inheritdoc /> */
-
- public IClusterNode GetLocalNode()
- {
- return _ignite.GetCluster().GetLocalNode();
- }
-
- /** <inheritdoc /> */
- public bool PingNode(Guid nodeId)
- {
- return _ignite.GetCluster().PingNode(nodeId);
- }
-
- /** <inheritdoc /> */
- public long TopologyVersion
- {
- get { return _ignite.GetCluster().TopologyVersion; }
- }
-
- /** <inheritdoc /> */
- public ICollection<IClusterNode> GetTopology(long ver)
- {
- return _ignite.GetCluster().GetTopology(ver);
- }
-
- /** <inheritdoc /> */
- public void ResetMetrics()
- {
- _ignite.GetCluster().ResetMetrics();
- }
-
- /** <inheritdoc /> */
- public IDataStreamer<TK, TV> GetDataStreamer<TK, TV>(string cacheName)
- {
- return _ignite.GetDataStreamer<TK, TV>(cacheName);
- }
-
- /** <inheritdoc /> */
- public IPortables GetPortables()
- {
- return _ignite.GetPortables();
- }
-
- /** <inheritdoc /> */
- public ICacheAffinity GetAffinity(string name)
- {
- return _ignite.GetAffinity(name);
- }
-
- /** <inheritdoc /> */
-
- public ITransactions GetTransactions()
- {
- return _ignite.GetTransactions();
- }
-
- /** <inheritdoc /> */
- public IMessaging GetMessaging()
- {
- return _ignite.GetMessaging();
- }
-
- /** <inheritdoc /> */
- public IEvents GetEvents()
- {
- return _ignite.GetEvents();
- }
-
- /** <inheritdoc /> */
- public IServices GetServices()
- {
- return _ignite.GetServices();
- }
-
- /** <inheritdoc /> */
- public void WritePortable(IPortableWriter writer)
- {
- // No-op.
- }
-
- /// <summary>
- /// Target grid.
- /// </summary>
- internal IIgnite Target
- {
- get
- {
- return _ignite;
- }
- }
-
- /** <inheritdoc /> */
- public IPortableMetadata Metadata(int typeId)
- {
- return ((IClusterGroupEx)_ignite).Metadata(typeId);
- }
- }
-}