Removes redundent NORELEASES and ObjectParserUtils (#32427)
This commit is contained in:
parent
783e427d36
commit
0682b4bbc9
|
@ -38,10 +38,11 @@ public class IndexLifecycleMetadata implements XPackMetaDataCustom {
|
||||||
public static final IndexLifecycleMetadata EMPTY = new IndexLifecycleMetadata(Collections.emptySortedMap(), OperationMode.RUNNING);
|
public static final IndexLifecycleMetadata EMPTY = new IndexLifecycleMetadata(Collections.emptySortedMap(), OperationMode.RUNNING);
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static final ConstructingObjectParser<IndexLifecycleMetadata, Void> PARSER = new ConstructingObjectParser<>(
|
public static final ConstructingObjectParser<IndexLifecycleMetadata, Void> PARSER = new ConstructingObjectParser<>(TYPE,
|
||||||
TYPE, a -> new IndexLifecycleMetadata(
|
a -> new IndexLifecycleMetadata(
|
||||||
ObjectParserUtils.convertListToMapValues(LifecyclePolicyMetadata::getName, (List<LifecyclePolicyMetadata>) a[0]),
|
((List<LifecyclePolicyMetadata>) a[0]).stream()
|
||||||
OperationMode.valueOf((String) a[1])));
|
.collect(Collectors.toMap(LifecyclePolicyMetadata::getName, Function.identity())),
|
||||||
|
OperationMode.valueOf((String) a[1])));
|
||||||
static {
|
static {
|
||||||
PARSER.declareNamedObjects(ConstructingObjectParser.constructorArg(), (p, c, n) -> LifecyclePolicyMetadata.parse(p, n),
|
PARSER.declareNamedObjects(ConstructingObjectParser.constructorArg(), (p, c, n) -> LifecyclePolicyMetadata.parse(p, n),
|
||||||
v -> {
|
v -> {
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
||||||
* or more contributor license agreements. Licensed under the Elastic License;
|
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
|
||||||
*/
|
|
||||||
package org.elasticsearch.xpack.core.indexlifecycle;
|
|
||||||
|
|
||||||
import org.elasticsearch.common.io.stream.Writeable;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.SortedMap;
|
|
||||||
import java.util.TreeMap;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* NORELEASE: these utility methods should be brought into the core API for
|
|
||||||
* parsing namedWriteables
|
|
||||||
*/
|
|
||||||
public class ObjectParserUtils {
|
|
||||||
public static <V extends Writeable> SortedMap<String, V> convertListToMapValues(Function<V, String> keyFunction,
|
|
||||||
List<V> list) {
|
|
||||||
SortedMap<String, V> map = new TreeMap<>();
|
|
||||||
for (V writeable : list) {
|
|
||||||
map.put(keyFunction.apply(writeable), writeable);
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -22,8 +22,8 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
import java.util.function.Function;
|
||||||
import static org.elasticsearch.xpack.core.indexlifecycle.ObjectParserUtils.convertListToMapValues;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents set of {@link LifecycleAction}s which should be executed at a
|
* Represents set of {@link LifecycleAction}s which should be executed at a
|
||||||
|
@ -36,8 +36,8 @@ public class Phase implements ToXContentObject, Writeable {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static final ConstructingObjectParser<Phase, String> PARSER = new ConstructingObjectParser<>("phase", false,
|
private static final ConstructingObjectParser<Phase, String> PARSER = new ConstructingObjectParser<>("phase", false,
|
||||||
(a, name) -> new Phase(name, (TimeValue) a[0],
|
(a, name) -> new Phase(name, (TimeValue) a[0], ((List<LifecycleAction>) a[1]).stream()
|
||||||
convertListToMapValues(LifecycleAction::getWriteableName, (List<LifecycleAction>) a[1])));
|
.collect(Collectors.toMap(LifecycleAction::getWriteableName, Function.identity()))));
|
||||||
static {
|
static {
|
||||||
PARSER.declareField(ConstructingObjectParser.optionalConstructorArg(),
|
PARSER.declareField(ConstructingObjectParser.optionalConstructorArg(),
|
||||||
(p, c) -> TimeValue.parseTimeValue(p.text(), AFTER_FIELD.getPreferredName()), AFTER_FIELD, ValueType.VALUE);
|
(p, c) -> TimeValue.parseTimeValue(p.text(), AFTER_FIELD.getPreferredName()), AFTER_FIELD, ValueType.VALUE);
|
||||||
|
|
|
@ -28,8 +28,7 @@ public class LifecyclePolicyMetadataTests extends AbstractSerializingTestCase<Li
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
lifecycleName = randomAlphaOfLength(20); // NORELEASE we need to randomise the lifecycle name rather
|
lifecycleName = randomAlphaOfLength(20);
|
||||||
// than use the same name for all instances
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,8 +28,7 @@ public class PhaseTests extends AbstractSerializingTestCase<Phase> {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
phaseName = randomAlphaOfLength(20); // NORELEASE we need to randomise the phase name rather
|
phaseName = randomAlphaOfLength(20);
|
||||||
// than use the same name for all instances
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -34,8 +34,7 @@ public class PutLifecycleRequestTests extends AbstractStreamableXContentTestCase
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
lifecycleName = randomAlphaOfLength(20); // NORELEASE we need to randomise the lifecycle name rather
|
lifecycleName = randomAlphaOfLength(20);
|
||||||
// than use the same name for all instances
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue