Example #1
0
        public override async Task ProfileAsync(IElasticClient client, ColoredConsoleWriter output)
        {
            for (var i = 0; i < _iterations; i++)
            {
                // TODO generate random search descriptors
                var searchResponse = await client.SearchAsync <Developer>(s => s
                                                                          .Index <Developer>()
                                                                          .Query(q => q
                                                                                 .Bool(b => b
                                                                                       .Must(
                                                                                           mc => mc.Match(m => m.Field(d => d.FirstName).Query(_developer.FirstName)),
                                                                                           mc => mc.Match(m => m.Field(d => d.LastName).Query(_developer.LastName)),
                                                                                           mc => mc.Match(m => m.Field(d => d.JobTitle).Query(_developer.JobTitle))
                                                                                           )
                                                                                       )
                                                                                 )
                                                                          ).ConfigureAwait(false);

                if (!searchResponse.IsValid)
                {
                    output.WriteOrange(
                        $"error searching for {nameof(Developer)}. message: {searchResponse.ApiCall.OriginalException}");
                }

                if (!searchResponse.Documents.Any())
                {
                    output.WriteOrange($"did not find matching {nameof(Developer)} for search.");
                }
            }
        }
		public override async Task TeardownAsync(IElasticClient client, ColoredConsoleWriter output)
		{
			var deleteResponse = await client.DeleteAsync<Developer>(_developer, d => d.Index<Developer>()).ConfigureAwait(false);

			if (!deleteResponse.IsValid)
				output.WriteOrange($"error with id {deleteResponse.Id}. message: {deleteResponse.CallDetails.OriginalException}");
		}
		public override async Task ProfileAsync(IElasticClient client, ColoredConsoleWriter output)
		{
			for (var i = 0; i < _iterations; i++)
			{
				// TODO generate random search descriptors
				var searchResponse = await client.SearchAsync<Developer>(s => s
					.Index<Developer>()
					.Query(q => q
						.Bool(b => b
							.Must(
								mc => mc.Match(m => m.Field(d => d.FirstName).Query(_developer.FirstName)),
								mc => mc.Match(m => m.Field(d => d.LastName).Query(_developer.LastName)),
								mc => mc.Match(m => m.Field(d => d.JobTitle).Query(_developer.JobTitle))
							)
						)
					)
					).ConfigureAwait(false);

				if (!searchResponse.IsValid)
					output.WriteOrange(
						$"error searching for {nameof(Developer)}. message: {searchResponse.CallDetails.OriginalException}");

				if (!searchResponse.Documents.Any())
					output.WriteOrange($"did not find matching {nameof(Developer)} for search.");
			}
		}
Example #4
0
        public override async Task TeardownAsync(IElasticClient client, ColoredConsoleWriter output)
        {
            var deleteResponse = await client.DeleteAsync <Developer>(_developer, d => d.Index <Developer>()).ConfigureAwait(false);

            if (!deleteResponse.IsValid)
            {
                output.WriteOrange($"error with id {deleteResponse.Id}. message: {deleteResponse.ApiCall.OriginalException}");
            }
        }
		public override async Task SetupAsync(IElasticClient client, ColoredConsoleWriter output)
		{
			_developer = Developer.Generator.Generate();

			var indexResponse = await client.IndexAsync(_developer, d => d.Index<Developer>().Refresh()).ConfigureAwait(false);

			if (!indexResponse.IsValid)
				output.WriteOrange($"error with id {indexResponse.Id}. message: {indexResponse.CallDetails.OriginalException}");
		}
		public override async Task ProfileAsync(IElasticClient client, ColoredConsoleWriter output)
		{
			for (var i = 0; i < _iterations; i++)
			{
				var mappingResponse = await client.GetMappingAsync<Project>(s => s.Index<Project>()).ConfigureAwait(false);

				if (!mappingResponse.IsValid)
					output.WriteOrange("Invalid response for get mapping operation");
			}
		}
		public override async Task TeardownAsync(IElasticClient client, ColoredConsoleWriter output)
		{
			var removeResponse = await client.AliasAsync(a => a
				.Remove(remove => remove
					.Alias(_aliasName)
					.Index<Developer>()
				)).ConfigureAwait(false);

			if (!removeResponse.IsValid)
				output.WriteOrange($"Invalid response when adding alias for {nameof(AliasExistsAsyncOperation)} operation");
		}
		public override async Task ProfileAsync(IElasticClient client, ColoredConsoleWriter output)
		{
			for (var i = 0; i < _iterations; i++)
			{
				var indexResponse =
					await client.IndexAsync(Developer.Generator.Generate(), d => d.Index<Developer>()).ConfigureAwait(false);

				if (!indexResponse.IsValid)
					output.WriteOrange($"error with id {indexResponse.Id}. message: {indexResponse.ApiCall.OriginalException}");
			}
		}
Example #9
0
        public override async Task SetupAsync(IElasticClient client, ColoredConsoleWriter output)
        {
            _developer = Developer.Generator.Generate();

            var indexResponse = await client.IndexAsync(_developer, d => d.Index <Developer>().Refresh(Refresh.True)).ConfigureAwait(false);

            if (!indexResponse.IsValid)
            {
                output.WriteOrange($"error with id {indexResponse.Id}. message: {indexResponse.ApiCall.OriginalException}");
            }
        }
		public override async Task ProfileAsync(IElasticClient client, ColoredConsoleWriter output)
		{
			for (var i = 0; i < _iterations; i++)
			{
				var catAllocationAsync = client.CatAllocationAsync(s => s.V());
				var catCountAsync = client.CatCountAsync(s => s.V());
				var catFielddataAsync = client.CatFielddataAsync(s => s.V());
				var catHealthAsync = client.CatHealthAsync(s => s.V());
				var catIndicesAsync = client.CatIndicesAsync(s => s.V());
				var catNodesAsync = client.CatNodesAsync(s => s.V());
				var catPendingTasksAsync = client.CatPendingTasksAsync(s => s.V());
				var catThreadPoolAsync = client.CatThreadPoolAsync(s => s.V());
				var catAliasesAsync = client.CatAliasesAsync(s => s.V());

				await Task.WhenAll(
					catAllocationAsync,
					catCountAsync,
					catFielddataAsync,
					catHealthAsync,
					catIndicesAsync,
					catNodesAsync,
					catPendingTasksAsync,
					catThreadPoolAsync,
					catAliasesAsync
					).ConfigureAwait(false);

				if (!catAllocationAsync.Result.IsValid)
					output.WriteOrange("invalid response received for cat allocation");

				if (!catCountAsync.Result.IsValid)
					output.WriteOrange("invalid response received for cat count");

				if (!catFielddataAsync.Result.IsValid)
					output.WriteOrange("invalid response received for cat fielddata");

				if (!catHealthAsync.Result.IsValid)
					output.WriteOrange("invalid response received for cat health");

				if (!catIndicesAsync.Result.IsValid)
					output.WriteOrange("invalid response received for cat indices");

				if (!catNodesAsync.Result.IsValid)
					output.WriteOrange("invalid response received for cat nodes");

				if (!catPendingTasksAsync.Result.IsValid)
					output.WriteOrange("invalid response received for cat pending tasks");

				if (!catThreadPoolAsync.Result.IsValid)
					output.WriteOrange("invalid response received for cat thread pool");

				if (!catAliasesAsync.Result.IsValid)
					output.WriteOrange("invalid response received for cat aliases");
			}
		}
Example #11
0
        public override async Task ProfileAsync(IElasticClient client, ColoredConsoleWriter output)
        {
            for (var i = 0; i < _iterations; i++)
            {
                var mappingResponse = await client.GetMappingAsync <Project>(s => s.Index <Project>()).ConfigureAwait(false);

                if (!mappingResponse.IsValid)
                {
                    output.WriteOrange("Invalid response for get mapping operation");
                }
            }
        }
Example #12
0
        public override async Task ProfileAsync(IElasticClient client, ColoredConsoleWriter output)
        {
            for (var i = 0; i < _iterations; i++)
            {
                var indexResponse =
                    await client.IndexAsync(Developer.Generator.Generate(), d => d.Index <Developer>()).ConfigureAwait(false);

                if (!indexResponse.IsValid)
                {
                    output.WriteOrange($"error with id {indexResponse.Id}. message: {indexResponse.ApiCall.OriginalException}");
                }
            }
        }
Example #13
0
        public override async Task TeardownAsync(IElasticClient client, ColoredConsoleWriter output)
        {
            var removeResponse = await client.AliasAsync(a => a
                                                         .Remove(remove => remove
                                                                 .Alias(_aliasName)
                                                                 .Index <Developer>()
                                                                 )).ConfigureAwait(false);

            if (!removeResponse.IsValid)
            {
                output.WriteOrange($"Invalid response when adding alias for {nameof(AliasExistsAsyncOperation)} operation");
            }
        }
		public override async Task ProfileAsync(IElasticClient client, ColoredConsoleWriter output)
		{
			for (int i = 0; i < _iterations; i++)
			{
				var analyzeResponse = await client.AnalyzeAsync(a => a
					.Analyzer("standard")
					.Text(_sentenceGenerator.Sentance())
				).ConfigureAwait(false);

				if (!analyzeResponse.IsValid)
					output.WriteOrange($"Invalid response from {nameof(AnalyzeAsyncOperation)} operation");
			}
		}
		public override async Task ProfileAsync(IElasticClient client, ColoredConsoleWriter output)
		{
			for (int i = 0; i < _iterations; i++)
			{
				var aliasResponse = await client.AliasExistsAsync(a => a
					.Index(typeof(Developer))
					.Name(i % 2 == 0 ? _aliasName : "non-existent-alias")
				).ConfigureAwait(false);

				if (!aliasResponse.IsValid)
					output.WriteOrange($"Invalid response from {nameof(AliasExistsAsyncOperation)} operation");
			}
		}
Example #16
0
        public override async Task ProfileAsync(IElasticClient client, ColoredConsoleWriter output)
        {
            for (int i = 0; i < _iterations; i++)
            {
                var analyzeResponse = await client.AnalyzeAsync(a => a
                                                                .Analyzer("standard")
                                                                .Text(_sentenceGenerator.Sentence())
                                                                ).ConfigureAwait(false);

                if (!analyzeResponse.IsValid)
                {
                    output.WriteOrange($"Invalid response from {nameof(AnalyzeAsyncOperation)} operation");
                }
            }
        }
        public async Task RunAsync(IElasticClient client, ColoredConsoleWriter output)
        {
            await SetupAsync(client, output).ConfigureAwait(false);

            output.Write($"Start {this.GetType().Name} operation");

            using (Profiler.Start())
            {
                await ProfileAsync(client, output).ConfigureAwait(false);
            }

            output.Write($"Finished {this.GetType().Name} operation");

            await TeardownAsync(client, output).ConfigureAwait(false);
        }
Example #18
0
        public override async Task ProfileAsync(IElasticClient client, ColoredConsoleWriter output)
        {
            for (int i = 0; i < _iterations; i++)
            {
                var aliasResponse = await client.AliasExistsAsync(a => a
                                                                  .Index(typeof(Developer))
                                                                  .Name(i % 2 == 0 ? _aliasName : "non-existent-alias")
                                                                  ).ConfigureAwait(false);

                if (!aliasResponse.IsValid)
                {
                    output.WriteOrange($"Invalid response from {nameof(AliasExistsAsyncOperation)} operation");
                }
            }
        }
		public async Task RunAsync(IElasticClient client, ColoredConsoleWriter output)
		{
			await SetupAsync(client, output).ConfigureAwait(false);

			output.Write($"Start {this.GetType().Name} operation");

			using (Profiler.Start())
			{
				await ProfileAsync(client, output).ConfigureAwait(false);
			}

			output.Write($"Finished {this.GetType().Name} operation");

			await TeardownAsync(client, output).ConfigureAwait(false);
		}
		public override async Task ProfileAsync(IElasticClient client, ColoredConsoleWriter output)
		{
			for (var i = 0; i < _iterations; i++)
			{
				var bulkResponse = await client.BulkAsync(b => b
					.IndexMany(Developer.Generator.Generate(_itemsPerIteration), (bd, d) => bd
						.Index(Infer.Index<Developer>())
						.Document(d)
					)).ConfigureAwait(false);

				if (!bulkResponse.IsValid)
					if (bulkResponse.Errors)
						foreach (var error in bulkResponse.ItemsWithErrors)
							output.WriteOrange($"error with id {error.Id}. message: {error.Error.Reason}");
			}
		}
Example #21
0
        public override async Task ProfileAsync(IElasticClient client, ColoredConsoleWriter output)
        {
            for (var i = 0; i < _iterations; i++)
            {
                var bulkResponse = await client.BulkAsync(b => b
                                                          .IndexMany(Developer.Generator.Generate(_itemsPerIteration), (bd, d) => bd
                                                                     .Index(Infer.Index <Developer>())
                                                                     .Document(d)
                                                                     )).ConfigureAwait(false);

                if (!bulkResponse.IsValid)
                {
                    if (bulkResponse.Errors)
                    {
                        foreach (var error in bulkResponse.ItemsWithErrors)
                        {
                            output.WriteOrange($"error with id {error.Id}. message: {error.Error.Reason}");
                        }
                    }
                }
            }
        }
Example #22
0
        public override async Task ProfileAsync(IElasticClient client, ColoredConsoleWriter output)
        {
            for (int i = 0; i < _iterations; i++)
            {
                IBulkAliasResponse aliasResponse;
                if (i == 0)
                {
                    aliasResponse = await client.AliasAsync(a => a
                                                            .Add(add => add
                                                                 .Alias($"dev{i}").Index <Developer>()
                                                                 )).ConfigureAwait(false);
                }
                else if (i == _iterations - 1)
                {
                    aliasResponse = await client.AliasAsync(a => a
                                                            .Remove(remove => remove
                                                                    .Alias($"dev{i - 1}")
                                                                    .Index(typeof(Developer))
                                                                    )).ConfigureAwait(false);
                }
                else
                {
                    aliasResponse = await client.AliasAsync(a => a
                                                            .Add(add => add
                                                                 .Alias($"dev{i}").Index <Developer>()
                                                                 )
                                                            .Remove(remove => remove
                                                                    .Alias($"dev{i - 1}")
                                                                    .Index(typeof(Developer))
                                                                    )).ConfigureAwait(false);
                }

                if (!aliasResponse.IsValid)
                {
                    output.WriteOrange($"Invalid response from {nameof(AliasAsyncOperation)} operation");
                }
            }
        }
Example #23
0
        static void Main(string[] args)
        {
            Console.WriteLine("What qualifies as useful?");
            ConsoleReader.WaitResponse();
            Console.Clear();
            Console.BufferWidth     = 500;
            Console.BufferHeight    = 600;
            Console.ForegroundColor = ConsoleColor.Green;
            AlphabetPrinter prntr = new AlphabetPrinter('%');

            prntr.Print("Next To");
            Console.WriteLine();
            Thread.Sleep(750);
            prntr.Print("Nearly");
            Console.WriteLine();
            Thread.Sleep(750);
            prntr.Print("Almost");
            Console.WriteLine();
            Thread.Sleep(750);
            prntr.Print("Absolutely");
            Console.WriteLine();
            Thread.Sleep(1000);
            Console.Clear();
            Console.BackgroundColor = ConsoleColor.DarkRed;
            Console.ForegroundColor = ConsoleColor.Cyan;
            new AlphabetPrinter('*').Print("Nothing!");
            Console.ForegroundColor = ConsoleColor.Gray;
            ConsoleReader.WaitResponse();
            Console.BackgroundColor = ConsoleColor.Black;
            Console.Clear();

            ColoredConsoleWriter.WriteLine(ColoredConsoleWriter.TranslateAlternateColorCodes('&', "&00&11&22&33&44&55&66&77&88&99&aa&bb&cc&dd&ee&ff"));
            ConsoleReader.WaitResponse();
            Console.Clear();
            ColoredConsoleWriter.WriteLine(String.Format(ColoredConsoleWriter.TranslateAlternateColorCodes('&', "&aYou entered: &r'{0}'"), ConsoleReader.PromptHidden("Enter a password: ", '\u00B7')));
            ConsoleReader.WaitResponse();
        }
		public override async Task ProfileAsync(IElasticClient client, ColoredConsoleWriter output)
		{
			for (int i = 0; i < _iterations; i++)
			{
				IBulkAliasResponse aliasResponse;
				if (i == 0)
				{
					aliasResponse = await client.AliasAsync(a => a
						.Add(add => add
							.Alias($"dev{i}").Index<Developer>()
						)).ConfigureAwait(false);
				}
				else if (i == _iterations - 1)
				{
					aliasResponse = await client.AliasAsync(a => a
						.Remove(remove => remove
							.Alias($"dev{i - 1}")
							.Index(typeof (Developer))
						)).ConfigureAwait(false);
				}
				else
				{
					aliasResponse = await client.AliasAsync(a => a
						.Add(add => add
							.Alias($"dev{i}").Index<Developer>()
						)
						.Remove(remove => remove
							.Alias($"dev{i - 1}")
							.Index(typeof (Developer))
						)).ConfigureAwait(false);
				}

				if (!aliasResponse.IsValid)
					output.WriteOrange($"Invalid response from {nameof(AliasAsyncOperation)} operation");
			}
		}
Example #25
0
 public virtual Task SetupAsync(IElasticClient client, ColoredConsoleWriter output)
 {
     return(System.Threading.Tasks.Task.FromResult(0));
 }
Example #26
0
 public Task RunAsync(IElasticClient client, ColoredConsoleWriter output)
 {
     throw new NotImplementedException();
 }
		public Task RunAsync(IElasticClient client, ColoredConsoleWriter output)
		{
			throw new NotImplementedException();
		}
Example #28
0
        public override async Task ProfileAsync(IElasticClient client, ColoredConsoleWriter output)
        {
            for (var i = 0; i < _iterations; i++)
            {
                var catAllocationAsync   = client.CatAllocationAsync(s => s.V());
                var catCountAsync        = client.CatCountAsync(s => s.V());
                var catFielddataAsync    = client.CatFielddataAsync(s => s.V());
                var catHealthAsync       = client.CatHealthAsync(s => s.V());
                var catIndicesAsync      = client.CatIndicesAsync(s => s.V());
                var catNodesAsync        = client.CatNodesAsync(s => s.V());
                var catPendingTasksAsync = client.CatPendingTasksAsync(s => s.V());
                var catThreadPoolAsync   = client.CatThreadPoolAsync(s => s.V());
                var catAliasesAsync      = client.CatAliasesAsync(s => s.V());

                await System.Threading.Tasks.Task.WhenAll(
                    catAllocationAsync,
                    catCountAsync,
                    catFielddataAsync,
                    catHealthAsync,
                    catIndicesAsync,
                    catNodesAsync,
                    catPendingTasksAsync,
                    catThreadPoolAsync,
                    catAliasesAsync
                    ).ConfigureAwait(false);

                if (!catAllocationAsync.Result.IsValid)
                {
                    output.WriteOrange("invalid response received for cat allocation");
                }

                if (!catCountAsync.Result.IsValid)
                {
                    output.WriteOrange("invalid response received for cat count");
                }

                if (!catFielddataAsync.Result.IsValid)
                {
                    output.WriteOrange("invalid response received for cat fielddata");
                }

                if (!catHealthAsync.Result.IsValid)
                {
                    output.WriteOrange("invalid response received for cat health");
                }

                if (!catIndicesAsync.Result.IsValid)
                {
                    output.WriteOrange("invalid response received for cat indices");
                }

                if (!catNodesAsync.Result.IsValid)
                {
                    output.WriteOrange("invalid response received for cat nodes");
                }

                if (!catPendingTasksAsync.Result.IsValid)
                {
                    output.WriteOrange("invalid response received for cat pending tasks");
                }

                if (!catThreadPoolAsync.Result.IsValid)
                {
                    output.WriteOrange("invalid response received for cat thread pool");
                }

                if (!catAliasesAsync.Result.IsValid)
                {
                    output.WriteOrange("invalid response received for cat aliases");
                }
            }
        }
		public virtual Task SetupAsync(IElasticClient client, ColoredConsoleWriter output)
		{
			return Task.FromResult(0);
		}
		public abstract Task ProfileAsync(IElasticClient client, ColoredConsoleWriter output);
		public virtual Task SetupAsync(IElasticClient client, ColoredConsoleWriter output)
		{
			return System.Threading.Tasks.Task.FromResult(0);
		}
 public virtual Task SetupAsync(IElasticClient client, ColoredConsoleWriter output)
 {
     return(Task.FromResult(0));
 }
Example #33
0
 public ConsoleAdapter(ColoredConsoleWriter console)
 {
     _console = console;
 }
 public abstract Task ProfileAsync(IElasticClient client, ColoredConsoleWriter output);