@@ -178,18 +178,7 @@ public final class RuntimeEnvironment {
178
178
/* Get thread pool used for top-level repository history generation. */
179
179
public static synchronized ExecutorService getHistoryExecutor () {
180
180
if (historyExecutor == null ) {
181
- int num = Runtime .getRuntime ().availableProcessors ();
182
- String total = System .getProperty ("org.opensolaris.opengrok.history.NumCacheThreads" );
183
- if (total != null ) {
184
- try {
185
- num = Integer .valueOf (total );
186
- } catch (Throwable t ) {
187
- LOGGER .log (Level .WARNING , "Failed to parse the number of "
188
- + "cache threads to use for cache creation" , t );
189
- }
190
- }
191
-
192
- historyExecutor = Executors .newFixedThreadPool (num ,
181
+ historyExecutor = Executors .newFixedThreadPool (getInstance ().getHistoryParallelism (),
193
182
new ThreadFactory () {
194
183
@ Override
195
184
public Thread newThread (Runnable runnable ) {
@@ -206,18 +195,7 @@ public Thread newThread(Runnable runnable) {
206
195
/* Get thread pool used for history generation of renamed files. */
207
196
public static synchronized ExecutorService getHistoryRenamedExecutor () {
208
197
if (historyRenamedExecutor == null ) {
209
- int num = Runtime .getRuntime ().availableProcessors ();
210
- String total = System .getProperty ("org.opensolaris.opengrok.history.NumCacheRenamedThreads" );
211
- if (total != null ) {
212
- try {
213
- num = Integer .valueOf (total );
214
- } catch (Throwable t ) {
215
- LOGGER .log (Level .WARNING , "Failed to parse the number of "
216
- + "cache threads to use for cache creation of renamed files" , t );
217
- }
218
- }
219
-
220
- historyRenamedExecutor = Executors .newFixedThreadPool (num ,
198
+ historyRenamedExecutor = Executors .newFixedThreadPool (getInstance ().getHistoryRenamedParallelism (),
221
199
new ThreadFactory () {
222
200
@ Override
223
201
public Thread newThread (Runnable runnable ) {
@@ -1133,6 +1111,28 @@ public int getIndexingParallelism() {
1133
1111
parallelism ;
1134
1112
}
1135
1113
1114
+ /**
1115
+ * Gets the value of {@link Configuration#getHistoryParallelism()} -- or
1116
+ * if zero, then as a default gets the number of available processors.
1117
+ * @return a natural number >= 1
1118
+ */
1119
+ public int getHistoryParallelism () {
1120
+ int parallelism = threadConfig .get ().getHistoryParallelism ();
1121
+ return parallelism < 1 ? Runtime .getRuntime ().availableProcessors () :
1122
+ parallelism ;
1123
+ }
1124
+
1125
+ /**
1126
+ * Gets the value of {@link Configuration#getHistoryRenamedParallelism()} -- or
1127
+ * if zero, then as a default gets the number of available processors.
1128
+ * @return a natural number >= 1
1129
+ */
1130
+ public int getHistoryRenamedParallelism () {
1131
+ int parallelism = threadConfig .get ().getHistoryRenamedParallelism ();
1132
+ return parallelism < 1 ? Runtime .getRuntime ().availableProcessors () :
1133
+ parallelism ;
1134
+ }
1135
+
1136
1136
public boolean isTagsEnabled () {
1137
1137
return threadConfig .get ().isTagsEnabled ();
1138
1138
}
0 commit comments