public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems) { AmazonAthenaConfig config = new AmazonAthenaConfig(); config.RegionEndpoint = region; ConfigureClient(config); AmazonAthenaClient client = new AmazonAthenaClient(creds, config); ListQueryExecutionsResponse resp = new ListQueryExecutionsResponse(); do { ListQueryExecutionsRequest req = new ListQueryExecutionsRequest { NextToken = resp.NextToken , MaxResults = maxItems }; resp = client.ListQueryExecutions(req); CheckError(resp.HttpStatusCode, "200"); foreach (var obj in resp.QueryExecutionIds) { AddObject(obj); } }while (!string.IsNullOrEmpty(resp.NextToken)); }
static void Main(string[] args) { AmazonAthenaClient client = new AmazonAthenaClient(); while (true) { using (var writer = new StreamWriter(@"C:\Users\bslocum\Desktop\AthenaRecords.csv")) { using (var csv = new CsvWriter(writer)) { Console.WriteLine("Starting"); string currentPageId = null; int count = 0; int totalRunning = 0; while (count < 1000) { var executionParams = new Amazon.Athena.Model.ListQueryExecutionsRequest(); if (count != 0) { executionParams.NextToken = currentPageId; } var thelist = client.ListQueryExecutions(executionParams); var theExecutions = client.BatchGetQueryExecution(new Amazon.Athena.Model.BatchGetQueryExecutionRequest() { QueryExecutionIds = thelist.QueryExecutionIds }); currentPageId = thelist.NextToken; var theRunners = theExecutions.QueryExecutions.Where(x => x.Status.State == QueryExecutionState.RUNNING); foreach (var aRunner in theRunners) { Console.WriteLine($"Time: {aRunner.Status.SubmissionDateTime.ToLocalTime().ToLongTimeString()}, {aRunner.ResultConfiguration.OutputLocation}, {aRunner.StatementType}"); var queryLine = new QueryRun(); queryLine.Time = aRunner.Status.SubmissionDateTime.ToLocalTime().ToLongTimeString(); queryLine.OutPutLocation = aRunner.ResultConfiguration.OutputLocation; queryLine.StatementType = aRunner.StatementType; csv.WriteRecord(queryLine); csv.Flush(); } totalRunning += theRunners.Count(); count += 50; } Console.WriteLine($"Finished with {totalRunning} running"); Console.WriteLine($"Sleeping for 1 min"); Console.WriteLine("----------------------------------------------------"); Console.WriteLine(""); System.Threading.Thread.Sleep(15000); } } } Console.ReadKey(); }
public static void Example() { // Create an Amazon Athena client var athenaConfig = new AmazonAthenaConfig { RegionEndpoint = RegionEndpoint.USEast1, Timeout = TimeSpan.FromMilliseconds(ExampleConstants.CLIENT_EXECUTION_TIMEOUT) }; var athenaClient = new AmazonAthenaClient(config: athenaConfig); // Build the request var ListQueryExecutionsRequest = new ListQueryExecutionsRequest(); // Get the list results. var ListQueryExecutionsResponse = athenaClient.ListQueryExecutions(ListQueryExecutionsRequest); // Process the results. bool hasMoreResults = true; while (hasMoreResults) { var queryExecutionIds = ListQueryExecutionsResponse.QueryExecutionIds; // process query execution IDs // If nextToken is not null, there are more results. Get the next page of results. if (!String.IsNullOrEmpty(ListQueryExecutionsResponse.NextToken)) { ListQueryExecutionsRequest.NextToken = ListQueryExecutionsResponse.NextToken; ListQueryExecutionsResponse = athenaClient.ListQueryExecutions(ListQueryExecutionsRequest); } else { hasMoreResults = false; } } }