public bool Check(AbstractConnection connection)
        {
            var hashCode = connection.Uri().GetHashCode();

            if (Checks.ContainsKey(hashCode))
            {
                return(Checks[hashCode]);
            }

            var client = new ElasticSearchClientFactory().Create(connection, null);

            try {
                var response = client.Client.Ping();
                if (response.HttpStatusCode != null && response.HttpStatusCode == 200)
                {
                    _logger.Debug("Successful ping of {0}.", connection.Name);
                    return(true);
                }
                _logger.Warn("Failed to connect to {0}, {1}:{2}. {3}", connection.Name, connection.Server, connection.Port, response.ServerError.Error);
            } catch (Exception e) {
                _logger.Warn("Failed to connect to {0}, {1}:{2}. {3}", connection.Name, connection.Server, connection.Port, e.Message);
                return(false);
            }

            return(false);
        }
        public ElasticSearchNetClient Create(AbstractConnection connection, Entity entity) {
            var entityExists = entity != null;
            var processName = entityExists ? entity.ProcessName : string.Empty;
            var entityName = entityExists ? entity.Name : string.Empty;
            var alias = entityExists ? entity.Alias.ToLower() : string.Empty;

            connection.Logger.EntityDebug(entityName, "Preparing Elasticsearch.NET client for {0}", connection.Uri());
            var settings = new ConnectionConfiguration(
                new SingleNodeConnectionPool(connection.Uri())
            );

            return new ElasticSearchNetClient(
                new ElasticsearchClient(settings),
                processName.ToLower(),
                alias
            );
        }
        public NestClient CreateNest(AbstractConnection connection, Entity entity) {

            var entityExists = entity != null;
            var processName = entityExists ? entity.ProcessName : string.Empty;
            var entityName = entityExists ? entity.Name : string.Empty;
            var alias = entityExists ? entity.Alias.ToLower() : string.Empty;

            connection.Logger.EntityDebug(entityName, "Preparing NEST client for {0}", connection.Uri());
            var pool = new SingleNodeConnectionPool(connection.Uri());
            var settings = new ConnectionSettings(pool).SetTimeout(System.Threading.Timeout.Infinite);

            return new NestClient(
                new ElasticClient(settings),
                processName.ToLower(),
                alias
            );
        }
Exemple #4
0
        public NestClient CreateNest(AbstractConnection connection, Entity entity)
        {
            var entityExists = entity != null;
            var processName  = entityExists ? entity.ProcessName : string.Empty;
            var entityName   = entityExists ? entity.Name : string.Empty;
            var alias        = entityExists ? entity.Alias.ToLower() : string.Empty;

            connection.Logger.EntityDebug(entityName, "Preparing NEST client for {0}", connection.Uri());
            var pool     = new SingleNodeConnectionPool(connection.Uri());
            var settings = new ConnectionSettings(pool).SetTimeout(System.Threading.Timeout.Infinite);

            return(new NestClient(
                       new ElasticClient(settings),
                       processName.ToLower(),
                       alias
                       ));
        }
        public bool Check(AbstractConnection connection) {

            var solrConnection = (SolrConnection)connection;

            var hashCode = connection.Uri().GetHashCode();
            if (Checks.ContainsKey(hashCode)) {
                return Checks[hashCode];
            }

            try {
                new WebClient().DownloadString(solrConnection.GetPingUrl());
                Checks[hashCode] = true;
                return true;
            } catch (Exception e) {
                _logger.Warn("Failed to connect to {0}. Pinging {1} resulted in: {3}", connection.Name, solrConnection.GetPingUrl(), e.Message);
                return false;
            }
        }
Exemple #6
0
        public ElasticSearchNetClient Create(AbstractConnection connection, Entity entity)
        {
            var entityExists = entity != null;
            var processName  = entityExists ? entity.ProcessName : string.Empty;
            var entityName   = entityExists ? entity.Name : string.Empty;
            var alias        = entityExists ? entity.Alias.ToLower() : string.Empty;

            connection.Logger.EntityDebug(entityName, "Preparing Elasticsearch.NET client for {0}", connection.Uri());
            var settings = new ConnectionConfiguration(
                new SingleNodeConnectionPool(connection.Uri())
                );

            return(new ElasticSearchNetClient(
                       new ElasticsearchClient(settings),
                       processName.ToLower(),
                       alias
                       ));
        }
Exemple #7
0
        public bool Check(AbstractConnection connection)
        {
            var solrConnection = (SolrConnection)connection;

            var hashCode = connection.Uri().GetHashCode();

            if (Checks.ContainsKey(hashCode))
            {
                return(Checks[hashCode]);
            }

            try {
                new WebClient().DownloadString(solrConnection.GetPingUrl());
                Checks[hashCode] = true;
                return(true);
            } catch (Exception e) {
                _logger.Warn("Failed to connect to {0}. Pinging {1} resulted in: {3}", connection.Name, solrConnection.GetPingUrl(), e.Message);
                return(false);
            }
        }
        public bool Check(AbstractConnection connection) {

            var hashCode = connection.Uri().GetHashCode();
            if (Checks.ContainsKey(hashCode)) {
                return Checks[hashCode];
            }

            var client = new ElasticSearchClientFactory().Create(connection, null);
            try {
                var response = client.Client.Ping();
                if (response.HttpStatusCode != null && response.HttpStatusCode == 200) {
                    _logger.Debug("Successful ping of {0}.", connection.Name);
                    return true;
                }
                _logger.Warn("Failed to connect to {0}, {1}:{2}. {3}", connection.Name, connection.Server, connection.Port, response.ServerError.Error);
            } catch (Exception e) {
                _logger.Warn("Failed to connect to {0}, {1}:{2}. {3}", connection.Name, connection.Server, connection.Port, e.Message);
                return false;
            }

            return false;
        }