예제 #1
0
        public SystemService(
            ILogger <SystemService> logger,
            IServiceProvider serviceProvider,
            IXNodeConnectionRepository xNodeConnectionRepository,
            SystemIOService systemIOService,
            TenantIOService tenantIOService,
            ProducerIOService producerIOService,
            ConsumerIOService consumerIOService,
            MessageIOService messageIOService2)
        {
            _logger          = logger;
            _serviceProvider = serviceProvider;

            _xNodeConnectionRepository = xNodeConnectionRepository;
            _systemIOService           = systemIOService;
            _tenantIOService           = tenantIOService;
            _producerIOService         = producerIOService;
            _consumerIOService         = consumerIOService;
            _messageIOService2         = messageIOService2;
            nodes       = _serviceProvider.GetService(typeof(List <XNodeConfiguration>)) as List <XNodeConfiguration>;
            dataStorage = _serviceProvider.GetService(typeof(DataStorageConfiguration)) as DataStorageConfiguration;
            agent       = _serviceProvider.GetService(typeof(AgentConfiguration)) as AgentConfiguration;
            partition   = _serviceProvider.GetService(typeof(PartitionConfiguration)) as PartitionConfiguration;
            credentials = _serviceProvider.GetService(typeof(CredentialsConfiguration)) as CredentialsConfiguration;


            DoFileConfiguration();

            UpdateXNodesConfiguration();
            UpdateDataStorageConfiguration();
            UpdateCredentials();

            InitializeServices();
        }
예제 #2
0
        private static void BindPartitionConfiguration(this IServiceCollection services, IConfiguration configuration)
        {
            var partitionConfiguration = new PartitionConfiguration();

            configuration.Bind("Partition", partitionConfiguration);
            services.AddSingleton(partitionConfiguration);
        }
예제 #3
0
        public MessageIOService(
            ILogger <MessageIOService> logger,
            PartitionConfiguration partitionConfiguration,
            AgentConfiguration agentConfiguration,
            ConsumerIOService consumerIOService)
        {
            _logger = logger;
            _partitionConfiguration = partitionConfiguration;
            _agentConfiguration     = agentConfiguration;
            _consumerIOService      = consumerIOService;

            connectors = new ConcurrentDictionary <string, MessageStorageConnector>();
        }
예제 #4
0
        public ConsumerConnector(ILogger <ConsumerIOService> logger,
                                 string tenant,
                                 string product,
                                 string component,
                                 string topic,
                                 string consumer,
                                 ConsumerPointerContext consumerPointer,
                                 PartitionConfiguration partitionConfiguration,
                                 int agentCount)
        {
            _logger    = logger;
            _tenant    = tenant;
            _product   = product;
            _component = component;
            _topic     = topic;
            _consumer  = consumer;

            _partitionConfiguration = partitionConfiguration;


            ConsumerPointerContext = null;
            ThreadingPool          = new Model.Threading.ThreadPool(agentCount);

            MessagesBuffer = new ConcurrentQueue <Model.Entities.ConsumerMessage>();
            BatchAcknowledgedConsumerMessagesToMerge   = new ConcurrentDictionary <Guid, Model.Entities.ConsumerMessage>();
            BatchUnacknowledgedConsumerMessagesToMerge = new ConcurrentDictionary <Guid, Model.Entities.ConsumerMessage>();
            ConsumerPointerContext = consumerPointer;
            Count = 0;

            try
            {
                consumerPointer.ChangeTracker.AutoDetectChangesEnabled = false;
                consumerPointer.Database.EnsureCreated();

                // database exists
                // create new instance of Backend ConsumerArchiveBackgroundService
                _consumerArchiveBackgroundService = new ConsumerArchiveBackgroundService(logger, tenant, product, component, topic, consumer, partitionConfiguration, consumerPointer);
                _consumerArchiveBackgroundService.StartService();
            }
            catch (Exception)
            {
            }

            _flushPointerTimer           = new Timer();
            _flushPointerTimer.Interval  = partitionConfiguration.FlushInterval;
            _flushPointerTimer.Elapsed  += FlushPointerTimer_Elapsed;
            _flushPointerTimer.AutoReset = true;
            _flushPointerTimer.Start();
        }
예제 #5
0
        public MessageStorageConnector(PartitionConfiguration partitionConfiguration, int agentCount)
        {
            _partitionConfiguration = partitionConfiguration;

            MessageContext = null;
            ThreadingPool  = new Model.Threading.ThreadPool(agentCount);

            MessagesBuffer        = new ConcurrentQueue <Model.Entities.Message>();
            BatchMessagesToInsert = new ConcurrentDictionary <Guid, Model.Entities.Message>();

            _flushPointerTimer           = new Timer();
            _flushPointerTimer.Interval  = partitionConfiguration.FlushInterval;
            _flushPointerTimer.Elapsed  += FlushPointerTimer_Elapsed;
            _flushPointerTimer.AutoReset = true;
            _flushPointerTimer.Start();
        }
        public ConsumerIOService(
            ILogger <ConsumerIOService> logger,
            PartitionConfiguration partitionConfiguration,
            AgentConfiguration agentConfiguration)
        {
            _logger = logger;
            _partitionConfiguration = partitionConfiguration;
            _agentConfiguration     = agentConfiguration;
            consumerLogsQueue       = new ConcurrentQueue <ConsumerLog>();

            threadingPoolUnprocessedMessages = new Model.Threading.ThreadPool(agentConfiguration.MaxNumber);
            unprocessedMessageQueue          = new ConcurrentQueue <UnprocessedMessage>();

            connectors = new ConcurrentDictionary <string, ConsumerConnector>();

            InitializeAllConsumerConnections();
        }
예제 #7
0
        static void Main(string[] args)
        {
            var auditLog = new SimpleAuditLog();
            var planner  = new Planner(1000, 900, 200, 50);

            var partitionConfig = new PartitionConfiguration(
                new Dictionary <string, int>
            {
                { "a", 1 },
                { "b", 1 },
                { "c", 1 },
                { "d", 1 },
                { "e", 2 },
                { "f", 2 },
                { "g", 2 },
                { "h", 2 },
            },
                false
                );

            var servers = new List <IServer>
            {
                new RaftServer("a", auditLog, planner),
                new RaftServer("b", auditLog, planner),
                new RaftServer("c", auditLog, planner),
                new RaftServer("e", auditLog, planner),
                new RaftServer("f", auditLog, planner),
                new RaftServer("g", auditLog, planner),
                new RaftServer("h", auditLog, planner),
            };



            foreach (var server in servers)
            {
                server.Initialise(servers.Where(s => s.Id != server.Id).Select(s => new ProxyWithPartitions(new ReliableProxy(s, 100), partitionConfig)));
            }

            System.Threading.Thread.Sleep(10000);
            partitionConfig.Partition();
            System.Threading.Thread.Sleep(10000);
            partitionConfig.Heal();
            System.Threading.Thread.Sleep(10000);
        }
예제 #8
0
        public ConsumerArchiveBackgroundService(ILogger <ConsumerIOService> logger,
                                                string tenant,
                                                string product,
                                                string component,
                                                string topic,
                                                string consumer,
                                                PartitionConfiguration partitionConfiguration,
                                                ConsumerPointerContext consumerPointerContext)
        {
            _logger    = logger;
            _tenant    = tenant;
            _product   = product;
            _component = component;
            _topic     = topic;
            _consumer  = consumer;

            _partitionConfiguration = partitionConfiguration;
            _consumerPointerContext = consumerPointerContext;

            InitializeBackgroundTask();
        }
예제 #9
0
 public ProxyWithPartitions(IServerProxy proxy, PartitionConfiguration config)
 {
     _proxy  = proxy;
     _config = config;
 }