Esempio n. 1
0
        protected Node(NodeInfo identity, NodeConfiguration config)
        {
            Logger         = config.LoggerDelegate;
            SeedNode       = config.SeedNode;
            SuccessorCount = config.SuccessorCount;
            Serializer     = config.Serializer;
            Marshaller     = new NodeMarshaller(Serializer, config.HashingService);
            MessageBus     = new MemoryBus(); // We can change the publishing strategy factory so we can log everything...
            InitHandlers();
            Identity           = identity;
            Successor          = identity;
            Predecessor        = null;
            SocketFactory      = config.NodeSocketFactory;
            HashingService     = config.HashingService;
            CorrelationFactory = config.CorrelationFactory;
            Clock   = config.Clock;
            Janitor = new DisposableStack();

            Poller          = Janitor.Push(new NetMQPoller());
            InitTimer       = CreateInitTimer();
            ListeningSocket = Janitor.Push(SocketFactory.CreateBindingSocket(Identity.HostAndPort));
            InitListeningSocket();
            ForwardingSockets  = Janitor.Push(new SocketCache(SocketFactory, Clock));
            Actor              = Janitor.Push(CreateActor());
            InitTimer.Elapsed += (sender, args) =>
            {
                Publish(new NodeReady(Identity.RoutingHash));
            };
            FingerTable    = new FingerTable(Identity, Identity.RoutingHash.BitCount);
            SuccessorTable = new SuccessorTable(Identity, config.SuccessorCount);
        }