public void TestRebuild_ShouldRebuildHighwaysAndPoints()
        {
            _service.Rebuild(new UpdateRequest {
                Highways = true, PointsOfInterest = true
            }).Wait();

            _elasticSearchGateway.Received(1).UpdateHighwaysZeroDownTime(Arg.Any <List <Feature> >());
            _elasticSearchGateway.Received(1).UpdatePointsOfInterestZeroDownTime(Arg.Any <List <Feature> >());
        }
Esempio n. 2
0
        public async Task <IActionResult> PostUpdateData(UpdateRequest request)
        {
            if (!RebuildSemaphore.WaitOne(0))
            {
                return(BadRequest("Can't run two full updates in parallel"));
            }
            try
            {
                if (!IsRequestLocal())
                {
                    return(BadRequest("This operation can't be done from a remote client, please run this from the server"));
                }
                if (request == null ||
                    request.Routing == false &&
                    request.Highways == false &&
                    request.PointsOfInterest == false &&
                    request.OsmFile == false)
                {
                    request = new UpdateRequest
                    {
                        Routing          = true,
                        Highways         = true,
                        PointsOfInterest = true,
                        OsmFile          = true
                    };
                    _logger.LogInformation("No specific filters were applied, updating all databases.");
                }
                _logger.LogInformation("Starting updating site's databases according to request: " + JsonConvert.SerializeObject(request));
                await _osmLatestFileFetcherExecutor.Update(request.OsmFile);

                _logger.LogInformation("Update OSM file completed.");

                await _elasticSearchUpdaterService.Rebuild(request);

                _logger.LogInformation("Finished updating site's databases according to request");
                return(Ok());
            }
            finally
            {
                RebuildSemaphore.Release();
            }
        }