Beispiel #1
0
  @Test
  public void testPutWarmerAcknowledgement() {
    createIndex("test");
    // make sure one shard is started so the search during put warmer will not fail
    index("test", "type", "1", "f", 1);

    assertAcked(
        client()
            .admin()
            .indices()
            .preparePutWarmer("custom_warmer")
            .setSearchRequest(
                client()
                    .prepareSearch("test")
                    .setTypes("test")
                    .setQuery(QueryBuilders.matchAllQuery())));

    for (Client client : clients()) {
      GetWarmersResponse getWarmersResponse =
          client.admin().indices().prepareGetWarmers().setLocal(true).get();
      assertThat(getWarmersResponse.warmers().size(), equalTo(1));
      ObjectObjectCursor<String, List<IndexWarmersMetaData.Entry>> entry =
          getWarmersResponse.warmers().iterator().next();
      assertThat(entry.key, equalTo("test"));
      assertThat(entry.value.size(), equalTo(1));
      assertThat(entry.value.get(0).name(), equalTo("custom_warmer"));
    }
  }
Beispiel #2
0
  @Test
  public void testDeleteWarmerAcknowledgement() {
    createIndex("test");
    index("test", "type", "1", "f", 1);

    assertAcked(
        client()
            .admin()
            .indices()
            .preparePutWarmer("custom_warmer")
            .setSearchRequest(
                client()
                    .prepareSearch("test")
                    .setTypes("test")
                    .setQuery(QueryBuilders.matchAllQuery())));

    assertAcked(
        client()
            .admin()
            .indices()
            .prepareDeleteWarmer()
            .setIndices("test")
            .setNames("custom_warmer"));

    for (Client client : clients()) {
      GetWarmersResponse getWarmersResponse =
          client.admin().indices().prepareGetWarmers().setLocal(true).get();
      assertThat(getWarmersResponse.warmers().size(), equalTo(0));
    }
  }
  @Test
  public void simpleWarmerTests() {
    client().admin().indices().prepareDelete().execute().actionGet();

    client()
        .admin()
        .indices()
        .prepareCreate("test")
        .setSettings(ImmutableSettings.settingsBuilder().put("index.number_of_shards", 1))
        .execute()
        .actionGet();

    client()
        .admin()
        .cluster()
        .prepareHealth()
        .setWaitForEvents(Priority.LANGUID)
        .setWaitForGreenStatus()
        .execute()
        .actionGet();

    client()
        .admin()
        .indices()
        .preparePutWarmer("warmer_1")
        .setSearchRequest(
            client()
                .prepareSearch("test")
                .setTypes("a1")
                .setQuery(QueryBuilders.termQuery("field", "value1")))
        .execute()
        .actionGet();
    client()
        .admin()
        .indices()
        .preparePutWarmer("warmer_2")
        .setSearchRequest(
            client()
                .prepareSearch("test")
                .setTypes("a2")
                .setQuery(QueryBuilders.termQuery("field", "value2")))
        .execute()
        .actionGet();

    client()
        .prepareIndex("test", "type1", "1")
        .setSource("field", "value1")
        .setRefresh(true)
        .execute()
        .actionGet();
    client()
        .prepareIndex("test", "type1", "2")
        .setSource("field", "value2")
        .setRefresh(true)
        .execute()
        .actionGet();

    GetWarmersResponse getWarmersResponse =
        client().admin().indices().prepareGetWarmers("tes*").execute().actionGet();
    assertThat(getWarmersResponse.getWarmers().size(), equalTo(1));
    assertThat(getWarmersResponse.getWarmers().get("test").size(), equalTo(2));
    assertThat(getWarmersResponse.getWarmers().get("test").get(0).name(), equalTo("warmer_1"));
    assertThat(getWarmersResponse.getWarmers().get("test").get(1).name(), equalTo("warmer_2"));

    getWarmersResponse =
        client()
            .admin()
            .indices()
            .prepareGetWarmers("test")
            .addWarmers("warmer_*")
            .execute()
            .actionGet();
    assertThat(getWarmersResponse.getWarmers().size(), equalTo(1));
    assertThat(getWarmersResponse.getWarmers().get("test").size(), equalTo(2));
    assertThat(getWarmersResponse.getWarmers().get("test").get(0).name(), equalTo("warmer_1"));
    assertThat(getWarmersResponse.getWarmers().get("test").get(1).name(), equalTo("warmer_2"));

    getWarmersResponse =
        client()
            .admin()
            .indices()
            .prepareGetWarmers("test")
            .addWarmers("warmer_1")
            .execute()
            .actionGet();
    assertThat(getWarmersResponse.getWarmers().size(), equalTo(1));
    assertThat(getWarmersResponse.getWarmers().get("test").size(), equalTo(1));
    assertThat(getWarmersResponse.getWarmers().get("test").get(0).name(), equalTo("warmer_1"));

    getWarmersResponse =
        client()
            .admin()
            .indices()
            .prepareGetWarmers("test")
            .addWarmers("warmer_2")
            .execute()
            .actionGet();
    assertThat(getWarmersResponse.getWarmers().size(), equalTo(1));
    assertThat(getWarmersResponse.getWarmers().get("test").size(), equalTo(1));
    assertThat(getWarmersResponse.getWarmers().get("test").get(0).name(), equalTo("warmer_2"));

    getWarmersResponse =
        client()
            .admin()
            .indices()
            .prepareGetWarmers("test")
            .addTypes("a*")
            .addWarmers("warmer_2")
            .execute()
            .actionGet();
    assertThat(getWarmersResponse.getWarmers().size(), equalTo(1));
    assertThat(getWarmersResponse.getWarmers().get("test").size(), equalTo(1));
    assertThat(getWarmersResponse.getWarmers().get("test").get(0).name(), equalTo("warmer_2"));

    getWarmersResponse =
        client()
            .admin()
            .indices()
            .prepareGetWarmers("test")
            .addTypes("a1")
            .addWarmers("warmer_2")
            .execute()
            .actionGet();
    assertThat(getWarmersResponse.getWarmers().size(), equalTo(0));
  }