Пример #1
0
        public void Register(ContainerBuilder builder)
        {
            builder.RegisterModule(new LoggingModule());
            builder.RegisterBuildCallback(
                c =>
            {
                // set up loggers for Dotnetty
                var loggerFactory = c.Resolve <ILoggerFactory>();
                InternalLoggerFactory.DefaultFactory = loggerFactory;

                var eventListener = new LoggerEventListener(loggerFactory.CreateLogger("EdgeHub"));
                eventListener.EnableEvents(CommonEventSource.Log, EventLevel.Informational);
            });

            bool optimizeForPerformance = this.configuration.GetValue("OptimizeForPerformance", true);

            (bool isEnabled, bool usePersistentStorage, StoreAndForwardConfiguration config, string storagePath, bool useBackupAndRestore, Option <string> storageBackupPath, Option <ulong> storageMaxTotalWalSize, Option <StorageLogLevel> storageLogLevel)storeAndForward =
                this.GetStoreAndForwardConfiguration();

            IConfiguration       configuration        = this.configuration.GetSection("experimentalFeatures");
            ExperimentalFeatures experimentalFeatures = ExperimentalFeatures.Create(configuration, Logger.Factory.CreateLogger("EdgeHub"));

            // Temporarly make metrics default to off for windows. This is only until the dotnet 3.1 work is completed
            // This temp fix is needed to fix all e2e tests since edgehub currently crashes
            MetricsConfig metricsConfig = new MetricsConfig(this.configuration.GetSection("metrics:listener"), !RuntimeInformation.IsOSPlatform(OSPlatform.Windows));

            this.RegisterCommonModule(builder, optimizeForPerformance, storeAndForward, metricsConfig);
            this.RegisterRoutingModule(builder, storeAndForward, experimentalFeatures);
            this.RegisterMqttModule(builder, storeAndForward, optimizeForPerformance);
            this.RegisterAmqpModule(builder);
            builder.RegisterModule(new HttpModule());
        }
Пример #2
0
        public void Register(ContainerBuilder builder)
        {
            builder.RegisterModule(new LoggingModule());
            builder.RegisterBuildCallback(
                c =>
            {
                // set up loggers for Dotnetty
                var loggerFactory = c.Resolve <ILoggerFactory>();
                InternalLoggerFactory.DefaultFactory = loggerFactory;

                var eventListener = new LoggerEventListener(loggerFactory.CreateLogger("EdgeHub"));
                eventListener.EnableEvents(CommonEventSource.Log, EventLevel.Informational);
            });

            bool optimizeForPerformance = this.configuration.GetValue("OptimizeForPerformance", true);

            (bool isEnabled, bool usePersistentStorage, StoreAndForwardConfiguration config, string storagePath, bool useBackupAndRestore, Option <string> storageBackupPath, Option <ulong> storageMaxTotalWalSize)storeAndForward =
                this.GetStoreAndForwardConfiguration();

            IConfiguration       configuration        = this.configuration.GetSection("experimentalFeatures");
            ExperimentalFeatures experimentalFeatures = ExperimentalFeatures.Create(configuration);

            MetricsListenerConfig listenerConfig = experimentalFeatures.EnableMetrics
                ? MetricsListenerConfig.Create(this.configuration.GetSection("metrics:listener"))
                : new MetricsListenerConfig();
            MetricsConfig metricsConfig = new MetricsConfig(experimentalFeatures.Enabled, listenerConfig);

            this.RegisterCommonModule(builder, optimizeForPerformance, storeAndForward, metricsConfig);
            this.RegisterRoutingModule(builder, storeAndForward, experimentalFeatures);
            this.RegisterMqttModule(builder, storeAndForward, optimizeForPerformance);
            this.RegisterAmqpModule(builder);
            builder.RegisterModule(new HttpModule());
        }
Пример #3
0
        static ExperimentalFeatures CreateExperimentalFeatures(IConfigurationRoot configuration)
        {
            IConfiguration       experimentalFeaturesConfig = configuration.GetSection(Constants.ConfigKey.ExperimentalFeatures);
            ExperimentalFeatures experimentalFeatures       = ExperimentalFeatures.Create(experimentalFeaturesConfig, Logger.Factory.CreateLogger("EdgeHub"));

            return(experimentalFeatures);
        }
Пример #4
0
        public void Register(ContainerBuilder builder)
        {
            builder.RegisterModule(new LoggingModule());
            builder.RegisterBuildCallback(
                c =>
            {
                // set up loggers for Dotnetty
                var loggerFactory = c.Resolve <ILoggerFactory>();
                InternalLoggerFactory.DefaultFactory = loggerFactory;

                var eventListener = new LoggerEventListener(loggerFactory.CreateLogger("EdgeHub"));
                eventListener.EnableEvents(CommonEventSource.Log, EventLevel.Informational);
            });

            bool            optimizeForPerformance = this.configuration.GetValue("OptimizeForPerformance", true);
            StoreAndForward storeAndForward        = this.GetStoreAndForwardConfiguration();

            IConfiguration       experimentalFeaturesConfig = this.configuration.GetSection(Constants.ConfigKey.ExperimentalFeatures);
            ExperimentalFeatures experimentalFeatures       = ExperimentalFeatures.Create(experimentalFeaturesConfig, Logger.Factory.CreateLogger("EdgeHub"));

            MetricsConfig metricsConfig = new MetricsConfig(this.configuration.GetSection("metrics:listener"));

            bool nestedEdgeEnabled = this.configuration.GetValue <bool>(Constants.ConfigKey.NestedEdgeEnabled, true);

            if (!Enum.TryParse(this.configuration.GetValue("AuthenticationMode", string.Empty), true, out AuthenticationMode authenticationMode))
            {
                authenticationMode = AuthenticationMode.Scope;
            }

            bool trackDeviceState = authenticationMode == AuthenticationMode.Scope &&
                                    this.configuration.GetValue("TrackDeviceState", true);

            string proxyModuleId = this.configuration.GetValue("ApiProxyModuleId", Core.Constants.DefaultApiProxyId);

            this.RegisterCommonModule(builder, optimizeForPerformance, storeAndForward, metricsConfig, nestedEdgeEnabled, authenticationMode);
            this.RegisterRoutingModule(builder, storeAndForward, experimentalFeatures, nestedEdgeEnabled, authenticationMode == AuthenticationMode.Scope, trackDeviceState);
            this.RegisterMqttModule(builder, storeAndForward, optimizeForPerformance, experimentalFeatures);
            this.RegisterAmqpModule(builder);
            builder.RegisterModule(new HttpModule(this.iotHubHostname, this.edgeDeviceId, proxyModuleId));

            if (experimentalFeatures.EnableMqttBroker)
            {
                var authConfig = this.configuration.GetSection("authAgentSettings");
                builder.RegisterModule(new AuthModule(authConfig));

                var mqttBrokerConfig = this.configuration.GetSection("mqttBrokerSettings");
                builder.RegisterModule(new MqttBrokerModule(mqttBrokerConfig));
            }
        }
Пример #5
0
        static async Task <EdgeHubProtocolHead> GetEdgeHubProtocolHeadAsync(ILogger logger, IConfigurationRoot configuration, IContainer container, Hosting hosting)
        {
            IConfiguration       experimentalFeaturesConfig = configuration.GetSection(Constants.ConfigKey.ExperimentalFeatures);
            ExperimentalFeatures experimentalFeatures       = ExperimentalFeatures.Create(experimentalFeaturesConfig, Logger.Factory.CreateLogger("EdgeHub"));

            var protocolHeads = new List <IProtocolHead>();

            // MQTT broker overrides the legacy MQTT protocol head
            if (configuration.GetValue("mqttSettings:enabled", true) && !experimentalFeatures.EnableMqttBroker)
            {
                protocolHeads.Add(await container.Resolve <Task <MqttProtocolHead> >());
            }

            if (configuration.GetValue("amqpSettings:enabled", true))
            {
                protocolHeads.Add(await container.Resolve <Task <AmqpProtocolHead> >());
            }

            if (configuration.GetValue("httpSettings:enabled", true))
            {
                protocolHeads.Add(new HttpProtocolHead(hosting.WebHost));
            }

            var orderedProtocolHeads = new List <IProtocolHead>();

            if (experimentalFeatures.EnableMqttBroker)
            {
                orderedProtocolHeads.Add(container.Resolve <MqttBrokerProtocolHead>());
                orderedProtocolHeads.Add(await container.Resolve <Task <AuthAgentProtocolHead> >());
            }

            switch (orderedProtocolHeads.Count)
            {
            case 0:
                break;

            case 1:
                protocolHeads.Add(orderedProtocolHeads.First());
                break;

            default:
                protocolHeads.Add(new OrderedProtocolHead(orderedProtocolHeads));
                break;
            }

            return(new EdgeHubProtocolHead(protocolHeads, logger));
        }
Пример #6
0
        public void Register(ContainerBuilder builder)
        {
            builder.RegisterModule(new LoggingModule());
            builder.RegisterBuildCallback(
                c =>
            {
                // set up loggers for Dotnetty
                var loggerFactory = c.Resolve <ILoggerFactory>();
                InternalLoggerFactory.DefaultFactory = loggerFactory;

                var eventListener = new LoggerEventListener(loggerFactory.CreateLogger("EdgeHub"));
                eventListener.EnableEvents(CommonEventSource.Log, EventLevel.Informational);
            });

            bool            optimizeForPerformance = this.configuration.GetValue("OptimizeForPerformance", true);
            StoreAndForward storeAndForward        = this.GetStoreAndForwardConfiguration();

            IConfiguration       experimentalFeaturesConfig = this.configuration.GetSection(Constants.ConfigKey.ExperimentalFeatures);
            ExperimentalFeatures experimentalFeatures       = ExperimentalFeatures.Create(experimentalFeaturesConfig, Logger.Factory.CreateLogger("EdgeHub"));

            MetricsConfig metricsConfig = new MetricsConfig(this.configuration.GetSection("metrics:listener"));

            this.RegisterCommonModule(builder, optimizeForPerformance, storeAndForward, metricsConfig, experimentalFeatures);
            this.RegisterRoutingModule(builder, storeAndForward, experimentalFeatures);
            this.RegisterMqttModule(builder, storeAndForward, optimizeForPerformance, experimentalFeatures);
            this.RegisterAmqpModule(builder);
            builder.RegisterModule(new HttpModule(this.iotHubHostname));

            if (experimentalFeatures.EnableMqttBroker)
            {
                var authConfig = this.configuration.GetSection("authAgentSettings");
                builder.RegisterModule(new AuthModule(authConfig));

                var mqttBrokerConfig = this.configuration.GetSection("mqttBrokerSettings");
                builder.RegisterModule(new MqttBrokerModule(mqttBrokerConfig));
            }
        }