Awaiting termination of pool in flush
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@117212 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
21e648a08e
commit
80101b5b7c
|
@ -5,6 +5,7 @@ package org.gcube.accounting.persistence;
|
|||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.gcube.accounting.aggregation.scheduler.AggregationScheduler;
|
||||
import org.gcube.accounting.datamodel.SingleUsageRecord;
|
||||
|
@ -136,7 +137,9 @@ public abstract class AccountingPersistence {
|
|||
|
||||
}
|
||||
|
||||
public void flush() throws Exception {
|
||||
public void flush(long timeout, TimeUnit timeUnit) throws Exception {
|
||||
pool.awaitTermination(timeout, timeUnit);
|
||||
|
||||
final AccountingPersistence persistence = this;
|
||||
aggregationScheduler.flush(new AccountingPersistenceExecutor(){
|
||||
|
||||
|
@ -146,6 +149,7 @@ public abstract class AccountingPersistence {
|
|||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
*/
|
||||
package org.gcube.accounting.persistence;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.gcube.accounting.datamodel.SingleUsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.TestUsageRecord;
|
||||
import org.gcube.accounting.testutility.StressTestUtility;
|
||||
|
@ -17,6 +19,9 @@ import org.junit.Test;
|
|||
*/
|
||||
public class PersistenceTest {
|
||||
|
||||
public static final long timeout = 5000;
|
||||
public static final TimeUnit timeUnit = TimeUnit.MILLISECONDS;
|
||||
|
||||
public static AccountingPersistence getPersistence(){
|
||||
ScopeProvider.instance.set(PersistenceConfigurationTest.GCUBE_DEVNEXT_SCOPE);
|
||||
AccountingPersistenceFactory.setFallbackLocation(null);
|
||||
|
@ -36,7 +41,7 @@ public class PersistenceTest {
|
|||
}
|
||||
}, 1);
|
||||
|
||||
persistence.flush();
|
||||
persistence.flush(timeout, timeUnit);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -50,7 +55,7 @@ public class PersistenceTest {
|
|||
}
|
||||
}, 1);
|
||||
|
||||
persistence.flush();
|
||||
persistence.flush(timeout, timeUnit);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -76,7 +81,7 @@ public class PersistenceTest {
|
|||
persistence.account(usageRecord);
|
||||
}
|
||||
});
|
||||
persistence.flush();
|
||||
persistence.flush(timeout, timeUnit);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue