Ejemplo n.º 1
0
        public List <CloudBlobContainer> GetSecondaryContainers()
        {
            List <CloudBlobContainer> result = new List <CloudBlobContainer>();

            SecondaryServers.ForEach(s => result.Add(ConfigurationLookup.GetCloudBlobContainer(s, this.Name)));
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Removed already registered servers in session states if they don't exist anymore (because of some reconfiguration).
        /// </summary>
        private void garbageCollectOldServersFromSessionState()
        {
            List <string> allServers = new List <string>();

            PrimaryServers.ForEach(o => allServers.Add(o));
            SecondaryServers.ForEach(o => allServers.Add(o));

            //State.UnregisterOldServers(allServers);
        }
        public override string ToString()
        {
            string result;

            result  = "Container: " + this.Name;
            result += " Primaries: ";
            PrimaryServers.ForEach(e => result += e + ",");
            result += " Secondaries: ";
            SecondaryServers.ForEach(e => result += e + ",");
            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns the list of servers that do not replicate this container.
        /// </summary>
        /// <returns></returns>
        public List <string> GetNoReplicaServers()
        {
            List <string> result = new List <string>();

            foreach (string server in ConfigurationLookup.AllServers)
            {
                if ((!PrimaryServers.Contains(server)) && (!SecondaryServers.Contains(server)))
                {
                    result.Add(server);
                }
            }
            return(result);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Periodically refresh the configuration.
        /// </summary>
        private void RefreshConfigurationPeriodically()
        {
            try
            {
                Stopwatch          w = new Stopwatch();
                CloudBlobContainer configurationContainer = GetConfigurationContainer();
                ICloudBlob         blob = configurationContainer.GetBlockBlobReference(ConstPool.CURRENT_CONFIGURATION_BLOB_NAME);


                while (true)
                {
                    while (!blob.Exists())
                    {
                        Console.WriteLine("Configuration blob is null for " + this.Name);
                        Thread.Sleep(ConstPool.CACHED_CONFIGURATION_VALIDITY_DURATION);
                    }

                    int oldEpoch = Epoch;
                    Epoch = -1;
                    w.Restart();

                    blob.FetchAttributes();
                    int newEpoch = Convert.ToInt32(blob.Metadata[ConstPool.EPOCH_NUMBER]);
                    if (newEpoch > 0)
                    {
                        if (newEpoch != oldEpoch)
                        {
                            //foreach (ConsistencySLAEngine engine in CapCloudBlobClient.slaEngines[this.Name])
                            //{
                            //    engine.Sla.ResetHitsAndMisses();
                            //}
                            ReadConfiguration();

                            Console.WriteLine("New configuration for Epoch " + newEpoch + " is primaries: " + String.Join(", ", PrimaryServers.ToList()) + " secondaries:" + String.Join(", ", SecondaryServers.ToList()));
                        }
                        Epoch = newEpoch;

                        w.Stop();
                        if (ConstPool.CACHED_CONFIGURATION_VALIDITY_DURATION - Convert.ToInt32(w.ElapsedMilliseconds) > 0)
                        {
                            Thread.Sleep(ConstPool.CACHED_CONFIGURATION_VALIDITY_DURATION - Convert.ToInt32(w.ElapsedMilliseconds));
                        }

                        lock (this)
                            Monitor.PulseAll(this);
                    }
                    else
                    {
                        //Cached Configuration is changing, we need to wait for the meantime.
                        Thread.Sleep(ConstPool.CONFIGURATION_ACTION_DURATION);
                    }
                }
            }
            catch (StorageException ex)
            {
                Console.WriteLine(ex.ToString());
                throw ex;
            }
            catch (Exception exx)
            {
                Console.WriteLine(exx.ToString());
                throw exx;
            }
        }