當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。