Switch to ConcurrentHashMap for jobs table to allow multiple accessors
This commit is contained in:
parent
0ff2d7ed9f
commit
dc206e1889
@ -44,6 +44,7 @@ import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.json.JSONException;
|
||||
@ -82,7 +83,7 @@ public class ImportingManager {
|
||||
|
||||
static private RefineServlet servlet;
|
||||
static private File importDir;
|
||||
final static private Map<Long, ImportingJob> jobs = new HashMap<Long, ImportingJob>();
|
||||
final static private Map<Long, ImportingJob> jobs = new ConcurrentHashMap<Long, ImportingJob>();
|
||||
|
||||
// Mapping from format to label, e.g., "text" to "Text files", "text/xml" to "XML files"
|
||||
final static public Map<String, Format> formatToRecord = new HashMap<String, Format>();
|
||||
@ -288,12 +289,11 @@ public class ImportingManager {
|
||||
|
||||
static private void cleanUpStaleJobs() {
|
||||
long now = System.currentTimeMillis();
|
||||
for (Long id : new HashSet<Long>(jobs.keySet())) {
|
||||
for (Long id : jobs.keySet()) {
|
||||
ImportingJob job = jobs.get(id);
|
||||
if (job != null && !job.updating && now - job.lastTouched > s_stalePeriod) {
|
||||
job.dispose();
|
||||
jobs.remove(id);
|
||||
|
||||
logger.info("Disposed " + id);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user