當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。