Skip to content

Commit 8a60331

Browse files
committed
Add a condition Type (MIN/MAX) and drop isRequired
1 parent becd6af commit 8a60331

13 files changed

+47
-57
lines changed

server/src/main/java/org/elasticsearch/action/admin/indices/rollover/Condition.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,21 @@
2020
*/
2121
public abstract class Condition<T> implements NamedWriteable, ToXContentFragment {
2222

23+
/**
24+
* Describes the type of condition - a min_* condition (MIN) or max_* condition (MAX).
25+
*/
26+
public enum Type {
27+
MIN,
28+
MAX
29+
}
30+
2331
protected T value;
2432
protected final String name;
33+
protected final Type type;
2534

26-
protected Condition(String name) {
35+
protected Condition(String name, Type type) {
2736
this.name = name;
37+
this.type = type;
2838
}
2939

3040
/**
@@ -67,8 +77,8 @@ public String name() {
6777
return name;
6878
}
6979

70-
public boolean isRequired() {
71-
return false;
80+
public Type type() {
81+
return type;
7282
}
7383

7484
/**

server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MaxAgeCondition.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ public class MaxAgeCondition extends Condition<TimeValue> {
2424
public static final String NAME = "max_age";
2525

2626
public MaxAgeCondition(TimeValue value) {
27-
super(NAME);
27+
super(NAME, Type.MAX);
2828
this.value = value;
2929
}
3030

3131
public MaxAgeCondition(StreamInput in) throws IOException {
32-
super(NAME);
32+
super(NAME, Type.MAX);
3333
this.value = TimeValue.timeValueMillis(in.readLong());
3434
}
3535

server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MaxDocsCondition.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ public class MaxDocsCondition extends Condition<Long> {
2323
public static final String NAME = "max_docs";
2424

2525
public MaxDocsCondition(Long value) {
26-
super(NAME);
26+
super(NAME, Type.MAX);
2727
this.value = value;
2828
}
2929

3030
public MaxDocsCondition(StreamInput in) throws IOException {
31-
super(NAME);
31+
super(NAME, Type.MAX);
3232
this.value = in.readLong();
3333
}
3434

server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MaxPrimaryShardDocsCondition.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ public class MaxPrimaryShardDocsCondition extends Condition<Long> {
2424
public static final String NAME = "max_primary_shard_docs";
2525

2626
public MaxPrimaryShardDocsCondition(Long value) {
27-
super(NAME);
27+
super(NAME, Type.MAX);
2828
this.value = value;
2929
}
3030

3131
public MaxPrimaryShardDocsCondition(StreamInput in) throws IOException {
32-
super(NAME);
32+
super(NAME, Type.MAX);
3333
this.value = in.readLong();
3434
}
3535

server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MaxPrimaryShardSizeCondition.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ public class MaxPrimaryShardSizeCondition extends Condition<ByteSizeValue> {
2525
public static final String NAME = "max_primary_shard_size";
2626

2727
public MaxPrimaryShardSizeCondition(ByteSizeValue value) {
28-
super(NAME);
28+
super(NAME, Type.MAX);
2929
this.value = value;
3030
}
3131

3232
public MaxPrimaryShardSizeCondition(StreamInput in) throws IOException {
33-
super(NAME);
33+
super(NAME, Type.MAX);
3434
this.value = new ByteSizeValue(in.readVLong(), ByteSizeUnit.BYTES);
3535
}
3636

server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MaxSizeCondition.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ public class MaxSizeCondition extends Condition<ByteSizeValue> {
2525
public static final String NAME = "max_size";
2626

2727
public MaxSizeCondition(ByteSizeValue value) {
28-
super(NAME);
28+
super(NAME, Type.MAX);
2929
this.value = value;
3030
}
3131

3232
public MaxSizeCondition(StreamInput in) throws IOException {
33-
super(NAME);
33+
super(NAME, Type.MAX);
3434
this.value = new ByteSizeValue(in.readVLong(), ByteSizeUnit.BYTES);
3535
}
3636

server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MinAgeCondition.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ public class MinAgeCondition extends Condition<TimeValue> {
2525
public static final String NAME = "min_age";
2626

2727
public MinAgeCondition(TimeValue value) {
28-
super(NAME);
28+
super(NAME, Type.MIN);
2929
this.value = value;
3030
}
3131

3232
public MinAgeCondition(StreamInput in) throws IOException {
33-
super(NAME);
33+
super(NAME, Type.MIN);
3434
this.value = TimeValue.timeValueMillis(in.readLong());
3535
}
3636

@@ -40,11 +40,6 @@ public Result evaluate(final Stats stats) {
4040
return new Result(this, this.value.getMillis() <= indexAge);
4141
}
4242

43-
@Override
44-
public boolean isRequired() {
45-
return true;
46-
}
47-
4843
@Override
4944
public String getWriteableName() {
5045
return NAME;

server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MinDocsCondition.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ public class MinDocsCondition extends Condition<Long> {
2424
public static final String NAME = "min_docs";
2525

2626
public MinDocsCondition(Long value) {
27-
super(NAME);
27+
super(NAME, Type.MIN);
2828
this.value = value;
2929
}
3030

3131
public MinDocsCondition(StreamInput in) throws IOException {
32-
super(NAME);
32+
super(NAME, Type.MIN);
3333
this.value = in.readLong();
3434
}
3535

@@ -38,11 +38,6 @@ public Result evaluate(final Stats stats) {
3838
return new Result(this, this.value <= stats.numDocs());
3939
}
4040

41-
@Override
42-
public boolean isRequired() {
43-
return true;
44-
}
45-
4641
@Override
4742
public String getWriteableName() {
4843
return NAME;

server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MinPrimaryShardDocsCondition.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ public class MinPrimaryShardDocsCondition extends Condition<Long> {
2424
public static final String NAME = "min_primary_shard_docs";
2525

2626
public MinPrimaryShardDocsCondition(Long value) {
27-
super(NAME);
27+
super(NAME, Type.MIN);
2828
this.value = value;
2929
}
3030

3131
public MinPrimaryShardDocsCondition(StreamInput in) throws IOException {
32-
super(NAME);
32+
super(NAME, Type.MIN);
3333
this.value = in.readLong();
3434
}
3535

@@ -38,11 +38,6 @@ public Result evaluate(Stats stats) {
3838
return new Result(this, this.value <= stats.maxPrimaryShardDocs());
3939
}
4040

41-
@Override
42-
public boolean isRequired() {
43-
return true;
44-
}
45-
4641
@Override
4742
public String getWriteableName() {
4843
return NAME;

server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MinPrimaryShardSizeCondition.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ public class MinPrimaryShardSizeCondition extends Condition<ByteSizeValue> {
2525
public static final String NAME = "min_primary_shard_size";
2626

2727
public MinPrimaryShardSizeCondition(ByteSizeValue value) {
28-
super(NAME);
28+
super(NAME, Type.MIN);
2929
this.value = value;
3030
}
3131

3232
public MinPrimaryShardSizeCondition(StreamInput in) throws IOException {
33-
super(NAME);
33+
super(NAME, Type.MIN);
3434
this.value = new ByteSizeValue(in);
3535
}
3636

@@ -39,11 +39,6 @@ public Result evaluate(Stats stats) {
3939
return new Result(this, stats.maxPrimaryShardSize().getBytes() >= value.getBytes());
4040
}
4141

42-
@Override
43-
public boolean isRequired() {
44-
return true;
45-
}
46-
4742
@Override
4843
public String getWriteableName() {
4944
return NAME;

0 commit comments

Comments
 (0)