예제 #1
0
 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 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);
        }
예제 #3
0
        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)
                      };
            }
        }