|
@@ -10,20 +10,21 @@ import org.elasticsearch.cluster.metadata.Metadata;
|
|
import org.elasticsearch.common.Strings;
|
|
import org.elasticsearch.common.Strings;
|
|
import org.elasticsearch.common.Table;
|
|
import org.elasticsearch.common.Table;
|
|
import org.elasticsearch.common.unit.TimeValue;
|
|
import org.elasticsearch.common.unit.TimeValue;
|
|
-import org.elasticsearch.xpack.core.action.util.PageParams;
|
|
|
|
-import org.elasticsearch.xpack.core.common.table.TableColumnAttributeBuilder;
|
|
|
|
import org.elasticsearch.rest.RestRequest;
|
|
import org.elasticsearch.rest.RestRequest;
|
|
import org.elasticsearch.rest.RestResponse;
|
|
import org.elasticsearch.rest.RestResponse;
|
|
import org.elasticsearch.rest.action.RestActionListener;
|
|
import org.elasticsearch.rest.action.RestActionListener;
|
|
import org.elasticsearch.rest.action.RestResponseListener;
|
|
import org.elasticsearch.rest.action.RestResponseListener;
|
|
import org.elasticsearch.rest.action.cat.AbstractCatAction;
|
|
import org.elasticsearch.rest.action.cat.AbstractCatAction;
|
|
import org.elasticsearch.rest.action.cat.RestTable;
|
|
import org.elasticsearch.rest.action.cat.RestTable;
|
|
|
|
+import org.elasticsearch.xpack.core.action.util.PageParams;
|
|
|
|
+import org.elasticsearch.xpack.core.common.table.TableColumnAttributeBuilder;
|
|
import org.elasticsearch.xpack.core.transform.TransformField;
|
|
import org.elasticsearch.xpack.core.transform.TransformField;
|
|
import org.elasticsearch.xpack.core.transform.action.GetTransformAction;
|
|
import org.elasticsearch.xpack.core.transform.action.GetTransformAction;
|
|
import org.elasticsearch.xpack.core.transform.action.GetTransformStatsAction;
|
|
import org.elasticsearch.xpack.core.transform.action.GetTransformStatsAction;
|
|
import org.elasticsearch.xpack.core.transform.transforms.TransformCheckpointingInfo;
|
|
import org.elasticsearch.xpack.core.transform.transforms.TransformCheckpointingInfo;
|
|
import org.elasticsearch.xpack.core.transform.transforms.TransformIndexerStats;
|
|
import org.elasticsearch.xpack.core.transform.transforms.TransformIndexerStats;
|
|
import org.elasticsearch.xpack.core.transform.transforms.TransformStats;
|
|
import org.elasticsearch.xpack.core.transform.transforms.TransformStats;
|
|
|
|
+import org.elasticsearch.xpack.transform.Transform;
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -35,14 +36,9 @@ import static org.elasticsearch.xpack.core.transform.TransformField.ALLOW_NO_MAT
|
|
|
|
|
|
public class RestCatTransformAction extends AbstractCatAction {
|
|
public class RestCatTransformAction extends AbstractCatAction {
|
|
|
|
|
|
- private static final Integer DEFAULT_MAX_PAGE_SEARCH_SIZE = Integer.valueOf(500);
|
|
|
|
- private static final TimeValue DEFAULT_TRANSFORM_FREQUENCY = TimeValue.timeValueMillis(60000);
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public List<Route> routes() {
|
|
public List<Route> routes() {
|
|
- return List.of(
|
|
|
|
- new Route(GET, "_cat/transforms"),
|
|
|
|
- new Route(GET, "_cat/transforms/{" + TransformField.TRANSFORM_ID + "}"));
|
|
|
|
|
|
+ return List.of(new Route(GET, "_cat/transforms"), new Route(GET, "_cat/transforms/{" + TransformField.TRANSFORM_ID + "}"));
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -64,8 +60,10 @@ public class RestCatTransformAction extends AbstractCatAction {
|
|
statsRequest.setAllowNoMatch(restRequest.paramAsBoolean(ALLOW_NO_MATCH.getPreferredName(), true));
|
|
statsRequest.setAllowNoMatch(restRequest.paramAsBoolean(ALLOW_NO_MATCH.getPreferredName(), true));
|
|
|
|
|
|
if (restRequest.hasParam(PageParams.FROM.getPreferredName()) || restRequest.hasParam(PageParams.SIZE.getPreferredName())) {
|
|
if (restRequest.hasParam(PageParams.FROM.getPreferredName()) || restRequest.hasParam(PageParams.SIZE.getPreferredName())) {
|
|
- PageParams pageParams = new PageParams(restRequest.paramAsInt(PageParams.FROM.getPreferredName(), PageParams.DEFAULT_FROM),
|
|
|
|
- restRequest.paramAsInt(PageParams.SIZE.getPreferredName(), PageParams.DEFAULT_SIZE));
|
|
|
|
|
|
+ PageParams pageParams = new PageParams(
|
|
|
|
+ restRequest.paramAsInt(PageParams.FROM.getPreferredName(), PageParams.DEFAULT_FROM),
|
|
|
|
+ restRequest.paramAsInt(PageParams.SIZE.getPreferredName(), PageParams.DEFAULT_SIZE)
|
|
|
|
+ );
|
|
request.setPageParams(pageParams);
|
|
request.setPageParams(pageParams);
|
|
statsRequest.setPageParams(pageParams);
|
|
statsRequest.setPageParams(pageParams);
|
|
}
|
|
}
|
|
@@ -95,138 +93,113 @@ public class RestCatTransformAction extends AbstractCatAction {
|
|
}
|
|
}
|
|
|
|
|
|
private static Table getTableWithHeader() {
|
|
private static Table getTableWithHeader() {
|
|
- return new Table()
|
|
|
|
- .startHeaders()
|
|
|
|
|
|
+ return new Table().startHeaders()
|
|
// Transform config info
|
|
// Transform config info
|
|
.addCell("id", TableColumnAttributeBuilder.builder("the id").build())
|
|
.addCell("id", TableColumnAttributeBuilder.builder("the id").build())
|
|
- .addCell("create_time",
|
|
|
|
- TableColumnAttributeBuilder.builder("transform creation time")
|
|
|
|
- .setAliases("ct", "createTime")
|
|
|
|
- .build())
|
|
|
|
- .addCell("version",
|
|
|
|
- TableColumnAttributeBuilder.builder("the version of Elasticsearch when the transform was created")
|
|
|
|
- .setAliases("v")
|
|
|
|
- .build())
|
|
|
|
- .addCell("source_index",
|
|
|
|
- TableColumnAttributeBuilder.builder("source index")
|
|
|
|
- .setAliases("si", "sourceIndex")
|
|
|
|
- .build())
|
|
|
|
- .addCell("dest_index",
|
|
|
|
- TableColumnAttributeBuilder.builder("destination index")
|
|
|
|
- .setAliases("di", "destIndex")
|
|
|
|
- .build())
|
|
|
|
- .addCell("pipeline",
|
|
|
|
- TableColumnAttributeBuilder.builder("transform pipeline")
|
|
|
|
- .setAliases("p")
|
|
|
|
- .build())
|
|
|
|
- .addCell("description",
|
|
|
|
- TableColumnAttributeBuilder.builder("description")
|
|
|
|
- .setAliases("d")
|
|
|
|
- .build())
|
|
|
|
- .addCell("transform_type",
|
|
|
|
- TableColumnAttributeBuilder.builder("batch or continuous transform")
|
|
|
|
- .setAliases("tt")
|
|
|
|
- .build())
|
|
|
|
- .addCell("frequency",
|
|
|
|
- TableColumnAttributeBuilder.builder("frequency of transform")
|
|
|
|
- .setAliases("f")
|
|
|
|
- .build())
|
|
|
|
- .addCell("max_page_search_size",
|
|
|
|
- TableColumnAttributeBuilder.builder("max page search size")
|
|
|
|
- .setAliases("mpsz")
|
|
|
|
- .build())
|
|
|
|
-
|
|
|
|
|
|
+ .addCell("create_time", TableColumnAttributeBuilder.builder("transform creation time").setAliases("ct", "createTime").build())
|
|
|
|
+ .addCell(
|
|
|
|
+ "version",
|
|
|
|
+ TableColumnAttributeBuilder.builder("the version of Elasticsearch when the transform was created").setAliases("v").build()
|
|
|
|
+ )
|
|
|
|
+ .addCell("source_index", TableColumnAttributeBuilder.builder("source index").setAliases("si", "sourceIndex").build())
|
|
|
|
+ .addCell("dest_index", TableColumnAttributeBuilder.builder("destination index").setAliases("di", "destIndex").build())
|
|
|
|
+ .addCell("pipeline", TableColumnAttributeBuilder.builder("transform pipeline").setAliases("p").build())
|
|
|
|
+ .addCell("description", TableColumnAttributeBuilder.builder("description").setAliases("d").build())
|
|
|
|
+ .addCell("transform_type", TableColumnAttributeBuilder.builder("batch or continuous transform").setAliases("tt").build())
|
|
|
|
+ .addCell("frequency", TableColumnAttributeBuilder.builder("frequency of transform").setAliases("f").build())
|
|
|
|
+ .addCell("max_page_search_size", TableColumnAttributeBuilder.builder("max page search size").setAliases("mpsz").build())
|
|
|
|
+ .addCell("docs_per_second", TableColumnAttributeBuilder.builder("docs per second").setAliases("dps").build())
|
|
// Transform stats info
|
|
// Transform stats info
|
|
- .addCell("state",
|
|
|
|
|
|
+ .addCell(
|
|
|
|
+ "state",
|
|
TableColumnAttributeBuilder.builder("transform state")
|
|
TableColumnAttributeBuilder.builder("transform state")
|
|
.setAliases("s")
|
|
.setAliases("s")
|
|
.setTextAlignment(TableColumnAttributeBuilder.TextAlign.RIGHT)
|
|
.setTextAlignment(TableColumnAttributeBuilder.TextAlign.RIGHT)
|
|
- .build())
|
|
|
|
- .addCell("reason",
|
|
|
|
- TableColumnAttributeBuilder.builder("reason for the current state", false)
|
|
|
|
- .setAliases("r", "reason")
|
|
|
|
- .build())
|
|
|
|
- .addCell("changes_last_detection_time",
|
|
|
|
- TableColumnAttributeBuilder.builder("changes last detected time", false)
|
|
|
|
- .setAliases("cldt")
|
|
|
|
- .build())
|
|
|
|
- .addCell("search_total",
|
|
|
|
- TableColumnAttributeBuilder.builder("total number of search phases", false)
|
|
|
|
- .setAliases("st")
|
|
|
|
- .build())
|
|
|
|
- .addCell("search_failure",
|
|
|
|
- TableColumnAttributeBuilder.builder("total number of search failures", false)
|
|
|
|
- .setAliases("sf")
|
|
|
|
- .build())
|
|
|
|
- .addCell("search_time",
|
|
|
|
- TableColumnAttributeBuilder.builder("total search time", false)
|
|
|
|
- .setAliases("stime")
|
|
|
|
- .build())
|
|
|
|
- .addCell("index_total",
|
|
|
|
- TableColumnAttributeBuilder.builder("total number of index phases done by the transform", false)
|
|
|
|
- .setAliases("it")
|
|
|
|
- .build())
|
|
|
|
- .addCell("index_failure",
|
|
|
|
- TableColumnAttributeBuilder.builder("total number of index failures", false)
|
|
|
|
- .setAliases("if")
|
|
|
|
- .build())
|
|
|
|
- .addCell("index_time",
|
|
|
|
- TableColumnAttributeBuilder.builder("total time spent indexing documents", false)
|
|
|
|
- .setAliases("itime")
|
|
|
|
- .build())
|
|
|
|
- .addCell("documents_processed",
|
|
|
|
- TableColumnAttributeBuilder.builder("the number of documents read from source indices and processed",
|
|
|
|
- false)
|
|
|
|
|
|
+ .build()
|
|
|
|
+ )
|
|
|
|
+ .addCell("reason", TableColumnAttributeBuilder.builder("reason for the current state", false).setAliases("r", "reason").build())
|
|
|
|
+ .addCell(
|
|
|
|
+ "changes_last_detection_time",
|
|
|
|
+ TableColumnAttributeBuilder.builder("changes last detected time", false).setAliases("cldt").build()
|
|
|
|
+ )
|
|
|
|
+ .addCell("search_total", TableColumnAttributeBuilder.builder("total number of search phases", false).setAliases("st").build())
|
|
|
|
+ .addCell(
|
|
|
|
+ "search_failure",
|
|
|
|
+ TableColumnAttributeBuilder.builder("total number of search failures", false).setAliases("sf").build()
|
|
|
|
+ )
|
|
|
|
+ .addCell("search_time", TableColumnAttributeBuilder.builder("total search time", false).setAliases("stime").build())
|
|
|
|
+ .addCell(
|
|
|
|
+ "index_total",
|
|
|
|
+ TableColumnAttributeBuilder.builder("total number of index phases done by the transform", false).setAliases("it").build()
|
|
|
|
+ )
|
|
|
|
+ .addCell("index_failure", TableColumnAttributeBuilder.builder("total number of index failures", false).setAliases("if").build())
|
|
|
|
+ .addCell(
|
|
|
|
+ "index_time",
|
|
|
|
+ TableColumnAttributeBuilder.builder("total time spent indexing documents", false).setAliases("itime").build()
|
|
|
|
+ )
|
|
|
|
+ .addCell(
|
|
|
|
+ "documents_processed",
|
|
|
|
+ TableColumnAttributeBuilder.builder("the number of documents read from source indices and processed", false)
|
|
.setAliases("docp")
|
|
.setAliases("docp")
|
|
- .build())
|
|
|
|
- .addCell("documents_indexed",
|
|
|
|
- TableColumnAttributeBuilder.builder("the number of documents index to the destination index",
|
|
|
|
- false)
|
|
|
|
|
|
+ .build()
|
|
|
|
+ )
|
|
|
|
+ .addCell(
|
|
|
|
+ "documents_indexed",
|
|
|
|
+ TableColumnAttributeBuilder.builder("the number of documents index to the destination index", false)
|
|
.setAliases("doci")
|
|
.setAliases("doci")
|
|
- .build())
|
|
|
|
- .addCell("trigger_count",
|
|
|
|
- TableColumnAttributeBuilder.builder("the number of times the transform has been triggered", false)
|
|
|
|
- .setAliases("tc")
|
|
|
|
- .build())
|
|
|
|
- .addCell("pages_processed",
|
|
|
|
- TableColumnAttributeBuilder.builder("the number of pages processed", false)
|
|
|
|
- .setAliases("pp")
|
|
|
|
- .build())
|
|
|
|
- .addCell("processing_time",
|
|
|
|
- TableColumnAttributeBuilder.builder("the total time spent processing documents", false)
|
|
|
|
- .setAliases("pt")
|
|
|
|
- .build())
|
|
|
|
- .addCell("checkpoint_duration_time_exp_avg",
|
|
|
|
|
|
+ .build()
|
|
|
|
+ )
|
|
|
|
+ .addCell(
|
|
|
|
+ "trigger_count",
|
|
|
|
+ TableColumnAttributeBuilder.builder("the number of times the transform has been triggered", false).setAliases("tc").build()
|
|
|
|
+ )
|
|
|
|
+ .addCell(
|
|
|
|
+ "pages_processed",
|
|
|
|
+ TableColumnAttributeBuilder.builder("the number of pages processed", false).setAliases("pp").build()
|
|
|
|
+ )
|
|
|
|
+ .addCell(
|
|
|
|
+ "processing_time",
|
|
|
|
+ TableColumnAttributeBuilder.builder("the total time spent processing documents", false).setAliases("pt").build()
|
|
|
|
+ )
|
|
|
|
+ .addCell(
|
|
|
|
+ "checkpoint_duration_time_exp_avg",
|
|
TableColumnAttributeBuilder.builder("exponential average checkpoint processing time (milliseconds)", false)
|
|
TableColumnAttributeBuilder.builder("exponential average checkpoint processing time (milliseconds)", false)
|
|
.setAliases("cdtea", "checkpointTimeExpAvg")
|
|
.setAliases("cdtea", "checkpointTimeExpAvg")
|
|
- .build())
|
|
|
|
- .addCell("indexed_documents_exp_avg",
|
|
|
|
- TableColumnAttributeBuilder.builder("exponential average number of documents indexed", false)
|
|
|
|
- .setAliases("idea")
|
|
|
|
- .build())
|
|
|
|
- .addCell("processed_documents_exp_avg",
|
|
|
|
- TableColumnAttributeBuilder.builder("exponential average number of documents processed", false)
|
|
|
|
- .setAliases("pdea")
|
|
|
|
- .build())
|
|
|
|
|
|
+ .build()
|
|
|
|
+ )
|
|
|
|
+ .addCell(
|
|
|
|
+ "indexed_documents_exp_avg",
|
|
|
|
+ TableColumnAttributeBuilder.builder("exponential average number of documents indexed", false).setAliases("idea").build()
|
|
|
|
+ )
|
|
|
|
+ .addCell(
|
|
|
|
+ "processed_documents_exp_avg",
|
|
|
|
+ TableColumnAttributeBuilder.builder("exponential average number of documents processed", false).setAliases("pdea").build()
|
|
|
|
+ )
|
|
.endHeaders();
|
|
.endHeaders();
|
|
}
|
|
}
|
|
|
|
|
|
private Table buildTable(GetTransformAction.Response response, GetTransformStatsAction.Response statsResponse) {
|
|
private Table buildTable(GetTransformAction.Response response, GetTransformStatsAction.Response statsResponse) {
|
|
Table table = getTableWithHeader();
|
|
Table table = getTableWithHeader();
|
|
- Map<String, TransformStats> statsById = statsResponse.getTransformsStats().stream()
|
|
|
|
- .collect(Collectors.toMap(TransformStats::getId, Function.identity()));
|
|
|
|
|
|
+ Map<String, TransformStats> statsById = statsResponse.getTransformsStats()
|
|
|
|
+ .stream()
|
|
|
|
+ .collect(Collectors.toMap(TransformStats::getId, Function.identity()));
|
|
response.getTransformConfigurations().forEach(config -> {
|
|
response.getTransformConfigurations().forEach(config -> {
|
|
TransformStats stats = statsById.get(config.getId());
|
|
TransformStats stats = statsById.get(config.getId());
|
|
TransformCheckpointingInfo checkpointingInfo = null;
|
|
TransformCheckpointingInfo checkpointingInfo = null;
|
|
TransformIndexerStats transformIndexerStats = null;
|
|
TransformIndexerStats transformIndexerStats = null;
|
|
|
|
|
|
- if(stats != null) {
|
|
|
|
|
|
+ if (stats != null) {
|
|
checkpointingInfo = stats.getCheckpointingInfo();
|
|
checkpointingInfo = stats.getCheckpointingInfo();
|
|
transformIndexerStats = stats.getIndexerStats();
|
|
transformIndexerStats = stats.getIndexerStats();
|
|
}
|
|
}
|
|
|
|
|
|
- table
|
|
|
|
- .startRow()
|
|
|
|
|
|
+ Integer maxPageSearchSize = config.getSettings() == null || config.getSettings().getMaxPageSearchSize() == null
|
|
|
|
+ ? config.getPivotConfig() == null || config.getPivotConfig().getMaxPageSearchSize() == null
|
|
|
|
+ ? Transform.DEFAULT_INITIAL_MAX_PAGE_SEARCH_SIZE
|
|
|
|
+ : config.getPivotConfig().getMaxPageSearchSize()
|
|
|
|
+ : config.getSettings().getMaxPageSearchSize();
|
|
|
|
+
|
|
|
|
+ table.startRow()
|
|
.addCell(config.getId())
|
|
.addCell(config.getId())
|
|
.addCell(config.getCreateTime())
|
|
.addCell(config.getCreateTime())
|
|
.addCell(config.getVersion())
|
|
.addCell(config.getVersion())
|
|
@@ -235,9 +208,13 @@ public class RestCatTransformAction extends AbstractCatAction {
|
|
.addCell(config.getDestination().getPipeline())
|
|
.addCell(config.getDestination().getPipeline())
|
|
.addCell(config.getDescription())
|
|
.addCell(config.getDescription())
|
|
.addCell(config.getSyncConfig() == null ? "batch" : "continuous")
|
|
.addCell(config.getSyncConfig() == null ? "batch" : "continuous")
|
|
- .addCell(config.getFrequency() == null ? DEFAULT_TRANSFORM_FREQUENCY : config.getFrequency())
|
|
|
|
- .addCell(config.getPivotConfig() == null || config.getPivotConfig().getMaxPageSearchSize() == null ?
|
|
|
|
- DEFAULT_MAX_PAGE_SEARCH_SIZE : config.getPivotConfig().getMaxPageSearchSize())
|
|
|
|
|
|
+ .addCell(config.getFrequency() == null ? Transform.DEFAULT_TRANSFORM_FREQUENCY : config.getFrequency())
|
|
|
|
+ .addCell(maxPageSearchSize)
|
|
|
|
+ .addCell(
|
|
|
|
+ config.getSettings() == null || config.getSettings().getDocsPerSecond() == null
|
|
|
|
+ ? "-"
|
|
|
|
+ : config.getSettings().getDocsPerSecond()
|
|
|
|
+ )
|
|
.addCell(stats == null ? null : stats.getState())
|
|
.addCell(stats == null ? null : stats.getState())
|
|
.addCell(stats == null ? null : stats.getReason())
|
|
.addCell(stats == null ? null : stats.getReason())
|
|
.addCell(checkpointingInfo == null ? null : checkpointingInfo.getChangesLastDetectedAt())
|
|
.addCell(checkpointingInfo == null ? null : checkpointingInfo.getChangesLastDetectedAt())
|