protected void OnConfigChange() { ConfigChangeHandler handler = ConfigChange; if (handler != null) { handler(null, new EventArgs()); } }
protected void OnShadowTechniqueChange() { ConfigChangeHandler handler = ShadowTechniqueChange; if (handler != null) { handler(null, new EventArgs()); } }
/// <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"); } }
/// <summary> /// When the worker role starts, we do the following: /// 1. Initialize Logger to be used /// 2. Schedule Extract Processing job on startup if configured for. /// 3. Schedule Ping Job /// </summary> /// <remarks> /// If we schedule Extract Processing job at the same time everyday, we might get /// duplicate jobs to execute at the same time (which might be a problem when we have /// more than one instance of the role). We can revisit this later, but for now we will /// schedule it at the start. /// </remarks> /// <returns> /// boolean status about startup /// </returns> public override bool OnStart() { // Set the maximum number of concurrent connections ServicePointManager.DefaultConnectionLimit = 100 * Environment.ProcessorCount; // Use only for debugging // TelemetryConfiguration.Active.TelemetryChannel.DeveloperMode = true; //TelemetryConfiguration.Active.InstrumentationKey = CloudConfigurationManager.GetSetting("APPINSIGHTS_INSTRUMENTATIONKEY"); // Create a CommerceLog instance to funnel log entries to the log. LogInitializer.CreateLogInstance(CommerceWorkerConfig.Instance.LogVerbosity, CommerceWorkerConfig.Instance.ForceEventLog, CommerceLogSource, CommerceWorkerConfig.Instance); Log = new CommerceLog(Guid.NewGuid(), CommerceWorkerConfig.Instance.LogVerbosity, CommerceLogSource); ConfigChangeHandler = new ConfigChangeHandler(Log, ExemptConfigurationItems); // turn off processing jobs at start ProcessJobs = Convert.ToBoolean(CloudConfigurationManager.GetSetting(ProcessJobsPropertyKey)); // role should not exit even after processing jobs stop ExitRole = false; // event handlers RoleEnvironment.Changing += RoleEnvironmentChanging; RoleEnvironment.Changed += RoleEnvironmentChanged; if (!string.IsNullOrEmpty(ConcurrencyMonitorConnectionString)) { Log.Verbose("Initializing Jobs."); using (ConcurrencyMonitor monitor = new ConcurrencyMonitor(ConcurrencyMonitorConnectionString)) { monitor.InvokeWithLease(() => PartnerJobInitializer.InitializeJobs(Scheduler)); } Log.Verbose("Initialized Jobs."); } return(base.OnStart()); }
/// <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); }