当前位置: 首页>>代码示例>>Java>>正文


Java ClusterAdminClient类代码示例

本文整理汇总了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());
    }

}
 
开发者ID:ggj2010,项目名称:javabase,代码行数:23,代码来源:UpdateMappingFieldDemo.java

示例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());
    }
}
 
开发者ID:ggj2010,项目名称:javabase,代码行数:18,代码来源:UpdateMappingFieldDemo.java

示例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;
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:22,代码来源:EmbeddedServer.java

示例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");
    }
}
 
开发者ID:szwork2013,项目名称:elasticsearch-sentiment,代码行数:19,代码来源:RiverHelper.java

示例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");
    }
}
 
开发者ID:szwork2013,项目名称:elasticsearch-sentiment,代码行数:19,代码来源:RiverHelper.java

示例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);
}
 
开发者ID:cternes,项目名称:alfa,代码行数:20,代码来源:LogCleanerTest.java

示例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());
}
 
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:20,代码来源:ElasticsearchStatus.java

示例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());
}
 
开发者ID:gquintana,项目名称:beepbeep,代码行数:10,代码来源:EmbeddedElasticsearch.java

示例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();
    }
}
 
开发者ID:ggj2010,项目名称:javabase,代码行数:14,代码来源:CrudDemo.java

示例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();
}
 
开发者ID:JM-Lab,项目名称:utils-elasticsearch,代码行数:8,代码来源:JMEmbededElastricsearch.java

示例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
        }
    }
}
 
开发者ID:szwork2013,项目名称:elasticsearch-sentiment,代码行数:16,代码来源:RiverHelper.java

示例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();
}
 
开发者ID:arey,项目名称:musicbrainz-elasticsearch,代码行数:16,代码来源:TestMusicAlbumJob.java

示例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);
}
 
开发者ID:searchisko,项目名称:elasticsearch-river-remote,代码行数:8,代码来源:JRLifecycleActionTest.java

示例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);
}
 
开发者ID:searchisko,项目名称:elasticsearch-river-remote,代码行数:8,代码来源:JRStateActionTest.java

示例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);
}
 
开发者ID:searchisko,项目名称:elasticsearch-river-remote,代码行数:8,代码来源:IncrementalUpdateActionTest.java


注:本文中的org.elasticsearch.client.ClusterAdminClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。