|
1 | 1 | package org.labkey.jbrowse; |
2 | 2 |
|
3 | 3 | import org.apache.commons.lang3.StringUtils; |
| 4 | +import org.apache.commons.lang3.math.NumberUtils; |
4 | 5 | import org.apache.logging.log4j.Logger; |
5 | 6 | import org.jetbrains.annotations.Nullable; |
6 | 7 | import org.json.JSONObject; |
7 | 8 | import org.labkey.api.collections.CaseInsensitiveHashMap; |
8 | 9 | import org.labkey.api.data.Container; |
| 10 | +import org.labkey.api.data.ContainerManager; |
9 | 11 | import org.labkey.api.data.SimpleFilter; |
10 | 12 | import org.labkey.api.data.TableInfo; |
11 | 13 | import org.labkey.api.data.TableSelector; |
|
17 | 19 | import org.labkey.api.jbrowse.JBrowseFieldCustomizer; |
18 | 20 | import org.labkey.api.jbrowse.JBrowseFieldDescriptor; |
19 | 21 | import org.labkey.api.jbrowse.JBrowseService; |
| 22 | +import org.labkey.api.module.Module; |
20 | 23 | import org.labkey.api.module.ModuleLoader; |
| 24 | +import org.labkey.api.module.ModuleProperty; |
21 | 25 | import org.labkey.api.pipeline.PipeRoot; |
22 | 26 | import org.labkey.api.pipeline.PipelineJobException; |
23 | 27 | import org.labkey.api.pipeline.PipelineService; |
@@ -436,7 +440,23 @@ public boolean isAvailable(Container c) |
436 | 440 | } |
437 | 441 | } |
438 | 442 |
|
| 443 | + private static final String JBrowseLuceneCoresProp = "JBrowseLuceneCores"; |
| 444 | + |
439 | 445 | public int getCoresForLuceneSearches() { |
440 | | - return Runtime.getRuntime().availableProcessors(); |
| 446 | + Module m = ModuleLoader.getInstance().getModule(JBrowseModule.NAME); |
| 447 | + ModuleProperty mp = m.getModuleProperties().get(JBrowseLuceneCoresProp); |
| 448 | + String nCores = StringUtils.trimToNull(mp.getEffectiveValue(ContainerManager.getRoot())); |
| 449 | + if (nCores == null) |
| 450 | + { |
| 451 | + return 1; |
| 452 | + } |
| 453 | + else if (!NumberUtils.isCreatable(nCores)) |
| 454 | + { |
| 455 | + _log.error("Improper value for " + JBrowseLuceneCoresProp + ": " + nCores); |
| 456 | + } |
| 457 | + |
| 458 | + Number n = NumberUtils.createNumber(nCores); |
| 459 | + |
| 460 | + return n.intValue(); |
441 | 461 | } |
442 | 462 | } |
0 commit comments