[DATA-FRAME] Sort `GET` transforms and stats by ID (#39365) (#39369)

* [Data-Frame] Sort `GET` transforms and stats by ID

* removing unused import
This commit is contained in:
Benjamin Trent 2019-02-25 14:22:41 -06:00 committed by GitHub
parent 0f29b89655
commit 926291aac8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 7 deletions

View File

@ -28,8 +28,8 @@ import org.elasticsearch.xpack.dataframe.persistence.DataFrameTransformsConfigMa
import org.elasticsearch.xpack.dataframe.transforms.DataFrameTransformConfig;
import org.elasticsearch.xpack.dataframe.transforms.DataFrameTransformTask;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
@ -52,8 +52,10 @@ public class TransportGetDataFrameTransformsAction extends
@Override
protected Response newResponse(Request request, List<Response> tasks, List<TaskOperationFailure> taskOperationFailures,
List<FailedNodeException> failedNodeExceptions) {
List<DataFrameTransformConfig> configs = tasks.stream().map(GetDataFrameTransformsAction.Response::getTransformConfigurations)
.flatMap(Collection::stream).collect(Collectors.toList());
List<DataFrameTransformConfig> configs = tasks.stream()
.flatMap(r -> r.getTransformConfigurations().stream())
.sorted(Comparator.comparing(DataFrameTransformConfig::getId))
.collect(Collectors.toList());
return new Response(configs, taskOperationFailures, failedNodeExceptions);
}

View File

@ -26,8 +26,8 @@ import org.elasticsearch.xpack.dataframe.action.GetDataFrameTransformsStatsActio
import org.elasticsearch.xpack.dataframe.persistence.DataFramePersistentTaskUtils;
import org.elasticsearch.xpack.dataframe.transforms.DataFrameTransformTask;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
@ -48,8 +48,9 @@ public class TransportGetDataFrameTransformsStatsAction extends
protected Response newResponse(Request request, List<Response> tasks, List<TaskOperationFailure> taskOperationFailures,
List<FailedNodeException> failedNodeExceptions) {
List<DataFrameTransformStateAndStats> responses = tasks.stream()
.map(GetDataFrameTransformsStatsAction.Response::getTransformsStateAndStats).flatMap(Collection::stream)
.collect(Collectors.toList());
.flatMap(r -> r.getTransformsStateAndStats().stream())
.sorted(Comparator.comparing(DataFrameTransformStateAndStats::getId))
.collect(Collectors.toList());
return new Response(responses, taskOperationFailures, failedNodeExceptions);
}
@ -95,4 +96,4 @@ public class TransportGetDataFrameTransformsStatsAction extends
}
}
}
}
}

View File

@ -89,11 +89,15 @@ setup:
data_frame.get_data_frame_transform:
transform_id: "*"
- match: { count: 2 }
- match: { transforms.0.id: "airline-transform" }
- match: { transforms.1.id: "airline-transform-dos" }
- do:
data_frame.get_data_frame_transform:
transform_id: "_all"
- match: { count: 2 }
- match: { transforms.0.id: "airline-transform" }
- match: { transforms.1.id: "airline-transform-dos" }
- do:
data_frame.delete_data_frame_transform:

View File

@ -78,11 +78,15 @@ teardown:
data_frame.get_data_frame_transform_stats:
transform_id: "*"
- match: { count: 2 }
- match: { transforms.0.id: "airline-transform-stats" }
- match: { transforms.1.id: "airline-transform-stats-dos" }
- do:
data_frame.get_data_frame_transform_stats:
transform_id: "_all"
- match: { count: 2 }
- match: { transforms.0.id: "airline-transform-stats" }
- match: { transforms.1.id: "airline-transform-stats-dos" }
- do:
data_frame.delete_data_frame_transform: