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