Ejemplo n.º 1
0
  public void testDeleteIsAppliedFirst() {
    DiscoverySettings discoverySettings = getDiscoverySettings();

    assertEquals(
        discoverySettings.getPublishTimeout(),
        DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY));
    assertTrue(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY));

    ClusterUpdateSettingsResponse response =
        client()
            .admin()
            .cluster()
            .prepareUpdateSettings()
            .setTransientSettings(
                Settings.builder()
                    .put(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.getKey(), false)
                    .put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "1s")
                    .build())
            .get();

    assertAcked(response);
    assertEquals(
        response
            .getTransientSettings()
            .getAsMap()
            .get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()),
        "1s");
    assertTrue(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY));
    assertFalse(
        response
            .getTransientSettings()
            .getAsBoolean(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.getKey(), null));

    response =
        client()
            .admin()
            .cluster()
            .prepareUpdateSettings()
            .setTransientSettings(
                Settings.builder()
                    .putNull((randomBoolean() ? "discovery.zen.*" : "*"))
                    .put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "2s"))
            .get();
    assertEquals(
        response
            .getTransientSettings()
            .getAsMap()
            .get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()),
        "2s");
    assertNull(
        response
            .getTransientSettings()
            .getAsBoolean(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.getKey(), null));
  }
Ejemplo n.º 2
0
  public void testUpdateDiscoveryPublishTimeout() {

    DiscoverySettings discoverySettings = getDiscoverySettings();

    assertThat(
        discoverySettings.getPublishTimeout(),
        equalTo(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY)));

    ClusterUpdateSettingsResponse response =
        client()
            .admin()
            .cluster()
            .prepareUpdateSettings()
            .setTransientSettings(
                Settings.builder()
                    .put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "1s")
                    .build())
            .get();

    assertAcked(response);
    assertThat(
        response
            .getTransientSettings()
            .getAsMap()
            .get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()),
        equalTo("1s"));
    assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L));

    try {
      client()
          .admin()
          .cluster()
          .prepareUpdateSettings()
          .setTransientSettings(
              Settings.builder()
                  .put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "whatever")
                  .build())
          .get();
      fail("bogus value");
    } catch (IllegalArgumentException ex) {
      assertEquals(
          ex.getMessage(),
          "failed to parse setting [discovery.zen.publish_timeout] with value [whatever] as a time value: unit is missing or unrecognized");
    }

    assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L));

    try {
      client()
          .admin()
          .cluster()
          .prepareUpdateSettings()
          .setTransientSettings(
              Settings.builder()
                  .put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), -1)
                  .build())
          .get();
      fail("bogus value");
    } catch (IllegalArgumentException ex) {
      assertEquals(
          ex.getMessage(),
          "Failed to parse value [-1] for setting [discovery.zen.publish_timeout] must be >= 0s");
    }

    assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L));
  }
Ejemplo n.º 3
0
  public void testResetClusterSetting() {
    DiscoverySettings discoverySettings = getDiscoverySettings();

    assertThat(
        discoverySettings.getPublishTimeout(),
        equalTo(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY)));
    assertThat(
        discoverySettings.getPublishDiff(),
        equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY)));

    ClusterUpdateSettingsResponse response =
        client()
            .admin()
            .cluster()
            .prepareUpdateSettings()
            .setTransientSettings(
                Settings.builder()
                    .put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "1s")
                    .build())
            .get();

    assertAcked(response);
    assertThat(
        response
            .getTransientSettings()
            .getAsMap()
            .get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()),
        equalTo("1s"));
    assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L));
    assertThat(
        discoverySettings.getPublishDiff(),
        equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY)));

    response =
        client()
            .admin()
            .cluster()
            .prepareUpdateSettings()
            .setTransientSettings(
                Settings.builder().putNull(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()))
            .get();

    assertAcked(response);
    assertNull(
        response
            .getTransientSettings()
            .getAsMap()
            .get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()));
    assertThat(
        discoverySettings.getPublishTimeout(),
        equalTo(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY)));
    assertThat(
        discoverySettings.getPublishDiff(),
        equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY)));

    response =
        client()
            .admin()
            .cluster()
            .prepareUpdateSettings()
            .setTransientSettings(
                Settings.builder()
                    .put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "1s")
                    .put(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.getKey(), false)
                    .build())
            .get();

    assertAcked(response);
    assertThat(
        response
            .getTransientSettings()
            .getAsMap()
            .get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()),
        equalTo("1s"));
    assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L));
    assertFalse(discoverySettings.getPublishDiff());
    response =
        client()
            .admin()
            .cluster()
            .prepareUpdateSettings()
            .setTransientSettings(
                Settings.builder().putNull((randomBoolean() ? "discovery.zen.*" : "*")))
            .get();

    assertNull(
        response
            .getTransientSettings()
            .getAsMap()
            .get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()));
    assertNull(
        response
            .getTransientSettings()
            .getAsMap()
            .get(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.getKey()));
    assertThat(
        discoverySettings.getPublishTimeout(),
        equalTo(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY)));
    assertThat(
        discoverySettings.getPublishDiff(),
        equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY)));

    // now persistent
    response =
        client()
            .admin()
            .cluster()
            .prepareUpdateSettings()
            .setPersistentSettings(
                Settings.builder()
                    .put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "1s")
                    .build())
            .get();

    assertAcked(response);
    assertThat(
        response
            .getPersistentSettings()
            .getAsMap()
            .get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()),
        equalTo("1s"));
    assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L));
    assertThat(
        discoverySettings.getPublishDiff(),
        equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY)));

    response =
        client()
            .admin()
            .cluster()
            .prepareUpdateSettings()
            .setPersistentSettings(
                Settings.builder().putNull((DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey())))
            .get();

    assertAcked(response);
    assertNull(
        response
            .getPersistentSettings()
            .getAsMap()
            .get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()));
    assertThat(
        discoverySettings.getPublishTimeout(),
        equalTo(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY)));
    assertThat(
        discoverySettings.getPublishDiff(),
        equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY)));

    response =
        client()
            .admin()
            .cluster()
            .prepareUpdateSettings()
            .setPersistentSettings(
                Settings.builder()
                    .put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "1s")
                    .put(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.getKey(), false)
                    .build())
            .get();

    assertAcked(response);
    assertThat(
        response
            .getPersistentSettings()
            .getAsMap()
            .get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()),
        equalTo("1s"));
    assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L));
    assertFalse(discoverySettings.getPublishDiff());
    response =
        client()
            .admin()
            .cluster()
            .prepareUpdateSettings()
            .setPersistentSettings(
                Settings.builder().putNull((randomBoolean() ? "discovery.zen.*" : "*")))
            .get();

    assertNull(
        response
            .getPersistentSettings()
            .getAsMap()
            .get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()));
    assertNull(
        response
            .getPersistentSettings()
            .getAsMap()
            .get(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.getKey()));
    assertThat(
        discoverySettings.getPublishTimeout(),
        equalTo(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY)));
    assertThat(
        discoverySettings.getPublishDiff(),
        equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY)));
  }