本文整理匯總了Java中org.elasticsearch.node.NodeBuilder.node方法的典型用法代碼示例。如果您正苦於以下問題:Java NodeBuilder.node方法的具體用法?Java NodeBuilder.node怎麽用?Java NodeBuilder.node使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.elasticsearch.node.NodeBuilder
的用法示例。
在下文中一共展示了NodeBuilder.node方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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();
}
示例2: 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.");
}
}
示例3: start
import org.elasticsearch.node.NodeBuilder; //導入方法依賴的package包/類
public void start() throws Exception {
Map<String, String> properties = new HashMap<String, String>() ;
properties.put("cluster.name", "neverwinterdp");
properties.put("path.data", rtEnv.getDataDir() + "/elasticsearch");
logger.info(
"ElasticSearch default properties:\n" +
JSONSerializer.INSTANCE.toString(properties)
);
if(esProperties != null) {
properties.putAll(esProperties);
logger.info(
"ElasticSearch overrided properties:\n" +
JSONSerializer.INSTANCE.toString(properties)
);
}
if(moduleProperties.isDataDrop()) {
String dataDir = properties.get("path.data") ;
FileUtil.removeIfExist(dataDir, false);
logger.info("module.data.drop = true, clean data directory");
}
NodeBuilder nb = nodeBuilder();
for(Map.Entry<String, String> entry : properties.entrySet()) {
nb.getSettings().put(entry.getKey(), entry.getValue());
}
server = nb.node();
}
示例4: setup
import org.elasticsearch.node.NodeBuilder; //導入方法依賴的package包/類
@Before
public void setup() throws Exception {
FileUtil.removeIfExist("build/data", false);
NodeBuilder nb = nodeBuilder();
nb.getSettings().put("cluster.name", "neverwinterdp");
nb.getSettings().put("path.data", "build/data");
node = nb.node();
esclient = new ESClient(new String[] { "127.0.0.1:9300" });
esObjecclient = new ESObjectClient<Map<String, Object>>(esclient, "index", Record.class) ;
}
示例5: start
import org.elasticsearch.node.NodeBuilder; //導入方法依賴的package包/類
private void start() {
log.info("Starting Elastic Search");
NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder().local(true);
nodeBuilder.getSettings().put("network.host", "127.0.0.1");
node = nodeBuilder.node();
client = node.client();
log.info("Started Elastic Search");
}
示例6: startup
import org.elasticsearch.node.NodeBuilder; //導入方法依賴的package包/類
public void startup() {
// NodeBuilder nodeBuilder = new NodeBuilder();
// NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder();
//是否加載配置文件
//NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder().loadConfigSettings(true);
//cluster.name in elasticsearch.yml
//NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder().clusterName("yourclustername")
//是否隻作為客戶端,即不存儲索引數據,默認值為false
NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder().client(true);
Node node = nodeBuilder.node();
client = node.client();
}
示例7: createClient
import org.elasticsearch.node.NodeBuilder; //導入方法依賴的package包/類
private Node createClient(Settings defaultSettings,Configuration config) {
NodeBuilder builder = nodeBuilder().clusterName(config.getStorageClusterName()).data(false).client(true);
// load the pre-packaged defaults
builder.getSettings().loadFromClasspath(defaultConfigFileName);
// Set the default cluster name from the configuration, then possibility to override
// from the given settings object. Then once again the possibility to override from
// the xml filenames
builder.settings(defaultSettings);
// load the overrides on the classpath
builder.getSettings().loadFromClasspath(configFileName);
return builder.node();
}