|
@@ -18,7 +18,7 @@ import org.elasticsearch.common.unit.TimeValue;
|
|
|
import org.elasticsearch.common.xcontent.StatusToXContentObject;
|
|
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
|
import org.elasticsearch.rest.RestStatus;
|
|
|
-import org.elasticsearch.xpack.core.textstructure.structurefinder.FileStructure;
|
|
|
+import org.elasticsearch.xpack.core.textstructure.structurefinder.TextStructure;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.util.Arrays;
|
|
@@ -28,31 +28,31 @@ import java.util.Objects;
|
|
|
|
|
|
import static org.elasticsearch.action.ValidateActions.addValidationError;
|
|
|
|
|
|
-public class FindFileStructureAction extends ActionType<FindFileStructureAction.Response> {
|
|
|
+public class FindStructureAction extends ActionType<FindStructureAction.Response> {
|
|
|
|
|
|
- public static final FindFileStructureAction INSTANCE = new FindFileStructureAction();
|
|
|
+ public static final FindStructureAction INSTANCE = new FindStructureAction();
|
|
|
public static final String NAME = "cluster:monitor/text_structure/findstructure";
|
|
|
|
|
|
- private FindFileStructureAction() {
|
|
|
+ private FindStructureAction() {
|
|
|
super(NAME, Response::new);
|
|
|
}
|
|
|
|
|
|
public static class Response extends ActionResponse implements StatusToXContentObject, Writeable {
|
|
|
|
|
|
- private FileStructure fileStructure;
|
|
|
+ private TextStructure textStructure;
|
|
|
|
|
|
- public Response(FileStructure fileStructure) {
|
|
|
- this.fileStructure = fileStructure;
|
|
|
+ public Response(TextStructure textStructure) {
|
|
|
+ this.textStructure = textStructure;
|
|
|
}
|
|
|
|
|
|
Response(StreamInput in) throws IOException {
|
|
|
super(in);
|
|
|
- fileStructure = new FileStructure(in);
|
|
|
+ textStructure = new TextStructure(in);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void writeTo(StreamOutput out) throws IOException {
|
|
|
- fileStructure.writeTo(out);
|
|
|
+ textStructure.writeTo(out);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -62,13 +62,13 @@ public class FindFileStructureAction extends ActionType<FindFileStructureAction.
|
|
|
|
|
|
@Override
|
|
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
|
|
- fileStructure.toXContent(builder, params);
|
|
|
+ textStructure.toXContent(builder, params);
|
|
|
return builder;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int hashCode() {
|
|
|
- return Objects.hash(fileStructure);
|
|
|
+ return Objects.hash(textStructure);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -82,8 +82,8 @@ public class FindFileStructureAction extends ActionType<FindFileStructureAction.
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- FindFileStructureAction.Response that = (FindFileStructureAction.Response) other;
|
|
|
- return Objects.equals(fileStructure, that.fileStructure);
|
|
|
+ FindStructureAction.Response that = (FindStructureAction.Response) other;
|
|
|
+ return Objects.equals(textStructure, that.textStructure);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -92,17 +92,17 @@ public class FindFileStructureAction extends ActionType<FindFileStructureAction.
|
|
|
public static final ParseField LINES_TO_SAMPLE = new ParseField("lines_to_sample");
|
|
|
public static final ParseField LINE_MERGE_SIZE_LIMIT = new ParseField("line_merge_size_limit");
|
|
|
public static final ParseField TIMEOUT = new ParseField("timeout");
|
|
|
- public static final ParseField CHARSET = FileStructure.CHARSET;
|
|
|
- public static final ParseField FORMAT = FileStructure.FORMAT;
|
|
|
- public static final ParseField COLUMN_NAMES = FileStructure.COLUMN_NAMES;
|
|
|
- public static final ParseField HAS_HEADER_ROW = FileStructure.HAS_HEADER_ROW;
|
|
|
- public static final ParseField DELIMITER = FileStructure.DELIMITER;
|
|
|
- public static final ParseField QUOTE = FileStructure.QUOTE;
|
|
|
- public static final ParseField SHOULD_TRIM_FIELDS = FileStructure.SHOULD_TRIM_FIELDS;
|
|
|
- public static final ParseField GROK_PATTERN = FileStructure.GROK_PATTERN;
|
|
|
+ public static final ParseField CHARSET = TextStructure.CHARSET;
|
|
|
+ public static final ParseField FORMAT = TextStructure.FORMAT;
|
|
|
+ public static final ParseField COLUMN_NAMES = TextStructure.COLUMN_NAMES;
|
|
|
+ public static final ParseField HAS_HEADER_ROW = TextStructure.HAS_HEADER_ROW;
|
|
|
+ public static final ParseField DELIMITER = TextStructure.DELIMITER;
|
|
|
+ public static final ParseField QUOTE = TextStructure.QUOTE;
|
|
|
+ public static final ParseField SHOULD_TRIM_FIELDS = TextStructure.SHOULD_TRIM_FIELDS;
|
|
|
+ public static final ParseField GROK_PATTERN = TextStructure.GROK_PATTERN;
|
|
|
// This one is plural in FileStructure, but singular in FileStructureOverrides
|
|
|
public static final ParseField TIMESTAMP_FORMAT = new ParseField("timestamp_format");
|
|
|
- public static final ParseField TIMESTAMP_FIELD = FileStructure.TIMESTAMP_FIELD;
|
|
|
+ public static final ParseField TIMESTAMP_FIELD = TextStructure.TIMESTAMP_FIELD;
|
|
|
|
|
|
private static final String ARG_INCOMPATIBLE_WITH_FORMAT_TEMPLATE =
|
|
|
"[%s] may only be specified if [" + FORMAT.getPreferredName() + "] is [%s]";
|
|
@@ -111,7 +111,7 @@ public class FindFileStructureAction extends ActionType<FindFileStructureAction.
|
|
|
private Integer lineMergeSizeLimit;
|
|
|
private TimeValue timeout;
|
|
|
private String charset;
|
|
|
- private FileStructure.Format format;
|
|
|
+ private TextStructure.Format format;
|
|
|
private List<String> columnNames;
|
|
|
private Boolean hasHeaderRow;
|
|
|
private Character delimiter;
|
|
@@ -131,7 +131,7 @@ public class FindFileStructureAction extends ActionType<FindFileStructureAction.
|
|
|
lineMergeSizeLimit = in.readOptionalVInt();
|
|
|
timeout = in.readOptionalTimeValue();
|
|
|
charset = in.readOptionalString();
|
|
|
- format = in.readBoolean() ? in.readEnum(FileStructure.Format.class) : null;
|
|
|
+ format = in.readBoolean() ? in.readEnum(TextStructure.Format.class) : null;
|
|
|
columnNames = in.readBoolean() ? in.readStringList() : null;
|
|
|
hasHeaderRow = in.readOptionalBoolean();
|
|
|
delimiter = in.readBoolean() ? (char) in.readVInt() : null;
|
|
@@ -176,16 +176,16 @@ public class FindFileStructureAction extends ActionType<FindFileStructureAction.
|
|
|
this.charset = (charset == null || charset.isEmpty()) ? null : charset;
|
|
|
}
|
|
|
|
|
|
- public FileStructure.Format getFormat() {
|
|
|
+ public TextStructure.Format getFormat() {
|
|
|
return format;
|
|
|
}
|
|
|
|
|
|
- public void setFormat(FileStructure.Format format) {
|
|
|
+ public void setFormat(TextStructure.Format format) {
|
|
|
this.format = format;
|
|
|
}
|
|
|
|
|
|
public void setFormat(String format) {
|
|
|
- this.format = (format == null || format.isEmpty()) ? null : FileStructure.Format.fromString(format);
|
|
|
+ this.format = (format == null || format.isEmpty()) ? null : TextStructure.Format.fromString(format);
|
|
|
}
|
|
|
|
|
|
public List<String> getColumnNames() {
|
|
@@ -284,7 +284,7 @@ public class FindFileStructureAction extends ActionType<FindFileStructureAction.
|
|
|
this.sample = sample;
|
|
|
}
|
|
|
|
|
|
- private static ActionRequestValidationException addIncompatibleArgError(ParseField arg, FileStructure.Format format,
|
|
|
+ private static ActionRequestValidationException addIncompatibleArgError(ParseField arg, TextStructure.Format format,
|
|
|
ActionRequestValidationException validationException) {
|
|
|
return addValidationError(String.format(Locale.ROOT, ARG_INCOMPATIBLE_WITH_FORMAT_TEMPLATE, arg.getPreferredName(), format),
|
|
|
validationException);
|
|
@@ -301,27 +301,27 @@ public class FindFileStructureAction extends ActionType<FindFileStructureAction.
|
|
|
validationException = addValidationError("[" + LINE_MERGE_SIZE_LIMIT.getPreferredName() + "] must be positive if specified",
|
|
|
validationException);
|
|
|
}
|
|
|
- if (format != FileStructure.Format.DELIMITED) {
|
|
|
+ if (format != TextStructure.Format.DELIMITED) {
|
|
|
if (columnNames != null) {
|
|
|
- validationException = addIncompatibleArgError(COLUMN_NAMES, FileStructure.Format.DELIMITED, validationException);
|
|
|
+ validationException = addIncompatibleArgError(COLUMN_NAMES, TextStructure.Format.DELIMITED, validationException);
|
|
|
}
|
|
|
if (hasHeaderRow != null) {
|
|
|
- validationException = addIncompatibleArgError(HAS_HEADER_ROW, FileStructure.Format.DELIMITED, validationException);
|
|
|
+ validationException = addIncompatibleArgError(HAS_HEADER_ROW, TextStructure.Format.DELIMITED, validationException);
|
|
|
}
|
|
|
if (delimiter != null) {
|
|
|
- validationException = addIncompatibleArgError(DELIMITER, FileStructure.Format.DELIMITED, validationException);
|
|
|
+ validationException = addIncompatibleArgError(DELIMITER, TextStructure.Format.DELIMITED, validationException);
|
|
|
}
|
|
|
if (quote != null) {
|
|
|
- validationException = addIncompatibleArgError(QUOTE, FileStructure.Format.DELIMITED, validationException);
|
|
|
+ validationException = addIncompatibleArgError(QUOTE, TextStructure.Format.DELIMITED, validationException);
|
|
|
}
|
|
|
if (shouldTrimFields != null) {
|
|
|
- validationException = addIncompatibleArgError(SHOULD_TRIM_FIELDS, FileStructure.Format.DELIMITED, validationException);
|
|
|
+ validationException = addIncompatibleArgError(SHOULD_TRIM_FIELDS, TextStructure.Format.DELIMITED, validationException);
|
|
|
}
|
|
|
}
|
|
|
- if (format != FileStructure.Format.SEMI_STRUCTURED_TEXT) {
|
|
|
+ if (format != TextStructure.Format.SEMI_STRUCTURED_TEXT) {
|
|
|
if (grokPattern != null) {
|
|
|
validationException =
|
|
|
- addIncompatibleArgError(GROK_PATTERN, FileStructure.Format.SEMI_STRUCTURED_TEXT, validationException);
|
|
|
+ addIncompatibleArgError(GROK_PATTERN, TextStructure.Format.SEMI_STRUCTURED_TEXT, validationException);
|
|
|
}
|
|
|
}
|
|
|
if (sample == null || sample.length() == 0) {
|