/// <summary>
        /// Finds a shard map from cache if requested and if necessary from global shard map.
        /// </summary>
        /// <param name="operationName">Operation name, useful for diagnostics.</param>
        /// <param name="shardMapName">Name of shard map.</param>
        /// <param name="lookInCacheFirst">Whether to skip first lookup in cache.</param>
        /// <returns>Shard map object corresponding to one being searched.</returns>
        internal ShardMap LookupShardMapByName(string operationName, string shardMapName, bool lookInCacheFirst)
        {
            IStoreShardMap ssm = null;

            if (lookInCacheFirst)
            {
                // Typical scenario will result in immediate lookup succeeding.
                ssm = this.Cache.LookupShardMapByName(shardMapName);
            }

            ShardMap shardMap;

            // Cache miss. Go to store and add entry to cache.
            if (ssm == null)
            {
                Stopwatch stopwatch = Stopwatch.StartNew();

                shardMap = this.LookupShardMapByNameInStore(operationName, shardMapName);

                stopwatch.Stop();

                Tracer.TraceInfo(TraceSourceConstants.ComponentNames.ShardMapManager,
                                 "LookupShardMapByName", "Lookup ShardMap: {0} in store complete; Duration: {1}",
                                 shardMapName, stopwatch.Elapsed);
            }
            else
            {
                shardMap = ShardMapUtils.CreateShardMapFromStoreShardMap(this, ssm);
            }

            return(shardMap);
        }
        /// <summary>
        /// Obtains all ShardMaps associated with the shard map manager.
        /// </summary>
        /// <returns>Collection of shard maps associated with the shard map manager.</returns>
        private IEnumerable <ShardMap> GetShardMapsFromStore()
        {
            IStoreResults result;

            using (IStoreOperationGlobal op = this.StoreOperationFactory.CreateGetShardMapsGlobalOperation(this, "GetShardMaps"))
            {
                result = op.Do();
            }

            return(result.StoreShardMaps
                   .Select(ssm => ShardMapUtils.CreateShardMapFromStoreShardMap(this, ssm)));
        }
        /// <summary>
        /// Finds shard map with given name in global shard map.
        /// </summary>
        /// <param name="operationName">Operation name, useful for diagnostics.</param>
        /// <param name="shardMapName">Name of shard map to search.</param>
        /// <returns>Shard map corresponding to given Id.</returns>
        private ShardMap LookupShardMapByNameInStore(string operationName, string shardMapName)
        {
            IStoreResults result;

            using (IStoreOperationGlobal op = this.StoreOperationFactory.CreateFindShardMapByNameGlobalOperation(this, operationName, shardMapName))
            {
                result = op.Do();
            }

            return(result.StoreShardMaps
                   .Select(ssm => ShardMapUtils.CreateShardMapFromStoreShardMap(this, ssm))
                   .SingleOrDefault());
        }