Skip to content

Commit

Permalink
Make the DICOM Storage SCP indexing queue to be asynchronous (#496)
Browse files Browse the repository at this point in the history
  • Loading branch information
bastiao authored Aug 22, 2021
1 parent 0b71dbf commit 8bff934
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public synchronized static PluginController getInstance() {
private final WebUIPluginManager webUI;
private final DicooglePlatformProxy proxy;
private TaskManager taskManager = new TaskManager(Integer.parseInt(System.getProperty("dicoogle.taskManager.nThreads", "4")));

private TaskManager taskManagerQueries = new TaskManager(Integer.parseInt(System.getProperty("dicoogle.taskManager.nQueryThreads", "4")));

public PluginController(File pathToPluginDirectory) {
logger.info("Creating PluginController Instance");
pluginFolder = pathToPluginDirectory;
Expand Down Expand Up @@ -450,7 +451,7 @@ public JointQueryTask queryAll(JointQueryTask holder, final String query, final

public Task<Iterable<SearchResult>> query(String querySource, final String query, final Object ... parameters){
Task<Iterable<SearchResult>> t = getTaskForQuery(querySource, query, parameters);
taskManager.dispatch(t);
taskManagerQueries.dispatch(t);
//logger.info("Fired Query Task: "+querySource +" QueryString:"+query);

return t;//returns the handler to obtain the computation results
Expand All @@ -469,7 +470,7 @@ public JointQueryTask query(JointQueryTask holder, List<String> querySources, fi

//and executes said task asynchronously
for(Task<?> t : tasks)
taskManager.dispatch(t);
taskManagerQueries.dispatch(t);

//logger.info("Fired Query Tasks: "+Arrays.toString(querySources.toArray()) +" QueryString:"+query);
return holder;//returns the handler to obtain the computation results
Expand Down
7 changes: 5 additions & 2 deletions dicoogle/src/main/java/pt/ua/dicoogle/server/RSIStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ public class RSIStorage extends StorageService
private BlockingQueue<ImageElement> queue = new PriorityBlockingQueue<>();
private NetworkApplicationEntity[] naeArr = null;
private AtomicLong seqNum = new AtomicLong(0L);
private static boolean ASYNC_INDEX = Boolean.valueOf(System.getProperty("dicoogle.index.async", "true"));


/**
*
* @param Services List of supported SOP Classes
Expand Down Expand Up @@ -377,7 +377,10 @@ public void run()
// Fetch an element by the queue taking into account the priorities.
ImageElement element = queue.take();
URI exam = element.getUri();
PluginController.getInstance().indexBlocking(exam);
if (ASYNC_INDEX)
PluginController.getInstance().index(exam);
else
PluginController.getInstance().indexBlocking(exam);
} catch (InterruptedException ex) {
LoggerFactory.getLogger(RSIStorage.class).error("Could not take instance to index", ex);
}
Expand Down

0 comments on commit 8bff934

Please sign in to comment.