本文整理汇总了Java中org.elasticsearch.index.shard.DocsStats类的典型用法代码示例。如果您正苦于以下问题:Java DocsStats类的具体用法?Java DocsStats怎么用?Java DocsStats使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocsStats类属于org.elasticsearch.index.shard包,在下文中一共展示了DocsStats类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: CommonStats
import org.elasticsearch.index.shard.DocsStats; //导入依赖的package包/类
public CommonStats(StreamInput in) throws IOException {
docs = in.readOptionalStreamable(DocsStats::new);
store = in.readOptionalStreamable(StoreStats::new);
indexing = in.readOptionalStreamable(IndexingStats::new);
get = in.readOptionalStreamable(GetStats::new);
search = in.readOptionalStreamable(SearchStats::new);
merge = in.readOptionalStreamable(MergeStats::new);
refresh = in.readOptionalStreamable(RefreshStats::new);
flush = in.readOptionalStreamable(FlushStats::new);
warmer = in.readOptionalStreamable(WarmerStats::new);
queryCache = in.readOptionalStreamable(QueryCacheStats::new);
fieldData = in.readOptionalStreamable(FieldDataStats::new);
completion = in.readOptionalStreamable(CompletionStats::new);
segments = in.readOptionalStreamable(SegmentsStats::new);
translog = in.readOptionalStreamable(TranslogStats::new);
requestCache = in.readOptionalStreamable(RequestCacheStats::new);
recoveryStats = in.readOptionalStreamable(RecoveryStats::new);
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:CommonStats.java
示例2: createSearchIndexStatistics
import org.elasticsearch.index.shard.DocsStats; //导入依赖的package包/类
/**
* Creates a new search index statistics objects per specified parameters.
*
* @param settings the search index settings
* @param docsStats the search index docs stats
* @param indexCount the count of index
*
* @return the newly created search index statistics object
*/
protected SearchIndexStatistics createSearchIndexStatistics(Settings settings, DocsStats docsStats, long indexCount)
{
SearchIndexStatistics searchIndexStatistics = new SearchIndexStatistics();
Long creationDate = settings.getAsLong(IndexMetaData.SETTING_CREATION_DATE, -1L);
if (creationDate.longValue() != -1L)
{
DateTime creationDateTime = new DateTime(creationDate, DateTimeZone.UTC);
searchIndexStatistics.setIndexCreationDate(HerdDateUtils.getXMLGregorianCalendarValue(creationDateTime.toDate()));
}
searchIndexStatistics.setIndexNumberOfActiveDocuments(docsStats.getCount());
searchIndexStatistics.setIndexNumberOfDeletedDocuments(docsStats.getDeleted());
searchIndexStatistics.setIndexUuid(settings.get(IndexMetaData.SETTING_INDEX_UUID));
searchIndexStatistics.setIndexCount(indexCount);
return searchIndexStatistics;
}
开发者ID:FINRAOS,项目名称:herd,代码行数:28,代码来源:SearchIndexServiceImpl.java
示例3: testCreateSearchIndexStatisticsNoIndexCreationDate
import org.elasticsearch.index.shard.DocsStats; //导入依赖的package包/类
@Test
public void testCreateSearchIndexStatisticsNoIndexCreationDate()
{
// Create a search index get settings response without the index creation date setting.
ImmutableOpenMap<String, Settings> getIndexResponseSettings = ImmutableOpenMap.<String, Settings>builder()
.fPut(SEARCH_INDEX_NAME, Settings.builder().put(IndexMetaData.SETTING_INDEX_UUID, SEARCH_INDEX_STATISTICS_INDEX_UUID).build()).build();
// Mock an index docs stats object.
DocsStats mockedDocsStats = mock(DocsStats.class);
when(mockedDocsStats.getCount()).thenReturn(SEARCH_INDEX_STATISTICS_NUMBER_OF_ACTIVE_DOCUMENTS);
when(mockedDocsStats.getDeleted()).thenReturn(SEARCH_INDEX_STATISTICS_NUMBER_OF_DELETED_DOCUMENTS);
// Get a search index settings created.
SearchIndexStatistics response = searchIndexServiceImpl.createSearchIndexStatistics(getIndexResponseSettings.get(SEARCH_INDEX_NAME), mockedDocsStats, 0l);
// Verify the external calls.
verifyNoMoreInteractions(alternateKeyHelper, businessObjectDefinitionDao, businessObjectDefinitionHelper, configurationDaoHelper, configurationHelper,
searchIndexDao, searchIndexDaoHelper, searchIndexHelperService, searchIndexStatusDaoHelper, searchIndexTypeDaoHelper);
// Validate the returned object.
assertEquals(new SearchIndexStatistics(NO_SEARCH_INDEX_STATISTICS_CREATION_DATE, SEARCH_INDEX_STATISTICS_NUMBER_OF_ACTIVE_DOCUMENTS,
SEARCH_INDEX_STATISTICS_NUMBER_OF_DELETED_DOCUMENTS, SEARCH_INDEX_STATISTICS_INDEX_UUID, 0l), response);
}
开发者ID:FINRAOS,项目名称:herd,代码行数:24,代码来源:SearchIndexServiceImplTest.java
示例4: evaluateConditions
import org.elasticsearch.index.shard.DocsStats; //导入依赖的package包/类
static Set<Condition.Result> evaluateConditions(final Set<Condition> conditions,
final DocsStats docsStats, final IndexMetaData metaData) {
final long numDocs = docsStats == null ? 0 : docsStats.getCount();
final Condition.Stats stats = new Condition.Stats(numDocs, metaData.getCreationDate());
return conditions.stream()
.map(condition -> condition.evaluate(stats))
.collect(Collectors.toSet());
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:TransportRolloverAction.java
示例5: ClusterStatsIndices
import org.elasticsearch.index.shard.DocsStats; //导入依赖的package包/类
public ClusterStatsIndices(List<ClusterStatsNodeResponse> nodeResponses) {
ObjectObjectHashMap<String, ShardStats> countsPerIndex = new ObjectObjectHashMap<>();
this.docs = new DocsStats();
this.store = new StoreStats();
this.fieldData = new FieldDataStats();
this.queryCache = new QueryCacheStats();
this.completion = new CompletionStats();
this.segments = new SegmentsStats();
for (ClusterStatsNodeResponse r : nodeResponses) {
for (org.elasticsearch.action.admin.indices.stats.ShardStats shardStats : r.shardsStats()) {
ShardStats indexShardStats = countsPerIndex.get(shardStats.getShardRouting().getIndexName());
if (indexShardStats == null) {
indexShardStats = new ShardStats();
countsPerIndex.put(shardStats.getShardRouting().getIndexName(), indexShardStats);
}
indexShardStats.total++;
CommonStats shardCommonStats = shardStats.getStats();
if (shardStats.getShardRouting().primary()) {
indexShardStats.primaries++;
docs.add(shardCommonStats.docs);
}
store.add(shardCommonStats.store);
fieldData.add(shardCommonStats.fieldData);
queryCache.add(shardCommonStats.queryCache);
completion.add(shardCommonStats.completion);
segments.add(shardCommonStats.segments);
}
}
shards = new ShardStats();
indexCount = countsPerIndex.size();
for (ObjectObjectCursor<String, ShardStats> indexCountsCursor : countsPerIndex) {
shards.addIndexShardCount(indexCountsCursor.value);
}
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:41,代码来源:ClusterStatsIndices.java
示例6: randomIndicesStatsResponse
import org.elasticsearch.index.shard.DocsStats; //导入依赖的package包/类
private IndicesStatsResponse randomIndicesStatsResponse(final Index[] indices) {
List<ShardStats> shardStats = new ArrayList<>();
for (final Index index : indices) {
for (int i = 0; i < 2; i++) {
ShardId shardId = new ShardId(index, i);
Path path = createTempDir().resolve("indices").resolve(index.getUUID()).resolve(String.valueOf(i));
ShardRouting shardRouting = ShardRouting.newUnassigned(shardId, i == 0,
i == 0 ? StoreRecoverySource.EMPTY_STORE_INSTANCE : PeerRecoverySource.INSTANCE,
new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, null)
);
shardRouting = shardRouting.initialize("node-0", null, ShardRouting.UNAVAILABLE_EXPECTED_SHARD_SIZE);
shardRouting = shardRouting.moveToStarted();
CommonStats stats = new CommonStats();
stats.fieldData = new FieldDataStats();
stats.queryCache = new QueryCacheStats();
stats.docs = new DocsStats();
stats.store = new StoreStats();
stats.indexing = new IndexingStats();
stats.search = new SearchStats();
stats.segments = new SegmentsStats();
stats.merge = new MergeStats();
stats.refresh = new RefreshStats();
stats.completion = new CompletionStats();
stats.requestCache = new RequestCacheStats();
stats.get = new GetStats();
stats.flush = new FlushStats();
stats.warmer = new WarmerStats();
shardStats.add(new ShardStats(shardRouting, new ShardPath(false, path, path, shardId), stats, null, null));
}
}
return IndicesStatsTests.newIndicesStatsResponse(
shardStats.toArray(new ShardStats[shardStats.size()]), shardStats.size(), shardStats.size(), 0, emptyList()
);
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:35,代码来源:RestIndicesActionTests.java
示例7: testShrinkIndexSettings
import org.elasticsearch.index.shard.DocsStats; //导入依赖的package包/类
public void testShrinkIndexSettings() {
String indexName = randomAsciiOfLength(10);
// create one that won't fail
ClusterState clusterState = ClusterState.builder(createClusterState(indexName, randomIntBetween(2, 10), 0,
Settings.builder()
.put("index.blocks.write", true)
.build())).nodes(DiscoveryNodes.builder().add(newNode("node1")))
.build();
AllocationService service = new AllocationService(Settings.builder().build(), new AllocationDeciders(Settings.EMPTY,
Collections.singleton(new MaxRetryAllocationDecider(Settings.EMPTY))),
new TestGatewayAllocator(), new BalancedShardsAllocator(Settings.EMPTY), EmptyClusterInfoService.INSTANCE);
RoutingTable routingTable = service.reroute(clusterState, "reroute").routingTable();
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
// now we start the shard
routingTable = service.applyStartedShards(clusterState,
routingTable.index(indexName).shardsWithState(ShardRoutingState.INITIALIZING)).routingTable();
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
int numSourceShards = clusterState.metaData().index(indexName).getNumberOfShards();
DocsStats stats = new DocsStats(randomIntBetween(0, (IndexWriter.MAX_DOCS) / numSourceShards), randomIntBetween(1, 1000));
ShrinkRequest target = new ShrinkRequest("target", indexName);
final ActiveShardCount activeShardCount = randomBoolean() ? ActiveShardCount.ALL : ActiveShardCount.ONE;
target.setWaitForActiveShards(activeShardCount);
CreateIndexClusterStateUpdateRequest request = TransportShrinkAction.prepareCreateIndexRequest(
target, clusterState, (i) -> stats,
new IndexNameExpressionResolver(Settings.EMPTY));
assertNotNull(request.shrinkFrom());
assertEquals(indexName, request.shrinkFrom().getName());
assertEquals("1", request.settings().get("index.number_of_shards"));
assertEquals("shrink_index", request.cause());
assertEquals(request.waitForActiveShards(), activeShardCount);
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:33,代码来源:TransportShrinkActionTests.java
示例8: readFrom
import org.elasticsearch.index.shard.DocsStats; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
indexCount = in.readVInt();
shards = ShardStats.readShardStats(in);
docs = DocsStats.readDocStats(in);
store = StoreStats.readStoreStats(in);
fieldData = FieldDataStats.readFieldDataStats(in);
queryCache = QueryCacheStats.readQueryCacheStats(in);
completion = CompletionStats.readCompletionStats(in);
segments = SegmentsStats.readSegmentsStats(in);
percolate = PercolateStats.readPercolateStats(in);
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:13,代码来源:ClusterStatsIndices.java
示例9: getSearchIndex
import org.elasticsearch.index.shard.DocsStats; //导入依赖的package包/类
@Override
public SearchIndex getSearchIndex(SearchIndexKey searchIndexKey)
{
// Perform validation and trim.
validateSearchIndexKey(searchIndexKey);
// Retrieve and ensure that a search index already exists with the specified key.
SearchIndexEntity searchIndexEntity = searchIndexDaoHelper.getSearchIndexEntity(searchIndexKey);
// Create the search index object from the persisted entity.
SearchIndex searchIndex = createSearchIndexFromEntity(searchIndexEntity);
DocsStats docsStats = indexFunctionsDao.getIndexStats(searchIndexKey.getSearchIndexName());
// Retrieve index settings from the actual search index. A non-existing search index name results in a "no such index" internal server error.
Settings settings = indexFunctionsDao.getIndexSettings(searchIndexKey.getSearchIndexName());
String searchIndexType = searchIndexEntity.getType().getCode();
String documentType = null;
// Currently, only search index for business object definitions and tag are supported.
if (SearchIndexTypeEntity.SearchIndexTypes.BUS_OBJCT_DFNTN.name().equalsIgnoreCase(searchIndexType))
{
documentType = configurationHelper.getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class);
}
else if (SearchIndexTypeEntity.SearchIndexTypes.TAG.name().equalsIgnoreCase(searchIndexType))
{
documentType = configurationHelper.getProperty(ConfigurationValue.ELASTICSEARCH_TAG_DOCUMENT_TYPE, String.class);
}
else
{
throw new IllegalArgumentException(String.format("Search index type with code \"%s\" is not supported.", searchIndexType));
}
long indexCount = indexFunctionsDao.getNumberOfTypesInIndex(searchIndexKey.getSearchIndexName(), documentType);
// Update the search index statistics.
searchIndex.setSearchIndexStatistics(createSearchIndexStatistics(settings, docsStats, indexCount));
return searchIndex;
}
开发者ID:FINRAOS,项目名称:herd,代码行数:40,代码来源:SearchIndexServiceImpl.java
示例10: getIndexStats
import org.elasticsearch.index.shard.DocsStats; //导入依赖的package包/类
@Override
public DocsStats getIndexStats(String indexName)
{
Action getStats = new Stats.Builder().addIndex(indexName).build();
JestResult jestResult = jestClientHelper.executeAction(getStats);
Assert.isTrue(jestResult.isSucceeded(), jestResult.getErrorMessage());
JsonObject statsJson = jestResult.getJsonObject().getAsJsonObject("indices").getAsJsonObject(indexName).getAsJsonObject("primaries");
JsonObject docsJson = statsJson.getAsJsonObject("docs");
return new DocsStats(docsJson.get("count").getAsLong(), docsJson.get("deleted").getAsLong());
}
开发者ID:FINRAOS,项目名称:herd,代码行数:11,代码来源:IndexFunctionsDaoImpl.java
示例11: getDocs
import org.elasticsearch.index.shard.DocsStats; //导入依赖的package包/类
@Nullable
public DocsStats getDocs() {
return stats.getDocs();
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:NodeIndicesStats.java
示例12: prepareCreateIndexRequest
import org.elasticsearch.index.shard.DocsStats; //导入依赖的package包/类
static CreateIndexClusterStateUpdateRequest prepareCreateIndexRequest(final ShrinkRequest shrinkRequest, final ClusterState state
, final IntFunction<DocsStats> perShardDocStats, IndexNameExpressionResolver indexNameExpressionResolver) {
final String sourceIndex = indexNameExpressionResolver.resolveDateMathExpression(shrinkRequest.getSourceIndex());
final CreateIndexRequest targetIndex = shrinkRequest.getShrinkIndexRequest();
final String targetIndexName = indexNameExpressionResolver.resolveDateMathExpression(targetIndex.index());
final IndexMetaData metaData = state.metaData().index(sourceIndex);
final Settings targetIndexSettings = Settings.builder().put(targetIndex.settings())
.normalizePrefix(IndexMetaData.INDEX_SETTING_PREFIX).build();
int numShards = 1;
if (IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.exists(targetIndexSettings)) {
numShards = IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.get(targetIndexSettings);
}
for (int i = 0; i < numShards; i++) {
Set<ShardId> shardIds = IndexMetaData.selectShrinkShards(i, metaData, numShards);
long count = 0;
for (ShardId id : shardIds) {
DocsStats docsStats = perShardDocStats.apply(id.id());
if (docsStats != null) {
count += docsStats.getCount();
}
if (count > IndexWriter.MAX_DOCS) {
throw new IllegalStateException("Can't merge index with more than [" + IndexWriter.MAX_DOCS
+ "] docs - too many documents in shards " + shardIds);
}
}
}
if (IndexMetaData.INDEX_ROUTING_PARTITION_SIZE_SETTING.exists(targetIndexSettings)) {
throw new IllegalArgumentException("cannot provide a routing partition size value when shrinking an index");
}
targetIndex.cause("shrink_index");
Settings.Builder settingsBuilder = Settings.builder().put(targetIndexSettings);
settingsBuilder.put("index.number_of_shards", numShards);
targetIndex.settings(settingsBuilder);
return new CreateIndexClusterStateUpdateRequest(targetIndex,
"shrink_index", targetIndex.index(), targetIndexName, true)
// mappings are updated on the node when merging in the shards, this prevents race-conditions since all mapping must be
// applied once we took the snapshot and if somebody fucks things up and switches the index read/write and adds docs we miss
// the mappings for everything is corrupted and hard to debug
.ackTimeout(targetIndex.timeout())
.masterNodeTimeout(targetIndex.masterNodeTimeout())
.settings(targetIndex.settings())
.aliases(targetIndex.aliases())
.customs(targetIndex.customs())
.waitForActiveShards(targetIndex.waitForActiveShards())
.shrinkFrom(metaData.getIndex());
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:49,代码来源:TransportShrinkAction.java
示例13: getDocs
import org.elasticsearch.index.shard.DocsStats; //导入依赖的package包/类
@Nullable
public DocsStats getDocs() {
return this.docs;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:CommonStats.java
示例14: getDocs
import org.elasticsearch.index.shard.DocsStats; //导入依赖的package包/类
public DocsStats getDocs() {
return docs;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:ClusterStatsIndices.java
示例15: CommonStats
import org.elasticsearch.index.shard.DocsStats; //导入依赖的package包/类
public CommonStats(CommonStatsFlags flags) {
CommonStatsFlags.Flag[] setFlags = flags.getFlags();
for (CommonStatsFlags.Flag flag : setFlags) {
switch (flag) {
case Docs:
docs = new DocsStats();
break;
case Store:
store = new StoreStats();
break;
case Indexing:
indexing = new IndexingStats();
break;
case Get:
get = new GetStats();
break;
case Search:
search = new SearchStats();
break;
case Merge:
merge = new MergeStats();
break;
case Refresh:
refresh = new RefreshStats();
break;
case Flush:
flush = new FlushStats();
break;
case Warmer:
warmer = new WarmerStats();
break;
case QueryCache:
queryCache = new QueryCacheStats();
break;
case FieldData:
fieldData = new FieldDataStats();
break;
case Completion:
completion = new CompletionStats();
break;
case Segments:
segments = new SegmentsStats();
break;
case Percolate:
percolate = new PercolateStats();
break;
case Translog:
translog = new TranslogStats();
break;
case Suggest:
suggest = new SuggestStats();
break;
case RequestCache:
requestCache = new RequestCacheStats();
break;
case Recovery:
recoveryStats = new RecoveryStats();
break;
case DL:
dlStats = new DLStats();
break;
case Reindex:
reindexStats = new ReindexStats();
break;
default:
throw new IllegalStateException("Unknown Flag: " + flag);
}
}
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:71,代码来源:CommonStats.java
示例16: readFrom
import org.elasticsearch.index.shard.DocsStats; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
if (in.readBoolean()) {
docs = DocsStats.readDocStats(in);
}
if (in.readBoolean()) {
store = StoreStats.readStoreStats(in);
}
if (in.readBoolean()) {
indexing = IndexingStats.readIndexingStats(in);
}
if (in.readBoolean()) {
get = GetStats.readGetStats(in);
}
if (in.readBoolean()) {
search = SearchStats.readSearchStats(in);
}
if (in.readBoolean()) {
merge = MergeStats.readMergeStats(in);
}
if (in.readBoolean()) {
refresh = RefreshStats.readRefreshStats(in);
}
if (in.readBoolean()) {
flush = FlushStats.readFlushStats(in);
}
if (in.readBoolean()) {
warmer = WarmerStats.readWarmerStats(in);
}
if (in.readBoolean()) {
queryCache = QueryCacheStats.readQueryCacheStats(in);
}
if (in.readBoolean()) {
fieldData = FieldDataStats.readFieldDataStats(in);
}
if (in.readBoolean()) {
percolate = PercolateStats.readPercolateStats(in);
}
if (in.readBoolean()) {
completion = CompletionStats.readCompletionStats(in);
}
if (in.readBoolean()) {
segments = SegmentsStats.readSegmentsStats(in);
}
if (in.readBoolean()) {
dlStats = DLStats.readDLStats(in);
}
if (in.readBoolean()) {
reindexStats = ReindexStats.readReindexStats(in);
}
translog = in.readOptionalStreamable(new TranslogStats());
suggest = in.readOptionalStreamable(new SuggestStats());
requestCache = in.readOptionalStreamable(new RequestCacheStats());
recoveryStats = in.readOptionalStreamable(new RecoveryStats());
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:56,代码来源:CommonStats.java
示例17: ClusterStatsIndices
import org.elasticsearch.index.shard.DocsStats; //导入依赖的package包/类
public ClusterStatsIndices(ClusterStatsNodeResponse[] nodeResponses) {
ObjectObjectHashMap<String, ShardStats> countsPerIndex = new ObjectObjectHashMap<>();
this.docs = new DocsStats();
this.store = new StoreStats();
this.fieldData = new FieldDataStats();
this.queryCache = new QueryCacheStats();
this.completion = new CompletionStats();
this.segments = new SegmentsStats();
this.percolate = new PercolateStats();
for (ClusterStatsNodeResponse r : nodeResponses) {
for (org.elasticsearch.action.admin.indices.stats.ShardStats shardStats : r.shardsStats()) {
ShardStats indexShardStats = countsPerIndex.get(shardStats.getShardRouting().getIndex());
if (indexShardStats == null) {
indexShardStats = new ShardStats();
countsPerIndex.put(shardStats.getShardRouting().getIndex(), indexShardStats);
}
indexShardStats.total++;
CommonStats shardCommonStats = shardStats.getStats();
if (shardStats.getShardRouting().primary()) {
indexShardStats.primaries++;
docs.add(shardCommonStats.docs);
}
store.add(shardCommonStats.store);
fieldData.add(shardCommonStats.fieldData);
queryCache.add(shardCommonStats.queryCache);
completion.add(shardCommonStats.completion);
segments.add(shardCommonStats.segments);
percolate.add(shardCommonStats.percolate);
}
}
shards = new ShardStats();
indexCount = countsPerIndex.size();
for (ObjectObjectCursor<String, ShardStats> indexCountsCursor : countsPerIndex) {
shards.addIndexShardCount(indexCountsCursor.value);
}
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:43,代码来源:ClusterStatsIndices.java
示例18: testGetSearchIndex
import org.elasticsearch.index.shard.DocsStats; //导入依赖的package包/类
@Test
public void testGetSearchIndex()
{
// Create a search index key.
SearchIndexKey searchIndexKey = new SearchIndexKey(SEARCH_INDEX_NAME);
// Create the search index entity.
SearchIndexEntity searchIndexEntity = createTestSearchIndexEntity();
// Mock some of the external call responses.
@SuppressWarnings("unchecked")
DocsStats mockedDocsStats = mock(DocsStats.class);
java.util.Map<String, String> map = new HashMap<>();
map.put(IndexMetaData.SETTING_INDEX_UUID, SEARCH_INDEX_STATISTICS_INDEX_UUID);
map.put(IndexMetaData.SETTING_CREATION_DATE, Long.toString(SEARCH_INDEX_STATISTICS_CREATION_DATE.toGregorianCalendar().getTimeInMillis()));
Settings settings = Settings.builder().put(map).build();
// Mock the external calls.
when(alternateKeyHelper.validateStringParameter("Search index name", SEARCH_INDEX_NAME)).thenReturn(SEARCH_INDEX_NAME);
when(searchIndexDaoHelper.getSearchIndexEntity(searchIndexKey)).thenReturn(searchIndexEntity);
when(indexFunctionsDao.getIndexSettings(SEARCH_INDEX_NAME)).thenReturn(settings);
when(indexFunctionsDao.getIndexStats(SEARCH_INDEX_NAME)).thenReturn(mockedDocsStats);
when(mockedDocsStats.getCount()).thenReturn(SEARCH_INDEX_STATISTICS_NUMBER_OF_ACTIVE_DOCUMENTS);
when(mockedDocsStats.getDeleted()).thenReturn(SEARCH_INDEX_STATISTICS_NUMBER_OF_DELETED_DOCUMENTS);
when(configurationHelper.getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class)).thenReturn("doc");
when(indexFunctionsDao.getNumberOfTypesInIndex(any(), any())).thenReturn(0l);
// Get a search index.
SearchIndex response = searchIndexService.getSearchIndex(searchIndexKey);
// Verify the external calls.
verify(alternateKeyHelper).validateStringParameter("Search index name", SEARCH_INDEX_NAME);
verify(searchIndexDaoHelper).getSearchIndexEntity(searchIndexKey);
verify(mockedDocsStats).getCount();
verify(mockedDocsStats).getDeleted();
verify(indexFunctionsDao).getIndexSettings(SEARCH_INDEX_NAME);
verify(indexFunctionsDao).getIndexStats(SEARCH_INDEX_NAME);
verify(configurationHelper).getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class);
verify(indexFunctionsDao).getNumberOfTypesInIndex(any(), any());
verifyNoMoreInteractions(alternateKeyHelper, businessObjectDefinitionDao, businessObjectDefinitionHelper, configurationDaoHelper, configurationHelper,
indexFunctionsDao, searchIndexDao, searchIndexDaoHelper, searchIndexHelperService, searchIndexStatusDaoHelper, searchIndexTypeDaoHelper);
//response.getSearchIndexStatistics().setIndexCreationDate(SEARCH_INDEX_STATISTICS_CREATION_DATE);
// Validate the returned object.
assertEquals(new SearchIndex(searchIndexKey, SEARCH_INDEX_TYPE_BDEF, SEARCH_INDEX_STATUS, SEARCH_INDEX_DEFAULT_ACTIVE_FLAG,
new SearchIndexStatistics(SEARCH_INDEX_STATISTICS_CREATION_DATE, SEARCH_INDEX_STATISTICS_NUMBER_OF_ACTIVE_DOCUMENTS,
SEARCH_INDEX_STATISTICS_NUMBER_OF_DELETED_DOCUMENTS, SEARCH_INDEX_STATISTICS_INDEX_UUID, 0l), USER_ID, CREATED_ON, UPDATED_ON), response);
}
开发者ID:FINRAOS,项目名称:herd,代码行数:51,代码来源:SearchIndexServiceTest.java
示例19: sendDocsStats
import org.elasticsearch.index.shard.DocsStats; //导入依赖的package包/类
private void sendDocsStats(String name, DocsStats docsStats)
{
sendCount(name, "count", docsStats.getCount());
sendCount(name, "deleted", docsStats.getDeleted());
}
开发者ID:swoop-inc,项目名称:elasticsearch-statsd-plugin,代码行数:6,代码来源:StatsdReporter.java
示例20: sendDocsStats
import org.elasticsearch.index.shard.DocsStats; //导入依赖的package包/类
private void sendDocsStats(String name, DocsStats docsStats) {
sendInt(name, "count", docsStats.getCount());
sendInt(name, "deleted", docsStats.getDeleted());
}
开发者ID:spinscale,项目名称:elasticsearch-graphite-plugin,代码行数:5,代码来源:GraphiteReporter.java
注:本文中的org.elasticsearch.index.shard.DocsStats类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论