예제 #1
0
		public SealedVirtualCluster(VirtualCluster cluster, IConnectionPool pool, TestableDateTimeProvider dateTimeProvider)
		{
			this._cluster = cluster;
			this._connectionPool = pool;
			this._connection = new VirtualClusterConnection(cluster, dateTimeProvider);
			this._dateTimeProvider = dateTimeProvider;
		}
예제 #2
0
 public SealedVirtualCluster(VirtualCluster cluster, IConnectionPool pool, TestableDateTimeProvider dateTimeProvider)
 {
     this._cluster          = cluster;
     this._connectionPool   = pool;
     this._connection       = new VirtualClusterConnection(cluster, dateTimeProvider);
     this._dateTimeProvider = dateTimeProvider;
 }
        public VirtualizedCluster(VirtualCluster cluster, IConnectionPool pool, TestableDateTimeProvider dateTimeProvider, ConnectionSettings settings)
        {
            this._dateTimeProvider     = dateTimeProvider;
            this._fixedRequestPipeline = new FixedPipelineFactory(settings, this._dateTimeProvider);
            this._client = this._fixedRequestPipeline.Client;

            this._cluster        = cluster;
            this._connectionPool = pool;
        }
		public VirtualizedCluster(VirtualCluster cluster, IConnectionPool pool, TestableDateTimeProvider dateTimeProvider, ConnectionSettings settings)
		{
			this._dateTimeProvider = dateTimeProvider;
			this._settings = settings;
			this._fixedRequestPipeline = new FixedPipelineFactory(settings, this._dateTimeProvider);

			this._cluster = cluster;
			this._connectionPool = pool;
		}
		public VirtualizedCluster(TestableDateTimeProvider dateTimeProvider, ConnectionSettings settings)
		{
			this._dateTimeProvider = dateTimeProvider;
			this._settings = settings;
			this._fixedRequestPipeline = new FixedPipelineFactory(settings, this._dateTimeProvider);

			this._syncCall = (c, r) => c.Search<Project>(s => s.RequestConfiguration(r));
			this._asyncCall = async (c, r) =>
			{
				var res = await c.SearchAsync<Project>(s => s.RequestConfiguration(r));
				return (IResponse)res;
			};
		}
        public VirtualizedCluster(TestableDateTimeProvider dateTimeProvider, ConnectionSettings settings)
        {
            _dateTimeProvider     = dateTimeProvider;
            _settings             = settings;
            _fixedRequestPipeline = new FixedPipelineFactory(settings, _dateTimeProvider);

            _syncCall  = (c, r) => c.Search <Project>(s => s.RequestConfiguration(r));
            _asyncCall = async(c, r) =>
            {
                var res = await c.SearchAsync <Project>(s => s.RequestConfiguration(r));

                return((IResponse)res);
            };
        }
예제 #7
0
        public VirtualizedCluster(VirtualCluster cluster, IConnectionPool pool, TestableDateTimeProvider dateTimeProvider, ConnectionSettings settings)
        {
            this._dateTimeProvider     = dateTimeProvider;
            this._settings             = settings;
            this._fixedRequestPipeline = new FixedPipelineFactory(settings, this._dateTimeProvider);

            this._cluster        = cluster;
            this._connectionPool = pool;

            this._syncCall  = (c, r) => c.Search <Project>(s => s.RequestConfiguration(r));
            this._asyncCall = async(c, r) =>
            {
                var res = await c.SearchAsync <Project>(s => s.RequestConfiguration(r));

                return((IResponse)res);
            };
        }
예제 #8
0
		[U] public void ViewSeesResurrectedNodes()
		{
			var dateTimeProvider = new TestableDateTimeProvider();
			var seeds = Enumerable.Range(9200, NumberOfNodes).Select(p => new Node(new Uri("http://localhost:" + p))).ToList();
			seeds.First().MarkDead(dateTimeProvider.Now().AddDays(1));
			var pool = new StaticConnectionPool(seeds, randomize: false, dateTimeProvider: dateTimeProvider);
			for (var i = 0; i < 20; i++)
			{
				var node = pool.CreateView().First();
				node.Uri.Port.Should().Be(9201);
				node = pool.CreateView().First();
				node.Uri.Port.Should().Be(9202);
			}
			/** If we roll the clock forward two days, the node that was marked dead until tomorrow (or yesterday!) should be resurrected */
			dateTimeProvider.ChangeTime(d => d.AddDays(2));
			var n = pool.CreateView().First();
			n.Uri.Port.Should().Be(9201);
			n = pool.CreateView().First();
			n.Uri.Port.Should().Be(9202);
			n = pool.CreateView().First();
			n.Uri.Port.Should().Be(9200);
			n.IsResurrected.Should().BeTrue();
		}
예제 #9
0
 public VirtualClusterConnection(VirtualCluster cluster, TestableDateTimeProvider dateTimeProvider)
 {
     this.UpdateCluster(cluster);
     this._dateTimeProvider = dateTimeProvider;
 }
		public void SniffsOnStaleCluster()
		{
			var dateTime = new TestableDateTimeProvider();
			var singleNodePipeline = CreatePipeline(uris => new SingleNodeConnectionPool(uris.First(), dateTime), dateTimeProvider: dateTime);
			var staticPipeline = CreatePipeline(uris => new StaticConnectionPool(uris, dateTimeProvider: dateTime), dateTimeProvider: dateTime);
			var sniffingPipeline = CreatePipeline(uris => new SniffingConnectionPool(uris, dateTimeProvider: dateTime), dateTimeProvider: dateTime);

			singleNodePipeline.SniffsOnStaleCluster.Should().BeFalse();
			staticPipeline.SniffsOnStaleCluster.Should().BeFalse();
			sniffingPipeline.SniffsOnStaleCluster.Should().BeTrue();

			singleNodePipeline.StaleClusterState.Should().BeFalse();
			staticPipeline.StaleClusterState.Should().BeFalse();
			sniffingPipeline.StaleClusterState.Should().BeFalse();

			/** go one hour into the future */
			dateTime.ChangeTime(d => d.Add(TimeSpan.FromHours(2)));

			/**connection pools that do not support reseeding never go stale */
			singleNodePipeline.StaleClusterState.Should().BeFalse();
			staticPipeline.StaleClusterState.Should().BeFalse();
			/** the sniffing connection pool supports reseeding so the pipeline will signal the state is out of date */
			sniffingPipeline.StaleClusterState.Should().BeTrue();

		}
		public void SetsSniffPathUsingToTimespan()
		{
			var dateTime = new TestableDateTimeProvider();
			var sniffingPipeline = CreatePipeline(uris => new SniffingConnectionPool(uris, dateTimeProvider: dateTime), dateTimeProvider: dateTime) as RequestPipeline;
			sniffingPipeline.SniffPath.Should().Be("_nodes/_all/settings?flat_settings&timeout=2s");
		}
		public void IsTakingTooLong()
		{
			var dateTime = new TestableDateTimeProvider();
			var singleNodePipeline = CreatePipeline(uris => new SingleNodeConnectionPool(uris.First(), dateTime), dateTimeProvider: dateTime);
			var staticPipeline = CreatePipeline(uris => new StaticConnectionPool(uris, dateTimeProvider: dateTime), dateTimeProvider: dateTime);
			var sniffingPipeline = CreatePipeline(uris => new SniffingConnectionPool(uris, dateTimeProvider: dateTime), dateTimeProvider: dateTime);

			singleNodePipeline.IsTakingTooLong.Should().BeFalse();
			staticPipeline.IsTakingTooLong.Should().BeFalse();
			sniffingPipeline.IsTakingTooLong.Should().BeFalse();

			/** go one hour into the future */
			dateTime.ChangeTime(d => d.Add(TimeSpan.FromHours(2)));

			/**connection pools that do not support reseeding never go stale */
			singleNodePipeline.IsTakingTooLong.Should().BeTrue();
			staticPipeline.IsTakingTooLong.Should().BeTrue();
			/** the sniffing connection pool supports reseeding so the pipeline will signal the state is out of date */
			sniffingPipeline.IsTakingTooLong.Should().BeTrue();

			/** request pipeline exposes the DateTime it started, here we assert it started 2 hours in the past */
			(dateTime.Now() - singleNodePipeline.StartedOn).Should().BePositive().And.BeCloseTo(TimeSpan.FromHours(2));
			(dateTime.Now() - staticPipeline.StartedOn).Should().BePositive().And.BeCloseTo(TimeSpan.FromHours(2));
			(dateTime.Now() - sniffingPipeline.StartedOn).Should().BePositive().And.BeCloseTo(TimeSpan.FromHours(2));
		}