public void LoadTestAddPointMapping() { try { ShardMapManager smm = ShardMapManagerFactory.GetSqlShardMapManager( Globals.ShardMapManagerConnectionString, ShardMapManagerLoadPolicy.Lazy); ListShardMap <int> lsm = smm.GetListShardMap <int>(ShardMapManagerLoadTests.s_listShardMapName); Assert.IsNotNull(lsm); do { // Chose a random shard to add mapping. Shard s = GetRandomOnlineShardFromShardMap((ShardMap)lsm); if (s == null) { continue; } // Create a random integer key for a new mapping and verify that its not already present in this shard map. int key = _r.Next(MinMappingPoint, MaxMappingPoint); PointMapping <int> pExisting = null; // choose different mapping if this one already exists. if (lsm.TryGetMappingForKey(key, out pExisting)) { continue; } Debug.WriteLine("Trying to add point mapping for key {0} to shard location {1}", key, s.Location); PointMapping <int> p1 = lsm.CreatePointMapping(key, s); Assert.IsNotNull(p1); // Validate mapping by trying to connect s_retryPolicy.ExecuteAction( () => ValidateImpl( (ShardMap)lsm, key)); }while (false); } catch (ShardManagementException sme) { Debug.WriteLine("Exception caught: {0}", sme.Message); } }
/// <summary> /// Performs the store operation. /// </summary> /// <returns>Results of the operation.</returns> public IStoreResults Do() { try { return(_retryPolicy.ExecuteAction(() => { IStoreResults r; try { // Open connection. this.EstablishConnnection(); using (IStoreTransactionScope ts = this.GetTransactionScope()) { r = this.DoLocalExecute(ts); ts.Success = r.Result == StoreResult.Success; } if (r.Result != StoreResult.Success) { this.HandleDoLocalExecuteError(r); } return r; } finally { // Close connection. this.TeardownConnection(); } })); } catch (StoreException se) { throw this.OnStoreException(se); } }
/// <summary> /// Performs the store operation. /// </summary> /// <returns>Results of the operation.</returns> public IStoreResults Do() { IStoreResults result; try { do { result = _retryPolicy.ExecuteAction(() => { IStoreResults r; try { // Open connection. this.EstablishConnnection(); using (IStoreTransactionScope ts = this.GetTransactionScope()) { r = this.DoGlobalExecute(ts); ts.Success = r.Result == StoreResult.Success; } if (!r.StoreOperations.Any()) { if (r.Result != StoreResult.Success) { this.DoGlobalUpdateCachePre(r); this.HandleDoGlobalExecuteError(r); } this.DoGlobalUpdateCachePost(r); } return(r); } finally { // Close connection. this.TeardownConnection(); } }); // If pending operation, deserialize the pending operation and perform Undo. if (result.StoreOperations.Any()) { Debug.Assert(result.StoreOperations.Count() == 1); this.UndoPendingStoreOperations(result.StoreOperations.Single()); } }while (result.StoreOperations.Any()); } catch (StoreException se) { throw this.OnStoreException(se); } Debug.Assert(result != null); return(result); }