Added the possibility to force the elaboration of fallback file in the application that run and die so that the monitor cannot be take up and running

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-publishing/document-store-lib@134508 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-11-22 11:09:47 +00:00
parent b771e6bb2e
commit 0285e12d7a
1 changed files with 8 additions and 5 deletions

View File

@ -20,7 +20,7 @@ import org.slf4j.LoggerFactory;
*
* @author Luca Frosini (ISTI - CNR)
*/
class PersistenceBackendMonitor implements Runnable {
public class PersistenceBackendMonitor implements Runnable {
private final static Logger logger = LoggerFactory.getLogger(PersistenceBackendMonitor.class);
@ -42,6 +42,13 @@ class PersistenceBackendMonitor implements Runnable {
ExecutorUtils.scheduler.scheduleAtFixedRate(this, INITIAL_DELAY, DELAY, TimeUnit.MINUTES);
}
public PersistenceBackendMonitor(PersistenceBackend persistenceBackend, boolean schedule){
this.persistenceBackend = persistenceBackend;
if(schedule){
ExecutorUtils.scheduler.scheduleAtFixedRate(this, INITIAL_DELAY, DELAY, TimeUnit.MINUTES);
}
}
protected void elaborateFile(File elaborationFile){
try(BufferedReader br = new BufferedReader(new FileReader(elaborationFile))) {
for(String line; (line = br.readLine()) != null; ) {
@ -109,10 +116,6 @@ class PersistenceBackendMonitor implements Runnable {
}
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
FallbackPersistenceBackend fallbackPersistenceBackend = persistenceBackend.getFallbackPersistence();