-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Qsb framework changes #13007
Closed
kaushalmahi12
wants to merge
4
commits into
opensearch-project:main
from
kaushalmahi12:qsb-framework-changes
Closed
Qsb framework changes #13007
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
This file contains 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 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 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 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 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 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 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
23 changes: 23 additions & 0 deletions
23
server/src/main/java/org/opensearch/search/sandbox/Persistable.java
This file contains 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 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.search.sandbox; | ||
|
||
import org.opensearch.core.action.ActionListener; | ||
import org.opensearch.core.action.ActionResponse; | ||
|
||
/** | ||
* This interface defines the key APIs for implementing Sandbox persistence | ||
*/ | ||
public interface Persistable { | ||
/** | ||
* persists the @link Sandbox in a durable storage | ||
* @param sandbox | ||
*/ | ||
<U extends ActionResponse> void persist(Object sandbox, ActionListener<U> listener); | ||
} |
70 changes: 70 additions & 0 deletions
70
server/src/main/java/org/opensearch/search/sandbox/QuerySandboxService.java
This file contains 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,70 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.search.sandbox; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.opensearch.common.lifecycle.AbstractLifecycleComponent; | ||
import org.opensearch.threadpool.Scheduler; | ||
import org.opensearch.threadpool.ThreadPool; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Main service which will run periodically to track and cancel resource constraint violating tasks in sandboxes | ||
*/ | ||
public class QuerySandboxService extends AbstractLifecycleComponent { | ||
private static final Logger logger = LogManager.getLogger(QuerySandboxService.class); | ||
|
||
private final SandboxedRequestTrackerService requestTrackerService; | ||
private volatile Scheduler.Cancellable scheduledFuture; | ||
private final QuerySandboxServiceSettings sandboxServiceSettings; | ||
private final ThreadPool threadPool; | ||
|
||
public QuerySandboxService( | ||
SandboxedRequestTrackerService requestTrackerService, | ||
QuerySandboxServiceSettings sandboxServiceSettings, | ||
ThreadPool threadPool | ||
) { | ||
this.requestTrackerService = requestTrackerService; | ||
this.sandboxServiceSettings = sandboxServiceSettings; | ||
this.threadPool = threadPool; | ||
} | ||
|
||
private void doRun() { | ||
requestTrackerService.updateSandboxResourceUsages(); | ||
requestTrackerService.cancelViolatingTasks(); | ||
requestTrackerService.pruneSandboxes(); | ||
} | ||
|
||
@Override | ||
protected void doStart() { | ||
scheduledFuture = threadPool.scheduleWithFixedDelay(() -> { | ||
try { | ||
doRun(); | ||
} catch (Exception e) { | ||
logger.debug("Exception occurred in Query Sandbox service", e); | ||
} | ||
}, sandboxServiceSettings.getRunIntervalMillis(), ThreadPool.Names.GENERIC); | ||
} | ||
|
||
@Override | ||
protected void doStop() { | ||
if (scheduledFuture != null) { | ||
scheduledFuture.cancel(); | ||
} | ||
} | ||
|
||
@Override | ||
protected void doClose() throws IOException {} | ||
|
||
public SandboxStatsHolder stats() { | ||
return requestTrackerService.getSandboxLevelStats(); | ||
} | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By making the SanboxableTask an interface like this it would imply there are numerous tasks which may eventually support sandboxing (or whatever it ends up being called); do you have some other ideas around what this may look like?
I think that may help with defining the interface more accurately. Personally, I had thought it was only for search so I could have been misunderstanding things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were thinking that this feature can supersede the AdmissionControl and SearchBackpressure, We can extend this idea to indexing traffic as well.