Package org.elasticsearch.node

Examples of org.elasticsearch.node.NodeBuilder


    @BeforeClass
    public static void setUpBeforeClass() throws Exception
    {
        ImmutableSettings.Builder builder = ImmutableSettings.settingsBuilder();
        builder.put("path.data", "target/data");
        node = new NodeBuilder().settings(builder).node();
    }


    {
        if (!checkIfServerRunning())
        {
          ImmutableSettings.Builder builder = ImmutableSettings.settingsBuilder();
          builder.put("path.data", "target/data");
          node = new NodeBuilder().settings(builder).node();
        }
        _PU = "es-pu";
        setUpInternal();
    }

  public boolean isSingleton() {
    return true;
  }

  private Node initialize() {
    final NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder();

    if (null != settings && null == properties) {
      logger.warn("settings has been deprecated in favor of properties. See issue #15: https://github.com/dadoonet/spring-elasticsearch/issues/15.");
      nodeBuilder.getSettings().put(settings);
    }

    if (null != settingsFile && null == properties) {
      Settings settings = ImmutableSettings.settingsBuilder()
          .loadFromClasspath(this.settingsFile)
          .build();
      nodeBuilder.getSettings().put(settings);
    }

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

    if (logger.isDebugEnabled()) logger.debug("Starting ElasticSearch node...");
    node = nodeBuilder.node();
    logger.info("Node [" + node.settings().get("name") + "] for [" + node.settings().get("cluster.name") + "] cluster started...");
    if (logger.isDebugEnabled()) logger.debug("  - data : " + node.settings().get("path.data"));
    if (logger.isDebugEnabled()) logger.debug("  - logs : " + node.settings().get("path.logs"));

    return node;

    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);

        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) {
    if (StringUtils.isBlank(appid) || StringUtils.containsWhitespace(appid) || existsIndex(appid)) {
      return false;
    }
    try {
      NodeBuilder nb = NodeBuilder.nodeBuilder();
      nb.settings().put("number_of_shards", Config.getConfigParam("para.es.shards", "5"));
      nb.settings().put("number_of_replicas", Config.getConfigParam("para.es.replicas", "0"));
      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();

        // Check Model
        if (this.isLocalMode()) {
            Logger.info("ElasticSearch : Starting in Local Mode");

            NodeBuilder nb = nodeBuilder().settings(settings).local(true).client(false).data(true);
            node = nb.node();
            client = node.client();
            Logger.info("ElasticSearch : Started in Local Mode");
        } else {
            Logger.info("ElasticSearch : Starting in Client Mode");
            TransportClient c = new TransportClient(settings);

        // Prepare the configuration of the elastic search node
        Settings settings = loadSettings();

        // Configure and start the elastic search node. In a testing scenario,
        // the node is being created locally.
        NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder().settings(settings);
        elasticSearch = nodeBuilder.local(TestUtils.isTest()).build();
        elasticSearch.start();
      }
    }

    // Create the client

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.