本文整理汇总了Java中org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse类的典型用法代码示例。如果您正苦于以下问题:Java ClusterUpdateSettingsResponse类的具体用法?Java ClusterUpdateSettingsResponse怎么用?Java ClusterUpdateSettingsResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClusterUpdateSettingsResponse类属于org.elasticsearch.action.admin.cluster.settings包,在下文中一共展示了ClusterUpdateSettingsResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testClusterUpdateSettingsNoAcknowledgement
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse; //导入依赖的package包/类
public void testClusterUpdateSettingsNoAcknowledgement() {
client().admin().indices().prepareCreate("test")
.setSettings(Settings.builder()
.put("number_of_shards", between(cluster().numDataNodes(), DEFAULT_MAX_NUM_SHARDS))
.put("number_of_replicas", 0)).get();
ensureGreen();
// now that the cluster is stable, remove timeout
removePublishTimeout();
NodesInfoResponse nodesInfo = client().admin().cluster().prepareNodesInfo().get();
String excludedNodeId = null;
for (NodeInfo nodeInfo : nodesInfo.getNodes()) {
if (nodeInfo.getNode().isDataNode()) {
excludedNodeId = nodeInfo.getNode().getId();
break;
}
}
assertNotNull(excludedNodeId);
ClusterUpdateSettingsResponse clusterUpdateSettingsResponse = client().admin().cluster().prepareUpdateSettings().setTimeout("0s")
.setTransientSettings(Settings.builder().put("cluster.routing.allocation.exclude._id", excludedNodeId)).get();
assertThat(clusterUpdateSettingsResponse.isAcknowledged(), equalTo(false));
assertThat(clusterUpdateSettingsResponse.getTransientSettings().get("cluster.routing.allocation.exclude._id"), equalTo(excludedNodeId));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:AckClusterUpdateSettingsIT.java
示例2: testDeleteIsAppliedFirst
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse; //导入依赖的package包/类
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));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:ClusterSettingsIT.java
示例3: prepareRequest
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse; //导入依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
final ClusterUpdateSettingsRequest clusterUpdateSettingsRequest = Requests.clusterUpdateSettingsRequest();
clusterUpdateSettingsRequest.timeout(request.paramAsTime("timeout", clusterUpdateSettingsRequest.timeout()));
clusterUpdateSettingsRequest.masterNodeTimeout(
request.paramAsTime("master_timeout", clusterUpdateSettingsRequest.masterNodeTimeout()));
Map<String, Object> source;
try (XContentParser parser = request.contentParser()) {
source = parser.map();
}
if (source.containsKey("transient")) {
clusterUpdateSettingsRequest.transientSettings((Map) source.get("transient"));
}
if (source.containsKey("persistent")) {
clusterUpdateSettingsRequest.persistentSettings((Map) source.get("persistent"));
}
return channel -> client.admin().cluster().updateSettings(clusterUpdateSettingsRequest,
new AcknowledgedRestListener<ClusterUpdateSettingsResponse>(channel) {
@Override
protected void addCustomFields(XContentBuilder builder, ClusterUpdateSettingsResponse response) throws IOException {
builder.startObject("persistent");
response.getPersistentSettings().toXContent(builder, request);
builder.endObject();
builder.startObject("transient");
response.getTransientSettings().toXContent(builder, request);
builder.endObject();
}
});
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:32,代码来源:RestClusterUpdateSettingsAction.java
示例4: testCanUpdateTracerSettings
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse; //导入依赖的package包/类
public void testCanUpdateTracerSettings() {
ClusterUpdateSettingsResponse clusterUpdateSettingsResponse = client().admin().cluster()
.prepareUpdateSettings()
.setTransientSettings(Settings.builder().putArray("transport.tracer.include", "internal:index/shard/recovery/*",
"internal:gateway/local*"))
.get();
assertArrayEquals(clusterUpdateSettingsResponse.getTransientSettings().getAsArray("transport.tracer.include"), new String[] {"internal:index/shard/recovery/*",
"internal:gateway/local*"});
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:ClusterSettingsIT.java
示例5: testClusterUpdateSettingsWithBlocks
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse; //导入依赖的package包/类
public void testClusterUpdateSettingsWithBlocks() {
String key1 = "cluster.routing.allocation.enable";
Settings transientSettings = Settings.builder().put(key1, EnableAllocationDecider.Allocation.NONE.name()).build();
String key2 = "cluster.routing.allocation.node_concurrent_recoveries";
Settings persistentSettings = Settings.builder().put(key2, "5").build();
ClusterUpdateSettingsRequestBuilder request = client().admin().cluster().prepareUpdateSettings()
.setTransientSettings(transientSettings)
.setPersistentSettings(persistentSettings);
// Cluster settings updates are blocked when the cluster is read only
try {
setClusterReadOnly(true);
assertBlocked(request, MetaData.CLUSTER_READ_ONLY_BLOCK);
// But it's possible to update the settings to update the "cluster.blocks.read_only" setting
Settings settings = Settings.builder().put(MetaData.SETTING_READ_ONLY_SETTING.getKey(), false).build();
assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(settings).get());
} finally {
setClusterReadOnly(false);
}
// It should work now
ClusterUpdateSettingsResponse response = request.execute().actionGet();
assertAcked(response);
assertThat(response.getTransientSettings().get(key1), notNullValue());
assertThat(response.getTransientSettings().get(key2), nullValue());
assertThat(response.getPersistentSettings().get(key1), nullValue());
assertThat(response.getPersistentSettings().get(key2), notNullValue());
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:34,代码来源:ClusterSettingsIT.java
示例6: testMinimumMasterNodesStart
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse; //导入依赖的package包/类
public void testMinimumMasterNodesStart() {
Settings nodeSettings = Settings.builder()
.put("discovery.type", "ec2")
.build();
internalCluster().startNode(nodeSettings);
// We try to update minimum_master_nodes now
ClusterUpdateSettingsResponse response = client().admin().cluster().prepareUpdateSettings()
.setPersistentSettings(Settings.builder().put("discovery.zen.minimum_master_nodes", 1))
.setTransientSettings(Settings.builder().put("discovery.zen.minimum_master_nodes", 1))
.get();
Integer min = response.getPersistentSettings().getAsInt("discovery.zen.minimum_master_nodes", null);
assertThat(min, is(1));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:Ec2DiscoveryUpdateSettingsTests.java
示例7: toClusterUpdateSettingsResponse
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse; //导入依赖的package包/类
public ClusterUpdateSettingsResponse toClusterUpdateSettingsResponse() {
Map<String, Object> transientsAsMap = getAsStringObjectMap(entityWrapper, "transient");
Map<String, Object> persistentsAsMap = getAsStringObjectMap(entityWrapper, "persistent");
Settings transients = ImmutableSettings.builder().put(transientsAsMap).build();
Settings persistents = ImmutableSettings.builder().put(persistentsAsMap).build();
return ClusterUpdateSettingsResponseAccessor.create(true, transients, persistents);
}
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:8,代码来源:ResponseWrapper.java
示例8: setPersistentSettings
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse; //导入依赖的package包/类
public boolean setPersistentSettings(final String key,
final String value) {
final ClusterUpdateSettingsResponse response = client
.admin()
.cluster()
.prepareUpdateSettings()
.setPersistentSettings(
"{\"" + key + "\":\"" + value + "\"}").execute()
.actionGet();
return response.isAcknowledged();
}
开发者ID:codelibs,项目名称:elasticsearch-eventhook,代码行数:12,代码来源:EventHookService.java
示例9: setTransientSettings
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse; //导入依赖的package包/类
public boolean setTransientSettings(final String key, final String value) {
final ClusterUpdateSettingsResponse response = client
.admin()
.cluster()
.prepareUpdateSettings()
.setTransientSettings("{\"" + key + "\":\"" + value + "\"}")
.execute().actionGet();
return response.isAcknowledged();
}
开发者ID:codelibs,项目名称:elasticsearch-eventhook,代码行数:10,代码来源:EventHookService.java
示例10: testScriptField
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse; //导入依赖的package包/类
@Test
public void testScriptField() throws InterruptedException, ExecutionException {
Client client = es.client();
// Index
String id = "id1";
Map<String, Object> document = ImmutableMap.<String, Object> builder().put("field1", "value1").put("field2", "value2").build();
IndexResponse indexResponse = client.prepareIndex("index1", "type1").setId(id).setSource(document).setRefresh(true).execute().get();
assertThat(indexResponse.getId()).isEqualTo(id);
// Configure
String clusterImports = "java.io.*";
Settings settings = ImmutableSettings.builder().put(JavaPlugin.SCRIPT_JAVA_IMPORTS, clusterImports).build();
ClusterUpdateSettingsResponse settingsResponse = client.admin().cluster().prepareUpdateSettings().setPersistentSettings(settings).execute().get();
assertThat(settingsResponse.getPersistentSettings().get(JavaPlugin.SCRIPT_JAVA_IMPORTS)).isEqualTo(clusterImports);
// Test
int x = 1;
int y = 1;
int sum = x + y;
Map<String, Object> params = ImmutableMap.<String, Object> builder().put("x", x).put("y", y).build();
String script = "System.out.println(Version.CURRENT); return (Integer)var('x') + (Integer)var('y');";
SearchResponse searchResponse = client.prepareSearch("index1").addScriptField("result", "java", script, params).execute().get();
Integer result = searchResponse.getHits().getHits()[0].getFields().get("result").getValue();
assertThat(result).isEqualTo(sum);
}
开发者ID:btiernay,项目名称:elasticsearch-lang-java,代码行数:30,代码来源:JavaPluginTest.java
示例11: updateSettings
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse; //导入依赖的package包/类
@Override
public ActionFuture<ClusterUpdateSettingsResponse> updateSettings(final ClusterUpdateSettingsRequest request) {
return execute(ClusterUpdateSettingsAction.INSTANCE, request);
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AbstractClient.java
示例12: testClusterSettingsUpdateResponse
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse; //导入依赖的package包/类
public void testClusterSettingsUpdateResponse() {
String key1 = RecoverySettings.INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey();
int value1 = 10;
String key2 = EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey();
String value2 = EnableAllocationDecider.Allocation.NONE.name();
Settings transientSettings1 = Settings.builder().put(key1, value1, ByteSizeUnit.BYTES).build();
Settings persistentSettings1 = Settings.builder().put(key2, value2).build();
ClusterUpdateSettingsResponse response1 = client().admin().cluster()
.prepareUpdateSettings()
.setTransientSettings(transientSettings1)
.setPersistentSettings(persistentSettings1)
.execute()
.actionGet();
assertAcked(response1);
assertThat(response1.getTransientSettings().get(key1), notNullValue());
assertThat(response1.getTransientSettings().get(key2), nullValue());
assertThat(response1.getPersistentSettings().get(key1), nullValue());
assertThat(response1.getPersistentSettings().get(key2), notNullValue());
Settings transientSettings2 = Settings.builder().put(key1, value1, ByteSizeUnit.BYTES).put(key2, value2).build();
Settings persistentSettings2 = Settings.EMPTY;
ClusterUpdateSettingsResponse response2 = client().admin().cluster()
.prepareUpdateSettings()
.setTransientSettings(transientSettings2)
.setPersistentSettings(persistentSettings2)
.execute()
.actionGet();
assertAcked(response2);
assertThat(response2.getTransientSettings().get(key1), notNullValue());
assertThat(response2.getTransientSettings().get(key2), notNullValue());
assertThat(response2.getPersistentSettings().get(key1), nullValue());
assertThat(response2.getPersistentSettings().get(key2), nullValue());
Settings transientSettings3 = Settings.EMPTY;
Settings persistentSettings3 = Settings.builder().put(key1, value1, ByteSizeUnit.BYTES).put(key2, value2).build();
ClusterUpdateSettingsResponse response3 = client().admin().cluster()
.prepareUpdateSettings()
.setTransientSettings(transientSettings3)
.setPersistentSettings(persistentSettings3)
.execute()
.actionGet();
assertAcked(response3);
assertThat(response3.getTransientSettings().get(key1), nullValue());
assertThat(response3.getTransientSettings().get(key2), nullValue());
assertThat(response3.getPersistentSettings().get(key1), notNullValue());
assertThat(response3.getPersistentSettings().get(key2), notNullValue());
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:56,代码来源:ClusterSettingsIT.java
示例13: execute
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse; //导入依赖的package包/类
public void execute(ClusterUpdateSettingsRequest request, final ActionListener<ClusterUpdateSettingsResponse> listener) {
// TODO test
logger.debug("cluster update settings request {}", request);
try {
RequestUriBuilder uriBuilder = new RequestUriBuilder().addEndpoint("_cluster/settings");
// TODO what to do with headers ?
request.getHeaders();
Settings transientSettings = ClusterUpdateSettingsRequestAccessor.transientSettings(request);
Settings persistentSettings = ClusterUpdateSettingsRequestAccessor.persistentSettings(request);
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject();
if (transientSettings != ImmutableSettings.Builder.EMPTY_SETTINGS) {
// TODO waiting for https://github.com/elasticsearch/elasticsearch/pull/7212 to be merged and use a cleaner API
xContentBuilder.field("transient").map((Map) transientSettings.getAsMap());
}
if (persistentSettings != ImmutableSettings.Builder.EMPTY_SETTINGS) {
xContentBuilder.field("persistent").map((Map) persistentSettings.getAsMap());
}
xContentBuilder.endObject();
byte[] body = xContentBuilder.bytes().toBytes();
uriBuilder.addQueryParameter("timeout", request.timeout().toString());
uriBuilder.addQueryParameter("master_timeout", request.masterNodeTimeout().toString());
uriBuilder.addQueryParameter("flat_settings", true);
indicesAdminClient.getHttpClient().submit(HttpClientRequest.createPut(uriBuilder.toString())
.withContent(body))
.flatMap(ErrorHandler.AS_FUNC)
.flatMap(new Func1<HttpClientResponse<ByteBuf>, Observable<ClusterUpdateSettingsResponse>>() {
@Override
public Observable<ClusterUpdateSettingsResponse> call(HttpClientResponse<ByteBuf> response) {
return response.getContent().flatMap(new Func1<ByteBuf, Observable<ClusterUpdateSettingsResponse>>() {
@Override
public Observable<ClusterUpdateSettingsResponse> call(ByteBuf byteBuf) {
// TODO
return null;
}
});
}
})
.single()
.subscribe(new ListenerCompleterObserver<>(listener));
} catch (Exception e) {
listener.onFailure(e);
}
}
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:49,代码来源:ClusterUpdateSettingsActionHandler.java
示例14: doExecute
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse; //导入依赖的package包/类
@Override
protected ActionFuture<ClusterUpdateSettingsResponse> doExecute(ClusterUpdateSettingsRequest request) {
return client.admin().cluster().updateSettings(request);
}
开发者ID:javanna,项目名称:elasticshell,代码行数:5,代码来源:UpdateClusterSettingsRequestBuilder.java
示例15: updateSettings
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse; //导入依赖的package包/类
/**
* Updates settings in the cluster.
*/
ActionFuture<ClusterUpdateSettingsResponse> updateSettings(ClusterUpdateSettingsRequest request);
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:ClusterAdminClient.java
注:本文中的org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论