public TempDirectoryConfiguration(ISession session, IElasticsearchEnvironmentStateProvider esState, IFileSystem fileSystem) { Session = session; FileSystem = fileSystem ?? new FileSystem();; ProductName = this.Session.ProductName; TempProductInstallationDirectory = this.FileSystem.Path.Combine(esState.TempDirectoryVariable, ProductName + DirectorySuffix); }
public JavaConfiguration( IJavaEnvironmentStateProvider javaStateProvider, IElasticsearchEnvironmentStateProvider elasticsearchStateProvider) { _javaStateProvider = javaStateProvider ?? new JavaEnvironmentStateProvider(); _elasticsearchStateProvider = elasticsearchStateProvider ?? new ElasticsearchEnvironmentStateProvider(); }
public InstallationModel( IWixStateProvider wixStateProvider, JavaConfiguration javaConfiguration, IElasticsearchEnvironmentStateProvider environmentStateProvider, IServiceStateProvider serviceStateProvider, IPluginStateProvider pluginStateProvider, ElasticsearchYamlConfiguration yamlConfiguration, LocalJvmOptionsConfiguration localJvmOptions, ISession session, string[] args ) { this.Session = session; if (wixStateProvider == null) { throw new ArgumentNullException(nameof(wixStateProvider)); } if (javaConfiguration == null) { throw new ArgumentNullException(nameof(javaConfiguration)); } this._wixStateProvider = wixStateProvider; this.JavaConfiguration = javaConfiguration; this.ElasticsearchEnvironmentState = environmentStateProvider; this._yamlConfiguration = yamlConfiguration; var versionConfig = new VersionConfiguration(wixStateProvider); this.SameVersionAlreadyInstalled = versionConfig.SameVersionAlreadyInstalled; this.HigherVersionAlreadyInstalled = versionConfig.HigherVersionAlreadyInstalled; this.LocationsModel = new LocationsModel(environmentStateProvider, yamlConfiguration, versionConfig); this.NoticeModel = new NoticeModel(versionConfig, serviceStateProvider, this.LocationsModel); this.ServiceModel = new ServiceModel(serviceStateProvider, versionConfig); this.ConfigurationModel = new ConfigurationModel(yamlConfiguration, localJvmOptions); var pluginDependencies = this.WhenAnyValue( vm => vm.ConfigurationModel.IngestNode, vm => vm.NoticeModel.AlreadyInstalled, vm => vm.LocationsModel.InstallDir, vm => vm.LocationsModel.ConfigDirectory ); this.PluginsModel = new PluginsModel(pluginStateProvider, pluginDependencies); var observeHost = this.WhenAnyValue(vm => vm.ConfigurationModel.NetworkHost, vm => vm.ConfigurationModel.HttpPort, (h, p) => $"http://{(string.IsNullOrWhiteSpace(h) ? "localhost" : h)}:{p}"); var observeLog = this.WhenAnyValue(vm => vm.MsiLogFileLocation); var observeElasticsearchLog = this.WhenAnyValue(vm => vm.LocationsModel.ElasticsearchLog); var isUpgrade = versionConfig.InstallationDirection == InstallationDirection.Up; this.ClosingModel = new ClosingModel(wixStateProvider.CurrentVersion, isUpgrade, observeHost, observeLog, observeElasticsearchLog, serviceStateProvider); this.AllSteps = new ReactiveList <IStep> { this.NoticeModel, this.LocationsModel, this.ServiceModel, this.ConfigurationModel, this.PluginsModel, this.ClosingModel }; this.Steps = this.AllSteps.CreateDerivedCollection(x => x, x => x.IsRelevant); this.NextButtonText = TextResources.SetupView_NextText; var canMoveForwards = this.WhenAny(vm => vm.TabSelectedIndex, vm => vm.TabSelectionMax, (i, max) => i.GetValue() < max.GetValue()); this.Next = ReactiveCommand.Create(canMoveForwards); this.Next.Subscribe(i => { this.TabSelectedIndex = Math.Min(this.Steps.Count - 1, this.TabSelectedIndex + 1); }); var canMoveBackwards = this.WhenAny(vm => vm.TabSelectedIndex, (i) => i.GetValue() > 0); this.Back = ReactiveCommand.Create(canMoveBackwards); this.Back.Subscribe(i => { this.TabSelectedIndex = Math.Max(0, this.TabSelectedIndex - 1); }); this.Help = ReactiveCommand.Create(); this.ShowLicenseBlurb = ReactiveCommand.Create(); this.ShowCurrentStepErrors = ReactiveCommand.Create(); this.RefreshCurrentStep = ReactiveCommand.Create(); this.RefreshCurrentStep.Subscribe(x => { this.Steps[this.TabSelectedIndex].Refresh(); }); this.Exit = ReactiveCommand.Create(); var observeValidationChanges = this.WhenAny( vm => vm.NoticeModel.ValidationFailures, vm => vm.LocationsModel.ValidationFailures, vm => vm.ConfigurationModel.ValidationFailures, vm => vm.PluginsModel.ValidationFailures, vm => vm.ServiceModel.ValidationFailures, vm => vm.ClosingModel.ValidationFailures, vm => vm.TabSelectedIndex, (welcome, locations, configuration, plugins, service, install, index) => { var firstInvalidScreen = this.Steps.FirstOrDefault(s => !s.IsValid) ?? this.ClosingModel; return(firstInvalidScreen); }); var canInstall = observeValidationChanges.Select(s => s.IsValid); this.Install = ReactiveCommand.CreateAsyncTask(canInstall, _ => { this.TabSelectedIndex += 1; return(this.InstallUITask()); }); this.Install.Subscribe(installationObservable => { installationObservable.Subscribe(installed => { this.ClosingModel.Installed = installed; }); }); this.WhenAny(vm => vm.TabSelectedIndex, v => v.GetValue()) .Subscribe(i => { var c = this.Steps.Count; if (i == (c - 1)) { this.NextButtonText = TextResources.SetupView_ExitText; } else if (i == (c - 2)) { this.NextButtonText = TextResources.SetupView_InstallText; } else { this.NextButtonText = TextResources.SetupView_NextText; } }); observeValidationChanges .Subscribe(selected => { var step = this.Steps[this.TabSelectedIndex]; var failures = step.ValidationFailures; this.CurrentStepValidationFailures = selected.ValidationFailures; }); this.WhenAny( vm => vm.NoticeModel.IsValid, vm => vm.LocationsModel.IsValid, vm => vm.ConfigurationModel.IsValid, vm => vm.PluginsModel.IsValid, vm => vm.ServiceModel.IsValid, vm => vm.ClosingModel.IsValid, (welcome, locations, configuration, plugins, service, install) => { var firstInvalidScreen = this.Steps.Select((s, i) => new { s, i }).FirstOrDefault(s => !s.s.IsValid); return(firstInvalidScreen?.i ?? (this.Steps.Count - 1)); }) .Subscribe(selected => { this.TabSelectionMax = selected; //if one of the steps prior to the current selection is invalid jump back if (this.TabSelectedIndex > this.TabSelectionMax) { this.TabSelectedIndex = this.TabSelectionMax; } this.CurrentStepValidationFailures = this.ActiveStep.ValidationFailures; }); this.WhenAnyValue(view => view.ValidationFailures) .Subscribe(failures => { this.PrequisiteFailures = (failures ?? Enumerable.Empty <ValidationFailure>()) .Where(v => _prerequisiteProperties.Contains(v.PropertyName)) .ToList(); }); this.Refresh(); //validate the first stab explicitly on constructing this //main viewmodel. WPF triggers a validation already this.ParsedArguments = new InstallationModelArgumentParser(this.AllSteps.Cast <IValidatableReactiveObject>().Concat(new[] { this }).ToList(), args); this.ActiveStep.Validate(); }
public ElasticsearchEnvironmentConfiguration(IElasticsearchEnvironmentStateProvider stateProvider) =>
public ElasticsearchEnvironmentConfiguration(IElasticsearchEnvironmentStateProvider stateProvider) { StateProvider = stateProvider ?? new ElasticsearchEnvironmentStateProvider(); }
public LocationsModel( IElasticsearchEnvironmentStateProvider environmentStateProvider, ElasticsearchYamlConfiguration yamlConfiguration, VersionConfiguration versionConfig) { this.IsRelevant = !versionConfig.AlreadyInstalled; this.Header = "Locations"; this._environmentStateProvider = environmentStateProvider; this._yamlConfiguration = yamlConfiguration; this.Refresh(); this._refreshing = true; //when configurelocations is checked and place paths in samefolder is not set, set configureall locations to true var prop = this.WhenAny( vm => vm.ConfigureLocations, vm => vm.PlaceWritableLocationsInSamePath, vm => vm.InstallDir, (configureLocations, samePath, i) => configureLocations.GetValue() && !samePath.GetValue() ) .ToProperty(this, vm => vm.ConfigureAllLocations, out configureAllLocations); this.WhenAny( vm => vm.LogsDirectory, (c) => { var v = c.GetValue(); if (Path.IsPathRooted(v)) { return(Path.Combine(c.GetValue(), "elasticsearch.log")); } return(null); }) .ToProperty(this, vm => vm.ElasticsearchLog, out elasticsearchLog); this.ThrownExceptions.Subscribe(e => { }); //If install, config, logs or data dir are set force ConfigureLocations to true this.WhenAny( vm => vm.InstallDir, vm => vm.ConfigDirectory, vm => vm.LogsDirectory, vm => vm.DataDirectory, (i, c, l, d) => !this._refreshing ) .Subscribe(x => { if (x) { this.ConfigureLocations = true; } }); this.WhenAny( vm => vm.ConfigureLocations, (c) => !this._refreshing && !c.Value ) .Subscribe(x => { if (x) { this.Refresh(); } }); this._refreshing = false; }