fix #2310 use ThreadUtil
This commit is contained in:
parent
e3fe5ed75c
commit
06ee2c75b4
12 changed files with 32 additions and 94 deletions
|
@ -27,6 +27,7 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.core.lang.ThreadUtil;
|
||||
import org.codelibs.fess.crawler.Constants;
|
||||
import org.codelibs.fess.crawler.exception.CrawlerSystemException;
|
||||
import org.codelibs.fess.es.user.exentity.User;
|
||||
|
@ -186,11 +187,7 @@ public class CommandChain implements AuthenticationChain {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(timeout);
|
||||
} catch (final InterruptedException e) {
|
||||
// ignore
|
||||
}
|
||||
ThreadUtil.sleepQuietly(timeout);
|
||||
|
||||
if (!finished) {
|
||||
try {
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.Map;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.core.lang.ThreadUtil;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.ds.callback.IndexUpdateCallback;
|
||||
import org.codelibs.fess.es.config.exentity.DataConfig;
|
||||
|
@ -137,11 +138,7 @@ public abstract class AbstractDataStore implements DataStore {
|
|||
}
|
||||
|
||||
protected void sleep(final long interval) {
|
||||
try {
|
||||
Thread.sleep(interval);
|
||||
} catch (final Exception e) {
|
||||
// ignore
|
||||
}
|
||||
ThreadUtil.sleepQuietly(interval);
|
||||
}
|
||||
|
||||
protected abstract void storeData(DataConfig dataConfig, IndexUpdateCallback callback, Map<String, String> paramMap,
|
||||
|
|
|
@ -45,6 +45,7 @@ import org.codelibs.core.exception.ResourceNotFoundRuntimeException;
|
|||
import org.codelibs.core.io.FileUtil;
|
||||
import org.codelibs.core.io.ResourceUtil;
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.core.lang.ThreadUtil;
|
||||
import org.codelibs.curl.CurlResponse;
|
||||
import org.codelibs.elasticsearch.client.HttpClient;
|
||||
import org.codelibs.elasticsearch.runner.ElasticsearchClusterRunner;
|
||||
|
@ -590,11 +591,7 @@ public class FessEsClient implements Client {
|
|||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Failed to access to Elasticsearch:{}", i, cause);
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000L);
|
||||
} catch (final InterruptedException e) {
|
||||
// ignore
|
||||
}
|
||||
ThreadUtil.sleep(1000L);
|
||||
}
|
||||
final String message =
|
||||
"Elasticsearch (" + System.getProperty(Constants.FESS_ES_HTTP_ADDRESS)
|
||||
|
@ -625,11 +622,7 @@ public class FessEsClient implements Client {
|
|||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Failed to access to configsync:{}", i, cause);
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000L);
|
||||
} catch (final InterruptedException e) {
|
||||
// ignore
|
||||
}
|
||||
ThreadUtil.sleep(1000L);
|
||||
}
|
||||
throw cause;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.codelibs.fess.es.config.exbhv;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang3.RandomUtils;
|
||||
import org.codelibs.core.lang.ThreadUtil;
|
||||
import org.codelibs.fess.es.config.bsbhv.BsScheduledJobBhv;
|
||||
import org.codelibs.fess.es.config.exentity.ScheduledJob;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
|
@ -54,11 +55,7 @@ public class ScheduledJobBhv extends BsScheduledJobBhv {
|
|||
logger.debug("Failed to select a job by {}", id, e);
|
||||
}
|
||||
lastException = e;
|
||||
try {
|
||||
Thread.sleep(RandomUtils.nextLong(500, 5000));
|
||||
} catch (final InterruptedException e1) {
|
||||
// ignore
|
||||
}
|
||||
ThreadUtil.sleep(RandomUtils.nextLong(500, 5000));
|
||||
}
|
||||
}
|
||||
logger.warn("Failed to select a job by " + id, lastException);
|
||||
|
|
|
@ -36,7 +36,9 @@ import java.util.stream.Collectors;
|
|||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.core.CoreLibConstants;
|
||||
import org.codelibs.core.exception.InterruptedRuntimeException;
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.core.lang.ThreadUtil;
|
||||
import org.codelibs.core.misc.DynamicProperties;
|
||||
import org.codelibs.core.timer.TimeoutManager;
|
||||
import org.codelibs.core.timer.TimeoutTask;
|
||||
|
@ -233,7 +235,7 @@ public class Crawler {
|
|||
while (true) {
|
||||
try {
|
||||
while (!reader.ready()) {
|
||||
Thread.sleep(1000L);
|
||||
ThreadUtil.sleep(1000L);
|
||||
}
|
||||
command = reader.readLine().trim();
|
||||
if (logger.isDebugEnabled()) {
|
||||
|
@ -247,7 +249,7 @@ public class Crawler {
|
|||
if (Thread.interrupted()) {
|
||||
return;
|
||||
}
|
||||
} catch (final InterruptedException e) {
|
||||
} catch (final InterruptedRuntimeException e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.core.lang.ThreadUtil;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.app.service.FailureUrlService;
|
||||
import org.codelibs.fess.ds.DataStore;
|
||||
|
@ -123,13 +124,7 @@ public class DataIndexHelper {
|
|||
dataCrawlingThreadStatusList.set(startedCrawlerNum, Constants.RUNNING);
|
||||
startedCrawlerNum++;
|
||||
activeCrawlerNum++;
|
||||
try {
|
||||
Thread.sleep(crawlingExecutionInterval);
|
||||
} catch (final InterruptedException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Interrupted.", e);
|
||||
}
|
||||
}
|
||||
ThreadUtil.sleep(crawlingExecutionInterval);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -141,13 +136,7 @@ public class DataIndexHelper {
|
|||
activeCrawlerNum--;
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(crawlingExecutionInterval);
|
||||
} catch (final InterruptedException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Interrupted.", e);
|
||||
}
|
||||
}
|
||||
ThreadUtil.sleep(crawlingExecutionInterval);
|
||||
}
|
||||
|
||||
boolean finishedAll = false;
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.util.ArrayList;
|
|||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.codelibs.core.lang.ThreadUtil;
|
||||
import org.codelibs.fess.exception.FessSystemException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -34,26 +35,14 @@ public class IntervalControlHelper {
|
|||
|
||||
public void checkCrawlerStatus() {
|
||||
while (!crawlerRunning) {
|
||||
try {
|
||||
Thread.sleep(crawlerWaitMillis);
|
||||
} catch (final InterruptedException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Interrupted.", e);
|
||||
}
|
||||
}
|
||||
ThreadUtil.sleepQuietly(crawlerWaitMillis);
|
||||
}
|
||||
}
|
||||
|
||||
public void delayByRules() {
|
||||
final long delay = getDelay();
|
||||
if (delay > 0) {
|
||||
try {
|
||||
Thread.sleep(delay);
|
||||
} catch (final InterruptedException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Interrupted.", e);
|
||||
}
|
||||
}
|
||||
ThreadUtil.sleep(delay);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import javax.annotation.PostConstruct;
|
|||
|
||||
import org.codelibs.core.concurrent.CommonPoolUtil;
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.core.lang.ThreadUtil;
|
||||
import org.codelibs.core.misc.Pair;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.entity.SearchRequestParams.SearchRequestType;
|
||||
|
@ -108,13 +109,7 @@ public class KeyMatchHelper {
|
|||
}
|
||||
|
||||
if (interval > 0) {
|
||||
try {
|
||||
Thread.sleep(interval);
|
||||
} catch (final InterruptedException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Interrupted.", e);
|
||||
}
|
||||
}
|
||||
ThreadUtil.sleep(interval);
|
||||
}
|
||||
});
|
||||
this.keyMatchQueryMap = keyMatchQueryMap;
|
||||
|
|
|
@ -52,6 +52,7 @@ import org.apache.logging.log4j.Level;
|
|||
import org.apache.logging.log4j.core.config.Configurator;
|
||||
import org.codelibs.core.exception.IORuntimeException;
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.core.lang.ThreadUtil;
|
||||
import org.codelibs.core.misc.Pair;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.crawler.util.CharUtil;
|
||||
|
@ -369,14 +370,9 @@ public class SystemHelper {
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void sleep(final int sec) {
|
||||
try {
|
||||
Thread.sleep(sec * 1000L);
|
||||
} catch (final InterruptedException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Interrupted.", e);
|
||||
}
|
||||
}
|
||||
ThreadUtil.sleepQuietly(sec * 1000L);
|
||||
}
|
||||
|
||||
public void addShutdownHook(final Runnable hook) {
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.core.lang.ThreadUtil;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.crawler.Crawler;
|
||||
import org.codelibs.fess.crawler.CrawlerContext;
|
||||
|
@ -365,13 +366,7 @@ public class WebFsIndexHelper {
|
|||
crawlerStatusList.set(startedCrawlerNum, Constants.RUNNING);
|
||||
startedCrawlerNum++;
|
||||
activeCrawlerNum++;
|
||||
try {
|
||||
Thread.sleep(crawlingExecutionInterval);
|
||||
} catch (final InterruptedException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Interrupted.", e);
|
||||
}
|
||||
}
|
||||
ThreadUtil.sleep(crawlingExecutionInterval);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -386,13 +381,7 @@ public class WebFsIndexHelper {
|
|||
activeCrawlerNum--;
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(crawlingExecutionInterval);
|
||||
} catch (final InterruptedException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Interrupted.", e);
|
||||
}
|
||||
}
|
||||
ThreadUtil.sleep(crawlingExecutionInterval);
|
||||
}
|
||||
|
||||
boolean finishedAll = false;
|
||||
|
|
|
@ -24,6 +24,7 @@ import javax.annotation.PreDestroy;
|
|||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.core.lang.ThreadUtil;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.crawler.Crawler;
|
||||
import org.codelibs.fess.crawler.entity.AccessResult;
|
||||
|
@ -190,11 +191,7 @@ public class IndexUpdater extends Thread {
|
|||
final long interval = updateInterval - updateTime;
|
||||
if (interval > 0) {
|
||||
// sleep
|
||||
try {
|
||||
Thread.sleep(interval); // 10 sec (default)
|
||||
} catch (final InterruptedException e) {
|
||||
logger.warn("Interrupted index update.", e);
|
||||
}
|
||||
ThreadUtil.sleep(interval); // 10 sec (default)
|
||||
}
|
||||
|
||||
docList.clear();
|
||||
|
@ -217,11 +214,7 @@ public class IndexUpdater extends Thread {
|
|||
long hitCount = ((EsResultList<EsAccessResult>) arList).getTotalHits();
|
||||
while (hitCount > 0) {
|
||||
if (arList.isEmpty()) {
|
||||
try {
|
||||
Thread.sleep(fessConfig.getIndexerWebfsCommitMarginTimeAsInteger().longValue());
|
||||
} catch (final Exception e) {
|
||||
// ignore
|
||||
}
|
||||
ThreadUtil.sleep(fessConfig.getIndexerWebfsCommitMarginTimeAsInteger().longValue());
|
||||
cleanupTime = -1;
|
||||
} else {
|
||||
processAccessResults(docList, accessResultList, arList);
|
||||
|
|
|
@ -37,6 +37,7 @@ import javax.annotation.PostConstruct;
|
|||
import javax.annotation.PreDestroy;
|
||||
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.core.lang.ThreadUtil;
|
||||
import org.codelibs.core.misc.Tuple3;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.es.client.FessEsClient;
|
||||
|
@ -252,7 +253,7 @@ public class ThumbnailManager {
|
|||
} else {
|
||||
final long interval = fessConfig.getThumbnailGeneratorIntervalAsInteger().longValue();
|
||||
if (interval > 0) {
|
||||
Thread.sleep(interval);
|
||||
ThreadUtil.sleep(interval);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue