Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

Rest Layer and Async Search Cleanup Management #9

Merged
merged 33 commits into from
Dec 23, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9c921d2
rest actions
eirsep Dec 14, 2020
591d8ad
stats api. async search clean up.
eirsep Dec 14, 2020
28d39b7
register transport action and rest handler for stats.
eirsep Dec 14, 2020
93ecef5
wire async search stats listener to active context
eirsep Dec 14, 2020
959439a
status field in async search response. async search cleanup refactor
eirsep Dec 15, 2020
1bbf255
state field in async search response. submit async search rest tests
eirsep Dec 16, 2020
9fc6a89
submit async search rest tests. added wait for completion timeout max…
eirsep Dec 17, 2020
0678622
Merge branch 'master' of github.com:opendistro-for-elasticsearch/asyn…
eirsep Dec 17, 2020
c830645
validate keep alive change
eirsep Dec 17, 2020
7cbcbf8
more submit api tests
eirsep Dec 17, 2020
97d65c4
api param validation tests.
eirsep Dec 17, 2020
ceecbac
Merge branch 'rest-layer' of github.com:opendistro-for-elasticsearch/…
eirsep Dec 17, 2020
903b107
Management layer changes
Bukhtawar Dec 17, 2020
85fed8f
async search request routing tests
eirsep Dec 18, 2020
6f24bf0
async search settings tests and added more api tests
eirsep Dec 18, 2020
a62f6cb
Merge branch 'rest-layer' of github.com:opendistro-for-elasticsearch/…
eirsep Dec 18, 2020
c7b2df1
Management layer IT
Bukhtawar Dec 19, 2020
d072d6d
Disabling transport clients for test
Bukhtawar Dec 19, 2020
fa5cd67
fix failing tests
eirsep Dec 19, 2020
bc64fc3
Management layers tests
Bukhtawar Dec 20, 2020
3350aa8
Minor fixups around permits and timeouts
Bukhtawar Dec 20, 2020
d504524
Update expiration strengthen tests
Bukhtawar Dec 20, 2020
c164993
async search stats multi nodes tests.
eirsep Dec 21, 2020
b71e57f
Merge branch 'rest-layer' of github.com:opendistro-for-elasticsearch/…
eirsep Dec 21, 2020
362ab77
async search throttling count stats
eirsep Dec 21, 2020
99aacde
Management layer changes for PR feedback
Bukhtawar Dec 21, 2020
cfac793
request routing tests. coordinator node drop scenarios
eirsep Dec 21, 2020
30c3a66
Merge branch 'rest-layer' of github.com:opendistro-for-elasticsearch/…
eirsep Dec 21, 2020
34865ca
Async search post processor tests
Bukhtawar Dec 22, 2020
0878892
onContextPersistFailed stat. onRunningContextClosed hook to decremen…
eirsep Dec 23, 2020
8173ba0
remove persisting to closed transition. catch IOException instead of …
eirsep Dec 23, 2020
150ad90
equals method fix in async search response
eirsep Dec 23, 2020
f90d6be
revert removing PERSISTING->CLOSED transition.
eirsep Dec 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class AsyncSearchActiveStore {
private static Logger logger = LogManager.getLogger(AsyncSearchActiveStore.class);
private volatile int maxRunningContext;
public static final Setting<Integer> MAX_RUNNING_CONTEXT = Setting.intSetting(
"async_search.max_running_context", 100, 10, Setting.Property.Dynamic, Setting.Property.NodeScope);
"async_search.max_running_context", 100, 0, Setting.Property.Dynamic, Setting.Property.NodeScope);

private final ConcurrentMapLong<AsyncSearchActiveContext> activeContexts = newConcurrentMapLongWithAggressiveConcurrency();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,11 @@ default void onContextRunning(AsyncSearchContextId contextId) {
default void onContextRejected(AsyncSearchContextId contextId) {

}

/**
* @param contextId Executed when a running async search context is closed and has bypassed succeeded/failed state
*/
default void onRunningContextClosed(AsyncSearchContextId contextId) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,11 @@ private AsyncSearchStateMachine initStateMachine() {
(s, e) -> asyncSearchActiveStore.freeContext(e.asyncSearchContext().getContextId()),
(contextId, listener) -> listener.onContextPersistFailed(contextId), SearchResponsePersistFailedEvent.class));

for (AsyncSearchState state : EnumSet.of(PERSISTING, PERSISTED, PERSIST_FAILED, SUCCEEDED, FAILED, INIT, RUNNING)) {
stateMachine.registerTransition(new AsyncSearchTransition<>(RUNNING, CLOSED,
(s, e) -> asyncSearchActiveStore.freeContext(e.asyncSearchContext().getContextId()),
(contextId, listener) -> listener.onRunningContextClosed(contextId), SearchClosedEvent.class));

for (AsyncSearchState state : EnumSet.of(PERSISTING, PERSISTED, PERSIST_FAILED, SUCCEEDED, FAILED, INIT)) {
eirsep marked this conversation as resolved.
Show resolved Hide resolved
stateMachine.registerTransition(new AsyncSearchTransition<>(state, CLOSED,
(s, e) -> asyncSearchActiveStore.freeContext(e.asyncSearchContext().getContextId()),
(contextId, listener) -> listener.onContextClosed(contextId), SearchClosedEvent.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ public class AsyncSearchCountStats implements Writeable, ToXContentFragment {

private final long runningCount;
private final long persistedCount;
private final long persistFailedCount;
private final long completedCount;
private final long failedCount;
private final long throttledCount;

public AsyncSearchCountStats(long runningCount, long persistedCount,
long completedCount, long failedCount, long throttledCount) {
public AsyncSearchCountStats(long runningCount, long persistedCount, long completedCount, long failedCount, long throttledCount,
long persistFailedCount) {
this.runningCount = runningCount;
this.persistedCount = persistedCount;
this.persistFailedCount = persistFailedCount;
this.completedCount = completedCount;
this.failedCount = failedCount;
this.throttledCount = throttledCount;
Expand All @@ -49,6 +51,7 @@ public AsyncSearchCountStats(StreamInput in) throws IOException {
this.completedCount = in.readVLong();
this.failedCount = in.readVLong();
this.throttledCount = in.readVLong();
this.persistFailedCount = in.readVLong();
}

@Override
Expand All @@ -58,27 +61,30 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeVLong(this.completedCount);
out.writeVLong(this.failedCount);
out.writeVLong(this.throttledCount);
out.writeVLong(this.persistFailedCount);
}

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(Fields.ASYNC_SEARCH_STATUS);
builder.startObject(Fields.ASYNC_SEARCH_STATS);
builder.field(Fields.RUNNING, runningCount);
builder.field(Fields.PERSISTED, persistedCount);
builder.field(Fields.FAILED, failedCount);
builder.field(Fields.COMPLETED, completedCount);
builder.field(Fields.REJECTED, throttledCount);
builder.field(Fields.PERSIST_FAILED, persistFailedCount);
builder.endObject();
return builder;
}

static final class Fields {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have such long field names?Won't you have a section for async search and then add status, current directly there. Asking because long fields may take longer for serialization and deserialization depending on algo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trimming asynchronous_search_ prefix from individual stats

private static final String ASYNC_SEARCH_STATUS = "async_search_stats";
private static final String RUNNING = "async_search_running_current";
private static final String PERSISTED = "async_search_persisted";
private static final String FAILED = "async_search_failed";
private static final String COMPLETED = "async_search_completed";
private static final String REJECTED = "async_search_rejected";
private static final String ASYNC_SEARCH_STATS = "asynchronous_search_stats";
private static final String RUNNING = "running_current";
private static final String PERSISTED = "persisted";
private static final String PERSIST_FAILED = "persist_failed";
private static final String FAILED = "failed";
private static final String COMPLETED = "completed";
private static final String REJECTED = "rejected";
}

public long getRunningCount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public void onContextPersisted(AsyncSearchContextId asyncSearchContextId) {
countStatsHolder.persistedAsyncSearchCount.inc();
}

@Override
public void onContextPersistFailed(AsyncSearchContextId contextId) {
countStatsHolder.persistFailedAsyncSearchCount.inc();
}

@Override
public void onContextRunning(AsyncSearchContextId context) {
countStatsHolder.runningAsyncSearchCount.inc();
Expand All @@ -45,6 +50,11 @@ public void onContextRejected(AsyncSearchContextId contextId) {
countStatsHolder.rejectedAsyncSearchCount.inc();
}

@Override
public void onRunningContextClosed(AsyncSearchContextId contextId) {
countStatsHolder.runningAsyncSearchCount.dec();
}

@Override
public void onContextCompleted(AsyncSearchContextId context) {
countStatsHolder.completedAsyncSearchCount.inc();
Expand All @@ -58,13 +68,15 @@ public AsyncSearchStats stats(DiscoveryNode node) {
static final class CountStatsHolder {
final CounterMetric runningAsyncSearchCount = new CounterMetric();
final CounterMetric persistedAsyncSearchCount = new CounterMetric();
final CounterMetric persistFailedAsyncSearchCount = new CounterMetric();
final CounterMetric failedAsyncSearchCount = new CounterMetric();
final CounterMetric completedAsyncSearchCount = new CounterMetric();
final CounterMetric rejectedAsyncSearchCount = new CounterMetric();

public AsyncSearchCountStats countStats() {
return new AsyncSearchCountStats(runningAsyncSearchCount.count(), persistedAsyncSearchCount.count(),
completedAsyncSearchCount.count(), failedAsyncSearchCount.count(), rejectedAsyncSearchCount.count());
completedAsyncSearchCount.count(), failedAsyncSearchCount.count(), rejectedAsyncSearchCount.count(),
persistFailedAsyncSearchCount.count());
}
}
}