Ejemplo n.º 1
0
        private static string ResolveTopic([NotNull] Type taskType, [NotNull] string taskName, bool taskTopicIsRequired)
        {
            var taskTopic = taskType.TryGetTaskTopic(taskTopicIsRequired);

            if (!string.IsNullOrWhiteSpace(taskTopic))
            {
                return(taskTopic);
            }
            return(ShardingHelpers.GetShard(taskName.GetPersistentHashCode(), topicsCount).ToString(CultureInfo.InvariantCulture));
        }
        private ColumnAddress GetColumnAddress([NotNull] BlobId id)
        {
            var timeGuid = id.Id;

            switch (id.Type)
            {
            case BlobType.Regular:
                var ticks = timeGuid.GetTimestamp().Ticks;
                return(new ColumnAddress
                {
                    CfName = settings.RegularBlobsCfName,
                    RowKey = string.Format("{0}_{1}", ticks / TimeBasedBlobStorageSettings.TickPartition, ShardingHelpers.GetShard(timeGuid.GetHashCode(), TimeBasedBlobStorageSettings.SplittingFactor)),
                    ColumnName = string.Format("{0}_{1}", ticks.ToString("D20", CultureInfo.InvariantCulture), timeGuid.ToGuid()),
                });

            case BlobType.Large:
                return(new ColumnAddress
                {
                    CfName = settings.LargeBlobsCfName,
                    RowKey = timeGuid.ToGuid().ToString(),
                    ColumnName = largeBlobColumnName,
                });

            default:
                throw new InvalidOperationException(string.Format("Invalid BlobType in id: {0}", id));
            }
        }