public ElasticsearchPluginConfiguration(ElasticsearchPlugin plugin, Func <ElasticsearchVersion, bool> isValid) { Plugin = plugin; Moniker = plugin.Moniker(); FolderName = plugin.Moniker(); _isValid = isValid ?? (v => true); }
private static void DownloadPluginSnapshot(IConsoleLineHandler writer, string downloadLocation, ElasticsearchPlugin plugin, ElasticVersion v) { if (File.Exists(downloadLocation)) { return; } var artifact = v.Artifact(Product.ElasticsearchPlugin(plugin)); var downloadUrl = artifact.DownloadUrl; writer?.WriteDiagnostic( $"{{{nameof(DownloadPluginSnapshot)}}} downloading [{plugin.SubProductName}] from {{{downloadUrl}}}"); try { DownloadFile(downloadUrl, downloadLocation); writer?.WriteDiagnostic( $"{{{nameof(DownloadPluginSnapshot)}}} downloaded [{plugin.SubProductName}] to {{{downloadLocation}}}"); } catch (Exception) { writer?.WriteDiagnostic( $"{{{nameof(DownloadPluginSnapshot)}}} download failed! [{plugin.SubProductName}] from {{{downloadUrl}}}"); throw; } }
private static void CopyConfigDirectoryToHomeCacheConfigDirectory( IEphemeralCluster <EphemeralClusterConfiguration> cluster, ElasticsearchPlugin plugin) { if (plugin.SubProductName == "x-pack") { return; } if (!cluster.ClusterConfiguration.CacheEsHomeInstallation) { return; } var fs = cluster.FileSystem; var cachedEsHomeFolder = Path.Combine(fs.LocalFolder, cluster.GetCacheFolderName()); var configTarget = Path.Combine(cachedEsHomeFolder, "config"); var configPluginPath = Path.Combine(fs.ConfigPath, plugin.SubProductName); var configPluginPathCached = Path.Combine(configTarget, plugin.SubProductName); if (!Directory.Exists(configPluginPath) || Directory.Exists(configPluginPathCached)) { return; } Directory.CreateDirectory(configPluginPathCached); CopyFolder(configPluginPath, configPluginPathCached); }
private string DownloadSnapshotIfNeeded(NodeFileSystem fileSystem, ElasticsearchPlugin plugin, ElasticsearchVersion v) { var downloadLocation = Path.Combine(fileSystem.LocalFolder, plugin.SnapshotZip(v)); DownloadPluginSnapshot(downloadLocation, plugin, v); //transform downloadLocation to file uri and use that to install from return(new Uri(downloadLocation).AbsoluteUri); }
private static bool AlreadyInstalled(ElasticsearchPlugin plugin, NodeFileSystem fileSystem) { var folder = plugin.Moniker; var pluginFolder = Path.Combine(fileSystem.ElasticsearchHome, "plugins", folder); // assume plugin already installed return(Directory.Exists(pluginFolder)); }
private static string UseHttpPluginLocation(IConsoleLineHandler writer, INodeFileSystem fileSystem, ElasticsearchPlugin plugin, ElasticVersion v) { var downloadLocation = Path.Combine(fileSystem.LocalFolder, $"{plugin.SubProductName}-{v}.zip"); DownloadPluginSnapshot(writer, downloadLocation, plugin, v); //transform downloadLocation to file uri and use that to install from return(new Uri(new Uri("file://"), downloadLocation).AbsoluteUri); }
public static string Moniker(this ElasticsearchPlugin plugin) { var info = typeof(ElasticsearchPlugin).GetField(plugin.ToString()); var da = info.GetCustomAttribute <MonikerAttribute>(); if (da == null) { throw new InvalidOperationException($"{plugin} plugin must have a {nameof(MonikerAttribute)}"); } return(da.Moniker); }
public ElasticsearchPluginConfiguration( ElasticsearchPlugin plugin, Func <ElasticsearchVersion, bool> isValid, Func <ElasticsearchVersion, string> installParameter) { Plugin = plugin; Moniker = plugin.Moniker(); FolderName = plugin.Moniker(); _installParameter = installParameter ?? (v => Moniker); _isValid = isValid ?? (v => true); }
/// <summary> /// Defines the entry point of the application. /// </summary> /// <param name="args">Command line arguments</param> private static void Main(string[] args) { // parse command line arguments foreach (string sCmd in args) { string[] parts = sCmd.Split('='); if (parts[0].ToUpperInvariant() == "SERVER") { serverAddress = parts[1]; } } using (var plugin = new ElasticsearchPlugin()) { plugin.Connect(serverAddress, serverPort); plugin.WaitforShutDownOrDisconnect(); } }
private static void DownloadPluginSnapshot(string downloadLocation, ElasticsearchPlugin plugin, ElasticsearchVersion v) { if (File.Exists(downloadLocation)) { return; } var downloadUrl = plugin.SnapshotDownloadUrl(v); Console.WriteLine($"Download plugin snapshot {plugin.Moniker}: {downloadUrl}"); try { DownloadFile(downloadUrl, downloadLocation); Console.WriteLine($"Downloaded plugin snapshot {plugin.Moniker}"); } catch (Exception e) { Console.WriteLine($"Failed downloading plugin snapshot {plugin.Moniker}, {e.Message}"); } }
private static void DownloadPluginSnapshot(IConsoleLineWriter writer, string downloadLocation, ElasticsearchPlugin plugin, ElasticsearchVersion v) { if (File.Exists(downloadLocation)) { return; } var downloadUrl = plugin.DownloadUrl(v); writer?.WriteDiagnostic($"{{{nameof(DownloadPluginSnapshot)}}} downloading [{plugin.FolderName}] from {{{downloadUrl}}}"); try { DownloadFile(downloadUrl, downloadLocation); writer?.WriteDiagnostic($"{{{nameof(DownloadPluginSnapshot)}}} downloaded [{plugin.FolderName}] to {{{downloadLocation}}}"); } catch (Exception) { writer?.WriteDiagnostic($"{{{nameof(DownloadPluginSnapshot)}}} download failed! [{plugin.FolderName}] from {{{downloadUrl}}}"); throw; } }
public ElasticsearchPluginConfiguration( ElasticsearchPlugin plugin, Func <ElasticsearchVersion, bool> isValid) : this(plugin, isValid, null) { }
public ElasticsearchPluginConfiguration(ElasticsearchPlugin plugin) : this(plugin, null, null) { }
/// <summary> /// Initializes a new instance of the <see cref="ConfigPage" /> class. /// </summary> /// <param name="HS">The hs.</param> /// <param name="pluginInstance">The plugin instance.</param> public ConfigPage(IHSApplication HS, ElasticsearchPlugin pluginInstance) : base(HS, pluginInstance.Config, pageName) { this.pluginInstance = pluginInstance; }