コード例 #1
0
        internal async Task <bool> RebuildTokenMapAsync(bool retry)
        {
            var currentCounter = Interlocked.Read(ref _counterRebuild);

            Metadata.Logger.Info("Retrieving keyspaces metadata");
            // running this statement synchronously inside the exclusive scheduler deadlocks
            var ksList = await _schemaParser.GetKeyspaces(retry).ConfigureAwait(false);

            var task = _tokenMapTaskFactory.StartNew(() =>
            {
                if (!RebuildNecessary(currentCounter))
                {
                    return(true);
                }

                Metadata.Logger.Info("Updating keyspaces metadata");
                var ksMap  = ksList.Select(ks => new KeyValuePair <string, KeyspaceMetadata>(ks.Name, ks));
                _keyspaces = new ConcurrentDictionary <string, KeyspaceMetadata>(ksMap);
                Metadata.Logger.Info("Rebuilding token map");
                if (Partitioner == null)
                {
                    throw new DriverInternalError("Partitioner can not be null");
                }

                _tokenMap = TokenMap.Build(Partitioner, Hosts.ToCollection(), _keyspaces.Values);
                return(true);
            });

            return(await task.ConfigureAwait(false));
        }
コード例 #2
0
ファイル: Metadata.cs プロジェクト: panuoksala/csharp-driver
        internal async Task RebuildTokenMapAsync(bool retry, bool fetchKeyspaces)
        {
            IEnumerable <KeyspaceMetadata> ksList = null;

            if (fetchKeyspaces)
            {
                Metadata.Logger.Info("Retrieving keyspaces metadata");
                ksList = await _schemaParser.GetKeyspacesAsync(retry).ConfigureAwait(false);
            }

            ConcurrentDictionary <string, KeyspaceMetadata> keyspaces;

            if (ksList != null)
            {
                Metadata.Logger.Info("Updating keyspaces metadata");
                var ksMap = ksList.Select(ks => new KeyValuePair <string, KeyspaceMetadata>(ks.Name, ks));
                keyspaces = new ConcurrentDictionary <string, KeyspaceMetadata>(ksMap);
            }
            else
            {
                keyspaces = _keyspaces;
            }

            Metadata.Logger.Info("Rebuilding token map");
            if (Partitioner == null)
            {
                throw new DriverInternalError("Partitioner can not be null");
            }

            var tokenMap = TokenMap.Build(Partitioner, Hosts.ToCollection(), keyspaces.Values);

            _keyspaces = keyspaces;
            _tokenMap  = tokenMap;
        }
コード例 #3
0
 internal void RebuildTokenMap()
 {
     Logger.Info("Rebuilding token map");
     if (Partitioner == null)
     {
         throw new DriverInternalError("Partitioner can not be null");
     }
     _tokenMap = TokenMap.Build(Partitioner, Hosts.ToCollection(), _keyspaces.Values);
 }
コード例 #4
0
 internal void RebuildTokenMap()
 {
     if (!Configuration.Policies.LoadBalancingPolicy.RequiresTokenMap)
     {
         Logger.Info("Skip rebuilding token map");
         return;
     }
     Logger.Info("Rebuilding token map");
     if (Partitioner == null)
     {
         throw new DriverInternalError("Partitioner can not be null");
     }
     _tokenMap = TokenMap.Build(Partitioner, Hosts.ToCollection(), _keyspaces.Values);
 }
コード例 #5
0
 internal void RebuildTokenMap(string partitioner, Dictionary <IPAddress, DictSet <string> > allTokens)
 {
     this._tokenMap = TokenMap.Build(partitioner, allTokens);
 }
コード例 #6
0
 internal void RebuildTokenMap(string partitioner, Dictionary <IPEndPoint, HashSet <string> > allTokens)
 {
     _tokenMap = TokenMap.Build(partitioner, allTokens);
 }