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@120288 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2015-11-17 11:15:16 +00:00
parent 6ef06f9ecd
commit 4445ec9df7
1 changed files with 29 additions and 29 deletions

View File

@ -119,6 +119,12 @@ public abstract class AccountingPersistenceBackendFactory {
logger.debug("The {} for scope {} is {}. Is time to rediscover if there is another possibility.",
AccountingPersistenceBackend.class.getSimpleName(), scope, actual.getClass().getSimpleName());
lock.lock();
try {
logger.trace("Renewing Last check Timestamp. The next one will be {}", now);
fallbackLastCheck.put(scope, now);
lastCheckTimestamp = fallbackLastCheck.get(scope);
AccountingPersistenceBackend discoveredPersistenceBackend = discoverAccountingPersistenceBackend(scope);
if(discoveredPersistenceBackend!=null){
// Passing the aggregator to the new AccountingPersistenceBackend
@ -135,14 +141,13 @@ public abstract class AccountingPersistenceBackendFactory {
actual.getClass().getSimpleName(), scope,
discoveredPersistenceBackend.getClass().getSimpleName(), e);
}
lock.unlock();
return discoveredPersistenceBackend;
}else{
// Renewing timestamp
logger.trace("Renewing Last check Timestamp. The new one will be {}", now);
fallbackLastCheck.put(scope, now);
lastCheckTimestamp = fallbackLastCheck.get(scope);
}
}finally {
lock.unlock();
}
}
long nextCheck = (lastCheckTimestamp + FALLBACK_RETRY_TIME) - Calendar.getInstance().getTimeInMillis();
@ -184,15 +189,10 @@ public abstract class AccountingPersistenceBackendFactory {
lock.unlock();
}
lock.lock();
try {
persistence = accountingPersistenceBackends.get(scope);
if(persistence instanceof FallbackPersistenceBackend){
persistence = rediscoverAccountingPersistenceBackend(persistence, scope);
}
} finally {
lock.unlock();
}
return persistence;
}