本文整理汇总了Java中org.elasticsearch.client.ClusterAdminClient类的典型用法代码示例。如果您正苦于以下问题:Java ClusterAdminClient类的具体用法?Java ClusterAdminClient怎么用?Java ClusterAdminClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ClusterAdminClient类属于org.elasticsearch.client包,在下文中一共展示了ClusterAdminClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import org.elasticsearch.client.ClusterAdminClient; //导入依赖的package包/类
private static void update() {
try {
IndicesAdminClient indicesAdminClient = client.admin().indices();
if (indicesAdminClient.prepareExists(INDEX_NAME_v2).execute().actionGet().isExists()) {
indicesAdminClient.delete(new DeleteIndexRequest(INDEX_NAME_v2)).actionGet();
}
indicesAdminClient.prepareCreate(INDEX_NAME_v2).addMapping(INDEX_TYPE,getItemInfoMapping()).execute().actionGet();
//等待集群shard,防止No shard available for 异常
ClusterAdminClient clusterAdminClient = client.admin().cluster();
clusterAdminClient.prepareHealth().setWaitForYellowStatus().execute().actionGet(5000);
//0、更新mapping
updateMapping();
//1、更新数据
reindexData(indicesAdminClient);
//2、realias 重新建立连接
indicesAdminClient.prepareAliases().removeAlias(INDEX_NAME_v1, ALIX_NAME).addAlias(INDEX_NAME_v2, ALIX_NAME).execute().actionGet();
}catch (Exception e){
log.error("beforeUpdate error:{}"+e.getLocalizedMessage());
}
}
示例2: beforeUpdate
import org.elasticsearch.client.ClusterAdminClient; //导入依赖的package包/类
private static void beforeUpdate() {
try {
IndicesAdminClient indicesAdminClient = client.admin().indices();
indicesAdminClient.delete(new DeleteIndexRequest(INDEX_NAME_v1)).actionGet();
if (!indicesAdminClient.prepareExists(INDEX_NAME_v1).execute().actionGet().isExists()) {
indicesAdminClient.prepareCreate(INDEX_NAME_v1).addMapping(INDEX_TYPE,getItemInfoMapping()).execute().actionGet();
}
//等待集群shard,防止No shard available for 异常
ClusterAdminClient clusterAdminClient = client.admin().cluster();
clusterAdminClient.prepareHealth().setWaitForYellowStatus().execute().actionGet(5000);
//创建别名alias
indicesAdminClient.prepareAliases().addAlias(INDEX_NAME_v1, ALIX_NAME).execute().actionGet();
prepareData(indicesAdminClient);
}catch (Exception e){
log.error("beforeUpdate error:{}"+e.getLocalizedMessage());
}
}
示例3: getClient
import org.elasticsearch.client.ClusterAdminClient; //导入依赖的package包/类
public Client getClient() {
Client client = node.client();
ExecutorService executor = Executors.newSingleThreadExecutor();
Future<Void> future = executor.submit(new Callable<Void>() {
@Override
public Void call() {
ClusterAdminClient clusterAdmin = client.admin().cluster();
ClusterHealthResponse res = clusterAdmin.health(new ClusterHealthRequest()).actionGet(1000);
while (res.getStatus().equals(ClusterHealthStatus.RED)) {
res = clusterAdmin.health(new ClusterHealthRequest()).actionGet(1000);
}
return null;
}
});
try {
future.get(3, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
log.error("Failed to wait for cluster to startup synchronously. Unit tests may fail", e);
}
return client;
}
示例4: waitForActiveRiver
import org.elasticsearch.client.ClusterAdminClient; //导入依赖的package包/类
public static void waitForActiveRiver(ClusterAdminClient client, String riverName, String riverType, int seconds) throws InterruptedException, IOException {
GetRiverStateRequest riverStateRequest = new GetRiverStateRequest()
.setRiverName(riverName)
.setRiverType(riverType);
GetRiverStateResponse riverStateResponse = client
.execute(GetRiverStateAction.INSTANCE, riverStateRequest).actionGet();
while (seconds-- > 0 && !isActive(riverName, riverStateResponse)) {
Thread.sleep(1000L);
try {
riverStateResponse = client.execute(GetRiverStateAction.INSTANCE, riverStateRequest).actionGet();
} catch (IndexMissingException e) {
//
}
}
if (seconds < 0) {
throw new IOException("timeout waiting for active river");
}
}
示例5: waitForInactiveRiver
import org.elasticsearch.client.ClusterAdminClient; //导入依赖的package包/类
public static void waitForInactiveRiver(ClusterAdminClient client, String riverName, String riverType, int seconds) throws InterruptedException, IOException {
GetRiverStateRequest riverStateRequest = new GetRiverStateRequest()
.setRiverName(riverName)
.setRiverType(riverType);
GetRiverStateResponse riverStateResponse = client
.execute(GetRiverStateAction.INSTANCE, riverStateRequest).actionGet();
while (seconds-- > 0 && isActive(riverName, riverStateResponse)) {
Thread.sleep(1000L);
try {
riverStateResponse = client.execute(GetRiverStateAction.INSTANCE, riverStateRequest).actionGet();
} catch (IndexMissingException e) {
//
}
}
if (seconds < 0) {
throw new IOException("timeout waiting for inactive river");
}
}
示例6: SetupMocks
import org.elasticsearch.client.ClusterAdminClient; //导入依赖的package包/类
private void SetupMocks(Client client, IndicesAdminClient indicesAdminClient, ImmutableOpenMap<String, IndexMetaData> indicesMap) {
AdminClient adminClient = mock(AdminClient.class);
ClusterAdminClient clusterAdminClient = mock(ClusterAdminClient.class);
@SuppressWarnings("unchecked")
ActionFuture<ClusterStateResponse> actionFuture = ((ActionFuture<ClusterStateResponse>) mock(ActionFuture.class));
ClusterStateResponse response = mock(ClusterStateResponse.class);
ClusterState state = mock(ClusterState.class);
MetaData metaData = mock(MetaData.class);
when(client.admin()).thenReturn(adminClient);
when(adminClient.indices()).thenReturn(indicesAdminClient);
when(adminClient.cluster()).thenReturn(clusterAdminClient);
when(clusterAdminClient.state(Mockito.any(ClusterStateRequest.class))).thenReturn(actionFuture);
when(actionFuture.actionGet()).thenReturn(response);
when(response.getState()).thenReturn(state);
when(state.getMetaData()).thenReturn(metaData);
when(metaData.getIndices()).thenReturn(indicesMap);
}
示例7: refreshStatus
import org.elasticsearch.client.ClusterAdminClient; //导入依赖的package包/类
public void refreshStatus() {
TransportClient client = Elasticsearch.getClient();
ArrayList<TransportAddress> current_connected_nodes = convertList(client.connectedNodes());
if (current_connected_nodes.isEmpty()) {
return;
}
ClusterAdminClient cluster_admin_client = client.admin().cluster();
ClusterStatsRequestBuilder cluster_stats_request = cluster_admin_client.prepareClusterStats();
ClusterStatsResponse cluster_stats_response = cluster_stats_request.execute().actionGet();
last_status_reports = new LinkedHashMap<String, StatusReport>();
last_status_reports.put("clusterhealthstatus", new StatusReport("Cluster health status").addCell("Color", "Cluster", cluster_stats_response.getStatus().name()));
processHostsNodesLists(client.connectedNodes(), client.listedNodes(), client.filteredNodes());
processStats(cluster_stats_response.getIndicesStats());
processStats(cluster_stats_response.getNodesStats());
}
示例8: resolveAddresses
import org.elasticsearch.client.ClusterAdminClient; //导入依赖的package包/类
private void resolveAddresses() {
ClusterAdminClient cluster = client.admin().cluster();
cluster.prepareHealth().setWaitForYellowStatus().get();
NodesInfoResponse nodeInfos = cluster.prepareNodesInfo(NODE_NAME)
.setHttp(true).setTransport(true).get();
NodeInfo nodeInfo = nodeInfos.getAt(0);
httpAddress = addressToString(nodeInfo.getHttp().getAddress());
transportAddress = addressToString(nodeInfo.getTransport().getAddress());
}
示例9: main
import org.elasticsearch.client.ClusterAdminClient; //导入依赖的package包/类
public static void main(String[] args) {
try {
index();
//等待集群shard,防止No shard available for 异常
ClusterAdminClient clusterAdminClient = client.admin().cluster();
clusterAdminClient.prepareHealth().setWaitForYellowStatus().execute().actionGet(5000);
// analyze();
} catch (Exception e) {
log.error("main error:{}", e.getMessage());
}finally {
client.close();
}
}
示例10: getCurrentNode
import org.elasticsearch.client.ClusterAdminClient; //导入依赖的package包/类
private NodeInfo getCurrentNode() {
ClusterAdminClient cluster = client().admin().cluster();
return cluster
.prepareNodesInfo(cluster.prepareState().get().getState()
.getNodes().getLocalNodeId())
.get().getNodes().iterator().next();
}
示例11: waitForRiverEnabled
import org.elasticsearch.client.ClusterAdminClient; //导入依赖的package包/类
public static void waitForRiverEnabled(ClusterAdminClient client, String riverName, String riverType, int seconds) throws InterruptedException, IOException {
GetRiverStateRequest riverStateRequest = new GetRiverStateRequest()
.setRiverName(riverName)
.setRiverType(riverType);
GetRiverStateResponse riverStateResponse = client
.execute(GetRiverStateAction.INSTANCE, riverStateRequest).actionGet();
while (seconds-- > 0 && !isEnabled(riverName, riverStateResponse)) {
Thread.sleep(1000L);
try {
riverStateResponse = client.execute(GetRiverStateAction.INSTANCE, riverStateRequest).actionGet();
} catch (IndexMissingException e) {
// ignore
}
}
}
示例12: checkElasticSearchHealth
import org.elasticsearch.client.ClusterAdminClient; //导入依赖的package包/类
@Before
public void checkElasticSearchHealth() throws Throwable {
AdminClient admin = client.admin();
ClusterAdminClient cluster = admin.cluster();
ClusterHealthRequest request = new ClusterHealthRequest().waitForGreenStatus();
ActionFuture<ClusterHealthResponse> health = cluster.health(request);
ClusterHealthResponse healthResponse = health.get();
assertEquals(ClusterHealthStatus.GREEN, healthResponse.getStatus());
Operation operation = sequenceOf(StaticDataOperations.ALL_STATIC_DATA_ROWS,
ArtistU2Operations.RELEASE_GROUP_U2_ROWS);
DbSetup dbSetup = new DbSetup(new DataSourceDestination(dataSource),
operation);
dbSetup.launch();
}
示例13: newRequestBuilder
import org.elasticsearch.client.ClusterAdminClient; //导入依赖的package包/类
@Test
public void newRequestBuilder() {
ClusterAdminClient client = Mockito.mock(ClusterAdminClient.class);
JRLifecycleRequestBuilder rb = JRLifecycleAction.INSTANCE.newRequestBuilder(client);
Assert.assertNotNull(rb);
}
示例14: newRequestBuilder
import org.elasticsearch.client.ClusterAdminClient; //导入依赖的package包/类
@Test
public void newRequestBuilder() {
ClusterAdminClient client = Mockito.mock(ClusterAdminClient.class);
JRStateRequestBuilder rb = JRStateAction.INSTANCE.newRequestBuilder(client);
Assert.assertNotNull(rb);
}
示例15: newRequestBuilder
import org.elasticsearch.client.ClusterAdminClient; //导入依赖的package包/类
@Test
public void newRequestBuilder() {
ClusterAdminClient client = Mockito.mock(ClusterAdminClient.class);
IncrementalUpdateRequestBuilder rb = IncrementalUpdateAction.INSTANCE.newRequestBuilder(client);
Assert.assertNotNull(rb);
}