示例#1
0
文件: View.cs 项目: farukc/rtable
        public static View InitFromConfigVer2(string name, ReplicatedTableConfigurationStore configurationStore, Action<ReplicaInfo> SetConnectionString)
        {
            View view = new View(name);

            if (configurationStore != null)
            {
                view.ViewId = configurationStore.ViewId;

                foreach (ReplicaInfo replica in configurationStore.GetCurrentReplicaChain())
                {
                    SetConnectionString(replica);

                    CloudTableClient tableClient = ReplicatedTableConfigurationManager.GetTableClientForReplica(replica);
                    if (tableClient != null)
                    {
                        view.Chain.Add(new Tuple<ReplicaInfo, CloudTableClient>(replica, tableClient));
                    }
                }

                // Infered: first readable replica
                view.ReadHeadIndex = view.Chain.FindIndex(tuple => tuple.Item1.IsReadable());
            }

            return view;
        }
示例#2
0
文件: View.cs 项目: farukc/rtable
        public static View InitFromConfigVer1(string name, ReplicatedTableConfigurationStore configurationStore, Action<ReplicaInfo> SetConnectionString)
        {
            View view = new View(name);

            if (configurationStore != null)
            {
                view.ViewId = configurationStore.ViewId;
                view.ReadHeadIndex = configurationStore.ReadViewHeadIndex;

                foreach (ReplicaInfo replica in configurationStore.ReplicaChain)
                {
                    SetConnectionString(replica);

                    CloudTableClient tableClient = ReplicatedTableConfigurationManager.GetTableClientForReplica(replica);
                    if (replica != null && tableClient != null)
                    {
                        view.Chain.Add(new Tuple<ReplicaInfo, CloudTableClient>(replica, tableClient));
                    }
                }

                if (!view.IsEmpty)
                {
                    ReplicaInfo head = view.GetReplicaInfo(0);
                    head.Status = ReplicaStatus.WriteOnly;

                    if (view.IsStable)
                    {
                        head.Status = ReplicaStatus.ReadWrite;
                    }
                }
            }

            return view;
        }