本文整理汇总了Java中org.elasticsearch.cluster.metadata.IndexTemplateMetaData类的典型用法代码示例。如果您正苦于以下问题:Java IndexTemplateMetaData类的具体用法?Java IndexTemplateMetaData怎么用?Java IndexTemplateMetaData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IndexTemplateMetaData类属于org.elasticsearch.cluster.metadata包,在下文中一共展示了IndexTemplateMetaData类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: wipeAllTemplates
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; //导入依赖的package包/类
/**
* Removes all templates, except the templates defined in the exclude
*/
public void wipeAllTemplates(Set<String> exclude) {
if (size() > 0) {
GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates().get();
for (IndexTemplateMetaData indexTemplate : response.getIndexTemplates()) {
if (exclude.contains(indexTemplate.getName())) {
continue;
}
try {
client().admin().indices().prepareDeleteTemplate(indexTemplate.getName()).execute().actionGet();
} catch (IndexTemplateMissingException e) {
// ignore
}
}
}
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:TestCluster.java
示例2: buildTable
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; //导入依赖的package包/类
private Table buildTable(RestRequest request, ClusterStateResponse clusterStateResponse, String patternString) {
Table table = getTableWithHeader(request);
MetaData metadata = clusterStateResponse.getState().metaData();
for (ObjectObjectCursor<String, IndexTemplateMetaData> entry : metadata.templates()) {
IndexTemplateMetaData indexData = entry.value;
if (patternString == null || Regex.simpleMatch(patternString, indexData.name())) {
table.startRow();
table.addCell(indexData.name());
table.addCell("[" + String.join(", ", indexData.patterns()) + "]");
table.addCell(indexData.getOrder());
table.addCell(indexData.getVersion());
table.endRow();
}
}
return table;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:RestTemplatesAction.java
示例3: masterOperation
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; //导入依赖的package包/类
@Override
protected void masterOperation(GetIndexTemplatesRequest request, ClusterState state, ActionListener<GetIndexTemplatesResponse> listener) {
List<IndexTemplateMetaData> results;
// If we did not ask for a specific name, then we return all templates
if (request.names().length == 0) {
results = Arrays.asList(state.metaData().templates().values().toArray(IndexTemplateMetaData.class));
} else {
results = new ArrayList<>();
}
for (String name : request.names()) {
if (Regex.isSimpleMatchPattern(name)) {
for (ObjectObjectCursor<String, IndexTemplateMetaData> entry : state.metaData().templates()) {
if (Regex.simpleMatch(name, entry.key)) {
results.add(entry.value);
}
}
} else if (state.metaData().templates().containsKey(name)) {
results.add(state.metaData().templates().get(name));
}
}
listener.onResponse(new GetIndexTemplatesResponse(results));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:TransportGetIndexTemplatesAction.java
示例4: testClusterStateSerialization
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; //导入依赖的package包/类
public void testClusterStateSerialization() throws Exception {
MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder("test_idx").settings(settings(Version.CURRENT)).numberOfShards(10).numberOfReplicas(1))
.put(IndexTemplateMetaData.builder("test_template").build())
.build();
RoutingTable routingTable = RoutingTable.builder()
.addAsNew(metaData.index("test_idx"))
.build();
DiscoveryNodes nodes = DiscoveryNodes.builder().add(new DiscoveryNode("node_foo", buildNewFakeTransportAddress(),
emptyMap(), emptySet(), Version.CURRENT)).localNodeId("node_foo").masterNodeId("node_foo").build();
ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).nodes(nodes)
.metaData(metaData).routingTable(routingTable).build();
AllocationService strategy = createAllocationService();
clusterState = ClusterState.builder(clusterState).routingTable(strategy.reroute(clusterState, "reroute").routingTable()).build();
String clusterStateString = Strings.toString(clusterState);
assertNotNull(clusterStateString);
assertThat(clusterStateString, containsString("test_idx"));
assertThat(clusterStateString, containsString("test_template"));
assertThat(clusterStateString, containsString("node_foo"));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:ClusterStateToStringTests.java
示例5: mergeTemplateMapping
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; //导入依赖的package包/类
private Map<String, Object> mergeTemplateMapping(IndexTemplateMetaData templateMetaData,
Map<String, Object> newMapping) {
Map<String, Object> mergedMapping = new HashMap<>();
for (ObjectObjectCursor<String, CompressedXContent> cursor : templateMetaData.mappings()) {
try {
Map<String, Object> mapping = parseMapping(cursor.value.toString());
Object o = mapping.get(Constants.DEFAULT_MAPPING_TYPE);
assert o != null && o instanceof Map;
XContentHelper.update(mergedMapping, (Map) o, false);
} catch (IOException e) {
// pass
}
}
XContentHelper.update(mergedMapping, newMapping, false);
return mergedMapping;
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:18,代码来源:AlterTableOperation.java
示例6: assertIndexTemplateMissing
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; //导入依赖的package包/类
/**
* Assert that an index template is missing
*/
public static void assertIndexTemplateMissing(GetIndexTemplatesResponse templatesResponse, String name) {
List<String> templateNames = new ArrayList<>();
for (IndexTemplateMetaData indexTemplateMetaData : templatesResponse.getIndexTemplates()) {
templateNames.add(indexTemplateMetaData.name());
}
assertThat(templateNames, not(hasItem(name)));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:ElasticsearchAssertions.java
示例7: assertIndexTemplateExists
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; //导入依赖的package包/类
/**
* Assert that an index template exists
*/
public static void assertIndexTemplateExists(GetIndexTemplatesResponse templatesResponse, String name) {
List<String> templateNames = new ArrayList<>();
for (IndexTemplateMetaData indexTemplateMetaData : templatesResponse.getIndexTemplates()) {
templateNames.add(indexTemplateMetaData.name());
}
assertThat(templateNames, hasItem(name));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:ElasticsearchAssertions.java
示例8: readFrom
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
int size = in.readVInt();
indexTemplates = new ArrayList<>(size);
for (int i = 0 ; i < size ; i++) {
indexTemplates.add(0, IndexTemplateMetaData.readFrom(in));
}
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:GetIndexTemplatesResponse.java
示例9: writeTo
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; //导入依赖的package包/类
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeVInt(indexTemplates.size());
for (IndexTemplateMetaData indexTemplate : indexTemplates) {
indexTemplate.writeTo(out);
}
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:GetIndexTemplatesResponse.java
示例10: toXContent
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; //导入依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
params = new ToXContent.DelegatingMapParams(singletonMap("reduce_mappings", "true"), params);
builder.startObject();
for (IndexTemplateMetaData indexTemplateMetaData : getIndexTemplates()) {
IndexTemplateMetaData.Builder.toXContent(indexTemplateMetaData, builder, params);
}
builder.endObject();
return builder;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:GetIndexTemplatesResponse.java
示例11: updateTemplate
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; //导入依赖的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
示例12: handleRequest
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
final String[] names = Strings.splitStringByCommaToArray(request.param("name"));
GetIndexTemplatesRequest getIndexTemplatesRequest = new GetIndexTemplatesRequest(names);
getIndexTemplatesRequest.local(request.paramAsBoolean("local", getIndexTemplatesRequest.local()));
getIndexTemplatesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getIndexTemplatesRequest.masterNodeTimeout()));
final boolean implicitAll = getIndexTemplatesRequest.names().length == 0;
client.admin().indices().getTemplates(getIndexTemplatesRequest, new RestBuilderListener<GetIndexTemplatesResponse>(channel) {
@Override
public RestResponse buildResponse(GetIndexTemplatesResponse getIndexTemplatesResponse, XContentBuilder builder) throws Exception {
boolean templateExists = getIndexTemplatesResponse.getIndexTemplates().size() > 0;
Map<String, String> paramsMap = Maps.newHashMap();
paramsMap.put("reduce_mappings", "true");
ToXContent.Params params = new ToXContent.DelegatingMapParams(paramsMap, request);
builder.startObject();
for (IndexTemplateMetaData indexTemplateMetaData : getIndexTemplatesResponse.getIndexTemplates()) {
IndexTemplateMetaData.Builder.toXContent(indexTemplateMetaData, builder, params);
}
builder.endObject();
RestStatus restStatus = (templateExists || implicitAll) ? OK : NOT_FOUND;
return new BytesRestResponse(restStatus, builder);
}
});
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:32,代码来源:RestGetIndexTemplateAction.java
示例13: readFrom
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
int size = in.readVInt();
indexTemplates = new ArrayList<>(size);
for (int i = 0 ; i < size ; i++) {
indexTemplates.add(0, IndexTemplateMetaData.Builder.readFrom(in));
}
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:10,代码来源:GetIndexTemplatesResponse.java
示例14: testThatTemplateIsAdded
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; //导入依赖的package包/类
@Test
public void testThatTemplateIsAdded() throws Exception {
GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates("metrics_template").get();
assertThat(response.getIndexTemplates(), hasSize(1));
IndexTemplateMetaData templateData = response.getIndexTemplates().get(0);
assertThat(templateData.order(), is(0));
assertThat(templateData.getMappings().get("_default_"), is(notNullValue()));
}
开发者ID:elastic,项目名称:elasticsearch-metrics-reporter-java,代码行数:10,代码来源:ElasticsearchReporterTest.java
示例15: testThatTemplateIsNotOverWritten
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; //导入依赖的package包/类
@Test
public void testThatTemplateIsNotOverWritten() throws Exception {
client().admin().indices().preparePutTemplate("metrics_template").setTemplate("foo*").setSettings("{ \"index.number_of_shards\" : \"1\"}").execute().actionGet();
elasticsearchReporter = createElasticsearchReporterBuilder().build();
GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates("metrics_template").get();
assertThat(response.getIndexTemplates(), hasSize(1));
IndexTemplateMetaData templateData = response.getIndexTemplates().get(0);
assertThat(templateData.template(), is("foo*"));
}
开发者ID:elastic,项目名称:elasticsearch-metrics-reporter-java,代码行数:13,代码来源:ElasticsearchReporterTest.java
示例16: isTemplateExist
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; //导入依赖的package包/类
/**
* Check if a template already exists
*
* @param template template name
* @return true if template exists
*/
private boolean isTemplateExist(String template) {
ClusterState cs = client.admin().cluster().prepareState()
.setFilterIndexTemplates(template).execute().actionGet()
.getState();
final IndexTemplateMetaData mdd = cs.getMetaData().templates()
.get(template);
if (mdd != null) return true;
return false;
}
开发者ID:yamingd,项目名称:argo,代码行数:17,代码来源:ElasticsearchAbstractClientFactoryBean.java
示例17: GetIndexTemplatesResponse
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; //导入依赖的package包/类
GetIndexTemplatesResponse(List<IndexTemplateMetaData> indexTemplates) {
this.indexTemplates = indexTemplates;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:GetIndexTemplatesResponse.java
示例18: getIndexTemplates
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; //导入依赖的package包/类
public List<IndexTemplateMetaData> getIndexTemplates() {
return indexTemplates;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:GetIndexTemplatesResponse.java
示例19: testOldSnapshot
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; //导入依赖的package包/类
private void testOldSnapshot(String version, String repo, String snapshot) throws IOException {
logger.info("--> get snapshot and check its version");
GetSnapshotsResponse getSnapshotsResponse = client().admin().cluster().prepareGetSnapshots(repo).setSnapshots(snapshot).get();
assertThat(getSnapshotsResponse.getSnapshots().size(), equalTo(1));
SnapshotInfo snapshotInfo = getSnapshotsResponse.getSnapshots().get(0);
assertThat(snapshotInfo.version().toString(), equalTo(version));
logger.info("--> restoring snapshot");
RestoreSnapshotResponse response = client().admin().cluster().prepareRestoreSnapshot(repo, snapshot).setRestoreGlobalState(true).setWaitForCompletion(true).get();
assertThat(response.status(), equalTo(RestStatus.OK));
RestoreInfo restoreInfo = response.getRestoreInfo();
assertThat(restoreInfo.successfulShards(), greaterThan(0));
assertThat(restoreInfo.successfulShards(), equalTo(restoreInfo.totalShards()));
assertThat(restoreInfo.failedShards(), equalTo(0));
String index = restoreInfo.indices().get(0);
logger.info("--> check search");
SearchResponse searchResponse = client().prepareSearch(index).get();
assertThat(searchResponse.getHits().getTotalHits(), greaterThan(1L));
logger.info("--> check settings");
ClusterState clusterState = client().admin().cluster().prepareState().get().getState();
assertThat(clusterState.metaData().persistentSettings().get(FilterAllocationDecider.CLUSTER_ROUTING_EXCLUDE_GROUP_SETTING.getKey() + "version_attr"), equalTo(version));
logger.info("--> check templates");
IndexTemplateMetaData template = clusterState.getMetaData().templates().get("template_" + version.toLowerCase(Locale.ROOT));
assertThat(template, notNullValue());
assertThat(template.patterns(), equalTo(Collections.singletonList("te*")));
assertThat(template.settings().getAsInt(IndexMetaData.SETTING_NUMBER_OF_SHARDS, -1), equalTo(1));
assertThat(template.mappings().size(), equalTo(1));
assertThat(template.mappings().get("type1").string(),
anyOf(
equalTo("{\"type1\":{\"_source\":{\"enabled\":false}}}"),
equalTo("{\"type1\":{\"_source\":{\"enabled\":\"false\"}}}"),
equalTo("{\"type1\":{\"_source\":{\"enabled\":\"0\"}}}"),
equalTo("{\"type1\":{\"_source\":{\"enabled\":0}}}"),
equalTo("{\"type1\":{\"_source\":{\"enabled\":\"off\"}}}"),
equalTo("{\"type1\":{\"_source\":{\"enabled\":\"no\"}}}")
));
assertThat(template.aliases().size(), equalTo(3));
assertThat(template.aliases().get("alias1"), notNullValue());
assertThat(template.aliases().get("alias2").filter().string(), containsString(version));
assertThat(template.aliases().get("alias2").indexRouting(), equalTo("kimchy"));
assertThat(template.aliases().get("{index}-alias"), notNullValue());
logger.info("--> cleanup");
cluster().wipeIndices(restoreInfo.indices().toArray(new String[restoreInfo.indices().size()]));
cluster().wipeTemplates();
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:51,代码来源:RestoreBackwardsCompatIT.java
示例20: create
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; //导入依赖的package包/类
public static GetIndexTemplatesResponse create(List<IndexTemplateMetaData> metaData) {
return new GetIndexTemplatesResponse(metaData);
}
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:4,代码来源:GetIndexTemplatesResponseAccessor.java
注:本文中的org.elasticsearch.cluster.metadata.IndexTemplateMetaData类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论