Add new method shutdown
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-publishing/document-store-lib@144456 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
b73f53cd50
commit
5c3fdbbe6b
2
pom.xml
2
pom.xml
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
<groupId>org.gcube.data.publishing</groupId>
|
<groupId>org.gcube.data.publishing</groupId>
|
||||||
<artifactId>document-store-lib</artifactId>
|
<artifactId>document-store-lib</artifactId>
|
||||||
<version>1.5.0-SNAPSHOT</version>
|
<version>1.6.0-SNAPSHOT</version>
|
||||||
<name>Document Store Lib</name>
|
<name>Document Store Lib</name>
|
||||||
<description>Allow to persist data in NoSQL Document Store Databases.
|
<description>Allow to persist data in NoSQL Document Store Databases.
|
||||||
Discover Model dynamically.
|
Discover Model dynamically.
|
||||||
|
|
|
@ -27,4 +27,6 @@ public class ExecutorUtils {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,4 +299,40 @@ public abstract class PersistenceBackendFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static void shutdown() {
|
||||||
|
//shutdown the scheduler
|
||||||
|
ExecutorUtils.scheduler.shutdown();
|
||||||
|
try {
|
||||||
|
ExecutorUtils.scheduler.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
logger.error("Unable to shutdown the scheduler", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
//shutdown the threadPool
|
||||||
|
ExecutorUtils.threadPool.shutdown();
|
||||||
|
try {
|
||||||
|
ExecutorUtils.threadPool.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
logger.error("Unable to shutdown the threadPool", e);
|
||||||
|
}
|
||||||
|
//disconnect the persistence and clean
|
||||||
|
for(String context : persistenceBackends.keySet()){
|
||||||
|
context = sanitizeContext(context);
|
||||||
|
PersistenceBackend apb;
|
||||||
|
synchronized (persistenceBackends) {
|
||||||
|
apb = persistenceBackends.get(context);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
logger.debug("Flushing records in context {}", context);
|
||||||
|
apb.closeAndClean();
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("Unable to flush records in context {} with {}", context, apb, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue