private void CrashAndInitializeAgainWithSnapshot()
        {
            //crash
            InputDisruptorPublisher.Shutdown();
            OutputDisruptor.ShutDown();
            _exchange.StopTimer();
            inputEventStore.ShutDown();
            outputEventStore.ShutDown();
            inputJournaler.ShutDown();
            outputJournaler.ShutDown();
            ContextRegistry.Clear();

            //initialize
            inputEventStore     = new RavenNEventStore(Constants.INPUT_EVENT_STORE);
            outputEventStore    = new RavenNEventStore(Constants.OUTPUT_EVENT_STORE);
            inputJournaler      = new Journaler(inputEventStore);
            outputJournaler     = new Journaler(outputEventStore);
            _applicationContext = ContextRegistry.GetContext();
            IList <CurrencyPair> currencyPairs = new List <CurrencyPair>();

            currencyPairs.Add(new CurrencyPair("BTCUSD", "USD", "BTC"));
            currencyPairs.Add(new CurrencyPair("BTCLTC", "LTC", "BTC"));
            currencyPairs.Add(new CurrencyPair("BTCDOGE", "DOGE", "BTC"));
            _exchange = new Exchange(currencyPairs, outputEventStore.LoadLastSnapshot());
            InputDisruptorPublisher.InitializeDisruptor(new IEventHandler <InputPayload>[] { _exchange, inputJournaler });
            OutputDisruptor.InitializeDisruptor(new IEventHandler <byte[]>[] { outputJournaler });
            _exchange.InitializeExchangeAfterSnaphot();
            LimitOrderBookReplayService service = new LimitOrderBookReplayService();

            service.ReplayOrderBooks(_exchange, outputJournaler);
            _exchange.EnableSnaphots(5000);
            ManualResetEvent resetEvent = new ManualResetEvent(false);

            resetEvent.WaitOne(20000);
        }
Esempio n. 2
0
        //protected override System.Web.Http.Dependencies.IDependencyResolver BuildWebApiDependencyResolver()
        //{
        //    //get the 'default' resolver, populated from the 'main' config metadata
        //    var resolver = base.BuildWebApiDependencyResolver();

        //    //check if its castable to a SpringWebApiDependencyResolver
        //    var springResolver = resolver as SpringWebApiDependencyResolver;

        //    //return the fully-configured resolver
        //    return springResolver;
        //}

        /// <summary>
        /// Method for initializaing the single threaded application parts
        /// </summary>
        private void InitiliazeApplication()
        {
            InputDisruptorPublisher.Shutdown();
            OutputDisruptor.ShutDown();
            IEventStore inputEventStore = new RavenNEventStore(Constants.INPUT_EVENT_STORE);
            IEventStore outputEventStore = new RavenNEventStore(Constants.OUTPUT_EVENT_STORE);
            Journaler inputJournaler = new Journaler(inputEventStore);
            Journaler outputJournaler = new Journaler(outputEventStore);
            ExchangeEssentialsList exchangeEssentialsList=outputEventStore.LoadLastSnapshot();
            ICurrencyPairRepository currencyPairRepository = (ICurrencyPairRepository) ContextRegistry.GetContext()["CurrencyPairRepository"];
            IList<CurrencyPair> tradeableCurrencyPairs = currencyPairRepository.GetTradeableCurrencyPairs();
            Exchange exchange;
            if (exchangeEssentialsList != null)
            {
                //means snapshot found so initialize the exchange
                exchange = new Exchange(tradeableCurrencyPairs, exchangeEssentialsList);
                InputDisruptorPublisher.InitializeDisruptor(new IEventHandler<InputPayload>[] {exchange, inputJournaler});
                OutputDisruptor.InitializeDisruptor(new IEventHandler<byte[]>[] {outputJournaler});
                exchange.InitializeExchangeAfterSnaphot();
                LimitOrderBookReplayService service = new LimitOrderBookReplayService();
                service.ReplayOrderBooks(exchange, outputJournaler);
                exchange.EnableSnaphots(Constants.SnaphsortInterval);
            }
            else
            {
                //no snapshot found
                exchange = new Exchange(tradeableCurrencyPairs);
                InputDisruptorPublisher.InitializeDisruptor(new IEventHandler<InputPayload>[] { exchange, inputJournaler });
                OutputDisruptor.InitializeDisruptor(new IEventHandler<byte[]>[] { outputJournaler });
               // check if there are events to replay
                LimitOrderBookReplayService service = new LimitOrderBookReplayService();
                service.ReplayOrderBooks(exchange, outputJournaler);
                exchange.EnableSnaphots(Constants.SnaphsortInterval);
            }
        }
Esempio n. 3
0
        public void SetUp()
        {
            //initialize journaler
            _eventStore = new RavenNEventStore(Constants.INPUT_EVENT_STORE);
            Journaler journaler = new Journaler(_eventStore);

            //assign journaler to disruptor as its consumer
            InputDisruptorPublisher.InitializeDisruptor(new IEventHandler <InputPayload>[] { journaler });
            _manualResetEvent = new ManualResetEvent(false);
        }
        public void SetUp()
        {
            var connection = ConfigurationManager.ConnectionStrings["MySql"].ToString();

            _databaseUtility = new DatabaseUtility(connection);
            _databaseUtility.Create();
            _databaseUtility.Populate();
            inputEventStore  = new RavenNEventStore(Constants.INPUT_EVENT_STORE);
            outputEventStore = new RavenNEventStore(Constants.OUTPUT_EVENT_STORE);
            inputJournaler   = new Journaler(inputEventStore);
            outputJournaler  = new Journaler(outputEventStore);
            IList <CurrencyPair> currencyPairs = new List <CurrencyPair>();

            currencyPairs.Add(new CurrencyPair("BTCUSD", "USD", "BTC"));
            currencyPairs.Add(new CurrencyPair("BTCLTC", "LTC", "BTC"));
            currencyPairs.Add(new CurrencyPair("BTCDOGE", "DOGE", "BTC"));
            _exchange = new Exchange(currencyPairs);
            _exchange.EnableSnaphots(5000);
            InputDisruptorPublisher.InitializeDisruptor(new IEventHandler <InputPayload>[] { _exchange, inputJournaler });
            OutputDisruptor.InitializeDisruptor(new IEventHandler <byte[]>[] { outputJournaler });
        }
 public void SetUp()
 {
     _orderseService = ContextRegistry.GetContext()["OrderApplicationService"] as IOrderApplicationService;
     InputDisruptorPublisher.InitializeDisruptor(new IEventHandler <InputPayload>[] { this });
     _manualResetEvent = new ManualResetEvent(false);
 }
 public void Setup()
 {
     InputDisruptorPublisher.InitializeDisruptor(new IEventHandler <InputPayload>[] { this });
     _manualResetEvent = new ManualResetEvent(false);
     _receivedTraderId = new List <string>();
 }