当前位置: 首页>>代码示例>>C#>>正文


C# AbstractConnection.Uri方法代码示例

本文整理汇总了C#中AbstractConnection.Uri方法的典型用法代码示例。如果您正苦于以下问题:C# AbstractConnection.Uri方法的具体用法?C# AbstractConnection.Uri怎么用?C# AbstractConnection.Uri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AbstractConnection的用法示例。


在下文中一共展示了AbstractConnection.Uri方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateNest

        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
            );
        }
开发者ID:modulexcite,项目名称:Transformalize,代码行数:17,代码来源:ElasticSearchClientFactory.cs

示例2: Create

        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
            );
        }
开发者ID:modulexcite,项目名称:Transformalize,代码行数:17,代码来源:ElasticSearchClientFactory.cs

示例3: Check

        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;
            }
        }
开发者ID:modulexcite,项目名称:Transformalize,代码行数:18,代码来源:SolrConnectionChecker.cs

示例4: Check

        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;
        }
开发者ID:modulexcite,项目名称:Transformalize,代码行数:22,代码来源:ElasticSearchConnectionChecker.cs


注:本文中的AbstractConnection.Uri方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。