コード例 #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="target">Target.</param>
        /// <param name="prj">Projection.</param>
        /// <param name="keepBinary">Binary flag.</param>
        public ComputeImpl(IPlatformTargetInternal target, ClusterGroupImpl prj, bool keepBinary)
            : base(target)
        {
            _prj = prj;

            _keepBinary.Value = keepBinary;
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Events" /> class.
        /// </summary>
        /// <param name="target">Target.</param>
        /// <param name="clusterGroup">Cluster group.</param>
        public Events(IPlatformTargetInternal target, IClusterGroup clusterGroup)
            : base(target)
        {
            Debug.Assert(clusterGroup != null);

            _clusterGroup = clusterGroup;
        }
コード例 #3
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="target">Target.</param>
        /// <param name="marsh">Marshaller.</param>
        /// <param name="cacheName">Cache name.</param>
        /// <param name="keepBinary">Binary flag.</param>
        public DataStreamerImpl(IPlatformTargetInternal target, Marshaller marsh, string cacheName, bool keepBinary)
            : base(target)
        {
            _cacheName  = cacheName;
            _keepBinary = keepBinary;

            // Create empty batch.
            _batch = new DataStreamerBatch <TK, TV>();

            // Allocate GC handle so that this data streamer could be easily dereferenced from native code.
            WeakReference thisRef = new WeakReference(this);

            _hnd = marsh.Ignite.HandleRegistry.Allocate(thisRef);

            // Start topology listening. This call will ensure that buffer size member is updated.
            DoOutInOp(OpListenTopology, _hnd);

            // Membar to ensure fields initialization before leaving constructor.
            Thread.MemoryBarrier();

            // Start flusher after everything else is initialized.
            _flusher = new Flusher <TK, TV>(thisRef);

            _flusher.RunThread();
        }
コード例 #4
0
ファイル: Ignite.cs プロジェクト: zkillingjar/ignite
        /// <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="lifecycleHandlers">Lifecycle beans.</param>
        /// <param name="cbs">Callbacks.</param>
        public Ignite(IgniteConfiguration cfg, string name, IPlatformTargetInternal proc, Marshaller marsh,
                      IList <LifecycleHandlerHolder> lifecycleHandlers, UnmanagedCallbacks cbs) : base(proc)
        {
            Debug.Assert(cfg != null);
            Debug.Assert(proc != null);
            Debug.Assert(marsh != null);
            Debug.Assert(lifecycleHandlers != null);
            Debug.Assert(cbs != null);

            _cfg               = cfg;
            _name              = name;
            _proc              = proc;
            _marsh             = marsh;
            _lifecycleHandlers = lifecycleHandlers;
            _cbs               = cbs;

            marsh.Ignite = this;

            _prj = new ClusterGroupImpl(Target.OutObjectInternal((int)Op.GetClusterGroup), null);

            _binary = new Binary.Binary(marsh);

            _binaryProc = new BinaryProcessor(DoOutOpObject((int)Op.GetBinaryProcessor));

            cbs.Initialize(this);

            // Set reconnected task to completed state for convenience.
            _clientReconnectTaskCompletionSource.SetResult(false);

            SetCompactFooter();

            _pluginProcessor = new PluginProcessor(this);
        }
コード例 #5
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="target">Target.</param>
        protected PlatformTargetAdapter(IPlatformTargetInternal target)
        {
            Debug.Assert(target != null);

            _target = target;
            _marsh  = target.Marshaller;
        }
コード例 #6
0
ファイル: IgniteLock.cs プロジェクト: pks-os/gridgain
        /// <summary>
        /// Initializes a new instance of <see cref="IgniteLock"/>.
        /// </summary>
        public IgniteLock(IPlatformTargetInternal target, LockConfiguration cfg)
            : base(target)
        {
            Debug.Assert(cfg != null);

            _cfg = cfg;
        }
コード例 #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Apache.Ignite.Core.Impl.DataStructures.AtomicLong"/> class.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="name">The name.</param>
        public AtomicSequence(IPlatformTargetInternal target, string name)
            : base(target)
        {
            Debug.Assert(!string.IsNullOrEmpty(name));

            _name = name;
        }
コード例 #8
0
ファイル: Services.cs プロジェクト: Vladsz83/ignite
        /// <summary>
        /// Invokes the service proxy method.
        /// </summary>
        /// <param name="proxy">Unmanaged proxy.</param>
        /// <param name="methodName">Name of the method.</param>
        /// <param name="method">Method to invoke.</param>
        /// <param name="args">Arguments.</param>
        /// <param name="platformType">The platform.</param>
        /// <param name="callCtx">Service call context.</param>
        /// <returns>
        /// Invocation result.
        /// </returns>
        private object InvokeProxyMethod(IPlatformTargetInternal proxy, string methodName,
                                         MethodBase method, object[] args, PlatformType platformType, IServiceCallContext callCtx)
        {
            bool locRegisterSameJavaType = Marshaller.RegisterSameJavaTypeTl.Value;

            if (platformType == PlatformType.Java)
            {
                Marshaller.RegisterSameJavaTypeTl.Value = true;
            }

            try
            {
                return(DoOutInOp(OpInvokeMethod,
                                 writer => ServiceProxySerializer.WriteProxyMethod(writer, methodName, method, args, platformType, callCtx),
                                 (stream, res) => ServiceProxySerializer.ReadInvocationResult(stream, Marshaller, _keepBinary),
                                 proxy));
            }
            finally
            {
                if (platformType == PlatformType.Java)
                {
                    Marshaller.RegisterSameJavaTypeTl.Value = locRegisterSameJavaType;
                }
            }
        }
コード例 #9
0
ファイル: FieldsQueryCursor.cs プロジェクト: vladdou/ignite
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="target">Target.</param>
        /// <param name="keepBinary">Keep poratble flag.</param>
        /// <param name="readerFunc">The reader function.</param>
        public FieldsQueryCursor(IPlatformTargetInternal target, bool keepBinary,
                                 Func <IBinaryRawReader, int, T> readerFunc)
            : base(target, keepBinary)
        {
            Debug.Assert(readerFunc != null);

            _readerFunc = readerFunc;
        }
コード例 #10
0
        /// <summary>
        /// Updates cache with batch of entries.
        /// </summary>
        /// <param name="grid">The grid.</param>
        /// <param name="cache">Cache.</param>
        /// <param name="stream">Stream.</param>
        /// <param name="keepBinary">Binary flag.</param>
        public void Receive(Ignite grid, IPlatformTargetInternal cache, IBinaryStream stream, bool keepBinary)
        {
            Debug.Assert(grid != null);
            Debug.Assert(cache != null);
            Debug.Assert(stream != null);

            _invoke(_rcv, grid, cache, stream, keepBinary);
        }
コード例 #11
0
 /// <summary>
 /// Invokes the service proxy method.
 /// </summary>
 /// <param name="proxy">Unmanaged proxy.</param>
 /// <param name="method">Method to invoke.</param>
 /// <param name="args">Arguments.</param>
 /// <param name="platform">The platform.</param>
 /// <returns>
 /// Invocation result.
 /// </returns>
 private object InvokeProxyMethod(IPlatformTargetInternal proxy, MethodBase method, object[] args,
                                  Platform platform)
 {
     return(DoOutInOp(OpInvokeMethod,
                      writer => ServiceProxySerializer.WriteProxyMethod(writer, method, args, platform),
                      (stream, res) => ServiceProxySerializer.ReadInvocationResult(stream, Marshaller, _keepBinary),
                      proxy));
 }
コード例 #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Messaging" /> class.
        /// </summary>
        /// <param name="target">Target.</param>
        /// <param name="prj">Cluster group.</param>
        public Messaging(IPlatformTargetInternal target, IClusterGroup prj)
            : base(target)
        {
            Debug.Assert(prj != null);

            _clusterGroup = prj;

            _ignite = (Ignite)prj.Ignite;
        }
コード例 #13
0
ファイル: Services.cs プロジェクト: Vladsz83/ignite
        /// <summary>
        /// Initializes a new instance of the <see cref="Services" /> class.
        /// </summary>
        /// <param name="target">Target.</param>
        /// <param name="clusterGroup">Cluster group.</param>
        /// <param name="keepBinary">Invoker binary flag.</param>
        /// <param name="srvKeepBinary">Server binary flag.</param>
        public Services(IPlatformTargetInternal target, IClusterGroup clusterGroup,
                        bool keepBinary, bool srvKeepBinary)
            : base(target)
        {
            Debug.Assert(clusterGroup != null);

            _clusterGroup  = clusterGroup;
            _keepBinary    = keepBinary;
            _srvKeepBinary = srvKeepBinary;
        }
コード例 #14
0
ファイル: ClusterGroupImpl.cs プロジェクト: zmyer/gridgain
        public ClusterGroupImpl(IPlatformTargetInternal target, Func <IClusterNode, bool> pred)
            : base(target)
        {
            _ignite = target.Marshaller.Ignite;
            _pred   = pred;

            _comp     = new Lazy <ICompute>(() => CreateCompute());
            _msg      = new Lazy <IMessaging>(() => CreateMessaging());
            _events   = new Lazy <IEvents>(() => CreateEvents());
            _services = new Lazy <IServices>(() => CreateServices());
        }
コード例 #15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TransactionsImpl" /> class.
        /// </summary>
        /// <param name="target">Target.</param>
        /// <param name="localNodeId">Local node id.</param>
        public TransactionsImpl(IPlatformTargetInternal target, Guid localNodeId) : base(target)
        {
            _localNodeId = localNodeId;

            var res = target.OutStream(OpCacheConfigParameters, reader => Tuple.Create(
                                           (TransactionConcurrency)reader.ReadInt(),
                                           (TransactionIsolation)reader.ReadInt(),
                                           reader.ReadLongAsTimespan()));

            _dfltConcurrency = res.Item1;
            _dfltIsolation   = res.Item2;
            _dfltTimeout     = res.Item3;
        }
コード例 #16
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="target">Target.</param>
        /// <param name="keepBinary">Keep binary flag.</param>
        /// <param name="readerFunc">The reader function.</param>
        public FieldsQueryCursor(IPlatformTargetInternal target, bool keepBinary,
                                 Func <IBinaryRawReader, int, T> readerFunc)
            : base(target, keepBinary, r =>
        {
            // Reading and skipping row size in bytes.
            r.ReadInt();

            int cnt = r.ReadInt();

            return(readerFunc(r, cnt));
        })
        {
            // No-op.
        }
コード例 #17
0
        /// <summary>
        /// Invokes the receiver.
        /// </summary>
        /// <param name="receiver">Receiver.</param>
        /// <param name="grid">Grid.</param>
        /// <param name="cache">Cache.</param>
        /// <param name="stream">Stream.</param>
        /// <param name="keepBinary">Binary flag.</param>
        public static void InvokeReceiver <TK, TV>(IStreamReceiver <TK, TV> receiver, Ignite grid,
                                                   IPlatformTargetInternal cache, IBinaryStream stream, bool keepBinary)
        {
            var reader = grid.Marshaller.StartUnmarshal(stream, keepBinary);

            var size = reader.ReadInt();

            var entries = new List <ICacheEntry <TK, TV> >(size);

            for (var i = 0; i < size; i++)
            {
                entries.Add(new CacheEntry <TK, TV>(reader.ReadObject <TK>(), reader.ReadObject <TV>()));
            }

            receiver.Receive(Ignite.GetCache <TK, TV>(cache, keepBinary), entries);
        }
コード例 #18
0
ファイル: CacheImpl.cs プロジェクト: zhaoshijie/ignite
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="target">Target.</param>
        /// <param name="flagSkipStore">Skip store flag.</param>
        /// <param name="flagKeepBinary">Keep binary flag.</param>
        /// <param name="flagNoRetries">No-retries mode flag.</param>
        /// <param name="flagPartitionRecover">Partition recover mode flag.</param>
        public CacheImpl(IPlatformTargetInternal target,
                         bool flagSkipStore, bool flagKeepBinary, bool flagNoRetries, bool flagPartitionRecover)
            : base(target)
        {
            _ignite               = target.Marshaller.Ignite;
            _flagSkipStore        = flagSkipStore;
            _flagKeepBinary       = flagKeepBinary;
            _flagNoRetries        = flagNoRetries;
            _flagPartitionRecover = flagPartitionRecover;

            _txManager = GetConfiguration().AtomicityMode == CacheAtomicityMode.Transactional
                ? new CacheTransactionManager(_ignite.GetIgnite().GetTransactions())
                : null;

            _readException = stream => ReadException(Marshaller.StartUnmarshal(stream));
        }
コード例 #19
0
        /// <summary>
        /// Invokes the service proxy method.
        /// </summary>
        /// <param name="proxy">Unmanaged proxy.</param>
        /// <param name="methodName">Name of the method.</param>
        /// <param name="method">Method to invoke.</param>
        /// <param name="args">Arguments.</param>
        /// <param name="platformType">The platform.</param>
        /// <returns>
        /// Invocation result.
        /// </returns>
        private object InvokeProxyMethod(IPlatformTargetInternal proxy, string methodName,
                                         MethodBase method, object[] args, PlatformType platformType)
        {
            Marshaller.RegisterSameJavaType.Value = true;

            try
            {
                return(DoOutInOp(OpInvokeMethod,
                                 writer => ServiceProxySerializer.WriteProxyMethod(writer, methodName, method, args, platformType),
                                 (stream, res) => ServiceProxySerializer.ReadInvocationResult(stream, Marshaller, _keepBinary),
                                 proxy));
            }
            finally
            {
                Marshaller.RegisterSameJavaType.Value = false;
            }
        }
コード例 #20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TransactionsImpl" /> class.
        /// </summary>
        /// <param name="ignite">Parent target, actually <see cref="Ignite"/> (used for withLabel)</param>
        /// <param name="target">Target.</param>
        /// <param name="localNodeId">Local node id.</param>
        /// <param name="label">TX label. </param>
        public TransactionsImpl(Ignite ignite, IPlatformTargetInternal target, Guid localNodeId, string label = null)
            : base(target)
        {
            _localNodeId = localNodeId;

            var res = target.OutStream(OpCacheConfigParameters, reader => Tuple.Create(
                                           (TransactionConcurrency)reader.ReadInt(),
                                           (TransactionIsolation)reader.ReadInt(),
                                           reader.ReadLongAsTimespan(),
                                           reader.ReadLongAsTimespan()
                                           ));

            _dfltConcurrency = res.Item1;
            _dfltIsolation   = res.Item2;
            _dfltTimeout     = res.Item3;
            _dfltTimeoutOnPartitionMapExchange = res.Item4;
            _ignite = ignite;
            _label  = label;
        }
コード例 #21
0
        private IPlatformTargetInternal GetInitialQueryCursorInternal()
        {
            lock (this)
            {
                if (_disposed)
                {
                    throw new ObjectDisposedException("Continuous query handle has been disposed.");
                }

                var cur = _nativeInitialQueryCursor;

                if (cur == null)
                {
                    throw new InvalidOperationException("GetInitialQueryCursor() can be called only once.");
                }

                _nativeInitialQueryCursor = null;

                return(cur);
            }
        }
コード例 #22
0
        public TR InObjectStreamOutObjectStream <TR>(int type, Action <IBinaryStream> writeAction,
                                                     Func <IBinaryStream, IPlatformTargetInternal, TR> readAction, IPlatformTargetInternal arg)
        {
            PlatformMemoryStream outStream = null;
            long outPtr = 0;

            PlatformMemoryStream inStream = null;
            long inPtr = 0;

            try
            {
                if (writeAction != null)
                {
                    outStream = IgniteManager.Memory.Allocate().GetStream();
                    writeAction(outStream);
                    outPtr = outStream.SynchronizeOutput();
                }

                if (readAction != null)
                {
                    inStream = IgniteManager.Memory.Allocate().GetStream();
                    inPtr    = inStream.MemoryPointer;
                }

                var res = UU.TargetInObjectStreamOutObjectStream(_target, type,
                                                                 ((PlatformJniTarget)arg).Target, outPtr, inPtr);

                if (readAction == null)
                {
                    return(default(TR));
                }

                inStream.SynchronizeInput();

                var target = res == null ? null : new PlatformJniTarget(res, _marsh);

                return(readAction(inStream, target));
            }
            catch (JavaException jex)
            {
                throw ConvertException(jex);
            }
            finally
            {
                try
                {
                    if (inStream != null)
                    {
                        inStream.Dispose();
                    }
                }
                finally
                {
                    if (outStream != null)
                    {
                        outStream.Dispose();
                    }
                }
            }
        }
コード例 #23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CacheAffinityImpl" /> class.
        /// </summary>
        /// <param name="target">Target.</param>
        /// <param name="keepBinary">Keep binary flag.</param>
        public CacheAffinityImpl(IPlatformTargetInternal target, bool keepBinary) : base(target)
        {
            _keepBinary = keepBinary;

            _ignite = target.Marshaller.Ignite;
        }
コード例 #24
0
ファイル: Ignite.cs プロジェクト: zkillingjar/ignite
 /// <summary>
 /// Gets cache from specified native cache object.
 /// </summary>
 /// <param name="nativeCache">Native cache.</param>
 /// <param name="keepBinary">Keep binary flag.</param>
 /// <returns>
 /// New instance of cache wrapping specified native cache.
 /// </returns>
 public static ICache <TK, TV> GetCache <TK, TV>(IPlatformTargetInternal nativeCache, bool keepBinary = false)
 {
     return(new CacheImpl <TK, TV>(nativeCache, false, keepBinary, false, false, false));
 }
コード例 #25
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="target">Target.</param>
 /// <param name="keepBinary">Keep binary flag.</param>
 public CacheEnumerator(IPlatformTargetInternal target, bool keepBinary) : base(target)
 {
     _keepBinary = keepBinary;
 }
コード例 #26
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="target">Target.</param>
 /// <param name="keepBinary">Keep poratble flag.</param>
 public QueryCursor(IPlatformTargetInternal target, bool keepBinary)
     : base(target, keepBinary,
            r => new CacheEntry <TK, TV>(r.ReadObject <TK>(), r.ReadObject <TV>()))
 {
     // No-op.
 }
コード例 #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PlatformQueryQursorBase{T}"/> class.
 /// </summary>
 /// <param name="target">The target.</param>
 /// <param name="keepBinary">Keep binary flag.</param>
 /// <param name="readFunc"></param>
 protected PlatformQueryQursorBase(IPlatformTargetInternal target, bool keepBinary,
                                   Func <BinaryReader, T> readFunc)
     : base(target.Marshaller, keepBinary, readFunc)
 {
     _target = target;
 }
コード例 #28
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="qry">Query.</param>
        /// <param name="marsh">Marshaller.</param>
        /// <param name="keepBinary">Keep binary flag.</param>
        /// <param name="createTargetCb">The initialization callback.</param>
        /// <param name="initialQry">The initial query.</param>
        public ContinuousQueryHandleImpl(ContinuousQuery <TK, TV> qry, Marshaller marsh, bool keepBinary,
                                         Func <Action <BinaryWriter>, IPlatformTargetInternal> createTargetCb, IQueryBaseInternal initialQry)
        {
            _marsh      = marsh;
            _keepBinary = keepBinary;

            _lsnr   = qry.Listener;
            _filter = qry.Filter;

            // 1. Inject resources.
            ResourceProcessor.Inject(_lsnr, _marsh.Ignite);
            ResourceProcessor.Inject(_filter, _marsh.Ignite);

            try
            {
                // 2. Allocate handle.
                _hnd = _marsh.Ignite.HandleRegistry.Allocate(this);

                // 3. Call Java.
                _nativeQry = createTargetCb(writer =>
                {
                    writer.WriteLong(_hnd);
                    writer.WriteBoolean(qry.Local);
                    writer.WriteBoolean(qry.IncludeExpired);
                    writer.WriteBoolean(_filter != null);

                    var javaFilter = _filter as PlatformJavaObjectFactoryProxy;

                    if (javaFilter != null)
                    {
                        writer.WriteObject(javaFilter.GetRawProxy());
                    }
                    else
                    {
                        var filterHolder = _filter == null || qry.Local
                            ? null
                            : new ContinuousQueryFilterHolder(_filter, _keepBinary);

                        writer.WriteObject(filterHolder);
                    }

                    writer.WriteInt(qry.BufferSize);
                    writer.WriteLong((long)qry.TimeInterval.TotalMilliseconds);
                    writer.WriteBoolean(qry.AutoUnsubscribe);

                    if (initialQry != null)
                    {
                        writer.WriteInt((int)initialQry.OpId);

                        initialQry.Write(writer, _keepBinary);
                    }
                    else
                    {
                        writer.WriteInt(-1); // no initial query
                    }
                });

                // 4. Initial query.
                _nativeInitialQueryCursor = _nativeQry.OutObjectInternal(0);
                _initialQueryIsFields     = initialQry is SqlFieldsQuery;
            }
            catch (Exception)
            {
                if (_hnd > 0)
                {
                    _marsh.Ignite.HandleRegistry.Release(_hnd);
                }

                if (_nativeQry != null)
                {
                    _nativeQry.Dispose();
                }

                if (_nativeInitialQueryCursor != null)
                {
                    _nativeInitialQueryCursor.Dispose();
                }

                throw;
            }
        }
コード例 #29
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="target">Target.</param>
 protected PlatformDisposableTargetAdapter(IPlatformTargetInternal target) : base(target)
 {
     // No-op.
 }
コード例 #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Listenable"/> class.
 /// </summary>
 /// <param name="target">Target.</param>
 public Listenable(IPlatformTargetInternal target) : base(target)
 {
     // No-op.
 }