29
29
import java .io .FileNotFoundException ;
30
30
import java .io .IOException ;
31
31
import java .nio .file .Path ;
32
+ import java .security .InvalidParameterException ;
32
33
import java .util .ArrayList ;
33
34
import java .util .Arrays ;
34
35
import java .util .Collections ;
@@ -170,7 +171,7 @@ private ExecutorService newRevisionExecutor() {
170
171
171
172
public void shutdownRevisionExecutor () throws InterruptedException {
172
173
getRevisionExecutor ().shutdownNow ();
173
- getRevisionExecutor ().awaitTermination (getCommandTimeout (), TimeUnit .SECONDS );
174
+ getRevisionExecutor ().awaitTermination (getIndexerCommandTimeout (), TimeUnit .SECONDS );
174
175
}
175
176
176
177
/**
@@ -225,29 +226,59 @@ public void setNestingMaximum(int nestingMaximum) {
225
226
syncWriteConfiguration (nestingMaximum , Configuration ::setNestingMaximum );
226
227
}
227
228
228
- public int getCommandTimeout () {
229
- return syncReadConfiguration (Configuration ::getCommandTimeout );
229
+ public int getCommandTimeout (CommandTimeoutType cmdType ) {
230
+ switch (cmdType ) {
231
+ case INDEXER :
232
+ return getIndexerCommandTimeout ();
233
+ case INTERACTIVE :
234
+ return getInteractiveCommandTimeout ();
235
+ case WEBAPP_START :
236
+ return getWebappStartCommandTimeout ();
237
+ case RESTFUL :
238
+ return getRestfulCommandTimeout ();
239
+ }
240
+
241
+ throw new InvalidParameterException ("invalid command timeout type" );
242
+ }
243
+
244
+ public int getRestfulCommandTimeout () {
245
+ return syncReadConfiguration (Configuration ::getRestfulCommandTimeout );
246
+ }
247
+
248
+ public void setRestfulCommandTimeout (int timeout ) {
249
+ syncWriteConfiguration (timeout , Configuration ::setWebappStartCommandTimeout );
250
+ }
251
+
252
+ public int getWebappStartCommandTimeout () {
253
+ return syncReadConfiguration (Configuration ::getWebappStartCommandTimeout );
254
+ }
255
+
256
+ public void setWebappStartCommandTimeout (int timeout ) {
257
+ syncWriteConfiguration (timeout , Configuration ::setWebappStartCommandTimeout );
258
+ }
259
+
260
+ public int getIndexerCommandTimeout () {
261
+ return syncReadConfiguration (Configuration ::getIndexerCommandTimeout );
230
262
}
231
263
232
- public void setCommandTimeout (int commandTimeout ) {
233
- syncWriteConfiguration (commandTimeout , Configuration ::setCommandTimeout );
264
+ public void setIndexerCommandTimeout (int timeout ) {
265
+ syncWriteConfiguration (timeout , Configuration ::setIndexerCommandTimeout );
234
266
}
235
267
236
268
public int getInteractiveCommandTimeout () {
237
269
return syncReadConfiguration (Configuration ::getInteractiveCommandTimeout );
238
270
}
239
271
240
- public void setInteractiveCommandTimeout (int interactiveCommandTimeout ) {
241
- syncWriteConfiguration (interactiveCommandTimeout ,
242
- Configuration ::setInteractiveCommandTimeout );
272
+ public void setInteractiveCommandTimeout (int timeout ) {
273
+ syncWriteConfiguration (timeout , Configuration ::setInteractiveCommandTimeout );
243
274
}
244
275
245
276
public long getCtagsTimeout () {
246
277
return syncReadConfiguration (Configuration ::getCtagsTimeout );
247
278
}
248
279
249
- public void setCtagsTimeout (long ctagsTimeout ) {
250
- syncWriteConfiguration (ctagsTimeout , Configuration ::setCtagsTimeout );
280
+ public void setCtagsTimeout (long timeout ) {
281
+ syncWriteConfiguration (timeout , Configuration ::setCtagsTimeout );
251
282
}
252
283
253
284
public void setLastEditedDisplayMode (boolean lastEditedDisplayMode ) {
@@ -1326,12 +1357,12 @@ public void readConfiguration(File file) throws IOException {
1326
1357
/**
1327
1358
* Read configuration from a file and put it into effect.
1328
1359
* @param file the file to read
1329
- * @param interactive true if run in interactive mode
1360
+ * @param cmdType command timeout type
1330
1361
* @throws IOException I/O
1331
1362
*/
1332
- public void readConfiguration (File file , boolean interactive ) throws IOException {
1363
+ public void readConfiguration (File file , CommandTimeoutType cmdType ) throws IOException {
1333
1364
// The following method handles the locking.
1334
- setConfiguration (Configuration .read (file ), null , interactive );
1365
+ setConfiguration (Configuration .read (file ), null , cmdType );
1335
1366
}
1336
1367
1337
1368
/**
@@ -1478,26 +1509,26 @@ public void populateGroups(Set<Group> groups, Set<Project> projects) {
1478
1509
* @param configuration what configuration to use
1479
1510
*/
1480
1511
public void setConfiguration (Configuration configuration ) {
1481
- setConfiguration (configuration , null , false );
1512
+ setConfiguration (configuration , null , CommandTimeoutType . INDEXER );
1482
1513
}
1483
1514
1484
1515
/**
1485
1516
* Sets the configuration and performs necessary actions.
1486
1517
* @param configuration new configuration
1487
- * @param interactive true if in interactive mode
1518
+ * @param cmdType command timeout type
1488
1519
*/
1489
- public void setConfiguration (Configuration configuration , boolean interactive ) {
1490
- setConfiguration (configuration , null , interactive );
1520
+ public void setConfiguration (Configuration configuration , CommandTimeoutType cmdType ) {
1521
+ setConfiguration (configuration , null , cmdType );
1491
1522
}
1492
1523
1493
1524
/**
1494
1525
* Sets the configuration and performs necessary actions.
1495
1526
*
1496
1527
* @param configuration new configuration
1497
1528
* @param subFileList list of repositories
1498
- * @param interactive true if in interactive mode
1529
+ * @param cmdType command timeout type
1499
1530
*/
1500
- public synchronized void setConfiguration (Configuration configuration , List <String > subFileList , boolean interactive ) {
1531
+ public synchronized void setConfiguration (Configuration configuration , List <String > subFileList , CommandTimeoutType cmdType ) {
1501
1532
try (ResourceLock resourceLock = configLock .writeLockAsResource ()) {
1502
1533
//noinspection ConstantConditions to avoid warning of no reference to auto-closeable
1503
1534
assert resourceLock != null ;
@@ -1509,11 +1540,9 @@ public synchronized void setConfiguration(Configuration configuration, List<Stri
1509
1540
1510
1541
// Set the working repositories in HistoryGuru.
1511
1542
if (subFileList != null ) {
1512
- histGuru .invalidateRepositories (
1513
- getRepositories (), subFileList , interactive );
1543
+ histGuru .invalidateRepositories (getRepositories (), subFileList , cmdType );
1514
1544
} else {
1515
- histGuru .invalidateRepositories (getRepositories (),
1516
- interactive );
1545
+ histGuru .invalidateRepositories (getRepositories (), cmdType );
1517
1546
}
1518
1547
1519
1548
// The invalidation of repositories above might have excluded some
@@ -1569,10 +1598,10 @@ public void setAuthorizationFramework(AuthorizationFramework fw) {
1569
1598
/**
1570
1599
* Re-apply the configuration.
1571
1600
* @param reindex is the message result of reindex
1572
- * @param interactive true if in interactive mode
1601
+ * @param cmdType command timeout type
1573
1602
*/
1574
- public void applyConfig (boolean reindex , boolean interactive ) {
1575
- applyConfig (configuration , reindex , interactive );
1603
+ public void applyConfig (boolean reindex , CommandTimeoutType cmdType ) {
1604
+ applyConfig (configuration , reindex , cmdType );
1576
1605
}
1577
1606
1578
1607
/**
@@ -1582,11 +1611,11 @@ public void applyConfig(boolean reindex, boolean interactive) {
1582
1611
*
1583
1612
* @param configuration XML configuration
1584
1613
* @param reindex is the message result of reindex
1585
- * @param interactive true if in interactive mode
1614
+ * @param cmdType command timeout type
1586
1615
* @see #applyConfig(org.opengrok.indexer.configuration.Configuration,
1587
- * boolean, boolean ) applyConfig(config, reindex, interactive )
1616
+ * boolean, CommandTimeoutType ) applyConfig(config, reindex, cmdType )
1588
1617
*/
1589
- public void applyConfig (String configuration , boolean reindex , boolean interactive ) {
1618
+ public void applyConfig (String configuration , boolean reindex , CommandTimeoutType cmdType ) {
1590
1619
Configuration config ;
1591
1620
try {
1592
1621
config = makeXMLStringAsConfiguration (configuration );
@@ -1595,7 +1624,7 @@ public void applyConfig(String configuration, boolean reindex, boolean interacti
1595
1624
return ;
1596
1625
}
1597
1626
1598
- applyConfig (config , reindex , interactive );
1627
+ applyConfig (config , reindex , cmdType );
1599
1628
}
1600
1629
1601
1630
/**
@@ -1605,10 +1634,10 @@ public void applyConfig(String configuration, boolean reindex, boolean interacti
1605
1634
*
1606
1635
* @param config the incoming configuration
1607
1636
* @param reindex is the message result of reindex
1608
- * @param interactive true if in interactive mode
1637
+ * @param cmdType command timeout type
1609
1638
*/
1610
- public void applyConfig (Configuration config , boolean reindex , boolean interactive ) {
1611
- setConfiguration (config , interactive );
1639
+ public void applyConfig (Configuration config , boolean reindex , CommandTimeoutType cmdType ) {
1640
+ setConfiguration (config , cmdType );
1612
1641
LOGGER .log (Level .INFO , "Configuration updated" );
1613
1642
1614
1643
if (reindex ) {
0 commit comments