Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.joda.FormatDateTimeFormatter;
import org.elasticsearch.common.joda.Joda;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Property;
import org.elasticsearch.common.settings.Settings;
Expand All @@ -47,11 +49,21 @@
*/
public final class UnassignedInfo implements ToXContentFragment, Writeable {

private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(Loggers.getLogger(UnassignedInfo.class));

public static final FormatDateTimeFormatter DATE_TIME_FORMATTER = Joda.forPattern("dateOptionalTime");

public static final Setting<TimeValue> INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING =
Setting.timeSetting("index.unassigned.node_left.delayed_timeout", TimeValue.timeValueMinutes(1), Property.Dynamic,
Property.IndexScope);
new Setting<>("index.unassigned.node_left.delayed_timeout", (s) -> TimeValue.timeValueMinutes(1).getStringRep(), (s) -> {
TimeValue parsedValue = TimeValue.parseTimeValue(s, "index.unassigned.node_left.delayed_timeout");
if (parsedValue.getNanos() < 0) {
DEPRECATION_LOGGER.deprecated(
"Negative values for index.unassigned.node_left.delayed_timeout [{}]" +
" are deprecated and should now be set to \"0\".", s);
}
return parsedValue;
}, Property.Dynamic, Property.IndexScope);

/**
* Reason why the shard is in unassigned state.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,4 +356,11 @@ public void testAllocationStatusSerialization() throws IOException {
assertThat(readStatus, equalTo(allocationStatus));
}
}

public void testNegativeTimeoutDeprecated() {
Settings settings = settings(Version.CURRENT).put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "-1s").build();
assertThat(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.get(settings).seconds(), equalTo(-1L));
assertWarnings("Negative values for index.unassigned.node_left.delayed_timeout [-1s]" +
" are deprecated and should now be set to \"0\".");
}
}