Search in sources :

Example 1 with FileDiskUsageInfo

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;
}
Also used : LindenServiceInfo(com.xiaomi.linden.thrift.common.LindenServiceInfo) FileDiskUsageInfo(com.xiaomi.linden.thrift.common.FileDiskUsageInfo) ArrayList(java.util.ArrayList) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Map(java.util.Map)

Example 2 with FileDiskUsageInfo

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);
}
Also used : LindenServiceInfo(com.xiaomi.linden.thrift.common.LindenServiceInfo) ArrayList(java.util.ArrayList) IOException(java.io.IOException) IOException(java.io.IOException) SearcherTaxonomyManager(org.apache.lucene.facet.taxonomy.SearcherTaxonomyManager) FileDiskUsageInfo(com.xiaomi.linden.thrift.common.FileDiskUsageInfo)

Example 3 with FileDiskUsageInfo

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;
}
Also used : FileDiskUsageInfo(com.xiaomi.linden.thrift.common.FileDiskUsageInfo) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Example 4 with FileDiskUsageInfo

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;
}
Also used : LindenServiceInfo(com.xiaomi.linden.thrift.common.LindenServiceInfo) FileDiskUsageInfo(com.xiaomi.linden.thrift.common.FileDiskUsageInfo) ArrayList(java.util.ArrayList) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Aggregations

FileDiskUsageInfo (com.xiaomi.linden.thrift.common.FileDiskUsageInfo)4 ArrayList (java.util.ArrayList)4 LindenServiceInfo (com.xiaomi.linden.thrift.common.LindenServiceInfo)3 IOException (java.io.IOException)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 SearcherTaxonomyManager (org.apache.lucene.facet.taxonomy.SearcherTaxonomyManager)1