Package org.elasticsearch.node

Examples of org.elasticsearch.node.NodeBuilder


    }

    @Override
    @Singleton
    public Node get() {
        final NodeBuilder builder = nodeBuilder().client(true);
        Map<String, String> settings = readNodeSettings(configuration);

        builder.settings().put(settings);
        return builder.build();
    }


            return null;
        }
    }

    public Node buildNode() {
        NodeBuilder builder = nodeBuilder().local(isLocal()).data(isData());
        if (!isLocal() && getClusterName() != null) {
            builder.clusterName(getClusterName());
        }
        return builder.node();
    }

    /**
     * Constructor.  Initialize elastic and create the index/mapping
     */
    public ParentChildStressTest() {
        NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder();
        Settings settings = nodeBuilder.settings()
                .build();
        this.elasticNode = nodeBuilder.settings(settings).client(true).node();
        this.client = this.elasticNode.client();

        String mapping =
                "{\"contentFiles\": {" +
                        "\"_parent\": {" +

        if (tuple.v1().getAsBoolean("bootstrap.mlockall", false)) {
            Natives.tryMlockall();
        }
        tuple = setupJmx(tuple);

        NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder().settings(tuple.v1()).loadConfigSettings(false);
        node = nodeBuilder.build();
        if (addShutdownHook) {
            Runtime.getRuntime().addShutdownHook(new Thread() {
                @Override public void run() {
                    node.close();
                }

  public static boolean createIndex(String appid, int shards, int replicas) {
    if (StringUtils.isBlank(appid) || StringUtils.containsWhitespace(appid) || existsIndex(appid)) {
      return false;
    }
    try {
      NodeBuilder nb = NodeBuilder.nodeBuilder();
      nb.settings().put("number_of_shards", Integer.toString(shards));
      nb.settings().put("number_of_replicas", Integer.toString(replicas));
      nb.settings().put("auto_expand_replicas", "0-all");
      nb.settings().put("analysis.analyzer.default.type", "standard");
      nb.settings().putArray("analysis.analyzer.default.stopwords",
          "arabic", "armenian", "basque", "brazilian", "bulgarian", "catalan",
          "czech", "danish", "dutch", "english", "finnish", "french", "galician",
          "german", "greek", "hindi", "hungarian", "indonesian", "italian",
          "norwegian", "persian", "portuguese", "romanian", "russian", "spanish",
          "swedish", "turkish");

      String name = appid + "1";
      CreateIndexRequestBuilder create = getClient().admin().indices().prepareCreate(name).
          setSettings(nb.settings().build());

      // default system mapping (all the rest are dynamic)
      create.addMapping("_default_", getDefaultMapping());
      create.execute().actionGet();

            return null;
        }
    }

    public Node buildNode() {
        NodeBuilder builder = nodeBuilder().local(isLocal()).data(isData());
        if (!isLocal() && getClusterName() != null) {
            builder.clusterName(getClusterName());
        }
        return builder.node();
    }

import org.elasticsearch.common.settings.ImmutableSettings;


public class ElasticSearch {
  public static void main(String[] args) {
    NodeBuilder nb = NodeBuilder.nodeBuilder();

    nb.local(true);
    nb.settings(ImmutableSettings.settingsBuilder().loadFromClasspath("elasticsearch.yml"));
    nb.node();

    while (true) {
      try {
        Thread.currentThread().sleep(60000);
      } catch (Exception e) {

  public void afterPropertiesSet() throws Exception {
    internalCreateNode();
  }

  private void internalCreateNode() {
    final NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder();

    if (null != configLocation) {
      internalLoadSettings(nodeBuilder, configLocation);
    }

    if (null != configLocations) {
      for (final Resource location : configLocations) {
        internalLoadSettings(nodeBuilder, location);
      }
    }

    if (null != settings) {
      nodeBuilder.getSettings().put(settings);
    }

    node = nodeBuilder.node();
  }

//                put("gateway.type", "fs").
//                put("gateway.fs.location", homeDir.getAbsolutePath()).
        }

        settings.build();
        NodeBuilder nBuilder = nodeBuilder().settings(settings);
        if (!testing) {
            nBuilder.clusterName(CLUSTER);
        } else {
            nBuilder.local(true);
        }

        node = nBuilder.build().start();
       
        started = true;
        logger.info("Started Node in cluster " + CLUSTER + ". Home folder: " + homeDir.getAbsolutePath());
        return this;
    }

//                put("gateway.type", "fs").
//                put("gateway.fs.location", homeDir.getAbsolutePath()).
        }

        settings.build();
        NodeBuilder nBuilder = nodeBuilder().settings(settings);
        if (!testing) {
            nBuilder.clusterName(CLUSTER);
        } else {
            nBuilder.local(true);
        }

        node = nBuilder.build().start();
       
        started = true;
        logger.info("Started Node in cluster " + CLUSTER + ". Home folder: " + homeDir.getAbsolutePath());
        return this;
    }

TOP

Related Classes of org.elasticsearch.node.NodeBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.