add named writable registry glue

This commit is contained in:
Areek Zillur 2016-06-06 16:11:46 -04:00
parent 3a2cc22aff
commit d96fe20e3a
17 changed files with 56 additions and 103 deletions

View File

@ -19,10 +19,12 @@
package org.elasticsearch.indices; package org.elasticsearch.indices;
import org.elasticsearch.action.admin.indices.rollover.Condition;
import org.elasticsearch.action.update.UpdateHelper; import org.elasticsearch.action.update.UpdateHelper;
import org.elasticsearch.cluster.metadata.MetaDataIndexUpgradeService; import org.elasticsearch.cluster.metadata.MetaDataIndexUpgradeService;
import org.elasticsearch.common.geo.ShapesAvailability; import org.elasticsearch.common.geo.ShapesAvailability;
import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.index.NodeServicesProvider; import org.elasticsearch.index.NodeServicesProvider;
import org.elasticsearch.index.mapper.Mapper; import org.elasticsearch.index.mapper.Mapper;
import org.elasticsearch.index.mapper.MetadataFieldMapper; import org.elasticsearch.index.mapper.MetadataFieldMapper;
@ -74,10 +76,18 @@ public class IndicesModule extends AbstractModule {
// Use a LinkedHashMap for metadataMappers because iteration order matters // Use a LinkedHashMap for metadataMappers because iteration order matters
private final Map<String, MetadataFieldMapper.TypeParser> metadataMapperParsers private final Map<String, MetadataFieldMapper.TypeParser> metadataMapperParsers
= new LinkedHashMap<>(); = new LinkedHashMap<>();
private final NamedWriteableRegistry namedWritableRegistry;
public IndicesModule() { public IndicesModule(NamedWriteableRegistry namedWriteableRegistry) {
this.namedWritableRegistry = namedWriteableRegistry;
registerBuiltInMappers(); registerBuiltInMappers();
registerBuiltInMetadataMappers(); registerBuiltInMetadataMappers();
registerBuildInWritables();
}
private void registerBuildInWritables() {
namedWritableRegistry.register(Condition.class, Condition.MaxAge.NAME, Condition.MaxAge::new);
namedWritableRegistry.register(Condition.class, Condition.MaxDocs.NAME, Condition.MaxDocs::new);
} }
private void registerBuiltInMappers() { private void registerBuiltInMappers() {

View File

@ -235,7 +235,7 @@ public class Node implements Closeable {
modules.add(new ThreadPoolModule(threadPool)); modules.add(new ThreadPoolModule(threadPool));
modules.add(new DiscoveryModule(this.settings)); modules.add(new DiscoveryModule(this.settings));
modules.add(new ClusterModule(this.settings)); modules.add(new ClusterModule(this.settings));
modules.add(new IndicesModule()); modules.add(new IndicesModule(namedWriteableRegistry));
modules.add(new SearchModule(settings, namedWriteableRegistry)); modules.add(new SearchModule(settings, namedWriteableRegistry));
modules.add(new ActionModule(DiscoveryNode.isIngestNode(settings), false)); modules.add(new ActionModule(DiscoveryNode.isIngestNode(settings), false));
modules.add(new GatewayModule(settings)); modules.add(new GatewayModule(settings));

View File

@ -22,6 +22,7 @@ package org.elasticsearch.action.admin.indices.rollover;
import org.elasticsearch.action.admin.indices.alias.Alias; import org.elasticsearch.action.admin.indices.alias.Alias;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
@ -61,7 +62,7 @@ public class RolloverIT extends ESIntegTestCase {
index("test_index", "type1", "1", "field", "value"); index("test_index", "type1", "1", "field", "value");
flush("test_index"); flush("test_index");
final RolloverResponse response = client().admin().indices().prepareRolloverIndex("test_alias") final RolloverResponse response = client().admin().indices().prepareRolloverIndex("test_alias")
.addMaxIndexAgeCondition("7d").get(); .addMaxIndexAgeCondition(TimeValue.timeValueHours(4)).get();
assertThat(response.getOldIndex(), equalTo("test_index")); assertThat(response.getOldIndex(), equalTo("test_index"));
assertThat(response.getNewIndex(), equalTo("test_index")); assertThat(response.getNewIndex(), equalTo("test_index"));
final ClusterState state = client().admin().cluster().prepareState().get().getState(); final ClusterState state = client().admin().cluster().prepareState().get().getState();
@ -71,22 +72,6 @@ public class RolloverIT extends ESIntegTestCase {
assertNull(newIndex); assertNull(newIndex);
} }
public void testRolloverWithOptionalTargetAlias() throws Exception {
assertAcked(prepareCreate("test_index").addAlias(new Alias("test_alias")).get());
index("test_index", "type1", "1", "field", "value");
flush("test_index");
final RolloverResponse response = client().admin().indices().prepareRolloverIndex("test_alias")
.setOptionalTargetAlias("test_alias_2").get();
assertThat(response.getOldIndex(), equalTo("test_index"));
assertThat(response.getNewIndex(), equalTo("test_index-1"));
final ClusterState state = client().admin().cluster().prepareState().get().getState();
final IndexMetaData oldIndex = state.metaData().index("test_index");
assertFalse(oldIndex.getAliases().containsKey("test_alias"));
final IndexMetaData newIndex = state.metaData().index("test_index-1");
assertTrue(newIndex.getAliases().containsKey("test_alias"));
assertTrue(newIndex.getAliases().containsKey("test_alias_2"));
}
public void testRolloverOnExistingIndex() throws Exception { public void testRolloverOnExistingIndex() throws Exception {
assertAcked(prepareCreate("test_index").addAlias(new Alias("test_alias")).get()); assertAcked(prepareCreate("test_index").addAlias(new Alias("test_alias")).get());
index("test_index", "type1", "1", "field", "value"); index("test_index", "type1", "1", "field", "value");

View File

@ -27,59 +27,49 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.common.UUIDs; import org.elasticsearch.common.UUIDs;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.ESTestCase;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.Set;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.not;
public class TransportRolloverActionTests extends ESTestCase { public class TransportRolloverActionTests extends ESTestCase {
public void testSatisfyConditions() throws Exception { public void testSatisfyConditions() throws Exception {
List<Condition> conditions = Collections.emptyList(); Set<Condition> conditions = Collections.emptySet();
assertTrue(TransportRolloverAction.satisfiesConditions(conditions, randomLong(), randomLong(), assertTrue(TransportRolloverAction.satisfiesConditions(conditions, randomLong(),
randomLong())); randomLong()));
conditions = Collections.singletonList( conditions = Collections.singleton(new Condition.MaxAge(TimeValue.timeValueMillis(10)));
new Condition(Condition.ConditionType.MAX_AGE, 10L)); assertTrue(TransportRolloverAction.satisfiesConditions(conditions, randomLong(),
assertTrue(TransportRolloverAction.satisfiesConditions(conditions, randomLong(), randomLong(), TimeValue.timeValueMillis(randomIntBetween(10, 100)).getMillis()));
System.currentTimeMillis() - randomIntBetween(10, 100))); assertFalse(TransportRolloverAction.satisfiesConditions(conditions, randomLong(),
assertFalse(TransportRolloverAction.satisfiesConditions(conditions, randomLong(), randomLong(), TimeValue.timeValueMillis(randomIntBetween(0, 9)).getMillis()));
System.currentTimeMillis() - randomIntBetween(1, 9)));
conditions = Collections.singletonList( conditions = Collections.singleton(new Condition.MaxDocs(10L));
new Condition(Condition.ConditionType.MAX_SIZE, 10L)); assertTrue(TransportRolloverAction.satisfiesConditions(conditions, randomIntBetween(10, 100),
assertTrue(TransportRolloverAction.satisfiesConditions(conditions, randomLong(), randomIntBetween(10, 100),
randomLong())); randomLong()));
assertFalse(TransportRolloverAction.satisfiesConditions(conditions, randomLong(), randomIntBetween(1, 9), assertFalse(TransportRolloverAction.satisfiesConditions(conditions, randomIntBetween(1, 9),
randomLong())); randomLong()));
conditions = Collections.singletonList( conditions = Sets.newHashSet(new Condition.MaxAge(TimeValue.timeValueMillis(100)), new Condition.MaxDocs(1000L));
new Condition(Condition.ConditionType.MAX_DOCS, 10L));
assertTrue(TransportRolloverAction.satisfiesConditions(conditions, randomIntBetween(10, 100), randomLong(),
randomLong()));
assertFalse(TransportRolloverAction.satisfiesConditions(conditions, randomIntBetween(1, 9), randomLong(),
randomLong()));
conditions = Arrays.asList(new Condition(Condition.ConditionType.MAX_AGE, 100L),
new Condition(Condition.ConditionType.MAX_DOCS, 1000L));
assertTrue(TransportRolloverAction.satisfiesConditions(conditions, randomIntBetween(1000, 1500), assertTrue(TransportRolloverAction.satisfiesConditions(conditions, randomIntBetween(1000, 1500),
randomLong(), System.currentTimeMillis() - randomIntBetween(100, 500))); TimeValue.timeValueMillis(randomIntBetween(100, 1000)).getMillis()));
assertFalse(TransportRolloverAction.satisfiesConditions(conditions, randomIntBetween(1, 999), assertFalse(TransportRolloverAction.satisfiesConditions(conditions, randomIntBetween(1, 999),
randomLong(), System.currentTimeMillis() - randomIntBetween(100, 500))); TimeValue.timeValueMillis(randomIntBetween(100, 1000)).getMillis()));
assertFalse(TransportRolloverAction.satisfiesConditions(conditions, randomIntBetween(1000, 1500), assertFalse(TransportRolloverAction.satisfiesConditions(conditions, randomIntBetween(1000, 1500),
randomLong(), System.currentTimeMillis() - randomIntBetween(1, 99))); TimeValue.timeValueMillis(randomIntBetween(0, 99)).getMillis()));
} }
public void testCreateUpdateAliasRequest() throws Exception { public void testCreateUpdateAliasRequest() throws Exception {
String sourceAlias = randomAsciiOfLength(10); String sourceAlias = randomAsciiOfLength(10);
String sourceIndex = randomAsciiOfLength(10); String sourceIndex = randomAsciiOfLength(10);
String targetIndex = randomAsciiOfLength(10); String targetIndex = randomAsciiOfLength(10);
final RolloverRequest rolloverRequest = new RolloverRequest(sourceAlias, null); final RolloverRequest rolloverRequest = new RolloverRequest(sourceAlias);
final IndicesAliasesClusterStateUpdateRequest updateRequest = final IndicesAliasesClusterStateUpdateRequest updateRequest =
TransportRolloverAction.prepareIndicesAliasesRequest(sourceIndex, targetIndex, rolloverRequest); TransportRolloverAction.prepareIndicesAliasesRequest(sourceIndex, targetIndex, rolloverRequest);
@ -102,35 +92,6 @@ public class TransportRolloverActionTests extends ESTestCase {
assertTrue(foundRemove); assertTrue(foundRemove);
} }
public void testCreateUpdateAliasRequestWithOptionalTargetAlias() throws Exception {
String sourceAlias = randomAsciiOfLength(10);
String optionalTargetAlias = randomAsciiOfLength(10);
String sourceIndex = randomAsciiOfLength(10);
String targetIndex = randomAsciiOfLength(10);
final RolloverRequest rolloverRequest = new RolloverRequest(sourceAlias, optionalTargetAlias);
final IndicesAliasesClusterStateUpdateRequest updateRequest =
TransportRolloverAction.prepareIndicesAliasesRequest(sourceIndex, targetIndex, rolloverRequest);
final AliasAction[] actions = updateRequest.actions();
assertThat(actions.length, equalTo(3));
boolean foundAdd = false;
boolean foundRemove = false;
for (AliasAction action : actions) {
if (action.actionType() == AliasAction.Type.ADD) {
foundAdd = true;
assertThat(action.index(), equalTo(targetIndex));
assertThat(action.alias(), anyOf(equalTo(sourceAlias),
equalTo(optionalTargetAlias)));
} else if (action.actionType() == AliasAction.Type.REMOVE) {
foundRemove = true;
assertThat(action.index(), equalTo(sourceIndex));
assertThat(action.alias(), equalTo(sourceAlias));
}
}
assertTrue(foundAdd);
assertTrue(foundRemove);
}
public void testValidation() throws Exception { public void testValidation() throws Exception {
String index1 = randomAsciiOfLength(10); String index1 = randomAsciiOfLength(10);
String alias = randomAsciiOfLength(10); String alias = randomAsciiOfLength(10);
@ -154,31 +115,27 @@ public class TransportRolloverActionTests extends ESTestCase {
).build(); ).build();
try { try {
TransportRolloverAction.validate(metaData, new RolloverRequest(aliasWithMultipleIndices, TransportRolloverAction.validate(metaData, new RolloverRequest(aliasWithMultipleIndices));
randomBoolean() ? null : randomAsciiOfLength(10)));
fail("expected to throw exception"); fail("expected to throw exception");
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
assertThat(e.getMessage(), equalTo("source alias maps to multiple indices")); assertThat(e.getMessage(), equalTo("source alias maps to multiple indices"));
} }
try { try {
TransportRolloverAction.validate(metaData, new RolloverRequest(randomFrom(index1, index2), TransportRolloverAction.validate(metaData, new RolloverRequest(randomFrom(index1, index2)));
randomBoolean() ? null : randomAsciiOfLength(10)));
fail("expected to throw exception"); fail("expected to throw exception");
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
assertThat(e.getMessage(), equalTo("source alias is a concrete index")); assertThat(e.getMessage(), equalTo("source alias is a concrete index"));
} }
try { try {
TransportRolloverAction.validate(metaData, new RolloverRequest(randomAsciiOfLength(5), TransportRolloverAction.validate(metaData, new RolloverRequest(randomAsciiOfLength(5)));
randomBoolean() ? null : randomAsciiOfLength(10)));
fail("expected to throw exception"); fail("expected to throw exception");
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
assertThat(e.getMessage(), equalTo("source alias does not exist")); assertThat(e.getMessage(), equalTo("source alias does not exist"));
} }
TransportRolloverAction.validate(metaData, new RolloverRequest(alias, TransportRolloverAction.validate(metaData, new RolloverRequest(alias));
randomBoolean() ? null : randomAsciiOfLength(10)));
} }
public void testGenerateRolloverIndexName() throws Exception { public void testGenerateRolloverIndexName() throws Exception {

View File

@ -35,6 +35,7 @@ import org.elasticsearch.Version;
import org.elasticsearch.client.Client; import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.test.ClusterServiceUtils; import org.elasticsearch.test.ClusterServiceUtils;
import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Property; import org.elasticsearch.common.settings.Setting.Property;
@ -134,7 +135,7 @@ public class IndexModuleTests extends ESTestCase {
environment = new Environment(settings); environment = new Environment(settings);
nodeServicesProvider = newNodeServiceProvider(settings, environment, null); nodeServicesProvider = newNodeServiceProvider(settings, environment, null);
nodeEnvironment = new NodeEnvironment(settings, environment); nodeEnvironment = new NodeEnvironment(settings, environment);
mapperRegistry = new IndicesModule().getMapperRegistry(); mapperRegistry = new IndicesModule(new NamedWriteableRegistry()).getMapperRegistry();
} }
@Override @Override

View File

@ -58,6 +58,7 @@ import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.FileSystemUtils; import org.elasticsearch.common.io.FileSystemUtils;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.lucene.Lucene;
import org.elasticsearch.common.lucene.uid.Versions; import org.elasticsearch.common.lucene.uid.Versions;
@ -2015,7 +2016,7 @@ public class InternalEngineTests extends ESTestCase {
IndexSettings indexSettings = IndexSettingsModule.newIndexSettings(index, settings); IndexSettings indexSettings = IndexSettingsModule.newIndexSettings(index, settings);
AnalysisService analysisService = new AnalysisService(indexSettings, Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap()); AnalysisService analysisService = new AnalysisService(indexSettings, Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap());
SimilarityService similarityService = new SimilarityService(indexSettings, Collections.emptyMap()); SimilarityService similarityService = new SimilarityService(indexSettings, Collections.emptyMap());
MapperRegistry mapperRegistry = new IndicesModule().getMapperRegistry(); MapperRegistry mapperRegistry = new IndicesModule(new NamedWriteableRegistry()).getMapperRegistry();
MapperService mapperService = new MapperService(indexSettings, analysisService, similarityService, mapperRegistry, () -> null); MapperService mapperService = new MapperService(indexSettings, analysisService, similarityService, mapperRegistry, () -> null);
DocumentMapper.Builder b = new DocumentMapper.Builder(rootBuilder, mapperService); DocumentMapper.Builder b = new DocumentMapper.Builder(rootBuilder, mapperService);
this.docMapper = b.build(mapperService); this.docMapper = b.build(mapperService);

View File

@ -24,6 +24,7 @@ import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.IndexableField; import org.apache.lucene.index.IndexableField;
import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.compress.CompressedXContent; import org.elasticsearch.common.compress.CompressedXContent;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.IndexService; import org.elasticsearch.index.IndexService;
@ -234,7 +235,7 @@ public class FieldNamesFieldMapperTests extends ESSingleNodeTestCase {
public void testSeesFieldsFromPlugins() throws IOException { public void testSeesFieldsFromPlugins() throws IOException {
IndexService indexService = createIndex("test"); IndexService indexService = createIndex("test");
IndicesModule indicesModule = new IndicesModule(); IndicesModule indicesModule = new IndicesModule(new NamedWriteableRegistry());
indicesModule.registerMetadataMapper("_dummy", new DummyMetadataFieldMapper.TypeParser()); indicesModule.registerMetadataMapper("_dummy", new DummyMetadataFieldMapper.TypeParser());
final MapperRegistry mapperRegistry = indicesModule.getMapperRegistry(); final MapperRegistry mapperRegistry = indicesModule.getMapperRegistry();
MapperService mapperService = new MapperService(indexService.getIndexSettings(), indexService.analysisService(), indexService.similarityService(), mapperRegistry, indexService::newQueryShardContext); MapperService mapperService = new MapperService(indexService.getIndexSettings(), indexService.analysisService(), indexService.similarityService(), mapperRegistry, indexService::newQueryShardContext);

View File

@ -151,7 +151,7 @@ public class AggregatorParsingTests extends ESTestCase {
}; };
scriptModule.prepareSettings(settingsModule); scriptModule.prepareSettings(settingsModule);
injector = new ModulesBuilder().add(new EnvironmentModule(new Environment(settings)), settingsModule, injector = new ModulesBuilder().add(new EnvironmentModule(new Environment(settings)), settingsModule,
new ThreadPoolModule(threadPool), scriptModule, new IndicesModule() { new ThreadPoolModule(threadPool), scriptModule, new IndicesModule(namedWriteableRegistry) {
@Override @Override
protected void configure() { protected void configure() {

View File

@ -169,7 +169,7 @@ public abstract class BaseAggregationTestCase<AB extends AbstractAggregationBuil
settingsModule, settingsModule,
new ThreadPoolModule(threadPool), new ThreadPoolModule(threadPool),
scriptModule, scriptModule,
new IndicesModule() { new IndicesModule(namedWriteableRegistry) {
@Override @Override
protected void configure() { protected void configure() {

View File

@ -168,7 +168,7 @@ public abstract class BasePipelineAggregationTestCase<AF extends AbstractPipelin
settingsModule, settingsModule,
new ThreadPoolModule(threadPool), new ThreadPoolModule(threadPool),
scriptModule, scriptModule,
new IndicesModule() { new IndicesModule(namedWriteableRegistry) {
@Override @Override
protected void configure() { protected void configure() {

View File

@ -173,7 +173,7 @@ public class SearchSourceBuilderTests extends ESTestCase {
injector = new ModulesBuilder().add( injector = new ModulesBuilder().add(
new EnvironmentModule(new Environment(settings)), settingsModule, new EnvironmentModule(new Environment(settings)), settingsModule,
new ThreadPoolModule(threadPool), new ThreadPoolModule(threadPool),
scriptModule, new IndicesModule() { scriptModule, new IndicesModule(namedWriteableRegistry) {
@Override @Override
protected void configure() { protected void configure() {
bindMapperExtension(); bindMapperExtension();

View File

@ -134,7 +134,7 @@ public class TemplateQueryParserTests extends ESTestCase {
AnalysisService analysisService = new AnalysisRegistry(null, new Environment(settings)).build(idxSettings); AnalysisService analysisService = new AnalysisRegistry(null, new Environment(settings)).build(idxSettings);
ScriptService scriptService = injector.getInstance(ScriptService.class); ScriptService scriptService = injector.getInstance(ScriptService.class);
SimilarityService similarityService = new SimilarityService(idxSettings, Collections.emptyMap()); SimilarityService similarityService = new SimilarityService(idxSettings, Collections.emptyMap());
MapperRegistry mapperRegistry = new IndicesModule().getMapperRegistry(); MapperRegistry mapperRegistry = new IndicesModule(new NamedWriteableRegistry()).getMapperRegistry();
MapperService mapperService = new MapperService(idxSettings, analysisService, similarityService, mapperRegistry, () -> MapperService mapperService = new MapperService(idxSettings, analysisService, similarityService, mapperRegistry, () ->
contextFactory.get()); contextFactory.get());
IndicesFieldDataCache cache = new IndicesFieldDataCache(settings, new IndexFieldDataCache.Listener() {}); IndicesFieldDataCache cache = new IndicesFieldDataCache(settings, new IndexFieldDataCache.Listener() {});

View File

@ -21,6 +21,7 @@ package org.elasticsearch.mapper.attachments;
import org.elasticsearch.Version; import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment; import org.elasticsearch.env.Environment;
import org.elasticsearch.indices.IndicesModule; import org.elasticsearch.indices.IndicesModule;
@ -32,7 +33,7 @@ public abstract class AttachmentUnitTestCase extends ESTestCase {
protected Settings testSettings; protected Settings testSettings;
protected static IndicesModule getIndicesModuleWithRegisteredAttachmentMapper() { protected static IndicesModule getIndicesModuleWithRegisteredAttachmentMapper() {
IndicesModule indicesModule = new IndicesModule(); IndicesModule indicesModule = new IndicesModule(new NamedWriteableRegistry());
indicesModule.registerMapper(AttachmentMapper.CONTENT_TYPE, new AttachmentMapper.TypeParser()); indicesModule.registerMapper(AttachmentMapper.CONTENT_TYPE, new AttachmentMapper.TypeParser());
return indicesModule; return indicesModule;
} }

View File

@ -21,6 +21,7 @@ package org.elasticsearch.index.mapper.size;
import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.compress.CompressedXContent; import org.elasticsearch.common.compress.CompressedXContent;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.IndexService; import org.elasticsearch.index.IndexService;
import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.DocumentMapper;
@ -47,7 +48,7 @@ public class SizeMappingTests extends ESSingleNodeTestCase {
@Before @Before
public void before() { public void before() {
indexService = createIndex("test"); indexService = createIndex("test");
IndicesModule indices = new IndicesModule(); IndicesModule indices = new IndicesModule(new NamedWriteableRegistry());
indices.registerMetadataMapper(SizeFieldMapper.NAME, new SizeFieldMapper.TypeParser()); indices.registerMetadataMapper(SizeFieldMapper.NAME, new SizeFieldMapper.TypeParser());
mapperService = new MapperService(indexService.getIndexSettings(), indexService.analysisService(), indexService.similarityService(), indices.getMapperRegistry(), indexService::newQueryShardContext); mapperService = new MapperService(indexService.getIndexSettings(), indexService.analysisService(), indexService.similarityService(), indices.getMapperRegistry(), indexService::newQueryShardContext);
parser = mapperService.documentMapperParser(); parser = mapperService.documentMapperParser();

View File

@ -3,18 +3,13 @@
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-index.html", "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-index.html",
"methods": ["PUT", "POST"], "methods": ["PUT", "POST"],
"url": { "url": {
"path": "/{alias}/_rollover/{target_alias}", "path": "/{alias}/_rollover",
"paths": ["/{alias}/_rollover/{target_alias}"], "paths": ["/{alias}/_rollover", "/{alias}/_rollover/{target_alias}"],
"parts": { "parts": {
"alias": { "alias": {
"type" : "string", "type" : "string",
"required" : true, "required" : true,
"description" : "The name of the alias to rollover" "description" : "The name of the alias to rollover"
},
"target_alias": {
"type" : "string",
"required" : false,
"description" : "The name of optional target alias"
} }
}, },
"params": { "params": {

View File

@ -21,6 +21,7 @@ package org.elasticsearch.index;
import org.elasticsearch.Version; import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment; import org.elasticsearch.env.Environment;
import org.elasticsearch.index.analysis.AnalysisRegistry; import org.elasticsearch.index.analysis.AnalysisRegistry;
@ -39,7 +40,7 @@ import java.util.Collections;
public class MapperTestUtils { public class MapperTestUtils {
public static MapperService newMapperService(Path tempDir, Settings indexSettings) throws IOException { public static MapperService newMapperService(Path tempDir, Settings indexSettings) throws IOException {
IndicesModule indicesModule = new IndicesModule(); IndicesModule indicesModule = new IndicesModule(new NamedWriteableRegistry());
return newMapperService(tempDir, indexSettings, indicesModule); return newMapperService(tempDir, indexSettings, indicesModule);
} }

View File

@ -934,7 +934,7 @@ public abstract class AbstractQueryTestCase<QB extends AbstractQueryBuilder<QB>>
new EnvironmentModule(new Environment(settings)), new EnvironmentModule(new Environment(settings)),
settingsModule, settingsModule,
new ThreadPoolModule(threadPool), new ThreadPoolModule(threadPool),
new IndicesModule() { new IndicesModule(namedWriteableRegistry) {
@Override @Override
public void configure() { public void configure() {
// skip services // skip services