Ejemplo n.º 1
0
        private static void ConfigureServices(IServiceCollection services, ReassemblerCliOptions opts)
        {
            services.AddLogging();

            services.AddSingleton <IClusterSettings, ClusterSettings>(
                provider => new ClusterSettings
            {
                ClusterNodeHostname     = opts.ClusterNodeHostname,
                ClusterNodePort         = opts.ClusterNodePort,
                ClusterSeedNodeHostname = opts.ClusterSeedNodeHostname
            });

            services.AddSingleton <IHostedService, ReassemblerService>();

            ActorsServiceInstaller.Install(services);
            FacadesServiceInstaller.Install(services);

            if (opts.DevnullRepository)
            {
                DevNullServiceInstaller.Install(services);
            }
            else if (opts.CassandraRepository)
            {
                CassandraServiceInstaller.Install(services, opts.CassandraKeyspace, opts.CassandraContactPoint);
            }
            else
            {
                InMemoryServiceInstaller.Install(services);
            }

            if (opts.OutPcapDirectory != null)
            {
                services.AddSingleton <IPcapFacadeConfiguration>(new PcapFacadeConfiguration
                {
                    BaseDirectory = opts.OutPcapDirectory
                });
                services.AddSingleton <IPcapFacade, PcapFacade>();
            }
            else
            {
                services.AddSingleton <IPcapFacade, PcapDevnullFacade>();
            }
        }
Ejemplo n.º 2
0
        private static void ConfigureServices(IServiceCollection services, ReassemblerCliOptions opts)
        {
            services.AddLogging();

            services.AddSingleton <IClusterSettings, ClusterSettings>(
                provider => new ClusterSettings
            {
                ClusterNodeHostname     = opts.ClusterNodeHostname,
                ClusterNodePort         = opts.ClusterNodePort,
                ClusterSeedNodeHostname = opts.ClusterSeedNodeHostname
            });

            services.AddSingleton <IHostedService, ReassemblerService>();

            services.AddSingleton <ICaptureFacade, CaptureFacade>();
            services.AddSingleton <IL7ConversationFacade, L7ConversationFacade>();
            services.AddSingleton <ICaptureTrackingActorFactory, CaptureTrackingActorFactory>();
            services.AddSingleton <IRawPacketBatchParserActorFactory, RawPacketBatchParserActorFactory>();
            services.AddSingleton <ICaptureTrackingActorFactory, CaptureTrackingActorFactory>();
            services.AddSingleton <IL3ConversationTrackingActorFactory, L3ConversationTrackingActorFactory>();
            services.AddSingleton <IL4ConversationTrackingActorFactory, L4ConversationTrackingActorFactory>();
            services.AddSingleton <IL7ConversationStorageActorFactory, L7ConversationStorageActorFactory>();

            if (opts.DevnullRepository)
            {
                DevNullServiceInstaller.Install(services);
            }
            else if (opts.CassandraRepository)
            {
                CassandraServiceInstaller.Install(services, opts.CassandraKeyspace, opts.CassandraContactPoint);
            }
            else
            {
                InMemoryServiceInstaller.Install(services);
            }
        }
Ejemplo n.º 3
0
        private static void ConfigureServices(LoadBalancerCliOptions opts)
        {
            IServiceCollection services = new ServiceCollection();

            services.AddLogging();
            services.AddSingleton(services);
            services.AddSingleton(provider => provider);
            services.AddSingleton <IPcapLoader, PcapLoader.PcapLoader>();

            services.AddSingleton <LoadBalancerRunner>();
            services.AddSingleton <IAkkaSettings>(new AkkaSettings {
                IsDebug = opts.IsDebug
            });

            if (opts.Uri.Scheme == "rpcap")
            {
                services.AddSingleton <ICaptureDeviceFactory, CaptureLiveDeviceFactory>();
            }
            else
            {
                services.AddSingleton <ICaptureDeviceFactory, CaptureDeviceFactory>();
            }

            services.AddSingleton <ILoadBalancerRunner, LoadBalancerRunner>();
            services.AddSingleton <ILoadBalancerRunnerFactory, LoadBalancerRunnerFactory>();
            services.AddSingleton <IBatchLoader, BatchLoader>();
            services.AddSingleton <IBatchSender, BatchSender>();

            ActorsServiceInstaller.Install(services);
            FacadesServiceInstaller.Install(services);

            if (opts.Offline)
            {
                services.AddSingleton <IPacketIngestor, OfflineLoadBalancer>();
                services.AddSingleton <IOfflineLoadBalancerActorFactory, OfflineLoadBalancerActorFactory>();
            }
            else
            {
                services.AddSingleton <IPacketIngestor, OnlineLoadBalancer>();
                services.AddSingleton <IClusterSettings, ClusterSettings>(
                    provider => new ClusterSettings
                {
                    ClusterNodeHostname     = opts.ClusterNodeHostname,
                    ClusterNodePort         = opts.ClusterNodePort,
                    ClusterSeedNodeHostname = opts.ClusterSeedNodeHostname
                });
                services.AddSingleton <IClusterMember, OnlineLoadBalancer>();
                services.AddSingleton <IOnlineLoadBalancerActorFactory, OnlineLoadBalancerActorFactory>();
            }

            if (opts.DevnullRepository)
            {
                DevNullServiceInstaller.Install(services);
            }
            else if (opts.CassandraRepository)
            {
                CassandraServiceInstaller.Install(services, opts.CassandraKeyspace, opts.CassandraContactPoint);
            }
            // Not specified or InMemoryRepository selected
            else
            {
                InMemoryServiceInstaller.Install(services);
            }

            if (opts.OutPcapDirectory != null)
            {
                services.AddSingleton <IPcapFacadeConfiguration>(new PcapFacadeConfiguration
                {
                    BaseDirectory = opts.OutPcapDirectory
                });
                services.AddSingleton <IPcapFacade, PcapFacade>();
            }
            else
            {
                services.AddSingleton <IPcapFacade, PcapDevnullFacade>();
            }

            services.AddLogging(builder => builder.AddConsole());

            var serviceProvider = services.BuildServiceProvider();

            _loadBalancerRunnerFactory = serviceProvider.GetService <ILoadBalancerRunnerFactory>();
        }
Ejemplo n.º 4
0
        private static void ConfigureServices(LoadBalancerCliOptions opts)
        {
            IServiceCollection serviceCollection = new ServiceCollection();

            serviceCollection.AddLogging();
            serviceCollection.AddSingleton(serviceCollection);
            serviceCollection.AddSingleton(provider => provider);
            serviceCollection.AddSingleton <IPcapLoader, PcapLoader.PcapLoader>();

            serviceCollection.AddSingleton <LoadBalancerRunner>();
            serviceCollection.AddSingleton <IAkkaSettings>(new AkkaSettings {
                IsDebug = opts.IsDebug
            });

            if (opts.Uri.Scheme == "rpcap")
            {
                serviceCollection.AddSingleton <ICaptureDeviceFactory, CaptureLiveDeviceFactory>();
            }
            else
            {
                serviceCollection.AddSingleton <ICaptureDeviceFactory, CaptureDeviceFactory>();
            }

            serviceCollection.AddSingleton <ICaptureFacade, CaptureFacade>();
            serviceCollection.AddSingleton <IL7ConversationFacade, L7ConversationFacade>();

            serviceCollection.AddSingleton <ILoadBalancerRunner, LoadBalancerRunner>();
            serviceCollection.AddSingleton <ILoadBalancerRunnerFactory, LoadBalancerRunnerFactory>();
            serviceCollection.AddSingleton <IBatchLoader, BatchLoader>();
            serviceCollection.AddSingleton <IBatchSender, BatchSender>();
            serviceCollection.AddSingleton <IRawPacketBatchParserActorFactory, RawPacketBatchParserActorFactory>();
            serviceCollection.AddSingleton <ICaptureTrackingActorFactory, CaptureTrackingActorFactory>();
            serviceCollection.AddSingleton <IL3ConversationTrackingActorFactory, L3ConversationTrackingActorFactory>();
            serviceCollection.AddSingleton <IL4ConversationTrackingActorFactory, L4ConversationTrackingActorFactory>();
            serviceCollection.AddSingleton <IL7ConversationStorageActorFactory, L7ConversationStorageActorFactory>();

            if (opts.Offline)
            {
                serviceCollection.AddSingleton <IPacketIngestor, OfflineLoadBalancer>();
                serviceCollection.AddSingleton <IOfflineLoadBalancerActorFactory, OfflineLoadBalancerActorFactory>();
            }
            else
            {
                serviceCollection.AddSingleton <IPacketIngestor, OnlineLoadBalancer>();
                serviceCollection.AddSingleton <IClusterSettings, ClusterSettings>(
                    provider => new ClusterSettings
                {
                    ClusterNodeHostname     = opts.ClusterNodeHostname,
                    ClusterNodePort         = opts.ClusterNodePort,
                    ClusterSeedNodeHostname = opts.ClusterSeedNodeHostname
                });
                serviceCollection.AddSingleton <IClusterMember, OnlineLoadBalancer>();
                serviceCollection.AddSingleton <IOnlineLoadBalancerActorFactory, OnlineLoadBalancerActorFactory>();
            }

            if (opts.DevnullRepository)
            {
                DevNullServiceInstaller.Install(serviceCollection);
            }
            else if (opts.CassandraRepository)
            {
                CassandraServiceInstaller.Install(serviceCollection, opts.CassandraKeyspace, opts.CassandraContactPoint);
            }
            // Not specified or InMemoryRepository selected
            else
            {
                InMemoryServiceInstaller.Install(serviceCollection);
            }

            var services = serviceCollection.BuildServiceProvider();

            services.GetService <ILoggerFactory>().AddProvider(opts.IsDebug ?
                                                               new ConsoleLoggerProvider((s, level) => level >= LogLevel.Debug, true) :
                                                               new ConsoleLoggerProvider((s, level) => level >= LogLevel.Error, true));

            _loadBalancerRunnerFactory = services.GetService <ILoadBalancerRunnerFactory>();
        }