3535import static org .elasticsearch .common .xcontent .ConstructingObjectParser .optionalConstructorArg ;
3636
3737/**
38- * This class holds the configuration details of a rollup V2 job, such as the groupings, metrics, what
38+ * This class holds the configuration details of a {@link RollupAction} job, such as the groupings, metrics, what
3939 * index to rollup and where to roll them to.
4040 */
41- public class RollupV2Config implements NamedWriteable , ToXContentObject {
41+ public class RollupActionConfig implements NamedWriteable , ToXContentObject {
4242
43- private static final String NAME = "xpack/rollupv2 /config" ;
43+ private static final String NAME = "xpack/rollup/action /config" ;
4444 private static final TimeValue DEFAULT_TIMEOUT = TimeValue .timeValueSeconds (20 );
4545 private static final String TIMEOUT = "timeout" ;
4646 private static final String ROLLUP_INDEX = "rollup_index" ;
@@ -49,17 +49,16 @@ public class RollupV2Config implements NamedWriteable, ToXContentObject {
4949 private final List <MetricConfig > metricsConfig ;
5050 private final TimeValue timeout ;
5151 private String rollupIndex ;
52- private String sourceIndex ;
5352
54- private static final ConstructingObjectParser <RollupV2Config , String > PARSER ;
53+ private static final ConstructingObjectParser <RollupActionConfig , Void > PARSER ;
5554 static {
56- PARSER = new ConstructingObjectParser <>(NAME , false , (args , sourceIndex ) -> {
55+ PARSER = new ConstructingObjectParser <>(NAME , false , (args ) -> {
5756 String rollupIndex = (String ) args [0 ];
5857 GroupConfig groupConfig = (GroupConfig ) args [1 ];
5958 @ SuppressWarnings ("unchecked" )
6059 List <MetricConfig > metricsConfig = (List <MetricConfig >) args [2 ];
6160 TimeValue timeout = (TimeValue ) args [3 ];
62- return new RollupV2Config ( sourceIndex , groupConfig , metricsConfig , timeout , rollupIndex );
61+ return new RollupActionConfig ( groupConfig , metricsConfig , timeout , rollupIndex );
6362 });
6463 PARSER .declareString (constructorArg (), new ParseField (ROLLUP_INDEX ));
6564 PARSER .declareObject (optionalConstructorArg (), (p , c ) -> GroupConfig .fromXContent (p ), new ParseField (GroupConfig .NAME ));
@@ -68,42 +67,29 @@ public class RollupV2Config implements NamedWriteable, ToXContentObject {
6867 new ParseField (TIMEOUT ), ObjectParser .ValueType .STRING_OR_NULL );
6968 }
7069
71- public RollupV2Config (String sourceIndex , final GroupConfig groupConfig , final List <MetricConfig > metricsConfig ,
72- final @ Nullable TimeValue timeout , final String rollupIndex ) {
73- if (sourceIndex == null || sourceIndex .isEmpty ()) {
74- throw new IllegalArgumentException ("The source index must be a non-null, non-empty string" );
75- }
70+ public RollupActionConfig (final GroupConfig groupConfig , final List <MetricConfig > metricsConfig ,
71+ final @ Nullable TimeValue timeout , final String rollupIndex ) {
7672 if (rollupIndex == null || rollupIndex .isEmpty ()) {
7773 throw new IllegalArgumentException ("Rollup index must be a non-null, non-empty string" );
7874 }
7975 if (groupConfig == null && (metricsConfig == null || metricsConfig .isEmpty ())) {
8076 throw new IllegalArgumentException ("At least one grouping or metric must be configured" );
8177 }
82- this .sourceIndex = sourceIndex ;
8378 this .rollupIndex = rollupIndex ;
8479 this .groupConfig = groupConfig ;
8580 this .metricsConfig = metricsConfig != null ? metricsConfig : Collections .emptyList ();
8681 this .timeout = timeout != null ? timeout : DEFAULT_TIMEOUT ;
8782 }
8883
89- public RollupV2Config (final StreamInput in ) throws IOException {
90- this .sourceIndex = in .readString ();
84+ public RollupActionConfig (final StreamInput in ) throws IOException {
9185 rollupIndex = in .readString ();
9286 groupConfig = in .readOptionalWriteable (GroupConfig ::new );
9387 metricsConfig = in .readList (MetricConfig ::new );
9488 timeout = in .readTimeValue ();
9589 }
9690
9791 public String getId () {
98- return RollupField .NAME + "_" + sourceIndex + "_" + rollupIndex ;
99- }
100-
101- public String getSourceIndex () {
102- return sourceIndex ;
103- }
104-
105- public void setSourceIndex (String sourceIndex ) {
106- this .sourceIndex = sourceIndex ;
92+ return RollupField .NAME + "_" + rollupIndex ;
10793 }
10894
10995 public void setRollupIndex (String rollupIndex ) {
@@ -177,7 +163,6 @@ public XContentBuilder toXContent(final XContentBuilder builder, final Params pa
177163
178164 @ Override
179165 public void writeTo (final StreamOutput out ) throws IOException {
180- out .writeString (sourceIndex );
181166 out .writeString (rollupIndex );
182167 out .writeOptionalWriteable (groupConfig );
183168 out .writeList (metricsConfig );
@@ -193,17 +178,16 @@ public boolean equals(Object other) {
193178 return false ;
194179 }
195180
196- final RollupV2Config that = (RollupV2Config ) other ;
197- return Objects .equals (this .sourceIndex , that .sourceIndex )
198- && Objects .equals (this .rollupIndex , that .rollupIndex )
181+ final RollupActionConfig that = (RollupActionConfig ) other ;
182+ return Objects .equals (this .rollupIndex , that .rollupIndex )
199183 && Objects .equals (this .groupConfig , that .groupConfig )
200184 && Objects .equals (this .metricsConfig , that .metricsConfig )
201185 && Objects .equals (this .timeout , that .timeout );
202186 }
203187
204188 @ Override
205189 public int hashCode () {
206- return Objects .hash (sourceIndex , rollupIndex , groupConfig , metricsConfig , timeout );
190+ return Objects .hash (rollupIndex , groupConfig , metricsConfig , timeout );
207191 }
208192
209193 @ Override
@@ -218,7 +202,7 @@ public String toJSONString() {
218202 return toString ();
219203 }
220204
221- public static RollupV2Config fromXContent (final XContentParser parser , final String sourceIndex ) throws IOException {
222- return PARSER .parse (parser , sourceIndex );
205+ public static RollupActionConfig fromXContent (final XContentParser parser ) throws IOException {
206+ return PARSER .parse (parser , null );
223207 }
224208}
0 commit comments