Beispiel #1
0
        private static void ManualConfigRun()
        {
            ElasticVersion version = "latest";

            var plugins =
                new ElasticsearchPlugins(ElasticsearchPlugin.IngestGeoIp, ElasticsearchPlugin.IngestAttachment);
            var features = Security | XPack | SSL;
            var config   = new EphemeralClusterConfiguration(version, features, plugins, numberOfNodes: 1)
            {
                HttpFiddlerAware = true,
                ShowElasticsearchOutputAfterStarted = true,
                CacheEsHomeInstallation             = false,
                TrialMode = XPackTrialMode.Trial,
                NoCleanupAfterNodeStopped = false,
            };

            using (var cluster = new EphemeralCluster(config))
            {
                cluster.Start();

                var nodes          = cluster.NodesUris();
                var connectionPool = new StaticConnectionPool(nodes);
                var settings       = new ConnectionSettings(connectionPool).EnableDebugMode();
                if (config.EnableSecurity)
                {
                    settings = settings.BasicAuthentication(ClusterAuthentication.Admin.Username,
                                                            ClusterAuthentication.Admin.Password);
                }
                if (config.EnableSsl)
                {
                    settings = settings.ServerCertificateValidationCallback(CertificateValidations.AllowAll);
                }

                var client = new ElasticClient(settings);

                var clusterConfiguration = new Dictionary <string, object>()
                {
                    { "cluster.routing.use_adaptive_replica_selection", true },
                    { "cluster.remote.remote-cluster.seeds", "127.0.0.1:9300" }
                };


                var putSettingsResponse = client.ClusterPutSettings(new ClusterPutSettingsRequest
                {
                    Transient = clusterConfiguration
                });


                Console.Write(client.XPackInfo().DebugInformation);
                Console.WriteLine("Press any key to exit");
                Console.ReadKey();
                Console.WriteLine("Exitting..");
            }

            Console.WriteLine("Done!");
        }
Beispiel #2
0
 private static List <Func <object> > ClusterCommands(ElasticClient elastic)
 {
     return(new List <Func <object> >
     {
         () => elastic.ClusterAllocationExplain(new ClusterAllocationExplainRequest()),
         () => elastic.ClusterGetSettings(new ClusterGetSettingsRequest()),
         () => elastic.ClusterHealth(new ClusterHealthRequest()),
         () => elastic.ClusterPendingTasks(new ClusterPendingTasksRequest()),
         () => elastic.ClusterPutSettings(new ClusterPutSettingsRequest()),
         () => elastic.ClusterReroute(new ClusterRerouteRequest()),
         () => elastic.ClusterState(new ClusterStateRequest()),
         () => elastic.ClusterStats(new ClusterStatsRequest()),
     });
 }
Beispiel #3
0
        public void SetTransientLogLevel(TraceLevel traceLevel)
        {
            var response = _elasticClient.ClusterPutSettings(d => d.Transient(t => t.Add("org.elasticsearch.action", "Debug")));

            Console.WriteLine("{0} {1}", response.ApiCall.Uri, response.ToString());
        }