本文整理汇总了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
);
}
示例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
);
}
示例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;
}
}
示例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;
}