Skip to content

Commit

Permalink
fix(rest-api): search all commands except with the DATA_TO_INDEX tag
Browse files Browse the repository at this point in the history
- the ScheduledCommandsRefresherService manages all commands except with the DATA_TO_INDEX tag
- the ScheduledSearchIndexerService manages commands with the DATA_TO_INDEX tag only

They can't compete with each other, otherwise it makes their execution random.

https://gravitee.atlassian.net/browse/APIM-3614
  • Loading branch information
ThibaudAV committed Mar 7, 2024
1 parent 11c6ca5 commit a307cba
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
-->
<md-autocomplete
md-no-cache="true"
md-selected-item="selectedItem"
md-search-text="$ctrl.searchText"
md-selected-item-change="$ctrl.selectUser(user)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
import io.gravitee.repository.management.model.MessageRecipient;
import io.gravitee.rest.api.model.command.CommandEntity;
import io.gravitee.rest.api.model.command.CommandQuery;
import io.gravitee.rest.api.model.command.CommandTags;
import io.gravitee.rest.api.service.CommandService;
import io.gravitee.rest.api.service.ScheduledCommandService;
import io.gravitee.rest.api.service.event.CommandEvent;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -40,6 +43,12 @@ public class ScheduledCommandsRefresherServiceImpl
extends AbstractService<ScheduledCommandsRefresherServiceImpl>
implements ScheduledCommandService<ScheduledCommandsRefresherServiceImpl>, Runnable {

// We exclude the DATA_TO_INDEX tag because it is processed by another service
public static final List<CommandTags> SUPPORTED_COMMAND_TAGS = Arrays
.stream(CommandTags.values())
.filter(commandTags -> commandTags != CommandTags.DATA_TO_INDEX)
.toList();

private final CommandService commandService;

private final Node node;
Expand Down Expand Up @@ -84,6 +93,7 @@ private List<CommandEntity> searchCommands() {
CommandQuery commandQuery = new CommandQuery();
commandQuery.setTo(MessageRecipient.MANAGEMENT_APIS.name());
commandQuery.setNotAckBy(node.id());
commandQuery.setTags(SUPPORTED_COMMAND_TAGS);

return commandService.search(commandQuery);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ public void shouldSyncCommandAndPublishEventAccordingly() {
when(
commandService.search(
ArgumentMatchers.argThat(query ->
query.getTo().equals(MessageRecipient.MANAGEMENT_APIS.name()) && query.getNotAckBy().equals("node-id")
query.getTo().equals(MessageRecipient.MANAGEMENT_APIS.name()) &&
query.getNotAckBy().equals("node-id") &&
!query.getTags().contains(CommandTags.DATA_TO_INDEX)
)
)
)
Expand Down

0 comments on commit a307cba

Please sign in to comment.