// No DB-lock is required for these READ-operations.
publicstaticfinalConcurrentHashMap<String,Integer>datasourcesWithNumOfPayloads=newConcurrentHashMap<>(105_000);// The number of datasources is around 10_000.
try{// For each of the 4 columns returned, do the following. The column-indexing starts from 1
intnewValue=rs.getInt(2);
IntegeroldValue=datasourcesWithNumOfPayloads.put(rs.getString(1),newValue);// Updates the number for an existing datasourceId or adds a new mapping for a new datasourceId.
if(!SchedulingTasks.runningFirstTime){
if(oldValue==null){
countNewDatasources[0]++;
countAddedPayloads[0]+=newValue;
}else{
intdiff=newValue-oldValue;
if(diff!=0){// The diff may be positive for added payloads or negative if a deduplication or any other fix was performed and the number was reduced.
countUpdatedDatasources[0]++;
countAddedPayloads[0]+=diff;
// A negative diff wil result in substituting that number from the total. So we may have 3000 added payloads and 100 removed, so the final "newPayloads" will be 2900.
logger.info("The \"datasourcesWithNumOfPayloads\" map was "+(SchedulingTasks.runningFirstTime?"populated with the payload-numbers for "+datasourcesWithNumOfPayloads.size()+" datasources.":("updated. "+countNewDatasources[0]+" new datasources were added and "+countUpdatedDatasources[0]+" were updated. The number of added payloads is "+countAddedPayloads[0])));
logger.error("The number of payloads per datasource could not be retrieved from the database \""+databaseName+"\" using the getNumberOfPayloadsPerDatasourceQuery: "+getNumberOfPayloadsPerDatasourceQuery);
// If such an unknown error appears during initialization, it is fatal but not something that is so remarkable to completely avoid deploying the app to save time..
// We allow for 1 retry, 2 Minutes later. If the error appears again then the app will shutdown.
logger.error("Problem when executing \"getNumberOfPayloadsPerDatasourceQuery\": "+getNumberOfPayloadsPerDatasourceQuery,e);