Esempio n. 1
0
        /** <inheritDoc /> */
        public Task <ICollection <ICacheEntry <TK, TV> > > GetAllAsync(IEnumerable <TK> keys)
        {
            IgniteArgumentCheck.NotNull(keys, "keys");

            return(DoOutOpAsync(CacheOp.GetAllAsync, w => w.WriteEnumerable(keys), r => ReadGetAllDictionary(r)));
        }
Esempio n. 2
0
        /// <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));
        }
Esempio n. 3
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();
                    }
                }
            }
        }
Esempio n. 4
0
        /** <inheritdoc /> */
        public T GetPlugin <T>(string name) where T : class
        {
            IgniteArgumentCheck.NotNullOrEmpty(name, "name");

            return(PluginProcessor.GetProvider(name).GetPlugin <T>());
        }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Endpoint"/> class.
 /// </summary>
 private Endpoint(string host, int port = IgniteClientConfiguration.DefaultPort, int portRange = 0)
 {
     Host      = IgniteArgumentCheck.NotNullOrEmpty(host, "host");
     Port      = port;
     PortRange = portRange;
 }
Esempio n. 6
0
        /** <inheritdoc /> */
        public IClusterGroup ForHost(IClusterNode node)
        {
            IgniteArgumentCheck.NotNull(node, "node");

            return(_prj.ForHost(node));
        }
Esempio n. 7
0
        /** <inheritdoc /> */
        public void DestroyCache(string name)
        {
            IgniteArgumentCheck.NotNull(name, "name");

            UU.ProcessorDestroyCache(_proc, name);
        }
Esempio n. 8
0
        /** <inheritdoc /> */
        public ICache <TK, TV> GetOrCreateCache <TK, TV>(string name)
        {
            IgniteArgumentCheck.NotNull(name, "name");

            return(GetCache <TK, TV>(DoOutOpObject((int)Op.GetOrCreateCache, w => w.WriteString(name))));
        }
Esempio n. 9
0
        /** <inheritdoc /> */
        public void DestroyCache(string name)
        {
            IgniteArgumentCheck.NotNull(name, "name");

            DoOutOp((int)Op.DestroyCache, w => w.WriteString(name));
        }
Esempio n. 10
0
        /** <inheritdoc /> */
        public void LocalClearAll(IEnumerable <TK> keys)
        {
            IgniteArgumentCheck.NotNull(keys, "keys");

            DoOutOp(CacheOp.LocalClearAll, writer => writer.WriteEnumerable(keys));
        }
Esempio n. 11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="IgniteLog4NetLogger"/> class.
        /// </summary>
        /// <param name="log">The log.</param>
        public IgniteLog4NetLogger(ILog log)
        {
            IgniteArgumentCheck.NotNull(log, "log");

            _log = log;
        }
Esempio n. 12
0
        /** <inheritdoc /> */
        public void LocalClear(TK key)
        {
            IgniteArgumentCheck.NotNull(key, "key");

            DoOutOp(CacheOp.LocalClear, key);
        }
Esempio n. 13
0
        /** <inheritDoc /> */
        public Task ClearAllAsync(IEnumerable <TK> keys)
        {
            IgniteArgumentCheck.NotNull(keys, "keys");

            return(DoOutOpAsync(CacheOp.ClearAllAsync, writer => writer.WriteEnumerable(keys)));
        }
Esempio n. 14
0
        /** <inheritDoc /> */
        public Task ClearAsync(TK key)
        {
            IgniteArgumentCheck.NotNull(key, "key");

            return(DoOutOpAsync(CacheOp.ClearAsync, key));
        }
Esempio n. 15
0
        /// <summary>
        /// Gets the <see cref="CategoryLogger"/> with a specified category that wraps provided logger.
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <param name="category">The category.</param>
        /// <returns>Logger that uses specified category when no other category is provided.</returns>
        public static ILogger GetLogger(this ILogger logger, string category)
        {
            IgniteArgumentCheck.NotNull(logger, "logger");

            return(new CategoryLogger(logger, category));
        }
Esempio n. 16
0
        /** <inheritdoc /> */
        public IDataStreamer <TK, TV> GetDataStreamer <TK, TV>(string cacheName)
        {
            IgniteArgumentCheck.NotNull(cacheName, "cacheName");

            return(GetDataStreamer <TK, TV>(cacheName, false));
        }
Esempio n. 17
0
        /** <inheritdoc /> */
        public IClusterGroup ForPredicate(Func <IClusterNode, bool> p)
        {
            IgniteArgumentCheck.NotNull(p, "p");

            return(_prj.ForPredicate(p));
        }
Esempio n. 18
0
        /** <inheritdoc /> */
        public IMemoryMetrics GetMemoryMetrics(string memoryPolicyName)
        {
            IgniteArgumentCheck.NotNullOrEmpty(memoryPolicyName, "memoryPolicyName");

            return(_prj.GetMemoryMetrics(memoryPolicyName));
        }
Esempio n. 19
0
        /** <inheritdoc /> */
        public ICache <TK, TV> CreateCache <TK, TV>(string name)
        {
            IgniteArgumentCheck.NotNull(name, "name");

            return(Cache <TK, TV>(UU.ProcessorCreateCache(_proc, name)));
        }
Esempio n. 20
0
        /** <inheritdoc /> */
        public void EnableWal(string cacheName)
        {
            IgniteArgumentCheck.NotNull(cacheName, "cacheName");

            DoOutOp((int)Op.EnableWal, w => w.WriteString(cacheName));
        }
Esempio n. 21
0
        /** <inheritdoc /> */
        public ICacheAffinity GetAffinity(string cacheName)
        {
            IgniteArgumentCheck.NotNull(cacheName, "cacheName");

            return(new CacheAffinityImpl(UU.ProcessorAffinity(_proc, cacheName), _marsh, false, this));
        }
Esempio n. 22
0
        /** <inheritdoc /> */
        public bool IsWalEnabled(string cacheName)
        {
            IgniteArgumentCheck.NotNull(cacheName, "cacheName");

            return(DoOutOp((int)Op.IsWalEnabled, w => w.WriteString(cacheName)) == True);
        }
Esempio n. 23
0
        /** <inheritdoc /> */
        public void ResetLostPartitions(IEnumerable <string> cacheNames)
        {
            IgniteArgumentCheck.NotNull(cacheNames, "cacheNames");

            _prj.ResetLostPartitions(cacheNames);
        }
Esempio n. 24
0
        /** <inheritDoc /> */
        public IClientClusterGroup ForAttribute(string name, string val)
        {
            IgniteArgumentCheck.NotNullOrEmpty(name, "name");

            return(new ClientClusterGroup(_ignite, _marsh, _projection.ForAttribute(name, val)));
        }
Esempio n. 25
0
        /** <inheritDoc /> */
        public void Cancel(string name)
        {
            IgniteArgumentCheck.NotNullOrEmpty(name, "name");

            UU.ServicesCancel(Target, name);
        }
Esempio n. 26
0
        /// <summary>
        /// Logs the message.
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <param name="level">The level.</param>
        /// <param name="ex">The exception.</param>
        /// <param name="message">The message.</param>
        public static void Log(this ILogger logger, LogLevel level, Exception ex, string message)
        {
            IgniteArgumentCheck.NotNull(logger, "logger");

            logger.Log(level, message, null, null, null, null, ex);
        }
Esempio n. 27
0
        /** <inheritdoc /> */
        public void Send(object message, object topic = null)
        {
            IgniteArgumentCheck.NotNull(message, "message");

            DoOutOp((int)Op.Send, topic, message);
        }
Esempio n. 28
0
        /// <summary>
        /// Logs the message.
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <param name="level">The level.</param>
        /// <param name="ex">The exception.</param>
        /// <param name="message">The message.</param>
        /// <param name="args">The arguments.</param>
        public static void Log(this ILogger logger, LogLevel level, Exception ex, string message, params object[] args)
        {
            IgniteArgumentCheck.NotNull(logger, "logger");

            logger.Log(level, message, args, CultureInfo.InvariantCulture, null, null, ex);
        }
Esempio n. 29
0
        /** <inheritDoc /> */
        public TV Get(TK key)
        {
            IgniteArgumentCheck.NotNull(key, "key");

            return(DoOutInOpAffinity(ClientOp.CacheGet, key, UnmarshalNotNull <TV>));
        }
Esempio n. 30
0
        /** <inheritDoc /> */
        public Task <CacheResult <TV> > TryGetAsync(TK key)
        {
            IgniteArgumentCheck.NotNull(key, "key");

            return(DoOutOpAsync(CacheOp.GetAsync, w => w.WriteObject(key), reader => GetCacheResult(reader)));
        }