本文整理汇总了Java中org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse类的典型用法代码示例。如果您正苦于以下问题:Java PutIndexTemplateResponse类的具体用法?Java PutIndexTemplateResponse怎么用?Java PutIndexTemplateResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PutIndexTemplateResponse类属于org.elasticsearch.action.admin.indices.template.put包,在下文中一共展示了PutIndexTemplateResponse类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: updateTemplate
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse; //导入依赖的package包/类
private ListenableFuture<Long> updateTemplate(Map<String, Object> newMappings,
Settings newSettings,
TableIdent tableIdent,
AbstractDDLAnalyzedStatement statement) {
String templateName = PartitionName.templateName(tableIdent.schema(), tableIdent.name());
IndexTemplateMetaData indexTemplateMetaData =
clusterService.state().metaData().templates().get(templateName);
if (indexTemplateMetaData == null) {
return Futures.immediateFailedFuture(new RuntimeException("Template for partitioned table is missing"));
}
// merge mappings
Map<String, Object> mapping = mergeTemplateMapping(indexTemplateMetaData, newMappings);
// merge settings
Settings.Builder settingsBuilder = Settings.builder();
settingsBuilder.put(indexTemplateMetaData.settings());
settingsBuilder.put(newSettings);
PutIndexTemplateRequest request = new PutIndexTemplateRequest(templateName)
.create(false)
.mapping(Constants.DEFAULT_MAPPING_TYPE, mapping)
.order(indexTemplateMetaData.order())
.settings(settingsBuilder.build())
.template(indexTemplateMetaData.template());
request.putHeader(LoginUserContext.USER_INFO_KEY, statement.getParameterContext().getLoginUserContext());
for (ObjectObjectCursor<String, AliasMetaData> container : indexTemplateMetaData.aliases()) {
Alias alias = new Alias(container.key);
request.alias(alias);
}
SettableFuture<Long> result = SettableFuture.create();
transportActionProvider.transportPutIndexTemplateAction().execute(request,
new SettableFutureToNullActionListener<PutIndexTemplateResponse>(result));
return result;
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:39,代码来源:AlterTableOperation.java
示例2: onResponse
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse; //导入依赖的package包/类
@Override
public void onResponse(PutIndexTemplateResponse putIndexTemplateResponse) {
if (putIndexTemplateResponse.isAcknowledged()) {
future.set(TaskResult.ONE_ROW);
} else {
future.set(TaskResult.ZERO);
}
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:9,代码来源:ESCreateTemplateTask.java
示例3: handleRequest
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse; //导入依赖的package包/类
@SuppressWarnings({"unchecked"})
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
PutIndexTemplateRequest putRequest = new PutIndexTemplateRequest(request.param("name"));
putRequest.template(request.param("template", putRequest.template()));
putRequest.order(request.paramAsInt("order", putRequest.order()));
putRequest.masterNodeTimeout(request.paramAsTime("master_timeout", putRequest.masterNodeTimeout()));
putRequest.create(request.paramAsBoolean("create", false));
putRequest.cause(request.param("cause", ""));
putRequest.source(request.content());
client.admin().indices().putTemplate(putRequest, new AcknowledgedRestListener<PutIndexTemplateResponse>(channel));
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:13,代码来源:RestPutIndexTemplateAction.java
示例4: configure
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse; //导入依赖的package包/类
public AsyncFuture<Void> configure() {
final IndicesAdminClient indices = client.getClient().admin().indices();
log.info("[{}] updating template for {}", templateName, index.template());
final PutIndexTemplateRequestBuilder put = indices.preparePutTemplate(templateName);
put.setSettings(type.getSettings());
put.setTemplate(index.template());
for (final Map.Entry<String, Map<String, Object>> mapping : type.getMappings().entrySet()) {
put.addMapping(mapping.getKey(), mapping.getValue());
}
final ResolvableFuture<Void> future = async.future();
final ListenableActionFuture<PutIndexTemplateResponse> target = put.execute();
target.addListener(new ActionListener<PutIndexTemplateResponse>() {
@Override
public void onResponse(final PutIndexTemplateResponse response) {
if (!response.isAcknowledged()) {
future.fail(new Exception("request not acknowledged"));
return;
}
future.resolve(null);
}
@Override
public void onFailure(Exception e) {
future.fail(e);
}
});
future.onCancelled(() -> target.cancel(false));
return future;
}
开发者ID:spotify,项目名称:heroic,代码行数:39,代码来源:Connection.java
示例5: run
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse; //导入依赖的package包/类
@Override
protected void run(Bootstrap<FoxtrotServerConfiguration> bootstrap,
Namespace namespace,
FoxtrotServerConfiguration configuration) throws Exception {
ElasticsearchConfig esConfig = configuration.getElasticsearch();
ElasticsearchConnection connection = new ElasticsearchConnection(esConfig);
connection.start();
ClusterHealthResponse clusterHealth = new ClusterHealthRequestBuilder(connection.getClient().admin().cluster())
.execute()
.get();
int numDataNodes = clusterHealth.getNumberOfDataNodes();
int numReplicas = (numDataNodes < 2) ? 0 : 1;
logger.info("# data nodes: {}, Setting replica count to: {}", numDataNodes, numReplicas);
createMetaIndex(connection, "consoles", numDataNodes - 1);
createMetaIndex(connection, "table-meta", numDataNodes - 1);
PutIndexTemplateResponse response = new PutIndexTemplateRequestBuilder(connection.getClient().admin().indices(), "template_foxtrot_mappings")
.setTemplate(String.format("%s-*",configuration.getElasticsearch().getTableNamePrefix()))
.setSettings(
ImmutableSettings.builder()
.put("number_of_shards", 10)
.put("number_of_replicas", numReplicas)
)
.addMapping("document", ElasticsearchUtils.getDocumentMapping())
.execute()
.get();
logger.info("Create mapping: {}", response.isAcknowledged());
logger.info("Creating hbase table");
HBaseUtil.createTable(configuration.getHbase(), configuration.getHbase().getTableName());
}
开发者ID:Flipkart,项目名称:foxtrot,代码行数:36,代码来源:InitializerCommand.java
示例6: open
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse; //导入依赖的package包/类
@Override
public void open(VDSConfiguration ctx) throws Exception {
_logger.info("Initializing ElasticSearch target");
_indexName = ctx.optString("index-name", "surf");
_typeName = ctx.optString("type-name", "http");
boolean useTemplate = ctx.optBoolean("use-template", true);
if(!_indexName.startsWith("surf") && useTemplate){
_logger.error("The index name *must* start with 'surf' if the default Surf template is used");
_logger.error("Either use an index-name starting with 'surf' or set use-template to false and provide your own template");
throw new IllegalArgumentException("Invalid index name for default template");
}
String cluster = ctx.optString("cluster-name", "elasticsearch");
_node = nodeBuilder()
.client(true)
.clusterName(cluster)
.node();
_client = _node.client();
_logger.info("ElasticSearch target initialized");
if(useTemplate){
InputStream stream = getClass().getResourceAsStream("/surf-template.json");
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte buf[] = new byte[1024];
while(stream.read(buf) > 0){
bos.write(buf);
}
stream.close();
bos.close();
byte [] template = bos.toByteArray();
PutIndexTemplateRequestBuilder req = _client.admin().indices().preparePutTemplate("surf-template")
.setSource(template);
PutIndexTemplateResponse resp = req.execute().actionGet();
if(resp.isAcknowledged()){
_logger.info("Template loaded");
}
}
else{
_logger.info("Default Surf template not loaded - make sure you have configured ElasticSearch correctly");
}
}
开发者ID:InformaticaCorp,项目名称:Surf,代码行数:40,代码来源:ElasticSearchTarget.java
示例7: toXContent
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse; //导入依赖的package包/类
@Override
protected XContentBuilder toXContent(PutIndexTemplateRequest request, PutIndexTemplateResponse response, XContentBuilder builder) throws IOException {
builder.startObject()
.field(Fields.OK, true)
.field(Fields.ACKNOWLEDGED, response.isAcknowledged())
.endObject();
return builder;
}
开发者ID:javanna,项目名称:elasticshell,代码行数:9,代码来源:PutIndexTemplateRequestBuilder.java
示例8: putTemplate
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse; //导入依赖的package包/类
@Override
public ActionFuture<PutIndexTemplateResponse> putTemplate(final PutIndexTemplateRequest request) {
return execute(PutIndexTemplateAction.INSTANCE, request);
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AbstractClient.java
示例9: createTemplate
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse; //导入依赖的package包/类
/**
* Create a template if needed
*
* @param template template name
* @param force force recreate template
* @throws Exception
*/
private void createTemplate(String template, boolean force)
throws Exception {
if (logger.isTraceEnabled()){
logger.trace("createTemplate(" + template + ")");
}
checkClient();
// If template already exists and if we are in force mode, we delete the template
if (force && isTemplateExist(template)) {
if (logger.isDebugEnabled()){
logger.debug("Force remove template [" + template + "]");
}
// Remove template in ElasticSearch !
client.admin()
.indices().prepareDeleteTemplate(template).execute()
.actionGet();
}
// Read the template json file if exists and use it
String source = readTemplate(template);
if (source != null) {
if (logger.isTraceEnabled()){
logger.trace("Template [" + template + "]=" + source);
}
// Create template
final PutIndexTemplateResponse response = client.admin().indices()
.preparePutTemplate(template).setSource(source).execute()
.actionGet();
if (!response.isAcknowledged()) {
throw new Exception("Could not define template [" + template
+ "].");
} else {
if (logger.isDebugEnabled()) {
logger.debug("Template [" + template
+ "] successfully created.");
}
}
} else {
if (logger.isWarnEnabled()) {
logger.warn("No template definition for [" + template
+ "]. Ignoring.");
}
}
if (logger.isTraceEnabled()){
logger.trace("/createTemplate(" + template + ")");
}
}
开发者ID:yamingd,项目名称:argo,代码行数:57,代码来源:ElasticsearchAbstractClientFactoryBean.java
示例10: doExecute
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse; //导入依赖的package包/类
@Override
protected ActionFuture<PutIndexTemplateResponse> doExecute(PutIndexTemplateRequest request) {
return client.admin().indices().putTemplate(request);
}
开发者ID:javanna,项目名称:elasticshell,代码行数:5,代码来源:PutIndexTemplateRequestBuilder.java
示例11: putTemplate
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse; //导入依赖的package包/类
/**
* Puts an index template.
*/
ActionFuture<PutIndexTemplateResponse> putTemplate(PutIndexTemplateRequest request);
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:IndicesAdminClient.java
注:本文中的org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论