コード例 #1
0
        public void TestFailQuery()
        {
            var connection = new ElasticSearchConnection();

            connection.ConnectionString = ConnectionString;
            connection.Open();

            var command = connection.CreateCommand();

            command.CommandText = "SELECT DISTINCT real_ip FROM \"logstash-stats-apps-*\" WHERE \"@timestamp\" > NOW() - INTERVAL 7 DAYS";

            Trace.WriteLine("Results:");
            int linesRead = 0;

            Assert.ThrowsException <DataException>(() =>
            {
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var boolField = reader.IsDBNull(0) ? "null" : reader.GetBoolean(0).ToString();
                        var dtField   = reader.IsDBNull(1) ? "null" : reader.GetDateTime(1).ToString();
                        var longField = reader.IsDBNull(2) ? "null" : reader.GetInt64(2).ToString();

                        Trace.WriteLine($"{boolField}, {dtField}, {longField}");
                        linesRead++;
                    }
                }
            });
        }
コード例 #2
0
        public void TestFieldsMapping()
        {
            var connection = new ElasticSearchConnection();

            connection.ConnectionString = ConnectionString;
            connection.Open();

            var command = connection.CreateCommand();

            command.CommandText = "SELECT is_ott, \"@timestamp\" ts, dev_id FROM \"logstash-stats-apps-*\" ORDER BY \"@timestamp\" DESC LIMIT 10";

            Trace.WriteLine("Results:");
            int linesRead = 0;

            using (var reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    var boolField = reader.IsDBNull(0) ? "null" : reader.GetBoolean(0).ToString();
                    var dtField   = reader.IsDBNull(1) ? "null" : reader.GetDateTime(1).ToString();
                    var longField = reader.IsDBNull(2) ? "null" : reader.GetInt64(2).ToString();

                    Trace.WriteLine($"{boolField}, {dtField}, {longField}");
                    linesRead++;
                }
            }

            Assert.AreEqual(10, linesRead);
        }
コード例 #3
0
        public void TestReader()
        {
            var connection = new ElasticSearchConnection();

            connection.ConnectionString = ConnectionString;
            connection.Open();

            var command = connection.CreateCommand();

            command.CommandText = "SELECT action, mac FROM \"logstash-stats-apps-*\" LIMIT 10";

            Trace.WriteLine("Results:");
            int linesRead = 0;

            using (var reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    Trace.WriteLine($"{reader.GetString(0)}, {reader.GetString(1)}");
                    linesRead++;
                }
            }

            Assert.AreEqual(10, linesRead);
        }
コード例 #4
0
        public void TestBasicConnection()
        {
            var connection = new ElasticSearchConnection();

            connection.ConnectionString = ConnectionString;
            connection.Open();
            Assert.IsTrue(connection.State == System.Data.ConnectionState.Open);
        }
コード例 #5
0
        public void TestCase()
        {
            var connection = new ElasticSearchConnection();
            var indexer    = new Indexer(connection);

            indexer.IndexIfc("Resources/02_BIMcollab_Example_STR.ifc");

//			var searchResponse = connection.client.Search<string>("bim_projects", "project", new
//				{
//					query = new
//					{
//						query_string = new
//						{
//							query = "Revit"
//						}
//					}
//				});
//
//			var successful = searchResponse.Success;
//			var responseJson = searchResponse.Body;
        }
コード例 #6
0
        public void TestPaginatedQuery()
        {
            var connection = new ElasticSearchConnection();

            connection.ConnectionString = ConnectionString;
            connection.Open();

            var command = connection.CreateCommand();

            command.CommandText = "SELECT real_ip FROM \"logstash-stats-apps-*\" WHERE \"@timestamp\" > NOW() - INTERVAL 7 DAYS GROUP BY real_ip";

            int linesRead = 0;

            using (var reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    linesRead++;
                }
            }
            Trace.WriteLine($"Lines read: {linesRead}");
            Assert.IsTrue(linesRead > 1000);
        }
コード例 #7
0
 public ElasticSearchHolderDataProvider(string elasticSearchUri, string elasticSearchIndex)
 {
     _client = ElasticSearchConnection.GetElasticClient(elasticSearchUri, elasticSearchIndex);
 }
コード例 #8
0
 public CreateFactoryWithNewES()
 {
     _connectionToEs = new ElasticSearchConnection();
     _indexName      = ConfigurationManager.AppSettings["ElasticSearchIndexName"];
     _typeName       = ConfigurationManager.AppSettings["ElasticSearchTypeName"];
 }
コード例 #9
0
        /// <summary>
        /// Invokes events will be occurred during the service start.
        /// </summary>
        protected override void ServiceStart()
        {
            if (!this.firstInit)
            {
                return;
            }

            this.firstInit = false;

            if (this.Configuration != null)
            {
                Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(this.Configuration.Culture);
            }

            this.Log.Write(LogLevel.Info, "Tasslehoff 0.9.7  (c) 2008-2016 Eser Ozvataf ([email protected]). All rights reserved.");
            this.Log.Write(LogLevel.Info, "This program is free software under the terms of the GPL v3 or later.");
            this.Log.Write(LogLevel.Info, string.Empty);

            if (this.Configuration != null)
            {
                if (!string.IsNullOrEmpty(this.Configuration.DatabaseConnectionString))
                {
                    this.DatabaseManager.Connections.Add(
                        this.DatabaseManager.DefaultDatabaseKey,
                        new DatabaseManagerConnection()
                        {
                            ProviderName = this.Configuration.DatabaseProviderName,
                            ConnectionString = this.Configuration.DatabaseConnectionString,
                        }
                    );
                }

                // search for extensions
                if (this.Configuration.ExtensionPaths != null)
                {
                    this.ExtensionFinder.SearchStructured(this.Configuration.ExtensionPaths);
                }
            }

            this.Log.Write(LogLevel.Info, string.Format("{0} extensions found:", this.ExtensionFinder.Assemblies.Count));
            foreach (string assemblyName in this.ExtensionFinder.Assemblies.Keys)
            {
                this.Log.Write(LogLevel.Info, string.Format("- {0}", assemblyName));
            }
            this.Log.Write(LogLevel.Info, string.Empty);

            if (this.Configuration != null)
            {
                if (!string.IsNullOrEmpty(this.Configuration.RabbitMQAddress))
                {
                    IQueueManager rabbitMq = new RabbitMQConnection(this.Configuration.RabbitMQAddress);
                    this.AddChild(rabbitMq);
                }

                if (!string.IsNullOrEmpty(this.Configuration.IronMQProjectId))
                {
                    IQueueManager ironMq = new IronMQConnection(this.Configuration.IronMQProjectId, this.Configuration.IronMQToken);
                    this.AddChild(ironMq);
                }

                if (!string.IsNullOrEmpty(this.Configuration.MemcachedAddress))
                {
                    ICacheManager memcached = new MemcachedConnection(this.Configuration.MemcachedAddress);
                    this.AddChild(memcached);
                }

                if (!string.IsNullOrEmpty(this.Configuration.RedisAddress))
                {
                    ICacheManager redis = new RedisConnection(this.Configuration.RedisAddress);
                    this.AddChild(redis);
                }

                if (!string.IsNullOrEmpty(this.Configuration.ElasticSearchAddress))
                {
                    ICacheManager elasticSearch = new ElasticSearchConnection(new Uri(this.Configuration.ElasticSearchAddress));
                    this.AddChild(elasticSearch);
                }
            }
        }