コード例 #1
0
        public async Task EnsureWriteThrottleAlarm(TableDescription table, GlobalSecondaryIndexDescription index, string alarmNameSuffix,
                                                   double threshold,
                                                   string snsTopicArn, bool dryRun)
        {
            var alarmName = GetAlarmName(table, index, AwsMetrics.WriteThrottleEvents, alarmNameSuffix);

            await CheckIndexAlarm(alarmName, table.TableName, index.IndexName, AwsMetrics.WriteThrottleEvents,
                                  threshold, AwsConstants.OneMinuteInSeconds, snsTopicArn, dryRun);
        }
コード例 #2
0
        public async Task EnsureReadCapacityAlarm(TableDescription table, GlobalSecondaryIndexDescription index, string alarmNameSuffix,
                                                  double thresholdFraction, string snsTopicArn, bool dryRun)
        {
            var alarmName        = GetAlarmName(table, index, AwsMetrics.ConsumedReadCapacity, alarmNameSuffix);
            var thresholdInUnits = AlarmThresholds.Calulate(index.ProvisionedThroughput.ReadCapacityUnits, thresholdFraction);

            await CheckIndexAlarm(alarmName, table.TableName, index.IndexName, AwsMetrics.ConsumedReadCapacity,
                                  thresholdInUnits, AwsConstants.FiveMinutesInSeconds, snsTopicArn, dryRun);
        }
コード例 #3
0
 internal static IEnumerable <QueryArgument> ToQueryArguments(this GlobalSecondaryIndexDescription index, IEnumerable <AttributeDefinition> attributes)
 {
     foreach (var key in index.KeySchema)
     {
         yield return(ToQueryArgument(attributes, key.AttributeName));
     }
     foreach (var attributeName in index.Projection.NonKeyAttributes)
     {
         yield return(ToQueryArgument(attributes, attributeName));
     }
 }
コード例 #4
0
 private ProvisioningReportRow GetIndexReport(TableDescription table, GlobalSecondaryIndexDescription index)
 {
     return(new ProvisioningReportRow
     {
         TableName = table.TableName,
         IndexName = index.IndexName,
         ProvisionedReadCapacityUnits = index.ProvisionedThroughput.ReadCapacityUnits,
         ProvisionedWriteCapacityUnits = index.ProvisionedThroughput.WriteCapacityUnits,
         MaxConsumedReadPerMinute = GetConsumptionMetric(table.TableName, AwsMetrics.ConsumedReadCapacity, index.IndexName),
         MaxConsumedWritePerMinute = GetConsumptionMetric(table.TableName, AwsMetrics.ConsumedWriteCapacity, index.IndexName)
     });
 }
コード例 #5
0
        private QueryRequest ToQuery(ResolveFieldContext context, string tableName, GlobalSecondaryIndexDescription index)
        {
            var arguments = context.Arguments.Select(arg => GetArgument(arg, index.KeySchema));

            return(new QueryRequest(tableName)
            {
                Select = Select.ALL_ATTRIBUTES,
                IndexName = index.IndexName,
                KeyConditionExpression = String.Join(" and ", arguments.Select(_ => $"{_.Key} = :v_{_.Key}")),
                ExpressionAttributeValues = arguments.ToDictionary(_ => $":v_{_.Key}", _ => new AttributeValue {
                    S = _.Value.ToString()
                })
            });
        }
コード例 #6
0
ファイル: DynamoDBStorage.cs プロジェクト: LiveFly/orleans
        private async Task <TableDescription> TableIndexWaitOnStatusAsync(string tableName, string indexName, IndexStatus whileStatus, IndexStatus desiredStatus = null, int delay = 2000)
        {
            TableDescription ret;
            GlobalSecondaryIndexDescription index = null;

            do
            {
                if (index != null)
                {
                    await Task.Delay(delay);
                }

                ret = await GetTableDescription(tableName);

                index = ret.GlobalSecondaryIndexes.FirstOrDefault(index => index.IndexName == indexName);
            } while (index.IndexStatus == whileStatus);

            if (desiredStatus != null && index.IndexStatus != desiredStatus)
            {
                throw new InvalidOperationException($"Index {indexName} in table {tableName} has failed to reach the desired status of {desiredStatus}");
            }

            return(ret);
        }
コード例 #7
0
        /// <summary>
        /// Tries to make up a query request from the list of conditions using a global secondary index
        /// </summary>
        internal static bool TryGetQueryFilterForGlobalSeconaryIndex(this TranslationResult translationResult, GlobalSecondaryIndexDescription indexDescription, out QueryFilter resultFilter)
        {
            resultFilter = null;

            string hashKeyFieldName = indexDescription.KeySchema.Single(ks => ks.KeyType == "HASH").AttributeName;

            Primitive hashKeyValue;

            if (!translationResult.Conditions.TryGetValueForKey(hashKeyFieldName, out hashKeyValue))
            {
                return(false);
            }
            if (hashKeyValue == null)
            {
                throw new NotSupportedException("Hash key value should not be null");
            }

            resultFilter = new QueryFilter(hashKeyFieldName, QueryOperator.Equal, hashKeyValue);

            // Copying the list of conditions. without HashKey condition, which is already matched.
            var conditions = translationResult.Conditions.ExcludeField(hashKeyFieldName);

            if (conditions.Count <= 0)
            {
                return(true);
            }

            var rangeKeyElement = indexDescription.KeySchema.SingleOrDefault(ks => ks.KeyType == "RANGE");

            if (rangeKeyElement == null)
            {
                return(false);
            }

            // first trying to search by range key
            if (TryMatchFieldWithCondition(rangeKeyElement.AttributeName, resultFilter, conditions))
            {
                return(TryPutRemainingConditionsToQueryFilter(resultFilter, conditions));
            }

            return(false);
        }
コード例 #8
0
 private static string GetAlarmName(TableDescription table, GlobalSecondaryIndexDescription index, string metricName, string alarmNameSuffix)
 {
     return($"{table.TableName}-{index.IndexName}-{metricName}-{alarmNameSuffix}");
 }