當前位置: 首頁>>代碼示例>>Java>>正文


Java PreBuiltTransportClient.addTransportAddress方法代碼示例

本文整理匯總了Java中org.elasticsearch.transport.client.PreBuiltTransportClient.addTransportAddress方法的典型用法代碼示例。如果您正苦於以下問題:Java PreBuiltTransportClient.addTransportAddress方法的具體用法?Java PreBuiltTransportClient.addTransportAddress怎麽用?Java PreBuiltTransportClient.addTransportAddress使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.transport.client.PreBuiltTransportClient的用法示例。


在下文中一共展示了PreBuiltTransportClient.addTransportAddress方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import org.elasticsearch.transport.client.PreBuiltTransportClient; //導入方法依賴的package包/類
/**
 * init
 * 
 * @param esAddrs
 * @param clusterName
 */
private void init(String[] esAddrs, String clusterName) {

    Settings settings = Settings.EMPTY;

    if (!StringHelper.isEmpty(clusterName)) {
        settings = Settings.builder().put("cluster.name", clusterName).build();
    }

    client = new PreBuiltTransportClient(settings);

    for (String esAddr : esAddrs) {
        String[] ipport = esAddr.split(":");
        client.addTransportAddress(new InetSocketTransportAddress(
                new InetSocketAddress(ipport[0], DataConvertHelper.toInt(ipport[1], 9300))));
    }
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:23,代碼來源:ESClient.java

示例2: ElasticNamespaceDAO

import org.elasticsearch.transport.client.PreBuiltTransportClient; //導入方法依賴的package包/類
public ElasticNamespaceDAO(ElasticDAOConfig config) {
	try {
		Builder builder = Settings.builder();
		// Check for new hosts within the cluster
		builder.put(CLIENT_SNIFFING_CONFIG, true);
		// specify cluster name
		if (config.getClusterName() != null) {
			builder.put(CLIENT_CLUSTER_NAME_CONFIG, config.getClusterName());
		}
		Settings settings = builder.build();
		// create client
		elasticClient = new PreBuiltTransportClient(settings);
		// add hosts
		for (String elasticHost : config.getHosts()) {
			elasticClient.addTransportAddress(
					new InetSocketTransportAddress(InetAddress.getByName(elasticHost), config.getPort()));
		}
	} catch (UnknownHostException e) {
		throw new RuntimeException("Unable to initialize Eleasticsearch client " + e.getLocalizedMessage());
	}
}
 
開發者ID:carone1,項目名稱:ecs-dashboard,代碼行數:22,代碼來源:ElasticNamespaceDAO.java

示例3: ElasticVdcDAO

import org.elasticsearch.transport.client.PreBuiltTransportClient; //導入方法依賴的package包/類
public ElasticVdcDAO(ElasticDAOConfig config) {
	try {
		Builder builder = Settings.builder();
		// Check for new hosts within the cluster
		builder.put(CLIENT_SNIFFING_CONFIG, true);
		// specify cluster name
		if (config.getClusterName() != null) {
			builder.put(CLIENT_CLUSTER_NAME_CONFIG, config.getClusterName());
		}
		Settings settings = builder.build();
		// create client
		elasticClient = new PreBuiltTransportClient(settings);
		// add hosts
		for (String elasticHost : config.getHosts()) {
			elasticClient.addTransportAddress(
					new InetSocketTransportAddress(InetAddress.getByName(elasticHost), config.getPort()));
		}
	} catch (UnknownHostException e) {
		throw new RuntimeException("Unable to initialize Eleasticsearch client " + e.getLocalizedMessage());
	}
}
 
開發者ID:carone1,項目名稱:ecs-dashboard,代碼行數:22,代碼來源:ElasticVdcDAO.java

示例4: createElasticsearchClient

import org.elasticsearch.transport.client.PreBuiltTransportClient; //導入方法依賴的package包/類
@Bean(name = "indexingElasticsearchClient")
public Client createElasticsearchClient() {
    String[] elasticsearchHosts = environment.getRequiredProperty("actor.indexing.elasticsearch.hosts", String[].class);
    Integer elasticsearchPort = environment.getProperty("actor.indexing.elasticsearch.port", Integer.class, 9300);
    String elasticsearchClusterName = environment.getProperty("actor.indexing.elasticsearch.cluster.name", String.class, "elasticsearch");

    logger.info(format("Creating elasticsearch client with hosts <%s>", Arrays.toString(elasticsearchHosts)));

    Settings settings = Settings.builder()
            .put("cluster.name", elasticsearchClusterName).build();

    client = new PreBuiltTransportClient(settings);

    for (String elasticsearchHost : elasticsearchHosts) {
        try {
            client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(elasticsearchHost), elasticsearchPort));
        } catch (UnknownHostException e) {
            throw new BeanCreationException("Could not add elasticsearch host <" + elasticsearchHost + "> to client configuration. Aborting", e);
        }
    }

    return client;
}
 
開發者ID:elasticsoftwarefoundation,項目名稱:elasticactors,代碼行數:24,代碼來源:IndexderAppConfig.java

示例5: prepare

import org.elasticsearch.transport.client.PreBuiltTransportClient; //導入方法依賴的package包/類
@Override
public void prepare(@SuppressWarnings("rawtypes") Map stormConf, TopologyContext context) {
	mapper = new ObjectMapper(); 
	Settings settings = Settings.builder().put("cluster.name", "my-application").build();
	preBuiltTransportClient = new PreBuiltTransportClient(settings);
	client = preBuiltTransportClient
			.addTransportAddress(new InetSocketTransportAddress(new InetSocketAddress("localhost", 9300)));
}
 
開發者ID:PacktPublishing,項目名稱:Practical-Real-time-Processing-and-Analytics,代碼行數:9,代碼來源:ElasticSearchBolt.java

示例6: prepare

import org.elasticsearch.transport.client.PreBuiltTransportClient; //導入方法依賴的package包/類
@Override
public void prepare(@SuppressWarnings("rawtypes") Map stormConf, TopologyContext context) {
	// instance a json mapper
	mapper = new ObjectMapper(); // create once, reuse
	Settings settings = Settings.builder()
			.put("cluster.name", "my-application").build();
	preBuiltTransportClient = new PreBuiltTransportClient(settings);
	client = preBuiltTransportClient.addTransportAddress(new InetSocketTransportAddress(new InetSocketAddress("localhost", 9300)));
}
 
開發者ID:PacktPublishing,項目名稱:Practical-Real-time-Processing-and-Analytics,代碼行數:10,代碼來源:ElasticSearchBolt.java

示例7: newClient

import org.elasticsearch.transport.client.PreBuiltTransportClient; //導入方法依賴的package包/類
private static void newClient() {
    logger.info("[elasticsearch.cluster.name -> " + clusterName + "]");
    logger.info("[elasticsearch.addresses -> " + addresses + "]");
    Settings settings = Settings.builder().put("client.transport.sniff", true).put("cluster.name", clusterName).build();
    transportClient = new PreBuiltTransportClient(settings);
    String[] addressArr = addresses.split(",");
    for (String address : addressArr) {
        String[] hostport = address.split(":");
        transportClient.addTransportAddress(new InetSocketTransportAddress(new InetSocketAddress(hostport[0], Integer.parseInt(hostport[1]))));
    }
    logger.info("elasticsearch client connection successful");
}
 
開發者ID:geeker-lait,項目名稱:tasfe-framework,代碼行數:13,代碼來源:ElasticsearchClient.java

示例8: createClient

import org.elasticsearch.transport.client.PreBuiltTransportClient; //導入方法依賴的package包/類
/**
   * This method will create the client instance for elastic search.
   * @param clusterName String
   * @param host  List<String>
   * @param port List<Integer>
   * @return boolean
   * @throws Exception
   */
private static boolean createClient(String clusterName, List<String> host, List<Integer> port) throws Exception {
	Builder builder = Settings.builder();
	if (clusterName != null && !"".equals(clusterName)) {
		builder = builder.put("cluster.name", clusterName);
	}
	builder = builder.put("client.transport.sniff", true);
	builder = builder.put("client.transport.ignore_cluster_name", true);
	client = new PreBuiltTransportClient(builder.build());
	for (int i = 0; i < host.size(); i++) {
		client.addTransportAddress(
				new InetSocketTransportAddress(InetAddress.getByName(host.get(i)), ports.get(i)));
	}
	return true;
}
 
開發者ID:project-sunbird,項目名稱:sunbird-utils,代碼行數:23,代碼來源:ConnectionManager.java

示例9: ElasticBillingDAO

import org.elasticsearch.transport.client.PreBuiltTransportClient; //導入方法依賴的package包/類
public ElasticBillingDAO(ElasticDAOConfig config) {
	
	try {
		
		Builder builder = Settings.builder();
		
		// Check for new hosts within the cluster
		builder.put(CLIENT_SNIFFING_CONFIG, true);
		
		// specify cluster name
		if( config.getClusterName() != null ) {
			builder.put(CLIENT_CLUSTER_NAME_CONFIG, config.getClusterName());
		}
		
		Settings settings = builder.build();
		
		// create client
		elasticClient = new PreBuiltTransportClient(settings);
		
		// add hosts
		for( String elasticHost : config.getHosts()) {
			elasticClient.addTransportAddress(
					new InetSocketTransportAddress(InetAddress.getByName(elasticHost), config.getPort()));				
		}
		
	} catch (UnknownHostException e) {
		throw new RuntimeException("Unable to initialize Eleasticsearch client " + e.getLocalizedMessage() );
	}				
}
 
開發者ID:carone1,項目名稱:ecs-dashboard,代碼行數:30,代碼來源:ElasticBillingDAO.java

示例10: init

import org.elasticsearch.transport.client.PreBuiltTransportClient; //導入方法依賴的package包/類
@PostConstruct
public void init() {
  Settings settings = Settings.builder()
      .put("cluster.name", properties.getElasticsearchCluster())
      .put("transport.type", "netty4")
      .build();
  elasticsearch = new PreBuiltTransportClient(settings);
  logger.info(" *** connecting to : {}:{}:{}",
      properties.getElasticsearchCluster(), properties.getElasticsearchHost(), properties.getElasticsearchNativePort());

  InetSocketAddress address = new InetSocketAddress(properties.getElasticsearchHost(), properties.getElasticsearchNativePort());
  InetSocketTransportAddress transport = new InetSocketTransportAddress(address);
  elasticsearch.addTransportAddress(transport);
}
 
開發者ID:the-james-burton,項目名稱:the-turbine,代碼行數:15,代碼來源:BaseElasticsearchNativeServiceImpl.java

示例11: init

import org.elasticsearch.transport.client.PreBuiltTransportClient; //導入方法依賴的package包/類
@PostConstruct
public void init() {
  Settings settings = Settings.builder()
      .put("cluster.name", cluster)
      .put("transport.type", "netty4")
      .build();
  elasticsearch = new PreBuiltTransportClient(settings);
  logger.info(" *** connecting to : {}:{}:{}", cluster, host, port);

  InetSocketAddress address = new InetSocketAddress(host, port);
  InetSocketTransportAddress transport = new InetSocketTransportAddress(address);
  elasticsearch.addTransportAddress(transport);
}
 
開發者ID:the-james-burton,項目名稱:the-turbine,代碼行數:14,代碼來源:ElasticsearchNativeServiceImpl.java

示例12: init

import org.elasticsearch.transport.client.PreBuiltTransportClient; //導入方法依賴的package包/類
@PostConstruct
public void init() {
  // Node node = NodeBuilder.nodeBuilder().clusterName("elasticsearch").client(true).node();
  String host = infrastructureProperties.getElasticsearchHost();
  String cluster = infrastructureProperties.getElasticsearchCluster();
  Integer port = infrastructureProperties.getElasticsearchNativePort();
  indexForTickers = infrastructureProperties.getElasticsearchIndexForTickers();
  typeForTickers = infrastructureProperties.getElasticsearchTypeForTickers();
  indexForTicks = infrastructureProperties.getElasticsearchIndexForTicks();
  typeForTicks = infrastructureProperties.getElasticsearchTypeForTicks();
  indexForIndicators = infrastructureProperties.getElasticsearchIndexForIndicators();
  typeForIndicators = infrastructureProperties.getElasticsearchTypeForIndicators();
  indexForStrategies = infrastructureProperties.getElasticsearchIndexForStrategies();
  typeForStrategies = infrastructureProperties.getElasticsearchTypeForStrategies();
  // Settings settings = Settings.settingsBuilder()
  Settings settings = Settings.builder()
      .put("cluster.name", cluster)
      .put("transport.type", "netty4")
      .build();
  // elasticsearch = new TransportClient(settings);
  // elasticsearch = TransportClient.builder().settings(settings).build();
  elasticsearch = new PreBuiltTransportClient(settings);
  logger.info(" *** connecting to : {}:{}:{}", cluster, host, port);

  InetSocketAddress address = new InetSocketAddress(host, port);
  InetSocketTransportAddress transport = new InetSocketTransportAddress(address);
  elasticsearch.addTransportAddress(transport);
}
 
開發者ID:the-james-burton,項目名稱:the-turbine,代碼行數:29,代碼來源:ElasticsearchNativeServiceImpl.java

示例13: ElasticsearchTransportClient

import org.elasticsearch.transport.client.PreBuiltTransportClient; //導入方法依賴的package包/類
/**
 * Hostname and port to talk to will be same server for now optionally we might want the IP to poll.
 * NOTE: This class shouldn't be a singleton and this shouldn't be cached.
 * This will work only if Elasticsearch runs.
 */
private ElasticsearchTransportClient(InetAddress host, IConfiguration configuration) {
    logger.info("Initializing client connection to {}", host.toString());

    Map<String, String> transportClientSettings = new HashMap<>();
    transportClientSettings.put("cluster.name", configuration.getAppName());

    client = new PreBuiltTransportClient(Settings.builder().put(transportClientSettings).build());
    client.addTransportAddress(new InetSocketTransportAddress(host, configuration.getTransportTcpPort()));

    nodeStatsRequestBuilder = client.admin().cluster().prepareNodesStats(configuration.getEsNodeName()).all();
}
 
開發者ID:Netflix,項目名稱:Raigad,代碼行數:17,代碼來源:ElasticsearchTransportClient.java

示例14: initClient

import org.elasticsearch.transport.client.PreBuiltTransportClient; //導入方法依賴的package包/類
public void initClient() throws UnknownHostException {
	Settings setting = Settings.builder().put("cluster.name", clustername).build();
	preBuiltTransportClient = new PreBuiltTransportClient(setting);
	client = preBuiltTransportClient
			.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(host), port));
}
 
開發者ID:jiashiwen,項目名稱:elasticbak,代碼行數:7,代碼來源:ElasticsearchConnector.java

示例15: ElasticS3ObjectDAO

import org.elasticsearch.transport.client.PreBuiltTransportClient; //導入方法依賴的package包/類
public ElasticS3ObjectDAO( ElasticDAOConfig config ) {
	
	try {
		this.config = config;
		
		
		Builder builder = Settings.builder();
		
		// Check for new hosts within the cluster
		builder.put(CLIENT_SNIFFING_CONFIG, true);
		
		// specify cluster name
		if( config.getClusterName() != null ) {
			builder.put(CLIENT_CLUSTER_NAME_CONFIG, config.getClusterName());
		}
		
		Settings settings = builder.build();
		
		// create client
		elasticClient = new PreBuiltTransportClient(settings);
		
		
		// add hosts
		for( String elasticHost : config.getHosts()) {
			elasticClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(elasticHost), config.getPort()));				
		}
		
		
	} catch (UnknownHostException e) {
		throw new RuntimeException(e.getLocalizedMessage());
	}				
}
 
開發者ID:carone1,項目名稱:ecs-dashboard,代碼行數:33,代碼來源:ElasticS3ObjectDAO.java


注:本文中的org.elasticsearch.transport.client.PreBuiltTransportClient.addTransportAddress方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。