本文整理汇总了Java中org.elasticsearch.index.shard.DocsStats类的典型用法代码示例。如果您正苦于以下问题:Java DocsStats类的具体用法?Java DocsStats怎么用?Java DocsStats使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocsStats类属于org.elasticsearch.index.shard包,在下文中一共展示了DocsStats类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例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);
}
示例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());
}
示例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);
}
}
示例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()
);
}
示例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);
}
示例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);
}
示例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;
}
示例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());
}
示例11: getDocs
import org.elasticsearch.index.shard.DocsStats; //导入依赖的package包/类
@Nullable
public DocsStats getDocs() {
return stats.getDocs();
}
示例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());
}
示例13: getDocs
import org.elasticsearch.index.shard.DocsStats; //导入依赖的package包/类
@Nullable
public DocsStats getDocs() {
return this.docs;
}
示例14: getDocs
import org.elasticsearch.index.shard.DocsStats; //导入依赖的package包/类
public DocsStats getDocs() {
return docs;
}
示例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);
}
}
}