Skip to content
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

Update command-manager to sort documents by delivery timeout #169

Merged
merged 5 commits into from
Dec 9, 2024
Merged
Changes from all commits
Commits
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 @@ -44,6 +44,7 @@

import com.wazuh.commandmanager.CommandManagerPlugin;
import com.wazuh.commandmanager.model.Command;
import com.wazuh.commandmanager.model.Document;
import com.wazuh.commandmanager.model.Status;
import com.wazuh.commandmanager.settings.PluginSettings;
import com.wazuh.commandmanager.utils.httpclient.AuthHttpRestClient;
Expand All @@ -58,6 +59,7 @@ public class SearchThread implements Runnable {
public static final String COMMAND_ORDER_ID_FIELD =
Command.COMMAND + "." + Command.ORDER_ID;
public static final String COMMAND_TIMEOUT_FIELD = Command.COMMAND + "." + Command.TIMEOUT;
public static final String DELIVERY_TIMESTAMP_FIELD = Document.DELIVERY_TIMESTAMP;
private static final Logger log = LogManager.getLogger(SearchThread.class);
public static final String ORDERS_OBJECT = "/orders";
private final SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
Expand Down Expand Up @@ -207,9 +209,7 @@ public SearchResponse pitQuery(PointInTimeBuilder pointInTimeBuilder, Object[] s
.timeout(timeout)
.pointInTimeBuilder(pointInTimeBuilder);
if (this.searchSourceBuilder.sorts() == null) {
this.searchSourceBuilder
.sort(SearchThread.COMMAND_ORDER_ID_FIELD, SortOrder.ASC)
.sort(SearchThread.COMMAND_TIMEOUT_FIELD, SortOrder.ASC);
this.searchSourceBuilder.sort(SearchThread.DELIVERY_TIMESTAMP_FIELD, SortOrder.ASC);
}
if (searchAfter.length > 0) {
this.searchSourceBuilder.searchAfter(searchAfter);
Expand Down