public JavaManager(IElasticsearchServiceSettings settings )
     : base(settings,settings.JavaInstaller)
 {
     if (!string.IsNullOrWhiteSpace(settings.JavaDownloadType) && settings.JavaDownloadType == "storage")
     {
         _installer = new StorageArtifact(settings.JavaDownloadURL, settings.JavaInstaller, settings.StorageAccount);
     }
     else
     {
         _installer = new WebArtifact(settings.JavaDownloadURL, settings.JavaInstaller);
     }
 }
 public JavaManager(IElasticsearchServiceSettings settings)
     : base(settings, settings.JavaInstaller)
 {
     if (!string.IsNullOrWhiteSpace(settings.JavaDownloadType) && settings.JavaDownloadType == "storage")
     {
         _installer = new StorageArtifact(settings.JavaDownloadURL, settings.JavaInstaller, settings.StorageAccount);
     }
     else
     {
         _installer = new WebArtifact(settings.JavaDownloadURL, settings.JavaInstaller);
     }
 }
        public ElasticsearchManager(IElasticsearchServiceSettings settings, string dataPath, string bridgeName)
            : base(settings, settings.ElasticsearchInstaller)
        {
            _InstallRoot    = settings.ElasticsearchDirectory;
            _DataPath       = dataPath;
            _BridgePipeName = bridgeName;

            //Maybe there is a less noisy way to do this?
            if (!string.IsNullOrWhiteSpace(settings.ElasticsearchDownloadType) && settings.ElasticsearchDownloadType == "storage")
            {
                _installer = new StorageArtifact(settings.ElasticsearchDownloadURL, settings.ElasticsearchInstaller, settings.StorageAccount);
            }
            else
            {
                _installer = new WebArtifact(settings.ElasticsearchDownloadURL, settings.ElasticsearchInstaller);
            }

            _PackagePluginPath     = Path.Combine(settings.RootDirectory, "plugins");
            _TemplateConfigFile    = Path.Combine(settings.RootDirectory, "config", ELASTICSEARCH_CONFIG_FILE);
            _TemplateLogConfigFile = Path.Combine(settings.RootDirectory, "config", ELASTICSEARCH_LOG_CONFIG_FILE);

            _ElasticRoot = Path.Combine(_InstallRoot, Path.GetFileNameWithoutExtension(_installer.Name));
            _PluginRoot  = Path.Combine(_ElasticRoot, ELASTICSEARCH_PLUGIN_DIR);
        }
        public ElasticsearchManager(IElasticsearchServiceSettings settings, string dataPath, string bridgeName)
            : base(settings,settings.ElasticsearchInstaller)
        {
            _InstallRoot = settings.ElasticsearchDirectory;
            _DataPath = dataPath;
            _BridgePipeName = bridgeName;

            //Maybe there is a less noisy way to do this?
            if (!string.IsNullOrWhiteSpace(settings.ElasticsearchDownloadType) && settings.ElasticsearchDownloadType == "storage")
            {
                _installer = new StorageArtifact(settings.ElasticsearchDownloadURL, settings.ElasticsearchInstaller, settings.StorageAccount);
            }
            else
            {
                _installer = new WebArtifact(settings.ElasticsearchDownloadURL, settings.ElasticsearchInstaller);
            }

            _PackagePluginPath = Path.Combine(settings.RootDirectory,"plugins");
            _TemplateConfigFile = Path.Combine(settings.RootDirectory,"config",ELASTICSEARCH_CONFIG_FILE);
            _TemplateLogConfigFile = Path.Combine(settings.RootDirectory, "config", ELASTICSEARCH_LOG_CONFIG_FILE);

            _ElasticRoot = Path.Combine(_InstallRoot, Path.GetFileNameWithoutExtension(_installer.Name));
            _PluginRoot = Path.Combine(_ElasticRoot, ELASTICSEARCH_PLUGIN_DIR);
        }
Beispiel #5
0
        public override bool OnStart()
        {
            // Not sure what this should be. Hopefully storage over smb doesn't open a million connections
            ServicePointManager.DefaultConnectionLimit = 12;

            #region Load Config Settings
            nodeName = RoleEnvironment.CurrentRoleInstance.Id;
            string UseElasticLocalDataFolder    = CloudConfigurationManager.GetSetting("UseElasticLocalDataFolder");
            string javaInstaller                = CloudConfigurationManager.GetSetting("JavaInstallerName");
            string javaDownloadURL              = CloudConfigurationManager.GetSetting("JavaDownloadURL");
            string elasticsearchZip             = CloudConfigurationManager.GetSetting("ElasticsearchZip");
            string elasticsearchDownloadURL     = CloudConfigurationManager.GetSetting("ElasticsearchDownloadURL");
            string elasticsearchPluginContainer = CloudConfigurationManager.GetSetting("ElasticsearchPluginContainer");
            string shareName        = CloudConfigurationManager.GetSetting("ShareName");  //root path for es data
            string shareDrive       = CloudConfigurationManager.GetSetting("ShareDrive"); //Drive letter to map azure share
            string endpointName     = CloudConfigurationManager.GetSetting("EndpointName");
            string archiveRoot      = RoleEnvironment.GetLocalResource("ArchiveRoot").RootPath;
            string logRoot          = RoleEnvironment.GetLocalResource("LogRoot").RootPath;
            string elasticDataRoot  = RoleEnvironment.GetLocalResource("ElasticDataRoot").RootPath;
            string elasticRoot      = RoleEnvironment.GetLocalResource("ElasticRoot").RootPath;
            string emulatorDataRoot = RoleEnvironment.GetLocalResource("EmulatorDataRoot").RootPath; // we need this cause we can't emulate shares
            string roleRoot         = Environment.GetEnvironmentVariable("ROLEROOT");
            string tempPath         = RoleEnvironment.GetLocalResource("CustomTempRoot").RootPath;   //Standard temp folder is too small

            /**
             * Issue #1.  In azure the role root is just a drive letter. Unfortunately, System.IO doesn't add needed slash
             *  so Path.Combine("E:","path\to\file") yields E:path\to\file
             *  Still hoping there is a .net api that I an use to avoid the code below.
             */
            if (!roleRoot.EndsWith(@"\"))
            {
                roleRoot += @"\";
            }

            #endregion

            #region Configure Java  manager
            //Are we downloading java from storage or regular url?
            string      javaDownloadType = CloudConfigurationManager.GetSetting("JavaDownloadType");
            WebArtifact javaArtifact;

            if (!string.IsNullOrWhiteSpace(javaDownloadType) && javaDownloadType == "storage")
            {
                javaArtifact = new StorageArtifact(javaDownloadURL, javaInstaller, storage);
            }
            else
            {
                javaArtifact = new WebArtifact(javaDownloadURL, javaInstaller);
            }

            javaManager = new JavaManager(javaArtifact, archiveRoot, logRoot); //Java installer

            #endregion

            #region Configure Elasticsearch manager
            //Are we downloading elasticsearch from storage or regular url?
            string      elasticsearchDownloadType = CloudConfigurationManager.GetSetting("ElasticsearchDownloadType");
            WebArtifact elasticsearchArtifact;

            if (!string.IsNullOrWhiteSpace(elasticsearchDownloadType) && elasticsearchDownloadType == "storage")
            {
                elasticsearchArtifact = new StorageArtifact(elasticsearchDownloadURL, elasticsearchZip, storage);
            }
            else
            {
                elasticsearchArtifact = new WebArtifact(elasticsearchDownloadURL, elasticsearchZip);
            }

            bridge = new PipesRuntimeBridge(endpointName); //Discovery helper

            if (UseElasticLocalDataFolder.ToLower() != "true")
            {
                //Azure file is not available in emulator
                if (!RoleEnvironment.IsEmulated)
                {
                    // Mount a drive for a CloudFileShare.
                    Trace.WriteLine("Configuring file Share");
                    var share = storage.CreateCloudFileClient()
                                .GetShareReference(shareName);
                    share.CreateIfNotExists();

                    Trace.WriteLine("Mapping Share to " + shareDrive);
                    share.Mount(shareDrive);
                }
                else
                {
                    shareDrive = emulatorDataRoot;
                }
            }
            else
            {
                shareDrive = elasticDataRoot;
            }

            var runtimeConfig = new ElasticsearchRuntimeConfig
            {
                DataPath              = shareDrive,
                LogPath               = logRoot,
                TempPath              = tempPath,
                NodeName              = nodeName,
                BridgePipeName        = bridge.PipeName,
                PackagePluginPath     = Path.Combine(roleRoot, "approot", "plugins"),
                TemplateConfigFile    = Path.Combine(roleRoot, "approot", "config", ElasticsearchManager.ELASTICSEARCH_CONFIG_FILE),
                TemplateLogConfigFile = Path.Combine(roleRoot, "approot", "config", ElasticsearchManager.ELASTICSEARCH_LOG_CONFIG_FILE)
            };

            elasticsearchManager = new ElasticsearchManager(runtimeConfig, elasticsearchArtifact, archiveRoot, elasticRoot, logRoot);

            if (!string.IsNullOrWhiteSpace(elasticsearchPluginContainer))
            {
                elasticsearchManager.AddPluginSource(elasticsearchPluginContainer, storage);
            }
            #endregion



            bool result = base.OnStart();

            Trace.TraceInformation("ElasticsearchRole has been started");

            return(result);
        }