protected void markIndicesReadOnly(Set<String> indicesToMarkReadOnly) { // set read-only block but don't block on the response client.admin().indices().prepareUpdateSettings(indicesToMarkReadOnly.toArray(Strings.EMPTY_ARRAY)). setSettings(Settings.builder().put(IndexMetaData.SETTING_READ_ONLY_ALLOW_DELETE, true).build()).execute(); }
@Override public void commit() { if (this.client != null) { this.flushIndex(true); this.client.admin().indices() .refresh(new RefreshRequest(this.indexName)).actionGet(); // enable index auto refresh ImmutableSettings.Builder indexSettings = ImmutableSettings .settingsBuilder(); indexSettings.put("refresh_interval", 1); this.client.admin().indices().prepareUpdateSettings(this.indexName) .setSettings(indexSettings).execute().actionGet(); this.client.admin().indices().prepareOptimize(this.indexName) .setMaxNumSegments(5).execute().actionGet(); } }
indexSettings.put("refresh_interval", -1); this.client.admin().indices().prepareUpdateSettings(this.indexName) .setSettings(indexSettings).execute().actionGet();
protected void markIndicesReadOnly(Set<String> indicesToMarkReadOnly) { // set read-only block but don't block on the response client.admin().indices().prepareUpdateSettings(indicesToMarkReadOnly.toArray(Strings.EMPTY_ARRAY)). setSettings(Settings.builder().put(IndexMetaData.SETTING_READ_ONLY_ALLOW_DELETE, true).build()).execute(); }
protected void markIndicesReadOnly(Set<String> indicesToMarkReadOnly) { // set read-only block but don't block on the response client.admin().indices().prepareUpdateSettings(indicesToMarkReadOnly.toArray(Strings.EMPTY_ARRAY)). setSettings(Settings.builder().put(IndexMetaData.SETTING_READ_ONLY_ALLOW_DELETE, true).build()).execute(); }
/** * インデックスの設定を更新する. * @param index インデックス名 * @param settings 更新するインデックス設定 * @return Void */ public Void updateIndexSettings(String index, Map<String, String> settings) { Settings settingsForUpdate = Settings.settingsBuilder().put(settings).build(); esTransportClient.admin().indices().prepareUpdateSettings(index).setSettings(settingsForUpdate).execute() .actionGet(); return null; }
/** * Restricts the given index to be allocated on <code>n</code> nodes using the allocation deciders. * Yet if the shards can't be allocated on any other node shards for this index will remain allocated on * more than <code>n</code> nodes. */ public void allowNodes(String index, int n) { assert index != null; internalCluster().ensureAtLeastNumDataNodes(n); Settings.Builder builder = Settings.builder(); if (n > 0) { getExcludeSettings(index, n, builder); } Settings build = builder.build(); if (!build.isEmpty()) { logger.debug("allowNodes: updating [{}]'s setting to [{}]", index, build.toDelimitedString(';')); client().admin().indices().prepareUpdateSettings(index).setSettings(build).execute().actionGet(); } }