org.elasticsearch.node
Class NodeBuilder

java.lang.Object
  extended by org.elasticsearch.node.NodeBuilder

public class NodeBuilder
extends Object

A node builder is used to construct a Node instance.

Settings will be loaded relative to the ES home (with or without config/ prefix) and if not found, within the classpath (with or without config/ prefix). The settings file loaded can either be named elasticsearch.yml or elasticsearch.json). Loading settings can be disabled by calling loadConfigSettings(boolean) with false.

Explicit settings can be passed by using the settings(Settings) method.

In any case, settings will be resolved from system properties as well that are either prefixed with es. or elasticsearch..

An example for creating a simple node with optional settings loaded from the classpath:

 Node node = NodeBuilder.nodeBuilder().node();
 

An example for creating a node with explicit settings (in this case, a node in the cluster that does not hold data):

 Node node = NodeBuilder.nodeBuilder()
                      .settings(ImmutableSettings.settingsBuilder().put("node.data", false)
                      .node();
 

When done with the node, make sure you call Node.close() on it.


Constructor Summary
NodeBuilder()
           
 
Method Summary
 Node build()
          Builds the node without starting it.
 NodeBuilder client(boolean client)
          Is the node going to be a client node which means it will hold no data (node.data is set to false) and other optimizations by different modules.
 NodeBuilder clusterName(String clusterName)
          The cluster name this node is part of (maps to the cluster.name setting).
 NodeBuilder data(boolean data)
          Is the node going to be allowed to allocate data (shards) to it or not.
 ImmutableSettings.Builder getSettings()
          Set addition settings simply by working directly against the settings builder.
 NodeBuilder loadConfigSettings(boolean loadConfigSettings)
          Should the node builder automatically try and load config settings from the file system / classpath.
 NodeBuilder local(boolean local)
          Is the node a local node.
 Node node()
          build()s and starts the node.
static NodeBuilder nodeBuilder()
          A convenient factory method to create a NodeBuilder.
 ImmutableSettings.Builder settings()
          Set addition settings simply by working directly against the settings builder.
 NodeBuilder settings(Settings.Builder settings)
          Explicit node settings to set.
 NodeBuilder settings(Settings settings)
          Explicit node settings to set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeBuilder

public NodeBuilder()
Method Detail

nodeBuilder

public static NodeBuilder nodeBuilder()
A convenient factory method to create a NodeBuilder.


settings

public ImmutableSettings.Builder settings()
Set addition settings simply by working directly against the settings builder.


getSettings

public ImmutableSettings.Builder getSettings()
Set addition settings simply by working directly against the settings builder.


settings

public NodeBuilder settings(Settings.Builder settings)
Explicit node settings to set.


settings

public NodeBuilder settings(Settings settings)
Explicit node settings to set.


loadConfigSettings

public NodeBuilder loadConfigSettings(boolean loadConfigSettings)
Should the node builder automatically try and load config settings from the file system / classpath. Defaults to true.


client

public NodeBuilder client(boolean client)
Is the node going to be a client node which means it will hold no data (node.data is set to false) and other optimizations by different modules.

Parameters:
client - Should the node be just a client node or not.

data

public NodeBuilder data(boolean data)
Is the node going to be allowed to allocate data (shards) to it or not. This setting map to the node.data setting. Note, when setting client(boolean), the node will not hold any data by default.

Parameters:
data - Should the node be allocated data to or not.

local

public NodeBuilder local(boolean local)
Is the node a local node. A local node is a node that uses a local (JVM level) discovery and transport. Other (local) nodes started within the same JVM (actually, class-loader) will be discovered and communicated with. Nodes outside of the JVM will not be discovered.

Parameters:
local - Should the node be local or not

clusterName

public NodeBuilder clusterName(String clusterName)
The cluster name this node is part of (maps to the cluster.name setting). Defaults to elasticsearch.

Parameters:
clusterName - The cluster name this node is part of.

build

public Node build()
Builds the node without starting it.


node

public Node node()
build()s and starts the node.



Copyright © 2009-2012. All Rights Reserved.