Skip to content

Instantly share code, notes, and snippets.

@nik9000
Created December 29, 2017 16:50
Show Gist options
  • Save nik9000/84320047e828c773ec381eb433d64573 to your computer and use it in GitHub Desktop.
Save nik9000/84320047e828c773ec381eb433d64573 to your computer and use it in GitHub Desktop.
public void testArchivedSetting() throws IOException {
if (runningAgainstOldCluster) {
String updateSettingsRequestBody = "{\"persistent\": {\"cluster.routing.allocation.disk.watermark.high\": 0.99}}";
client().performRequest("PUT", "/_cluster/settings", emptyMap(),
new StringEntity(updateSettingsRequestBody, ContentType.APPLICATION_JSON));
}
Map<?, ?> r = toMap(client().performRequest("GET", "/_cluster/settings", singletonMap("flat_settings", "true")));
r = (Map<?, ?>) r.get("persistent");
// The restart will have moved the setting to "archived"
assertEquals("0.99", r.get((runningAgainstOldCluster ? "" : "archived.") + "cluster.routing.allocation.disk.watermark.high"));
if (false == runningAgainstOldCluster) {
// We should be able to update another setting
String updateSettingsRequestBody = "{\"persistent\": {\"cluster.routing.allocation.enable\": \"all\"}}";
client().performRequest("PUT", "/_cluster/settings", emptyMap(),
new StringEntity(updateSettingsRequestBody, ContentType.APPLICATION_JSON));
// And lets read it back just for good measure
r = toMap(client().performRequest("GET", "/_cluster/settings", singletonMap("flat_settings", "true")));
r = (Map<?, ?>) r.get("transient");
assertEquals("all", r.get("cluster.routing.allocation.enable"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment