refs #1282: New Accounting: IS-Collector doesn't start correctly after upgrade to ghn 6.0.0

https://support.d4science.org/issues/1282

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@120301 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2015-11-18 11:55:14 +00:00
parent 4b9bbd779e
commit 7121248817
1 changed files with 24 additions and 13 deletions

View File

@ -116,6 +116,7 @@ public abstract class AccountingPersistenceBackendFactory {
if( (lastCheckTimestamp + FALLBACK_RETRY_TIME) <= now ){
logger.debug("The {} for scope {} is {}. Is time to rediscover if there is another possibility.",
AccountingPersistenceBackend.class.getSimpleName(), scope, actual.getClass().getSimpleName());
AccountingPersistenceBackend discoveredPersistenceBackend = discoverAccountingPersistenceBackend(scope);
synchronized (accountingPersistenceBackends) {
@ -123,25 +124,36 @@ public abstract class AccountingPersistenceBackendFactory {
Long reCheckTimestamp = fallbackLastCheck.get(scope);
if(lastCheckTimestamp.compareTo(reCheckTimestamp)!=0){
// Someone else arrived here before. Stopping to try to
logger.debug("Someone else arrived here before. Stopping to try to rediscover AccountingPersistenceBackend");
return actual;
logger.debug("Someone else arrived here before. Stopping to try to rediscover AccountingPersistenceBackend and getting the current");
return accountingPersistenceBackends.get(scope);
}
fallbackLastCheck.put(scope, now);
if(discoveredPersistenceBackend!=null){
// Passing the aggregator to the new AccountingPersistenceBackend
// so that the buffered records will be persisted with the new method
/*
* Passing the aggregator to the new AccountingPersistenceBackend
* so that the buffered records will be persisted with the
* new method
*
*/
discoveredPersistenceBackend.setAggregationScheduler(actual.getAggregationScheduler());
// Removing timestamp wich is no more needed
// Removing timestamp which is no more needed
fallbackLastCheck.remove(scope);
accountingPersistenceBackends.put(scope, discoveredPersistenceBackend);
try {
actual.close();
} catch (Exception e) {
logger.error("Error closing {} for scope {} which has been substituted with {}.",
actual.getClass().getSimpleName(), scope,
discoveredPersistenceBackend.getClass().getSimpleName(), e);
}
/*
* Not needed because close has no effect. Removed to
* prevent problem in cases of future changes.
* try {
* actual.close();
* } catch (Exception e) {
* logger.error("Error closing {} for scope {} which has been substituted with {}.",
* actual.getClass().getSimpleName(), scope,
* discoveredPersistenceBackend.getClass().getSimpleName(), e);
* }
*
*/
return discoveredPersistenceBackend;
}
}
@ -184,7 +196,6 @@ public abstract class AccountingPersistenceBackendFactory {
}
}
persistence = accountingPersistenceBackends.get(scope);
if(persistence instanceof FallbackPersistenceBackend){
persistence = rediscoverAccountingPersistenceBackend(persistence, scope);
}