code clean-up
This commit is contained in:
parent
50034eb3a3
commit
b4d8ca7385
25 changed files with 74 additions and 77 deletions
|
@ -526,11 +526,11 @@ public class GsaApiManager extends BaseApiManager implements WebApiManager {
|
|||
this.gsaMetaPrefix = gsaMetaPrefix;
|
||||
}
|
||||
|
||||
public void setCharsetField(String charsetField) {
|
||||
public void setCharsetField(final String charsetField) {
|
||||
this.charsetField = charsetField;
|
||||
}
|
||||
|
||||
public void setContentTypeField(String contentTypeField) {
|
||||
public void setContentTypeField(final String contentTypeField) {
|
||||
this.contentTypeField = contentTypeField;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ public class JsonApiManager extends BaseJsonApiManager {
|
|||
buf.append('\n');
|
||||
try {
|
||||
response.getWriter().print(buf.toString());
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
}
|
||||
return true;
|
||||
|
@ -170,8 +170,8 @@ public class JsonApiManager extends BaseJsonApiManager {
|
|||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Loaded " + count + " docs");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
int status = 9;
|
||||
} catch (final Exception e) {
|
||||
final int status = 9;
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Failed to process a ping request.", e);
|
||||
}
|
||||
|
|
|
@ -189,7 +189,7 @@ public class AdminBackupAction extends FessAdminAction {
|
|||
});
|
||||
}
|
||||
|
||||
private static StringBuilder appendJson(String field, Object value, StringBuilder buf) {
|
||||
private static StringBuilder appendJson(final String field, final Object value, final StringBuilder buf) {
|
||||
buf.append('"').append(StringEscapeUtils.escapeJson(field)).append('"').append(':');
|
||||
if (value == null) {
|
||||
buf.append("null");
|
||||
|
@ -210,7 +210,7 @@ public class AdminBackupAction extends FessAdminAction {
|
|||
} else if (value instanceof Map) {
|
||||
buf.append('{');
|
||||
final String json = ((Map<?, ?>) value).entrySet().stream().map(e -> {
|
||||
StringBuilder tempBuf = new StringBuilder();
|
||||
final StringBuilder tempBuf = new StringBuilder();
|
||||
appendJson(e.getKey().toString(), e.getValue(), tempBuf);
|
||||
return tempBuf.toString();
|
||||
}).collect(Collectors.joining(","));
|
||||
|
@ -235,7 +235,7 @@ public class AdminBackupAction extends FessAdminAction {
|
|||
cb.query().addOrderBy_RequestedAt_Asc();
|
||||
},
|
||||
entity -> {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
buf.append('{');
|
||||
appendJson("id", entity.getId(), buf).append(',');
|
||||
appendJson("query-id", entity.getQueryId(), buf).append(',');
|
||||
|
@ -280,7 +280,7 @@ public class AdminBackupAction extends FessAdminAction {
|
|||
cb.query().matchAll();
|
||||
cb.query().addOrderBy_CreatedAt_Asc();
|
||||
}, entity -> {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
buf.append('{');
|
||||
appendJson("id", entity.getId(), buf).append(',');
|
||||
appendJson("created-at", entity.getCreatedAt(), buf).append(',');
|
||||
|
@ -303,7 +303,7 @@ public class AdminBackupAction extends FessAdminAction {
|
|||
cb.query().matchAll();
|
||||
cb.query().addOrderBy_CreatedAt_Asc();
|
||||
}, entity -> {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
buf.append('{');
|
||||
appendJson("id", entity.getId(), buf).append(',');
|
||||
appendJson("created-at", entity.getCreatedAt(), buf).append(',');
|
||||
|
@ -329,7 +329,7 @@ public class AdminBackupAction extends FessAdminAction {
|
|||
cb.query().matchAll();
|
||||
cb.query().addOrderBy_RequestedAt_Asc();
|
||||
}, entity -> {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
buf.append('{');
|
||||
appendJson("id", entity.getId(), buf).append(',');
|
||||
appendJson("query-id", entity.getQueryId(), buf).append(',');
|
||||
|
|
|
@ -148,7 +148,7 @@ public class AdminCrawlinginfoAction extends FessAdminAction {
|
|||
try {
|
||||
processHelper.sendCommand(entity.getSessionId(), Constants.CRAWLER_PROCESS_COMMAND_THREAD_DUMP);
|
||||
saveInfo(messages -> messages.addSuccessPrintThreadDump(GLOBAL));
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
logger.warn("Failed to print a thread dump.", e);
|
||||
throwValidationError(messages -> messages.addErrorsFailedToPrintThreadDump(GLOBAL), () -> asListHtml());
|
||||
}
|
||||
|
|
|
@ -192,8 +192,8 @@ public class FessXpathTransformer extends XpathTransformer implements FessTransf
|
|||
resultData.setEncoding(charsetName);
|
||||
}
|
||||
|
||||
protected void normalizeData(final ResponseData responseData, Map<String, Object> dataMap) {
|
||||
Object titleObj = dataMap.get(fessConfig.getIndexFieldTitle());
|
||||
protected void normalizeData(final ResponseData responseData, final Map<String, Object> dataMap) {
|
||||
final Object titleObj = dataMap.get(fessConfig.getIndexFieldTitle());
|
||||
if (titleObj != null) {
|
||||
dataMap.put(fessConfig.getIndexFieldTitle(),
|
||||
ComponentUtil.getDocumentHelper().getTitle(responseData, titleObj.toString(), dataMap));
|
||||
|
@ -254,7 +254,7 @@ public class FessXpathTransformer extends XpathTransformer implements FessTransf
|
|||
|
||||
protected void processXRobotsTag(final ResponseData responseData, final ResultData resultData) {
|
||||
final Map<String, String> configMap = getConfigPrameterMap(responseData, ConfigName.CONFIG);
|
||||
String ignore = configMap.get(IGNORE_ROBOTS_TAGS);
|
||||
final String ignore = configMap.get(IGNORE_ROBOTS_TAGS);
|
||||
if (ignore == null) {
|
||||
if (fessConfig.isCrawlerIgnoreRobotsTags()) {
|
||||
return;
|
||||
|
|
|
@ -50,7 +50,7 @@ public class JsonDataStoreImpl extends AbstractDataStoreImpl {
|
|||
|
||||
private static final String DIRS_PARAM = "directories";
|
||||
|
||||
private String[] fileSuffixes = new String[] { ".json", ".jsonl" };
|
||||
private final String[] fileSuffixes = new String[] { ".json", ".jsonl" };
|
||||
|
||||
@Override
|
||||
protected void storeData(final DataConfig dataConfig, final IndexUpdateCallback callback, final Map<String, String> paramMap,
|
||||
|
@ -148,9 +148,9 @@ public class JsonDataStoreImpl extends AbstractDataStoreImpl {
|
|||
|
||||
callback.store(paramMap, dataMap);
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
} catch (final FileNotFoundException e) {
|
||||
logger.error("Source file " + file + " does not exist.");
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
logger.error("IO Error occurred while reading source file.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -285,15 +285,12 @@ public class FessEsClient implements Client {
|
|||
if (StringUtil.isBlank(transportAddressesValue)) {
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
for (final TransportAddress transportAddress : transportAddressList) {
|
||||
if (transportAddress instanceof TransportAddress) {
|
||||
if (buf.length() > 0) {
|
||||
buf.append(',');
|
||||
}
|
||||
final TransportAddress inetTransportAddress = (TransportAddress) transportAddress;
|
||||
buf.append(inetTransportAddress.address().getHostName());
|
||||
buf.append(':');
|
||||
buf.append(inetTransportAddress.address().getPort());
|
||||
if (buf.length() > 0) {
|
||||
buf.append(',');
|
||||
}
|
||||
buf.append(transportAddress.address().getHostName());
|
||||
buf.append(':');
|
||||
buf.append(transportAddress.address().getPort());
|
||||
}
|
||||
if (buf.length() > 0) {
|
||||
System.setProperty(Constants.FESS_ES_TRANSPORT_ADDRESSES, buf.toString());
|
||||
|
@ -599,7 +596,7 @@ public class FessEsClient implements Client {
|
|||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Elasticsearch Cluster Status: " + response.getStatus());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
final String message =
|
||||
"Elasticsearch (" + System.getProperty(Constants.FESS_ES_TRANSPORT_ADDRESSES)
|
||||
+ ") is not available. Check the state of your Elasticsearch cluster ("
|
||||
|
@ -1437,7 +1434,7 @@ public class FessEsClient implements Client {
|
|||
this.scrollForDelete = scrollForDelete;
|
||||
}
|
||||
|
||||
public void setScrollForSearch(String scrollForSearch) {
|
||||
public void setScrollForSearch(final String scrollForSearch) {
|
||||
this.scrollForSearch = scrollForSearch;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,14 +49,14 @@ public class ScheduledJobBhv extends BsScheduledJobBhv {
|
|||
for (int i = 0; i < 30; i++) {
|
||||
try {
|
||||
return super.selectByPK(id);
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Failed to select a job by " + id, e);
|
||||
}
|
||||
lastException = e;
|
||||
try {
|
||||
Thread.sleep(RandomUtils.nextLong(500, 5000));
|
||||
} catch (InterruptedException e1) {
|
||||
} catch (final InterruptedException e1) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,12 +73,12 @@ public class SearchLogBhv extends BsSearchLogBhv {
|
|||
if (searchFieldObj instanceof Map) {
|
||||
((Map<String, ?>) searchFieldObj).entrySet().stream().forEach(e -> {
|
||||
if (e.getValue() instanceof String[]) {
|
||||
String[] values = (String[]) e.getValue();
|
||||
final String[] values = (String[]) e.getValue();
|
||||
for (final String v : values) {
|
||||
result.getSearchFieldLogList().add(new Pair<>(e.getKey(), v));
|
||||
}
|
||||
} else if (e.getValue() instanceof List) {
|
||||
List<String> values = (List<String>) e.getValue();
|
||||
final List<String> values = (List<String>) e.getValue();
|
||||
for (final String v : values) {
|
||||
result.getSearchFieldLogList().add(new Pair<>(e.getKey(), v));
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class SearchLogBhv extends BsSearchLogBhv {
|
|||
});
|
||||
}
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
final String msg = "Cannot create a new instance: " + entityType.getName();
|
||||
throw new IllegalBehaviorStateException(msg, e);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public class JobNotFoundException extends FessSystemException {
|
|||
super(scheduledJob.toString());
|
||||
}
|
||||
|
||||
public JobNotFoundException(String message) {
|
||||
public JobNotFoundException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public class JobProcessingException extends FessSystemException {
|
|||
super(e);
|
||||
}
|
||||
|
||||
public JobProcessingException(String message, IOException e) {
|
||||
public JobProcessingException(final String message, final IOException e) {
|
||||
super(message, e);
|
||||
}
|
||||
|
||||
|
|
|
@ -251,11 +251,11 @@ public class Crawler {
|
|||
if (Thread.interrupted()) {
|
||||
return;
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
} catch (final InterruptedException e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
logger.debug("I/O exception.", e);
|
||||
}
|
||||
}, "ProcessCommand");
|
||||
|
|
|
@ -139,7 +139,7 @@ public class ThumbnailGenerator {
|
|||
TimeoutManager.getInstance().addTimeoutTarget(new SystemMonitorTarget(),
|
||||
ComponentUtil.getFessConfig().getSuggestSystemMonitorIntervalAsInteger(), true);
|
||||
|
||||
int totalCount = process(options);
|
||||
final int totalCount = process(options);
|
||||
if (totalCount != 0) {
|
||||
logger.info("Created " + totalCount + " thumbnail files.");
|
||||
} else {
|
||||
|
|
|
@ -144,7 +144,7 @@ public class ActivityHelper {
|
|||
this.loggerName = loggerName;
|
||||
}
|
||||
|
||||
public void setPermissionSeparator(String permissionSeparator) {
|
||||
public void setPermissionSeparator(final String permissionSeparator) {
|
||||
this.permissionSeparator = permissionSeparator;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,8 +80,8 @@ public class ProcessHelper {
|
|||
return !runningProcessMap.isEmpty();
|
||||
}
|
||||
|
||||
public boolean isProcessRunning(String sessionId) {
|
||||
JobProcess jobProcess = runningProcessMap.get(sessionId);
|
||||
public boolean isProcessRunning(final String sessionId) {
|
||||
final JobProcess jobProcess = runningProcessMap.get(sessionId);
|
||||
return jobProcess != null && jobProcess.getProcess().isAlive();
|
||||
}
|
||||
|
||||
|
@ -147,14 +147,14 @@ public class ProcessHelper {
|
|||
this.processDestroyTimeout = processDestroyTimeout;
|
||||
}
|
||||
|
||||
public void sendCommand(String sessionId, String command) {
|
||||
JobProcess jobProcess = runningProcessMap.get(sessionId);
|
||||
public void sendCommand(final String sessionId, final String command) {
|
||||
final JobProcess jobProcess = runningProcessMap.get(sessionId);
|
||||
if (jobProcess != null) {
|
||||
try {
|
||||
final OutputStream out = jobProcess.getProcess().getOutputStream();
|
||||
IOUtils.write(command + "\n", out, Constants.CHARSET_UTF_8);
|
||||
out.flush();
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
throw new JobProcessingException(e);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -518,7 +518,7 @@ public class QueryHelper {
|
|||
return QueryBuilders.matchPhraseQuery(f, text);
|
||||
}
|
||||
|
||||
UnicodeBlock block = UnicodeBlock.of(text.codePointAt(0));
|
||||
final UnicodeBlock block = UnicodeBlock.of(text.codePointAt(0));
|
||||
if (block == UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS //
|
||||
|| block == UnicodeBlock.HIRAGANA //
|
||||
|| block == UnicodeBlock.KATAKANA //
|
||||
|
|
|
@ -72,7 +72,7 @@ public class RelatedContentHelper {
|
|||
relatedContentMap.put(key, pair);
|
||||
}
|
||||
if (entity.getTerm().startsWith(regexPrefix)) {
|
||||
String regex = entity.getTerm().substring(regexPrefix.length());
|
||||
final String regex = entity.getTerm().substring(regexPrefix.length());
|
||||
if (StringUtil.isBlank(regex)) {
|
||||
logger.warn("Unknown regex pattern: " + entity.getTerm());
|
||||
} else {
|
||||
|
@ -114,11 +114,11 @@ public class RelatedContentHelper {
|
|||
return term != null ? term.toLowerCase(Locale.ROOT) : term;
|
||||
}
|
||||
|
||||
public void setRegexPrefix(String regexPrefix) {
|
||||
public void setRegexPrefix(final String regexPrefix) {
|
||||
this.regexPrefix = regexPrefix;
|
||||
}
|
||||
|
||||
public void setQueryPlaceHolder(String queryPlaceHolder) {
|
||||
public void setQueryPlaceHolder(final String queryPlaceHolder) {
|
||||
this.queryPlaceHolder = queryPlaceHolder;
|
||||
}
|
||||
|
||||
|
|
|
@ -259,7 +259,7 @@ public class SystemHelper {
|
|||
}
|
||||
|
||||
public String normalizeHtmlLang(final String value) {
|
||||
String defaultLang = ComponentUtil.getFessConfig().getCrawlerDocumentHtmlDefaultLang();
|
||||
final String defaultLang = ComponentUtil.getFessConfig().getCrawlerDocumentHtmlDefaultLang();
|
||||
if (StringUtil.isNotBlank(defaultLang)) {
|
||||
return defaultLang;
|
||||
}
|
||||
|
|
|
@ -236,7 +236,7 @@ public class ViewHelper {
|
|||
// file
|
||||
try {
|
||||
url = URLDecoder.decode(url.replace("+", "%2B"), urlLinkEncoding);
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.warn("Failed to decode " + url, e);
|
||||
}
|
||||
|
|
|
@ -587,7 +587,7 @@ public class FessLabels extends UserMessages {
|
|||
/** The key of the message: MENU */
|
||||
public static final String LABELS_SIDEBAR_MENU = "{labels.sidebar.menu}";
|
||||
|
||||
/** The key of the message: ©2017 <a href="https://github.com/codelibs">CodeLibs Project</a>. */
|
||||
/** The key of the message: ©2018 <a href="https://github.com/codelibs">CodeLibs Project</a>. */
|
||||
public static final String LABELS_FOOTER_COPYRIGHT = "{labels.footer.copyright}";
|
||||
|
||||
/** The key of the message: Search */
|
||||
|
|
|
@ -178,7 +178,7 @@ public class GoogleAnalyticsScoreBooster extends ScoreBooster {
|
|||
return counter;
|
||||
}
|
||||
|
||||
protected String normalizeUrl(String path, final String baseUrl) throws MalformedURLException {
|
||||
protected String normalizeUrl(final String path, final String baseUrl) throws MalformedURLException {
|
||||
return new URL(baseUrl + path.toString()).toString();
|
||||
}
|
||||
|
||||
|
@ -194,10 +194,10 @@ public class GoogleAnalyticsScoreBooster extends ScoreBooster {
|
|||
}
|
||||
|
||||
public void addReportRequest(final List<String> urls, final ReportRequest request) {
|
||||
reportRequesList.add(new Pair<String[], ReportRequest>(urls.toArray(new String[urls.size()]), request));
|
||||
reportRequesList.add(new Pair<>(urls.toArray(new String[urls.size()]), request));
|
||||
}
|
||||
|
||||
public void addReportRequest(final String url, final ReportRequest request) {
|
||||
reportRequesList.add(new Pair<String[], ReportRequest>(new String[] { url }, request));
|
||||
reportRequesList.add(new Pair<>(new String[] { url }, request));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ public class CommandGenerator extends BaseThumbnailGenerator {
|
|||
|
||||
private final List<String> commandList;
|
||||
|
||||
private long timeout;
|
||||
private final long timeout;
|
||||
|
||||
protected ProcessDestroyer(final Process p, final List<String> commandList, final long timeout) {
|
||||
this.p = p;
|
||||
|
@ -206,7 +206,7 @@ public class CommandGenerator extends BaseThumbnailGenerator {
|
|||
this.baseDir = baseDir;
|
||||
}
|
||||
|
||||
public void setCommandDestroyTimeout(long commandDestroyTimeout) {
|
||||
public void setCommandDestroyTimeout(final long commandDestroyTimeout) {
|
||||
this.commandDestroyTimeout = commandDestroyTimeout;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ public class SystemMonitorTarget implements TimeoutTarget {
|
|||
|
||||
@Override
|
||||
public void expired() {
|
||||
StringBuilder buf = new StringBuilder(1000);
|
||||
final StringBuilder buf = new StringBuilder(1000);
|
||||
|
||||
buf.append("[SYSTEM MONITOR] ");
|
||||
buf.append('{');
|
||||
|
@ -84,10 +84,10 @@ public class SystemMonitorTarget implements TimeoutTarget {
|
|||
logger.info(buf.toString());
|
||||
}
|
||||
|
||||
private void appendJvmStats(StringBuilder buf) {
|
||||
private void appendJvmStats(final StringBuilder buf) {
|
||||
buf.append("\"jvm\":{");
|
||||
final JvmStats jvmStats = JvmStats.jvmStats();
|
||||
Mem mem = jvmStats.getMem();
|
||||
final Mem mem = jvmStats.getMem();
|
||||
buf.append("\"memory\":{");
|
||||
buf.append("\"heap\":{");
|
||||
append(buf, "used", () -> mem.getHeapUsed().bytesAsInt()).append(',');
|
||||
|
@ -100,10 +100,10 @@ public class SystemMonitorTarget implements TimeoutTarget {
|
|||
append(buf, "committed", () -> mem.getNonHeapCommitted().bytesAsInt());
|
||||
buf.append('}');
|
||||
buf.append("},");
|
||||
List<BufferPool> bufferPools = jvmStats.getBufferPools();
|
||||
final List<BufferPool> bufferPools = jvmStats.getBufferPools();
|
||||
buf.append("\"pools\":{");
|
||||
buf.append(bufferPools.stream().map(p -> {
|
||||
StringBuilder b = new StringBuilder();
|
||||
final StringBuilder b = new StringBuilder();
|
||||
b.append('"').append(StringEscapeUtils.escapeJson(p.getName())).append("\":{");
|
||||
append(b, "count", () -> p.getCount()).append(',');
|
||||
append(b, "used", () -> p.getUsed().bytesAsInt()).append(',');
|
||||
|
@ -111,22 +111,22 @@ public class SystemMonitorTarget implements TimeoutTarget {
|
|||
return b.toString();
|
||||
}).collect(Collectors.joining(",")));
|
||||
buf.append("},");
|
||||
GarbageCollectors gc = jvmStats.getGc();
|
||||
final GarbageCollectors gc = jvmStats.getGc();
|
||||
buf.append("\"gc\":{");
|
||||
buf.append(Arrays.stream(gc.getCollectors()).map(c -> {
|
||||
StringBuilder b = new StringBuilder();
|
||||
final StringBuilder b = new StringBuilder();
|
||||
b.append('"').append(StringEscapeUtils.escapeJson(c.getName())).append("\":{");
|
||||
append(b, "count", () -> c.getCollectionCount()).append(',');
|
||||
append(b, "time", () -> c.getCollectionTime().getMillis()).append('}');
|
||||
return b.toString();
|
||||
}).collect(Collectors.joining(",")));
|
||||
buf.append("},");
|
||||
Threads threads = jvmStats.getThreads();
|
||||
final Threads threads = jvmStats.getThreads();
|
||||
buf.append("\"threads\":{");
|
||||
append(buf, "count", () -> threads.getCount()).append(',');
|
||||
append(buf, "peak", () -> threads.getPeakCount());
|
||||
buf.append("},");
|
||||
Classes classes = jvmStats.getClasses();
|
||||
final Classes classes = jvmStats.getClasses();
|
||||
buf.append("\"classes\":{");
|
||||
append(buf, "loaded", () -> classes.getLoadedClassCount()).append(',');
|
||||
append(buf, "total_loaded", () -> classes.getTotalLoadedClassCount()).append(',');
|
||||
|
@ -136,7 +136,7 @@ public class SystemMonitorTarget implements TimeoutTarget {
|
|||
buf.append("},");
|
||||
}
|
||||
|
||||
private void appendProcessStats(StringBuilder buf) {
|
||||
private void appendProcessStats(final StringBuilder buf) {
|
||||
buf.append("\"process\":{");
|
||||
final ProcessProbe processProbe = ProcessProbe.getInstance();
|
||||
buf.append("\"file_descriptor\":{");
|
||||
|
@ -153,7 +153,7 @@ public class SystemMonitorTarget implements TimeoutTarget {
|
|||
buf.append("},");
|
||||
}
|
||||
|
||||
private void appendOsStats(StringBuilder buf) {
|
||||
private void appendOsStats(final StringBuilder buf) {
|
||||
buf.append("\"os\":{");
|
||||
final OsProbe osProbe = OsProbe.getInstance();
|
||||
buf.append("\"memory\":{");
|
||||
|
@ -168,26 +168,26 @@ public class SystemMonitorTarget implements TimeoutTarget {
|
|||
buf.append("},");
|
||||
buf.append("\"cpu\":{");
|
||||
append(buf, "percent", () -> osProbe.getSystemCpuPercent());
|
||||
OsStats osStats = osProbe.osStats();
|
||||
final OsStats osStats = osProbe.osStats();
|
||||
buf.append("},");
|
||||
append(buf, "load_averages", () -> osStats.getCpu().getLoadAverage());
|
||||
buf.append("},");
|
||||
}
|
||||
|
||||
private void appendElasticsearchStats(StringBuilder buf) {
|
||||
private void appendElasticsearchStats(final StringBuilder buf) {
|
||||
String stats = null;
|
||||
try {
|
||||
FessEsClient esClient = ComponentUtil.getFessEsClient();
|
||||
NodesStatsResponse response =
|
||||
final FessEsClient esClient = ComponentUtil.getFessEsClient();
|
||||
final NodesStatsResponse response =
|
||||
esClient.admin().cluster().prepareNodesStats().ingest(false).setBreaker(false).setDiscovery(false).setFs(true)
|
||||
.setHttp(false).setIndices(true).setJvm(true).setOs(true).setProcess(true).setScript(false).setThreadPool(true)
|
||||
.setTransport(true).execute().actionGet(10000L);
|
||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
final XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
builder.startObject();
|
||||
response.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||
builder.endObject();
|
||||
stats = builder.string();
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
logger.debug("Failed to access Elasticsearch stats.", e);
|
||||
}
|
||||
buf.append("\"elasticsearch\":").append(stats).append(',');
|
||||
|
|
|
@ -27,7 +27,7 @@ public final class DocumentUtil {
|
|||
}
|
||||
|
||||
public static <T> T getValue(final Map<String, Object> doc, final String key, final Class<T> clazz, final T defaultValue) {
|
||||
T value = getValue(doc, key, clazz);
|
||||
final T value = getValue(doc, key, clazz);
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
|
|
@ -53,16 +53,16 @@ public class ThreadDumpUtil {
|
|||
try {
|
||||
writer.write(s);
|
||||
writer.write('\n');
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
logger.warn("Failed to write a thread dump to " + file, e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void processThreadDump(Consumer<String> writer) {
|
||||
public static void processThreadDump(final Consumer<String> writer) {
|
||||
for (final Map.Entry<Thread, StackTraceElement[]> entry : Thread.getAllStackTraces().entrySet()) {
|
||||
writer.accept("Thread: " + entry.getKey());
|
||||
final StackTraceElement[] trace = entry.getValue();
|
||||
|
|
Loading…
Add table
Reference in a new issue