Search in sources :

Example 1 with ClusterStatsResponse

use of org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse in project elasticsearch by elastic.

the class ParentFieldLoadingIT method testChangingEagerParentFieldLoadingAtRuntime.

public void testChangingEagerParentFieldLoadingAtRuntime() throws Exception {
    assertAcked(prepareCreate("test").setSettings(indexSettings).addMapping("parent").addMapping("child", "_parent", "type=parent"));
    ensureGreen();
    client().prepareIndex("test", "parent", "1").setSource("{}", XContentType.JSON).get();
    client().prepareIndex("test", "child", "1").setParent("1").setSource("{}", XContentType.JSON).get();
    refresh();
    ClusterStatsResponse response = client().admin().cluster().prepareClusterStats().get();
    assertThat(response.getIndicesStats().getFieldData().getMemorySizeInBytes(), equalTo(0L));
    PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping("test").setType("child").setSource(childMapping(true)).setUpdateAllTypes(true).get();
    assertAcked(putMappingResponse);
    Index test = resolveIndex("test");
    assertBusy(new Runnable() {

        @Override
        public void run() {
            ClusterState clusterState = internalCluster().clusterService().state();
            ShardRouting shardRouting = clusterState.routingTable().index("test").shard(0).getShards().get(0);
            String nodeName = clusterState.getNodes().get(shardRouting.currentNodeId()).getName();
            boolean verified = false;
            IndicesService indicesService = internalCluster().getInstance(IndicesService.class, nodeName);
            IndexService indexService = indicesService.indexService(test);
            if (indexService != null) {
                MapperService mapperService = indexService.mapperService();
                DocumentMapper documentMapper = mapperService.documentMapper("child");
                if (documentMapper != null) {
                    verified = documentMapper.parentFieldMapper().fieldType().eagerGlobalOrdinals();
                }
            }
            assertTrue(verified);
        }
    });
    // Need to add a new doc otherwise the refresh doesn't trigger a new searcher
    // Because it ends up in its own segment, but isn't of type parent or child, this doc doesn't contribute to the size of the fielddata cache
    client().prepareIndex("test", "dummy", "dummy").setSource("{}", XContentType.JSON).get();
    refresh();
    response = client().admin().cluster().prepareClusterStats().get();
    assertThat(response.getIndicesStats().getFieldData().getMemorySizeInBytes(), greaterThan(0L));
}
Also used : ClusterState(org.elasticsearch.cluster.ClusterState) IndexService(org.elasticsearch.index.IndexService) DocumentMapper(org.elasticsearch.index.mapper.DocumentMapper) IndicesService(org.elasticsearch.indices.IndicesService) Index(org.elasticsearch.index.Index) ClusterStatsResponse(org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse) PutMappingResponse(org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse) ShardRouting(org.elasticsearch.cluster.routing.ShardRouting) MapperService(org.elasticsearch.index.mapper.MapperService)

Example 2 with ClusterStatsResponse

use of org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse in project elasticsearch by elastic.

the class FieldDataLoadingIT method testEagerGlobalOrdinalsFieldDataLoading.

public void testEagerGlobalOrdinalsFieldDataLoading() throws Exception {
    assertAcked(prepareCreate("test").addMapping("type", jsonBuilder().startObject().startObject("type").startObject("properties").startObject("name").field("type", "text").field("fielddata", true).field("eager_global_ordinals", true).endObject().endObject().endObject().endObject()));
    ensureGreen();
    client().prepareIndex("test", "type", "1").setSource("name", "name").get();
    client().admin().indices().prepareRefresh("test").get();
    ClusterStatsResponse response = client().admin().cluster().prepareClusterStats().get();
    assertThat(response.getIndicesStats().getFieldData().getMemorySizeInBytes(), greaterThan(0L));
}
Also used : ClusterStatsResponse(org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse)

Example 3 with ClusterStatsResponse

use of org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse in project graylog2-server by Graylog2.

the class ElasticsearchProbe method elasticsearchStats.

public ElasticsearchStats elasticsearchStats() {
    final ClusterAdminClient adminClient = client.admin().cluster();
    final ClusterStatsResponse clusterStatsResponse = adminClient.clusterStats(new ClusterStatsRequest()).actionGet();
    final String clusterName = clusterStatsResponse.getClusterNameAsString();
    final ClusterStatsNodes clusterNodesStats = clusterStatsResponse.getNodesStats();
    final NodesStats nodesStats = NodesStats.create(clusterNodesStats.getCounts().getTotal(), clusterNodesStats.getCounts().getMasterOnly(), clusterNodesStats.getCounts().getDataOnly(), clusterNodesStats.getCounts().getMasterData(), clusterNodesStats.getCounts().getClient());
    final IndicesStats indicesStats = IndicesStats.create(clusterStatsResponse.getIndicesStats().getIndexCount(), clusterStatsResponse.getIndicesStats().getStore().sizeInBytes(), clusterStatsResponse.getIndicesStats().getFieldData().getMemorySizeInBytes());
    final PendingClusterTasksResponse pendingClusterTasksResponse = adminClient.pendingClusterTasks(new PendingClusterTasksRequest()).actionGet();
    final int pendingTasksSize = pendingClusterTasksResponse.pendingTasks().size();
    final List<Long> pendingTasksTimeInQueue = Lists.newArrayListWithCapacity(pendingTasksSize);
    for (PendingClusterTask pendingClusterTask : pendingClusterTasksResponse) {
        pendingTasksTimeInQueue.add(pendingClusterTask.getTimeInQueueInMillis());
    }
    final ClusterHealthResponse clusterHealthResponse = adminClient.health(new ClusterHealthRequest(indexSetRegistry.getIndexWildcards())).actionGet();
    final ClusterHealth clusterHealth = ClusterHealth.create(clusterHealthResponse.getNumberOfNodes(), clusterHealthResponse.getNumberOfDataNodes(), clusterHealthResponse.getActiveShards(), clusterHealthResponse.getRelocatingShards(), clusterHealthResponse.getActivePrimaryShards(), clusterHealthResponse.getInitializingShards(), clusterHealthResponse.getUnassignedShards(), clusterHealthResponse.isTimedOut(), pendingTasksSize, pendingTasksTimeInQueue);
    return ElasticsearchStats.create(clusterName, clusterHealthResponse.getStatus(), clusterHealth, nodesStats, indicesStats);
}
Also used : ClusterHealthResponse(org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse) ClusterAdminClient(org.elasticsearch.client.ClusterAdminClient) ClusterHealthRequest(org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest) ClusterStatsNodes(org.elasticsearch.action.admin.cluster.stats.ClusterStatsNodes) PendingClusterTask(org.elasticsearch.cluster.service.PendingClusterTask) PendingClusterTasksResponse(org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksResponse) ClusterStatsRequest(org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequest) PendingClusterTasksRequest(org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksRequest) ClusterStatsResponse(org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse)

Example 4 with ClusterStatsResponse

use of org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse in project elasticsearch by elastic.

the class SimpleNestedIT method testCheckFixedBitSetCache.

public void testCheckFixedBitSetCache() throws Exception {
    boolean loadFixedBitSeLazily = randomBoolean();
    Settings.Builder settingsBuilder = Settings.builder().put(indexSettings()).put("index.refresh_interval", -1);
    if (loadFixedBitSeLazily) {
        settingsBuilder.put("index.load_fixed_bitset_filters_eagerly", false);
    }
    assertAcked(prepareCreate("test").setSettings(settingsBuilder).addMapping("type"));
    client().prepareIndex("test", "type", "0").setSource("field", "value").get();
    client().prepareIndex("test", "type", "1").setSource("field", "value").get();
    refresh();
    ensureSearchable("test");
    // No nested mapping yet, there shouldn't be anything in the fixed bit set cache
    ClusterStatsResponse clusterStatsResponse = client().admin().cluster().prepareClusterStats().get();
    assertThat(clusterStatsResponse.getIndicesStats().getSegments().getBitsetMemoryInBytes(), equalTo(0L));
    // Now add nested mapping
    assertAcked(client().admin().indices().preparePutMapping("test").setType("type").setSource("array1", "type=nested"));
    XContentBuilder builder = jsonBuilder().startObject().startArray("array1").startObject().field("field1", "value1").endObject().endArray().endObject();
    // index simple data
    client().prepareIndex("test", "type", "2").setSource(builder).get();
    client().prepareIndex("test", "type", "3").setSource(builder).get();
    client().prepareIndex("test", "type", "4").setSource(builder).get();
    client().prepareIndex("test", "type", "5").setSource(builder).get();
    client().prepareIndex("test", "type", "6").setSource(builder).get();
    refresh();
    ensureSearchable("test");
    if (loadFixedBitSeLazily) {
        clusterStatsResponse = client().admin().cluster().prepareClusterStats().get();
        assertThat(clusterStatsResponse.getIndicesStats().getSegments().getBitsetMemoryInBytes(), equalTo(0L));
        // only when querying with nested the fixed bitsets are loaded
        SearchResponse searchResponse = client().prepareSearch("test").setQuery(nestedQuery("array1", termQuery("array1.field1", "value1"), ScoreMode.Avg)).get();
        assertNoFailures(searchResponse);
        assertThat(searchResponse.getHits().getTotalHits(), equalTo(5L));
    }
    clusterStatsResponse = client().admin().cluster().prepareClusterStats().get();
    assertThat(clusterStatsResponse.getIndicesStats().getSegments().getBitsetMemoryInBytes(), greaterThan(0L));
    assertAcked(client().admin().indices().prepareDelete("test"));
    clusterStatsResponse = client().admin().cluster().prepareClusterStats().get();
    assertThat(clusterStatsResponse.getIndicesStats().getSegments().getBitsetMemoryInBytes(), equalTo(0L));
}
Also used : ClusterStatsResponse(org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse) Settings(org.elasticsearch.common.settings.Settings) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) SearchResponse(org.elasticsearch.action.search.SearchResponse)

Example 5 with ClusterStatsResponse

use of org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse in project elasticsearch by elastic.

the class ParentFieldLoadingIT method testEagerParentFieldLoading.

public void testEagerParentFieldLoading() throws Exception {
    logger.info("testing lazy loading...");
    assertAcked(prepareCreate("test").setSettings(indexSettings).addMapping("parent").addMapping("child", childMapping(false)));
    ensureGreen();
    client().prepareIndex("test", "parent", "1").setSource("{}", XContentType.JSON).get();
    client().prepareIndex("test", "child", "1").setParent("1").setSource("{}", XContentType.JSON).get();
    refresh();
    ClusterStatsResponse response = client().admin().cluster().prepareClusterStats().get();
    assertThat(response.getIndicesStats().getFieldData().getMemorySizeInBytes(), equalTo(0L));
    logger.info("testing default loading...");
    assertAcked(client().admin().indices().prepareDelete("test").get());
    assertAcked(prepareCreate("test").setSettings(indexSettings).addMapping("parent").addMapping("child", "_parent", "type=parent"));
    ensureGreen();
    client().prepareIndex("test", "parent", "1").setSource("{}", XContentType.JSON).get();
    client().prepareIndex("test", "child", "1").setParent("1").setSource("{}", XContentType.JSON).get();
    refresh();
    response = client().admin().cluster().prepareClusterStats().get();
    assertThat(response.getIndicesStats().getFieldData().getMemorySizeInBytes(), equalTo(0L));
    logger.info("testing eager global ordinals loading...");
    assertAcked(client().admin().indices().prepareDelete("test").get());
    assertAcked(prepareCreate("test").setSettings(indexSettings).addMapping("parent").addMapping("child", childMapping(true)));
    ensureGreen();
    // Need to do 2 separate refreshes, otherwise we have 1 segment and then we can't measure if global ordinals
    // is loaded by the size of the field data cache, because global ordinals on 1 segment shards takes no extra memory.
    client().prepareIndex("test", "parent", "1").setSource("{}", XContentType.JSON).get();
    refresh();
    client().prepareIndex("test", "child", "1").setParent("1").setSource("{}", XContentType.JSON).get();
    refresh();
    response = client().admin().cluster().prepareClusterStats().get();
    assertThat(response.getIndicesStats().getFieldData().getMemorySizeInBytes(), greaterThan(0L));
}
Also used : ClusterStatsResponse(org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse)

Aggregations

ClusterStatsResponse (org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse)5 ClusterHealthRequest (org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest)1 ClusterHealthResponse (org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse)1 ClusterStatsNodes (org.elasticsearch.action.admin.cluster.stats.ClusterStatsNodes)1 ClusterStatsRequest (org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequest)1 PendingClusterTasksRequest (org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksRequest)1 PendingClusterTasksResponse (org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksResponse)1 PutMappingResponse (org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse)1 SearchResponse (org.elasticsearch.action.search.SearchResponse)1 ClusterAdminClient (org.elasticsearch.client.ClusterAdminClient)1 ClusterState (org.elasticsearch.cluster.ClusterState)1 ShardRouting (org.elasticsearch.cluster.routing.ShardRouting)1 PendingClusterTask (org.elasticsearch.cluster.service.PendingClusterTask)1 Settings (org.elasticsearch.common.settings.Settings)1 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)1 Index (org.elasticsearch.index.Index)1 IndexService (org.elasticsearch.index.IndexService)1 DocumentMapper (org.elasticsearch.index.mapper.DocumentMapper)1 MapperService (org.elasticsearch.index.mapper.MapperService)1 IndicesService (org.elasticsearch.indices.IndicesService)1