Exemple #1
0
        /** <inheritdoc /> */
        public IClusterGroup ForPredicate(Func <IClusterNode, bool> p)
        {
            IgniteArgumentCheck.NotNull(p, "p");

            return(_prj.ForPredicate(p));
        }
Exemple #2
0
        /** <inheritDoc /> */
        public TV Get(TK key)
        {
            IgniteArgumentCheck.NotNull(key, "key");

            return(DoOutInOp(ClientOp.CacheGet, w => w.WriteObject(key), UnmarshalNotNull <TV>));
        }
Exemple #3
0
        /** <inheritDoc /> */
        public Task <bool> ContainsKeyAsync(TK key)
        {
            IgniteArgumentCheck.NotNull(key, "key");

            return(DoOutInOpAffinityAsync(ClientOp.CacheContainsKey, key, ctx => ctx.Stream.ReadBool()));
        }
Exemple #4
0
        /** <inheritDoc /> */
        public Task ClearAsync(TK key)
        {
            IgniteArgumentCheck.NotNull(key, "key");

            return(DoOutOpAsync(ClientOp.CacheClearKey, w => w.WriteObjectDetached(key)));
        }
Exemple #5
0
        /** <inheritDoc /> */
        public void RemoveAll(IEnumerable <TK> keys)
        {
            IgniteArgumentCheck.NotNull(keys, "keys");

            DoOutOp(ClientOp.CacheRemoveKeys, w => w.WriteEnumerable(keys));
        }
Exemple #6
0
        /** <inheritDoc /> */
        public Task <bool> ContainsKeysAsync(IEnumerable <TK> keys)
        {
            IgniteArgumentCheck.NotNull(keys, "keys");

            return(DoOutInOpAsync(ClientOp.CacheContainsKeys, w => w.WriteEnumerable(keys), r => r.ReadBool()));
        }
Exemple #7
0
        /** <inheritDoc /> */
        public Task PutAllAsync(IEnumerable <KeyValuePair <TK, TV> > vals)
        {
            IgniteArgumentCheck.NotNull(vals, "vals");

            return(DoOutOpAsync(ClientOp.CachePutAll, w => w.WriteDictionary(vals)));
        }
Exemple #8
0
        /** <inheritdoc /> */
        public void Send(object message, object topic = null)
        {
            IgniteArgumentCheck.NotNull(message, "message");

            DoOutOp((int)Op.Send, topic, message);
        }
        /// <summary>
        /// Casts this query to <see cref="ICacheQueryable"/>.
        /// </summary>
        public static ICacheQueryable ToCacheQueryable <T>(this IQueryable <T> query)
        {
            IgniteArgumentCheck.NotNull(query, "query");

            return((ICacheQueryable)query);
        }
Exemple #10
0
        /// <summary>
        /// Starts Ignite with given configuration.
        /// </summary>
        /// <returns>Started Ignite.</returns>
        public unsafe static IIgnite Start(IgniteConfiguration cfg)
        {
            IgniteArgumentCheck.NotNull(cfg, "cfg");

            lock (SyncRoot)
            {
                // 1. Check GC settings.
                CheckServerGc(cfg);

                // 2. Create context.
                IgniteUtils.LoadDlls(cfg.JvmDllPath);

                var cbs = new UnmanagedCallbacks();

                IgniteManager.CreateJvmContext(cfg, cbs);

                var gridName = cfg.GridName;

                var cfgPath = cfg.SpringConfigUrl == null
                    ? null
                    : Environment.GetEnvironmentVariable(EnvIgniteSpringConfigUrlPrefix) + cfg.SpringConfigUrl;

                // 3. Create startup object which will guide us through the rest of the process.
                _startup = new Startup(cfg, cbs);

                IUnmanagedTarget interopProc = null;

                try
                {
                    // 4. Initiate Ignite start.
                    UU.IgnitionStart(cbs.Context, cfgPath, gridName, 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;

                    if (interopProc != null)
                    {
                        UU.ProcessorReleaseStart(interopProc);
                    }
                }
            }
        }
        /// <summary>
        /// Deserializes IgniteConfiguration from the XML reader.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>Deserialized instance.</returns>
        public static IgniteConfiguration FromXml(XmlReader reader)
        {
            IgniteArgumentCheck.NotNull(reader, "reader");

            return(IgniteConfigurationXmlSerializer.Deserialize(reader));
        }
Exemple #12
0
        /** <inheritDoc /> */
        public ICacheClient <TK, TV> GetCache <TK, TV>(string name)
        {
            IgniteArgumentCheck.NotNull(name, "name");

            return(new CacheClient <TK, TV>(this, name));
        }
Exemple #13
0
        /** <inheritDoc /> */
        public void DestroyCache(string name)
        {
            IgniteArgumentCheck.NotNull(name, "name");

            DoOutOp(ClientOp.CacheDestroy, ctx => ctx.Stream.WriteInt(BinaryUtils.GetCacheId(name)));
        }
Exemple #14
0
        /** <inheritdoc /> */
        public IClusterGroup ForHost(IClusterNode node)
        {
            IgniteArgumentCheck.NotNull(node, "node");

            return(_prj.ForHost(node));
        }
Exemple #15
0
        /** <inheritDoc /> */
        public Task <ICollection <ICacheEntry <TK, TV> > > GetAllAsync(IEnumerable <TK> keys)
        {
            IgniteArgumentCheck.NotNull(keys, "keys");

            return(DoOutInOpAsync(ClientOp.CacheGetAll, w => w.WriteEnumerable(keys), s => ReadCacheEntries(s)));
        }
Exemple #16
0
        /// <summary>
        /// Starts Ignite with given configuration.
        /// </summary>
        /// <returns>Started Ignite.</returns>
        public static IIgnite Start(IgniteConfiguration cfg)
        {
            IgniteArgumentCheck.NotNull(cfg, "cfg");

            cfg = new IgniteConfiguration(cfg);  // Create a copy so that config can be modified and reused.

            lock (SyncRoot)
            {
                // 0. Init logger
                var log = cfg.Logger ?? new JavaLogger();

                log.Debug("Starting Ignite.NET " + Assembly.GetExecutingAssembly().GetName().Version);

                // 1. Check GC settings.
                CheckServerGc(cfg, log);

                // 2. Create context.
                JvmDll.Load(cfg.JvmDllPath, log);

                var cbs = IgniteManager.CreateJvmContext(cfg, log);
                var env = cbs.Jvm.AttachCurrentThread();
                log.Debug("JVM started.");

                var gridName = cfg.IgniteInstanceName;

                if (cfg.AutoGenerateIgniteInstanceName)
                {
                    gridName = (gridName ?? "ignite-instance-") + Guid.NewGuid();
                }

                // 3. Create startup object which will guide us through the rest of the process.
                _startup = new Startup(cfg, cbs);

                PlatformJniTarget interopProc = null;

                try
                {
                    // 4. Initiate Ignite start.
                    UU.IgnitionStart(env, cfg.SpringConfigUrl, gridName, ClientMode, cfg.Logger != null, cbs.IgniteId,
                                     cfg.RedirectJavaConsoleOutput);

                    // 5. At this point start routine is finished. We expect STARTUP object to have all necessary data.
                    var node = _startup.Ignite;
                    interopProc = (PlatformJniTarget)node.InteropProcessor;

                    var javaLogger = log as JavaLogger;
                    if (javaLogger != null)
                    {
                        javaLogger.SetIgnite(node);
                    }

                    // 6. On-start callback (notify lifecycle components).
                    node.OnStart();

                    Nodes[new NodeKey(_startup.Name)] = node;

                    return(node);
                }
                catch (Exception ex)
                {
                    // 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(gridName, true);
                    }

                    // 3. Throw error further (use startup error if exists because it is more precise).
                    if (_startup.Error != null)
                    {
                        // Wrap in a new exception to preserve original stack trace.
                        throw new IgniteException("Failed to start Ignite.NET, check inner exception for details",
                                                  _startup.Error);
                    }

                    var jex = ex as JavaException;

                    if (jex == null)
                    {
                        throw;
                    }

                    throw ExceptionUtils.GetException(null, jex);
                }
                finally
                {
                    var ignite = _startup.Ignite;

                    _startup = null;

                    if (ignite != null)
                    {
                        ignite.ProcessorReleaseStart();
                    }
                }
            }
        }
Exemple #17
0
        /** <inheritDoc /> */
        public bool ContainsKey(TK key)
        {
            IgniteArgumentCheck.NotNull(key, "key");

            return(DoOutInOp(ClientOp.CacheContainsKey, w => w.WriteObjectDetached(key), r => r.ReadBool()));
        }
Exemple #18
0
        /** <inheritDoc /> */
        public Task <TV> GetAsync(TK key)
        {
            IgniteArgumentCheck.NotNull(key, "key");

            return(DoOutInOpAffinityAsync(ClientOp.CacheGet, key, w => w.WriteObjectDetached(key), UnmarshalNotNull <TV>));
        }
Exemple #19
0
        /** <inheritDoc /> */
        public void PutAll(IEnumerable <KeyValuePair <TK, TV> > vals)
        {
            IgniteArgumentCheck.NotNull(vals, "vals");

            DoOutOp(ClientOp.CachePutAll, w => w.WriteDictionary(vals));
        }
Exemple #20
0
        /** <inheritDoc /> */
        public bool ContainsKey(TK key)
        {
            IgniteArgumentCheck.NotNull(key, "key");

            return(DoOutInOpAffinity(ClientOp.CacheContainsKey, key, r => r.ReadBool()));
        }
Exemple #21
0
        /** <inheritDoc /> */
        public void Clear(TK key)
        {
            IgniteArgumentCheck.NotNull(key, "key");

            DoOutOp(ClientOp.CacheClearKey, w => w.WriteObjectDetached(key));
        }
Exemple #22
0
        /** <inheritDoc /> */
        public void Clear(TK key)
        {
            IgniteArgumentCheck.NotNull(key, "key");

            DoOutOpAffinity(ClientOp.CacheClearKey, key);
        }
Exemple #23
0
        /** <inheritDoc /> */
        public Task <bool> RemoveAsync(TK key)
        {
            IgniteArgumentCheck.NotNull(key, "key");

            return(DoOutInOpAsync(ClientOp.CacheRemoveKey, w => w.WriteObjectDetached(key), r => r.ReadBool()));
        }
Exemple #24
0
        /** <inheritDoc /> */
        public Task <bool> RemoveAsync(TK key)
        {
            IgniteArgumentCheck.NotNull(key, "key");

            return(DoOutInOpAffinityAsync(ClientOp.CacheRemoveKey, key, r => r.ReadBool()));
        }
Exemple #25
0
        /** <inheritDoc /> */
        public Task RemoveAllAsync(IEnumerable <TK> keys)
        {
            IgniteArgumentCheck.NotNull(keys, "keys");

            return(DoOutOpAsync(ClientOp.CacheRemoveKeys, w => w.WriteEnumerable(keys)));
        }
Exemple #26
0
        /** <inheritDoc /> */
        public ICacheClient <TK, TV> WithExpiryPolicy(IExpiryPolicy plc)
        {
            IgniteArgumentCheck.NotNull(plc, "plc");

            return(new CacheClient <TK, TV>(_ignite, _name, _keepBinary, plc));
        }
Exemple #27
0
        /** <inheritDoc /> */
        public TV Get(TK key)
        {
            IgniteArgumentCheck.NotNull(key, "key");

            return(DoOutInOpAffinity(ClientOp.CacheGet, key, ctx => UnmarshalNotNull <TV>(ctx)));
        }
Exemple #28
0
        /** <inheritDoc /> */
        public Task <CacheResult <TV> > TryGetAsync(TK key)
        {
            IgniteArgumentCheck.NotNull(key, "key");

            return(DoOutInOpAsync(ClientOp.CacheGet, w => w.WriteObject(key), UnmarshalCacheResult <TV>));
        }
Exemple #29
0
        /** <inheritDoc /> */
        public Task <CacheResult <TV> > GetAndRemoveAsync(TK key)
        {
            IgniteArgumentCheck.NotNull(key, "key");

            return(DoOutInOpAffinityAsync(ClientOp.CacheGetAndRemove, key, UnmarshalCacheResult <TV>));
        }
Exemple #30
0
        /** <inheritdoc /> */
        public void ResetLostPartitions(IEnumerable <string> cacheNames)
        {
            IgniteArgumentCheck.NotNull(cacheNames, "cacheNames");

            _prj.ResetLostPartitions(cacheNames);
        }