public Server(IOStrategy ioStrategy, IViewClient viewClient, IQueryClient queryClient, INodeAdapter nodeAdapter, ClientConfiguration clientConfiguration, ITypeTranscoder transcoder, IBucketConfig bucketConfig) { _ioStrategy = ioStrategy; _ioStrategy.ConnectionPool.Owner = this; _nodeAdapter = nodeAdapter; _clientConfiguration = clientConfiguration; _timingEnabled = _clientConfiguration.EnableOperationTiming; _typeTranscoder = transcoder; _bucketConfig = bucketConfig; //services that this node is responsible for IsMgmtNode = _nodeAdapter.MgmtApi > 0; IsDataNode = _nodeAdapter.KeyValue > 0; IsQueryNode = _nodeAdapter.N1QL > 0; IsIndexNode = _nodeAdapter.IndexAdmin > 0; IsViewNode = _nodeAdapter.Views > 0; //View and query clients ViewClient = viewClient; QueryClient = queryClient; //timer and node status _heartBeatTimer = new Timer(1000) { Enabled = false }; _heartBeatTimer.Elapsed += _heartBeatTimer_Elapsed; TakeOffline(_ioStrategy.ConnectionPool.InitializationFailed); }
public Server(IIOService ioService, INodeAdapter nodeAdapter, ITypeTranscoder transcoder, ConcurrentDictionary <string, QueryPlan> queryCache, ConfigContextBase context) : this(ioService, new ViewClient(new CouchbaseHttpClient(context) { Timeout = new TimeSpan(0, 0, 0, 0, context.ClientConfig.ViewRequestTimeout) }, new JsonDataMapper(context), context), new StreamingViewClient(new CouchbaseHttpClient(context) { Timeout = new TimeSpan(0, 0, 0, 0, context.ClientConfig.ViewRequestTimeout) }, new JsonDataMapper(context), context), new QueryClient(new CouchbaseHttpClient(context) { Timeout = new TimeSpan(0, 0, 0, 0, (int)context.ClientConfig.QueryRequestTimeout) }, new JsonDataMapper(context), queryCache, context), new StreamingQueryClient(new CouchbaseHttpClient(context) { Timeout = new TimeSpan(0, 0, 0, 0, (int)context.ClientConfig.QueryRequestTimeout) }, new JsonDataMapper(context), queryCache, context), new SearchClient(new CouchbaseHttpClient(context) { Timeout = new TimeSpan(0, 0, 0, 0, (int)context.ClientConfig.SearchRequestTimeout) }, new SearchDataMapper(), context), new AnalyticsClient(new CouchbaseHttpClient(context) { Timeout = new TimeSpan(0, 0, 0, 0, (int)context.ClientConfig.QueryRequestTimeout) }, new JsonDataMapper(context), context), nodeAdapter, transcoder, context) { }
internal static IIOService CreateIOService(INodeAdapter node) { var server = node.Hostname.Replace("8091", node.KeyValue.ToString(CultureInfo.InvariantCulture)); var connectionPool = new ConnectionPool<Connection>(new PoolConfiguration(), UriExtensions.GetEndPoint(server)); var ioService = new PooledIOService(connectionPool); return ioService; }
public Server(IIOService ioService, INodeAdapter nodeAdapter, ClientConfiguration clientConfiguration, IBucketConfig bucketConfig, ITypeTranscoder transcoder, ConcurrentDictionary <string, QueryPlan> queryCache) : this(ioService, new ViewClient(new CouchbaseHttpClient(clientConfiguration, bucketConfig) { Timeout = new TimeSpan(0, 0, 0, 0, clientConfiguration.ViewRequestTimeout) }, new JsonDataMapper(clientConfiguration), clientConfiguration), new StreamingViewClient(new CouchbaseHttpClient(clientConfiguration, bucketConfig) { Timeout = new TimeSpan(0, 0, 0, 0, clientConfiguration.ViewRequestTimeout) }, new JsonDataMapper(clientConfiguration), clientConfiguration), new QueryClient(new CouchbaseHttpClient(clientConfiguration, bucketConfig) { Timeout = new TimeSpan(0, 0, 0, 0, (int)clientConfiguration.QueryRequestTimeout) }, new JsonDataMapper(clientConfiguration), clientConfiguration, queryCache), new StreamingQueryClient(new CouchbaseHttpClient(clientConfiguration, bucketConfig) { Timeout = new TimeSpan(0, 0, 0, 0, (int)clientConfiguration.QueryRequestTimeout) }, new JsonDataMapper(clientConfiguration), clientConfiguration, queryCache), new SearchClient(new CouchbaseHttpClient(clientConfiguration, bucketConfig) { Timeout = new TimeSpan(0, 0, 0, 0, (int)clientConfiguration.SearchRequestTimeout) }, new SearchDataMapper(), clientConfiguration), new AnalyticsClient(new CouchbaseHttpClient(clientConfiguration, bucketConfig) { Timeout = new TimeSpan(0, 0, 0, 0, (int)clientConfiguration.QueryRequestTimeout) }, new JsonDataMapper(clientConfiguration), clientConfiguration), nodeAdapter, clientConfiguration, transcoder, bucketConfig) { }
public Server(IOStrategy ioStrategy, INodeAdapter nodeAdapter, ClientConfiguration clientConfiguration, IBucketConfig bucketConfig) : this(ioStrategy, new ViewClient(new HttpClient(), new JsonDataMapper(clientConfiguration), bucketConfig, clientConfiguration), new QueryClient(new HttpClient(), new JsonDataMapper(clientConfiguration), clientConfiguration), nodeAdapter, clientConfiguration) { }
public Server(IOStrategy ioStrategy, INodeAdapter nodeAdapter, ClientConfiguration clientConfiguration, IBucketConfig bucketConfig, ITypeTranscoder transcoder, ConcurrentDictionary <string, QueryPlan> queryCache) : this(ioStrategy, new ViewClient(new HttpClient(), new JsonDataMapper(clientConfiguration), bucketConfig, clientConfiguration), new QueryClient(new HttpClient(), new JsonDataMapper(clientConfiguration), clientConfiguration, queryCache), nodeAdapter, clientConfiguration, transcoder, bucketConfig) { }
internal static IOStrategy CreateIOStrategy(INodeAdapter node) { var server = node.Hostname.Replace("8091", node.KeyValue.ToString(CultureInfo.InvariantCulture)); var connectionPool = new ConnectionPool <Connection>(new PoolConfiguration(), UriExtensions.GetEndPoint(server)); var ioStrategy = new DefaultIOStrategy(connectionPool); return(ioStrategy); }
public Server(IIOService ioService, INodeAdapter nodeAdapter, ClientConfiguration clientConfiguration, IBucketConfig bucketConfig, ITypeTranscoder transcoder) : this(ioService, new ViewClient(new HttpClient(), new JsonDataMapper(clientConfiguration), bucketConfig, clientConfiguration), new QueryClient(new HttpClient(), new JsonDataMapper(clientConfiguration), bucketConfig, clientConfiguration), nodeAdapter, clientConfiguration, transcoder, bucketConfig) { }
public static string GetAnalyticsUri(INodeAdapter adapter, BucketConfiguration config) { var uri = string.Format(AnalyticsUriFormat, config.UseSsl ? Https : Http, adapter.Hostname, config.UseSsl ? adapter.AnalyticsSsl : adapter.Analytics); return(uri); }
public Server(IOStrategy ioStrategy, IViewClient viewClient, IQueryClient queryClient, INodeAdapter nodeAdapter, ClientConfiguration clientConfiguration) { _ioStrategy = ioStrategy; ViewClient = viewClient; QueryClient = queryClient; _nodeAdapter = nodeAdapter; _clientConfiguration = clientConfiguration; _timingEnabled = _clientConfiguration.EnableOperationTiming; }
public Server(IIOService ioService, IViewClient viewClient, IViewClient streamingViewClient, IQueryClient queryClient, IQueryClient streamingQueryClient, ISearchClient searchClient, IAnalyticsClient analyticsClient, INodeAdapter nodeAdapter, ClientConfiguration clientConfiguration, ITypeTranscoder transcoder, IBucketConfig bucketConfig) { if (ioService != null) { _ioService = ioService; _ioService.ConnectionPool.Owner = this; } _nodeAdapter = nodeAdapter; _clientConfiguration = clientConfiguration; _bucketConfiguration = clientConfiguration.BucketConfigs[bucketConfig.Name]; _timingEnabled = _clientConfiguration.EnableOperationTiming; _typeTranscoder = transcoder; _bucketConfig = bucketConfig; //services that this node is responsible for IsMgmtNode = _nodeAdapter.MgmtApi > 0; IsDataNode = _nodeAdapter.KeyValue > 0; IsQueryNode = _nodeAdapter.N1QL > 0; IsIndexNode = _nodeAdapter.IndexAdmin > 0; IsViewNode = _nodeAdapter.Views > 0; IsSearchNode = _nodeAdapter.IsSearchNode; IsAnalyticsNode = _nodeAdapter.IsAnalyticsNode; //View and query clients ViewClient = viewClient; _streamingViewClient = streamingViewClient; QueryClient = queryClient; SearchClient = searchClient; _streamingQueryClient = streamingQueryClient; AnalyticsClient = analyticsClient; CachedViewBaseUri = UrlUtil.GetViewBaseUri(_nodeAdapter, _bucketConfiguration); CachedQueryBaseUri = UrlUtil.GetN1QLBaseUri(_nodeAdapter, _bucketConfiguration); if (IsDataNode || IsQueryNode) { _lastIOErrorCheckedTime = DateTime.Now; //On initialization, data nodes are authenticated, so they can start in a down state. //If the node is down immediately start the timer, otherwise disable it. if (IsDataNode) { _isDown = _ioService.ConnectionPool.InitializationFailed; } Log.Info("Initialization {0} for node {1}", _isDown ? "failed" : "succeeded", EndPoint); //timer and node status _heartBeatTimer = new Timer(_heartBeatTimer_Elapsed, null, Timeout.Infinite, Timeout.Infinite); if (_isDown) { StartHeartbeatTimer(); } } }
// ReSharper disable once InconsistentNaming public static string GetN1QLBaseUriAsString(INodeAdapter adapter, BucketConfiguration config) { var uriAsString = string.Format(N1QLUriFormat, config.UseSsl ? Https : Http, adapter.Hostname, config.UseSsl ? adapter.N1QLSsl : adapter.N1QL); return uriAsString; }
// ReSharper disable once InconsistentNaming public static string GetN1QLBaseUriAsString(INodeAdapter adapter, BucketConfiguration config) { var uriAsString = string.Format(N1QLUriFormat, config.UseSsl ? Https : Http, GetHostName(adapter), config.UseSsl ? adapter.N1QLSsl : adapter.N1QL); return(uriAsString); }
public static string GetBaseUriAsString(INodeAdapter adapter, BucketConfiguration config) { var uriAsString = string.Format(BaseUriFormat, config.UseSsl ? Https : Http, adapter.Hostname, config.UseSsl ? adapter.MgmtApiSsl: adapter.MgmtApi); return(uriAsString); }
public static string GetSearchBaseUri(INodeAdapter adapter, BucketConfiguration config) { var uriAsString = string.Format(BaseUriFormat, config.UseSsl ? Https : Http, adapter.Hostname, config.UseSsl ? adapter.FtsSsl : adapter.Fts); return uriAsString; }
public static string GetViewBaseUriAsString(INodeAdapter adapter, BucketConfiguration config) { var uriAsString = string.Format(ViewUriFormat, config.UseSsl ? Https : Http, adapter.Hostname, config.UseSsl ? adapter.ViewsSsl : adapter.Views, config.BucketName); return uriAsString; }
public static string GetViewBaseUriAsString(INodeAdapter adapter, BucketConfiguration config) { var uriAsString = string.Format(ViewUriFormat, config.UseSsl ? Https : Http, adapter.Hostname, config.UseSsl ? adapter.ViewsSsl : adapter.Views, config.BucketName); return(uriAsString); }
public static string GetSearchBaseUri(INodeAdapter adapter, BucketConfiguration config) { var uriAsString = string.Format(BaseUriFormat, config.UseSsl ? Https : Http, GetHostName(adapter), config.UseSsl ? adapter.FtsSsl : adapter.Fts); return(uriAsString); }
public Server(IOStrategy ioStrategy, IViewClient viewClient, IQueryClient queryClient, INodeAdapter nodeAdapter, ClientConfiguration clientConfiguration, ITypeTranscoder transcoder, IBucketConfig bucketConfig) { if (ioStrategy != null) { _ioStrategy = ioStrategy; _ioStrategy.ConnectionPool.Owner = this; } _nodeAdapter = nodeAdapter; _clientConfiguration = clientConfiguration; _bucketConfiguration = clientConfiguration.BucketConfigs[bucketConfig.Name]; _timingEnabled = _clientConfiguration.EnableOperationTiming; _typeTranscoder = transcoder; _bucketConfig = bucketConfig; //services that this node is responsible for IsMgmtNode = _nodeAdapter.MgmtApi > 0; IsDataNode = _nodeAdapter.KeyValue > 0; IsQueryNode = _nodeAdapter.N1QL > 0; IsIndexNode = _nodeAdapter.IndexAdmin > 0; IsViewNode = _nodeAdapter.Views > 0; //View and query clients ViewClient = viewClient; QueryClient = queryClient; CachedViewBaseUri = UrlUtil.GetViewBaseUri(_nodeAdapter, _bucketConfiguration); CachedQueryBaseUri = UrlUtil.GetN1QLBaseUri(_nodeAdapter, _bucketConfiguration); if (IsDataNode || IsQueryNode) { _lastIOErrorCheckedTime = DateTime.Now; //On initialization, data nodes are authenticated, so they can start in a down state. //If the node is down immediately start the timer, otherwise disable it. if (IsDataNode) { _isDown = _ioStrategy.ConnectionPool.InitializationFailed; } Log.InfoFormat("Initialization {0} for node {1}", _isDown ? "failed" : "succeeded", EndPoint); //timer and node status _heartBeatTimer = new Timer(_clientConfiguration.NodeAvailableCheckInterval) { Enabled = _isDown }; _heartBeatTimer.Elapsed += _heartBeatTimer_Elapsed; } }
public Server(IIOService ioService, INodeAdapter nodeAdapter, ClientConfiguration clientConfiguration, IBucketConfig bucketConfig, ITypeTranscoder transcoder) : this(ioService, new ViewClient(new CouchbaseHttpClient(clientConfiguration, bucketConfig) { Timeout = new TimeSpan(0, 0, 0, 0, clientConfiguration.ViewRequestTimeout) }, new JsonDataMapper(clientConfiguration)), new QueryClient(new CouchbaseHttpClient(clientConfiguration, bucketConfig) { Timeout = new TimeSpan(0, 0, 0, 0, (int)clientConfiguration.QueryRequestTimeout) }, new JsonDataMapper(clientConfiguration), clientConfiguration), new SearchClient(bucketConfig, clientConfiguration, new SearchDataMapper()), nodeAdapter, clientConfiguration, transcoder, bucketConfig) { }
/// <summary> /// Updates the configured ports and URIs using the provided <see cref="T:Couchbase.Core.INodeAdapter" />. /// </summary> /// <param name="nodeAdapter">The node adapter.</param> public void LoadNodeAdapter(INodeAdapter nodeAdapter) { _nodeAdapter = nodeAdapter; //services that this node is responsible for IsMgmtNode = _nodeAdapter.MgmtApi > 0; IsDataNode = _nodeAdapter.KeyValue > 0; IsQueryNode = _nodeAdapter.N1QL > 0; IsIndexNode = _nodeAdapter.IndexAdmin > 0; IsViewNode = _nodeAdapter.Views > 0; IsSearchNode = _nodeAdapter.IsSearchNode; IsAnalyticsNode = _nodeAdapter.IsAnalyticsNode; CachedViewBaseUri = UrlUtil.GetViewBaseUri(_nodeAdapter, _bucketConfiguration); CachedQueryBaseUri = UrlUtil.GetN1QLBaseUri(_nodeAdapter, _bucketConfiguration); }
public static IPEndPoint GetEndPoint(INodeAdapter adapter, BucketConfiguration clientConfig, IBucketConfig server) { var address = adapter.Hostname.Split(':').First(); IPAddress ipAddress; if (!IPAddress.TryParse(address, out ipAddress)) { var uri = new Uri(String.Format("http://{0}", address)); ipAddress = uri.GetIpAddress(ClientConfiguration.UseInterNetworkV6Addresses); if (ipAddress == null) { throw new ArgumentException("ipAddress"); } } var port = clientConfig.UseSsl ? adapter.KeyValueSsl : adapter.KeyValue; return new IPEndPoint(ipAddress, port); }
public Server(IIOService ioService, IViewClient viewClient, IViewClient streamingViewClient, IQueryClient queryClient, IQueryClient streamingQueryClient, ISearchClient searchClient, IAnalyticsClient analyticsClient, INodeAdapter nodeAdapter, ITypeTranscoder transcoder, ConfigContextBase context) { if (ioService != null) { _ioService = ioService; _ioService.ConnectionPool.Owner = this; } _clientConfiguration = context.ClientConfig; _bucketConfiguration = context.ClientConfig.BucketConfigs[context.BucketConfig.Name]; _timingEnabled = _clientConfiguration.EnableOperationTiming; _typeTranscoder = transcoder; _bucketConfig = context.BucketConfig; //set all properties based off the nodes and nodeExt adapter LoadNodeAdapter(nodeAdapter); //View and query clients ViewClient = viewClient; _streamingViewClient = streamingViewClient; QueryClient = queryClient; SearchClient = searchClient; _streamingQueryClient = streamingQueryClient; AnalyticsClient = analyticsClient; if (IsDataNode || IsQueryNode) { _lastIOErrorCheckedTime = DateTime.Now; //On initialization, data nodes are authenticated, so they can start in a down state. //If the node is down immediately start the timer, otherwise disable it. if (IsDataNode) { _isDown = _ioService.ConnectionPool.InitializationFailed; } Log.Info("Initialization {0} for node {1}", _isDown ? "failed" : "succeeded", EndPoint); //timer and node status _heartBeatTimer = new Timer(_heartBeatTimer_Elapsed, null, Timeout.Infinite, Timeout.Infinite); if (_isDown) { StartHeartbeatTimer(); } } }
public static IPEndPoint GetEndPoint(INodeAdapter adapter, BucketConfiguration clientConfig, IBucketConfig serverConfig) { var address = adapter.Hostname.Split(':').First(); IPAddress ipAddress; if (!IPAddress.TryParse(address, out ipAddress)) { var uri = new Uri(String.Format("http://{0}", address)); ipAddress = uri.GetIpAddress(); if (ipAddress == null) { throw new ArgumentException("ipAddress"); } } var port = clientConfig.UseSsl ? adapter.KeyValueSsl : adapter.KeyValue; return(new IPEndPoint(ipAddress, port)); }
public static FailureCountingUri GetFailureCountinSearchBaseUri(INodeAdapter adapter, BucketConfiguration config) { return new FailureCountingUri(GetSearchBaseUri(adapter, config)); }
public static FailureCountingUri GetFailureCountingBaseUri(INodeAdapter adapter, BucketConfiguration config) { return new FailureCountingUri(GetN1QLBaseUriAsString(adapter, config)); }
public void LoadNodeAdapter(INodeAdapter nodeAdapter, uint rev) { throw new NotImplementedException(); }
public Server(IIOService ioService, INodeAdapter nodeAdapter, ClientConfiguration clientConfiguration, IBucketConfig bucketConfig, ITypeTranscoder transcoder) : this(ioService, null, null, null, null, null, null, nodeAdapter, clientConfiguration, transcoder, bucketConfig) { }
public Server(IIOService ioService, INodeAdapter nodeAdapter, ITypeTranscoder transcoder, ConfigContextBase context) : this(ioService, null, null, null, null, null, null, nodeAdapter, transcoder, context) { }
public static FailureCountingUri GetFailureCountingBaseUri(INodeAdapter adapter, BucketConfiguration config) { return(new FailureCountingUri(GetN1QLBaseUriAsString(adapter, config))); }
public static FailureCountingUri GetFailureCountinSearchBaseUri(INodeAdapter adapter, BucketConfiguration config) { return(new FailureCountingUri(GetSearchBaseUri(adapter, config))); }
public static FailureCountingUri GetFailureCountingAnalyticsUri(INodeAdapter adapter, BucketConfiguration config) { return(new FailureCountingUri(GetAnalyticsUri(adapter, config))); }
public static Uri GetViewBaseUri(INodeAdapter adapter, BucketConfiguration config) { return new Uri(GetViewBaseUriAsString(adapter, config)); }
// ReSharper disable once InconsistentNaming public static Uri GetN1QLBaseUri(INodeAdapter adapter, BucketConfiguration config) { return(new Uri(GetN1QLBaseUriAsString(adapter, config))); }
public static string GetHostName(INodeAdapter adapter) { return(adapter.IsIPv6 && !adapter.Hostname.Contains("[") ? string.Concat("[", adapter.Hostname, "]") : adapter.Hostname); }