示例#1
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));
        }
示例#2
0
 public DxStoreStateMachine(Policy policy, DxStoreInstance instance, INodeEndPoints <ServiceEndpoint> nodeEndPoints, IStorage <string, DxStoreCommand> storage, GroupMembersMesh mesh, Counters perfCounter, Round <string>?roundInitial) : base(nodeEndPoints, mesh, storage, policy, null, perfCounter, roundInitial)
 {
     this.instance       = instance;
     this.self           = nodeEndPoints.Self;
     this.localDataStore = instance.LocalDataStore;
     this.Mesh           = mesh;
     this.truncator      = new PeriodicPaxosTrancator(instance);
 }