public ConfigurationModel(ElasticsearchYamlConfiguration yamlConfiguration,
                                  LocalJvmOptionsConfiguration localJvmOptions, IObservable <bool> upgradingFrom6OrNewInstallation)
        {
            this.Header           = "Configuration";
            this._localJvmOptions = localJvmOptions;
            this._yamlSettings    = yamlConfiguration?.Settings;
            upgradingFrom6OrNewInstallation.Subscribe(b => this.UpgradingFrom6OrNewInstallation = b);
            this.Refresh();

            this.AddSeedHost = ReactiveCommand.CreateAsyncTask(async _ => await this.AddSeedHostUserInterfaceTask());
            this.WhenAnyObservable(vm => vm.AddSeedHost)
            .Subscribe(x =>
            {
                if (string.IsNullOrWhiteSpace(x))
                {
                    return;
                }
                var nodes = x
                            .Split(',')
                            .Select(node => node.Trim())
                            .Where(n => !string.IsNullOrEmpty(n))
                            .Distinct();

                foreach (var n in nodes)
                {
                    this.SeedHosts.Add(n);
                }
            });

            this.WhenAny(
                vm => vm.TotalPhysicalMemory,
                (maxMemory) => Math.Min(maxMemory.Value / 2, CompressedOrdinaryPointersThreshold)
                )
            .ToProperty(this, vm => vm.MaxSelectedMemory, out maxSelectedMemory);

            var canRemoveNode = this.WhenAny(vm => vm.SelectedSeedHost, (selected) => !string.IsNullOrWhiteSpace(selected.GetValue()));

            this.RemoveSeedHost = ReactiveCommand.Create(canRemoveNode);
            this.RemoveSeedHost.Subscribe(x =>
            {
                this.SeedHosts.Remove(this.SelectedSeedHost);
            });
            this.WhenAnyValue(vm => vm.MasterNode).Subscribe(b =>
            {
                // if we unset master node make sure InitialMaster is not set either.
                if (!b)
                {
                    this.InitialMaster = false;
                }
            });
        }
Exemple #2
0
        private void ApplyConfigurationModel(ElasticsearchYamlSettings settings)
        {
            this.Session.SendProgress(1000, "updating elasticsearch.yml with values from configuration model");
            var config  = this.InstallationModel.ConfigurationModel;
            var version = this.InstallationModel.NoticeModel.CurrentVersion;

            this.Session.Log($"Persisting configuration to elasticsearch.yml for version: {version}");

            settings.ClusterName = config.ClusterName;
            settings.NodeName    = config.NodeName;
            settings.MasterNode  = config.MasterNode;
            settings.DataNode    = config.DataNode;
            settings.IngestNode  = config.IngestNode;
            settings.MemoryLock  = config.LockMemory;
            settings.NetworkHost = !string.IsNullOrEmpty(config.NetworkHost) ? config.NetworkHost : null;
            if (config.HttpPort.HasValue)
            {
                settings.HttpPortString = config.HttpPort.Value.ToString(CultureInfo.InvariantCulture);
            }
            if (config.TransportPort.HasValue)
            {
                settings.TransportTcpPortString = config.TransportPort.Value.ToString(CultureInfo.InvariantCulture);
            }
            var hosts = config.SeedHosts;

            var hostsList = hosts.Any() ? hosts.ToList() : null;

            if (version.Major >= 7)
            {
                settings.SeedHosts = hostsList;
                var doesNotHaveInitialMasterNodesInYaml = settings.InitialMasterNodes == null || !settings.InitialMasterNodes.Any();
                this.Session.Log($"Yaml does not already have cluster.initial_master_nodes: {doesNotHaveInitialMasterNodesInYaml}");
                if (doesNotHaveInitialMasterNodesInYaml && !string.IsNullOrEmpty(config.NodeName) && config.InitialMaster)
                {
                    this.Session.Log($"Initial Master flag set defaulting to current node name: {config.NodeName}");
                    settings.InitialMasterNodes = new List <string> {
                        config.NodeName
                    };
                }
                this.Session.Log($"Making sure we are not carrying over unicast host or minimum master nodes configuration into >= 7.x of Elasticsearch");
                settings.UnicastHosts       = null;
                settings.MinimumMasterNodes = null;
            }
            else
            {
                settings.UnicastHosts = hostsList;
            }
        }
Exemple #3
0
        private void ApplyXPackModel(ElasticsearchYamlSettings settings)
        {
            this.Session.SendProgress(1000, "updating elasticsearch.yml with values from x-pack model if needed");
            var xPack = this.InstallationModel.XPackModel;

            //only set if no value already
            if (settings.XPackLicenseSelfGeneratedType.IsNullOrEmpty())
            {
                settings.XPackLicenseSelfGeneratedType = Enum.GetName(typeof(XPackLicenseMode), xPack.XPackLicense)?.ToLowerInvariant();
            }

            if (settings.XPackSecurityEnabled == null)
            {
                settings.XPackSecurityEnabled = xPack.XPackSecurityEnabled;
            }
        }
        public ConfigurationModel(ElasticsearchYamlConfiguration yamlConfiguration, LocalJvmOptionsConfiguration localJvmOptions)
        {
            this.Header           = "Configuration";
            this._localJvmOptions = localJvmOptions;
            this._yamlSettings    = yamlConfiguration?.Settings;
            this.Refresh();

            this.AddUnicastNode = ReactiveCommand.CreateAsyncTask(async _ => await this.AddUnicastNodeUITask());
            this.WhenAnyObservable(vm => vm.AddUnicastNode)
            .Subscribe(x =>
            {
                if (string.IsNullOrWhiteSpace(x))
                {
                    return;
                }
                var nodes = x
                            .Split(',')
                            .Select(node => node.Trim())
                            .Where(n => !string.IsNullOrEmpty(n))
                            .Distinct();

                foreach (var n in nodes)
                {
                    this.UnicastNodes.Add(n);
                }
            });

            this.WhenAny(
                vm => vm.TotalPhysicalMemory,
                (maxMemory) => Math.Min(maxMemory.Value / 2, CompressedOrdinaryPointersThreshold)
                )
            .ToProperty(this, vm => vm.MaxSelectedMemory, out maxSelectedMemory);

            var canRemoveNode = this.WhenAny(vm => vm.SelectedUnicastNode, (selected) => !string.IsNullOrWhiteSpace(selected.GetValue()));

            this.RemoveUnicastNode = ReactiveCommand.Create(canRemoveNode);
            this.RemoveUnicastNode.Subscribe(x =>
            {
                this.UnicastNodes.Remove(this.SelectedUnicastNode);
            });
        }
        private void ApplyXPackModel(ElasticsearchYamlSettings settings)
        {
            this.Session.SendProgress(1000, "updating elasticsearch.yml with values from x-pack model if needed");
            var xPack = this.InstallationModel.XPackModel;

            if (!xPack.IsRelevant)
            {
                //make sure we unset all xpack related settings because they might prevent a node from starting
                settings.XPackLicenseSelfGeneratedType = null;
                settings.XPackSecurityEnabled          = null;
                var xPackKeys = settings.Keys.Where(k => k.StartsWith("xpack.")).ToList();
                foreach (var key in xPackKeys)
                {
                    settings.Remove(key);
                }
            }
            else if (!this.InstallationModel.PluginsModel.InstalledPlugins.Contains("x-pack"))
            {
                settings.XPackLicenseSelfGeneratedType = Enum.GetName(typeof(XPackLicenseMode), xPack.XPackLicense)?.ToLowerInvariant();
                settings.XPackSecurityEnabled          = !xPack.XPackSecurityEnabled ? false : (bool?)null;
            }
        }
Exemple #6
0
        private void ApplyConfigurationModel(ElasticsearchYamlSettings settings)
        {
            this.Session.SendProgress(1000, "updating elasticsearch.yml with values from configuration model");
            var config = this.InstallationModel.ConfigurationModel;

            settings.ClusterName = config.ClusterName;
            settings.NodeName    = config.NodeName;
            settings.MasterNode  = config.MasterNode;
            settings.DataNode    = config.DataNode;
            settings.IngestNode  = config.IngestNode;
            settings.MemoryLock  = config.LockMemory;
            settings.NetworkHost = !string.IsNullOrEmpty(config.NetworkHost) ? config.NetworkHost : null;
            if (config.HttpPort.HasValue)
            {
                settings.HttpPortString = config.HttpPort.Value.ToString(CultureInfo.InvariantCulture);
            }
            if (config.TransportPort.HasValue)
            {
                settings.TransportTcpPortString = config.TransportPort.Value.ToString(CultureInfo.InvariantCulture);
            }
            var hosts = config.UnicastNodes;

            settings.UnicastHosts = hosts.Any() ? hosts.ToList() : null;
        }
Exemple #7
0
 private void ApplyLocationsModel(ElasticsearchYamlSettings settings, LocationsModel locations)
 {
     this.Session.SendProgress(1000, "updating elasticsearch.yml with values from locations model");
     settings.LogsPath = locations.LogsDirectory;
     settings.DataPath = locations.DataDirectory;
 }
Exemple #8
0
 private void ApplyServiceModel(ElasticsearchYamlSettings settings)
 {
     this.Session.SendProgress(1000, "updating elasticsearch.yml with values from locations model");
     settings.MaxLocalStorageNodes = this.InstallationModel.ServiceModel.InstallAsService ? (int?)1 : null;
 }