コード例 #1
0
ファイル: Configurator.cs プロジェクト: zshamrock/ignite
        /** <inheritDoc /> */
        public static IgniteConfiguration GetConfiguration(Tuple <string, string>[] args)
        {
            var jvmOpts    = new List <string>();
            var assemblies = new List <string>();

            var cfg = ReadConfigurationSection(args) ?? new IgniteConfiguration();

            foreach (var arg in args)
            {
                if (string.IsNullOrWhiteSpace(arg.Item2))
                {
                    throw new IgniteException(string.Format(
                                                  "Missing argument value: '{0}'. See 'Apache.Ignite.exe /help'", arg.Item1));
                }

                var arg0 = arg;  // copy captured variable
                Func <string, bool> argIs = x => arg0.Item1.Equals(x, StringComparison.OrdinalIgnoreCase);

                if (argIs(CmdIgniteHome))
                {
                    cfg.IgniteHome = arg.Item2;
                }
                else if (argIs(CmdSpringCfgUrl))
                {
                    cfg.SpringConfigUrl = arg.Item2;
                }
                else if (argIs(CmdJvmDll))
                {
                    cfg.JvmDllPath = arg.Item2;
                }
                else if (argIs(CmdJvmClasspath))
                {
                    cfg.JvmClasspath = arg.Item2;
                }
                else if (argIs(CmdSuppressWarn))
                {
                    cfg.SuppressWarnings = bool.TrueString.Equals(arg.Item2, StringComparison.OrdinalIgnoreCase);
                }
                else if (argIs(CmdJvmMinMem))
                {
                    cfg.JvmInitialMemoryMb = ConfigValueParser.ParseInt(arg.Item2, CmdJvmMinMem);
                }
                else if (argIs(CmdJvmMaxMem))
                {
                    cfg.JvmMaxMemoryMb = ConfigValueParser.ParseInt(arg.Item2, CmdJvmMaxMem);
                }
                else if (argIs(CmdJvmOpt))
                {
                    jvmOpts.Add(arg.Item2);
                }
                else if (argIs(CmdAssembly))
                {
                    assemblies.Add(arg.Item2);
                }
                else if (argIs(CmdForceTestClasspath) && arg.Item2 == "true")
                {
                    Environment.SetEnvironmentVariable("IGNITE_NATIVE_TEST_CLASSPATH", "true");
                }
                else if (!argIs(CmdConfigFile) && !argIs(CmdConfigSection))
                {
                    throw new IgniteException(string.Format(
                                                  "Unknown argument: '{0}'. See 'Apache.Ignite.exe /help'", arg.Item1));
                }
            }

            if (jvmOpts.Count > 0)
            {
                if (cfg.JvmOptions == null)
                {
                    cfg.JvmOptions = jvmOpts;
                }
                else
                {
                    jvmOpts.ForEach(val => cfg.JvmOptions.Add(val));
                }
            }

            if (assemblies.Count > 0)
            {
                if (cfg.Assemblies == null)
                {
                    cfg.Assemblies = assemblies;
                }
                else
                {
                    assemblies.ForEach(val => cfg.Assemblies.Add(val));
                }
            }

            return(cfg);
        }
コード例 #2
0
        /** <inheritDoc /> */
        public static IgniteConfiguration GetConfiguration(Tuple <string, string>[] args)
        {
            var jvmOpts    = new List <string>();
            var assemblies = new List <string>();

            var cfg = ReadConfigurationSection(args) ?? new IgniteConfiguration();

            foreach (var arg in args)
            {
                Func <string, bool> argIs = x => arg.Item1.Equals(x, StringComparison.OrdinalIgnoreCase);

                if (argIs(CmdIgniteHome))
                {
                    cfg.IgniteHome = arg.Item2;
                }
                else if (argIs(CmdSpringCfgUrl))
                {
                    cfg.SpringConfigUrl = arg.Item2;
                }
                else if (argIs(CmdJvmDll))
                {
                    cfg.JvmDllPath = arg.Item2;
                }
                else if (argIs(CmdJvmClasspath))
                {
                    cfg.JvmClasspath = arg.Item2;
                }
                else if (argIs(CmdSuppressWarn))
                {
                    cfg.SuppressWarnings = bool.TrueString.Equals(arg.Item2, StringComparison.OrdinalIgnoreCase);
                }
                else if (argIs(CmdJvmMinMem))
                {
                    cfg.JvmInitialMemoryMb = ConfigValueParser.ParseInt(arg.Item2, CmdJvmMinMem);
                }
                else if (argIs(CmdJvmMaxMem))
                {
                    cfg.JvmMaxMemoryMb = ConfigValueParser.ParseInt(arg.Item2, CmdJvmMaxMem);
                }
                else if (argIs(CmdJvmOpt))
                {
                    jvmOpts.Add(arg.Item2);
                }
                else if (argIs(CmdAssembly))
                {
                    assemblies.Add(arg.Item2);
                }
                else if (argIs(CmdForceTestClasspath) && arg.Item2 == "true")
                {
                    Environment.SetEnvironmentVariable("IGNITE_NATIVE_TEST_CLASSPATH", "true");
                }
            }

            if (jvmOpts.Count > 0)
            {
                if (cfg.JvmOptions == null)
                {
                    cfg.JvmOptions = jvmOpts;
                }
                else
                {
                    jvmOpts.ForEach(val => cfg.JvmOptions.Add(val));
                }
            }

            if (assemblies.Count > 0)
            {
                if (cfg.Assemblies == null)
                {
                    cfg.Assemblies = assemblies;
                }
                else
                {
                    assemblies.ForEach(val => cfg.Assemblies.Add(val));
                }
            }

            return(cfg);
        }
コード例 #3
0
        /** <inheritDoc /> */
        public void Configure(IgniteConfiguration cfg, NameValueCollection src)
        {
            var jvmOpts    = new List <string>();
            var assemblies = new List <string>();

            foreach (string key in src.Keys)
            {
                var key0 = key.ToLower();

                if (key0.StartsWith(CfgPrefix))
                {
                    key0 = key0.Substring(CfgPrefix.Length);

                    var val = src[key];

                    if (CfgHome.Equals(key0))
                    {
                        cfg.IgniteHome = val;
                    }
                    else if (CfgSpringCfgUrl.Equals(key0))
                    {
                        cfg.SpringConfigUrl = val;
                    }
                    else if (CfgJvmDll.Equals(key0))
                    {
                        cfg.JvmDllPath = val;
                    }
                    else if (CfgJvmClasspath.Equals(key0))
                    {
                        cfg.JvmClasspath = val;
                    }
                    else if (CfgSuppressWarn.Equals(key0))
                    {
                        cfg.SuppressWarnings = val != null && bool.TrueString.ToLower().Equals(val.ToLower());
                    }
                    else if (key0.StartsWith(CfgJvmOptPrefix))
                    {
                        jvmOpts.Add(val);
                    }
                    else if (key0.StartsWith(CfgAssemblyPrefix))
                    {
                        assemblies.Add(val);
                    }
                    else if (CfgJvmMinMem.Equals(key0))
                    {
                        cfg.JvmInitialMemoryMb = ConfigValueParser.ParseInt(val, key);
                    }
                    else if (CfgJvmMaxMem.Equals(key0))
                    {
                        cfg.JvmMaxMemoryMb = ConfigValueParser.ParseInt(val, key);
                    }
                }
            }

            if (jvmOpts.Count > 0)
            {
                if (cfg.JvmOptions == null)
                {
                    cfg.JvmOptions = jvmOpts;
                }
                else
                {
                    jvmOpts.ForEach(val => cfg.JvmOptions.Add(val));
                }
            }

            if (assemblies.Count > 0)
            {
                if (cfg.Assemblies == null)
                {
                    cfg.Assemblies = assemblies;
                }
                else
                {
                    assemblies.ForEach(val => cfg.Assemblies.Add(val));
                }
            }
        }
コード例 #4
0
        /** <inheritDoc /> */
        public void Configure(IgniteConfiguration cfg, string[] src)
        {
            var jvmOpts    = new List <string>();
            var assemblies = new List <string>();

            foreach (var arg in src)
            {
                var argLow = arg.ToLower();

                if (argLow.StartsWith(CmdIgniteHome))
                {
                    cfg.IgniteHome = arg.Substring(CmdIgniteHome.Length);
                }
                else if (argLow.StartsWith(CmdSpringCfgUrl))
                {
                    cfg.SpringConfigUrl = arg.Substring(CmdSpringCfgUrl.Length);
                }
                else if (argLow.StartsWith(CmdJvmDll))
                {
                    cfg.JvmDllPath = arg.Substring(CmdJvmDll.Length);
                }
                else if (argLow.StartsWith(CmdJvmClasspath))
                {
                    cfg.JvmClasspath = arg.Substring(CmdJvmClasspath.Length);
                }
                else if (argLow.StartsWith(CmdSuppressWarn))
                {
                    var val = arg.Substring(CmdSuppressWarn.Length);

                    cfg.SuppressWarnings = bool.TrueString.ToLower().Equals(val.ToLower());
                }
                else if (argLow.StartsWith(CmdJvmMinMem))
                {
                    cfg.JvmInitialMemoryMb = ConfigValueParser.ParseInt(arg.Substring(CmdJvmMinMem.Length),
                                                                        CmdJvmMinMem);
                }
                else if (argLow.StartsWith(CmdJvmMaxMem))
                {
                    cfg.JvmMaxMemoryMb = ConfigValueParser.ParseInt(arg.Substring(CmdJvmMaxMem.Length),
                                                                    CmdJvmMaxMem);
                }
                else if (argLow.StartsWith(CmdJvmOpt))
                {
                    jvmOpts.Add(arg.Substring(CmdJvmOpt.Length));
                }
                else if (argLow.StartsWith(CmdAssembly))
                {
                    assemblies.Add(arg.Substring(CmdAssembly.Length));
                }
            }

            if (jvmOpts.Count > 0)
            {
                if (cfg.JvmOptions == null)
                {
                    cfg.JvmOptions = jvmOpts;
                }
                else
                {
                    jvmOpts.ForEach(val => cfg.JvmOptions.Add(val));
                }
            }

            if (assemblies.Count > 0)
            {
                if (cfg.Assemblies == null)
                {
                    cfg.Assemblies = assemblies;
                }
                else
                {
                    assemblies.ForEach(val => cfg.Assemblies.Add(val));
                }
            }
        }