use of com.xiaomi.linden.thrift.common.FileDiskUsageInfo in project linden by XiaoMi.
the class HotSwapLindenCoreImpl method getServiceInfo.
@Override
public LindenServiceInfo getServiceInfo() throws IOException {
LindenServiceInfo serviceInfo = currentLindenCore.getServiceInfo();
List<String> indexNames = new ArrayList<>();
for (Map.Entry<String, LindenCore> entry : lindenCoreMap.entrySet()) {
indexNames.add(entry.getKey());
}
List<String> paths = new ArrayList<>();
if (baseIndexDir != null) {
paths.add(baseIndexDir);
}
if (lindenConfig.getLogPath() != null) {
paths.add(lindenConfig.getLogPath());
}
List<FileDiskUsageInfo> fileUsedInfos = RuntimeInfoUtils.getRuntimeFileInfo(paths);
serviceInfo.setIndexNames(indexNames).setFileUsedInfos(fileUsedInfos);
return serviceInfo;
}
use of com.xiaomi.linden.thrift.common.FileDiskUsageInfo in project linden by XiaoMi.
the class LindenCoreImpl method getServiceInfo.
@Override
public LindenServiceInfo getServiceInfo() throws IOException {
int docNum = trackingIndexWriter.getIndexWriter().numDocs();
List<String> paths = new ArrayList<>();
if (config.getIndexDirectory() != null) {
paths.add(config.getIndexDirectory());
}
if (config.getLogPath() != null) {
paths.add(config.getLogPath());
}
List<FileDiskUsageInfo> fileDiskUsageInfos = RuntimeInfoUtils.getRuntimeFileInfo(paths);
SearcherTaxonomyManager.SearcherAndTaxonomy searcherAndTaxonomy = lindenNRTSearcherManager.acquire();
int segmentNum;
try {
segmentNum = searcherAndTaxonomy.searcher.getIndexReader().leaves().size();
} catch (Exception e) {
throw new IOException(e);
} finally {
lindenNRTSearcherManager.release(searcherAndTaxonomy);
}
List<Integer> segmentNums = new ArrayList<>();
segmentNums.add(segmentNum);
return new LindenServiceInfo().setDocsNum(docNum).setJvmInfo(RuntimeInfoUtils.getJVMInfo()).setFileUsedInfos(fileDiskUsageInfos).setSegmentNums(segmentNums);
}
use of com.xiaomi.linden.thrift.common.FileDiskUsageInfo in project linden by XiaoMi.
the class RuntimeInfoUtils method getRuntimeFileInfo.
public static List<FileDiskUsageInfo> getRuntimeFileInfo(List<String> paths) {
List<FileDiskUsageInfo> runtimeInfos = new ArrayList<>();
for (String path : paths) {
long size;
try {
size = totalFileSize(path);
} catch (Exception e) {
continue;
}
FileDiskUsageInfo fileInfo = new FileDiskUsageInfo().setDirName(path).setDiskUsage(size);
runtimeInfos.add(fileInfo);
}
return runtimeInfos;
}
use of com.xiaomi.linden.thrift.common.FileDiskUsageInfo in project linden by XiaoMi.
the class MultiLindenCoreImpl method getServiceInfo.
@Override
public LindenServiceInfo getServiceInfo() throws IOException {
int docsNum = 0;
LindenServiceInfo serviceInfo = new LindenServiceInfo();
List<String> indexNames = new ArrayList<>();
List<Integer> segmentNums = new ArrayList<>();
for (Map.Entry<String, LindenCore> entry : lindenCoreMap.entrySet()) {
serviceInfo = entry.getValue().getServiceInfo();
docsNum += serviceInfo.getDocsNum();
indexNames.add(entry.getKey());
segmentNums.add(serviceInfo.getSegmentNums().get(0));
}
List<String> paths = new ArrayList<>();
if (baseIndexDir != null) {
paths.add(baseIndexDir);
}
if (config.getLogPath() != null) {
paths.add(config.getLogPath());
}
List<FileDiskUsageInfo> fileUsedInfos = RuntimeInfoUtils.getRuntimeFileInfo(paths);
serviceInfo.setDocsNum(docsNum).setIndexNames(indexNames).setFileUsedInfos(fileUsedInfos).setSegmentNums(segmentNums);
return serviceInfo;
}
Aggregations