Пример #1
0
        //Event Handler
        public void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            var changes = from ch in e.Changes.OfType<RoleEnvironmentTopologyChange>()
                          select ch;
            if (changes.Any())
            {
                const string semaphoreName = "SemaphoreShutDown";
                Semaphore sem = null;

                // Attempt to open the named semaphore.
                try
                {
                    sem = Semaphore.OpenExisting(semaphoreName);
                }
                catch (WaitHandleCannotBeOpenedException)
                {
                    return;
                }
                sem.Release(1);

                //Note this may be superfulous, as this event may be running on a non-blocking thread.  To be investigated.
                //If a blocking thread, this gives some time for IIS to complete its shutdown, based on the semaphore release
                //above.  
                Thread.Sleep(20000);
            }
        }
Пример #2
0
        private static void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            if (!e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange)) return;

            Trace.WriteLine("Working", "Environment Change: " + e.Changes.ToList());
            e.Cancel = true;
        }
Пример #3
0
 /// <summary>
 /// Event handler called when an environment change is to be applied to the role.
 /// Determines whether or not the role instance must be recycled.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The list of changed environment values.</param>
 private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     // If Azure should recycle the role, e.Cancel should be set to true.
     // If the changes are ones we can handle without a recycle, we set it to false.
     e.Cancel = this.RecycleConfiguration(e.Changes);
     Trace.WriteLine("WebRole environment change - role instance recycling: " + e.Cancel.ToString());
 }
Пример #4
0
 private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     // If a configuration setting is changing
     if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
         // set e.Cancel to true to restart this role instance
         e.Cancel = true;
 }
Пример #5
0
 private static void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
     {
         e.Cancel = true;
     }
 }
Пример #6
0
 private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     //Are any of the environment changes a configuration setting change? If so, cancel the event and restart the role
     if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
     {
         e.Cancel = true;
     }
 }
Пример #7
0
 static void RoleEnvironment_Changing(object sender, RoleEnvironmentChangingEventArgs e)
 {
     if (e.Changes.OfType<RoleEnvironmentConfigurationSettingChange>().Count() > 0)
     {
         // Cancel the changing event to force role instance restart
         //e.Cancel = true;
     }
 }
Пример #8
0
 private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     e.Cancel = false; // don't restart for configuration changes
     /*if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
     {
         e.Cancel = true;
     }*/
 }
Пример #9
0
		private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)  // pro forma, not used, most config settings are in an azure table
		{
			// If a configuration setting is changing
			if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
			{
				// Set e.Cancel to true to restart this role instance
				e.Cancel = true;
			}
		}
 private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     // for any configuration setting change except EnableTableStorageTraceListener
     if (e.Changes.OfType<RoleEnvironmentConfigurationSettingChange>().Any(change => change.ConfigurationSettingName != "EnableTableStorageTraceListener"))
     {
         // Set e.Cancel to true to restart this role instance
         e.Cancel = true;
     }
 }
Пример #11
0
 private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     // 如果配置设置数值变化
     if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
     {
         // 将e.Cancel设为true重启这个角色实例
         e.Cancel = true;
     }
 }
Пример #12
0
 private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     // 如果配置设置改变
     if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
     {
         // 设置e.Cancel为真重启角色实例
         e.Cancel = true;
     }
 }
Пример #13
0
 private static void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     // for any configuration setting change except TraceEventTypeFilter
     if (e.Changes.OfType <RoleEnvironmentConfigurationSettingChange>().Any(change => change.ConfigurationSettingName != "TraceEventTypeFilter"))
     {
         // Set e.Cancel to true to restart this role instance
         e.Cancel = true;
     }
 }
Пример #14
0
 private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     // 如果配置设置改变
     if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
     {
         // 设置e.Cancel为真重启角色实例
         e.Cancel = true;
     }
 }
Пример #15
0
        static void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            var i = 1;
            foreach (var c in e.Changes)
                Trace.WriteLine(string.Format("RoleEnvironmentChanging: #{0} Type={1} Change={2}", i++, c.GetType().FullName, c));

            if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
                e.Cancel = true;
        }
Пример #16
0
 private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     // �������������ֵ�仯
     if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
     {
         // ��e.Cancel��Ϊtrue���������ɫʵ��
         e.Cancel = true;
     }
 }
Пример #17
0
 private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     // If a configuration setting is changing
     if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
     {
         // Set e.Cancel to true to restart this role instance
         e.Cancel = true;
     }
 }
 private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     foreach (RoleEnvironmentChange change in e.Changes)
     {
         if (change.GetType() == typeof(RoleEnvironmentConfigurationSettingChange))
         {
             e.Cancel = true;
         }
     }
 }
 /// <summary>
 /// Role Environment Changing
 /// </summary>
 /// <param name="sender">Sender</param>
 /// <param name="e">Role Environment Changing Event Args</param>
 private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     foreach (RoleEnvironmentConfigurationSettingChange change in e.Changes)
     {
         if (null != change && !string.IsNullOrWhiteSpace(change.ConfigurationSettingName) && this.config.ContainsKey(change.ConfigurationSettingName))
         {
             this.config.Remove(change.ConfigurationSettingName);
         }
     }
 }
Пример #20
0
 /// <summary>
 /// This event is called after configuration changes have been submited to Windows Azure but before they have been applied in this instance
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="RoleEnvironmentChangingEventArgs" /> instance containing the event data.</param>
 private void RoleEnvironmentOnChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     // Implements the changes after restarting the role instance
     foreach (RoleEnvironmentConfigurationSettingChange settingChange in e.Changes.Where(x => x is RoleEnvironmentTopologyChange))
     {
         // Set e.Cancel to true to restart this role instance
         e.Cancel = true;
         return;
     }
 }
Пример #21
0
        private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            Func <RoleEnvironmentConfigurationSettingChange, bool> changeIsExempt =
                x => !Settings.ExemptConfigurationItems.Contains(x.ConfigurationSettingName);
            var environmentChanges = e.Changes.OfType <RoleEnvironmentConfigurationSettingChange>();

            e.Cancel = environmentChanges.Any(changeIsExempt);
            DiagnosticsHelper.TraceInformation("Role config changing. Cancel set to {0}",
                                               e.Cancel);
        }
Пример #22
0
        private void RoleEnvironment_Changing(object sender, RoleEnvironmentChangingEventArgs e)
        {
            //**
            var settingChanges = e.Changes.OfType <RoleEnvironmentConfigurationSettingChange>();

            if (settingChanges.Any(change => change.ConfigurationSettingName == "connectionString"))
            {
                Trace.TraceInformation("WorkerBackend restarting");
                e.Cancel = true;
            }
        }
Пример #23
0
 private void HandleRoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     foreach (var c in e.Changes.OfType <RoleEnvironmentTopologyChange>())
     {
         if (c.RoleName.Equals(AzureConstants.StoreWorkerRoleName))
         {
             Trace.TraceInformation("BrightstarCluster: Received RoleEnvironmentTopologyChange event. Updating store worker client list");
             UpdateClientList();
         }
     }
 }
Пример #24
0
        private void OnRoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            var configurationChanges = e.Changes.OfType <RoleEnvironmentConfigurationSettingChange>();

            if (configurationChanges.Any())
            {
                // If Azure settings changed, take the instance offline, applies the configuration change, and then brings the instance back online.
                // For more details, please refer to this article: https://msdn.microsoft.com/en-us/library/azure/gg432963.aspx
                e.Cancel = true;
            }
        }
Пример #25
0
 private void HandleRoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     foreach(var c in e.Changes.OfType<RoleEnvironmentTopologyChange>())
     {
         if (c.RoleName.Equals(AzureConstants.StoreWorkerRoleName))
         {
             Trace.TraceInformation("BrightstarCluster: Received RoleEnvironmentTopologyChange event. Updating store worker client list");
             UpdateClientList();
         }
     }
 }
Пример #26
0
        private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            WriteToTempFile("RoleEnvironmentChanging:" + e.Cancel);

            // If a configuration setting is changing
            foreach (RoleEnvironmentConfigurationSettingChange settingChange in e.Changes.Where(x => x is RoleEnvironmentTopologyChange))
            {
                // Set e.Cancel to true to restart this role instance
                e.Cancel = true;
                return;
            }
        }
Пример #27
0
        /// <summary>
        /// Event handler for the scenario when a config value is changing
        /// </summary>
        /// <param name="sender">
        /// Who the sender is
        /// </param>
        /// <param name="changingEventArgs">
        /// Changing Event args <see cref="RoleEnvironmentChangingEventArgs"/>
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Parameter changingEventArgs cannot be null.
        /// </exception>
        public void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs changingEventArgs)
        {
            if (changingEventArgs == null)
            {
                throw new ArgumentNullException("changingEventArgs", "Parameter changingEventArgs cannot be null.");
            }

            Log.Information("Got a configuration change event");

            //Cancel true means reboot. So we need to ask if we have a change we care about then don't reboot.
            changingEventArgs.Cancel = ShouldRebootRole(changingEventArgs);
        }
Пример #28
0
        static void OnRoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            // we restart all workers if the configuration changed (e.g. the storage account)
            // for now.

            // We do not request a recycle if only the topology changed,
            // e.g. if some instances have been removed or added.
            var configChanges = e.Changes.OfType <RoleEnvironmentConfigurationSettingChange>();

            if (configChanges.Any())
            {
                RoleEnvironment.RequestRecycle();
            }
        }
Пример #29
0
        static void OnRoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            // we restart all workers if the configuration changed (e.g. the storage account)
            // for now.

            // We do not request a recycle if only the topology changed,
            // e.g. if some instances have been removed or added.
            var configChanges = e.Changes.OfType<RoleEnvironmentConfigurationSettingChange>();

            if(configChanges.Any())
            {
                RoleEnvironment.RequestRecycle();
            }
        }
Пример #30
0
        static void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            var i = 1;

            foreach (var c in e.Changes)
            {
                Trace.WriteLine(string.Format("RoleEnvironmentChanging: #{0} Type={1} Change={2}", i++, c.GetType().FullName, c));
            }

            if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
            {
                e.Cancel = true;
            }
        }
Пример #31
0
        void RoleEnvironment_Changing(object sender, RoleEnvironmentChangingEventArgs e)
        {
            Trace.TraceInformation("Change notification");

            if (e.Changes.OfType<RoleEnvironmentConfigurationSettingChange>()
                .Any(c => !string.Equals(c.ConfigurationSettingName, MvcApplication.AzureLoggingVerbositySettingName, StringComparison.Ordinal)))
            {
                Trace.TraceInformation("Cancelling instance");
                e.Cancel = true;
            }
            else
            {
                Trace.TraceInformation("Handling change without recycle");
            }
        }
Пример #32
0
        private static void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            int i = 1;
            foreach (var c in e.Changes)
            {
                Trace.WriteLine(string.Format("RoleEnvironmentChanging: #{0} Type={1} Change={2}", i++, c.GetType().FullName, c));
            }

            // If a configuration setting is changing);
            if (e.Changes.Any((RoleEnvironmentChange change) => change is RoleEnvironmentConfigurationSettingChange))
            {
                // Set e.Cancel to true to restart this role instance
                e.Cancel = true;
            }
        }
Пример #33
0
        void RoleEnvironment_Changing(object sender, RoleEnvironmentChangingEventArgs e)
        {
            Trace.TraceInformation("Change notification");

            if (e.Changes.OfType <RoleEnvironmentConfigurationSettingChange>()
                .Any(c => !string.Equals(c.ConfigurationSettingName, MvcApplication.AzureLoggingVerbositySettingName, StringComparison.Ordinal)))
            {
                Trace.TraceInformation("Cancelling instance");
                e.Cancel = true;
            }
            else
            {
                Trace.TraceInformation("Handling change without recycle");
            }
        }
Пример #34
0
        private static void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            int i = 1;

            foreach (var c in e.Changes)
            {
                Trace.WriteLine($"RoleEnvironmentChanging: #{i++} Type={c.GetType().FullName} Change={c}");
            }

            // If a configuration setting is changing);
            if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
            {
                // Set e.Cancel to true to restart this role instance
                e.Cancel = true;
            }
        }
Пример #35
0
        private static void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            int i = 1;

            foreach (var c in e.Changes)
            {
                Trace.WriteLine(string.Format("RoleEnvironmentChanging: #{0} Type={1} Change={2}", i++, c.GetType().FullName, c));
            }

            // If a configuration setting is changing);
            if (e.Changes.Any((RoleEnvironmentChange change) => change is RoleEnvironmentConfigurationSettingChange))
            {
                // Set e.Cancel to true to restart this role instance
                e.Cancel = true;
            }
        }
Пример #36
0
 private void OnChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     foreach (var change in e.Changes)
     {
         var configChange = change as RoleEnvironmentConfigurationSettingChange;
         if (configChange != null)
         {
             if (configChange.ConfigurationSettingName == "DatabaseConnectionString")
             {
                 // Our database connectionstring changed.
                 // Maybe we need to restart the instance to make sure our cached objects no longer use the previous value.
                 e.Cancel = true;
             }
         }
     }
 }
Пример #37
0
        /// <summary>
        /// Is called if the azure portal environment changes as a result of sysadmin manual activity on the webpage.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="RoleEnvironmentChangingEventArgs" /> instance containing the event data.</param>
        private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            try
            {
                //Trace.WriteLine("WorkerRole RoleEnvironmentChanging", "Information");

                // If a configuration setting is changing
                if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
                {
                    // Set e.Cancel to true to restart this role instance
                    e.Cancel = true;
                }
            }
            catch (Exception)
            {
            }
        }
Пример #38
0
        void RoleEnvironment_Changing(object sender, RoleEnvironmentChangingEventArgs e)
        {
            var configurationChanges = e.Changes
                                       .OfType <RoleEnvironmentConfigurationSettingChange>()
                                       .ToList();


            if (!configurationChanges.Any())
            {
                return;
            }

            if (configurationChanges.Any(c => c.ConfigurationSettingName == "StorageAccount"))
            {
                e.Cancel = true;
            }
        }
Пример #39
0
        void RoleEnvironment_Changing(object sender, RoleEnvironmentChangingEventArgs e)
        {
            if (RoleEnvironment.IsEmulated)
            {
                // var traceSource = CreateTraceSource();
                Trace.TraceInformation("RoleEnvironment.Changing for {0}:", RoleEnvironment.CurrentRoleInstance.Id);

                foreach (RoleEnvironmentChange change in e.Changes)
                {
                    Trace.TraceInformation(" > {0}", change.GetType());
                }
            }
            if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
            {
                e.Cancel = true;
            }
        }
        private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            TraceManager.WorkerRoleComponent.TraceIn(InstanceId, CloudEnvironment.CurrentRoleInstanceId);

            // If a configuration setting is changing.
            if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
            {
                // Tell the configuration manager to unload any cached configuration data.
                ApplicationConfiguration.Current.Unload();

                // Set e.Cancel to true to restart this role instance, otherwise keep the role instance running.
                e.Cancel = false;
            }

            // Invoke the user defined part of the RoleEnvironmentChanging event handler.
            OnRoleEnvironmentChanging(sender, e);

            TraceManager.WorkerRoleComponent.TraceOut(InstanceId, e.Cancel);
        }
Пример #41
0
        /// <summary>
        /// RoleEventChanging - Called when a change is about to be applied to the role.  Determines whether or not to recycle the role instance.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">A list of what is changing</param>
        private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            // Note: e.Cancel == true -> Azure should recycle the role.  If all the changes are in our "exempt" list,
            // we don't need to recycle the role.

            e.Cancel = HasNonExemptConfigurationChanges(e.Changes);

            // Note that we use Trace.WriteLine here rather than going through the Diagnostics class so that we will always log
            // this, even when the switch for whether to log or not is being changed.

            if (!e.Cancel)
            {
                Trace.WriteLine("Processor.WorkerRole::RoleEnvironmentChanging - role is not recycling, getting new switch values from config file.");
            }
            else
            {
                Trace.WriteLine("Processor.WorkerRole::RoleEnvironmentChanging - recycling role instance due to non-exempt configuration changes.");
            }
        }
Пример #42
0
        private void RoleEnvironmentOnChanging(object sender, RoleEnvironmentChangingEventArgs roleEnvironmentChangingEventArgs)
        {
            // In order to handle changing configuration
            // this can be avoided if the config is not "singleton" but it is recreated via this event
            // https://msdn.microsoft.com/en-us/library/azure/gg432963.aspx
            // https://alexandrebrisebois.wordpress.com/2013/09/29/handling-cloud-service-role-configuration-changes-in-windows-azure/

            var configurationChanges = roleEnvironmentChangingEventArgs.Changes
                                    .OfType<RoleEnvironmentConfigurationSettingChange>()
                                    .ToList();

            if (!configurationChanges.Any())
            {
                return;
            }

            // TODO for specific settings which are uesd to instantiate any cached objects
            //if(configurationChanges.Any(c => c.ConfigurationSettingName == "StorageAccount"))
            roleEnvironmentChangingEventArgs.Cancel = true;
        }
Пример #43
0
        /// <summary>
        /// Handle configuration change events for ChefClient_ServerURL, ChefClient_Role, or ChefClient_Environment.
        /// This will cancel the event and force a Role Restart so that the client scripts (main.ps1) will reset a new
        /// connection and client registration with the new Server.
        /// </summary>
        /// <param name="sender">Sender object</param>
        /// <param name="e">Event arguments</param>
        private static void ChefConfigChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            var configurationChanges = e.Changes.OfType <RoleEnvironmentConfigurationSettingChange>().ToList();

            if (!configurationChanges.Any())
            {
                return;
            }

            if (configurationChanges.Any(c => c.ConfigurationSettingName == "ChefClient_SetBusyCheck"))
            {
                ClientService.statusCheckFilePath = CloudConfigurationManager.GetSetting("ChefClient_SetBusyCheck");
            }

            if (configurationChanges.Any(c => c.ConfigurationSettingName == "ChefClient_ServerUrl" ||
                                         c.ConfigurationSettingName == "ChefClient_Role" ||
                                         c.ConfigurationSettingName == "ChefClient_Environment"))
            {
                Stop(new TimeSpan(0, 0, 30), true);
                e.Cancel = true;
            }
        }
Пример #44
0
        /*
         *  In the Changing event, RoleEnvironment.CurrentRoleInstance.Role.Instances returns the original role instances,
         *  not the target role instances. There is no way of finding out the target role instances at this time.
         */
        private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            originalNumOfInstances = RoleEnvironment.CurrentRoleInstance.Role.Instances.Count;
            Logfile.Get(logfile).fTextout(Logging.Fontcolors.RED, "{0} > RoleEnvironmentChanging Eventhandler logging original instance count of {1} <br>", DateTime.Now.ToString(), originalNumOfInstances);
            Logfile.Get(logfile).Update();

            highestRoleInstanceId = RoleEnvironment.CurrentRoleInstance.Role.Instances.ElementAt(originalNumOfInstances - 1).Id;

            // The role instance with the lowest id deletes the db entry in case of downscale.
            if ("ImagingProcessorWorker_IN_0" == RoleEnvironment.CurrentRoleInstance.Id)
            {
                Logfile.Get(logfile).fTextout(Logging.Fontcolors.RED, "{0} > This ({1}) is the role instance with the lowest RoleInstanceId <br>", DateTime.Now.ToString(), RoleEnvironment.CurrentRoleInstance.Id);
                Logfile.Get(logfile).Update();

                lowestRoleInstanceId = true;
            }
            else
            {
                Logfile.Get(logfile).fTextout(Logging.Fontcolors.RED, "{0} > This ({1}) is NOT the role instance with the lowest RoleInstanceId <br>", DateTime.Now.ToString(), RoleEnvironment.CurrentRoleInstance.Id);
                Logfile.Get(logfile).Update();
            }
        }
Пример #45
0
        private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            Trace.TraceInformation("RoleEnvironmentChanging Event Fired");

            var changes = e.Changes
                          .OfType <RoleEnvironmentConfigurationSettingChange>()
                          .ToList();

            if (!changes.Any())
            {
                return;
            }

            e.Cancel = true; // Instruct server to reboot on change (if not canceled below)

            //// TODO: Implement (for now just repboot server)
            //// Service Bus Connection Strings Updated
            //if (changes.Any(c => c.ConfigurationSettingName == ""))
            //{
            //    e.Cancel = false; // Cancel reboot of server
            //}
        }
Пример #46
0
        private void RoleEnvironment_Changing(object sender, RoleEnvironmentChangingEventArgs e)
        {
            var changedSettings = e.Changes.OfType <RoleEnvironmentConfigurationSettingChange>()
                                  .Select(c => c.ConfigurationSettingName).ToList();

            Trace.TraceInformation("Configuration Changing notification. Settings being changed: "
                                   + string.Join(", ", changedSettings));

            if (changedSettings
                .Any(settingName => !string.Equals(settingName, CustomSettingName, StringComparison.Ordinal)))
            {
                Trace.TraceInformation("Cancelling dynamic configuration change (restarting).");

                // Setting this to true will restart the role gracefully. If Cancel is not set to true,
                // and the change is not handled by the application, then the application will not use
                // the new value until it is restarted (either manually or for some other reason).
                e.Cancel = true;
            }
            else
            {
                Trace.TraceInformation("Handling configuration change without restarting.");
            }
        }
Пример #47
0
        private void RoleEnvironment_Changing(object sender, RoleEnvironmentChangingEventArgs e)
        {
            var changedSettings = e.Changes.OfType<RoleEnvironmentConfigurationSettingChange>()
                                            .Select(c => c.ConfigurationSettingName).ToList();

            Trace.TraceInformation("Configuration Changing notification. Settings being changed: "
                + string.Join(", ", changedSettings));

            if (changedSettings
                .Any(settingName => !string.Equals(settingName, CustomSettingName, StringComparison.Ordinal)))
            {
                Trace.TraceInformation("Cancelling dynamic configuration change (restarting).");

                // Setting this to true will restart the role gracefully. If Cancel is not set to true,
                // and the change is not handled by the application, then the application will not use
                // the new value until it is restarted (either manually or for some other reason).
                e.Cancel = true;
            }
            else
            {
                Trace.TraceInformation("Handling configuration change without restarting.");
            }
        }
        private static void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            Boolean recycle = false;
            foreach (RoleEnvironmentChange change in e.Changes)
            {
                RoleEnvironmentTopologyChange topologyChange = change as RoleEnvironmentTopologyChange;
                if (topologyChange != null)
                {
                    String roleName = topologyChange.RoleName;
                    ReadOnlyCollection<RoleInstance> oldInstances = RoleEnvironment.Roles[roleName].Instances;
                }
                RoleEnvironmentConfigurationSettingChange settingChange = change as RoleEnvironmentConfigurationSettingChange;
                if (settingChange != null)
                {
                    String settingName = settingChange.ConfigurationSettingName;
                    String oldValue = RoleEnvironment.GetConfigurationSettingValue(settingName);
                    recycle |= settingName == "SettingRequiringRecycle";
                }
            }

            // Recycle when e.Cancel = true;
            e.Cancel = recycle;
        }
Пример #49
0
 private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     // 如果一个配置环境发生变化
     if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
     {
         // 将e.Cancel设为true重启这个角色实例
         e.Cancel = true;
     }
 }
Пример #50
0
        private static void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            Trace.TraceInformation("RoleEnvironmentChanging Event Fired");

            var changes = e.Changes
                           .OfType<RoleEnvironmentConfigurationSettingChange>()
                           .ToList();

            if (!changes.Any())
            {
                return;
            }

            e.Cancel = true; // Instruct server to reboot on change (if not canceled below)

            // TODO: Implement (for now just repboot server)
            //// Service Bus Connection Strings Updated
            //if (changes.Any(c => c.ConfigurationSettingName == ServiceBus.FrontendServiceBusConnectionStringName))
            //{
            //    e.Cancel = false; // Cancel reboot of server
            //}
            //if (changes.Any(c => c.ConfigurationSettingName == ServiceBus.WorkerServiceBusConnectionStringName))
            //{
            //    e.Cancel = false; // Cancel reboot of server
            //}
        }
 private void RoleEnvironmentOnChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     e.Cancel = true;
 }
Пример #52
0
 //Event Handler
 public void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     /*var changes = from ch in e.Changes.OfType<RoleEnvironmentTopologyChange>()
                   select ch;
     if (changes.Any())
     {
         myHost.deActivateHosts();
         ConfigUtility.writeConsoleMessage("\nWorker Role OnStop: Node ID: " + AzureUtility.getRoleInstanceID() + " Has Shut Down. Goodbye!\n", EventLogEntryType.Warning, true, new Sample.HelloServiceSettings.Settings()); 
     }*/
 }
Пример #53
0
        /// <summary>
        /// RoleEventChanging - Called when a change is about to be applied to the role.  Determines whether or not to recycle the role instance.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">A list of what is changing</param>
        private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            // Note: e.Cancel == true -> Azure should recycle the role.  If all the changes are in our "exempt" list,
            // we don't need to recycle the role.

            e.Cancel = HasNonExemptConfigurationChanges(e.Changes);

            // Note that we use Trace.WriteLine here rather than going through the Diagnostics class so that we will always log
            // this, even when the switch for whether to log or not is being changed.

            if (!e.Cancel)
            {
                Trace.WriteLine("WebRoleDiagnostics::RoleEnvironmentChanging - role is not recycling, getting new switch values from config file.");
            }
            else
            {
                Trace.WriteLine("WebRoleDiagnostics::RoleEnvironmentChanging - recycling role instance due to non-exempt configuration changes.");
            }
        }
Пример #54
0
 /// <summary>
 /// Force restart of the instance.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void OnRoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     if (e.Changes.Any(o => o is RoleEnvironmentChange))
         e.Cancel = true;
 }
Пример #55
0
 private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     // If a user configuration setting is changing
     if ((from change in e.Changes.OfType<RoleEnvironmentConfigurationSettingChange>()
          where !(change.ConfigurationSettingName.StartsWith("Microsoft.WindowsAzure.Plugins.RemoteAccess.") ||
                  change.ConfigurationSettingName.StartsWith("Microsoft.WindowsAzure.Plugins.RemoteForwarder."))
          select change).Any())
     {
         // Set e.Cancel to true to restart this role instance
         e.Cancel = true;
     }
 }
Пример #56
0
 private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     e.Cancel = false;
 }
Пример #57
0
 /// <summary>
 /// Changing event handler
 /// </summary>
 /// <param name="sender">
 /// Sender object
 /// </param>
 /// <param name="changingEventArgs">
 /// Chaning Event details
 /// </param>
 internal void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs changingEventArgs)
 {
     ConfigChangeHandler.RoleEnvironmentChanging(sender, changingEventArgs);
 }
Пример #58
0
 private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     Func<RoleEnvironmentConfigurationSettingChange, bool> changeIsExempt =
         x => !Settings.ExemptConfigurationItems.Contains(x.ConfigurationSettingName);
     var environmentChanges = e.Changes.OfType<RoleEnvironmentConfigurationSettingChange>();
     e.Cancel = environmentChanges.Any(changeIsExempt);
     DiagnosticsHelper.TraceInformation(string.Format("Role config changing. Cancel set to {0}",
         e.Cancel));
 }
Пример #59
0
 private void RoleEnvironment_Changing(object sender, RoleEnvironmentChangingEventArgs e)
 {
     // Setting cancel to false indicates that this instance should _not_ be restarted
     // in response to the configuration change.
     e.Cancel = Config.Get().OnConfigurationChanging(e.Changes);
     if (e.Cancel)
     {
         Log.TraceInformation("Role will be restarted due to configuration change");
     }
 }
Пример #60
0
        private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            Tracer.WriteLine("RoleEnvironmentChanging", "Information");
            log.WriteEntry("RoleEnvironmentChanging", "", GetLabel());

            // Don't object to any role environment changes
            // See RoleEnvironmentChanged for our attempt to cope with the changes
        }