本文整理匯總了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;
}