本文整理了Java中org.elasticsearch.client.AdminClient.cluster()
方法的一些代码示例,展示了AdminClient.cluster()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AdminClient.cluster()
方法的具体详情如下:
包路径:org.elasticsearch.client.AdminClient
类名称:AdminClient
方法名:cluster
[英]A client allowing to perform actions/operations against the cluster.
[中]允许对群集执行操作/操作的客户端。
代码示例来源:origin: SonarSource/sonarqube
public ProxyClusterStatsRequestBuilder(Client client) {
super(client.admin().cluster(), ClusterStatsAction.INSTANCE);
}
代码示例来源:origin: SonarSource/sonarqube
public ProxyClusterHealthRequestBuilder(Client client) {
super(client.admin().cluster(), ClusterHealthAction.INSTANCE);
}
代码示例来源:origin: SonarSource/sonarqube
public ProxyNodesStatsRequestBuilder(Client client) {
super(client.admin().cluster(), NodesStatsAction.INSTANCE);
}
代码示例来源:origin: SonarSource/sonarqube
public ProxyClusterStateRequestBuilder(Client client) {
super(client.admin().cluster(), ClusterStateAction.INSTANCE);
}
代码示例来源:origin: loklak/loklak_server
public boolean wait_ready(long maxtimemillis, ClusterHealthStatus status) {
// wait for yellow status
long start = System.currentTimeMillis();
boolean is_ready;
do {
// wait for yellow status
ClusterHealthResponse health = elasticsearchClient.admin().cluster().prepareHealth().setWaitForStatus(status).execute().actionGet();
is_ready = !health.isTimedOut();
if (!is_ready && System.currentTimeMillis() - start > maxtimemillis) return false;
} while (!is_ready);
return is_ready;
}
代码示例来源:origin: loklak/loklak_server
public String pendingClusterTasks() {
PendingClusterTasksResponse r = this.elasticsearchClient.admin().cluster().preparePendingClusterTasks().get();
return r.prettyPrint();
}
代码示例来源:origin: loklak/loklak_server
public String clusterStats() {
ClusterStatsResponse r = this.elasticsearchClient.admin().cluster().prepareClusterStats().get();
return r.toString();
}
代码示例来源:origin: floragunncom/search-guard
private static void issueWarnings(Client tc) {
NodesInfoResponse nir = tc.admin().cluster().nodesInfo(new NodesInfoRequest()).actionGet();
Version maxVersion = nir.getNodes().stream().max((n1,n2) -> n1.getVersion().compareTo(n2.getVersion())).get().getVersion();
Version minVersion = nir.getNodes().stream().min((n1,n2) -> n1.getVersion().compareTo(n2.getVersion())).get().getVersion();
if(!maxVersion.equals(minVersion)) {
System.out.println("WARNING: Your cluster consists of different node versions. It is not recommended to run sgadmin against a mixed cluster. This may fail.");
System.out.println(" Minimum node version is "+minVersion.toString());
System.out.println(" Maximum node version is "+maxVersion.toString());
} else {
System.out.println("Elasticsearch Version: "+minVersion.toString());
}
if(nir.getNodes().size() > 0) {
List<PluginInfo> pluginInfos = nir.getNodes().get(0).getPlugins().getPluginInfos();
String sgVersion = pluginInfos.stream().filter(p->p.getClassname().equals("com.floragunn.searchguard.SearchGuardPlugin")).map(p->p.getVersion()).findFirst().orElse("<unknown>");
System.out.println("Search Guard Version: "+sgVersion);
}
}
}
代码示例来源:origin: apache/usergrid
/**
* Check health of cluster.
*/
@Override
public Health getClusterHealth() {
try {
ClusterHealthResponse chr = esProvider.getClient().admin()
.cluster().health(new ClusterHealthRequest()).get();
return Health.valueOf( chr.getStatus().name() );
}
catch ( Exception ex ) {
ex.printStackTrace();
logger.error( "Error connecting to ElasticSearch", ex.getMessage() );
}
// this is bad, red alert!
return Health.RED;
}
代码示例来源:origin: richardwilly98/elasticsearch-river-mongodb
private long getBulkQueueSize() {
NodesInfoResponse response = client.admin().cluster().prepareNodesInfo().setThreadPool(true).get();
for (NodeInfo node : response.getNodes()) {
Iterator<Info> iterator = node.getThreadPool().iterator();
while (iterator.hasNext()) {
Info info = iterator.next();
if ("bulk".equals(info.getName())) {
return info.getQueueSize().getSingles();
}
}
}
return DEFAULT_BULK_QUEUE_SIZE;
}
private boolean isBulkProcessorAvailable() {
代码示例来源:origin: floragunncom/search-guard
ClusterHealthResponse nir = tc.admin().cluster().health(new ClusterHealthRequest()).actionGet();
sb.append(Strings.toString(nir,true, true));
} catch (Exception e1) {
NodesInfoResponse nir = tc.admin().cluster().nodesInfo(new NodesInfoRequest()).actionGet();
sb.append(Strings.toString(nir,true, true));
} catch (Exception e1) {
NodesStatsResponse nir = tc.admin().cluster().nodesStats(new NodesStatsRequest()).actionGet();
sb.append(Strings.toString(nir,true, true));
} catch (Exception e1) {
PendingClusterTasksResponse nir = tc.admin().cluster().pendingClusterTasks(new PendingClusterTasksRequest()).actionGet();
sb.append(Strings.toString(nir,true, true));
} catch (Exception e1) {
代码示例来源:origin: richardwilly98/elasticsearch-river-mongodb
private boolean isBulkProcessorAvailable() {
NodesStatsResponse response = client.admin().cluster().prepareNodesStats().setThreadPool(true).get();
for (NodeStats nodeStats : response.getNodes()) {
Iterator<Stats> iterator = nodeStats.getThreadPool().iterator();
while (iterator.hasNext()) {
Stats stats = iterator.next();
if ("bulk".equals(stats.getName())) {
int queue = stats.getQueue();
logger.trace("bulkQueueSize [{}] - queue [{}] - availability [{}]", bulkQueueSize, queue, 1 - (queue / bulkQueueSize));
return 1 - (queue / bulkQueueSize) > 0.1;
}
}
}
return true;
}
代码示例来源:origin: Netflix/conductor
@Override
public void setup() throws Exception {
elasticSearchClient.admin()
.cluster()
.prepareHealth()
.setWaitForGreenStatus()
.execute()
.get();
try {
initIndex();
updateLogIndexName();
Executors.newScheduledThreadPool(1)
.scheduleAtFixedRate(() -> updateLogIndexName(), 0, 1, TimeUnit.HOURS);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
//1. Create the required index
addIndex(indexName);
//2. Add Mappings for the workflow document type
addMappingToIndex(indexName, WORKFLOW_DOC_TYPE, "/mappings_docType_workflow.json");
//3. Add Mappings for task document type
addMappingToIndex(indexName, TASK_DOC_TYPE, "/mappings_docType_task.json");
}
代码示例来源:origin: brianfrankcooper/YCSB
client.admin().indices()
.exists(Requests.indicesExistsRequest(indexKey)).actionGet()
.isExists();
if (exists && newdb) {
client.admin().indices().prepareDelete(indexKey).execute().actionGet();
client.admin().indices().create(
new CreateIndexRequest(indexKey)
.settings(
)).actionGet();
client.admin().cluster().health(new ClusterHealthRequest().waitForGreenStatus()).actionGet();
代码示例来源:origin: apache/usergrid
/**
* Check health of this specific index.
*/
@Override
public Health getIndexHealth() {
try {
String[] indexNames = this.getIndexes();
final ActionFuture<ClusterHealthResponse> future = esProvider.getClient().admin().cluster().health(
new ClusterHealthRequest( indexNames ) );
//only wait 2 seconds max
ClusterHealthResponse chr = future.actionGet(2000);
return Health.valueOf( chr.getStatus().name() );
}
catch ( Exception ex ) {
logger.error( "Error connecting to ElasticSearch", ex.getMessage() );
}
// this is bad, red alert!
return Health.RED;
}
代码示例来源:origin: thinkaurelius/titan
public ElasticSearchIndex(Configuration config) {
indexName = config.get(INDEX_NAME);
useDeprecatedIgnoreUnmapped = config.get(USE_EDEPRECATED_IGNORE_UNMAPPED_OPTION);
checkExpectedClientVersion();
final ElasticSearchSetup.Connection c;
if (!config.has(INTERFACE)) {
c = legacyConfiguration(config);
} else {
c = interfaceConfiguration(config);
}
node = c.getNode();
client = c.getClient();
maxResultsSize = config.get(INDEX_MAX_RESULT_SET_SIZE);
log.debug("Configured ES query result set max size to {}", maxResultsSize);
client.admin().cluster().prepareHealth().setTimeout(config.get(HEALTH_REQUEST_TIMEOUT))
.setWaitForYellowStatus().execute().actionGet();
checkForOrCreateIndex(config);
}
代码示例来源:origin: stagemonitor/stagemonitor
private static void startElasticsearch() throws Exception {
try {
FileUtils.deleteDirectory(new File("build/elasticsearch"));
} catch (IOException e) {
// ignore
}
final Settings settings = Settings.builder()
.put("path.home", "build/elasticsearch")
.put("node.name", "junit-es-node")
.put("path.logs", "build/elasticsearch/logs")
.put("path.data", "build/elasticsearch/data")
.put("transport.type", "local")
.put("http.type", "netty4")
.build();
node = new TestNode(settings, Collections.singletonList(Netty4Plugin.class));
node.start();
node.client().admin().cluster().prepareHealth().setWaitForGreenStatus().get();
}
代码示例来源:origin: stagemonitor/stagemonitor
node.client().admin().cluster().prepareHealth().setWaitForGreenStatus().get();
adminClient = client.admin();
adminClient.cluster().prepareHealth()
.setWaitForYellowStatus().execute().actionGet();
代码示例来源:origin: richardwilly98/elasticsearch-river-mongodb
semaphore.acquire();
logger.trace("dropRecreateMapping index[{}] - type[{}]", index, type);
client.admin().indices().prepareRefresh(index).get();
ImmutableOpenMap<String, MappingMetaData> mappings = client.admin().cluster().prepareState().get().getState().getMetaData()
.index(index).mappings();
logger.trace("mappings contains type {}: {}", type, mappings.containsKey(type));
if (client.admin().indices().prepareDeleteMapping(index).setType(type).get().isAcknowledged()) {
PutMappingResponse pmr = client.admin().indices().preparePutMapping(index).setType(type)
.setSource(mapping.getSourceAsMap()).get();
代码示例来源:origin: floragunncom/search-guard
@Test
public void testCustomInterclusterRequestEvaluator() throws Exception {
final Settings settings = Settings.builder()
.put(ConfigConstants.SG_INTERCLUSTER_REQUEST_EVALUATOR_CLASS, "com.floragunn.searchguard.AlwaysFalseInterClusterRequestEvaluator")
.put("discovery.initial_state_timeout","8s")
.build();
setup(Settings.EMPTY, null, settings, false,ClusterConfiguration.DEFAULT ,5,1);
Assert.assertEquals(1, clusterHelper.nodeClient().admin().cluster().health(new ClusterHealthRequest().waitForGreenStatus()).actionGet().getNumberOfNodes());
Assert.assertEquals(ClusterHealthStatus.GREEN, clusterHelper.nodeClient().admin().cluster().health(new ClusterHealthRequest().waitForGreenStatus()).actionGet().getStatus());
}
内容来源于网络,如有侵权,请联系作者删除!