Пример #1
0
        /// <summary>
        /// Starts the adapter.
        /// This method returns immediately leaving to a background worker
        /// the task of getting the data and process it.
        ///
        /// Throws an exception if it can't initialise itself.
        /// </summary>
        public void Start()
        {
            try
            {
                LogVersions();

                if (SdkActorSystem.InitializeActors)
                {
                    _logger.Info("SDK is restarting...");
                    UDAPI.Init(new UdapiConfiguration(_settings));
                }

                _logger.Info("Adapter is connecting to the UDAPI service...");

                _udapiServiceFacade.Connect();
                if (!_udapiServiceFacade.IsConnected)
                {
                    return;
                }

                _logger.Debug("Adapter connected to the UDAPI - initialising...");

                AdapterActorSystem.Init(
                    _settings,
                    _udapiServiceFacade,
                    _platformConnector,
                    _stateManager,
                    _suspensionManager,
                    _streamHealthCheckValidation,
                    _fixtureValidation);

                _logger.InfoFormat("Adapter started");
                _stats.SetValue(AdapterCoreKeys.ADAPTER_STARTED, "1");
            }
            catch (Exception ex)
            {
                _logger.Fatal("A fatal error has occurred and the Adapater cannot start. You can try a manual restart", ex);
                throw;
            }
        }
Пример #2
0
        public Adapter(
            ISettings settings,
            IServiceFacade udapiServiceFacade,
            IAdapterPlugin platformConnector,
            IStateManager stateManager,
            IStateProvider stateProvider,
            ISuspensionManager suspensionManager,
            IStreamHealthCheckValidation streamHealthCheckValidation,
            IFixtureValidation fixtureValidation)
        {
            _settings                    = settings ?? throw new ArgumentNullException(nameof(settings));
            _udapiServiceFacade          = udapiServiceFacade ?? throw new ArgumentNullException(nameof(udapiServiceFacade));
            _platformConnector           = platformConnector ?? throw new ArgumentNullException(nameof(platformConnector));
            _stateManager                = stateManager ?? throw new ArgumentNullException(nameof(stateManager));
            _suspensionManager           = suspensionManager ?? throw new ArgumentNullException(nameof(suspensionManager));
            _streamHealthCheckValidation = streamHealthCheckValidation ?? throw new ArgumentNullException(nameof(streamHealthCheckValidation));
            _fixtureValidation           = fixtureValidation ?? throw new ArgumentNullException(nameof(fixtureValidation));

            UDAPI.Init(new UdapiConfiguration(_settings));

            StateProviderProxy.Init(stateProvider);

            if (settings.StatsEnabled)
            {
                StatsManager.Configure();
            }

            platformConnector.Initialise();
            stateManager.AddRules(platformConnector.MarketRules);

            ThreadPool.SetMinThreads(500, 500);

            _stats = StatsManager.Instance["adapter.core"].GetHandle();

            PopuplateAdapterVersionInfo();
        }