当前位置: 首页>>代码示例>>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;未经允许,请勿转载。