コード例 #1
0
        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);
        }
コード例 #2
0
 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)
 {
 }
コード例 #3
0
 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;
 }
コード例 #4
0
 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)
 {
 }
コード例 #5
0
 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)
 {
 }
コード例 #6
0
 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)
 {
 }
コード例 #7
0
        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);
        }
コード例 #8
0
 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)
 {
 }
コード例 #9
0
        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);
        }
コード例 #10
0
 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;
 }
コード例 #11
0
        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();
                }
            }
        }
コード例 #12
0
        // 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;
        }
コード例 #13
0
        // 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);
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        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;
        }
コード例 #16
0
        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;
        }
コード例 #17
0
        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);
        }
コード例 #18
0
        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);
        }
コード例 #19
0
        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;
            }
        }
コード例 #20
0
 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)
 {
 }
コード例 #21
0
        /// <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);
        }
コード例 #22
0
 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);
 }
コード例 #23
0
        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();
                }
            }
        }
コード例 #24
0
        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));
        }
コード例 #25
0
 public static FailureCountingUri GetFailureCountinSearchBaseUri(INodeAdapter adapter,
     BucketConfiguration config)
 {
     return new FailureCountingUri(GetSearchBaseUri(adapter, config));
 }
コード例 #26
0
 public static FailureCountingUri GetFailureCountingBaseUri(INodeAdapter adapter, BucketConfiguration config)
 {
     return new FailureCountingUri(GetN1QLBaseUriAsString(adapter, config));
 }
コード例 #27
0
 public void LoadNodeAdapter(INodeAdapter nodeAdapter, uint rev)
 {
     throw new NotImplementedException();
 }
コード例 #28
0
 public Server(IIOService ioService, INodeAdapter nodeAdapter, ClientConfiguration clientConfiguration,
               IBucketConfig bucketConfig, ITypeTranscoder transcoder) :
     this(ioService, null, null, null, null, null, null, nodeAdapter, clientConfiguration, transcoder, bucketConfig)
 {
 }
コード例 #29
0
 public Server(IIOService ioService, INodeAdapter nodeAdapter, ITypeTranscoder transcoder, ConfigContextBase context) :
     this(ioService, null, null, null, null, null, null, nodeAdapter, transcoder, context)
 {
 }
コード例 #30
0
 public static FailureCountingUri GetFailureCountingBaseUri(INodeAdapter adapter, BucketConfiguration config)
 {
     return(new FailureCountingUri(GetN1QLBaseUriAsString(adapter, config)));
 }
コード例 #31
0
 public static FailureCountingUri GetFailureCountinSearchBaseUri(INodeAdapter adapter,
                                                                 BucketConfiguration config)
 {
     return(new FailureCountingUri(GetSearchBaseUri(adapter, config)));
 }
コード例 #32
0
 public static FailureCountingUri GetFailureCountingAnalyticsUri(INodeAdapter adapter, BucketConfiguration config)
 {
     return(new FailureCountingUri(GetAnalyticsUri(adapter, config)));
 }
コード例 #33
0
 public static Uri GetViewBaseUri(INodeAdapter adapter, BucketConfiguration config)
 {
     return new Uri(GetViewBaseUriAsString(adapter, config));
 }
コード例 #34
0
 // ReSharper disable once InconsistentNaming
 public static Uri GetN1QLBaseUri(INodeAdapter adapter, BucketConfiguration config)
 {
     return(new Uri(GetN1QLBaseUriAsString(adapter, config)));
 }
コード例 #35
0
 public static string GetHostName(INodeAdapter adapter)
 {
     return(adapter.IsIPv6 && !adapter.Hostname.Contains("[")
         ? string.Concat("[", adapter.Hostname, "]")
         : adapter.Hostname);
 }