Exemplo n.º 1
0
        internal static Dictionary <string, AttributeValue> GetValues(UnitTestDynamoDBTableData data, bool includeKeys = false)
        {
            var values = new Dictionary <string, AttributeValue>();

            if (!string.IsNullOrWhiteSpace(data.StringData))
            {
                values.Add("StringData", new AttributeValue(data.StringData));
            }
            if (data.BinaryData != null && data.BinaryData.Length > 0)
            {
                values.Add("BinaryData", new AttributeValue {
                    B = new MemoryStream(data.BinaryData)
                });
            }

            if (includeKeys)
            {
                values.Add("PartitionKey", new AttributeValue(data.PartitionKey));
                values.Add("RowKey", new AttributeValue(data.RowKey));
            }

            values.Add("ETag", new AttributeValue {
                N = data.ETag.ToString()
            });
            return(values);
        }
Exemplo n.º 2
0
        private void WriteAlot_Async(string testName, int numPartitions, int iterations, int batchSize)
        {
            output.WriteLine("Iterations={0}, Batch={1}, Partitions={2}", iterations, batchSize, numPartitions);
            List <Task> promises = new List <Task>();
            Stopwatch   sw       = Stopwatch.StartNew();

            for (int i = 0; i < iterations; i++)
            {
                string partitionKey = PartitionKey;
                if (numPartitions > 1)
                {
                    partitionKey += (i % numPartitions);
                }
                string rowKey = i.ToString(CultureInfo.InvariantCulture);

                UnitTestDynamoDBTableData dataObject = new UnitTestDynamoDBTableData();
                dataObject.PartitionKey = partitionKey;
                dataObject.RowKey       = rowKey;
                dataObject.StringData   = rowKey;
                var promise = manager.UpsertEntryAsync(UnitTestDynamoDBStorage.INSTANCE_TABLE_NAME, DynamoDBStorageTests.GetKeys(dataObject), DynamoDBStorageTests.GetValues(dataObject));
                promises.Add(promise);
                if ((i % batchSize) == 0 && i > 0)
                {
                    Task.WhenAll(promises);
                    promises.Clear();
                    output.WriteLine("{0} has written {1} rows in {2} at {3} RPS",
                                     testName, i, sw.Elapsed, i / sw.Elapsed.TotalSeconds);
                }
            }
            Task.WhenAll(promises);
            sw.Stop();
            output.WriteLine("{0} completed. Wrote {1} entries to {2} partition(s) in {3} at {4} RPS",
                             testName, iterations, numPartitions, sw.Elapsed, iterations / sw.Elapsed.TotalSeconds);
        }
Exemplo n.º 3
0
        internal static Dictionary <string, AttributeValue> GetKeys(UnitTestDynamoDBTableData data)
        {
            var keys = new Dictionary <string, AttributeValue>();

            keys.Add("PartitionKey", new AttributeValue(data.PartitionKey));
            keys.Add("RowKey", new AttributeValue(data.RowKey));
            return(keys);
        }