Esempio n. 1
0
 private void ConfigurationPackageModified(object sender, PackageModifiedEventArgs <ConfigurationPackage> e)
 {
     if (e.NewPackage.Description.Name == ValueRangeCheckerConfigPackageName)
     {
         Init(e.NewPackage.Settings);
     }
 }
Esempio n. 2
0
 private void OnConfigurationPackageModified(object sender, PackageModifiedEventArgs <ConfigurationPackage> e)
 {
     if (e.NewPackage.Description.Name.Equals(this.packageName))
     {
         this.UpdateSettings(e.NewPackage.Settings);
     }
 }
 private void DataPackageModified(object sender, PackageModifiedEventArgs <DataPackage> e)
 {
     if (e.NewPackage.Description.Name == ValidThumbprintsPackageName)
     {
         Init(e.NewPackage.Path);
     }
 }
Esempio n. 4
0
 private void OnConfigurationPackageModified(object sender, PackageModifiedEventArgs <ConfigurationPackage> e)
 {
     try
     {
         var settings = this.LoadReplicatorSettingsFromConfigPackage(false);
         this.UpdateReplicatorSettings(settings);
     }
     catch (FabricElementNotFoundException ex)
     {
         // Trace and Report fault when section is not found for ReplicatorSettings.
         DataImplTrace.Source.WriteErrorWithId(
             TraceType,
             this._traceId,
             "FabricElementNotFoundException while loading replicator settings from configuation.",
             ex);
         this._partition.ReportFault(FaultType.Transient);
     }
     catch (FabricException ex)
     {
         // Trace and Report fault if user intended to provide Replicator Security config but provided it incorrectly.
         DataImplTrace.Source.WriteErrorWithId(
             TraceType,
             this._traceId,
             "FabricException while loading replicator security settings from configuation.",
             ex);
         this._partition.ReportFault(FaultType.Transient);
     }
     catch (ArgumentException ex)
     {
         DataImplTrace.Source.WriteWarningWithId(TraceType, this._traceId, "ArgumentException while updating replicator settings from configuation.", ex);
         this._partition.ReportFault(FaultType.Transient);
     }
 }
        private void OnConfigurationPackageModified(object sender, PackageModifiedEventArgs <ConfigurationPackage> e)
        {
            var section          = e.NewPackage?.Settings?.Sections?["Database"];
            var connectionString = section?.Parameters?["ConnectionString"]?.Value;

            if (connectionString != null)
            {
                if (connectionString.Contains("{application:service}"))
                {
                    var application = section.Parameters["Application"].Value;
                    var service     = section.Parameters["Service"].Value;
                    var resolver    = ServicePartitionResolver.GetDefault();
                    var partition   = resolver.ResolveAsync(new Uri($"fabric:/{application}/{service}"), new ServicePartitionKey(), CancellationToken.None).GetAwaiter().GetResult();
                    var address     = JObject.Parse(partition.Endpoints.Select(ep => ep.Address).First()).SelectToken("Endpoints").ToObject <JObject>().Properties().First().Value.Value <string>();
                    connectionString = connectionString.Replace("{application:service}", address);
                }

                var client = new MongoClient(connectionString);
                lock (sync)
                {
                    database   = client.GetDatabase(section.Parameters["Database"].Value);
                    collection = section.Parameters["Collection"].Value;
                }
            }
        }
Esempio n. 6
0
 private void CodePackageActivationContext_ConfigurationPackageModifiedEvent(
     object sender,
     PackageModifiedEventArgs <ConfigurationPackage> e)
 {
     ServiceEventSource.Current.Message(
         "CodePackageActivationContext_ConfigurationPackageModifiedEvent");
     LoadConfiguration();
 }
 /// <summary>
 /// Callback event for Configuration upgrade, this function is added to the
 /// list of <see cref="ICodePackageActivationContext.ConfigurationPackageModifiedEvent"/>
 /// </summary>
 /// <param name="sender">Sender of config upgrade</param>
 /// <param name="e">Contains new and old package along with other details related to configuration</param>
 internal void OnConfigurationPackageModified(object sender, PackageModifiedEventArgs <ConfigurationPackage> e)
 {
     if (e.NewPackage.Description.Name.Equals("Config"))
     {
         ServiceEventSource.Current.VerboseMessage("Configuration upgrade triggered from {0} to {1}",
                                                   e.OldPackage.Description.Version, e.NewPackage.Description.Version);
         this.InitializeConfiguration(e.NewPackage);
     }
 }
        /// <summary>
        /// Called when a change to an existing configuration package has been deployed.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">PackageAddedEventArgs&lt;ConfigurationPackage&gt; instance.</param>
        void ConfigurationPackageModified(object sender, PackageModifiedEventArgs <ConfigurationPackage> e)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(e));
            }

            // Attempt to load the configuration. Only load the new ones, the old settings are cached within the provider.
            this.LoadConfiguration(e.NewPackage.Path, e.NewPackage.Settings.Sections);
        }
Esempio n. 9
0
        private void CodePackageActivationContext_ConfigurationPackageModifiedEvent(object sender,
                                                                                    PackageModifiedEventArgs <ConfigurationPackage> e)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(e));
            }

            ReadSettings(e.NewPackage);
        }
 private void OnContextOnConfigurationPackageModifiedEvent(
     object sender,
     PackageModifiedEventArgs <ConfigurationPackage> args)
 {
     this.OnConfigPackageModified.NotifyAsync(
         this,
         new ServiceEventPayloadOnPackageModified <ConfigurationPackage>(args.OldPackage, args.NewPackage))
     .GetAwaiter()
     .GetResult();
 }
        protected override void ConfigurationModified(object sender, PackageModifiedEventArgs <ConfigurationPackage> e)
        {
            if (e.NewPackage.Settings.Sections.Contains("SendGridAdapter"))
            {
                var configSection = e.NewPackage.Settings.Sections["SendGridAdapter"];
                this.configurationCorrect  = GetConfigValue <string>(configSection, "SendMailUri", ref sendMailUri);
                this.configurationCorrect &= GetConfigValue <string>(configSection, "ApiKey", ref apiKey);
                this.configurationCorrect &= GetConfigValue <string>(configSection, "FromAddress", ref fromAddress);

                if (string.IsNullOrWhiteSpace(this.sendMailUri) && Uri.IsWellFormedUriString(this.sendMailUri, UriKind.Absolute))
                {
                    this.parent.ReportHealthInformation(ConfigurationHealthPropertyName,
                                                        $"Parameter 'SendMailUri'not valid!", System.Fabric.Health.HealthState.Error);
                    this.configurationCorrect = false;
                }

                if (string.IsNullOrWhiteSpace(this.apiKey))
                {
                    this.parent.ReportHealthInformation(ConfigurationHealthPropertyName,
                                                        $"Parameter 'ApiKey'not valid!", System.Fabric.Health.HealthState.Error);
                    this.configurationCorrect = false;
                }

                if (string.IsNullOrWhiteSpace(this.fromAddress))
                {
                    this.parent.ReportHealthInformation(ConfigurationHealthPropertyName,
                                                        $"Parameter 'FromAddress'not valid!", System.Fabric.Health.HealthState.Error);
                    this.configurationCorrect = false;
                }

                if (this.configurationCorrect)
                {
                    this.parent.ReportHealthInformation(ConfigurationHealthPropertyName,
                                                        $"Configuration correct!", System.Fabric.Health.HealthState.Ok);
                }
            }
            else
            {
                this.parent.ReportHealthInformation(ConfigurationHealthPropertyName,
                                                    "Configuration section 'SendGridAdapter' not exists!", System.Fabric.Health.HealthState.Error);
            }
        }
 void OnConfigurationPackageModified(object sender, PackageModifiedEventArgs <ConfigurationPackage> e)
 {
     try
     {
         storeReplica.UpdateReplicatorSettings(BuildReplicatorSettings());
     }
     catch (FabricElementNotFoundException ex)
     {
         WriteError("FabricElementNotFoundException while loading replicator settings from configuation.", ex);
         partition.ReportFault(FaultType.Transient);
     }
     catch (FabricException ex)
     {
         WriteError("FabricException while loading replicator security settings from configuation.", ex);
         partition.ReportFault(FaultType.Transient);
     }
     catch (ArgumentException ex)
     {
         WriteWarning("ArgumentException while updating replicator settings from configuation.", ex);
         partition.ReportFault(FaultType.Transient);
     }
 }
Esempio n. 13
0
 private void CodePackageActivationContext_DataPackageModifiedEvent(object sender, PackageModifiedEventArgs <DataPackage> e)
 {
     this.UpdateApplicationPackageData(e.NewPackage.Path);
 }
 private void CodePackageActivationContext_DataPackageModifiedEvent(object sender, PackageModifiedEventArgs<DataPackage> e)
 {
     this.UpdateApplicationPackageData(e.NewPackage.Path);
 }
Esempio n. 15
0
 public void OnDataPackageModifiedEvent(PackageModifiedEventArgs <DataPackage> e)
 {
     DataPackageModifiedEvent?.Invoke(this, e);
 }
Esempio n. 16
0
 private void OnConfigurationPackageModified(object sender, PackageModifiedEventArgs <ConfigurationPackage> e)
 {
     this.RefreshConfigPackage();
 }
 private void CodePackageActivationContext_DataPackageModifiedEvent(object sender, PackageModifiedEventArgs <DataPackage> e)
 {
     this.UpdateJoinMailTemplateContent(e.NewPackage.Path);
 }
Esempio n. 18
0
 private void ConfigurationPackageModifiedEvent(object sender,
                                                PackageModifiedEventArgs <ConfigurationPackage> e)
 {
     this.ReadSettings(e.NewPackage.Settings, true);
 }
Esempio n. 19
0
 private void ConfigurationPackageModifiedEvent(object sender, PackageModifiedEventArgs <ConfigurationPackage> e)
 {
     DumpConfiguration(ConfigurationPackageEvent.Modified, e.OldPackage, "previous: ");
     DumpConfiguration(ConfigurationPackageEvent.Modified, e.NewPackage, "current: ");
 }
 /// <summary>
 /// This event handler is called whenever a new data package is available.
 /// We can do whatever we want with the event. 
 /// In this sample, we reconfigure the service without stopping anything.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void CodePackageActivationContext_DataPackageModifiedEvent(object sender, PackageModifiedEventArgs<DataPackage> e)
 {
     // The Path property contains a path to our data file that we included with the data package.
     this.UpdateRequestData(e.NewPackage.Path);
 }
Esempio n. 21
0
 private static void DataPackageModified(object sender, PackageModifiedEventArgs <DataPackage> e)
 {
     Environment.Exit(0);
 }
 private void CodePackageActivationContext_ConfigurationPackageModifiedEvent(object sender, PackageModifiedEventArgs<ConfigurationPackage> e)
 {
     this.UpdateSendMailSettings(e.NewPackage.Settings);
 }
Esempio n. 23
0
 private static void ConfigPackageModified(object sender, PackageModifiedEventArgs <ConfigurationPackage> e)
 {
     Environment.Exit(0);
 }
 private void ConfigPackageChangedEvent(object sender, PackageModifiedEventArgs <ConfigurationPackage> e)
 {
     this.ConfigurationPackage = e.NewPackage;
     this.UpdateConfigSettings();
 }
Esempio n. 25
0
        /// <summary>
        /// Handle notifications of setting changes
        /// </summary>
        private void CodePackageActivationContext_ConfigurationPackageModifiedEvent(object sender, PackageModifiedEventArgs <ConfigurationPackage> e)
        {
            var env = e.NewPackage.Settings.Sections["WorkerConfig"].Parameters["Environment"];

            ServiceEventSource.Current.ServiceMessage(this, "New Config, environment: {0}, path: {1}", env.Value, e.NewPackage.Path);
        }
Esempio n. 26
0
 public void OnConfigurationPackageModifiedEvent(PackageModifiedEventArgs <ConfigurationPackage> e)
 {
     ConfigurationPackageModifiedEvent?.Invoke(this, e);
 }
        /// <summary>
        /// This event handler is called whenever a new config package is available.
        /// We can do whatever we want with the event. 
        /// In this sample, we reconfigure the service without stopping anything.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CodePackageActivationContext_ConfigurationPackageModifiedEvent(object sender, PackageModifiedEventArgs<ConfigurationPackage> e)
        {
            // The Settings property contains the built-in Settings.xml config.
            this.UpdateApplicationSettings(e.NewPackage.Settings);

            // The Path property contains a path to our custom config file that we included with the config package.
            this.UpdateRequestSettings(e.NewPackage.Path);
        }
Esempio n. 28
0
        /// <summary>
        /// Called when a change to an existing configuration package has been deployed.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">PackageAddedEventArgs&lt;ConfigurationPackage&gt; instance.</param>
        private void CodePackageActivationContext_ConfigurationPackageModifiedEvent(object sender, PackageModifiedEventArgs <ConfigurationPackage> e)
        {
            Guard.ArgumentNotNull(e, nameof(e));

            // Attempt to load the configuration. Only load the new ones, the old settings are cached within the provider.
            LoadConfiguration(e.NewPackage.Path, e.NewPackage.Settings.Sections);
        }
Esempio n. 29
0
        private void CodePackageActivationContext_ConfigurationPackageModifiedEvent(object sender, PackageModifiedEventArgs <ConfigurationPackage> e)
        {
            var configSection = this.Context.CodePackageActivationContext.GetConfigurationPackageObject("Config");
            var text          = configSection.Settings.Sections["MyConfigSection"].Parameters["IncrementStep"].Value;

            incrementStep = int.Parse(text);
        }
Esempio n. 30
0
 private void CodePackageActivationContext_ConfigurationPackageModifiedEvent(object sender, PackageModifiedEventArgs <ConfigurationPackage> e)
 {
     if ("Config" == e.NewPackage.Description.Name)
     {
         lock (thisLock)
         {
             this._logger.Dispose();
             this._logger = InitializeLogger(e.NewPackage.Settings);
         }
     }
 }
 private void CodePackageActivationContextOnCodePackageModifiedEvent(object sender, PackageModifiedEventArgs <CodePackage> packageModifiedEventArgs)
 {
     LoadConfiguration();
 }
 private void CodePackageActivationContext_DataPackageModifiedEvent(object sender, PackageModifiedEventArgs<DataPackage> e)
 {
     this.UpdateJoinMailTemplateContent(e.NewPackage.Path);
 }
 protected virtual void ConfigurationModified(object sender, PackageModifiedEventArgs <ConfigurationPackage> e)
 {
 }
Esempio n. 34
0
 private void CodePackageActivationContext_ConfigurationPackageModifiedEvent(object sender, PackageModifiedEventArgs <ConfigurationPackage> e)
 {
     this.UpdateConfigSettings(e.NewPackage.Settings);
 }
Esempio n. 35
0
        /// <summary>
        /// Called when a configuration package is modified.
        /// </summary>
        private void CodePackageActivationContext_ConfigurationPackageModifiedEvent(object sender, PackageModifiedEventArgs <ConfigurationPackage> e)
        {
            if ("Config" == e.NewPackage.Description.Name)
            {
                lock (thisLock)
                {
                    this._settings = e.NewPackage.Settings;
                    this._logger.Dispose();
                    this._logger = InitializeLogger(this._settings);

                    if (this._perfCounters != null)
                    {
                        foreach (var counter in this._perfCounters)
                        {
                            counter.Dispose();
                        }
                    }
                    this._perfCounters = InitializePerformanceCounters(this._settings);
                }
            }
        }