/// <summary> /// Initializes Orleans queries from the database. Orleans uses only these queries and the variables therein, nothing more. /// </summary> /// <param name="storage">The storage to use.</param> /// <returns>Orleans queries have been loaded to silo or client memory.</returns> /// <remarks>This is public only to be usable to the statistics providers. Not intended for public use otherwise.</remarks> public static async Task <QueryConstantsBag> InitializeOrleansQueriesAsync(this IRelationalStorage storage) { var queryConstants = new QueryConstantsBag(); var query = queryConstants.GetConstant(storage.InvariantName, QueryKeys.OrleansQueriesKey); var orleansQueries = await storage.ReadAsync(query, _ => { }, (selector, _) => { return(Tuple.Create(selector.GetValue <string>("QueryKey"), selector.GetValue <string>("QueryText"))); }).ConfigureAwait(continueOnCapturedContext: false); //The queries need to be added to be used later with a given key. foreach (var orleansQuery in orleansQueries) { queryConstants.AddOrModifyQueryConstant(storage.InvariantName, orleansQuery.Item1, orleansQuery.Item2); } //Check that all the required keys are loaded and throw an exception giving the keys expected but not loaded. var loadedQueriesKeys = queryConstants.GetAllConstants(storage.InvariantName).Keys; var missingQueryKeys = QueryKeys.Keys.Except(loadedQueriesKeys); if (missingQueryKeys.Any()) { throw new ArgumentException(string.Format("Not all required queries found when loading from the database. Missing are: {0}", string.Join(",", missingQueryKeys))); } return(await Task.FromResult(queryConstants)); }
/// <summary> /// Initializes Orleans queries from the database. Orleans uses only these queries and the variables therein, nothing more. /// </summary> /// <param name="storage">The storage to use.</param> /// <returns>Orleans queries have been loaded to silo or client memory.</returns> /// <remarks>This is public only to be usable to the statistics providers. Not intended for public use otherwise.</remarks> public static async Task<QueryConstantsBag> InitializeOrleansQueriesAsync(this IRelationalStorage storage) { var queryConstants = new QueryConstantsBag(); var query = queryConstants.GetConstant(storage.InvariantName, QueryKeys.OrleansQueriesKey); var orleansQueries = await storage.ReadAsync(query, _ => { }, (selector, _) => { return Tuple.Create(selector.GetValue<string>("QueryKey"), selector.GetValue<string>("QueryText")); }).ConfigureAwait(continueOnCapturedContext: false); //The queries need to be added to be used later with a given key. foreach(var orleansQuery in orleansQueries) { queryConstants.AddOrModifyQueryConstant(storage.InvariantName, orleansQuery.Item1, orleansQuery.Item2); } //Check that all the required keys are loaded and throw an exception giving the keys expected but not loaded. var loadedQueriesKeys = queryConstants.GetAllConstants(storage.InvariantName).Keys; var missingQueryKeys = QueryKeys.Keys.Except(loadedQueriesKeys); if(missingQueryKeys.Any()) { throw new ArgumentException(string.Format("Not all required queries found when loading from the database. Missing are: {0}", string.Join(",", missingQueryKeys))); } return await Task.FromResult(queryConstants); }
public Task ReportMetrics(IClientPerformanceMetrics metricsData) { if (logger != null && logger.IsVerbose3) { logger.Verbose3("SqlStatisticsPublisher.ReportMetrics (client) called with data: {0}.", metricsData); } try { var query = queryConstants.GetConstant(database.InvariantName, QueryKeys.UpsertReportClientMetricsKey); return(database.UpsertReportClientMetricsAsync(query, deploymentId, clientId, clientAddress, hostName, metricsData)); } catch (Exception ex) { if (logger != null && logger.IsVerbose) { logger.Verbose("SqlStatisticsPublisher.ReportMetrics (client) failed: {0}", ex); } throw; } }
public Task <IList <Uri> > GetGateways() { if (logger.IsVerbose3) { logger.Verbose3("SqlMembershipTable.GetGateways called."); } try { var query = queryConstants.GetConstant(database.InvariantName, QueryKeys.ActiveGatewaysQuery); return(database.ActiveGatewaysAsync(query, deploymentId)); } catch (Exception ex) { if (logger.IsVerbose) { logger.Verbose("SqlMembershipTable.Gateways failed {0}", ex); } throw; } }
public Task <ReminderTableData> ReadRows(GrainReference grainRef) { var query = queryConstants.GetConstant(database.InvariantName, QueryKeys.ReadReminderRowsKey); return(database.ReadReminderRowsAsync(query, serviceId, grainRef)); }