From 4f2524985b74bfb5debae6452d942b7514129a01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrique=20Gon=C3=A7alves?= <36671768+up201608320@users.noreply.github.com> Date: Sun, 16 Dec 2018 15:41:00 +0000 Subject: [PATCH 1/4] Update GetJobsStatsAction.java fixing match function to use expandedJobId instead of a single jobid --- .../xpack/core/ml/action/GetJobsStatsAction.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetJobsStatsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetJobsStatsAction.java index c5dba63fcc6b3..90a4933bf1544 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetJobsStatsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetJobsStatsAction.java @@ -118,7 +118,12 @@ public boolean allowNoJobs() { @Override public boolean match(Task task) { - return OpenJobAction.JobTaskMatcher.match(task, jobId); + for(int i = 0; i < expandedJobsIds.size(); i++) + { + if(OpenJobAction.JobTaskMatcher.match(task, expandedJobsIds[i]) == true) + return true; + } + return false; } @Override From 0fcf5ef1ee9e80fa6b8c1508a3ff1d42b8fc0a70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrique=20Gon=C3=A7alves?= <36671768+up201608320@users.noreply.github.com> Date: Mon, 17 Dec 2018 09:44:53 +0000 Subject: [PATCH 2/4] updated tests --- .../xpack/ml/action/TransportGetJobsStatsActionTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/TransportGetJobsStatsActionTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/TransportGetJobsStatsActionTests.java index 6d4b008570c72..590ce214e84d7 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/TransportGetJobsStatsActionTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/TransportGetJobsStatsActionTests.java @@ -50,7 +50,7 @@ public void testDetermineJobIds() { result = determineNonDeletedJobIdsWithoutLiveStats(mlMetadata, Arrays.asList("id1", "id2", "id3"), Collections.singletonList(new GetJobsStatsAction.Response.JobStats("id1", new DataCounts("id1"), null, null, - JobState.CLOSED, null, null, null)) + JobState.OPENED, null, null, null)) ); assertEquals(2, result.size()); assertEquals("id2", result.get(0)); From bbbc8717b6d01feb71eb55a8f29d1bc657c36d08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrique=20Gon=C3=A7alves?= <36671768+up201608320@users.noreply.github.com> Date: Mon, 17 Dec 2018 09:50:02 +0000 Subject: [PATCH 3/4] fixed [] to get() --- .../elasticsearch/xpack/core/ml/action/GetJobsStatsAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetJobsStatsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetJobsStatsAction.java index 90a4933bf1544..1f2bbba84c8d1 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetJobsStatsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetJobsStatsAction.java @@ -120,7 +120,7 @@ public boolean allowNoJobs() { public boolean match(Task task) { for(int i = 0; i < expandedJobsIds.size(); i++) { - if(OpenJobAction.JobTaskMatcher.match(task, expandedJobsIds[i]) == true) + if(OpenJobAction.JobTaskMatcher.match(task, expandedJobsIds.get(i)) == true) return true; } return false; From f5d92254fadb81e0e6e99e538848dd973e71b986 Mon Sep 17 00:00:00 2001 From: David Roberts Date: Mon, 28 Jan 2019 17:35:39 +0000 Subject: [PATCH 4/4] Address review comment --- .../xpack/core/ml/action/GetJobsStatsAction.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetJobsStatsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetJobsStatsAction.java index f42e224b68a2e..23d320143ab34 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetJobsStatsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetJobsStatsAction.java @@ -118,12 +118,7 @@ public boolean allowNoJobs() { @Override public boolean match(Task task) { - for(int i = 0; i < expandedJobsIds.size(); i++) - { - if(OpenJobAction.JobTaskMatcher.match(task, expandedJobsIds.get(i)) == true) - return true; - } - return false; + return expandedJobsIds.stream().anyMatch(jobId -> OpenJobAction.JobTaskMatcher.match(task, jobId)); } @Override