-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Add REST API for cache directory stats #51815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tlrx
merged 14 commits into
elastic:feature/searchable-snapshots
from
tlrx:add-instrumentation-step-2
Feb 6, 2020
Merged
Changes from 2 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
690a9b4
Add REST API for cache directory stats
tlrx 2dfb3fd
Fix typos
tlrx 88d5c2e
TransportBroadcastByNodeAction
tlrx fe84072
Remove unnecessary dependency
tlrx b934e0e
Merge branch 'feature/searchable-snapshots' into add-instrumentation-…
tlrx 1167ff7
Renaming
tlrx b1d7973
handle negative longs in tests + random seeking threshold
tlrx a4f92bd
unknown
tlrx f2ea47f
replicas to 0 and rename index to docs
tlrx dda6ab7
Collections.unmodifiableMap(stats);
tlrx fde0a86
Document // NORELEASE
tlrx c9468d1
RNFE
tlrx d1049a3
RNFE bis
tlrx c81bcde
Merge branch 'feature/searchable-snapshots' into add-instrumentation-…
elasticmachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
475 changes: 475 additions & 0 deletions
475
...c/main/java/org/elasticsearch/xpack/core/searchablesnapshots/SearchableSnapshotStats.java
Large diffs are not rendered by default.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
...t/java/org/elasticsearch/xpack/core/searchablesnapshots/SearchableSnapshotStatsTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
package org.elasticsearch.xpack.core.searchablesnapshots; | ||
|
||
import org.elasticsearch.common.io.stream.Writeable; | ||
import org.elasticsearch.index.shard.ShardId; | ||
import org.elasticsearch.repositories.IndexId; | ||
import org.elasticsearch.snapshots.SnapshotId; | ||
import org.elasticsearch.test.AbstractWireSerializingTestCase; | ||
import org.elasticsearch.xpack.core.searchablesnapshots.SearchableSnapshotStats.CacheDirectoryStats; | ||
import org.elasticsearch.xpack.core.searchablesnapshots.SearchableSnapshotStats.CacheIndexInputStats; | ||
import org.elasticsearch.xpack.core.searchablesnapshots.SearchableSnapshotStats.Counter; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class SearchableSnapshotStatsTests extends AbstractWireSerializingTestCase<SearchableSnapshotStats> { | ||
|
||
@Override | ||
protected Writeable.Reader<SearchableSnapshotStats> instanceReader() { | ||
return SearchableSnapshotStats::new; | ||
} | ||
|
||
@Override | ||
protected SearchableSnapshotStats createTestInstance() { | ||
final List<CacheDirectoryStats> directoryStats = new ArrayList<>(); | ||
for (int i = 0; i < randomInt(20); i++) { | ||
directoryStats.add(randomCacheDirectoryStats()); | ||
} | ||
return new SearchableSnapshotStats(directoryStats); | ||
} | ||
|
||
private CacheDirectoryStats randomCacheDirectoryStats() { | ||
SnapshotId snapshotId = new SnapshotId(randomAlphaOfLength(5), randomAlphaOfLength(5)); | ||
IndexId indexId = new IndexId(randomAlphaOfLength(5), randomAlphaOfLength(5)); | ||
ShardId shardId = new ShardId(randomAlphaOfLength(5), randomAlphaOfLength(5), randomInt(10)); | ||
|
||
final List<CacheIndexInputStats> inputStats = new ArrayList<>(); | ||
for (int j = 0; j < randomInt(20); j++) { | ||
inputStats.add(randomCacheIndexInputStats()); | ||
} | ||
return new CacheDirectoryStats(snapshotId, indexId, shardId, inputStats); | ||
} | ||
|
||
private CacheIndexInputStats randomCacheIndexInputStats() { | ||
return new CacheIndexInputStats(randomAlphaOfLength(10), randomNonNegativeLong(), | ||
randomNonNegativeLong(), randomNonNegativeLong(), randomNonNegativeLong(), | ||
randomCounter(), randomCounter(), | ||
randomCounter(), randomCounter(), | ||
randomCounter(), randomCounter(), | ||
randomCounter(), randomCounter(), | ||
randomCounter()); | ||
} | ||
|
||
private Counter randomCounter() { | ||
return new Counter(randomNonNegativeLong(), randomNonNegativeLong(), randomNonNegativeLong(), randomNonNegativeLong()); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import org.elasticsearch.gradle.test.RestIntegTestTask | ||
|
||
apply plugin: 'elasticsearch.build' | ||
test.enabled = false | ||
|
||
dependencies { | ||
compile project(':test:framework') | ||
} | ||
|
||
subprojects { | ||
project.tasks.withType(RestIntegTestTask) { | ||
final File xPackResources = new File(xpackProject('plugin:searchable-snapshots').projectDir, 'src/test/resources') | ||
project.copyRestSpec.from(xPackResources) { | ||
include 'rest-api-spec/api/**' | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apply plugin: 'elasticsearch.testclusters' | ||
apply plugin: 'elasticsearch.standalone-rest-test' | ||
apply plugin: 'elasticsearch.rest-test' | ||
|
||
dependencies { | ||
testCompile project(path: xpackModule('searchable-snapshots'), configuration: 'runtime') | ||
} | ||
|
||
testClusters.integTest { | ||
testDistribution = 'DEFAULT' | ||
setting 'xpack.license.self_generated.type', 'basic' | ||
} |
23 changes: 23 additions & 0 deletions
23
...test/java/org/elasticsearch/xpack/searchablesnapshots/rest/SearchableSnapshotsRestIT.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.searchablesnapshots.rest; | ||
|
||
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; | ||
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; | ||
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; | ||
|
||
public class SearchableSnapshotsRestIT extends ESClientYamlSuiteTestCase { | ||
|
||
public SearchableSnapshotsRestIT(final ClientYamlTestCandidate testCandidate) { | ||
super(testCandidate); | ||
} | ||
|
||
@ParametersFactory | ||
public static Iterable<Object[]> parameters() throws Exception { | ||
return ESClientYamlSuiteTestCase.createParameters(); | ||
} | ||
} |
149 changes: 149 additions & 0 deletions
149
x-pack/plugin/searchable-snapshots/qa/rest/src/test/resources/rest-api-spec/test/stats.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
--- | ||
setup: | ||
|
||
- do: | ||
indices.create: | ||
index: index | ||
body: | ||
settings: | ||
number_of_shards: 1 | ||
|
||
- do: | ||
bulk: | ||
body: | ||
- index: | ||
_index: index | ||
- field: foo | ||
- index: | ||
_index: index | ||
- field: bar | ||
- index: | ||
_index: index | ||
- field: baz | ||
|
||
- do: | ||
snapshot.create_repository: | ||
repository: repository-fs | ||
body: | ||
type: fs | ||
settings: | ||
location: "repository-fs" | ||
|
||
- do: | ||
snapshot.create: | ||
repository: repository-fs | ||
snapshot: snapshot | ||
wait_for_completion: true | ||
|
||
- do: | ||
snapshot.delete_repository: | ||
repository: repository-fs | ||
|
||
- do: | ||
indices.delete: | ||
index: index | ||
|
||
--- | ||
"Tests searchable snapshots stats": | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: searchable snapshots introduced in 8.0 | ||
|
||
- do: | ||
searchable_snapshots.stats: {} | ||
|
||
- length: { nodes: 0 } | ||
|
||
- do: | ||
snapshot.create_repository: | ||
repository: repository-searchable-snapshots | ||
body: | ||
type: searchable | ||
settings: | ||
delegate_type: fs | ||
location: "repository-fs" | ||
|
||
- match: { acknowledged: true } | ||
|
||
- do: | ||
snapshot.restore: | ||
repository: repository-searchable-snapshots | ||
snapshot: snapshot | ||
wait_for_completion: true | ||
|
||
- match: { snapshot.snapshot: snapshot } | ||
- match: { snapshot.shards.failed: 0 } | ||
- match: { snapshot.shards.successful: 1 } | ||
|
||
- do: | ||
search: | ||
rest_total_hits_as_int: true | ||
index: index | ||
body: | ||
query: | ||
match_all: {} | ||
|
||
- match: { hits.total: 3 } | ||
|
||
- do: | ||
nodes.info: {} | ||
- set: | ||
nodes._arbitrary_key_: node_id | ||
|
||
- do: | ||
searchable_snapshots.stats: {} | ||
|
||
- length: { nodes: 1 } | ||
- length: { nodes.$node_id.indices.index.shards: 1 } | ||
- is_true: nodes.$node_id.indices.index.shards.0.snapshot_uuid | ||
- is_true: nodes.$node_id.indices.index.shards.0.index_uuid | ||
- match: { nodes.$node_id.indices.index.shards.0.shard: 0 } | ||
|
||
- is_true: nodes.$node_id.indices.index.shards.0.files.0.name | ||
- gt: { nodes.$node_id.indices.index.shards.0.files.0.length: 0 } | ||
- gt: { nodes.$node_id.indices.index.shards.0.files.0.open_count: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.inner_count: 0 } | ||
- gt: { nodes.$node_id.indices.index.shards.0.files.0.close_count: 0 } | ||
|
||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.contiguous_bytes_read.count: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.contiguous_bytes_read.sum: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.contiguous_bytes_read.min: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.contiguous_bytes_read.max: 0 } | ||
|
||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.non_contiguous_bytes_read.count: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.non_contiguous_bytes_read.sum: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.non_contiguous_bytes_read.min: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.non_contiguous_bytes_read.max: 0 } | ||
|
||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.cached_bytes_read.count: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.cached_bytes_read.sum: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.cached_bytes_read.min: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.cached_bytes_read.max: 0 } | ||
|
||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.cached_bytes_written.count: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.cached_bytes_written.sum: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.cached_bytes_written.min: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.cached_bytes_written.max: 0 } | ||
|
||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.direct_bytes_read.count: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.direct_bytes_read.sum: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.direct_bytes_read.min: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.direct_bytes_read.max: 0 } | ||
|
||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.forward_seeks.small.count: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.forward_seeks.small.sum: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.forward_seeks.small.min: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.forward_seeks.small.max: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.forward_seeks.large.count: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.forward_seeks.large.sum: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.forward_seeks.large.min: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.forward_seeks.large.max: 0 } | ||
|
||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.backward_seeks.small.count: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.backward_seeks.small.sum: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.backward_seeks.small.min: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.backward_seeks.small.max: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.backward_seeks.large.count: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.backward_seeks.large.sum: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.backward_seeks.large.min: 0 } | ||
- gte: { nodes.$node_id.indices.index.shards.0.files.0.backward_seeks.large.max: 0 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...va/org/elasticsearch/xpack/searchablesnapshots/action/SearchableSnapshotsStatsAction.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
package org.elasticsearch.xpack.searchablesnapshots.action; | ||
|
||
import org.elasticsearch.action.ActionType; | ||
|
||
public class SearchableSnapshotsStatsAction extends ActionType<SearchableSnapshotsStatsResponse> { | ||
|
||
public static final SearchableSnapshotsStatsAction INSTANCE = new SearchableSnapshotsStatsAction(); | ||
static final String NAME = "cluster:monitor/xpack/searchable_snapshots/stats"; | ||
|
||
private SearchableSnapshotsStatsAction() { | ||
super(NAME, SearchableSnapshotsStatsResponse::new); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.