private static List <string> GetActiveSilos(ISiloStatusOracle siloStatusOracle, ConcurrentDictionary <SiloAddress, bool> immatureSilos)
        {
            var activeSiloNames = new List <string>();

            foreach (var kvp in siloStatusOracle.GetApproximateSiloStatuses(true))
            {
                bool immatureBit;
                if (!(immatureSilos.TryGetValue(kvp.Key, out immatureBit) && immatureBit)) // if not immature now or any more
                {
                    string siloName;
                    if (siloStatusOracle.TryGetSiloName(kvp.Key, out siloName))
                    {
                        activeSiloNames.Add(siloName);
                    }
                }
            }
            return(activeSiloNames);
        }
        private static HashSet <QueueId> GetQueuesOfImmatureSilos(ISiloStatusOracle siloStatusOracle,
                                                                  ConcurrentDictionary <SiloAddress, bool> immatureSilos,
                                                                  Dictionary <string, List <QueueId> > idealDistribution)
        {
            HashSet <QueueId> queuesOfImmatureSilos = new HashSet <QueueId>();

            foreach (var silo in immatureSilos.Where(s => s.Value)) // take only those from immature set that have their immature status bit set
            {
                string siloName;
                if (siloStatusOracle.TryGetSiloName(silo.Key, out siloName))
                {
                    List <QueueId> queues;
                    if (idealDistribution.TryGetValue(siloName, out queues))
                    {
                        queuesOfImmatureSilos.UnionWith(queues);
                    }
                }
            }
            return(queuesOfImmatureSilos);
        }
        /// <summary>
        /// Updates active silo names if necessary
        /// if silo is active and name is not in active list, add it.
        /// if silo is inactive and name is in active list, remove it.
        /// </summary>
        /// <param name="updatedSilo"></param>
        /// <param name="status"></param>
        /// <returns>bool, true if active silo names changed</returns>
        private bool UpdateActiveSilos(SiloAddress updatedSilo, SiloStatus status)
        {
            bool   changed = false;
            string siloName;

            // try to get silo name
            if (siloStatusOracle.TryGetSiloName(updatedSilo, out siloName))
            {
                if (status.Equals(SiloStatus.Active) &&   // if silo state became active
                    !activeSiloNames.Contains(siloName))  // and silo name is not currently in active silo list
                {
                    changed = true;
                    activeSiloNames.Add(siloName);            // add silo to list of active silos
                }
                else if (!status.Equals(SiloStatus.Active) && // if silo state became not active
                         activeSiloNames.Contains(siloName))  // and silo name is currently in active silo list
                {
                    changed = true;
                    activeSiloNames.Remove(siloName); // remove silo from list of active silos
                }
            }
            return(changed);
        }
 private static HashSet<QueueId> GetQueuesOfImmatureSilos(ISiloStatusOracle siloStatusOracle, 
     ConcurrentDictionary<SiloAddress, bool> immatureSilos, 
     Dictionary<string, List<QueueId>> idealDistribution)
 {
     HashSet<QueueId> queuesOfImmatureSilos = new HashSet<QueueId>();
     foreach (var silo in immatureSilos.Where(s => s.Value)) // take only those from immature set that have their immature status bit set
     {
         string siloName;
         if (siloStatusOracle.TryGetSiloName(silo.Key, out siloName))
         {
             List<QueueId> queues;
             if (idealDistribution.TryGetValue(siloName, out queues))
             {
                 queuesOfImmatureSilos.UnionWith(queues);
             }
         }
     }
     return queuesOfImmatureSilos;
 }
 private static List<string> GetActiveSilos(ISiloStatusOracle siloStatusOracle, ConcurrentDictionary<SiloAddress, bool> immatureSilos)
 {
     var activeSiloNames = new List<string>();
     foreach (var kvp in siloStatusOracle.GetApproximateSiloStatuses(true))
     {
         bool immatureBit;
         if (!(immatureSilos.TryGetValue(kvp.Key, out immatureBit) && immatureBit)) // if not immature now or any more
         {
             string siloName;
             if (siloStatusOracle.TryGetSiloName(kvp.Key, out siloName))
             {
                 activeSiloNames.Add(siloName);
             }
         }
     }
     return activeSiloNames;
 }