use of com.xiaomi.linden.thrift.common.LindenServiceInfo in project linden by XiaoMi.
the class TestMultiLindenCore method testDocNumDivision.
@Test
public void testDocNumDivision() throws Exception {
String path = FilenameUtils.concat(INDEX_DIR, "size/");
lindenConfig.setIndexDirectory(path).setLindenCoreMode(LindenConfig.LindenCoreMode.HOTSWAP).setMultiIndexDivisionType(LindenConfig.MultiIndexDivisionType.DOC_NUM).setMultiIndexDocNumLimit(100).setMultiIndexMaxLiveIndexNum(4);
Deencapsulation.setField(DocNumLimitMultiIndexStrategy.class, "INDEX_CHECK_INTERVAL_MILLISECONDS", -10);
lindenCore = new MultiLindenCoreImpl(lindenConfig);
for (int i = 0; i < 400; ++i) {
JSONObject json = new JSONObject();
json.put("type", "index");
JSONObject content = new JSONObject();
content.put("id", i);
content.put("title", "test " + i);
json.put("content", content);
handleRequest(json.toJSONString());
}
lindenCore.commit();
lindenCore.refresh();
Assert.assertEquals(4, lindenCore.getServiceInfo().getIndexNamesSize());
Assert.assertEquals(400, lindenCore.getServiceInfo().getDocsNum());
String bql = "select * from linden source";
LindenSearchRequest request = bqlCompiler.compile(bql).getSearchRequest();
LindenResult result = lindenCore.search(request);
Assert.assertEquals(400, result.getTotalHits());
for (int i = 0; i < 400; ++i) {
JSONObject json = new JSONObject();
json.put("type", "index");
JSONObject content = new JSONObject();
content.put("id", i + 400);
content.put("title", "test " + i);
json.put("content", content);
handleRequest(json.toJSONString());
}
lindenCore.commit();
lindenCore.refresh();
LindenServiceInfo serviceInfo = lindenCore.getServiceInfo();
Assert.assertEquals(4, serviceInfo.getIndexNamesSize());
Assert.assertEquals(400, serviceInfo.getDocsNum());
lindenCore.close();
}
use of com.xiaomi.linden.thrift.common.LindenServiceInfo in project linden by XiaoMi.
the class CoreLindenServiceImpl method getServiceInfo.
@Override
public Future<LindenServiceInfo> getServiceInfo() {
return instanceExecutorPool.apply(new Function0<LindenServiceInfo>() {
@Override
public LindenServiceInfo apply() {
LindenServiceInfo serviceInfo;
try {
serviceInfo = lindenCore.getServiceInfo();
CacheInfo cacheInfo = lindenCluster.getCacheInfo();
serviceInfo.setCacheInfo(cacheInfo);
} catch (Exception e) {
serviceInfo = new LindenServiceInfo();
LOGGER.error("get service info failed : {}", Throwables.getStackTraceAsString(e));
}
return serviceInfo;
}
});
}
use of com.xiaomi.linden.thrift.common.LindenServiceInfo 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.LindenServiceInfo 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.LindenServiceInfo 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