public DistributedHashTableStorageHost(
            Uri master,
            string name,
            int port)
        {
            Endpoint = new NodeEndpoint
            {
                Sync  = new Uri("rhino.dht://" + Environment.MachineName + ":" + port + "/"),
                Async = new Uri("rhino.queues://" + Environment.MachineName + ":" + (port + 1) + "/replication")
            };
            queueManager = new QueueManager(new IPEndPoint(IPAddress.Any, port + 1), name + ".queue.esent");
            queueManager.CreateQueues("replication");
            node = new DistributedHashTableNode(
                new DistributedHashTableMasterClient(master),
                new ThreadPoolExecuter(),
                new BinaryMessageSerializer(),
                Endpoint,
                queueManager,
                new NonPooledDistributedHashTableNodeFactory()
                );
            var dhtStorage = new DistributedHashTableStorage(name + ".data.esent", node);

            replication = dhtStorage.Replication;
            storage     = dhtStorage;

            listener = new TcpListener(
                Socket.OSSupportsIPv6 ? IPAddress.IPv6Any : IPAddress.Any,
                port);
        }
        public DistributedHashTableStorageHost(
            Uri master,
            string name,
            int port)
        {
            Endpoint = new NodeEndpoint
            {
                Sync = new Uri("rhino.dht://" + Environment.MachineName + ":" + port + "/"),
                Async = new Uri("rhino.queues://" + Environment.MachineName + ":" + (port + 1) + "/replication")
            };
            queueManager = new QueueManager(new IPEndPoint(IPAddress.Any, port + 1), name + ".queue.esent");
            queueManager.CreateQueues("replication");
            node = new DistributedHashTableNode(
                new DistributedHashTableMasterClient(master),
                new ThreadPoolExecuter(),
                new BinaryMessageSerializer(),
                Endpoint,
                queueManager,
                new NonPooledDistributedHashTableNodeFactory()
                );
            var dhtStorage = new DistributedHashTableStorage(name + ".data.esent", node);
            replication = dhtStorage.Replication;
            storage = dhtStorage;

            listener = new TcpListener(
                Socket.OSSupportsIPv6 ? IPAddress.IPv6Any : IPAddress.Any,
                port);
        }
 public WhenThereAreNoKeysInTable()
 {
     node            = MockRepository.GenerateStub <IDistributedHashTableNode>();
     topologyVersion = 7;
     node.Stub(x => x.GetTopologyVersion()).Return(topologyVersion);
     distributedHashTableStorage = new DistributedHashTableStorage("test.esent",
                                                                   node);
     replication = distributedHashTableStorage.Replication;
 }
        public bool Execute()
        {
            log.DebugFormat("Replication from {0} of {1} segments for {2}", endpoint.Sync, segments.Length, type);
            var processedSegments = new List <int>();

            if (continueWorking == false)
            {
                return(false);
            }
            try
            {
                otherNode = factory.Create(endpoint);
                var segmentsToLoad = AssignAllEmptySegmentsFromEndpoint(processedSegments);
                if (continueWorking == false)
                {
                    return(false);
                }
                return(ProcessSegmentsWithData(segmentsToLoad, processedSegments) == false);
            }
            catch (Exception e)
            {
                log.Warn("Could not replicate segments for " + type, e);
                return(false);
            }
            finally
            {
                if (processedSegments.Count != segments.Length)
                {
                    try
                    {
                        var array = segments.Select(x => x.Index).Except(processedSegments).ToArray();
                        if (array.Length > 0)
                        {
                            if (log.IsWarnEnabled)
                            {
                                log.WarnFormat("Giving up replicating for {0} the {0} segments",
                                               type,
                                               array.Length);
                            }
                            node.GivingUpOn(type, array);
                        }
                    }
                    catch (Exception e)
                    {
                        log.Error("Could not tell node that we are giving up on values", e);
                    }
                }
                Completed();
            }
        }
 public WhenThereAreKeysInTable()
 {
     node            = MockRepository.GenerateStub <IDistributedHashTableNode>();
     topologyVersion = 9;
     node.Stub(x => x.GetTopologyVersion()).Return(topologyVersion);
     distributedHashTableStorage = new DistributedHashTableStorage("test.esent",
                                                                   node);
     replication = distributedHashTableStorage.Replication;
     putResult   = distributedHashTableStorage.Put(topologyVersion, new ExtendedPutRequest
     {
         Tag     = 0,
         Bytes   = new byte[] { 1 },
         Key     = "test",
         Segment = 0
     })[0];
 }
 public WhenThereAreKeysInTable()
 {
     node = MockRepository.GenerateStub<IDistributedHashTableNode>();
     topologyVersion = 9;
     node.Stub(x => x.GetTopologyVersion()).Return(topologyVersion);
     distributedHashTableStorage = new DistributedHashTableStorage("test.esent",
                                                                   node);
     replication = distributedHashTableStorage.Replication;
     putResult = distributedHashTableStorage.Put(topologyVersion, new ExtendedPutRequest
     {
         Tag = 0,
         Bytes = new byte[] {1},
         Key = "test",
         Segment = 0
     })[0];
 }
 public OnlineSegmentReplicationCommandTest()
 {
     node = MockRepository.GenerateStub<IDistributedHashTableNode>();
     replication = MockRepository.GenerateStub<IDistributedHashTableNodeReplication>();
     endpoint = NodeEndpoint.ForTest(1);
     node.Stub(x => x.Endpoint).Return(NodeEndpoint.ForTest(2));
     storage = MockRepository.GenerateStub<IDistributedHashTableStorage>();
     node.Storage = storage;
     node.Stub(x => x.GetTopologyVersion()).Return(topologyVersion);
     var factory = MockRepository.GenerateStub<IDistributedHashTableNodeReplicationFactory>();
     factory.Stub(x => x.Create(null)).IgnoreArguments().Return(replication);
     command = new OnlineSegmentReplicationCommand(
         endpoint,
         new[] { new Segment { Index = 0 }, new Segment { Index = 1 }, },
         ReplicationType.Ownership,
         node,
         factory);
 }
Exemplo n.º 8
0
        public OnlineSegmentReplicationCommandTest()
        {
            node        = MockRepository.GenerateStub <IDistributedHashTableNode>();
            replication = MockRepository.GenerateStub <IDistributedHashTableNodeReplication>();
            endpoint    = NodeEndpoint.ForTest(1);
            node.Stub(x => x.Endpoint).Return(NodeEndpoint.ForTest(2));
            storage      = MockRepository.GenerateStub <IDistributedHashTableStorage>();
            node.Storage = storage;
            node.Stub(x => x.GetTopologyVersion()).Return(topologyVersion);
            var factory = MockRepository.GenerateStub <IDistributedHashTableNodeReplicationFactory>();

            factory.Stub(x => x.Create(null)).IgnoreArguments().Return(replication);
            command = new OnlineSegmentReplicationCommand(
                endpoint,
                new[] { new Segment {
                            Index = 0
                        }, new Segment {
                            Index = 1
                        }, },
                ReplicationType.Ownership,
                node,
                factory);
        }
 public WhenThereAreNoKeysInTable()
 {
     node = MockRepository.GenerateStub<IDistributedHashTableNode>();
     topologyVersion = 7;
     node.Stub(x => x.GetTopologyVersion()).Return(topologyVersion);
     distributedHashTableStorage = new DistributedHashTableStorage("test.esent",
                                                                   node);
     replication = distributedHashTableStorage.Replication;
 }