本文整理汇总了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();
}
示例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);
}
示例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();
}
示例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));
}
}
示例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();
}
示例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;
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}
示例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;
}
示例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.");
}
}
示例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);
}
示例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();
}
}
示例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();
}