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


Java NodeBuilder类代码示例

本文整理汇总了Java中org.elasticsearch.node.NodeBuilder的典型用法代码示例。如果您正苦于以下问题:Java NodeBuilder类的具体用法?Java NodeBuilder怎么用?Java NodeBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NodeBuilder类属于org.elasticsearch.node包,在下文中一共展示了NodeBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import org.elasticsearch.node.NodeBuilder; //导入依赖的package包/类
public static synchronized void start(String clusterName, String host, int port, boolean enableTransportClient) throws Exception{

		if (instance != null && !instance.isClosed()) {
			logger.info("Elastic Search is already running on port {}", getPort());
			return;
		}

		final Settings settings = getSettings(clusterName, host, port, enableTransportClient);
		setupDataDir(settings);

		logger.info("Starting ElasticSearch for cluster {} ", settings.get("cluster.name"));
		instance = NodeBuilder.nodeBuilder().data(true).local(enableTransportClient ? false : true).settings(settings).client(false).node();
		instance.start();
		Runtime.getRuntime().addShutdownHook(new Thread() {
			@Override
			public void run() {
				instance.close();
			}
		});
		logger.info("ElasticSearch cluster {} started in local mode on port {}", instance.settings().get("cluster.name"), getPort());
		client = instance.client();
	}
 
开发者ID:Netflix,项目名称:conductor,代码行数:23,代码来源:EmbeddedElasticSearch.java

示例2: EsEmbeddedServer

import org.elasticsearch.node.NodeBuilder; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public EsEmbeddedServer(String clusterName, String homePath, String dataPath, String httpRange, String transportRange, boolean hasSlave) {
    Properties props = new Properties();
    props.setProperty("path.home", homePath);
    props.setProperty("path.data", dataPath);
    props.setProperty("http.port", httpRange);
    props.setProperty("transport.tcp.port", transportRange);
    props.setProperty("cluster.name", "es.hadoop.test");
    props.setProperty("node.local", "true");
    //props.setProperty("es.index.store.type", "memory");
    // props.setProperty("gateway.type", "none");
    if (!hasSlave) {
        props.setProperty("discovery.zen.ping.multicast", "false");
        props.setProperty("discovery.zen.ping.multicast.enabled", "false");
    }
    //props.setProperty("script.disable_dynamic", "false");
    props.setProperty("script.inline", "true");
    props.setProperty("script.indexed", "true");

    Settings settings = NodeBuilder.nodeBuilder().local(false).client(false).settings(Settings.settingsBuilder().put(props).build()).clusterName(clusterName).getSettings().build();
    Collection plugins = Arrays.asList(GroovyPlugin.class);
    node = new PluginConfigurableNode(settings, plugins);
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:24,代码来源:EsEmbeddedServer.java

示例3: start

import org.elasticsearch.node.NodeBuilder; //导入依赖的package包/类
@Override
public void start() {
    // Start embedded Elasticsearch node
    ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder();
    settings.put("node.name", "test-node");
    settings.put("path.data", "build/data");

    m_node = NodeBuilder.nodeBuilder()
            .settings(settings)
            .clusterName("test-cluster")
            .data(true)
            .local(true)
            .node();
    m_client = m_node.client();

    // Start polling for index count
    m_timerId = vertx.setPeriodic(1000L, this);
    // Start tests
    super.start();
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:21,代码来源:ElasticsearchTest.java

示例4: before

import org.elasticsearch.node.NodeBuilder; //导入依赖的package包/类
@Override
protected void before() throws Throwable {
    boolean startEs = Boolean.valueOf(
            Optional.ofNullable(
                    System.getProperty(SYSTEM_PROPERTY_START_ES))
            .orElse(startElasticsearch.toString()));
    if (startEs) {
        String fileName = "elasticsearch-it.yml";
        Settings settings = Settings.settingsBuilder().loadFromStream(fileName, getClass().getResourceAsStream(fileName)).build();
        cluster = settings.get("cluster.name");

        embeddedNode = NodeBuilder.nodeBuilder().settings(settings).build();
        embeddedNode.start();
        client = embeddedNode.client();
        System.out.println(String.format("### Elasticsearch server '%s' started ###", cluster));
    }
}
 
开发者ID:52North,项目名称:youngs,代码行数:18,代码来源:ElasticsearchServer.java

示例5: setupClass

import org.elasticsearch.node.NodeBuilder; //导入依赖的package包/类
@BeforeClass
public static void setupClass() throws UIMAException{
	Path tmpDir;
	
	try{
		tmpDir = Files.createTempDirectory("elasticsearch");
	}catch(IOException ioe){
		throw new ResourceInitializationException(ioe);
	}
	
	Settings settings = Settings.builder()
			.put("path.home", tmpDir.toString())
			.build();
	
	node = NodeBuilder.nodeBuilder()
			.settings(settings)
			.data(false)
			.local(true)
			.client(true)
			.node();
}
 
开发者ID:dstl,项目名称:baleen,代码行数:22,代码来源:SharedElasticsearchResourceTest.java

示例6: doInitialize

import org.elasticsearch.node.NodeBuilder; //导入依赖的package包/类
@Override
protected boolean doInitialize(ResourceSpecifier specifier, Map<String, Object> additionalParams) throws ResourceInitializationException {
	try{
		tmpDir = Files.createTempDirectory("elasticsearch");
	}catch(IOException ioe){
		throw new ResourceInitializationException(ioe);
	}
	
	Settings settings = Settings.builder()
			.put("path.home", tmpDir.toString())
			.build();
	node = NodeBuilder.nodeBuilder()
			.settings(settings)
			.data(true)
			.local(true)
			.clusterName("test_cluster")
			.node();
	
	return true;
}
 
开发者ID:dstl,项目名称:baleen,代码行数:21,代码来源:SharedLocalElasticsearchResource.java

示例7: setupLocalElasticsearch

import org.elasticsearch.node.NodeBuilder; //导入依赖的package包/类
@BeforeClass
public static void setupLocalElasticsearch() throws UIMAException {
	// Initialise a local instance of Elasticsearch
	try {
		tmpDir = Files.createTempDirectory("elasticsearch");
	} catch (IOException ioe) {
		throw new ResourceInitializationException(ioe);
	}

	// Don't use the default ports for testing purposes
	Settings settings = Settings.builder().put("path.home", tmpDir.toString()).put("http.port", "29200")
			.put("transport.tcp.port", "29300").build();

	node = NodeBuilder.nodeBuilder().settings(settings).data(true).local(true).clusterName("test_cluster").node();

	client = node.client();
}
 
开发者ID:dstl,项目名称:baleen,代码行数:18,代码来源:ElasticsearchTemplateRecordConsumerTest.java

示例8: getElasticSearchNode

import org.elasticsearch.node.NodeBuilder; //导入依赖的package包/类
@Bean(name = "appSearchElasticNode", destroyMethod = "close")
public Node getElasticSearchNode(
        @Value("${elastic.hosts}") String hosts,
        @Value("${elastic.cluster.name}") String clusterName,
        @Value("${elastic.node.local}") boolean localMode) {

    NodeBuilder builder = nodeBuilder().clusterName(clusterName);

    if (localMode) {
        builder.local(true);
    } else {
        builder.settings(
                ImmutableSettings.builder()
                        .put("discovery.zen.ping.unicast.hosts", hosts)
                        .put("discovery.zen.ping.multicast.enabled", false)
                        .put("node.client", true)
                        .put("node.master", false)
                        .put("node.data", false));
    }

    return builder.node();
}
 
开发者ID:bpatters,项目名称:eservice,代码行数:23,代码来源:CommonBeans.java

示例9: getClient

import org.elasticsearch.node.NodeBuilder; //导入依赖的package包/类
public Client getClient() {
    if (client == null) {
        log.log(Level.INFO, "Elastic client doesn't exists, creating new one");
        if (node == null) {
            log.log(Level.INFO, "Elastic client node doesn't exists, creating new one");
            node = NodeBuilder.nodeBuilder()
                    .settings(ImmutableSettings.settingsBuilder()
                                    .put("http.enabled", false)
                                    .put("network.host", "_" + System.getenv("SINKIT_NIC") + ":ipv4_")
                                    .putArray("discovery.zen.ping.unicast.hosts", System.getenv("SINKIT_ELASTIC_HOST") + ":" + System.getenv("SINKIT_ELASTIC_PORT"))
                                    .put("cluster.name", System.getenv("SINKIT_ELASTIC_CLUSTER"))
                                    .put("discovery.zen.ping.multicast.enabled", true)
                                    .put("discovery.zen.ping.timeout", "3s")
                                    .put("discovery.zen.minimum_master_nodes", 1)
                    )
                    .client(true)
                    .data(false)
                    .node();
        }
        client = node.client();
    }
    return client;
}
 
开发者ID:whalebone,项目名称:sinkit-core,代码行数:24,代码来源:ElasticClientProvider.java

示例10: initSetting

import org.elasticsearch.node.NodeBuilder; //导入依赖的package包/类
public void initSetting() throws IOException {
  settings = settingsBuilder()
      .put("index.store.type", "memory")
      .put("gateway.type", "none")
      .put("path.data", "src/main/resources/esPath")
      // .put("discovery.zen.ping.unicast.hosts", "host1:9300,host2:9300")
      .build();

  node = NodeBuilder.nodeBuilder()
      .clusterName("wcrESCluster")
      .settings(settings)
      .local(true) // not join existing cluster on the network.
      .node();

  client = node.client();
}
 
开发者ID:faustineinsun,项目名称:WiseCrowdRec,代码行数:17,代码来源:JavaApiElasticsearchManipulator.java

示例11: startESNode

import org.elasticsearch.node.NodeBuilder; //导入依赖的package包/类
private static Node startESNode(String clusterName)
{

    Settings nodeSettings = Settings.settingsBuilder()
    		.put("path.home", "target")
    		.put("transport.tcp.port", "9600-9700")
            .put("http.port", "9500")
            .put("http.max_content_length", "100M").build();

    Node node = NodeBuilder.nodeBuilder()
    		.settings(nodeSettings)
    		.clusterName(clusterName).node();

    node.start();

    return node;
}
 
开发者ID:WedjaaOpen,项目名称:ElasticParser,代码行数:18,代码来源:ESSearchTest.java

示例12: start

import org.elasticsearch.node.NodeBuilder; //导入依赖的package包/类
public static void start() throws Exception {
    ImmutableSettings.Builder settings = config.loadSettings();
    if (config.isLocalMode()) {
        Logger.info("ElasticSearch : Starting in Local Mode");

        NodeBuilder nb = nodeBuilder().settings(settings).local(true).client(false).data(true);
        node = nb.node();
        Logger.info("ElasticSearch : Started in Local Mode");
    }

    client = JestClientWrapper.jestClient(config);

    // Check Client
    if (client == null) {
        throw new Exception("ElasticSearch Client cannot be null - please check the configuration provided and the health of your ElasticSearch instances.");
    }
}
 
开发者ID:CedricGatay,项目名称:play2-elasticsearch-jest,代码行数:18,代码来源:IndexClient.java

示例13: startLocalNode

import org.elasticsearch.node.NodeBuilder; //导入依赖的package包/类
private ElasticClient startLocalNode(String clusterName, boolean refresh, int version) {
    final ImmutableSettings.Builder builder = ImmutableSettings.settingsBuilder()
            .put("node.name", applicationName + "-local-node" + System.currentTimeMillis()).put("node.data", true)
            .put("cluster.name", clusterName).put("index.store.type", "memory")
            .put("index.store.fs.memory.enabled", "true").put("gateway.type", "none")
            .put("path.data", "./local-cluster/" + clusterName + "/data")
            .put("path.work", "./local-cluster/" + clusterName + "/work")
            .put("path.logs", "./local-cluster/" + clusterName + "/logs").put("index.number_of_shards", "1")
            .put("index.number_of_replicas", "0").put("cluster.routing.schedule", "50ms");
    final Node localNode = NodeBuilder.nodeBuilder().settings(builder).node();

    final Client client = localNode.client();
    client.admin().cluster().prepareHealth().setWaitForYellowStatus().setTimeout(TimeValue.timeValueMinutes(1))
            .execute().actionGet();
    return new ElasticClient(client, applicationName, refresh, version);
}
 
开发者ID:ezbake,项目名称:ezelastic,代码行数:17,代码来源:EzElasticHandler.java

示例14: initClient

import org.elasticsearch.node.NodeBuilder; //导入依赖的package包/类
private void initClient() {

    ImmutableSettings.Builder settingsBuilder = ImmutableSettings.settingsBuilder();
    settingsBuilder.put(ImmutableSettings.Builder.EMPTY_SETTINGS);//keep default classloader
    settingsBuilder.put(meta.getSettings());
    Settings settings = settingsBuilder.build();
    
    if(meta.getServers().length > 0){
      node = null;
      TransportClient tClient = new TransportClient(settings);
      for(InetSocketTransportAddress address : meta.getServers()){
        tClient.addTransportAddress(address);
      }
      client = tClient;
      
    }
    else {
      NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder();
      nodeBuilder.settings(settings);
      node = nodeBuilder.client(true).node();// this node will not hold data
      client = node.client();
      node.start();
    }
  }
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:25,代码来源:ElasticSearchBulk.java

示例15: createNodes

import org.elasticsearch.node.NodeBuilder; //导入依赖的package包/类
void createNodes() throws Exception {
  Settings settings = ImmutableSettings
      .settingsBuilder()
      .put("number_of_shards", 1)
      .put("number_of_replicas", 0)
      .put("routing.hash.type", "simple")
      .put("gateway.type", "none")
      .put("path.data", "target/es-test")
      .build();

  node = NodeBuilder.nodeBuilder().settings(settings).local(true).node();
  client = node.client();

  client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute()
      .actionGet();
}
 
开发者ID:Stratio,项目名称:ingestion,代码行数:17,代码来源:AbstractElasticSearchSinkTest.java


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