Exemple #1
0
 void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
 {
     if (e.Changes.OfType<RoleEnvironmentTopologyChange>().Any())
     {
         SetupReplication();
     }
 }
Exemple #2
0
        private void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
        {
            if (!e.Changes.OfType <RoleEnvironmentConfigurationSettingChange>().Any(c => c.ConfigurationSettingName == "LogDriveService.BlobPath"))
            {
                return;
            }

            try
            {
                // perform a rolling drive change
                var oldDrive = this.currentDrive;
                var newDrive = MountDrive();
                try
                {
                    ConfigureWebServer(newDrive.LocalPath);
                }
                catch (Exception)
                {
                    UnmountDrive(newDrive);
                    throw;
                }
                this.currentDrive = newDrive;
                UnmountDrive(oldDrive);
            }
            catch (Exception ex)
            {
                this.EventLog.WriteEntry(ex.ToString(), EventLogEntryType.Error);
                throw;
            }
        }
Exemple #3
0
 void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
 {
     if (e.Changes.OfType <RoleEnvironmentTopologyChange>().Any())
     {
         SetupReplication();
     }
 }
        void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
        {
            try
            {
                foreach (var item in e.Changes.OfType <RoleEnvironmentTopologyChange>())
                {
                    if (item.RoleName == RoleEnvironment.CurrentRoleInstance.Role.Name)
                    {
                        // take any action needed on instance count modification; gracefully shrink etc
                    }
                }

                foreach (var item in e.Changes.OfType <RoleEnvironmentConfigurationSettingChange>())
                {
                    if (item.ConfigurationSettingName == "MBrace.ServiceBusConnectionString" ||
                        item.ConfigurationSettingName == "MBrace.StorageConnectionString")
                    {
                        string storageConnectionString    = CloudConfigurationManager.GetSetting("MBrace.StorageConnectionString");
                        string serviceBusConnectionString = CloudConfigurationManager.GetSetting("MBrace.ServiceBusConnectionString");
                        _config = new Configuration(storageConnectionString, serviceBusConnectionString);
                        _svc.Stop();
                        _svc.Configuration = _config;
                        _svc.Start();
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("MBrace.Azure.WorkerRole RoleEnvironment_Changed unhandled exception: {0}", ex);
                throw;
            }
        }
Exemple #5
0
        private void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
        {
            // Get the list of configuration changes
            var settingChanges = e.Changes.OfType <RoleEnvironmentConfigurationSettingChange>();

            foreach (var settingChange in settingChanges)
            {
                var settingName = settingChange.ConfigurationSettingName;
                var value       = RoleEnvironment.GetConfigurationSettingValue(settingName);
                DiagnosticsHelper.TraceInformation(
                    string.Format("Setting {0} now has value {1} ",
                                  settingName,
                                  value));
            }


            // Get the list of topology changes
            var topologyChanges = e.Changes.OfType <RoleEnvironmentTopologyChange>();

            foreach (var topologyChange in topologyChanges)
            {
                var roleName = topologyChange.RoleName;
                DiagnosticsHelper.TraceInformation(
                    string.Format("Role {0} now has {1} instance(s)",
                                  roleName,
                                  RoleEnvironment.Roles[roleName].Instances.Count));
            }
        }
        void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
        {
            try
            {
                foreach (var item in e.Changes.OfType<RoleEnvironmentTopologyChange>())
                {
                    if (item.RoleName == RoleEnvironment.CurrentRoleInstance.Role.Name)
                    {
                        // take any action needed on instance count modification; gracefully shrink etc
                    }
                }

                foreach (var item in e.Changes.OfType<RoleEnvironmentConfigurationSettingChange>())
                {
                    if (item.ConfigurationSettingName == "MBrace.ServiceBusConnectionString"
                        || item.ConfigurationSettingName == "MBrace.StorageConnectionString")
                    {
                        string storageConnectionString = CloudConfigurationManager.GetSetting("MBrace.StorageConnectionString");
                        string serviceBusConnectionString = CloudConfigurationManager.GetSetting("MBrace.ServiceBusConnectionString");
                        _config = new Configuration(storageConnectionString, serviceBusConnectionString);
                        _svc.Stop();
                        _svc.Configuration = _config;
                        _svc.Start();
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("MBrace.Azure.WorkerRole RoleEnvironment_Changed unhandled exception: {0}", ex);
                throw;
            }
        }
Exemple #7
0
 // Event handler for roleenvironment changed event
 private static void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
 {
     if (WindowsAzureBlob2FileSystemSync._mainThread != null)
     {
         Trace.TraceInformation("Rolenvironment changed. Interrupting Synchronization thread that might be sleeping");
         WindowsAzureBlob2FileSystemSync._mainThread.Interrupt();
     }
 }
Exemple #8
0
 private static void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
 {
     // configure trace listener for any changes to EnableTableStorageTraceListener
     if (e.Changes.OfType <RoleEnvironmentConfigurationSettingChange>().Any(change => change.ConfigurationSettingName == "TraceEventTypeFilter"))
     {
         ConfigureTraceListener(RoleEnvironment.GetConfigurationSettingValue("TraceEventTypeFilter"));
     }
 }
Exemple #9
0
 private static void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
 {
     // configure trace listener for any changes to EnableTableStorageTraceListener
     if (e.Changes.OfType<RoleEnvironmentConfigurationSettingChange>().Any(change => change.ConfigurationSettingName == "TraceEventTypeFilter"))
     {
         ConfigureTraceListener(RoleEnvironment.GetConfigurationSettingValue("TraceEventTypeFilter"));
     }
 }
Exemple #10
0
        public static void OnChanged(object caller, RoleEnvironmentChangedEventArgs args)
        {
            var handler = Changed;

            if (handler != null)
            {
                handler(caller, args);
            }
        }
Exemple #11
0
        void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
        {
            if (!e.Changes.OfType <RoleEnvironmentTopologyChange>().Any())
            {
                return;
            }

            ValidateInstanceCount();
        }
        private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangedEventArgs e)
        {
            if (!e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
            {
                return;
            }

            InitWorkerConfiguration();
        }
Exemple #13
0
 private void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
 {
     //var settingChanges = e.Changes.OfType<RoleEnvironmentConfigurationSettingChange>();
     //if (settingChanges.Count() > 0) // Configuration setting values changed
     //{
     // Initialize all GlobalConfig values
     TFCTV.Helpers.GlobalConfig.Initialize();
     //}
 }
        private void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
        {
            var change = e.Changes
                .OfType<RoleEnvironmentConfigurationSettingChange>()
                .FirstOrDefault(c => c.ConfigurationSettingName == "StorageConnectionString");

            if (change != null)
                this.settingsBlob = GetSettingsBlockBlob();
        }
        private void OnRoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
        {
            var changes = e.Changes.OfType <RoleEnvironmentConfigurationSettingChange>();

            if (changes.Count() > 0)
            {
                StopApp();
                ActivateApp();
            }
        }
Exemple #16
0
 void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
 {
     WorkerTrace.TraceEvent(TraceEventType.Information, 18, "Role configuration has been changed. Requesting instance recycle");
     if (current != null)
     {
         current.Abandon();
     }
     Thread.Sleep(25); //waiting for logs transfer
     RoleEnvironment.RequestRecycle();
 }
 void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
 {
     // On Topology Changes to the FrontendWorkerRole --> Configure AzureWebFarm
     if (e.Changes.Any(c => c is RoleEnvironmentTopologyChange))
     {
         Trace.TraceAndLogInformation(TRACESOURCE + ":TopologyChange", "The topology has changed. Reconfiguring webfarm.");
         ClixOnAzure.WebFarmHostManager.ConfigureAzureWebFarm();
         Trace.TraceInformation(TRACESOURCE + ":TopologyChange: Azure Web Farm has been reconfigured.");
     }
 }
Exemple #18
0
 private void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
 {
     try
     {
         this.OnStart();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #19
0
        private void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
        {
            var change = e.Changes
                         .OfType <RoleEnvironmentConfigurationSettingChange>()
                         .FirstOrDefault(c => c.ConfigurationSettingName == "StorageConnectionString");

            if (change != null)
            {
                this.settingsBlob = GetSettingsBlockBlob();
            }
        }
Exemple #20
0
        /// <summary>
        /// Changed Event Handler
        /// </summary>
        /// <param name="sender">
        /// Sender of the event.
        /// </param>
        /// <param name="e">
        /// Chaning Event details
        /// </param>
        internal void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
        {
            IDictionary <string, string> newValues = ConfigChangeHandler.RetrieveNewValues(e);

            // right now we  only care about process jobs
            // if we have more properties to care about, we should iterate the dictionary
            if (newValues.ContainsKey(ProcessJobsPropertyKey))
            {
                ProcessJobs = Convert.ToBoolean(newValues[ProcessJobsPropertyKey]);
                Log.Information("Configuration change successfully applied");
            }
        }
Exemple #21
0
        private void RoleEnvironmentOnChanged(object sender, RoleEnvironmentChangedEventArgs roleEnvironmentChangedEventArgs)
        {
            var log4netChange = roleEnvironmentChangedEventArgs.Changes
                .OfType<RoleEnvironmentConfigurationSettingChange>()
                .FirstOrDefault(c => string.Equals(c.ConfigurationSettingName, "log4net", StringComparison.OrdinalIgnoreCase));
            if (log4netChange == null)
            {
                return;
            }

            ConfigureLogging();
        }
        private void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
        {
            Trace.TraceInformation("Updating instance with new configuration settings.");

            foreach (var settingChange in e.Changes.OfType <RoleEnvironmentConfigurationSettingChange>())
            {
                if (string.Equals(settingChange.ConfigurationSettingName, CustomSettingName, StringComparison.Ordinal))
                {
                    ConfigureFromSetting(CustomSettingName);
                }
            }
        }
        private void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
        {
            Trace.TraceInformation("Updating instance with new configuration settings.");

            foreach (var settingChange in e.Changes.OfType<RoleEnvironmentConfigurationSettingChange>())
            {
                if (string.Equals(settingChange.ConfigurationSettingName, CustomSettingName, StringComparison.Ordinal))
                {
                    ConfigureFromSetting(CustomSettingName);
                }
            }
        }
        private void RoleEnvironmentOnChanged(object sender, RoleEnvironmentChangedEventArgs args)
        {
            List<EnvironmentConfigurationSettingChange> changedSettings =
                args.Changes
                    .OfType<RoleEnvironmentConfigurationSettingChange>()
                    .Select(s => new EnvironmentConfigurationSettingChange(s.ConfigurationSettingName))
                    .ToList();

            if (changedSettings.Count > 0)
            {
                RaiseChanged(changedSettings);
            }
        }
Exemple #25
0
        static void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
        {
            if (!ChangesInCurrentRole(e.Changes))
            {
                return;
            }
            int serverCountDifference = RoleEnvironment.CurrentRoleInstance.Role.Instances.Count - instanceCount;

            if (serverCountDifference < 0)
            {
                RaiseServerNumberChanged(serverCountDifference);
            }
        }
Exemple #26
0
        private void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
        {
            Tracer.WriteLine("RoleEnvironmentChanged", "Information");
            log.WriteEntry("RoleEnvironmentChanged", "", GetLabel());

            bool update = false;

            foreach (RoleEnvironmentChange roleEnvironmentChange in e.Changes)
            {
                if (roleEnvironmentChange.GetType() == typeof(RoleEnvironmentConfigurationSettingChange))
                {
                    RoleEnvironmentConfigurationSettingChange change = (RoleEnvironmentConfigurationSettingChange)roleEnvironmentChange;

                    string message = string.Format("{0} = \"{1}\"", change.ConfigurationSettingName, RoleEnvironment.GetConfigurationSettingValue(change.ConfigurationSettingName));

                    Tracer.WriteLine(message, "Information");
                    log.WriteEntry("RoleEnvironmentConfigurationSettingChange", message, GetLabel());

                    switch (change.ConfigurationSettingName)
                    {
                    case TRACE_FORMAT:
                        ConfigureTraceFormat();
                        break;

                    case UPDATE_INDICATOR:
                        update = true;
                        break;

                    case DEFAULT_CONNECTION_LIMIT:
                        ConfigureDefaultConnectionLimit();
                        break;
                    }
                }
                else if (roleEnvironmentChange.GetType() == typeof(RoleEnvironmentTopologyChange))
                {
                    Tracer.WriteLine("RoleEnvironmentTopologyChange", "Information");
                    log.WriteEntry("RoleEnvironmentTopologyChange", "", GetLabel());
                }
                else
                {
                    Tracer.WriteLine("UnknownRoleEnvironmentChange", "Information");
                    log.WriteEntry("UnknownRoleEnvironmentChange", roleEnvironmentChange.GetType().ToString(), GetLabel());
                }
            }

            if (update)
            {
                DoUpdate();
            }
        }
Exemple #27
0
        private void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
        {
            Trace.TraceInformation("RoleEnvironmentChanged Event Fired");

            //// TODO: Implement
            //var changes = e.Changes
            //               .OfType<RoleEnvironmentConfigurationSettingChange>()
            //               .ToList();

            //// Service Bus Connection Strings Updated
            //if (changes.Any(c => c.ConfigurationSettingName == ""))
            //{
            //    // TODO: Close Service Bus connection and reopen with new connection string
            //}
        }
        void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
        {
            // Using WAD for tracing how the verbosity is updated
            Trace.TraceInformation("Updating instance");

            foreach (var settingChange in e.Changes.OfType <RoleEnvironmentConfigurationSettingChange>())
            {
                if (string.Equals(settingChange.ConfigurationSettingName, AzureLoggingVerbositySettingName, StringComparison.Ordinal))
                {
                    Trace.TraceInformation("Setting up listener after change");

                    this.SetupListener();
                }
            }
        }
Exemple #29
0
        /// <summary>
        /// RoleEnvironmentChanged - Called after a change has been applied to the role.
        /// NOTE: This is called AFTER RoleEnvironmentChanging is called.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">List of what has changed</param>
        private void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
        {
            // Refresh the diagnostic switches from the role config values.
            // This allows for run-time changing of the values of the switches without recycling (i.e. rebooting)
            // the role so we can turn on or off more verbose diagnostic output based on the switches we've
            // defined in ServiceConfiguration.cscfg.
            Diagnostics.GetTraceSwitchValuesFromRoleConfiguration();

            // Log the change to the logs - using Trace.WriteLine to circumvent the switches so that if the switch was
            // turned off or to a low setting like Critical, the message showing this will still go into the logs.
            //TODO: Figure out how to do this with after the change to the IUBIDiagnostics
            //Trace.WriteLine("Processor.WorkerRole::RoleEnvironmentChanged - Diagnostics switch values changed.  ConfigTrace = " +
            //                    Diagnostics.ConfigTrace.Switch.Level.ToString() + " MainTrace = " +
            //                    Diagnostics.MainTrace.Switch.Level.ToString());
        }
Exemple #30
0
        private void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
        {
            var configChanges = e.Changes
                .OfType<RoleEnvironmentConfigurationSettingChange>()
                .ToList();

            if (!configChanges.Any())
                return;

            if (configChanges.Any(c => c.ConfigurationSettingName == "TweetsPerMinute"))
            {
                Trace.TraceInformation("Role service configuration changed, updating the publish rate for role.");
                SetTweetPublishRate();
            }
        }
Exemple #31
0
        void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
        {
            // Using WAD for tracing how the verbosity is updated
            Trace.TraceInformation("Updating instance");

            foreach (var settingChange in e.Changes.OfType<RoleEnvironmentConfigurationSettingChange>())
            {
                if (string.Equals(settingChange.ConfigurationSettingName, AzureLoggingVerbositySettingName, StringComparison.Ordinal))
                {
                    Trace.TraceInformation("Setting up listener after change");

                    this.SetupListener();
                }
            }
        }
        /// <summary>
        /// Roles the environment changed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="RoleEnvironmentChangedEventArgs"/> instance containing the event data.</param>
        private void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
        {
            try
            {
                var settingChanges = e.Changes.OfType <RoleEnvironmentConfigurationSettingChange>();

                foreach (var settingChange in settingChanges)
                {
                    var message = "Setting: " + settingChange.ConfigurationSettingName;
                    //Trace.WriteLine(message, "Information");
                }
            }
            catch (Exception)
            {
            }
        }
Exemple #33
0
 void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
 {
     try
     {
         // On Topology Changes to the BackendWorkerRole --> Configure AzureWebFarm
         if (e.Changes.Any(c => c is RoleEnvironmentTopologyChange))
         {
             Trace.TraceAndLogInformation(TRACESOURCE + ":TopologyChange", "The topology has changed. Reconfiguring webfarm.");
             ClixOnAzure.WebFarmHostManager.ConfigureAzureWebFarm();
             Trace.TraceInformation(TRACESOURCE + ":TopologyChange: Azure Web Farm has been reconfigured.");
         }
     }
     catch (Exception ex)
     {
         Trace.TraceAndLogError(TRACESOURCE, " - RoleEnvironment_Changed: Error Configuring AzureWebfarm: " + ex.ToString());
         Trace.EmailTangible(TRACESOURCE, " - RoleEnvironment_Change: Error Configuring AzureWebfarm.", ex);
     }
 }
 private static void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
 {
     foreach (RoleEnvironmentChange change in e.Changes)
     {
         RoleEnvironmentTopologyChange topologyChange = change as RoleEnvironmentTopologyChange;
         if (topologyChange != null)
         {
             String roleName = topologyChange.RoleName;
             ReadOnlyCollection<RoleInstance> newInstances = RoleEnvironment.Roles[roleName].Instances;
         }
         RoleEnvironmentConfigurationSettingChange settingChange = change as RoleEnvironmentConfigurationSettingChange;
         if (settingChange != null)
         {
             String settingName = settingChange.ConfigurationSettingName;
             String newValue = RoleEnvironment.GetConfigurationSettingValue(settingName);
         }
     }
 }
        private void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
        {
            // Get the list of configuration changes
            var settingChanges = e.Changes.OfType <RoleEnvironmentConfigurationSettingChange>();

            foreach (var settingChange in settingChanges)
            {
                var settingName = settingChange.ConfigurationSettingName;
                var value       = RoleEnvironment.GetConfigurationSettingValue(settingName);
                DiagnosticsHelper.TraceInformation(
                    "Setting {0} now has value {1} ",
                    settingName,
                    value);
                if (settingName == Settings.LogVerbositySetting)
                {
                    var logLevel = Utilities.GetLogVerbosity(value);
                    if (logLevel != null)
                    {
                        if (logLevel != Settings.MongodLogLevel)
                        {
                            Settings.MongodLogLevel = logLevel;
                            DatabaseHelper.SetLogLevel(mongodPort, logLevel);
                        }
                    }
                }
                if (settingName == Settings.RecycleSetting)
                {
                    Settings.RecycleRoleOnExit = Utilities.GetRecycleFlag(RoleEnvironment.GetConfigurationSettingValue(settingName));
                }
            }


            // Get the list of topology changes
            var topologyChanges = e.Changes.OfType <RoleEnvironmentTopologyChange>();

            foreach (var topologyChange in topologyChanges)
            {
                var roleName = topologyChange.RoleName;
                DiagnosticsHelper.TraceInformation(
                    "Role {0} now has {1} instance(s)",
                    roleName,
                    RoleEnvironment.Roles[roleName].Instances.Count);
            }
        }
Exemple #36
0
        void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
        {
            //var traceSource = CreateTraceSource();
            Trace.TraceInformation("RoleEnvironment.Changed for {0}:", RoleEnvironment.CurrentRoleInstance.Id);

            foreach (RoleEnvironmentChange rec in e.Changes)
            {
                //Trace.TraceInformation(rec.ToString());
                Trace.TraceInformation(" > {0}", rec.GetType());
                RoleEnvironmentConfigurationSettingChange recsc = rec as RoleEnvironmentConfigurationSettingChange;
                Trace.TraceInformation(RoleEnvironment.GetConfigurationSettingValue(recsc.ConfigurationSettingName), "Information");
            }

            //Trace.(arg.Changes.GetType().ToString());RoleEnvironmentTopologyChange
            if (e.Changes.Any(chg => chg is RoleEnvironmentConfigurationSettingChange))
            {
                Trace.TraceInformation(RoleEnvironment.Roles.Count.ToString() + " instance count");
                RoleEnvironment.RequestRecycle();
            }
        }
Exemple #37
0
        /*
         *  In the Changed event, RoleEnvironment.CurrentRoleInstance.Role.Instances returns the target role instances,
         *  not the original role instances. If you need to know about the original instances,
         *  you can save this information when the Changing event fires and access it from the Changed event
         *  (since these events are always fired in sequence).
         */
        private void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
        {
            targetNumOfInstances = RoleEnvironment.CurrentRoleInstance.Role.Instances.Count;
            Logfile.Get(logfile).fTextout(Logging.Fontcolors.RED, "{0} > RoleEnvironmentChanged Eventhandler logging target instance count of {1} <br>", DateTime.Now.ToString(), targetNumOfInstances);
            Logfile.Get(logfile).Update();

            // The change is a downscale! Delete Mcr flag entry from db
            if (originalNumOfInstances > targetNumOfInstances)
            {
                using (IsmIoTPortalContext db = new IsmIoTPortalContext())
                {
                    try
                    {
                        // The highest role instance id was determined in the changing event
                        ImagingProcessorWorkerInstance entry = null;
                        var queryResults = db.ImagingProcessorWorkerInstances.Where(en => en.RoleInstanceId == highestRoleInstanceId);
                        if (queryResults.Count() > 0)
                        {
                            entry = queryResults.First();
                        }

                        if (lowestRoleInstanceId) // The role instance with the lowest id deletes the db entry in case of downscale.
                        {
                            Logfile.Get(logfile).fTextout(Logging.Fontcolors.RED, "{0} > Delete database entry with key {1} <br>", DateTime.Now.ToString(), highestRoleInstanceId);
                            Logfile.Get(logfile).Update();

                            // Delete entry from DB
                            db.ImagingProcessorWorkerInstances.Remove(entry);
                            db.SaveChanges();
                        }
                    }
                    catch (Exception ex)
                    {
                        Logfile.Get(logfile).fTextout(Logging.Fontcolors.RED, "{0} > Failed to delete McrInstalled flag DB entry. <br>", DateTime.Now.ToString());
                        Logfile.Get(logfile).fTextout(Logging.Fontcolors.RED, "{0} > Exception: {1} <br>", DateTime.Now.ToString(), ex.Message);
                        Logfile.Get(logfile).Update();
                        throw;
                    }
                }
            }
        }
Exemple #38
0
        /// <summary>
        /// Get updated properties
        /// </summary>
        /// <param name="changedEventArgs">
        /// Changed Event args <see cref="RoleEnvironmentChangedEventArgs"/>
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Parameter changedEventArgs cannot be null.
        /// </exception>
        public IDictionary <string, string> RetrieveNewValues(RoleEnvironmentChangedEventArgs changedEventArgs)
        {
            if (changedEventArgs == null)
            {
                throw new ArgumentNullException("changedEventArgs", "Parameter changedEventArgs cannot be null.");
            }

            IEnumerable <RoleEnvironmentConfigurationSettingChange> environmentChanges = changedEventArgs.Changes.OfType <RoleEnvironmentConfigurationSettingChange>();
            Dictionary <string, string> newKeyValues = new Dictionary <string, string>();

            foreach (RoleEnvironmentConfigurationSettingChange configurationSettingChange in environmentChanges)
            {
                foreach (string key in ExemptConfigurationItems)
                {
                    if (key == configurationSettingChange.ConfigurationSettingName)
                    {
                        newKeyValues.Add(key, ReadChangedProperty(key));
                    }
                }
            }

            return(newKeyValues);
        }
Exemple #39
0
        private void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
        {
            try
            {
                var changes = e.Changes.OfType <RoleEnvironmentConfigurationSettingChange>()
                              .Select(c => c.ConfigurationSettingName)
                              .ToList();

                if (changes.Count > 0)
                {
                    this.telemetry.TrackTrace(
                        "Configuration changes. Trigger restart",
                        SeverityLevel.Information,
                        changes.ToDictionary(name => name, name => CloudConfigurationManager.GetSetting(name)));

                    // fire and forget
                    this.RestartTrainProcessorHost();
                }
            }
            catch (Exception ex)
            {
                this.telemetry.TrackException(ex);
            }
        }
Exemple #40
0
        void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
        {
            foreach (var item in e.Changes.OfType<RoleEnvironmentTopologyChange>())
            {
                if (item.RoleName == RoleEnvironment.CurrentRoleInstance.Role.Name)
                {
                    // take any action needed on instance count modification; gracefully shrink etc
                }
            }

            foreach (var item in e.Changes.OfType<RoleEnvironmentConfigurationSettingChange>())
            {
                if (item.ConfigurationSettingName == "MBrace.ServiceBusConnectionString"
                    || item.ConfigurationSettingName == "MBrace.StorageConnectionString")
                {
                    _config = Configuration.Default
                                .WithStorageConnectionString(CloudConfigurationManager.GetSetting("MBrace.StorageConnectionString"))
                                .WithServiceBusConnectionString(CloudConfigurationManager.GetSetting("MBrace.ServiceBusConnectionString"));
                    _svc.Stop();
                    _svc.Configuration = _config;
                    _svc.Start();
                }
            }
        }
Exemple #41
0
        void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
        {
            foreach (var item in e.Changes.OfType <RoleEnvironmentTopologyChange>())
            {
                if (item.RoleName == RoleEnvironment.CurrentRoleInstance.Role.Name)
                {
                    // take any action needed on instance count modification; gracefully shrink etc
                }
            }

            foreach (var item in e.Changes.OfType <RoleEnvironmentConfigurationSettingChange>())
            {
                if (item.ConfigurationSettingName == "MBrace.ServiceBusConnectionString" ||
                    item.ConfigurationSettingName == "MBrace.StorageConnectionString")
                {
                    _config = Configuration.Default
                              .WithStorageConnectionString(CloudConfigurationManager.GetSetting("MBrace.StorageConnectionString"))
                              .WithServiceBusConnectionString(CloudConfigurationManager.GetSetting("MBrace.ServiceBusConnectionString"));
                    _svc.Stop();
                    _svc.Configuration = _config;
                    _svc.Start();
                }
            }
        }
 public static void OnChanged(object caller, RoleEnvironmentChangedEventArgs args)
 {
     var handler = Changed;
     if (handler != null)
         handler(caller, args);
 }
        void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
        {
            if (!e.Changes.OfType<RoleEnvironmentTopologyChange>().Any())
            {
                return;
            }

            ValidateInstanceCount();
        }
Exemple #44
0
        private void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
        {
            // Get the list of configuration changes
            var settingChanges = e.Changes.OfType<RoleEnvironmentConfigurationSettingChange>();

            foreach (var settingChange in settingChanges)
            {
                var settingName = settingChange.ConfigurationSettingName;
                var value = RoleEnvironment.GetConfigurationSettingValue(settingName);
                DiagnosticsHelper.TraceInformation(
                    string.Format("Setting {0} now has value {1} ",
                    settingName,
                    value));
                if (settingName == Settings.LogVerbositySetting)
                {
                    var logLevel = Utilities.GetLogVerbosity(value);
                    if (logLevel != null)
                    {
                        if (logLevel != Settings.MongodLogLevel)
                        {
                            Settings.MongodLogLevel = logLevel;
                            DatabaseHelper.SetLogLevel(mongodPort, logLevel);
                        }
                    }
                }
                if (settingName == Settings.RecycleSetting)
                {
                    Settings.RecycleRoleOnExit = Utilities.GetRecycleFlag(RoleEnvironment.GetConfigurationSettingValue(settingName));
                }
            }

            // Get the list of topology changes
            var topologyChanges = e.Changes.OfType<RoleEnvironmentTopologyChange>();

            foreach (var topologyChange in topologyChanges)
            {
                var roleName = topologyChange.RoleName;
                DiagnosticsHelper.TraceInformation(
                    string.Format("Role {0} now has {1} instance(s)",
                    roleName,
                    RoleEnvironment.Roles[roleName].Instances.Count));
            }
        }
Exemple #45
0
 void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
 {
     Log.TraceInformation("Recevied a configuration change notification");
     Config.Get().OnConfigurationChanged(e.Changes);
 }
        private void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
        {
            // Get the list of configuration changes
            var settingChanges = e.Changes.OfType<RoleEnvironmentConfigurationSettingChange>();

            foreach (var settingChange in settingChanges)
            {
                var settingName = settingChange.ConfigurationSettingName;
                var value = RoleEnvironment.GetConfigurationSettingValue(settingName);
                DiagnosticsHelper.TraceInformation(
                    string.Format("Setting {0} now has value {1} ",
                    settingName,
                    value));

            }

            // Get the list of topology changes
            var topologyChanges = e.Changes.OfType<RoleEnvironmentTopologyChange>();

            foreach (var topologyChange in topologyChanges)
            {
                var roleName = topologyChange.RoleName;
                DiagnosticsHelper.TraceInformation(
                    string.Format("Role {0} now has {1} instance(s)",
                    roleName,
                    RoleEnvironment.Roles[roleName].Instances.Count));
            }
        }
 void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
 {
     ReadAzureConfiguration();
     uri = string.Empty;
 }
        private void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
        {
            try
            {
                var changes = e.Changes.OfType<RoleEnvironmentConfigurationSettingChange>()
                    .Select(c => c.ConfigurationSettingName)
                    .ToList();

                if (changes.Count > 0)
                {
                    this.telemetry.TrackTrace(
                        "Configuration changes. Trigger restart",
                        SeverityLevel.Information,
                        changes.ToDictionary(name => name, name => CloudConfigurationManager.GetSetting(name)));

                    // fire and forget
                    this.RestartTrainProcessorHost();
                }
            }
            catch (Exception ex)
            {
                this.telemetry.TrackException(ex);
            }
        }
        private void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
        {
            try
            {
                Trace.TraceInformation("Event: Role Environment Changed.");

                if (e.Changes.OfType<RoleEnvironmentTopologyChange>().Any())
                {
                    SetupReplication();
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("RoleEnvironmentChanged Error: {0}", ex.Message);
            }
        }
 private void OnRoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
 {
     Trace.WriteLine(RoleEnvironment.CurrentRoleInstance.Role.Name + " has been changed.", "Information");
 }
        /// <summary>
        /// RoleEnvironmentChanged - Called after a change has been applied to the role.  
        /// NOTE: This is called AFTER RoleEnvironmentChanging is called.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">List of what has changed</param>
        private void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
        {
            // Refresh the diagnostic switches from the role config values.
            // This allows for run-time changing of the values of the switches without recycling (i.e. rebooting)
            // the role so we can turn on or off more verbose diagnostic output based on the switches we've
            // defined in ServiceConfiguration.cscfg.
            GetTraceSwitchValuesFromRoleConfiguration();

            // Log the change to the logs - using Trace.WriteLine to circumvent the switches so that if the switch was
            // turned off or to a low setting like Critical, the message showing this will still go into the logs.
            Trace.WriteLine("WebRoleDiagnostics::RoleEnvironmentChanged - Diagnostics switch values changed.  ConfigTrace = " +
                                ConfigTrace.Switch.Level.ToString() + " WebTrace = " +
                                WebTrace.Switch.Level.ToString());
        }
Exemple #52
0
        private void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
        {
            Tracer.WriteLine("RoleEnvironmentChanged", "Information");
            log.WriteEntry("RoleEnvironmentChanged", "", GetLabel());

            bool reconfigureDiagnostics = false;
            bool update = false;
            bool remountCloudDrive = false;

            foreach (RoleEnvironmentChange roleEnvironmentChange in e.Changes)
            {
                if (roleEnvironmentChange.GetType() == typeof(RoleEnvironmentConfigurationSettingChange))
                {

                    RoleEnvironmentConfigurationSettingChange change = (RoleEnvironmentConfigurationSettingChange)roleEnvironmentChange;

                    string message = string.Format("{0} = \"{1}\"", change.ConfigurationSettingName, RoleEnvironment.GetConfigurationSettingValue(change.ConfigurationSettingName));

                    Tracer.WriteLine(message, "Information");
                    log.WriteEntry("RoleEnvironmentConfigurationSettingChange", message, GetLabel());

                    switch (change.ConfigurationSettingName)
                    {
                        case TRACE_FORMAT:
                            ConfigureTraceFormat();
                            break;

                        case SCHEDULED_TRANSFER_LOG_LEVEL_FILTER:
                        case SCHEDULED_TRANSFER_PERIOD:
                            reconfigureDiagnostics = true;
                            break;

                        case UPDATE_INDICATOR:
                            update = true;
                            break;

                        case CLOUD_DRIVE_CONNECTION_STRING:
                        case CLOUD_DRIVE:
                        case CLOUD_DRIVE_SIZE:
                            remountCloudDrive = true;
                            break;

                        case DEFAULT_CONNECTION_LIMIT:
                            ConfigureDefaultConnectionLimit();
                            break;

                        // TODO: Support Trace changes
                    }

                }
                else if (roleEnvironmentChange.GetType() == typeof(RoleEnvironmentTopologyChange))
                {
                    Tracer.WriteLine("RoleEnvironmentTopologyChange", "Information");
                    log.WriteEntry("RoleEnvironmentTopologyChange", "", GetLabel());
                }
                else
                {
                    Tracer.WriteLine("UnknownRoleEnvironmentChange", "Information");
                    log.WriteEntry("UnknownRoleEnvironmentChange", roleEnvironmentChange.GetType().ToString(), GetLabel());
                }
            }

            if (remountCloudDrive)
            {
                UnmountCloudDrive();
                MountCloudDrive();
            }

            if (reconfigureDiagnostics)
                ConfigureDiagnostics();

            if (update)
                DoUpdate();
        }
 void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
 {
 }
Exemple #54
0
        private void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
        {
            Tracer.WriteLine("RoleEnvironmentChanged", "Information");
            log.WriteEntry("RoleEnvironmentChanged", "", GetLabel());

            bool update = false;

            foreach (RoleEnvironmentChange roleEnvironmentChange in e.Changes)
            {
                if (roleEnvironmentChange.GetType() == typeof(RoleEnvironmentConfigurationSettingChange))
                {

                    RoleEnvironmentConfigurationSettingChange change = (RoleEnvironmentConfigurationSettingChange)roleEnvironmentChange;

                    string message = string.Format("{0} = \"{1}\"", change.ConfigurationSettingName, RoleEnvironment.GetConfigurationSettingValue(change.ConfigurationSettingName));

                    Tracer.WriteLine(message, "Information");
                    log.WriteEntry("RoleEnvironmentConfigurationSettingChange", message, GetLabel());

                    switch (change.ConfigurationSettingName)
                    {
                        case TRACE_FORMAT:
                            ConfigureTraceFormat();
                            break;

                        case UPDATE_INDICATOR:
                            update = true;
                            break;

                        case DEFAULT_CONNECTION_LIMIT:
                            ConfigureDefaultConnectionLimit();
                            break;

                    }

                }
                else if (roleEnvironmentChange.GetType() == typeof(RoleEnvironmentTopologyChange))
                {
                    Tracer.WriteLine("RoleEnvironmentTopologyChange", "Information");
                    log.WriteEntry("RoleEnvironmentTopologyChange", "", GetLabel());
                }
                else
                {
                    Tracer.WriteLine("UnknownRoleEnvironmentChange", "Information");
                    log.WriteEntry("UnknownRoleEnvironmentChange", roleEnvironmentChange.GetType().ToString(), GetLabel());
                }
            }

            if (update)
                DoUpdate();
        }
        /// <summary>
        /// Event handler called after an environment change has been applied to the role.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The list of changed environment values.</param>
        private void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
        {

        }
Exemple #56
0
        private static void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
        {
            Trace.TraceInformation("RoleEnvironmentChanged Event Fired");

            // TODO: Implement
            //var changes = e.Changes
            //               .OfType<RoleEnvironmentConfigurationSettingChange>()
            //               .ToList();

            //// Service Bus Connection Strings Updated
            //if (changes.Any(c => c.ConfigurationSettingName == ServiceBus.FrontendServiceBusConnectionStringName))
            //{
            //    // TODO: Close Service Bus connection and reopen with new connection string
            //}
            //if (changes.Any(c => c.ConfigurationSettingName == ServiceBus.WorkerServiceBusConnectionStringName))
            //{
            //    // TODO: Close Service Bus connection and reopen with new connection string
            //}
        }
Exemple #57
0
 /// <summary>
 /// Event handler called after an environment change has been applied to the role.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The list of changed environment values.</param>
 private void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
 {
     // Refresh the settings defined in ServiceConfiguration.cscfg.
     ConfigureDiagnostics();
 }
 void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
 {
     // On Topology Changes to the FrontendWorkerRole --> Configure AzureWebFarm
     if (e.Changes.Any(c => c is RoleEnvironmentTopologyChange))
     {
         Trace.TraceAndLogInformation(TRACESOURCE + ":TopologyChange", "The topology has changed. Reconfiguring webfarm.");
         ClixOnAzure.WebFarmHostManager.ConfigureAzureWebFarm();
         Trace.TraceInformation(TRACESOURCE + ":TopologyChange: Azure Web Farm has been reconfigured.");
     }
 }
 // Event handler for roleenvironment changed event
 private static void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
 {
     if (WindowsAzureBlob2FileSystemSync._mainThread != null)
     {
         Trace.TraceInformation("Rolenvironment changed. Interrupting Synchronization thread that might be sleeping");
         WindowsAzureBlob2FileSystemSync._mainThread.Interrupt();
     }
 }
 /// <summary>
 /// The callback which is called to refresh in-memory service configuration settings only if the role environment is changed
 /// </summary>
 private void RoleEnvironment_Changed(object sender, RoleEnvironmentChangedEventArgs e)
 {
     ConfigurationManager.Reset();
 }