Restored ExecutorService pool
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@117211 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
107fabd78a
commit
21e648a08e
|
@ -3,6 +3,9 @@
|
|||
*/
|
||||
package org.gcube.accounting.persistence;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.gcube.accounting.aggregation.scheduler.AggregationScheduler;
|
||||
import org.gcube.accounting.datamodel.SingleUsageRecord;
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
|
@ -20,13 +23,19 @@ public abstract class AccountingPersistence {
|
|||
protected FallbackPersistence fallback;
|
||||
protected AggregationScheduler aggregationScheduler;
|
||||
|
||||
/**
|
||||
* Pool for thread execution
|
||||
*/
|
||||
private ExecutorService pool;
|
||||
|
||||
protected AccountingPersistence(){
|
||||
|
||||
this.pool = Executors.newCachedThreadPool();
|
||||
}
|
||||
|
||||
protected AccountingPersistence(FallbackPersistence fallback, AggregationScheduler aggregationScheduler){
|
||||
this.fallback = fallback;
|
||||
this.aggregationScheduler = aggregationScheduler;
|
||||
this.pool = Executors.newCachedThreadPool();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -117,18 +126,14 @@ public abstract class AccountingPersistence {
|
|||
* @throws InvalidValueException if the Record Validation Fails
|
||||
*/
|
||||
public void account(final SingleUsageRecord usageRecord) throws InvalidValueException{
|
||||
Thread thread = new Thread(){
|
||||
Runnable runnable = new Runnable(){
|
||||
@Override
|
||||
public void run(){
|
||||
validateAccountAggregate(usageRecord, true, true);
|
||||
}
|
||||
};
|
||||
thread.start();
|
||||
try {
|
||||
thread.join();
|
||||
} catch (InterruptedException e) {
|
||||
logger.error("Error joining Thread");
|
||||
}
|
||||
pool.execute(runnable);
|
||||
|
||||
}
|
||||
|
||||
public void flush() throws Exception {
|
||||
|
|
Loading…
Reference in New Issue