Exemplo n.º 1
0
        public PaxosBasicInfo GetPaxosInfo()
        {
            PaxosBasicInfo paxosBasicInfo = new PaxosBasicInfo();

            paxosBasicInfo.CountExecuted = base.CountExecuted;
            if (base.Paxos == null)
            {
                return(paxosBasicInfo);
            }
            Paxos <string, DxStoreCommand> paxos = base.Paxos;

            paxosBasicInfo.Self           = paxos.Self;
            paxosBasicInfo.LeaderHint     = paxos.LeaderRoundHint;
            paxosBasicInfo.CountTruncated = paxos.Storage.CountTruncated;
            if (paxos.ConfigurationHint != null && paxos.ConfigurationHint.Acceptors != null)
            {
                paxosBasicInfo.Members = paxos.ConfigurationHint.Acceptors.ToArray <string>();
            }
            if (paxos.GossipByNode != null)
            {
                paxosBasicInfo.Gossip = new PaxosBasicInfo.GossipDictionary();
                foreach (KeyValuePair <string, int> keyValuePair in paxos.CountDecidedByNode)
                {
                    paxosBasicInfo.Gossip[keyValuePair.Key] = keyValuePair.Value;
                }
            }
            return(paxosBasicInfo);
        }
Exemplo n.º 2
0
        private DxStoreStateMachine CreateStateMachine(Round <string>?leaderHint, PaxosBasicInfo referencePaxos)
        {
            Policy policy = new Policy
            {
                DebugName = this.GroupConfig.Self
            };
            bool flag = false;

            string[] array = (from m in this.GroupConfig.Members
                              select m.Name).ToArray <string>();
            if (referencePaxos != null && referencePaxos.IsMember(this.GroupConfig.Self))
            {
                array = referencePaxos.Members;
                flag  = true;
            }
            IDxStoreEventLogger eventLogger = this.EventLogger;
            DxEventSeverity     severity    = DxEventSeverity.Info;
            int    id           = 0;
            string formatString = "{0}: Creating state machine with membership '{1}' (IsUsingReferencePaxos: {2}, IsReferencePaxosLeader: {3}, GroupConfig.Members: {4}";

            object[] array2 = new object[5];
            array2[0] = this.GroupConfig.Identity;
            array2[1] = array.JoinWithComma("<null>");
            array2[2] = flag;
            array2[3] = (flag ? referencePaxos.IsLeader.ToString() : "<unknown>");
            array2[4] = (from m in this.GroupConfig.Members
                         select m.Name).JoinWithComma("<null>");
            eventLogger.Log(severity, id, formatString, array2);
            Dictionary <string, ServiceEndpoint> membersInstanceClientEndPoints = this.GetMembersInstanceClientEndPoints(array);
            NodeEndPointsBase <ServiceEndpoint>  nodeEndPointsBase = new NodeEndPointsBase <ServiceEndpoint>(this.GroupConfig.Self, membersInstanceClientEndPoints);

            this.PerfCounters = new Counters(this.GroupConfig.Identity);
            Configuration <string> configuration = new Configuration <string>(nodeEndPointsBase.Nodes, nodeEndPointsBase.Nodes, nodeEndPointsBase.Nodes, null);
            GroupMembersMesh       mesh          = new GroupMembersMesh(this.Identity, nodeEndPointsBase, this.GroupConfig);
            EsentStorage <string, DxStoreCommand> esentStorage = new EsentStorage <string, DxStoreCommand>(this.GroupConfig.Settings.PaxosStorageDir, this.PerfCounters, null, null, true);

            esentStorage.TryInitialize(configuration);
            return(new DxStoreStateMachine(policy, this, nodeEndPointsBase, esentStorage, mesh, this.PerfCounters, leaderHint));
        }