示例#1
0
        public NodeFileSystem(ElasticsearchVersion version, string clusterName, string tempFolderName = "ElasticsearchRunner")
        {
            this._version        = version;
            this._clusterName    = clusterName;
            this._tempFolderName = tempFolderName;
            var appData = GetApplicationDataDirectory();

            this.LocalFolder       = Path.Combine(appData, tempFolderName, this._version.FullyQualifiedVersion);
            this.ElasticsearchHome = Path.Combine(this.LocalFolder, this._version.FolderInZip);
        }
        public NodeConfiguration(ElasticsearchVersion version, string clusterName, string nodeName, int desiredPort = 9200)
        {
            this._clusterName = clusterName;
            this._nodeName    = nodeName;
            this.FileSystem   = new NodeFileSystem(version, this.ClusterName);

            var v = version;

            this.ElasticsearchVersion = v;
            this.DesiredPort          = desiredPort;

            var attr             = v.Major >= 5 ? "attr." : "";
            var indexedOrStored  = v > new ElasticsearchVersion("5.0.0-alpha1") ? "stored" : "indexed";
            var shieldOrSecurity = v > new ElasticsearchVersion("5.0.0-alpha1") ? "xpack.security" : "shield";
            var es         = v > new ElasticsearchVersion("5.0.0-alpha2") ? "" : "es.";
            var b          = this.XPackEnabled.ToString().ToLowerInvariant();
            var sslEnabled = this.EnableSsl.ToString().ToLowerInvariant();

            this.ElasticsearchArguments = new List <string>
            {
                $"{es}cluster.name={this.ClusterName}",
                $"{es}node.name={this.NodeName}",
                $"{es}path.repo={this.FileSystem.RepositoryPath}",
                $"{es}path.data={this.FileSystem.DataPath}",
                $"{es}script.inline=true",
                $"{es}script.max_compilations_per_minute=10000",
                $"{es}script.{indexedOrStored}=true",
                $"{es}node.{attr}testingcluster=true",
                $"{es}node.{attr}gateway=true",
            };

            if (this.XPackEnabled)
            {
                this.ElasticsearchArguments.AddRange(new List <string>
                {
                    $"{es}{shieldOrSecurity}.enabled={b}",
                    $"{es}{shieldOrSecurity}.http.ssl.enabled={sslEnabled}",
                    $"{es}{shieldOrSecurity}.authc.realms.pki1.enabled={sslEnabled}",
                });
            }
            if (v >= new ElasticsearchVersion("5.4.0"))
            {
                this.ElasticsearchArguments.Add($"{es}search.remote.connect=true");
            }
        }
 public NodeConfiguration(ElasticsearchVersion version, int desiredPort = 9200)
     : this(version, null, null, desiredPort)
 {
 }