use of org.elasticsearch.action.admin.indices.create.CreateIndexResponse in project fess by codelibs.
the class FessEsClient method createIndex.
public boolean createIndex(final String index, final String docType, final String indexName) {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
waitForConfigSyncStatus();
sendConfigFiles(index);
final String indexConfigFile = indexConfigPath + "/" + index + ".json";
try {
String source = FileUtil.readUTF8(indexConfigFile);
final String dictionaryPath = System.getProperty("fess.dictionary.path", StringUtil.EMPTY);
source = source.replaceAll(Pattern.quote("${fess.dictionary.path}"), dictionaryPath);
final CreateIndexResponse indexResponse = client.admin().indices().prepareCreate(indexName).setSource(source, XContentFactory.xContentType(source)).execute().actionGet(fessConfig.getIndexIndicesTimeout());
if (indexResponse.isAcknowledged()) {
logger.info("Created " + indexName + " index.");
return true;
} else if (logger.isDebugEnabled()) {
logger.debug("Failed to create " + indexName + " index.");
}
} catch (final Exception e) {
logger.warn(indexConfigFile + " is not found.", e);
}
return false;
}
use of org.elasticsearch.action.admin.indices.create.CreateIndexResponse in project crate by crate.
the class BlobAdminClient method createBlobTable.
public CompletableFuture<Void> createBlobTable(String tableName, Settings indexSettings) {
Settings.Builder builder = Settings.builder();
builder.put(indexSettings);
builder.put(SETTING_INDEX_BLOBS_ENABLED, true);
final CompletableFuture<Void> result = new CompletableFuture<>();
createIndexAction.execute(new CreateIndexRequest(fullIndexName(tableName), builder.build()), new ActionListener<CreateIndexResponse>() {
@Override
public void onResponse(CreateIndexResponse createIndexResponse) {
assert createIndexResponse.isAcknowledged() : "createIndexResponse must be acknowledged";
result.complete(null);
}
@Override
public void onFailure(Throwable e) {
result.completeExceptionally(e);
}
});
return result;
}
use of org.elasticsearch.action.admin.indices.create.CreateIndexResponse in project elasticsearch by elastic.
the class ActiveShardsObserverIT method testCreateIndexNoActiveShardsNoWaiting.
public void testCreateIndexNoActiveShardsNoWaiting() throws Exception {
Settings.Builder settingsBuilder = Settings.builder().put(indexSettings()).put(INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), randomIntBetween(1, 5)).put(INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0);
if (internalCluster().getNodeNames().length > 0) {
String exclude = String.join(",", internalCluster().getNodeNames());
settingsBuilder.put("index.routing.allocation.exclude._name", exclude);
}
Settings settings = settingsBuilder.build();
CreateIndexResponse response = prepareCreate("test-idx").setSettings(settings).setWaitForActiveShards(ActiveShardCount.NONE).get();
assertTrue(response.isAcknowledged());
}
use of org.elasticsearch.action.admin.indices.create.CreateIndexResponse in project elasticsearch by elastic.
the class ActiveShardsObserverIT method testCreateIndexStopsWaitingWhenIndexDeleted.
public void testCreateIndexStopsWaitingWhenIndexDeleted() throws Exception {
final String indexName = "test-idx";
Settings settings = Settings.builder().put(indexSettings()).put(INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), randomIntBetween(1, 5)).put(INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), internalCluster().numDataNodes() - 1).build();
logger.info("--> start the index creation process");
ListenableActionFuture<CreateIndexResponse> responseListener = prepareCreate(indexName).setSettings(settings).setWaitForActiveShards(ActiveShardCount.ALL).execute();
logger.info("--> wait until the cluster state contains the new index");
assertBusy(() -> assertTrue(client().admin().cluster().prepareState().get().getState().metaData().hasIndex(indexName)));
logger.info("--> delete the index");
assertAcked(client().admin().indices().prepareDelete(indexName));
logger.info("--> ensure the create index request completes");
assertAcked(responseListener.get());
}
use of org.elasticsearch.action.admin.indices.create.CreateIndexResponse in project elasticsearch by elastic.
the class AckIT method testCreateIndexNoAcknowledgement.
public void testCreateIndexNoAcknowledgement() {
CreateIndexResponse createIndexResponse = client().admin().indices().prepareCreate("test").setTimeout("0s").get();
assertThat(createIndexResponse.isAcknowledged(), equalTo(false));
//let's wait for green, otherwise there can be issues with after test checks (mock directory wrapper etc.)
ensureGreen();
}
Aggregations