Skip to content

Commit 16100b8

Browse files
committed
apply spotless
Signed-off-by: Kaushal Kumar <[email protected]>
1 parent abcb6de commit 16100b8

File tree

3 files changed

+29
-24
lines changed

3 files changed

+29
-24
lines changed

plugins/workload-management/src/main/java/org/opensearch/plugin/wlm/AutoTaggingActionFilter.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,17 @@ public int order() {
5050

5151
@Override
5252
public <Request extends ActionRequest, Response extends ActionResponse> void apply(
53-
Task task, String action
54-
, Request request
55-
, ActionListener<Response> listener
56-
, ActionFilterChain<Request, Response> chain) {
57-
final boolean isValidRequest = request instanceof SearchRequest
58-
|| request instanceof SearchScrollRequest;
53+
Task task,
54+
String action,
55+
Request request,
56+
ActionListener<Response> listener,
57+
ActionFilterChain<Request, Response> chain
58+
) {
59+
final boolean isValidRequest = request instanceof SearchRequest || request instanceof SearchScrollRequest;
5960

60-
if (!isValidRequest) { return; }
61+
if (!isValidRequest) {
62+
return;
63+
}
6164
Optional<String> label = ruleProcessingService.evaluateLabel(List.of(new IndicesExtractor((IndicesRequest) request)));
6265

6366
label.ifPresent(s -> threadPool.getThreadContext().putHeader(QueryGroupTask.QUERY_GROUP_ID_HEADER, s));

plugins/workload-management/src/main/java/org/opensearch/plugin/wlm/WorkloadManagementPlugin.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,28 @@
5959
public class WorkloadManagementPlugin extends Plugin implements ActionPlugin {
6060

6161
private AutoTaggingActionFilter autoTaggingActionFilter;
62+
6263
/**
6364
* Default constructor
6465
*/
6566
public WorkloadManagementPlugin() {}
6667

6768
@Override
68-
public Collection<Object> createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, IndexNameExpressionResolver indexNameExpressionResolver, Supplier<RepositoriesService> repositoriesServiceSupplier) {
69-
InMemoryRuleProcessingService ruleProcessingService = new InMemoryRuleProcessingService(null, null);// TODO: this will change post Ruirui's PR
69+
public Collection<Object> createComponents(
70+
Client client,
71+
ClusterService clusterService,
72+
ThreadPool threadPool,
73+
ResourceWatcherService resourceWatcherService,
74+
ScriptService scriptService,
75+
NamedXContentRegistry xContentRegistry,
76+
Environment environment,
77+
NodeEnvironment nodeEnvironment,
78+
NamedWriteableRegistry namedWriteableRegistry,
79+
IndexNameExpressionResolver indexNameExpressionResolver,
80+
Supplier<RepositoriesService> repositoriesServiceSupplier
81+
) {
82+
InMemoryRuleProcessingService ruleProcessingService = new InMemoryRuleProcessingService(null, null);// TODO: this will change post
83+
// Ruirui's PR
7084
autoTaggingActionFilter = new AutoTaggingActionFilter(ruleProcessingService, threadPool);
7185
return Collections.emptyList();
7286
}

plugins/workload-management/src/test/java/org/opensearch/plugin/wlm/AutoTaggingActionFilterTests.java

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import static org.mockito.Mockito.verify;
3434
import static org.mockito.Mockito.when;
3535

36-
3736
public class AutoTaggingActionFilterTests extends OpenSearchTestCase {
3837

3938
AutoTaggingActionFilter autoTaggingActionFilter;
@@ -60,14 +59,8 @@ public void testApplyForValidRequest() {
6059
SearchRequest request = mock(SearchRequest.class);
6160
when(request.indices()).thenReturn(new String[] { "foo" });
6261
try (ThreadContext.StoredContext context = threadPool.getThreadContext().stashContext()) {
63-
when(ruleProcessingService.evaluateLabel(anyList()))
64-
.thenReturn(Optional.of("TestQG_ID"));
65-
autoTaggingActionFilter.apply(
66-
mock(Task.class),
67-
"Test",
68-
request,
69-
null, null
70-
);
62+
when(ruleProcessingService.evaluateLabel(anyList())).thenReturn(Optional.of("TestQG_ID"));
63+
autoTaggingActionFilter.apply(mock(Task.class), "Test", request, null, null);
7164

7265
assertEquals("TestQG_ID", threadPool.getThreadContext().getHeader(QueryGroupTask.QUERY_GROUP_ID_HEADER));
7366
verify(ruleProcessingService, times(1)).evaluateLabel(anyList());
@@ -76,12 +69,7 @@ public void testApplyForValidRequest() {
7669

7770
public void testApplyForInValidRequest() {
7871
CancelTasksRequest request = new CancelTasksRequest();
79-
autoTaggingActionFilter.apply(
80-
mock(Task.class),
81-
"Test",
82-
request,
83-
null, null
84-
);
72+
autoTaggingActionFilter.apply(mock(Task.class), "Test", request, null, null);
8573

8674
verify(ruleProcessingService, times(0)).evaluateLabel(anyList());
8775
}

0 commit comments

Comments
 (0)