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,30 +119,35 @@ 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());
AccountingPersistenceBackend discoveredPersistenceBackend = discoverAccountingPersistenceBackend(scope);
if(discoveredPersistenceBackend!=null){
// 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
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);
}
return discoveredPersistenceBackend;
}else{
// Renewing timestamp
logger.trace("Renewing Last check Timestamp. The new one will be {}", now);
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
// so that the buffered records will be persisted with the new method
discoveredPersistenceBackend.setAggregationScheduler(actual.getAggregationScheduler());
// Removing timestamp wich 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);
}
lock.unlock();
return discoveredPersistenceBackend;
}
}finally {
lock.unlock();
}
}
long nextCheck = (lastCheckTimestamp + FALLBACK_RETRY_TIME) - Calendar.getInstance().getTimeInMillis();
@ -184,14 +189,9 @@ public abstract class AccountingPersistenceBackendFactory {
lock.unlock();
}
lock.lock();
try {
persistence = accountingPersistenceBackends.get(scope);
if(persistence instanceof FallbackPersistenceBackend){
persistence = rediscoverAccountingPersistenceBackend(persistence, scope);
}
} finally {
lock.unlock();
persistence = accountingPersistenceBackends.get(scope);
if(persistence instanceof FallbackPersistenceBackend){
persistence = rediscoverAccountingPersistenceBackend(persistence, scope);
}
return persistence;