Add some TODOs to optimize performance and reliability.

This commit is contained in:
Lampros Smyrnaios 2023-06-21 12:26:18 +03:00
parent 1846f25c6b
commit 64ef1bcf40
3 changed files with 11 additions and 1 deletions

View File

@ -37,6 +37,9 @@ public class PdfAggregationStatisticsApplication {
}
// TODO - Add GENTLE SHUTDOWN BEAN
@Bean
public CommandLineRunner setServerBaseUrl(Environment environment, ServletWebServerApplicationContext webServerAppCtxt)
{

View File

@ -1,4 +1,4 @@
package eu.openaire.pdf_aggregation_statistics.Components;
package eu.openaire.pdf_aggregation_statistics.components;
import eu.openaire.pdf_aggregation_statistics.services.StatsService;
import org.slf4j.Logger;
@ -27,6 +27,11 @@ public class SchedulingTasks {
// It will be a quick O(1) get operation in the HashMap.
statsService.gatherNumberOfPayloadsPerDatasource();
// TODO - If this is the first time running (check a boolean)
// TODO - AND the above method failed, then gently shutdown the app!
// todo - there is no point in keeping it running if it cannot provide any stat!
}
}

View File

@ -56,6 +56,8 @@ public class StatsController {
logger.error(errorMsg);
return ResponseEntity.internalServerError().body(errorMsg);
}
// TODO - The above check is expensive (check the code behind) and unessesery to run every time, since if the map is populated at init then it will not be empty!!
// TODO - if the map was not populated at init then the whole service should not run!! (instead of returning 500-SERVER-ERROR in every request)
Integer numPayloads = StatsServiceImpl.datasourcesWithNumOfPayloads.get(datasourceId);
if ( numPayloads == null )