public void Batch(Action <PersistentHashTableActions> action) { if (versionGenerator == null) { throw new InvalidOperationException("The PHT was not initialized. Did you forgot to call table.Initialize(); ?"); } for (int i = 0; i < 5; i++) { try { using (var pht = new PersistentHashTableActions( instance, database, HttpRuntime.Cache, Id, versionGenerator, keysColumns, listColumns, replicationColumns, replicationRemovalColumns, dataColumns)) { action(pht); } return; } // if we run into a write conflict, we will wait a bit and then retry catch (EsentErrorException e) { if (e.Error != JET_err.WriteConflict) { throw; } Thread.Sleep(10); } } }
public void Batch(Action<PersistentHashTableActions> action) { using (var pht = new PersistentHashTableActions(instance, database, HttpRuntime.Cache, Id)) { action(pht); } }
private static void RegisterRemovalForReplication(RemoveRequest request, PersistentHashTableActions actions, ValueVersion version) { foreach (var hash in actions.GetReplicationHashes(request.Key, version)) { actions.AddReplicationRemovalInfo( request.Key, version, hash ); } }
private static void AssertSegmentNotMoved(PersistentHashTableActions actions, int? segment) { if(segment < 0) throw new ArgumentNullException("segment", "Segment cannot be negative"); var values = actions.Get(new GetRequest { Key = Constants.MovedSegment + segment }); if(values.Length>0) { throw new SeeOtherException("This key belongs to a segment assigned to another node") { Endpoint = NodeEndpoint.FromBytes(values[0].Data) }; } }
public void Batch(Action<PersistentHashTableActions> action) { if (versionGenerator == null) throw new InvalidOperationException("The PHT was not initialized. Did you forgot to call table.Initialize(); ?"); for (int i = 0; i < 5; i++) { try { using (var pht = new PersistentHashTableActions( instance, database, HttpRuntime.Cache, Id, versionGenerator, keysColumns, listColumns, replicationColumns, replicationRemovalColumns, dataColumns)) { action(pht); } return; } // if we run into a write conflict, we will wait a bit and then retry catch (EsentErrorException e) { if (e.Error != JET_err.WriteConflict) throw; Thread.Sleep(10); } } }
private static bool MarkSegmentAsAssignedToEndpoint(PersistentHashTableActions actions, NodeEndpoint endpoint, int segment) { var result = actions.Put(new PutRequest { Key = Constants.MovedSegment + segment, OptimisticConcurrency = true, Bytes = endpoint.ToBytes(), }); return result.ConflictExists == false; }