예제 #1
0
        private void UpdatePartition(IEnumerable <ReplicaInformation> rps)
        {
            if (!rps.Any())
            {
                return;
            }
            var pid    = rps.First().PartitionId;
            var oldset = m_replicaList[pid];
            var newset = rps.ToList();

            foreach (var r in newset.Except(oldset))
            {
                Log.WriteLine("{0}", $"{nameof(CloudIndex)}: {r.Address}:{r.Port} ({r.Id}) added to partition {r.PartitionId}");
                IStorage storage = null;
                if (r.Id == m_nameservice.InstanceId)
                {
                    storage = Global.LocalStorage;
                }
                else
                {
                    storage = new DynamicRemoteStorage(r, TrinityConfig.ClientMaxConn, m_mc);
                }
                SetStorage(r.Id, storage);
            }
            foreach (var r in oldset.Except(newset))
            {
                Log.WriteLine("{0}", $"{nameof(CloudIndex)}: {r.Address}:{r.Port} ({r.Id}) removed from partition {r.PartitionId}");
                SetStorage(r.Id, null);
                SetChunks(r.Id, null);
                if (m_nameservice.IsMaster && m_nameservice.PartitionId == r.PartitionId)
                {
                    m_chunktable.DeleteEntry(r.Id);
                }
            }
            m_replicaList[pid] = newset;
        }
예제 #2
0
 internal void OnStorageJoin(DynamicRemoteStorage remoteStorage)
 {
     CheckServerProtocolSignatures(remoteStorage);
     m_storageTable.AddInstance(GetInstanceId(remoteStorage.ReplicaInformation.Id), remoteStorage);
     Log.WriteLine($"{nameof(DynamicCluster)}: Connected to '{remoteStorage.NickName}' ({remoteStorage.ReplicaInformation.Id})");
 }
예제 #3
0
        private void CheckServerProtocolSignatures(DynamicRemoteStorage rs)
        {
            Log.WriteLine(LogLevel.Debug, $"Checking protocol signatures with '{rs.NickName}' ({rs.ReplicaInformation})...");

            CheckProtocolSignatures_impl(rs, m_cluster_config.RunningMode, RunningMode.Server);
        }